diff options
author | Martin Felke <martin.felke@googlemail.com> | 2018-09-01 00:08:00 +0300 |
---|---|---|
committer | Martin Felke <martin.felke@googlemail.com> | 2018-09-01 00:08:00 +0300 |
commit | 63bf87364c0402e19e10004bdbf7756cbd8e84a2 (patch) | |
tree | 84e51af0e1954cf00691b54f2c798e537a094247 | |
parent | 433fac8f1e85286d008f634f5b18f5d4dc123937 (diff) | |
parent | ac9e1e692cecc98f3547386cfee5eb7d9df3b8a4 (diff) |
Merge remote-tracking branch 'origin/blender2.8' into fracture_modifier-2.8
# Conflicts:
# release/scripts/addons
605 files changed, 15477 insertions, 6410 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c2e9ab69a7..0379dff2db8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,6 +166,7 @@ option_defaults_init( _init_SDL _init_FFTW3 _init_OPENSUBDIV + _init_SYSTEM_OPENJPG ) # customize... @@ -182,11 +183,13 @@ if(UNIX AND NOT APPLE) set(_init_SDL OFF) set(_init_FFTW3 OFF) set(_init_OPENSUBDIV OFF) + set(_init_SYSTEM_OPENJPG OFF) elseif(WIN32) set(_init_JACK OFF) elseif(APPLE) set(_init_JACK OFF) set(_init_OPENSUBDIV OFF) + set(_init_SYSTEM_OPENJPG OFF) endif() @@ -298,7 +301,7 @@ endif() # (unix defaults to System OpenJPEG On) -option(WITH_SYSTEM_OPENJPEG "Use the operating systems OpenJPEG library" OFF) +option(WITH_SYSTEM_OPENJPEG "Use the operating systems OpenJPEG library" ${_init_SYSTEM_OPENJPG}) if(UNIX AND NOT APPLE) option(WITH_SYSTEM_EIGEN3 "Use the systems Eigen3 library" OFF) @@ -1448,6 +1451,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") # warning level: "/W3" "/w34062" # switch statement contains 'default' but no 'case' labels + "/w34189" # local variable is initialized but not referenced # disable: "/wd4018" # signed/unsigned mismatch "/wd4146" # unary minus operator applied to unsigned type, result still unsigned diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt index 81810e3e457..5270a2e2b3d 100644 --- a/build_files/build_environment/CMakeLists.txt +++ b/build_files/build_environment/CMakeLists.txt @@ -137,4 +137,12 @@ if(NOT WIN32 OR ENABLE_MINGW64) endif() endif() +if(UNIX AND NOT APPLE) + include(cmake/bzip2.cmake) + include(cmake/ffi.cmake) + include(cmake/lzma.cmake) + include(cmake/ssl.cmake) + include(cmake/sqlite.cmake) +endif() + include(cmake/harvest.cmake) diff --git a/build_files/build_environment/cmake/alembic.cmake b/build_files/build_environment/cmake/alembic.cmake index 4c0caecf335..e6323d53661 100644 --- a/build_files/build_environment/cmake/alembic.cmake +++ b/build_files/build_environment/cmake/alembic.cmake @@ -26,6 +26,12 @@ if(ALEMBIC_HDF5) endif() endif() +if(WIN32) + set(ALEMBIC_ILMBASE ${LIBDIR}/openexr) +else() + set(ALEMBIC_ILMBASE ${LIBDIR}/ilmbase) +endif() + set(ALEMBIC_EXTRA_ARGS -DBUILDSTATIC=ON -DLINKSTATIC=ON @@ -38,13 +44,13 @@ set(ALEMBIC_EXTRA_ARGS -DBoost_DEBUG=ON -DBOOST_ROOT=${LIBDIR}/boost -DBoost_NO_SYSTEM_PATHS=ON - -DILMBASE_ROOT=${LIBDIR}/openexr - -DALEMBIC_ILMBASE_INCLUDE_DIRECTORY=${LIBDIR}/openexr/include/OpenEXR - -DALEMBIC_ILMBASE_HALF_LIB=${LIBDIR}/openexr/lib/${LIBPREFIX}Half${ILMBASE_VERSION_POSTFIX}${LIBEXT} - -DALEMBIC_ILMBASE_IMATH_LIB=${LIBDIR}/openexr/lib/${LIBPREFIX}Imath${ILMBASE_VERSION_POSTFIX}${LIBEXT} - -DALEMBIC_ILMBASE_ILMTHREAD_LIB=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmThread${ILMBASE_VERSION_POSTFIX}${LIBEXT} - -DALEMBIC_ILMBASE_IEX_LIB=${LIBDIR}/openexr/lib/${LIBPREFIX}Iex${ILMBASE_VERSION_POSTFIX}${LIBEXT} - -DALEMBIC_ILMBASE_IEXMATH_LIB=${LIBDIR}/openexr/lib/${LIBPREFIX}IexMath${ILMBASE_VERSION_POSTFIX}${LIBEXT} + -DILMBASE_ROOT=${ALEMBIC_ILMBASE} + -DALEMBIC_ILMBASE_INCLUDE_DIRECTORY=${ALEMBIC_ILMBASE}/include/OpenEXR + -DALEMBIC_ILMBASE_HALF_LIB=${ALEMBIC_ILMBASE}/lib/${LIBPREFIX}Half${ILMBASE_VERSION_POSTFIX}${LIBEXT} + -DALEMBIC_ILMBASE_IMATH_LIB=${ALEMBIC_ILMBASE}/lib/${LIBPREFIX}Imath${ILMBASE_VERSION_POSTFIX}${LIBEXT} + -DALEMBIC_ILMBASE_ILMTHREAD_LIB=${ALEMBIC_ILMBASE}/lib/${LIBPREFIX}IlmThread${ILMBASE_VERSION_POSTFIX}${LIBEXT} + -DALEMBIC_ILMBASE_IEX_LIB=${ALEMBIC_ILMBASE}/lib/${LIBPREFIX}Iex${ILMBASE_VERSION_POSTFIX}${LIBEXT} + -DALEMBIC_ILMBASE_IEXMATH_LIB=${ALEMBIC_ILMBASE}/lib/${LIBPREFIX}IexMath${ILMBASE_VERSION_POSTFIX}${LIBEXT} -DUSE_PYILMBASE=0 -DUSE_PYALEMBIC=0 -DUSE_ARNOLD=0 diff --git a/build_files/build_environment/cmake/blosc.cmake b/build_files/build_environment/cmake/blosc.cmake index b0a0460aa94..18f258357c9 100644 --- a/build_files/build_environment/cmake/blosc.cmake +++ b/build_files/build_environment/cmake/blosc.cmake @@ -26,6 +26,7 @@ set(BLOSC_EXTRA_ARGS -DPTHREAD_LIBS=${LIBDIR}/pthreads/lib/pthreadVC2.lib -DPTHREAD_INCLUDE_DIR=${LIBDIR}/pthreads/inc -DDEACTIVATE_SNAPPY=ON + -DCMAKE_POSITION_INDEPENDENT_CODE=ON ) if(WIN32) diff --git a/build_files/build_environment/cmake/boost.cmake b/build_files/build_environment/cmake/boost.cmake index 959a6e22637..33bfa1d4e82 100644 --- a/build_files/build_environment/cmake/boost.cmake +++ b/build_files/build_environment/cmake/boost.cmake @@ -63,6 +63,11 @@ else() set(BOOST_BUILD_COMMAND ./b2) set(BOOST_BUILD_OPTIONS cxxflags=${PLATFORM_CXXFLAGS} --disable-icu boost.locale.icu=off) set(BOOST_PATCH_COMMAND echo .) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(BOOST_ADDRESS_MODEL 64) + else() + set(BOOST_ADDRESS_MODEL 32) + endif() endif() set(BOOST_OPTIONS diff --git a/build_files/build_environment/cmake/bzip2.cmake b/build_files/build_environment/cmake/bzip2.cmake new file mode 100644 index 00000000000..6c515d10d61 --- /dev/null +++ b/build_files/build_environment/cmake/bzip2.cmake @@ -0,0 +1,39 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +set(BZIP2_PREFIX "${LIBDIR}/bzip2") +set(BZIP2_CONFIGURE_ENV echo .) +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}) +endif() + +ExternalProject_Add(external_bzip2 + URL ${BZIP2_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${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 + INSTALL_DIR ${LIBDIR}/bzip2 +) diff --git a/build_files/build_environment/cmake/ffi.cmake b/build_files/build_environment/cmake/ffi.cmake new file mode 100644 index 00000000000..18531fd7906 --- /dev/null +++ b/build_files/build_environment/cmake/ffi.cmake @@ -0,0 +1,38 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +ExternalProject_Add(external_ffi + URL ${FFI_URI} + URL_HASH SHA256=${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 + 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 + 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 + DEPENDEES install + ) +endif() diff --git a/build_files/build_environment/cmake/ffmpeg.cmake b/build_files/build_environment/cmake/ffmpeg.cmake index b1e69b794df..5c8347cd40e 100644 --- a/build_files/build_environment/cmake/ffmpeg.cmake +++ b/build_files/build_environment/cmake/ffmpeg.cmake @@ -18,13 +18,6 @@ set(FFMPEG_CFLAGS "-I${mingw_LIBDIR}/lame/include -I${mingw_LIBDIR}/openjpeg/include/ -I${mingw_LIBDIR}/ogg/include -I${mingw_LIBDIR}/vorbis/include -I${mingw_LIBDIR}/theora/include -I${mingw_LIBDIR}/vpx/include -I${mingw_LIBDIR}/x264/include -I${mingw_LIBDIR}/xvidcore/include -I${mingw_LIBDIR}/zlib/include") set(FFMPEG_LDFLAGS "-L${mingw_LIBDIR}/lame/lib -L${mingw_LIBDIR}/openjpeg/lib -L${mingw_LIBDIR}/ogg/lib -L${mingw_LIBDIR}/vorbis/lib -L${mingw_LIBDIR}/theora/lib -L${mingw_LIBDIR}/vpx/lib -L${mingw_LIBDIR}/x264/lib -L${mingw_LIBDIR}/xvidcore/lib -L${mingw_LIBDIR}/zlib/lib") -if(UNIX AND NOT APPLE) - # OpenJpeg is compiled with pthread support on Linux, which is all fine and is what we - # want for maximum runtime performance, but due to static nature of that library we - # need to force FFpeg to link against pthread, otherwise test program used by autoconf - # will fail. - set(FFMPEG_LDFLAGS "${FFMPEG_LDFLAGS} -lpthread") -endif() set(FFMPEG_EXTRA_FLAGS --pkg-config-flags=--static --extra-cflags=${FFMPEG_CFLAGS} --extra-ldflags=${FFMPEG_LDFLAGS}) set(FFMPEG_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/openjpeg/lib/pkgconfig:${mingw_LIBDIR}/x264/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}) @@ -38,6 +31,12 @@ if(WIN32) --disable-pthreads --enable-libopenjpeg ) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") + set(FFMPEG_EXTRA_FLAGS + ${FFMPEG_EXTRA_FLAGS} + --x86asmexe=yasm + ) + endif() else() set(FFMPEG_EXTRA_FLAGS ${FFMPEG_EXTRA_FLAGS} @@ -58,6 +57,11 @@ ExternalProject_Add(external_ffmpeg URL ${FFMPEG_URI} DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH MD5=${FFMPEG_HASH} + # OpenJpeg is compiled with pthread support on Linux, which is all fine and is what we + # want for maximum runtime performance, but due to static nature of that library we + # need to force ffmpeg to link against pthread, otherwise test program used by autoconf + # will fail. This patch does that in a way that is compatible with multiple distributions. + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/ffmpeg/src/external_ffmpeg < ${PATCH_DIR}/ffmpeg.diff PREFIX ${BUILD_DIR}/ffmpeg CONFIGURE_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake index 57b76fdd1bd..d47a5e65d3c 100644 --- a/build_files/build_environment/cmake/harvest.cmake +++ b/build_files/build_environment/cmake/harvest.cmake @@ -31,9 +31,6 @@ if(BUILD_MODE STREQUAL Release) COMMAND # jpeg rename libfile + copy include ${CMAKE_COMMAND} -E copy ${LIBDIR}/jpg/lib/jpeg-static.lib ${HARVEST_TARGET}/jpeg/lib/libjpeg.lib && ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/jpg/include/ ${HARVEST_TARGET}/jpeg/include/ && - # pthreads, rename include dir - ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/inc/ ${HARVEST_TARGET}/pthreads/include/ && - ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/lib/ ${HARVEST_TARGET}/pthreads/lib && # OpenImageIO ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/include ${HARVEST_TARGET}/OpenImageIO/include && ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/lib ${HARVEST_TARGET}/OpenImageIO/lib && @@ -113,7 +110,6 @@ endfunction() harvest(alembic/include alembic/include "*.h") harvest(alembic/lib/libAlembic.a alembic/lib/libAlembic.a) -harvest(blosc/lib openvdb/lib "*.a") harvest(boost/include boost/include "*") harvest(boost/lib boost/lib "*.a") harvest(ffmpeg/include ffmpeg/include "*.h") @@ -138,6 +134,18 @@ harvest(ogg/lib ffmpeg/lib "*.a") harvest(openal/include openal/include "*.h") if(UNIX AND NOT APPLE) harvest(openal/lib openal/lib "*.a") + + harvest(blosc/include blosc/include "*.h") + harvest(blosc/lib blosc/lib "*.a") + + harvest(zlib/include zlib/include "*.h") + harvest(zlib/lib zlib/lib "*.a") + + harvest(xml2/include xml2/include "*.h") + harvest(xml2/lib xml2/lib "*.a") +else() + harvest(blosc/lib openvdb/lib "*.a") + harvest(xml2/lib opencollada/lib "*.a") endif() harvest(opencollada/include/opencollada opencollada/include "*.h") harvest(opencollada/lib/opencollada opencollada/lib "*.a") @@ -181,7 +189,6 @@ harvest(vorbis/lib ffmpeg/lib "*.a") harvest(vpx/lib ffmpeg/lib "*.a") harvest(webp/lib ffmpeg/lib "*.a") harvest(x264/lib ffmpeg/lib "*.a") -harvest(xml2/lib opencollada/lib "*.a") harvest(xvidcore/lib ffmpeg/lib "*.a") endif() diff --git a/build_files/build_environment/cmake/lcms.cmake b/build_files/build_environment/cmake/lcms.cmake index f67a85c3721..852d2b8d04c 100644 --- a/build_files/build_environment/cmake/lcms.cmake +++ b/build_files/build_environment/cmake/lcms.cmake @@ -29,10 +29,3 @@ ExternalProject_Add(external_lcms CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/lcms ${DEFAULT_CMAKE_FLAGS} ${LCMS_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/lcms ) - -#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 - # DEPENDEES install - #) -#endif() diff --git a/build_files/build_environment/cmake/llvm.cmake b/build_files/build_environment/cmake/llvm.cmake index 7390b1bf011..1aa31bc9d32 100644 --- a/build_files/build_environment/cmake/llvm.cmake +++ b/build_files/build_environment/cmake/llvm.cmake @@ -47,9 +47,7 @@ if(MSVC) set(LLVM_HARVEST_COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/ ${HARVEST_TARGET}/llvm/ ) 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/bin/ ${HARVEST_TARGET}/llvm/debug/bin/ && - ${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/ ) 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 new file mode 100644 index 00000000000..ef8adde2930 --- /dev/null +++ b/build_files/build_environment/cmake/lzma.cmake @@ -0,0 +1,32 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +set(LZMA_PATCH_CMD echo .) + +ExternalProject_Add(external_lzma + URL ${LZMA_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${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 + INSTALL_DIR ${LIBDIR}/lzma +) diff --git a/build_files/build_environment/cmake/openvdb.cmake b/build_files/build_environment/cmake/openvdb.cmake index a9533a89b1b..a550ed5decb 100644 --- a/build_files/build_environment/cmake/openvdb.cmake +++ b/build_files/build_environment/cmake/openvdb.cmake @@ -60,6 +60,12 @@ if(WIN32) -DOPENEXR_NAMESPACE_VERSIONING=OFF -DEXTRA_LIBS:FILEPATH=${LIBDIR}/pthreads/lib/pthreadVC2.lib ) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") + set(OPENVDB_EXTRA_ARGS ${OPENVDB_EXTRA_ARGS} + -DCMAKE_SHARED_LINKER_FLAGS="/safeseh:no" + -DCMAKE_EXE_LINKER_FLAGS="/safeseh:no" + ) + endif() endif() ExternalProject_Add(openvdb diff --git a/build_files/build_environment/cmake/options.cmake b/build_files/build_environment/cmake/options.cmake index b8efb1bda95..7bf971208ae 100644 --- a/build_files/build_environment/cmake/options.cmake +++ b/build_files/build_environment/cmake/options.cmake @@ -59,7 +59,7 @@ if(WIN32) if(MSVC_VERSION GREATER 1909) set(COMMON_MSVC_FLAGS "/Wv:18") #some deps with warnings as error aren't quite ready for dealing with the new 2017 warnings. endif() - + set(COMMON_MSVC_FLAGS "${COMMON_MSVC_FLAGS} /bigobj") if(WITH_OPTIMIZED_DEBUG) set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd ${COMMON_MSVC_FLAGS} /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") else() @@ -147,13 +147,13 @@ else() endif() if(WITH_OPTIMIZED_DEBUG) - set(BLENDER_CMAKE_C_FLAGS_DEBUG "-O2 -DNDEBUG") + set(BLENDER_CMAKE_C_FLAGS_DEBUG "-O2 -DNDEBUG ${PLATFORM_CFLAGS}") else() - set(BLENDER_CMAKE_C_FLAGS_DEBUG "-g") + set(BLENDER_CMAKE_C_FLAGS_DEBUG "-g ${PLATFORM_CFLAGS}") endif() - set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") - set(BLENDER_CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") - set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") + set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG ${PLATFORM_CFLAGS}") + set(BLENDER_CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG ${PLATFORM_CFLAGS}") + set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG ${PLATFORM_CFLAGS}") if(WITH_OPTIMIZED_DEBUG) set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "-O2 -DNDEBUG ${PLATFORM_CXXFLAGS}") diff --git a/build_files/build_environment/cmake/osl.cmake b/build_files/build_environment/cmake/osl.cmake index ab9027fedb7..eaf6a62d18a 100644 --- a/build_files/build_environment/cmake/osl.cmake +++ b/build_files/build_environment/cmake/osl.cmake @@ -73,18 +73,23 @@ set(OSL_EXTRA_ARGS -DUSE_LLVM_BITCODE=OFF -DUSE_PARTIO=OFF ${OSL_SIMD_FLAGS} - -DPUGIXML_HOME=${LIBDIR}/pugixml -DPARTIO_LIBRARIES= ) +if(WIN32) +set(OSL_EXTRA_ARGS + ${OSL_EXTRA_FLAGS} + -DPUGIXML_HOME=${LIBDIR}/pugixml +) +endif() + ExternalProject_Add(external_osl URL ${OSL_URI} DOWNLOAD_DIR ${DOWNLOAD_DIR} LIST_SEPARATOR ^^ URL_HASH MD5=${OSL_HASH} PREFIX ${BUILD_DIR}/osl - PATCH_COMMAND ${PATCH_CMD} -p 3 -d ${BUILD_DIR}/osl/src/external_osl < ${PATCH_DIR}/osl.diff - # ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/osl/src/external_osl < ${PATCH_DIR}/osl_simd_oiio.diff + 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 ) diff --git a/build_files/build_environment/cmake/pthreads.cmake b/build_files/build_environment/cmake/pthreads.cmake index c93f0866aa9..66246c5ee90 100644 --- a/build_files/build_environment/cmake/pthreads.cmake +++ b/build_files/build_environment/cmake/pthreads.cmake @@ -43,4 +43,13 @@ if(WIN32) ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/semaphore.h ${LIBDIR}/pthreads/inc/semaphore.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 + DEPENDEES install + ) + endif() + endif() diff --git a/build_files/build_environment/cmake/python.cmake b/build_files/build_environment/cmake/python.cmake index 3fbf3a40868..22b4052189e 100644 --- a/build_files/build_environment/cmake/python.cmake +++ b/build_files/build_environment/cmake/python.cmake @@ -86,11 +86,20 @@ else() set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV} && export PKG_CONFIG_PATH=${BREW_PKG_CONFIG} && ${PYTHON_FUNC_CONFIGS}) set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python.exe) - #set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_apple.diff) set(PYTHON_PATCH echo .) + set(PYTHON_CONFIGURE_EXTRA_ENV echo .) + set(PYTHON_CONFIGURE_EXTRA_ARGS) else() + set(PYTHON_CONFIGURE_EXTRA_ARGS "--with-openssl=${LIBDIR}/ssl") set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV}) + set(PYTHON_CFLAGS "-I${LIBDIR}/sqlite/include -I${LIBDIR}/bzip2/include -I${LIBDIR}/lzma/include -I${LIBDIR}/zlib/include") + set(PYTHON_LDFLAGS "-L${LIBDIR}/sqlite/lib -L${LIBDIR}/bzip2/lib -L${LIBDIR}/lzma/lib -L${LIBDIR}/zlib/lib") + set(PYTHON_CONFIGURE_EXTRA_ENV + export CFLAGS=${PYTHON_CFLAGS} && + export CPPFLAGS=${PYTHON_CFLAGS} && + export LDFLAGS=${PYTHON_LDFLAGS}) set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python) + set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_linux.diff) endif() ExternalProject_Add(external_python @@ -99,7 +108,7 @@ else() URL_HASH MD5=${PYTHON_HASH} PREFIX ${BUILD_DIR}/python PATCH_COMMAND ${PYTHON_PATCH} - CONFIGURE_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/python + 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) @@ -162,3 +171,15 @@ if(MSVC) ) add_custom_target(Make_Python_Environment ALL DEPENDS ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe Package_Python) endif() + +if(UNIX AND NOT APPLE) + add_dependencies( + external_python + external_bzip2 + external_ffi + external_lzma + external_ssl + external_sqlite + external_zlib + ) +endif() diff --git a/build_files/build_environment/cmake/python.map b/build_files/build_environment/cmake/python.map new file mode 100644 index 00000000000..1c11c33011d --- /dev/null +++ b/build_files/build_environment/cmake/python.map @@ -0,0 +1,9 @@ +{ +global: + Py*; + _Py*; + _py*; +local: + *; +}; + diff --git a/build_files/build_environment/cmake/setup_mingw32.cmake b/build_files/build_environment/cmake/setup_mingw32.cmake index ece12ddc179..afb44e8e88d 100644 --- a/build_files/build_environment/cmake/setup_mingw32.cmake +++ b/build_files/build_environment/cmake/setup_mingw32.cmake @@ -49,7 +49,7 @@ if(NOT EXISTS "${DOWNLOAD_DIR}/mingw") endif() # extract mingw32 -if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/mingw32env.cmd") AND (EXISTS "${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z")) +if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd") AND (EXISTS "${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z")) message("Extracting mingw32") execute_process( COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z diff --git a/build_files/build_environment/cmake/sqlite.cmake b/build_files/build_environment/cmake/sqlite.cmake new file mode 100644 index 00000000000..e5aa124a414 --- /dev/null +++ b/build_files/build_environment/cmake/sqlite.cmake @@ -0,0 +1,57 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +set(SQLITE_CONFIGURE_ENV echo .) +set(SQLITE_CONFIGURATION_ARGS) + +if(UNIX AND NOT APPLE) + set(SQLITE_LDFLAGS -Wl,--as-needed) + set(SQLITE_CFLAGS + "-DSQLITE_SECURE_DELETE -DSQLITE_ENABLE_COLUMN_METADATA \ + -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS \ + -DSQLITE_ENABLE_RTREE=1 -DSQLITE_SOUNDEX=1 \ + -DSQLITE_ENABLE_UNLOCK_NOTIFY \ + -DSQLITE_OMIT_LOOKASIDE=1 -DSQLITE_ENABLE_DBSTAT_VTAB \ + -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 \ + -DSQLITE_ENABLE_LOAD_EXTENSION \ + -DSQLITE_ENABLE_JSON1 \ + -DSQLITE_LIKE_DOESNT_MATCH_BLOBS \ + -DSQLITE_THREADSAFE=1 \ + -DSQLITE_ENABLE_FTS3_TOKENIZER=1 \ + -DSQLITE_MAX_SCHEMA_RETRY=25 \ + -DSQLITE_ENABLE_PREUPDATE_HOOK \ + -DSQLITE_ENABLE_SESSION \ + -DSQLITE_ENABLE_STMTVTAB \ + -DSQLITE_MAX_VARIABLE_NUMBER=250000 \ + -fPIC") + set(SQLITE_CONFIGURE_ENV ${SQLITE_CONFIGURE_ENV} && export LDFLAGS=${SQLITE_LDFLAGS} && export CFLAGS=${SQLITE_CFLAGS}) + set(SQLITE_CONFIGURATION_ARGS ${SQLITE_CONFIGURATION_ARGS} --enable-threadsafe --enable-load-extension --enable-json1 --enable-fts4 --enable-fts5 + --enable-shared=no) +endif() + +ExternalProject_Add(external_sqlite + URL ${SQLITE_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA1=${SQLITE_HASH} + PREFIX ${BUILD_DIR}/sqlite + PATCH_COMMAND ${SQLITE_PATCH_CMD} + 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/ssl.cmake b/build_files/build_environment/cmake/ssl.cmake new file mode 100644 index 00000000000..dd1b9957cc2 --- /dev/null +++ b/build_files/build_environment/cmake/ssl.cmake @@ -0,0 +1,44 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +set(SSL_CONFIGURE_COMMAND ./Configure) +set(SSL_PATCH_CMD echo .) + +if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(SSL_EXTRA_ARGS enable-ec_nistp_64_gcc_128) + set(SSL_OS_COMPILER "blender-x86_64") +else() + set(SSL_OS_COMPILER "blender-x86") +endif() + +ExternalProject_Add(external_ssl + URL ${SSL_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${SSL_HASH} + PREFIX ${BUILD_DIR}/ssl + PATCH_COMMAND ${SSL_PATCH_CMD} + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ssl/src/external_ssl/ && ${SSL_CONFIGURE_COMMAND} --prefix=${LIBDIR}/ssl + --openssldir=${LIBDIR}/ssl + 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 +) diff --git a/build_files/build_environment/cmake/ssl.conf b/build_files/build_environment/cmake/ssl.conf new file mode 100644 index 00000000000..a9534e56291 --- /dev/null +++ b/build_files/build_environment/cmake/ssl.conf @@ -0,0 +1,10 @@ +%targets = ( + "blender-x86" => { + inherit_from => [ "linux-x86" ], + cflags => add("-fPIC"), + }, + "blender-x86_64" => { + inherit_from => [ "linux-x86_64" ], + cflags => add("-fPIC"), + }, +); diff --git a/build_files/build_environment/cmake/tinyxml.cmake b/build_files/build_environment/cmake/tinyxml.cmake index fb28e7cce2f..9c7d0397c78 100644 --- a/build_files/build_environment/cmake/tinyxml.cmake +++ b/build_files/build_environment/cmake/tinyxml.cmake @@ -29,10 +29,3 @@ ExternalProject_Add(external_tinyxml CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tinyxml ${DEFAULT_CMAKE_FLAGS} ${TINYXML_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/tinyxml ) - -#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 - # DEPENDEES install - #) -#endif() diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index 594aa990d31..7ede80a2be9 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -274,3 +274,27 @@ set(PUGIXML_HASH 9346ca1dce2c48f1748c12fdac41a714) set(FLEXBISON_VERSION 2.5.5) set(FLEXBISON_URI http://prdownloads.sourceforge.net/winflexbison//win_flex_bison-2.5.5.zip) set(FLEXBISON_HASH d87a3938194520d904013abef3df10ce) + +# Libraries to keep Python modules static on Linux. + +# NOTE: bzip.org domain does no longer belong to BZip 2 project, so we download +# sources from Debian packaging. +set(BZIP2_VERSION 1.0.6) +set(BZIP2_URI http://http.debian.net/debian/pool/main/b/bzip2/bzip2_${BZIP2_VERSION}.orig.tar.bz2) +set(BZIP2_HASH d70a9ccd8bdf47e302d96c69fecd54925f45d9c7b966bb4ef5f56b770960afa7) + +set(FFI_VERSION 3.2.1) +set(FFI_URI ftp://sourceware.org/pub/libffi/libffi-${FFI_VERSION}.tar.gz) +set(FFI_HASH d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37) + +set(LZMA_VERSION 5.2.4) +set(LZMA_URI https://tukaani.org/xz/xz-${LZMA_VERSION}.tar.bz2) +set(LZMA_HASH 3313fd2a95f43d88e44264e6b015e7d03053e681860b0d5d3f9baca79c57b7bf) + +set(SSL_VERSION 1.1.0i) +set(SSL_URI https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz) +set(SSL_HASH ebbfc844a8c8cc0ea5dc10b86c9ce97f401837f3fa08c17b2cdadc118253cf99) + +set(SQLITE_VERSION 3.24.0) +set(SQLITE_URI https://www.sqlite.org/2018/sqlite-src-3240000.zip) +set(SQLITE_HASH fb558c49ee21a837713c4f1e7e413309aabdd9c7) diff --git a/build_files/build_environment/cmake/yamlcpp.cmake b/build_files/build_environment/cmake/yamlcpp.cmake index 308f7d88361..617158ff40a 100644 --- a/build_files/build_environment/cmake/yamlcpp.cmake +++ b/build_files/build_environment/cmake/yamlcpp.cmake @@ -32,10 +32,3 @@ ExternalProject_Add(external_yamlcpp CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/yamlcpp ${DEFAULT_CMAKE_FLAGS} ${YAMLCPP_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/yamlcpp ) - -#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 - # DEPENDEES install - #) -#endif() diff --git a/build_files/build_environment/cmake/zlib.cmake b/build_files/build_environment/cmake/zlib.cmake index b768293487a..7bf1c45e359 100644 --- a/build_files/build_environment/cmake/zlib.cmake +++ b/build_files/build_environment/cmake/zlib.cmake @@ -46,4 +46,10 @@ else() DEPENDEES install ) endif() + if (UNIX AND NOT APPLE) + ExternalProject_Add_Step(external_zlib after_install + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/libz.a ${LIBDIR}/zlib/lib/libz_pic.a + DEPENDEES install + ) + endif() endif() diff --git a/build_files/build_environment/patches/alembic.diff b/build_files/build_environment/patches/alembic.diff deleted file mode 100644 index f869858efb2..00000000000 --- a/build_files/build_environment/patches/alembic.diff +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 3e09c57..26565ae 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -116,7 +116,7 @@ IF (NOT ${ALEMBIC_LIB_USES_TR1} AND NOT ${ALEMBIC_LIB_USES_BOOST}) - INCLUDE(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) - CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) -- IF (COMPILER_SUPPORTS_CXX1X) -+ IF (COMPILER_SUPPORTS_CXX11) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - ELSEIF (COMPILER_SUPPORTS_CXX0X) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") ---- a/lib/Alembic/AbcCoreOgawa/StreamManager.cpp -+++ b/lib/Alembic/AbcCoreOgawa/StreamManager.cpp -@@ -47,7 +47,18 @@ - #define COMPARE_EXCHANGE( V, COMP, EXCH ) V.compare_exchange_weak( COMP, EXCH, std::memory_order_seq_cst, std::memory_order_seq_cst ) - // Windows - #elif defined( _MSC_VER ) --#define COMPARE_EXCHANGE( V, COMP, EXCH ) InterlockedCompareExhange64( &V, EXCH, COMP ) == COMP -+#define COMPARE_EXCHANGE( V, COMP, EXCH ) InterlockedCompareExchange64( &V, EXCH, COMP ) == COMP -+int ffsll(long long value) -+{ -+ if (!value) -+ return 0; -+ -+ for (int bit = 0; bit < 63; bit++) -+ { -+ if (value & (1 << bit)) -+ return bit + 1; -+ } -+} - // gcc 4.8 and above not using C++11 - #elif defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 - #define COMPARE_EXCHANGE( V, COMP, EXCH ) __atomic_compare_exchange_n( &V, &COMP, EXCH, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) diff --git a/build_files/build_environment/patches/cmakelists_openvdb.txt b/build_files/build_environment/patches/cmakelists_openvdb.txt deleted file mode 100644 index 43161b8acff..00000000000 --- a/build_files/build_environment/patches/cmakelists_openvdb.txt +++ /dev/null @@ -1,398 +0,0 @@ -# -------------------------------------------------------------------------------- - -cmake_minimum_required(VERSION 2.8) - -# -------------------------------------------------------------------------------- - -project(OpenVDB) - -# -------------------------------------------------------------------------------- - -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") - -# -------------------------------------------------------------------------------- - -set(CMAKE_BUILD_TYPE_INIT "Release") - -# -------------------------------------------------------------------------------- -# Options - -option(WITH_BLOSC "Enable Blosc support for compression" OFF) -option(WITH_LOGC4PLUS "Enable logging" OFF) -option(WITH_OPENVDB_2_ABI "Enable building the library to be compability with the OpenVDB 2 ABI" OFF) -option(WITH_PRINTER "Enable building the OpenVDB print executable" OFF) -option(WITH_PYTHON "Enable building the OpenVDB python API" OFF) -option(WITH_RENDERER "Enable building the OpenVDB render executable" OFF) -option(WITH_UNITTEST "Enable building the unit tests" OFF) -option(WITH_VIEWER "Enable building the OpenVDB viewer executable" OFF) - -# -------------------------------------------------------------------------------- -# Find packages -#set(BOOST_LIBRARIES boost_iostreams boost_system boost_thread) - -find_package(IlmBase) -find_package(OpenEXR) -find_package(TBB) -find_package(Boost) - -if(WITH_BLOSC) - find_package(Blosc) - - if(NOT BLOSC_FOUND) - set(WITH_BLOSC OFF) - endif() -endif() - -# todo -if(WITH_VIEWER) - set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_PATH}) - set(GLFW_LIBRARY_DIRS ${GLFW_LIBRARY_PATH}) -endif() - -if(WITH_LOGC4PLUS) - find_package(LogC4Plus) - - if(NOT LOGC4PLUS_FOUND) - set(WITH_LOGC4PLUS OFF) - endif() -endif() - -# todo -if(WITH_PYTHON) - set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH}) - set(PYTHON_LIBRARY_DIRS ${PYTHON_LIBRARY_PATH}) -endif() - -if(WITH_UNITTEST) - find_package(CppUnit) - - if(NOT CPPUNIT_FOUND) - set(WITH_UNITTEST OFF) - endif() -endif() - -# -------------------------------------------------------------------------------- - -message (STATUS "BOOST_ROOT ${BOOST_ROOT}") -message (STATUS "Boost found ${Boost_FOUND} ") -message (STATUS "Boost version ${Boost_VERSION}") -message (STATUS "Boost include dirs ${Boost_INCLUDE_DIRS}") -message (STATUS "Boost library dirs ${Boost_LIBRARY_DIRS}") -message (STATUS "Boost libraries ${Boost_LIBRARIES}") - -message (STATUS "ILMBase found ${ILMBASE_FOUND} ") -message (STATUS "ILMBase include dir ${ILMBASE_INCLUDE_DIR}") -message (STATUS "ILMBase libraries ${ILMBASE_LIBRARIES}") - -message (STATUS "TBB found ${TBB_FOUND} ") -message (STATUS "TBB include dir ${TBB_INCLUDE_DIR}") -message (STATUS "TBB libraries ${TBB_LIBRARIES}") - -if(MSVC) - set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" ) - set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj" ) -endif() - -set(OPENVDB_LIBRARIES ${BLOSC_LIBRARIES} ${BOOST_LIBRARIES} ${OPENEXR_LIBRARIES} ${ILMBASE_LIBRARIES} ${TBB_LIBRARIES} ${ZLIB_LIBRARY} ) - -include_directories(. ${CMAKE_CURRENT_SOURCE_DIR}/../ ${Boost_INCLUDE_DIRS} ${ILMBASE_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR} ${TBB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) -link_directories(${Boost_LIBRARY_DIRS} ${OPENEXR_LIBRARY_DIRS} ${TBB_INCLUDE_DIRS}) -add_definitions(-DNOMINMAX -D__TBB_NO_IMPLICIT_LINKAGE -DOPENVDB_STATICLIB -DOPENVDB_OPENEXR_STATICLIB) - -if(WITH_BLOSC) - add_definitions(-DOPENVDB_USE_BLOSC) - include_directories(${BLOSC_INCLUDE_DIRS}) - link_directories(${BLOSC_LIBRARY_DIRS}) -endif() - -if(WITH_LOGC4PLUS) - add_definitions(-DOPENVDB_USE_LOG4CPLUS) - include_directories(${LOG4CPLUS_INCLUDE_DIRS}) - link_directories(${LOG4CPLUS_LIBRARY_DIRS}) -endif() - -if(WITH_OPENVDB_2_ABI) - add_definitions(-DOPENVDB_2_ABI_COMPATIBLE) -endif() - -# todo -if(WITH_OPENVDB_USE_GLFW_3) - add_definitions(-DOPENVDB_USE_GLFW_3) -endif() - -if(WITH_UNITTEST) - include_directories(${CPPUNIT_INCLUDE_DIRS}) - link_directories(${CPPUNIT_LIBRARY_DIRS}) -endif() - -# -------------------------------------------------------------------------------- - -set(SRC_FILES - openvdb/openvdb.cc - openvdb/io/Compression.cc - openvdb/io/File.cc - openvdb/io/Queue.cc - openvdb/io/Stream.cc - openvdb/io/TempFile.cc - openvdb/io/GridDescriptor.cc - openvdb/io/Archive.cc - openvdb/metadata/MetaMap.cc - openvdb/metadata/Metadata.cc - openvdb/math/Maps.cc - openvdb/math/Transform.cc - openvdb/math/QuantizedUnitVec.cc - openvdb/math/Proximity.cc - openvdb/Grid.cc - openvdb/util/Formats.cc - openvdb/util/Util.cc -) - -set(HEADER_FILES - openvdb/openvdb.h - openvdb/version.h - openvdb/PlatformConfig.h - openvdb/Metadata.h - openvdb/Exceptions.h - openvdb/Grid.h - openvdb/Types.h - openvdb/Platform.h - openvdb/tree/ValueAccessor.h - openvdb/tree/NodeUnion.h - openvdb/tree/Tree.h - openvdb/tree/Iterator.h - openvdb/tree/LeafNodeBool.h - openvdb/tree/TreeIterator.h - openvdb/tree/LeafNode.h - openvdb/tree/NodeManager.h - openvdb/tree/LeafManager.h - openvdb/tree/InternalNode.h - openvdb/tree/RootNode.h - openvdb/tools/PointScatter.h - openvdb/tools/VolumeAdvect.h - openvdb/tools/LevelSetTracker.h - openvdb/tools/Composite.h - openvdb/tools/Morphology.h - openvdb/tools/ValueTransformer.h - openvdb/tools/ChangeBackground.h - openvdb/tools/GridTransformer.h - openvdb/tools/Prune.h - openvdb/tools/LevelSetUtil.h - openvdb/tools/VolumeToSpheres.h - openvdb/tools/LevelSetAdvect.h - openvdb/tools/Statistics.h - openvdb/tools/LevelSetMeasure.h - openvdb/tools/VectorTransformer.h - openvdb/tools/RayIntersector.h - openvdb/tools/PointPartitioner.h - openvdb/tools/Interpolation.h - openvdb/tools/VelocityFields.h - openvdb/tools/PointIndexGrid.h - openvdb/tools/LevelSetRebuild.h - openvdb/tools/Clip.h - openvdb/tools/SignedFloodFill.h - openvdb/tools/MeshToVolume.h - openvdb/tools/Dense.h - openvdb/tools/Filter.h - openvdb/tools/RayTracer.h - openvdb/tools/Diagnostics.h - openvdb/tools/VolumeToMesh.h - openvdb/tools/PoissonSolver.h - openvdb/tools/LevelSetFracture.h - openvdb/tools/GridOperators.h - openvdb/tools/DenseSparseTools.h - openvdb/tools/ParticlesToLevelSet.h - openvdb/tools/LevelSetSphere.h - openvdb/tools/LevelSetMorph.h - openvdb/tools/LevelSetFilter.h - openvdb/tools/PointAdvect.h - openvdb/io/Queue.h - openvdb/io/TempFile.h - openvdb/io/Stream.h - openvdb/io/GridDescriptor.h - openvdb/io/Archive.h - openvdb/io/io.h - openvdb/io/Compression.h - openvdb/io/File.h - openvdb/metadata/StringMetadata.h - openvdb/metadata/MetaMap.h - openvdb/metadata/Metadata.h - openvdb/math/DDA.h - openvdb/math/Vec2.h - openvdb/math/FiniteDifference.h - openvdb/math/Stencils.h - openvdb/math/BBox.h - openvdb/math/Mat3.h - openvdb/math/Mat.h - openvdb/math/Proximity.h - openvdb/math/Ray.h - openvdb/math/ConjGradient.h - openvdb/math/Quat.h - openvdb/math/Vec3.h - openvdb/math/Vec4.h - openvdb/math/QuantizedUnitVec.h - openvdb/math/Coord.h - openvdb/math/Operators.h - openvdb/math/Stats.h - openvdb/math/Math.h - openvdb/math/Tuple.h - openvdb/math/LegacyFrustum.h - openvdb/math/Mat4.h - openvdb/math/Maps.h - openvdb/math/Transform.h - openvdb/util/PagedArray.h - openvdb/util/CpuTimer.h - openvdb/util/Formats.h - openvdb/util/NullInterrupter.h - openvdb/util/Util.h - openvdb/util/Name.h - openvdb/util/MapsUtil.h - openvdb/util/NodeMasks.h - openvdb/util/logging.h -) - -add_library(openvdb STATIC ${SRC_FILES} ${HEADER_FILES}) - -# -------------------------------------------------------------------------------- - -target_link_libraries(openvdb ${OPENVDB_LIBRARIES}) - -set(OPENVDB_VERSION_MAJOR 3) -set(OPENVDB_VERSION_MINOR 1) -set(OPENVDB_VERSION_PATCH 0) -set(OPENVDB_VERSION_STRING ${OPENVDB_VERSION_MAJOR}.${OPENVDB_VERSION_MINOR}.${OPENVDB_VERSION_PATCH}) - -set_target_properties(openvdb PROPERTIES VERSION ${OPENVDB_VERSION_STRING} SOVERSION ${OPENVDB_VERSION_MAJOR}) - -install(TARGETS openvdb DESTINATION lib) - -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include COMPONENT Development FILES_MATCHING PATTERN "*.h" - PATTERN ".git" EXCLUDE PATTERN "build" EXCLUDE PATTERN "cmake" EXCLUDE) - -# -------------------------------------------------------------------------------- - -if(WITH_PRINTER) - set(PRINT_SRC - openvdb/cmd/openvdb_print/main.cc - ) - - add_executable(vdb_print ${PRINT_SRC}) - target_link_libraries(vdb_print openvdb) - install(TARGETS vdb_print RUNTIME DESTINATION bin) -endif() - -if(WITH_RENDER) - set(RENDER_SRC - openvdb/cmd/openvdb_render/main.cc - ) - - add_executable(vdb_render ${RENDER_SRC}) - target_link_libraries(vdb_render openvdb) - install(TARGETS vdb_render RUNTIME DESTINATION bin) -endif() - -# todo -if(WITH_VIEWER) - set(VIEWER_SRC - openvdb/viewer/Camera.cc - openvdb/viewer/ClipBox.cc - openvdb/viewer/Font.cc - openvdb/viewer/RenderModules.cc - openvdb/viewer/Viewer.cc - - openvdb/viewer/Camera.h - openvdb/viewer/ClipBox.h - openvdb/viewer/Font.h - openvdb/viewer/RenderModules.h - openvdb/viewer/Viewer.h - openvdb/cmd/openvdb_viewer/main.cc - ) - - include_directories(${GLFW_INCLUDE_DIRS}) - link_directories(${GLFW_LIBRARY_DIRS}) - - add_executable(vdb_viewer ${VIEWER_SRC}) - target_link_libraries(vdb_viewer openvdb) - install(TARGETS vdb_viewer RUNTIME DESTINATION bin) -endif() - -# todo -if(WITH_PYTHON) -# add_library(pyopenvdb SHARED ) -endif() - -set(UNITTEST_SRC - openvdb/unittest/main.cc - openvdb/unittest/TestBBox.cc - openvdb/unittest/TestConjGradient.cc - openvdb/unittest/TestCoord.cc - openvdb/unittest/TestCpt.cc - openvdb/unittest/TestCurl.cc - openvdb/unittest/TestDense.cc - openvdb/unittest/TestDenseSparseTools.cc - openvdb/unittest/TestDiagnostics.cc - openvdb/unittest/TestDivergence.cc - openvdb/unittest/TestDoubleMetadata.cc - openvdb/unittest/TestExceptions.cc - openvdb/unittest/TestFile.cc - openvdb/unittest/TestFloatMetadata.cc - openvdb/unittest/TestGradient.cc - openvdb/unittest/TestGrid.cc - openvdb/unittest/TestGridBbox.cc - openvdb/unittest/TestGridDescriptor.cc - openvdb/unittest/TestGridIO.cc - openvdb/unittest/TestGridTransformer.cc - openvdb/unittest/TestInit.cc - openvdb/unittest/TestInt32Metadata.cc - openvdb/unittest/TestInt64Metadata.cc - openvdb/unittest/TestInternalOrigin.cc - openvdb/unittest/TestLaplacian.cc - openvdb/unittest/TestLeaf.cc - openvdb/unittest/TestLeafBool.cc - openvdb/unittest/TestLeafIO.cc - openvdb/unittest/TestLeafOrigin.cc - openvdb/unittest/TestLevelSetRayIntersector.cc - openvdb/unittest/TestLevelSetUtil.cc - openvdb/unittest/TestLinearInterp.cc - openvdb/unittest/TestMaps.cc - openvdb/unittest/TestMat4Metadata.cc - openvdb/unittest/TestMath.cc - openvdb/unittest/TestMeanCurvature.cc - openvdb/unittest/TestMeshToVolume.cc - openvdb/unittest/TestMetadata.cc - openvdb/unittest/TestMetadataIO.cc - openvdb/unittest/TestMetaMap.cc - openvdb/unittest/TestName.cc - openvdb/unittest/TestNodeIterator.cc - openvdb/unittest/TestNodeMask.cc - openvdb/unittest/TestParticlesToLevelSet.cc - openvdb/unittest/TestPointIndexGrid.cc - openvdb/unittest/TestPointPartitioner.cc - openvdb/unittest/TestPoissonSolver.cc - openvdb/unittest/TestPrePostAPI.cc - openvdb/unittest/TestQuadraticInterp.cc - openvdb/unittest/TestQuantizedUnitVec.cc - openvdb/unittest/TestQuat.cc - openvdb/unittest/TestRay.cc - openvdb/unittest/TestStats.cc - openvdb/unittest/TestStream.cc - openvdb/unittest/TestStringMetadata.cc - openvdb/unittest/TestTools.cc - openvdb/unittest/TestTransform.cc - openvdb/unittest/TestTree.cc - openvdb/unittest/TestTreeCombine.cc - openvdb/unittest/TestTreeGetSetValues.cc - openvdb/unittest/TestTreeIterators.cc - openvdb/unittest/TestTreeVisitor.cc - openvdb/unittest/TestUtil.cc - openvdb/unittest/TestValueAccessor.cc - openvdb/unittest/TestVec2Metadata.cc - openvdb/unittest/TestVec3Metadata.cc - openvdb/unittest/TestVolumeRayIntersector.cc - openvdb/unittest/TestVolumeToMesh.cc -) - -# todo -if(WITH_UNITTEST) - add_executable(test ${UNITTEST_SRC} ${HEADER_FILES}) - target_link_libraries(test openvdb ${CPPUNIT_LIBRARIES}) -endif() diff --git a/build_files/build_environment/patches/distutildebugflags.diff b/build_files/build_environment/patches/distutildebugflags.diff deleted file mode 100644 index 3d6b688bc53..00000000000 --- a/build_files/build_environment/patches/distutildebugflags.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- _msvccompiler.py.orig 2017-01-17 00:57:48 -0700 -+++ _msvccompiler.py 2017-05-20 09:47:26 -0600 -@@ -237,7 +237,7 @@ - ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib')) - - ldflags_debug = [ -- '/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL' -+ '/nologo', '/INCREMENTAL:NO', '/LTCG' - ] - - self.ldflags_exe = [*ldflags, '/MANIFEST:EMBED,ID=1'] diff --git a/build_files/build_environment/patches/ffmpeg.diff b/build_files/build_environment/patches/ffmpeg.diff new file mode 100644 index 00000000000..960728ae980 --- /dev/null +++ b/build_files/build_environment/patches/ffmpeg.diff @@ -0,0 +1,11 @@ +--- a/configure 2018-08-27 13:46:41.071106150 +0200 ++++ b/configure 2018-08-27 13:46:28.162765762 +0200 +@@ -6013,7 +6013,7 @@ + require_pkg_config libopencv opencv opencv/cxcore.h cvCreateImageHeader; } + enabled libopenh264 && require_pkg_config libopenh264 openh264 wels/codec_api.h WelsGetCodecVersion + enabled libopenjpeg && { check_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version || +- { require_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } } ++ { require_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version "-DOPJ_STATIC $pthreads_extralibs $libm_extralibs" && add_cppflags "-DOPJ_STATIC $pthreads_extralibs $libm_extralibs"; } } + enabled libopenmpt && require_pkg_config libopenmpt "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append libopenmpt_extralibs "-lstdc++" + enabled libopus && { + enabled libopus_decoder && { diff --git a/build_files/build_environment/patches/osl.diff b/build_files/build_environment/patches/osl.diff index fcb5ec4165f..36cda06f394 100644 --- a/build_files/build_environment/patches/osl.diff +++ b/build_files/build_environment/patches/osl.diff @@ -1,6 +1,6 @@ -diff -Naur osl/src/external_osl/src/cmake/flexbison.cmake osl_bak/src/external_osl/src/cmake/flexbison.cmake ---- osl/src/external_osl//src/cmake/flexbison.cmake 2016-01-29 11:15:22 -0700 -+++ osl_bak/src/external_osl/src/cmake/flexbison.cmake 2016-02-29 21:26:26 -0700 +diff -Naur OpenShadingLanguage-Release-1.9.9/src/cmake/flexbison.cmake external_osl/src/cmake/flexbison.cmake +--- OpenShadingLanguage-Release-1.9.9/src/cmake/flexbison.cmake 2018-05-01 16:39:02 -0600 ++++ external_osl/src/cmake/flexbison.cmake 2018-08-23 15:42:27 -0600 @@ -77,7 +77,7 @@ DEPENDS ${${compiler_headers}} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -10,3 +10,65 @@ diff -Naur osl/src/external_osl/src/cmake/flexbison.cmake osl_bak/src/external_o MAIN_DEPENDENCY ${flexsrc} DEPENDS ${${compiler_headers}} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +diff -Naur OpenShadingLanguage-Release-1.9.9/src/cmake/flexbison.cmake.rej external_osl/src/cmake/flexbison.cmake.rej +--- OpenShadingLanguage-Release-1.9.9/src/cmake/flexbison.cmake.rej 1969-12-31 17:00:00 -0700 ++++ external_osl/src/cmake/flexbison.cmake.rej 2018-08-24 17:42:11 -0600 +@@ -0,0 +1,11 @@ ++--- src/cmake/flexbison.cmake 2018-05-01 16:39:02 -0600 +++++ src/cmake/flexbison.cmake 2018-08-24 10:24:03 -0600 ++@@ -77,7 +77,7 @@ ++ DEPENDS ${${compiler_headers}} ++ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) ++ ADD_CUSTOM_COMMAND ( OUTPUT ${flexoutputcxx} ++- COMMAND ${FLEX_EXECUTABLE} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}" +++ COMMAND ${FLEX_EXECUTABLE} ${FLEX_EXTRA_OPTIONS} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}" ++ MAIN_DEPENDENCY ${flexsrc} ++ DEPENDS ${${compiler_headers}} ++ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +diff -Naur OpenShadingLanguage-Release-1.9.9/src/include/OSL/llvm_util.h external_osl/src/include/OSL/llvm_util.h +--- OpenShadingLanguage-Release-1.9.9/src/include/OSL/llvm_util.h 2018-05-01 16:39:02 -0600 ++++ external_osl/src/include/OSL/llvm_util.h 2018-08-25 14:05:00 -0600 +@@ -33,6 +33,8 @@ + + #include <vector> + ++#define OSL_HAS_BLENDER_CLEANUP_FIX ++ + #ifdef LLVM_NAMESPACE + namespace llvm = LLVM_NAMESPACE; + #endif +@@ -487,6 +489,7 @@ + std::string func_name (llvm::Function *f); + + static size_t total_jit_memory_held (); ++ static void Cleanup (); + + private: + class MemoryManager; +diff -Naur OpenShadingLanguage-Release-1.9.9/src/include/OSL/oslnoise.h external_osl/src/include/OSL/oslnoise.h +--- OpenShadingLanguage-Release-1.9.9/src/include/OSL/oslnoise.h 2018-05-01 16:39:02 -0600 ++++ external_osl/src/include/OSL/oslnoise.h 2018-08-24 17:42:11 -0600 +@@ -762,7 +762,7 @@ + // packed into a float4. We assume T is float and VECTYPE is float4, + // but it also works if T is Dual2<float> and VECTYPE is Dual2<float4>. + template<typename T, typename VECTYPE> +-OIIO_FORCEINLINE T bilerp (VECTYPE abcd, T u, T v) { ++OIIO_FORCEINLINE T bilerp (VECTYPE& abcd, T u, T v) { + VECTYPE xx = OIIO::lerp (abcd, OIIO::simd::shuffle<1,1,3,3>(abcd), u); + return OIIO::simd::extract<0>(OIIO::lerp (xx,OIIO::simd::shuffle<2>(xx), v)); + } +diff -Naur OpenShadingLanguage-Release-1.9.9/src/liboslexec/llvm_util.cpp external_osl/src/liboslexec/llvm_util.cpp +--- OpenShadingLanguage-Release-1.9.9/src/liboslexec/llvm_util.cpp 2018-05-01 16:39:02 -0600 ++++ external_osl/src/liboslexec/llvm_util.cpp 2018-08-25 14:04:27 -0600 +@@ -140,7 +140,10 @@ + }; + + +- ++void LLVM_Util::Cleanup () ++{ ++ jitmm_hold.clear(); ++} + + size_t + LLVM_Util::total_jit_memory_held () diff --git a/build_files/build_environment/patches/osl_simd_oiio.diff b/build_files/build_environment/patches/osl_simd_oiio.diff deleted file mode 100644 index 5062a597167..00000000000 --- a/build_files/build_environment/patches/osl_simd_oiio.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- CMakeLists.txt 2016-10-31 16:48:19 -0600 -+++ CMakeLists.txt 2017-04-10 10:38:48 -0600 -@@ -269,6 +269,11 @@ - add_definitions ("-DOIIO_STATIC_BUILD=1") - endif () - -+set (OIIO_NOSIMD OFF CACHE BOOL "Disable simd support in oiio") -+if (OIIO_NOSIMD) -+ add_definitions ("-DOIIO_NO_SSE=1") -+endif () -+ - if (OSL_NO_DEFAULT_TEXTURESYSTEM) - add_definitions ("-DOSL_NO_DEFAULT_TEXTURESYSTEM=1") - endif () diff --git a/build_files/build_environment/patches/pyshell.diff b/build_files/build_environment/patches/pyshell.diff deleted file mode 100644 index 7ccffe4c040..00000000000 --- a/build_files/build_environment/patches/pyshell.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- pyshellext.cpp.orig 2017-01-17 00:57:53 -0700 -+++ pyshellext.cpp 2017-05-20 15:21:51 -0600 -@@ -13,6 +13,9 @@ - #include <strsafe.h> - - #include "pyshellext_h.h" -+#if _MSC_VER < 1900 -+#include "pyshellext_i.c" -+#endif - - #define DDWM_UPDATEWINDOW (WM_USER+3) - diff --git a/build_files/build_environment/patches/python.diff b/build_files/build_environment/patches/python.diff deleted file mode 100644 index 9e7eccfafff..00000000000 --- a/build_files/build_environment/patches/python.diff +++ /dev/null @@ -1,82 +0,0 @@ ---- Include/Python.h 2017-07-07 21:33:27 -0600 -+++ Include/Python.h 2017-09-19 10:36:10 -0600 -@@ -2,6 +2,10 @@ - #define Py_PYTHON_H - /* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ - -+#if _MSC_VER < 1900 -+#define inline __inline -+#endif -+ - /* Include nearly all Python header files */ - - #include "patchlevel.h" ---- Include/pydtrace.h 2017-07-07 21:33:27 -0600 -+++ Include/pydtrace.h 2017-09-19 10:32:31 -0600 -@@ -2,6 +2,11 @@ - - #ifndef Py_DTRACE_H - #define Py_DTRACE_H -+ -+#if _MSC_VER < 1900 -+#define inline __inline -+#endif -+ - #ifdef __cplusplus - extern "C" { - #endif - ---- Modules/_blake2/impl/blake2.h 2017-07-07 21:33:27 -0600 -+++ Modules/_blake2/impl/blake2.h 2017-09-19 10:22:41 -0600 -@@ -19,6 +19,10 @@ - #include <stddef.h> - #include <stdint.h> - -+#if _MSC_VER < 1900 -+#define inline __inline -+#endif -+ - #ifdef BLAKE2_NO_INLINE - #define BLAKE2_LOCAL_INLINE(type) static type - #endif - ---- pcbuild/build.bat 2016-05-21 09:53:55 -0600 -+++ pcbuild/build.bat 2016-05-21 09:56:16 -0600 -@@ -59,6 +59,7 @@ - if "%~1"=="-h" goto Usage - if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts - if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts -+if "%~1"=="-k" (set vs_toolset=%2) & shift & shift & goto CheckOpts - if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts - if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts - if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts -@@ -120,7 +120,7 @@ - - :Kill - echo on --%MSBUILD% "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^ -+%MSBUILD% "%dir%\pythoncore.vcxproj" /t:KillPython %verbose% /p:PlatformToolset=%vs_toolset%^ - /p:Configuration=%conf% /p:Platform=%platf%^ - /p:KillPython=true - -@@ -130,7 +130,7 @@ - rem batch is, shall we say, "lackluster" - echo on - %MSBUILD% "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^ -- /p:Configuration=%conf% /p:Platform=%platf%^ -+ /p:Configuration=%conf% /p:Platform=%platf% /p:PlatformToolset=%vs_toolset%^ - /p:IncludeExternals=%IncludeExternals%^ - /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^ - /p:UseTestMarker=%UseTestMarker%^ - ---- pcbuild/sqlite3.vcxproj 2015-12-06 18:39:10 -0700 -+++ pcbuild/sqlite3.vcxproj 2016-11-02 09:25:56 -0600 -@@ -43,7 +43,7 @@ - <Import Project="python.props" /> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Label="Configuration"> -- <ConfigurationType>DynamicLibrary</ConfigurationType> -+ <ConfigurationType>StaticLibrary</ConfigurationType> - <CharacterSet>NotSet</CharacterSet> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> diff --git a/build_files/build_environment/patches/python_apple.diff b/build_files/build_environment/patches/python_apple.diff deleted file mode 100644 index 34a7906ed6c..00000000000 --- a/build_files/build_environment/patches/python_apple.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- pyconfig.h.in 2017-09-19 14:41:01.000000000 +0300 -+++ pyconfig.h.in 2017-09-19 14:43:18.000000000 +0300 -@@ -119,12 +119,6 @@ - /* Define to 1 if you have the `clock' function. */ - #undef HAVE_CLOCK - --/* Define to 1 if you have the `clock_getres' function. */ --#undef HAVE_CLOCK_GETRES -- --/* Define to 1 if you have the `clock_gettime' function. */ --#undef HAVE_CLOCK_GETTIME -- - /* Define to 1 if you have the `clock_settime' function. */ - #undef HAVE_CLOCK_SETTIME - -@@ -369,9 +363,6 @@ - /* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ - #undef HAVE_GETC_UNLOCKED - --/* Define to 1 if you have the `getentropy' function. */ --#undef HAVE_GETENTROPY -- - /* Define to 1 if you have the `getgrouplist' function. */ - #undef HAVE_GETGROUPLIST - diff --git a/build_files/build_environment/patches/python_linux.diff b/build_files/build_environment/patches/python_linux.diff new file mode 100644 index 00000000000..24d625c7ceb --- /dev/null +++ b/build_files/build_environment/patches/python_linux.diff @@ -0,0 +1,38 @@ +diff --git a/setup.py.orig b/setup.py +index a97a755..07ce853 100644 +--- a/setup.py.orig ++++ b/setup.py +@@ -1422,13 +1422,13 @@ class PyBuildExt(build_ext): + version = line.split()[2] + break + if version >= version_req: +- if (self.compiler.find_library_file(lib_dirs, 'z')): ++ if (self.compiler.find_library_file(lib_dirs, 'z_pic')): + if host_platform == "darwin": + zlib_extra_link_args = ('-Wl,-search_paths_first',) + else: + zlib_extra_link_args = () + exts.append( Extension('zlib', ['zlibmodule.c'], +- libraries = ['z'], ++ libraries = ['z_pic'], + extra_link_args = zlib_extra_link_args)) + have_zlib = True + else: +@@ -1442,7 +1442,7 @@ class PyBuildExt(build_ext): + # crc32 if we have it. Otherwise binascii uses its own. + if have_zlib: + extra_compile_args = ['-DUSE_ZLIB_CRC32'] +- libraries = ['z'] ++ libraries = ['z_pic'] + extra_link_args = zlib_extra_link_args + else: + extra_compile_args = [] +@@ -1991,7 +1991,7 @@ class PyBuildExt(build_ext): + print('Header file {} does not exist'.format(ffi_h)) + ffi_lib = None + if ffi_inc is not None: +- for lib_name in ('ffi', 'ffi_pic'): ++ for lib_name in ('ffi_pic', ): + if (self.compiler.find_library_file(lib_dirs, lib_name)): + ffi_lib = lib_name + break diff --git a/build_files/build_environment/patches/python_runtime_vc2013.diff b/build_files/build_environment/patches/python_runtime_vc2013.diff deleted file mode 100644 index 186d2b36c07..00000000000 --- a/build_files/build_environment/patches/python_runtime_vc2013.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- _msvccompiler.py.orig 2017-05-20 19:31:45 -0600 -+++ _msvccompiler.py 2017-06-10 10:05:38 -0600 -@@ -222,9 +222,9 @@ - # use /MT[d] to build statically, then switch from libucrt[d].lib to ucrt[d].lib - # later to dynamically link to ucrtbase but not vcruntime. - self.compile_options = [ -- '/nologo', '/Ox', '/W3', '/GL', '/DNDEBUG' -+ '/nologo', '/Ox', '/W3', '/GL', '/DNDEBUG' , '/MD' - ] -- self.compile_options.append('/MD' if self._vcruntime_redist else '/MT') -+ #self.compile_options.append('/MD' if self._vcruntime_redist else '/MT') - - self.compile_options_debug = [ - '/nologo', '/Od', '/MDd', '/Zi', '/W3', '/D_DEBUG' -@@ -233,11 +233,11 @@ - ldflags = [ - '/nologo', '/INCREMENTAL:NO', '/LTCG' - ] -- if not self._vcruntime_redist: -- ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib')) -+ #if not self._vcruntime_redist: -+ # ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib')) - - ldflags_debug = [ -- '/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL' -+ '/nologo', '/INCREMENTAL:NO', '/LTCG' - ] - - self.ldflags_exe = [*ldflags, '/MANIFEST:EMBED,ID=1'] diff --git a/build_files/buildbot/config/blender_linux.cmake b/build_files/buildbot/config/blender_linux.cmake index 9625fabec30..71811fd23e2 100644 --- a/build_files/buildbot/config/blender_linux.cmake +++ b/build_files/buildbot/config/blender_linux.cmake @@ -5,7 +5,17 @@ include("${CMAKE_CURRENT_LIST_DIR}/../../cmake/config/blender_full.cmake") # Detect which libc we'll be linking against. # Some of the paths will depend on this -if(EXISTS "/lib/x86_64-linux-gnu/libc-2.19.so") +if(EXISTS "/lib/x86_64-linux-gnu/libc-2.24.so") + message(STATUS "Building in GLibc-2.24 environment") + set(GLIBC "2.24") + set(MULTILIB "/x86_64-linux-gnu") + set(LIBDIR_NAME "linux_x86_64") +elseif(EXISTS "/lib/i386-linux-gnu//libc-2.24.so") + message(STATUS "Building in GLibc-2.24 environment") + set(GLIBC "2.24") + set(MULTILIB "/i386-linux-gnu") + set(LIBDIR_NAME "linux_i686") +elseif(EXISTS "/lib/x86_64-linux-gnu/libc-2.19.so") message(STATUS "Building in GLibc-2.19 environment") set(GLIBC "2.19") set(MULTILIB "/x86_64-linux-gnu") @@ -40,7 +50,10 @@ set(WITH_PYTHON_INSTALL_NUMPY ON CACHE BOOL "" FORCE) set(WITH_PYTHON_INSTALL_REQUESTS ON CACHE BOOL "" FORCE) # ######## Release environment specific settings ######## -# All the hardcoded libraru paths and such + +if (NOT ${GLIBC} STREQUAL "2.24") + +# All the hardcoded library paths and such # LLVM libraries set(LLVM_VERSION "3.4" CACHE STRING "" FORCE) @@ -147,5 +160,28 @@ set(BLOSC_LIBRARY CACHE BOOL "" FORCE ) +else() + +set(LIBDIR "/opt/blender-deps/${LIBDIR_NAME}" CACHE BOOL "" FORCE) + +# TODO(sergey): Remove once Python is oficially bumped to 3.7. +set(PYTHON_VERSION 3.7 CACHE BOOL "" FORCE) + +# Platform specific configuration, to ensure static linking against everything. + +set(Boost_USE_STATIC_LIBS ON CACHE BOOL "" FORCE) + +# TODO(sergey): Move up to the rest of WITH_SYSTEM and DYNLOAD configuration, +# once old chroot is officially retired. +set(WITH_SYSTEM_OPENJPEG ON CACHE BOOL "" FORCE) + +# We need to link OpenCOLLADA against PCRE library. Even though it is not installed +# on /usr, we do not really care -- all we care is PCRE_FOUND be TRUE and its +# library pointing to a valid one. +set(PCRE_INCLUDE_DIR "/usr/include" CACHE STRING "" FORCE) +set(PCRE_LIBRARY "${LIBDIR}/opencollada/lib/libpcre.a" CACHE STRING "" FORCE) + +endif() + # Additional linking libraries set(CMAKE_EXE_LINKER_FLAGS "-lrt -static-libstdc++" CACHE STRING "" FORCE) diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index a77f237e978..ce4d0c8de66 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -48,7 +48,7 @@ if 'cmake' in builder: # cmake # Some fine-tuning configuration - blender_dir = os.path.join('..', blender_dir) + blender_dir = os.path.abspath(blender_dir) build_dir = os.path.abspath(os.path.join('..', 'build', builder)) install_dir = os.path.abspath(os.path.join('..', 'install', builder)) targets = ['blender'] @@ -101,7 +101,9 @@ if 'cmake' in builder: elif builder.startswith('linux'): tokens = builder.split("_") glibc = tokens[1] - if glibc == 'glibc219': + if glibc == 'glibc224': + deb_name = "stretch" + elif glibc == 'glibc219': deb_name = "jessie" elif glibc == 'glibc211': deb_name = "squeeze" @@ -113,8 +115,9 @@ if 'cmake' in builder: bits = 32 chroot_name = 'buildbot_' + deb_name + '_i686' targets = ['blender'] - cmake_extra_options.extend(["-DCMAKE_C_COMPILER=/usr/bin/gcc-7", - "-DCMAKE_CXX_COMPILER=/usr/bin/g++-7"]) + if deb_name != "stretch": + cmake_extra_options.extend(["-DCMAKE_C_COMPILER=/usr/bin/gcc-7", + "-DCMAKE_CXX_COMPILER=/usr/bin/g++-7"]) cmake_options.append("-C" + os.path.join(blender_dir, cmake_config_file)) @@ -157,10 +160,6 @@ if 'cmake' in builder: if target != 'blender': target_build_dir += '_' + target target_name = 'install' - # Make sure build directory exists and enter it - if not os.path.isdir(target_build_dir): - os.mkdir(target_build_dir) - os.chdir(target_build_dir) # Tweaking CMake options to respect the target target_cmake_options = cmake_options[:] if target == 'cuda': @@ -171,6 +170,19 @@ if 'cmake' in builder: # other targets don't compile cuda binaries. if 'cuda' in targets and target != 'cuda': target_cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=OFF") + # Do extra git fetch because not all platform/git/buildbot combinations + # update the origin remote, causing buildinfo to detect local changes. + os.chdir(blender_dir) + print("Fetching remotes") + command = ['git', 'fetch', '--all'] + print(command) + retcode = subprocess.call(target_chroot_prefix + command) + if retcode != 0: + sys.exit(retcode) + # Make sure build directory exists and enter it + if not os.path.isdir(target_build_dir): + os.mkdir(target_build_dir) + os.chdir(target_build_dir) # Configure the build print("CMake options:") print(target_cmake_options) @@ -185,11 +197,11 @@ if 'cmake' in builder: if 'win32' in builder or 'win64' in builder: command = ['cmake', '--build', '.', '--target', target_name, '--config', 'Release'] else: - command = target_chroot_prefix + ['make', '-s', '-j2', target_name] + command = ['make', '-s', '-j2', target_name] print("Executing command:") print(command) - retcode = subprocess.call(command) + retcode = subprocess.call(target_chroot_prefix + command) if retcode != 0: sys.exit(retcode) diff --git a/build_files/cmake/Modules/FindOpenJPEG.cmake b/build_files/cmake/Modules/FindOpenJPEG.cmake index 85a4c131fb1..a6c28be6782 100644 --- a/build_files/cmake/Modules/FindOpenJPEG.cmake +++ b/build_files/cmake/Modules/FindOpenJPEG.cmake @@ -47,6 +47,7 @@ FIND_PATH(OPENJPEG_INCLUDE_DIR FIND_LIBRARY(OPENJPEG_LIBRARY NAMES openjpeg + openjp2 HINTS ${_openjpeg_SEARCH_DIRS} PATH_SUFFIXES diff --git a/build_files/cmake/Modules/FindPythonLibsUnix.cmake b/build_files/cmake/Modules/FindPythonLibsUnix.cmake index 140f8be048a..a6924972e42 100644 --- a/build_files/cmake/Modules/FindPythonLibsUnix.cmake +++ b/build_files/cmake/Modules/FindPythonLibsUnix.cmake @@ -38,7 +38,7 @@ IF(NOT PYTHON_ROOT_DIR AND NOT $ENV{PYTHON_ROOT_DIR} STREQUAL "") SET(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR}) ENDIF() -SET(PYTHON_VERSION 3.6 CACHE STRING "Python Version (major and minor only)") +SET(PYTHON_VERSION 3.7 CACHE STRING "Python Version (major and minor only)") MARK_AS_ADVANCED(PYTHON_VERSION) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 047b1fa3b5b..c2c2efd0fc9 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -45,7 +45,6 @@ if(WITH_OPENAL) find_package(OpenAL) if(OPENAL_FOUND) set(WITH_OPENAL ON) - set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include/AL") else() set(WITH_OPENAL OFF) endif() diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 8c11e93e81a..fc9e09b73fd 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -24,13 +24,20 @@ # Libraries configuration for any *nix system including Linux and Unix. # Detect precompiled library directory -set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}) -string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME) -set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME}) +if(NOT DEFINED LIBDIR) + set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}) + string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME) + set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME}) +else() + message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") +endif() if(EXISTS ${LIBDIR}) file(GLOB LIB_SUBDIRS ${LIBDIR}/*) - set(CMAKE_PREFIX_PATH ${LIB_SUBDIRS}) + # NOTE: Make sure "proper" compiled zlib comes first before the one + # which is a part of OpenCollada. They have different ABI, and we + # do need to use the official one. + set(CMAKE_PREFIX_PATH ${LIBDIR}/zlib ${LIB_SUBDIRS}) set(WITH_STATIC_LIBS ON) set(WITH_OPENMP_STATIC ON) endif() diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index c45e8ad533d..0c1175df39b 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -265,9 +265,7 @@ if(WITH_OPENCOLLADA) ${OPENCOLLADA}/lib/opencollada/ftoa.lib ) - if(NOT WITH_LLVM) - list(APPEND OPENCOLLADA_LIBRARIES ${OPENCOLLADA}/lib/opencollada/UTF.lib) - endif() + list(APPEND OPENCOLLADA_LIBRARIES ${OPENCOLLADA}/lib/opencollada/UTF.lib) set(PCRE_LIBRARIES ${OPENCOLLADA}/lib/opencollada/pcre.lib @@ -282,8 +280,6 @@ if(WITH_CODEC_FFMPEG) windows_find_package(FFMPEG) if(NOT FFMPEG_FOUND) warn_hardcoded_paths(ffmpeg) - set(FFMPEG_LIBRARY_VERSION 57) - set(FFMPEG_LIBRARY_VERSION_AVU 55) set(FFMPEG_LIBRARIES ${LIBDIR}/ffmpeg/lib/avcodec.lib ${LIBDIR}/ffmpeg/lib/avformat.lib @@ -305,16 +301,16 @@ if(WITH_IMAGE_OPENEXR) set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR) set(OPENEXR_LIBPATH ${OPENEXR}/lib) set(OPENEXR_LIBRARIES - optimized ${OPENEXR_LIBPATH}/Iex-2_2.lib - optimized ${OPENEXR_LIBPATH}/Half.lib - optimized ${OPENEXR_LIBPATH}/IlmImf-2_2.lib - optimized ${OPENEXR_LIBPATH}/Imath-2_2.lib - optimized ${OPENEXR_LIBPATH}/IlmThread-2_2.lib - debug ${OPENEXR_LIBPATH}/Iex-2_2_d.lib - debug ${OPENEXR_LIBPATH}/Half_d.lib - debug ${OPENEXR_LIBPATH}/IlmImf-2_2_d.lib - debug ${OPENEXR_LIBPATH}/Imath-2_2_d.lib - debug ${OPENEXR_LIBPATH}/IlmThread-2_2_d.lib + optimized ${OPENEXR_LIBPATH}/Iex_s.lib + optimized ${OPENEXR_LIBPATH}/Half_s.lib + optimized ${OPENEXR_LIBPATH}/IlmImf_s.lib + optimized ${OPENEXR_LIBPATH}/Imath_s.lib + optimized ${OPENEXR_LIBPATH}/IlmThread_s.lib + debug ${OPENEXR_LIBPATH}/Iex_s_d.lib + debug ${OPENEXR_LIBPATH}/Half_s_d.lib + debug ${OPENEXR_LIBPATH}/IlmImf_s_d.lib + debug ${OPENEXR_LIBPATH}/Imath_s_d.lib + debug ${OPENEXR_LIBPATH}/IlmThread_s_d.lib ) endif() endif() @@ -338,7 +334,7 @@ if(WITH_JACK) endif() if(WITH_PYTHON) - set(PYTHON_VERSION 3.6) # CACHE STRING) + set(PYTHON_VERSION 3.7) # CACHE STRING) string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs @@ -373,14 +369,13 @@ if(WITH_BOOST) warn_hardcoded_paths(BOOST) set(BOOST ${LIBDIR}/boost) set(BOOST_INCLUDE_DIR ${BOOST}/include) - if(MSVC12) - set(BOOST_LIBPATH ${BOOST}/lib) - set(BOOST_POSTFIX "vc120-mt-s-1_60.lib") - set(BOOST_DEBUG_POSTFIX "vc120-mt-sgd-1_60.lib") + set(BOOST_LIBPATH ${BOOST}/lib) + if(CMAKE_CL_64) + set(BOOST_POSTFIX "vc140-mt-s-x64-1_68.lib") + set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x64-1_68.lib") else() - set(BOOST_LIBPATH ${BOOST}/lib) - set(BOOST_POSTFIX "vc140-mt-s-1_60.lib") - set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-1_60.lib") + set(BOOST_POSTFIX "vc140-mt-s-x32-1_68.lib") + set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x32-1_68.lib") endif() set(BOOST_LIBRARIES optimized ${BOOST_LIBPATH}/libboost_date_time-${BOOST_POSTFIX} @@ -459,7 +454,14 @@ if(WITH_OPENCOLORIO) set(OPENCOLORIO ${LIBDIR}/opencolorio) set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) set(OPENCOLORIO_LIBPATH ${LIBDIR}/opencolorio/lib) - set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib) + set(OPENCOLORIO_LIBRARIES + optimized ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib + optimized ${OPENCOLORIO_LIBPATH}/tinyxml.lib + optimized ${OPENCOLORIO_LIBPATH}/libyaml-cpp.lib + debug ${OPENCOLORIO_LIBPATH}/OpenColorIO_d.lib + debug ${OPENCOLORIO_LIBPATH}/tinyxml_d.lib + debug ${OPENCOLORIO_LIBPATH}/libyaml-cpp_d.lib + ) set(OPENCOLORIO_DEFINITIONS) endif() @@ -471,7 +473,7 @@ if(WITH_OPENVDB) set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib) set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include ${TBB_INCLUDE_DIR}) set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib ${TBB_LIBRARIES} ${BLOSC_LIBRARIES}) - + set(OPENVDB_DEFINITIONS -DNOMINMAX) endif() if(WITH_ALEMBIC) @@ -494,6 +496,12 @@ if(WITH_MOD_CLOTH_ELTOPO) ) endif() +if(WITH_IMAGE_OPENJPEG) + set(OPENJPEG ${LIBDIR}/openjpeg) + set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG}/include/openjpeg-2.3) + set(OPENJPEG_LIBRARIES ${OPENJPEG}/lib/openjp2.lib) +endif() + if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV) set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include) set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib) @@ -582,9 +590,11 @@ if(WITH_CYCLES_OSL) optimized ${OSL_LIB_COMP} optimized ${OSL_LIB_EXEC} optimized ${OSL_LIB_QUERY} + optimized ${CYCLES_OSL}/lib/pugixml.lib debug ${OSL_LIB_EXEC_DEBUG} debug ${OSL_LIB_COMP_DEBUG} debug ${OSL_LIB_QUERY_DEBUG} + debug ${CYCLES_OSL}/lib/pugixml_d.lib ) find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) diff --git a/doc/python_api/examples/bpy.types.Menu.2.py b/doc/python_api/examples/bpy.types.Menu.2.py index a1cce0c3ce2..fbdf747d472 100644 --- a/doc/python_api/examples/bpy.types.Menu.2.py +++ b/doc/python_api/examples/bpy.types.Menu.2.py @@ -15,4 +15,4 @@ def menu_draw(self, context): self.layout.operator("wm.save_homefile") -bpy.types.INFO_MT_file.append(menu_draw) +bpy.types.TOPBAR_MT_file.append(menu_draw) diff --git a/doc/python_api/examples/bpy.types.Operator.2.py b/doc/python_api/examples/bpy.types.Operator.2.py index d1f0edf15aa..901bd7b21f8 100644 --- a/doc/python_api/examples/bpy.types.Operator.2.py +++ b/doc/python_api/examples/bpy.types.Operator.2.py @@ -45,7 +45,7 @@ def menu_func(self, context): # Register and add to the file selector bpy.utils.register_class(ExportSomeData) -bpy.types.INFO_MT_file_export.append(menu_func) +bpy.types.TOPBAR_MT_file_export.append(menu_func) # test call diff --git a/doc/python_api/examples/bpy.types.Panel.1.py b/doc/python_api/examples/bpy.types.Panel.1.py index 13a9f53fa7b..b409f8dadea 100644 --- a/doc/python_api/examples/bpy.types.Panel.1.py +++ b/doc/python_api/examples/bpy.types.Panel.1.py @@ -34,7 +34,7 @@ class ObjectSelectPanel(bpy.types.Panel): row.prop(obj, "hide_render") box = layout.box() - box.label("Selection Tools") + box.label(text="Selection Tools") box.operator("object.select_all").action = 'TOGGLE' row = box.row() row.operator("object.select_all").action = 'INVERT' diff --git a/doc/python_api/examples/bpy.types.Panel.2.py b/doc/python_api/examples/bpy.types.Panel.2.py index 261430f1396..2c860e3e1a7 100644 --- a/doc/python_api/examples/bpy.types.Panel.2.py +++ b/doc/python_api/examples/bpy.types.Panel.2.py @@ -21,7 +21,7 @@ class PanelOne(View3DPanel, bpy.types.Panel): bl_label = "Panel One" def draw(self, context): - self.layout.label("Small Class") + self.layout.label(text="Small Class") class PanelTwo(View3DPanel, bpy.types.Panel): @@ -29,7 +29,7 @@ class PanelTwo(View3DPanel, bpy.types.Panel): bl_label = "Panel Two" def draw(self, context): - self.layout.label("Also Small Class") + self.layout.label(text="Also Small Class") bpy.utils.register_class(PanelOne) diff --git a/doc/python_api/examples/bpy.types.UIList.2.py b/doc/python_api/examples/bpy.types.UIList.2.py index a02a0530a66..81bbec11d9a 100644 --- a/doc/python_api/examples/bpy.types.UIList.2.py +++ b/doc/python_api/examples/bpy.types.UIList.2.py @@ -76,7 +76,7 @@ class MESH_UL_vgroups_slow(bpy.types.UIList): subrow.prop(self, "use_filter_empty_reverse", text="", icon=icon) row = layout.row(align=True) - row.label("Order by:") + row.label(text="Order by:") row.prop(self, "use_order_name", toggle=True) row.prop(self, "use_order_importance", toggle=True) icon = 'TRIA_UP' if self.use_filter_orderby_invert else 'TRIA_DOWN' diff --git a/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py b/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py index e6329f677f7..670444b8283 100644 --- a/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py +++ b/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py @@ -8,7 +8,7 @@ import bpy def draw(self, context): - self.layout.label("Hello World") + self.layout.label(text="Hello World") bpy.context.window_manager.popup_menu(draw, title="Greeting", icon='INFO') diff --git a/doc/python_api/rst_from_bmesh_opdefines.py b/doc/python_api/rst_from_bmesh_opdefines.py index d3e4b2a0cfd..d9e2f7f12e7 100644 --- a/doc/python_api/rst_from_bmesh_opdefines.py +++ b/doc/python_api/rst_from_bmesh_opdefines.py @@ -31,6 +31,7 @@ # - campbell import os +import re CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(CURRENT_DIR, "..", "..")))) @@ -75,7 +76,10 @@ def main(): for l in fsrc: l = l[:-1] # weak but ok - if ("BMOpDefine" in l and l.split()[1] == "BMOpDefine") and "bmo_opdefines[]" not in l: + if ( + (("BMOpDefine" in l and l.split()[1] == "BMOpDefine") and "bmo_opdefines[]" not in l) or + ("static BMO_FlagSet " in l) + ): is_block = True block_ctx = [] blocks.append((comment_ctx, block_ctx)) @@ -92,9 +96,12 @@ def main(): if cpp_comment != -1: l = l[:cpp_comment] + # remove sentinel from enums + l = l.replace("{0, NULL}", "") + block_ctx.append(l) - if l.strip() == "};": + if l.strip().endswith("};"): is_block = False comment_ctx = None @@ -136,6 +143,9 @@ def main(): "BMO_OP_SLOT_SUBTYPE_PTR_MESH", "BMO_OP_SLOT_SUBTYPE_PTR_BMESH", + "BMO_OP_SLOT_SUBTYPE_INT_ENUM", + "BMO_OP_SLOT_SUBTYPE_INT_FLAG", + "BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE", "BM_VERT", @@ -160,6 +170,7 @@ def main(): for comment, b in blocks: # magic, translate into python b[0] = b[0].replace("static BMOpDefine ", "") + is_enum = False for i, l in enumerate(b): l = l.strip() @@ -178,11 +189,35 @@ def main(): # exec func. eg: bmo_rotate_edges_exec, if l.startswith("bmo_") and l.endswith("_exec,"): l = "None," + + # enums + if l.startswith("static BMO_FlagSet "): + is_enum = True + b[i] = l # for l in b: # print(l) + if is_enum: + text = "".join(b) + text = text.replace("static BMO_FlagSet ", "") + text = text.replace("[]", "") + text = text.strip(";") + text = text.replace("(", "[").replace(")", "]") + text = text.replace("\"", "'") + + k, v = text.split("=", 1) + + v = repr(re.findall(r"'([^']*)'", v)) + + k = k.strip() + v = v.strip() + + vars_dict[k] = v + + continue + text = "\n".join(b) global_namespace = { "__file__": "generated", @@ -225,6 +260,7 @@ def main(): # -- wash the comment comment_washed = [] + comment = [] if comment is None else comment for i, l in enumerate(comment): assert((l.strip() == "") or (l in {"/*", " *"}) or @@ -246,7 +282,9 @@ def main(): args_wash = [] for i in args_index: arg = args[i] - if len(arg) == 3: + if len(arg) == 4: + name, tp, tp_sub, enums = arg + elif len(arg) == 3: name, tp, tp_sub = arg elif len(arg) == 2: name, tp = arg @@ -282,7 +320,12 @@ def main(): if tp == BMO_OP_SLOT_FLT: tp_str = "float" elif tp == BMO_OP_SLOT_INT: - tp_str = "int" + if tp_sub == BMO_OP_SLOT_SUBTYPE_INT_ENUM: + tp_str = "enum in " + enums + ", default " + enums.split(",", 1)[0].strip("[") + elif tp_sub == BMO_OP_SLOT_SUBTYPE_INT_FLAG: + tp_str = "set of flags from " + enums + ", default {}" + else: + tp_str = "int" elif tp == BMO_OP_SLOT_BOOL: tp_str = "bool" elif tp == BMO_OP_SLOT_MAT: diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 14222d03d87..6e7d2e45f3a 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -349,7 +349,7 @@ INFO_DOCS = ( "Tips and Tricks: Hints to help you while writing scripts for Blender"), ("info_gotcha.rst", "Gotcha's: some of the problems you may come up against when writing scripts"), - ("change_log.rst", "List of changes since last Blender release"), + ("change_log.rst", "List of changes since last Blender release"), ) # only support for properties atm. diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 00ac8e7e182..0147a4306f4 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -200,6 +200,9 @@ endif() if(WITH_CYCLES_OSL) add_definitions(-DWITH_OSL) + #osl 1.9.x + add_definitions(-DOSL_STATIC_BUILD) + #pre 1.9 add_definitions(-DOSL_STATIC_LIBRARY) include_directories( SYSTEM diff --git a/intern/cycles/app/cycles_cubin_cc.cpp b/intern/cycles/app/cycles_cubin_cc.cpp index 01a1234531b..da8ca53c8df 100644 --- a/intern/cycles/app/cycles_cubin_cc.cpp +++ b/intern/cycles/app/cycles_cubin_cc.cpp @@ -159,8 +159,7 @@ bool link_ptxas(CompilationSettings &settings) " --gpu-name sm_" + std::to_string(settings.target_arch) + " -m" + std::to_string(settings.bits); - if (settings.verbose) - { + if(settings.verbose) { ptx += " --verbose"; printf("%s\n", ptx.c_str()); } diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index 476cf975737..1604422211b 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -268,3 +268,10 @@ def register_passes(engine, scene, srl): engine.register_pass(scene, srl, "Denoising Shadow B", 3, "XYV", 'VECTOR') engine.register_pass(scene, srl, "Denoising Image", 3, "RGB", 'COLOR') engine.register_pass(scene, srl, "Denoising Image Variance", 3, "RGB", 'COLOR') + + clean_options = ("denoising_diffuse_direct", "denoising_diffuse_indirect", + "denoising_glossy_direct", "denoising_glossy_indirect", + "denoising_transmission_direct", "denoising_transmission_indirect", + "denoising_subsurface_direct", "denoising_subsurface_indirect") + if any(getattr(crl, option) for option in clean_options): + engine.register_pass(scene, srl, "Denoising Clean", 3, "RGB", 'COLOR') diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 7f0cb7e875f..3c82f5675c5 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -26,6 +26,8 @@ from bpy.props import ( StringProperty, ) +from math import pi + # enums import _cycles @@ -52,6 +54,7 @@ enum_displacement_methods = ( enum_bvh_layouts = ( ('BVH2', "BVH2", "", 1), ('BVH4', "BVH4", "", 2), + ('BVH8', "BVH8", "", 4), ) enum_bvh_types = ( @@ -155,575 +158,581 @@ enum_texture_limit = ( class CyclesRenderSettings(bpy.types.PropertyGroup): - @classmethod - def register(cls): - bpy.types.Scene.cycles = PointerProperty( - name="Cycles Render Settings", - description="Cycles render settings", - type=cls, - ) - cls.device = EnumProperty( - name="Device", - description="Device to use for rendering", - items=enum_devices, - default='CPU', - ) - cls.feature_set = EnumProperty( - name="Feature Set", - description="Feature set to use for rendering", - items=enum_feature_set, - default='SUPPORTED', - ) - cls.shading_system = BoolProperty( - name="Open Shading Language", - description="Use Open Shading Language (CPU rendering only)", - ) - cls.progressive = EnumProperty( - name="Integrator", - description="Method to sample lights and materials", - items=enum_integrator, - default='PATH', - ) + device: EnumProperty( + name="Device", + description="Device to use for rendering", + items=enum_devices, + default='CPU', + ) + feature_set: EnumProperty( + name="Feature Set", + description="Feature set to use for rendering", + items=enum_feature_set, + default='SUPPORTED', + ) + shading_system: BoolProperty( + name="Open Shading Language", + description="Use Open Shading Language (CPU rendering only)", + ) - cls.use_square_samples = BoolProperty( - name="Square Samples", - description="Square sampling values for easier artist control", - default=False, - ) + progressive: EnumProperty( + name="Integrator", + description="Method to sample lights and materials", + items=enum_integrator, + default='PATH', + ) - cls.samples = IntProperty( - name="Samples", - description="Number of samples to render for each pixel", - min=1, max=2147483647, - default=128, - ) - cls.preview_samples = IntProperty( - name="Preview Samples", - description="Number of samples to render in the viewport, unlimited if 0", - min=0, max=2147483647, - default=32, - ) - cls.preview_pause = BoolProperty( - name="Pause Preview", - description="Pause all viewport preview renders", - default=False, - ) - cls.aa_samples = IntProperty( - name="AA Samples", - description="Number of antialiasing samples to render for each pixel", - min=1, max=2097151, - default=128, - ) - cls.preview_aa_samples = IntProperty( - name="AA Samples", - description="Number of antialiasing samples to render in the viewport, unlimited if 0", - min=0, max=2097151, - default=32, - ) - cls.diffuse_samples = IntProperty( - name="Diffuse Samples", - description="Number of diffuse bounce samples to render for each AA sample", - min=1, max=1024, - default=1, - ) - cls.glossy_samples = IntProperty( - name="Glossy Samples", - description="Number of glossy bounce samples to render for each AA sample", - min=1, max=1024, - default=1, - ) - cls.transmission_samples = IntProperty( - name="Transmission Samples", - description="Number of transmission bounce samples to render for each AA sample", - min=1, max=1024, - default=1, - ) - cls.ao_samples = IntProperty( - name="Ambient Occlusion Samples", - description="Number of ambient occlusion samples to render for each AA sample", - min=1, max=1024, - default=1, - ) - cls.mesh_light_samples = IntProperty( - name="Mesh Light Samples", - description="Number of mesh emission light samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + use_square_samples: BoolProperty( + name="Square Samples", + description="Square sampling values for easier artist control", + default=False, + ) - cls.subsurface_samples = IntProperty( - name="Subsurface Samples", - description="Number of subsurface scattering samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + samples: IntProperty( + name="Samples", + description="Number of samples to render for each pixel", + min=1, max=2147483647, + default=128, + ) + preview_samples: IntProperty( + name="Preview Samples", + description="Number of samples to render in the viewport, unlimited if 0", + min=0, max=2147483647, + default=32, + ) + preview_pause: BoolProperty( + name="Pause Preview", + description="Pause all viewport preview renders", + default=False, + ) + aa_samples: IntProperty( + name="AA Samples", + description="Number of antialiasing samples to render for each pixel", + min=1, max=2097151, + default=128, + ) + preview_aa_samples: IntProperty( + name="AA Samples", + description="Number of antialiasing samples to render in the viewport, unlimited if 0", + min=0, max=2097151, + default=32, + ) + diffuse_samples: IntProperty( + name="Diffuse Samples", + description="Number of diffuse bounce samples to render for each AA sample", + min=1, max=1024, + default=1, + ) + glossy_samples: IntProperty( + name="Glossy Samples", + description="Number of glossy bounce samples to render for each AA sample", + min=1, max=1024, + default=1, + ) + transmission_samples: IntProperty( + name="Transmission Samples", + description="Number of transmission bounce samples to render for each AA sample", + min=1, max=1024, + default=1, + ) + ao_samples: IntProperty( + name="Ambient Occlusion Samples", + description="Number of ambient occlusion samples to render for each AA sample", + min=1, max=1024, + default=1, + ) + mesh_light_samples: IntProperty( + name="Mesh Light Samples", + description="Number of mesh emission light samples to render for each AA sample", + min=1, max=1024, + default=1, + ) - cls.volume_samples = IntProperty( - name="Volume Samples", - description="Number of volume scattering samples to render for each AA sample", - min=1, max=1024, - default=1, - ) + subsurface_samples: IntProperty( + name="Subsurface Samples", + description="Number of subsurface scattering samples to render for each AA sample", + min=1, max=1024, + default=1, + ) - cls.sampling_pattern = EnumProperty( - name="Sampling Pattern", - description="Random sampling pattern used by the integrator", - items=enum_sampling_pattern, - default='SOBOL', - ) + volume_samples: IntProperty( + name="Volume Samples", + description="Number of volume scattering samples to render for each AA sample", + min=1, max=1024, + default=1, + ) - cls.use_layer_samples = EnumProperty( - name="Layer Samples", - description="How to use per render layer sample settings", - items=enum_use_layer_samples, - default='USE', - ) + sampling_pattern: EnumProperty( + name="Sampling Pattern", + description="Random sampling pattern used by the integrator", + items=enum_sampling_pattern, + default='SOBOL', + ) - cls.sample_all_lights_direct = BoolProperty( - name="Sample All Direct Lights", - description="Sample all lights (for direct samples), rather than randomly picking one", - default=True, - ) + use_layer_samples: EnumProperty( + name="Layer Samples", + description="How to use per render layer sample settings", + items=enum_use_layer_samples, + default='USE', + ) - cls.sample_all_lights_indirect = BoolProperty( - name="Sample All Indirect Lights", - description="Sample all lights (for indirect samples), rather than randomly picking one", - default=True, - ) - cls.light_sampling_threshold = FloatProperty( - name="Light Sampling Threshold", - description="Probabilistically terminate light samples when the light contribution is below this threshold (more noise but faster rendering). " - "Zero disables the test and never ignores lights", - min=0.0, max=1.0, - default=0.01, - ) + sample_all_lights_direct: BoolProperty( + name="Sample All Direct Lights", + description="Sample all lights (for direct samples), rather than randomly picking one", + default=True, + ) - cls.caustics_reflective = BoolProperty( - name="Reflective Caustics", - description="Use reflective caustics, resulting in a brighter image (more noise but added realism)", - default=True, - ) + sample_all_lights_indirect: BoolProperty( + name="Sample All Indirect Lights", + description="Sample all lights (for indirect samples), rather than randomly picking one", + default=True, + ) + light_sampling_threshold: FloatProperty( + name="Light Sampling Threshold", + description="Probabilistically terminate light samples when the light contribution is below this threshold (more noise but faster rendering). " + "Zero disables the test and never ignores lights", + min=0.0, max=1.0, + default=0.01, + ) - cls.caustics_refractive = BoolProperty( - name="Refractive Caustics", - description="Use refractive caustics, resulting in a brighter image (more noise but added realism)", - default=True, - ) + caustics_reflective: BoolProperty( + name="Reflective Caustics", + description="Use reflective caustics, resulting in a brighter image (more noise but added realism)", + default=True, + ) - cls.blur_glossy = FloatProperty( - name="Filter Glossy", - description="Adaptively blur glossy shaders after blurry bounces, " - "to reduce noise at the cost of accuracy", - min=0.0, max=10.0, - default=1.0, - ) + caustics_refractive: BoolProperty( + name="Refractive Caustics", + description="Use refractive caustics, resulting in a brighter image (more noise but added realism)", + default=True, + ) - cls.max_bounces = IntProperty( - name="Max Bounces", - description="Total maximum number of bounces", - min=0, max=1024, - default=12, - ) + blur_glossy: FloatProperty( + name="Filter Glossy", + description="Adaptively blur glossy shaders after blurry bounces, " + "to reduce noise at the cost of accuracy", + min=0.0, max=10.0, + default=1.0, + ) - cls.diffuse_bounces = IntProperty( - name="Diffuse Bounces", - description="Maximum number of diffuse reflection bounces, bounded by total maximum", - min=0, max=1024, - default=4, - ) - cls.glossy_bounces = IntProperty( - name="Glossy Bounces", - description="Maximum number of glossy reflection bounces, bounded by total maximum", - min=0, max=1024, - default=4, - ) - cls.transmission_bounces = IntProperty( - name="Transmission Bounces", - description="Maximum number of transmission bounces, bounded by total maximum", - min=0, max=1024, - default=12, - ) - cls.volume_bounces = IntProperty( - name="Volume Bounces", - description="Maximum number of volumetric scattering events", - min=0, max=1024, - default=0, - ) + max_bounces: IntProperty( + name="Max Bounces", + description="Total maximum number of bounces", + min=0, max=1024, + default=12, + ) - cls.transparent_max_bounces = IntProperty( - name="Transparent Max Bounces", - description="Maximum number of transparent bounces", - min=0, max=1024, - default=8, - ) + diffuse_bounces: IntProperty( + name="Diffuse Bounces", + description="Maximum number of diffuse reflection bounces, bounded by total maximum", + min=0, max=1024, + default=4, + ) + glossy_bounces: IntProperty( + name="Glossy Bounces", + description="Maximum number of glossy reflection bounces, bounded by total maximum", + min=0, max=1024, + default=4, + ) + transmission_bounces: IntProperty( + name="Transmission Bounces", + description="Maximum number of transmission bounces, bounded by total maximum", + min=0, max=1024, + default=12, + ) + volume_bounces: IntProperty( + name="Volume Bounces", + description="Maximum number of volumetric scattering events", + min=0, max=1024, + default=0, + ) - cls.volume_step_size = FloatProperty( - name="Step Size", - description="Distance between volume shader samples when rendering the volume " - "(lower values give more accurate and detailed results, but also increased render time)", - default=0.1, - min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4 - ) + transparent_max_bounces: IntProperty( + name="Transparent Max Bounces", + description="Maximum number of transparent bounces", + min=0, max=1024, + default=8, + ) - cls.volume_max_steps = IntProperty( - name="Max Steps", - description="Maximum number of steps through the volume before giving up, " - "to avoid extremely long render times with big objects or small step sizes", - default=1024, - min=2, max=65536 - ) + volume_step_size: FloatProperty( + name="Step Size", + description="Distance between volume shader samples when rendering the volume " + "(lower values give more accurate and detailed results, but also increased render time)", + default=0.1, + min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4 + ) - cls.dicing_rate = FloatProperty( - name="Dicing Rate", - description="Size of a micropolygon in pixels", - min=0.1, max=1000.0, soft_min=0.5, - default=1.0, - subtype="PIXEL" - ) - cls.preview_dicing_rate = FloatProperty( - name="Preview Dicing Rate", - description="Size of a micropolygon in pixels during preview render", - min=0.1, max=1000.0, soft_min=0.5, - default=8.0, - subtype="PIXEL" - ) + volume_max_steps: IntProperty( + name="Max Steps", + description="Maximum number of steps through the volume before giving up, " + "to avoid extremely long render times with big objects or small step sizes", + default=1024, + min=2, max=65536 + ) - cls.max_subdivisions = IntProperty( - name="Max Subdivisions", - description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation", - min=0, max=16, - default=12, - ) + dicing_rate: FloatProperty( + name="Dicing Rate", + description="Size of a micropolygon in pixels", + min=0.1, max=1000.0, soft_min=0.5, + default=1.0, + subtype="PIXEL" + ) + preview_dicing_rate: FloatProperty( + name="Preview Dicing Rate", + description="Size of a micropolygon in pixels during preview render", + min=0.1, max=1000.0, soft_min=0.5, + default=8.0, + subtype="PIXEL" + ) - cls.dicing_camera = PointerProperty( - name="Dicing Camera", - description="Camera to use as reference point when subdividing geometry, useful to avoid crawling " - "artifacts in animations when the scene camera is moving", - type=bpy.types.Object, - poll=lambda self, obj: obj.type == 'CAMERA', - ) - cls.offscreen_dicing_scale = FloatProperty( - name="Offscreen Dicing Scale", - description="Multiplier for dicing rate of geometry outside of the camera view. The dicing rate " - "of objects is gradually increased the further they are outside the camera view. " - "Lower values provide higher quality reflections and shadows for off screen objects, " - "while higher values use less memory", - min=1.0, soft_max=25.0, - default=4.0, - ) + max_subdivisions: IntProperty( + name="Max Subdivisions", + description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation", + min=0, max=16, + default=12, + ) - cls.film_exposure = FloatProperty( - name="Exposure", - description="Image brightness scale", - min=0.0, max=10.0, - default=1.0, - ) - cls.film_transparent = BoolProperty( - name="Transparent", - description="World background is transparent, for compositing the render over another background", - default=False, - ) - cls.film_transparent_glass = BoolProperty( - name="Transparent Glass", - description="Render transmissive surfaces as transparent, for compositing glass over another background", - default=False, - ) - cls.film_transparent_roughness = FloatProperty( - name="Transparent Roughness Threshold", - description="For transparent transmission, keep surfaces with roughness above the threshold opaque", - min=0.0, max=1.0, - default=0.1, - ) + dicing_camera: PointerProperty( + name="Dicing Camera", + description="Camera to use as reference point when subdividing geometry, useful to avoid crawling " + "artifacts in animations when the scene camera is moving", + type=bpy.types.Object, + poll=lambda self, obj: obj.type == 'CAMERA', + ) + offscreen_dicing_scale: FloatProperty( + name="Offscreen Dicing Scale", + description="Multiplier for dicing rate of geometry outside of the camera view. The dicing rate " + "of objects is gradually increased the further they are outside the camera view. " + "Lower values provide higher quality reflections and shadows for off screen objects, " + "while higher values use less memory", + min=1.0, soft_max=25.0, + default=4.0, + ) - # Really annoyingly, we have to keep it around for a few releases, - # otherwise forward compatibility breaks in really bad manner: CRASH! - # - # TODO(sergey): Remove this during 2.8x series of Blender. - cls.filter_type = EnumProperty( - name="Filter Type", - description="Pixel filter type", - items=enum_filter_types, - default='BLACKMAN_HARRIS', - ) + film_exposure: FloatProperty( + name="Exposure", + description="Image brightness scale", + min=0.0, max=10.0, + default=1.0, + ) + film_transparent: BoolProperty( + name="Transparent", + description="World background is transparent, for compositing the render over another background", + default=False, + ) + film_transparent_glass: BoolProperty( + name="Transparent Glass", + description="Render transmissive surfaces as transparent, for compositing glass over another background", + default=False, + ) + film_transparent_roughness: FloatProperty( + name="Transparent Roughness Threshold", + description="For transparent transmission, keep surfaces with roughness above the threshold opaque", + min=0.0, max=1.0, + default=0.1, + ) - cls.pixel_filter_type = EnumProperty( - name="Filter Type", - description="Pixel filter type", - items=enum_filter_types, - default='BLACKMAN_HARRIS', - ) + # Really annoyingly, we have to keep it around for a few releases, + # otherwise forward compatibility breaks in really bad manner: CRASH! + # + # TODO(sergey): Remove this during 2.8x series of Blender. + filter_type: EnumProperty( + name="Filter Type", + description="Pixel filter type", + items=enum_filter_types, + default='BLACKMAN_HARRIS', + ) - cls.filter_width = FloatProperty( - name="Filter Width", - description="Pixel filter width", - min=0.01, max=10.0, - default=1.5, - ) + pixel_filter_type: EnumProperty( + name="Filter Type", + description="Pixel filter type", + items=enum_filter_types, + default='BLACKMAN_HARRIS', + ) - cls.seed = IntProperty( - name="Seed", - description="Seed value for integrator to get different noise patterns", - min=0, max=2147483647, - default=0, - ) + filter_width: FloatProperty( + name="Filter Width", + description="Pixel filter width", + min=0.01, max=10.0, + default=1.5, + ) - cls.use_animated_seed = BoolProperty( - name="Use Animated Seed", - description="Use different seed values (and hence noise patterns) at different frames", - default=False, - ) + seed: IntProperty( + name="Seed", + description="Seed value for integrator to get different noise patterns", + min=0, max=2147483647, + default=0, + ) - cls.sample_clamp_direct = FloatProperty( - name="Clamp Direct", - description="If non-zero, the maximum value for a direct sample, " - "higher values will be scaled down to avoid too " - "much noise and slow convergence at the cost of accuracy", - min=0.0, max=1e8, - default=0.0, - ) + use_animated_seed: BoolProperty( + name="Use Animated Seed", + description="Use different seed values (and hence noise patterns) at different frames", + default=False, + ) - cls.sample_clamp_indirect = FloatProperty( - name="Clamp Indirect", - description="If non-zero, the maximum value for an indirect sample, " - "higher values will be scaled down to avoid too " - "much noise and slow convergence at the cost of accuracy", - min=0.0, max=1e8, - default=10.0, - ) + sample_clamp_direct: FloatProperty( + name="Clamp Direct", + description="If non-zero, the maximum value for a direct sample, " + "higher values will be scaled down to avoid too " + "much noise and slow convergence at the cost of accuracy", + min=0.0, max=1e8, + default=0.0, + ) - cls.debug_tile_size = IntProperty( - name="Tile Size", - description="", - min=1, max=4096, - default=1024, - ) + sample_clamp_indirect: FloatProperty( + name="Clamp Indirect", + description="If non-zero, the maximum value for an indirect sample, " + "higher values will be scaled down to avoid too " + "much noise and slow convergence at the cost of accuracy", + min=0.0, max=1e8, + default=10.0, + ) - cls.preview_start_resolution = IntProperty( - name="Start Resolution", - description="Resolution to start rendering preview at, " - "progressively increasing it to the full viewport size", - min=8, max=16384, - default=64, - ) + debug_tile_size: IntProperty( + name="Tile Size", + description="", + min=1, max=4096, + default=1024, + ) - cls.debug_reset_timeout = FloatProperty( - name="Reset timeout", - description="", - min=0.01, max=10.0, - default=0.1, - ) - cls.debug_cancel_timeout = FloatProperty( - name="Cancel timeout", - description="", - min=0.01, max=10.0, - default=0.1, - ) - cls.debug_text_timeout = FloatProperty( - name="Text timeout", - description="", - min=0.01, max=10.0, - default=1.0, - ) + preview_start_resolution: IntProperty( + name="Start Resolution", + description="Resolution to start rendering preview at, " + "progressively increasing it to the full viewport size", + min=8, max=16384, + default=64, + ) - cls.debug_bvh_type = EnumProperty( - name="Viewport BVH Type", - description="Choose between faster updates, or faster render", - items=enum_bvh_types, - default='DYNAMIC_BVH', - ) - cls.debug_use_spatial_splits = BoolProperty( - name="Use Spatial Splits", - description="Use BVH spatial splits: longer builder time, faster render", - default=False, - ) - cls.debug_use_hair_bvh = BoolProperty( - name="Use Hair BVH", - description="Use special type BVH optimized for hair (uses more ram but renders faster)", - default=True, - ) - cls.debug_bvh_time_steps = IntProperty( - name="BVH Time Steps", - description="Split BVH primitives by this number of time steps to speed up render time in cost of memory", - default=0, - min=0, max=16, - ) - cls.tile_order = EnumProperty( - name="Tile Order", - description="Tile order for rendering", - items=enum_tile_order, - default='HILBERT_SPIRAL', - options=set(), # Not animatable! - ) - cls.use_progressive_refine = BoolProperty( - name="Progressive Refine", - description="Instead of rendering each tile until it is finished, " - "refine the whole image progressively " - "(this renders somewhat slower, " - "but time can be saved by manually stopping the render when the noise is low enough)", - default=False, - ) + debug_reset_timeout: FloatProperty( + name="Reset timeout", + description="", + min=0.01, max=10.0, + default=0.1, + ) + debug_cancel_timeout: FloatProperty( + name="Cancel timeout", + description="", + min=0.01, max=10.0, + default=0.1, + ) + debug_text_timeout: FloatProperty( + name="Text timeout", + description="", + min=0.01, max=10.0, + default=1.0, + ) - cls.bake_type = EnumProperty( - name="Bake Type", - default='COMBINED', - description="Type of pass to bake", - items=( - ('COMBINED', "Combined", ""), - ('AO', "Ambient Occlusion", ""), - ('SHADOW', "Shadow", ""), - ('NORMAL', "Normal", ""), - ('UV', "UV", ""), - ('ROUGHNESS', "Roughness", ""), - ('EMIT', "Emit", ""), - ('ENVIRONMENT', "Environment", ""), - ('DIFFUSE', "Diffuse", ""), - ('GLOSSY', "Glossy", ""), - ('TRANSMISSION', "Transmission", ""), - ('SUBSURFACE', "Subsurface", ""), - ), - ) + debug_bvh_type: EnumProperty( + name="Viewport BVH Type", + description="Choose between faster updates, or faster render", + items=enum_bvh_types, + default='DYNAMIC_BVH', + ) + debug_use_spatial_splits: BoolProperty( + name="Use Spatial Splits", + description="Use BVH spatial splits: longer builder time, faster render", + default=False, + ) + debug_use_hair_bvh: BoolProperty( + name="Use Hair BVH", + description="Use special type BVH optimized for hair (uses more ram but renders faster)", + default=True, + ) + debug_bvh_time_steps: IntProperty( + name="BVH Time Steps", + description="Split BVH primitives by this number of time steps to speed up render time in cost of memory", + default=0, + min=0, max=16, + ) + tile_order: EnumProperty( + name="Tile Order", + description="Tile order for rendering", + items=enum_tile_order, + default='HILBERT_SPIRAL', + options=set(), # Not animatable! + ) + use_progressive_refine: BoolProperty( + name="Progressive Refine", + description="Instead of rendering each tile until it is finished, " + "refine the whole image progressively " + "(this renders somewhat slower, " + "but time can be saved by manually stopping the render when the noise is low enough)", + default=False, + ) - cls.use_camera_cull = BoolProperty( - name="Use Camera Cull", - description="Allow objects to be culled based on the camera frustum", - default=False, - ) + bake_type: EnumProperty( + name="Bake Type", + default='COMBINED', + description="Type of pass to bake", + items=( + ('COMBINED', "Combined", ""), + ('AO', "Ambient Occlusion", ""), + ('SHADOW', "Shadow", ""), + ('NORMAL', "Normal", ""), + ('UV', "UV", ""), + ('ROUGHNESS', "Roughness", ""), + ('EMIT', "Emit", ""), + ('ENVIRONMENT', "Environment", ""), + ('DIFFUSE', "Diffuse", ""), + ('GLOSSY', "Glossy", ""), + ('TRANSMISSION', "Transmission", ""), + ('SUBSURFACE', "Subsurface", ""), + ), + ) - cls.camera_cull_margin = FloatProperty( - name="Camera Cull Margin", - description="Margin for the camera space culling", - default=0.1, - min=0.0, max=5.0 - ) + use_camera_cull: BoolProperty( + name="Use Camera Cull", + description="Allow objects to be culled based on the camera frustum", + default=False, + ) - cls.use_distance_cull = BoolProperty( - name="Use Distance Cull", - description="Allow objects to be culled based on the distance from camera", - default=False, - ) + camera_cull_margin: FloatProperty( + name="Camera Cull Margin", + description="Margin for the camera space culling", + default=0.1, + min=0.0, max=5.0 + ) - cls.distance_cull_margin = FloatProperty( - name="Cull Distance", - description="Cull objects which are further away from camera than this distance", - default=50, - min=0.0 - ) + use_distance_cull: BoolProperty( + name="Use Distance Cull", + description="Allow objects to be culled based on the distance from camera", + default=False, + ) - cls.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"), - ), - ) + distance_cull_margin: FloatProperty( + name="Cull Distance", + description="Cull objects which are further away from camera than this distance", + default=50, + min=0.0 + ) - cls.rolling_shutter_type = EnumProperty( - name="Shutter Type", - default='NONE', - description="Type of rolling shutter effect matching CMOS-based cameras", - items=( - ('NONE', "None", "No rolling shutter effect used"), - ('TOP', "Top-Bottom", "Sensor is being scanned from top to bottom") - # TODO(seergey): Are there real cameras with different scanning direction? - ), - ) + 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"), + ), + ) - cls.rolling_shutter_duration = FloatProperty( - name="Rolling Shutter Duration", - description="Scanline \"exposure\" time for the rolling shutter effect", - default=0.1, - min=0.0, max=1.0, - ) + rolling_shutter_type: EnumProperty( + name="Shutter Type", + default='NONE', + description="Type of rolling shutter effect matching CMOS-based cameras", + items=( + ('NONE', "None", "No rolling shutter effect used"), + ('TOP', "Top-Bottom", "Sensor is being scanned from top to bottom") + # TODO(seergey): Are there real cameras with different scanning direction? + ), + ) - cls.texture_limit = EnumProperty( - name="Viewport Texture Limit", - default='OFF', - description="Limit texture size used by viewport rendering", - items=enum_texture_limit - ) + rolling_shutter_duration: FloatProperty( + name="Rolling Shutter Duration", + description="Scanline \"exposure\" time for the rolling shutter effect", + default=0.1, + min=0.0, max=1.0, + ) - cls.texture_limit_render = EnumProperty( - name="Render Texture Limit", - default='OFF', - description="Limit texture size used by final rendering", - items=enum_texture_limit - ) + texture_limit: EnumProperty( + name="Viewport Texture Limit", + default='OFF', + description="Limit texture size used by viewport rendering", + items=enum_texture_limit + ) - cls.ao_bounces = IntProperty( - name="AO Bounces", - default=0, - description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature", - min=0, max=1024, - ) + texture_limit_render: EnumProperty( + name="Render Texture Limit", + default='OFF', + description="Limit texture size used by final rendering", + items=enum_texture_limit + ) - cls.ao_bounces_render = IntProperty( - name="AO Bounces Render", - default=0, - description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature", - min=0, max=1024, - ) + ao_bounces: IntProperty( + name="AO Bounces", + default=0, + description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature", + min=0, max=1024, + ) - # Various fine-tuning debug flags - - def devices_update_callback(self, context): - import _cycles - scene = context.scene.as_pointer() - return _cycles.debug_flags_update(scene) - - cls.debug_use_cpu_avx2 = BoolProperty(name="AVX2", default=True) - cls.debug_use_cpu_avx = BoolProperty(name="AVX", default=True) - cls.debug_use_cpu_sse41 = BoolProperty(name="SSE41", default=True) - cls.debug_use_cpu_sse3 = BoolProperty(name="SSE3", default=True) - cls.debug_use_cpu_sse2 = BoolProperty(name="SSE2", default=True) - cls.debug_bvh_layout = EnumProperty( - name="BVH Layout", - items=enum_bvh_layouts, - default='BVH4', - ) - cls.debug_use_cpu_split_kernel = BoolProperty(name="Split Kernel", default=False) - - cls.debug_use_cuda_adaptive_compile = BoolProperty(name="Adaptive Compile", default=False) - cls.debug_use_cuda_split_kernel = BoolProperty(name="Split Kernel", default=False) - - cls.debug_opencl_kernel_type = EnumProperty( - name="OpenCL Kernel Type", - default='DEFAULT', - items=( - ('DEFAULT', "Default", ""), - ('MEGA', "Mega", ""), - ('SPLIT', "Split", ""), - ), - update=devices_update_callback - ) + ao_bounces_render: IntProperty( + name="AO Bounces Render", + default=0, + description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature", + min=0, max=1024, + ) - cls.debug_opencl_device_type = EnumProperty( - name="OpenCL Device Type", - default='ALL', - items=( - ('NONE', "None", ""), - ('ALL', "All", ""), - ('DEFAULT', "Default", ""), - ('CPU', "CPU", ""), - ('GPU', "GPU", ""), - ('ACCELERATOR', "Accelerator", ""), - ), - update=devices_update_callback - ) + # Various fine-tuning debug flags - cls.debug_opencl_kernel_single_program = BoolProperty( - name="Single Program", - default=True, - update=devices_update_callback, - ) + def _devices_update_callback(self, context): + import _cycles + scene = context.scene.as_pointer() + return _cycles.debug_flags_update(scene) + + debug_use_cpu_avx2: BoolProperty(name="AVX2", default=True) + debug_use_cpu_avx: BoolProperty(name="AVX", default=True) + debug_use_cpu_sse41: BoolProperty(name="SSE41", default=True) + debug_use_cpu_sse3: BoolProperty(name="SSE3", default=True) + debug_use_cpu_sse2: BoolProperty(name="SSE2", default=True) + debug_bvh_layout: EnumProperty( + name="BVH Layout", + items=enum_bvh_layouts, + default='BVH8', + ) + debug_use_cpu_split_kernel: BoolProperty(name="Split Kernel", default=False) + + debug_use_cuda_adaptive_compile: BoolProperty(name="Adaptive Compile", default=False) + debug_use_cuda_split_kernel: BoolProperty(name="Split Kernel", default=False) + + debug_opencl_kernel_type: EnumProperty( + name="OpenCL Kernel Type", + default='DEFAULT', + items=( + ('DEFAULT', "Default", ""), + ('MEGA', "Mega", ""), + ('SPLIT', "Split", ""), + ), + update=_devices_update_callback + ) + + debug_opencl_device_type: EnumProperty( + name="OpenCL Device Type", + default='ALL', + items=( + ('NONE', "None", ""), + ('ALL', "All", ""), + ('DEFAULT', "Default", ""), + ('CPU', "CPU", ""), + ('GPU', "GPU", ""), + ('ACCELERATOR', "Accelerator", ""), + ), + update=_devices_update_callback + ) + + debug_opencl_kernel_single_program: BoolProperty( + name="Single Program", + default=True, + update=_devices_update_callback, + ) + del _devices_update_callback - cls.debug_use_opencl_debug = BoolProperty(name="Debug OpenCL", default=False) + debug_use_opencl_debug: BoolProperty(name="Debug OpenCL", default=False) - cls.debug_opencl_mem_limit = IntProperty(name="Memory limit", default=0, - description="Artificial limit on OpenCL memory usage in MB (0 to disable limit)") + debug_opencl_mem_limit: IntProperty( + name="Memory limit", + default=0, + description="Artificial limit on OpenCL memory usage in MB (0 to disable limit)" + ) + + @classmethod + def register(cls): + bpy.types.Scene.cycles = PointerProperty( + name="Cycles Render Settings", + description="Cycles render settings", + type=cls, + ) @classmethod def unregister(cls): @@ -731,6 +740,98 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): class CyclesCameraSettings(bpy.types.PropertyGroup): + + aperture_type: EnumProperty( + name="Aperture Type", + description="Use f-stop number or aperture radius", + items=enum_aperture_types, + default='RADIUS', + ) + aperture_fstop: FloatProperty( + name="Aperture f-stop", + description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)", + min=0.0, soft_min=0.1, soft_max=64.0, + default=5.6, + step=10, + precision=1, + ) + aperture_size: FloatProperty( + name="Aperture Size", + description="Radius of the aperture for depth of field (higher values give more defocus)", + min=0.0, soft_max=10.0, + default=0.0, + step=1, + precision=4, + subtype='DISTANCE', + ) + aperture_blades: IntProperty( + name="Aperture Blades", + description="Number of blades in aperture for polygonal bokeh (at least 3)", + min=0, max=100, + default=0, + ) + aperture_rotation: FloatProperty( + name="Aperture Rotation", + description="Rotation of blades in aperture", + soft_min=-pi, soft_max=pi, + subtype='ANGLE', + default=0, + ) + aperture_ratio: FloatProperty( + name="Aperture Ratio", + description="Distortion to simulate anamorphic lens bokeh", + min=0.01, soft_min=1.0, soft_max=2.0, + default=1.0, + precision=4, + ) + panorama_type: EnumProperty( + name="Panorama Type", + description="Distortion to use for the calculation", + items=enum_panorama_types, + default='FISHEYE_EQUISOLID', + ) + fisheye_fov: FloatProperty( + name="Field of View", + description="Field of view for the fisheye lens", + min=0.1745, soft_max=2.0 * pi, max=10.0 * pi, + subtype='ANGLE', + default=pi, + ) + fisheye_lens: FloatProperty( + name="Fisheye Lens", + description="Lens focal length (mm)", + min=0.01, soft_max=15.0, max=100.0, + default=10.5, + ) + latitude_min: FloatProperty( + name="Min Latitude", + description="Minimum latitude (vertical angle) for the equirectangular lens", + min=-0.5 * pi, max=0.5 * pi, + subtype='ANGLE', + default=-0.5 * pi, + ) + latitude_max: FloatProperty( + name="Max Latitude", + description="Maximum latitude (vertical angle) for the equirectangular lens", + min=-0.5 * pi, max=0.5 * pi, + subtype='ANGLE', + default=0.5 * pi, + ) + longitude_min: FloatProperty( + name="Min Longitude", + description="Minimum longitude (horizontal angle) for the equirectangular lens", + min=-pi, max=pi, + subtype='ANGLE', + default=-pi, + ) + longitude_max: FloatProperty( + name="Max Longitude", + description="Maximum longitude (horizontal angle) for the equirectangular lens", + min=-pi, max=pi, + subtype='ANGLE', + default=pi, + ) + @classmethod def register(cls): import math @@ -741,103 +842,53 @@ class CyclesCameraSettings(bpy.types.PropertyGroup): type=cls, ) - cls.aperture_type = EnumProperty( - name="Aperture Type", - description="Use f-stop number or aperture radius", - items=enum_aperture_types, - default='RADIUS', - ) - cls.aperture_fstop = FloatProperty( - name="Aperture f-stop", - description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)", - min=0.0, soft_min=0.1, soft_max=64.0, - default=5.6, - step=10, - precision=1, - ) - cls.aperture_size = FloatProperty( - name="Aperture Size", - description="Radius of the aperture for depth of field (higher values give more defocus)", - min=0.0, soft_max=10.0, - default=0.0, - step=1, - precision=4, - subtype='DISTANCE', - ) - cls.aperture_blades = IntProperty( - name="Aperture Blades", - description="Number of blades in aperture for polygonal bokeh (at least 3)", - min=0, max=100, - default=0, - ) - cls.aperture_rotation = FloatProperty( - name="Aperture Rotation", - description="Rotation of blades in aperture", - soft_min=-math.pi, soft_max=math.pi, - subtype='ANGLE', - default=0, - ) - cls.aperture_ratio = FloatProperty( - name="Aperture Ratio", - description="Distortion to simulate anamorphic lens bokeh", - min=0.01, soft_min=1.0, soft_max=2.0, - default=1.0, - precision=4, - ) - cls.panorama_type = EnumProperty( - name="Panorama Type", - description="Distortion to use for the calculation", - items=enum_panorama_types, - default='FISHEYE_EQUISOLID', - ) - cls.fisheye_fov = FloatProperty( - name="Field of View", - description="Field of view for the fisheye lens", - min=0.1745, soft_max=2.0 * math.pi, max=10.0 * math.pi, - subtype='ANGLE', - default=math.pi, - ) - cls.fisheye_lens = FloatProperty( - name="Fisheye Lens", - description="Lens focal length (mm)", - min=0.01, soft_max=15.0, max=100.0, - default=10.5, - ) - cls.latitude_min = FloatProperty( - name="Min Latitude", - description="Minimum latitude (vertical angle) for the equirectangular lens", - min=-0.5 * math.pi, max=0.5 * math.pi, - subtype='ANGLE', - default=-0.5 * math.pi, - ) - cls.latitude_max = FloatProperty( - name="Max Latitude", - description="Maximum latitude (vertical angle) for the equirectangular lens", - min=-0.5 * math.pi, max=0.5 * math.pi, - subtype='ANGLE', - default=0.5 * math.pi, - ) - cls.longitude_min = FloatProperty( - name="Min Longitude", - description="Minimum longitude (horizontal angle) for the equirectangular lens", - min=-math.pi, max=math.pi, - subtype='ANGLE', - default=-math.pi, - ) - cls.longitude_max = FloatProperty( - name="Max Longitude", - description="Maximum longitude (horizontal angle) for the equirectangular lens", - min=-math.pi, max=math.pi, - subtype='ANGLE', - default=math.pi, - ) - @classmethod def unregister(cls): del bpy.types.Camera.cycles class CyclesMaterialSettings(bpy.types.PropertyGroup): + + sample_as_light: BoolProperty( + name="Multiple Importance Sample", + description="Use multiple importance sampling for this material, " + "disabling may reduce overall noise for large " + "objects that emit little light compared to other light sources", + default=True, + ) + use_transparent_shadow: BoolProperty( + name="Transparent Shadows", + description="Use transparent shadows for this material if it contains a Transparent BSDF, " + "disabling will render faster but not give accurate shadows", + default=True, + ) + homogeneous_volume: BoolProperty( + name="Homogeneous Volume", + description="When using volume rendering, assume volume has the same density everywhere " + "(not using any textures), for faster rendering", + default=False, + ) + volume_sampling: EnumProperty( + name="Volume Sampling", + description="Sampling method to use for volumes", + items=enum_volume_sampling, + default='MULTIPLE_IMPORTANCE', + ) + + volume_interpolation: EnumProperty( + name="Volume Interpolation", + description="Interpolation method to use for smoke/fire volumes", + items=enum_volume_interpolation, + default='LINEAR', + ) + + displacement_method: EnumProperty( + name="Displacement Method", + description="Method to use for the displacement", + items=enum_displacement_methods, + default='DISPLACEMENT', + ) + @classmethod def register(cls): bpy.types.Material.cycles = PointerProperty( @@ -845,45 +896,6 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup): description="Cycles material settings", type=cls, ) - cls.sample_as_light = BoolProperty( - name="Multiple Importance Sample", - description="Use multiple importance sampling for this material, " - "disabling may reduce overall noise for large " - "objects that emit little light compared to other light sources", - default=True, - ) - cls.use_transparent_shadow = BoolProperty( - name="Transparent Shadows", - description="Use transparent shadows for this material if it contains a Transparent BSDF, " - "disabling will render faster but not give accurate shadows", - default=True, - ) - cls.homogeneous_volume = BoolProperty( - name="Homogeneous Volume", - description="When using volume rendering, assume volume has the same density everywhere " - "(not using any textures), for faster rendering", - default=False, - ) - cls.volume_sampling = EnumProperty( - name="Volume Sampling", - description="Sampling method to use for volumes", - items=enum_volume_sampling, - default='MULTIPLE_IMPORTANCE', - ) - - cls.volume_interpolation = EnumProperty( - name="Volume Interpolation", - description="Interpolation method to use for smoke/fire volumes", - items=enum_volume_interpolation, - default='LINEAR', - ) - - cls.displacement_method = EnumProperty( - name="Displacement Method", - description="Method to use for the displacement", - items=enum_displacement_methods, - default='DISPLACEMENT', - ) @classmethod def unregister(cls): @@ -891,6 +903,37 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup): class CyclesLightSettings(bpy.types.PropertyGroup): + + cast_shadow: BoolProperty( + name="Cast Shadow", + description="Light casts shadows", + default=True, + ) + samples: IntProperty( + name="Samples", + description="Number of light samples to render for each AA sample", + min=1, max=10000, + default=1, + ) + max_bounces: IntProperty( + name="Max Bounces", + description="Maximum number of bounces the light will contribute to the render", + min=0, max=1024, + default=1024, + ) + use_multiple_importance_sampling: BoolProperty( + name="Multiple Importance Sample", + description="Use multiple importance sampling for the light, " + "reduces noise for area lights and sharp glossy materials", + default=True, + ) + is_portal: BoolProperty( + name="Is Portal", + description="Use this area light to guide sampling of the background, " + "note that this will make the light invisible", + default=False, + ) + @classmethod def register(cls): bpy.types.Light.cycles = PointerProperty( @@ -898,35 +941,6 @@ class CyclesLightSettings(bpy.types.PropertyGroup): description="Cycles light settings", type=cls, ) - cls.cast_shadow = BoolProperty( - name="Cast Shadow", - description="Light casts shadows", - default=True, - ) - cls.samples = IntProperty( - name="Samples", - description="Number of light samples to render for each AA sample", - min=1, max=10000, - default=1, - ) - cls.max_bounces = IntProperty( - name="Max Bounces", - description="Maximum number of bounces the light will contribute to the render", - min=0, max=1024, - default=1024, - ) - cls.use_multiple_importance_sampling = BoolProperty( - name="Multiple Importance Sample", - description="Use multiple importance sampling for the light, " - "reduces noise for area lights and sharp glossy materials", - default=True, - ) - cls.is_portal = BoolProperty( - name="Is Portal", - description="Use this area light to guide sampling of the background, " - "note that this will make the light invisible", - default=False, - ) @classmethod def unregister(cls): @@ -934,6 +948,51 @@ class CyclesLightSettings(bpy.types.PropertyGroup): class CyclesWorldSettings(bpy.types.PropertyGroup): + + sampling_method: EnumProperty( + name="Sampling method", + description="How to sample the background light", + items=enum_world_mis, + default='AUTOMATIC', + ) + sample_map_resolution: IntProperty( + name="Map Resolution", + description="Importance map size is resolution x resolution/2; " + "higher values potentially produce less noise, at the cost of memory and speed", + min=4, max=8192, + default=1024, + ) + samples: IntProperty( + name="Samples", + description="Number of light samples to render for each AA sample", + min=1, max=10000, + default=1, + ) + max_bounces: IntProperty( + name="Max Bounces", + description="Maximum number of bounces the background light will contribute to the render", + min=0, max=1024, + default=1024, + ) + homogeneous_volume: BoolProperty( + name="Homogeneous Volume", + description="When using volume rendering, assume volume has the same density everywhere" + "(not using any textures), for faster rendering", + default=False, + ) + volume_sampling: EnumProperty( + name="Volume Sampling", + description="Sampling method to use for volumes", + items=enum_volume_sampling, + default='EQUIANGULAR', + ) + volume_interpolation: EnumProperty( + name="Volume Interpolation", + description="Interpolation method to use for volumes", + items=enum_volume_interpolation, + default='LINEAR', + ) + @classmethod def register(cls): bpy.types.World.cycles = PointerProperty( @@ -941,50 +1000,6 @@ class CyclesWorldSettings(bpy.types.PropertyGroup): description="Cycles world settings", type=cls, ) - cls.sampling_method = EnumProperty( - name="Sampling method", - description="How to sample the background light", - items=enum_world_mis, - default='AUTOMATIC', - ) - cls.sample_map_resolution = IntProperty( - name="Map Resolution", - description="Importance map size is resolution x resolution/2; " - "higher values potentially produce less noise, at the cost of memory and speed", - min=4, max=8192, - default=1024, - ) - cls.samples = IntProperty( - name="Samples", - description="Number of light samples to render for each AA sample", - min=1, max=10000, - default=1, - ) - cls.max_bounces = IntProperty( - name="Max Bounces", - description="Maximum number of bounces the background light will contribute to the render", - min=0, max=1024, - default=1024, - ) - cls.homogeneous_volume = BoolProperty( - name="Homogeneous Volume", - description="When using volume rendering, assume volume has the same density everywhere" - "(not using any textures), for faster rendering", - default=False, - ) - cls.volume_sampling = EnumProperty( - name="Volume Sampling", - description="Sampling method to use for volumes", - items=enum_volume_sampling, - default='EQUIANGULAR', - ) - - cls.volume_interpolation = EnumProperty( - name="Volume Interpolation", - description="Interpolation method to use for volumes", - items=enum_volume_interpolation, - default='LINEAR', - ) @classmethod def unregister(cls): @@ -992,6 +1007,38 @@ class CyclesWorldSettings(bpy.types.PropertyGroup): class CyclesVisibilitySettings(bpy.types.PropertyGroup): + + camera: BoolProperty( + name="Camera", + description="Object visibility for camera rays", + default=True, + ) + diffuse: BoolProperty( + name="Diffuse", + description="Object visibility for diffuse reflection rays", + default=True, + ) + glossy: BoolProperty( + name="Glossy", + description="Object visibility for glossy reflection rays", + default=True, + ) + transmission: BoolProperty( + name="Transmission", + description="Object visibility for transmission rays", + default=True, + ) + shadow: BoolProperty( + name="Shadow", + description="Object visibility for shadow rays", + default=True, + ) + scatter: BoolProperty( + name="Volume Scatter", + description="Object visibility for volume scatter rays", + default=True, + ) + @classmethod def register(cls): bpy.types.Object.cycles_visibility = PointerProperty( @@ -1006,37 +1053,6 @@ class CyclesVisibilitySettings(bpy.types.PropertyGroup): type=cls, ) - cls.camera = BoolProperty( - name="Camera", - description="Object visibility for camera rays", - default=True, - ) - cls.diffuse = BoolProperty( - name="Diffuse", - description="Object visibility for diffuse reflection rays", - default=True, - ) - cls.glossy = BoolProperty( - name="Glossy", - description="Object visibility for glossy reflection rays", - default=True, - ) - cls.transmission = BoolProperty( - name="Transmission", - description="Object visibility for transmission rays", - default=True, - ) - cls.shadow = BoolProperty( - name="Shadow", - description="Object visibility for shadow rays", - default=True, - ) - cls.scatter = BoolProperty( - name="Volume Scatter", - description="Object visibility for volume scatter rays", - default=True, - ) - @classmethod def unregister(cls): del bpy.types.Object.cycles_visibility @@ -1070,70 +1086,71 @@ class CyclesMeshSettings(bpy.types.PropertyGroup): class CyclesObjectSettings(bpy.types.PropertyGroup): - @classmethod - def register(cls): - bpy.types.Object.cycles = PointerProperty( - name="Cycles Object Settings", - description="Cycles object settings", - type=cls, - ) - cls.use_motion_blur = BoolProperty( - name="Use Motion Blur", - description="Use motion blur for this object", - default=True, - ) + use_motion_blur: BoolProperty( + name="Use Motion Blur", + description="Use motion blur for this object", + default=True, + ) - cls.use_deform_motion = BoolProperty( - name="Use Deformation Motion", - description="Use deformation motion blur for this object", - default=True, - ) + use_deform_motion: BoolProperty( + name="Use Deformation Motion", + description="Use deformation motion blur for this object", + default=True, + ) - cls.motion_steps = IntProperty( - name="Motion Steps", - description="Control accuracy of motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))", - min=1, soft_max=8, - default=1, - ) + motion_steps: IntProperty( + name="Motion Steps", + description="Control accuracy of motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))", + min=1, soft_max=8, + default=1, + ) - cls.use_camera_cull = BoolProperty( - name="Use Camera Cull", - description="Allow this object and its duplicators to be culled by camera space culling", - default=False, - ) + use_camera_cull: BoolProperty( + name="Use Camera Cull", + description="Allow this object and its duplicators to be culled by camera space culling", + default=False, + ) - cls.use_distance_cull = BoolProperty( - name="Use Distance Cull", - description="Allow this object and its duplicators to be culled by distance from camera", - default=False, - ) + use_distance_cull: BoolProperty( + name="Use Distance Cull", + description="Allow this object and its duplicators to be culled by distance from camera", + default=False, + ) - cls.use_adaptive_subdivision = BoolProperty( - name="Use Adaptive Subdivision", - description="Use adaptive render time subdivision", - default=False, - ) + use_adaptive_subdivision: BoolProperty( + name="Use Adaptive Subdivision", + description="Use adaptive render time subdivision", + default=False, + ) - cls.dicing_rate = FloatProperty( - name="Dicing Scale", - description="Multiplier for scene dicing rate (located in the Geometry Panel)", - min=0.1, max=1000.0, soft_min=0.5, - default=1.0, - ) + dicing_rate: FloatProperty( + name="Dicing Scale", + description="Multiplier for scene dicing rate (located in the Geometry Panel)", + min=0.1, max=1000.0, soft_min=0.5, + default=1.0, + ) - cls.is_shadow_catcher = BoolProperty( - name="Shadow Catcher", - description="Only render shadows on this object, for compositing renders into real footage", - default=False, - ) + is_shadow_catcher: BoolProperty( + name="Shadow Catcher", + description="Only render shadows on this object, for compositing renders into real footage", + default=False, + ) - cls.is_holdout = BoolProperty( - name="Holdout", - description="Render objects as a holdout or matte, creating a " - "hole in the image with zero alpha, to fill out in " - "compositing with real footange or another render", - default=False, + is_holdout: BoolProperty( + name="Holdout", + description="Render objects as a holdout or matte, creating a " + "hole in the image with zero alpha, to fill out in " + "compositing with real footange or another render", + default=False, + ) + + @classmethod + def register(cls): + bpy.types.Object.cycles = PointerProperty( + name="Cycles Object Settings", + description="Cycles object settings", + type=cls, ) @classmethod @@ -1142,6 +1159,54 @@ class CyclesObjectSettings(bpy.types.PropertyGroup): class CyclesCurveRenderSettings(bpy.types.PropertyGroup): + + primitive: EnumProperty( + name="Primitive", + description="Type of primitive used for hair rendering", + items=enum_curve_primitives, + default='LINE_SEGMENTS', + ) + shape: EnumProperty( + name="Shape", + description="Form of hair", + items=enum_curve_shape, + default='THICK', + ) + cull_backfacing: BoolProperty( + name="Cull Back-faces", + description="Do not test the back-face of each strand", + default=True, + ) + use_curves: BoolProperty( + name="Use Cycles Hair Rendering", + description="Activate Cycles hair rendering for particle system", + default=True, + ) + resolution: IntProperty( + name="Resolution", + description="Resolution of generated mesh", + min=3, max=64, + default=3, + ) + minimum_width: FloatProperty( + name="Minimal width", + description="Minimal pixel width for strands (0 - deactivated)", + min=0.0, max=100.0, + default=0.0, + ) + maximum_width: FloatProperty( + name="Maximal width", + description="Maximum extension that strand radius can be increased by", + min=0.0, max=100.0, + default=0.1, + ) + subdivisions: IntProperty( + name="Subdivisions", + description="Number of subdivisions used in Cardinal curve intersection (power of 2)", + min=0, max=24, + default=4, + ) + @classmethod def register(cls): bpy.types.Scene.cycles_curves = PointerProperty( @@ -1149,52 +1214,6 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup): description="Cycles hair rendering settings", type=cls, ) - cls.primitive = EnumProperty( - name="Primitive", - description="Type of primitive used for hair rendering", - items=enum_curve_primitives, - default='LINE_SEGMENTS', - ) - cls.shape = EnumProperty( - name="Shape", - description="Form of hair", - items=enum_curve_shape, - default='THICK', - ) - cls.cull_backfacing = BoolProperty( - name="Cull Back-faces", - description="Do not test the back-face of each strand", - default=True, - ) - cls.use_curves = BoolProperty( - name="Use Cycles Hair Rendering", - description="Activate Cycles hair rendering for particle system", - default=True, - ) - cls.resolution = IntProperty( - name="Resolution", - description="Resolution of generated mesh", - min=3, max=64, - default=3, - ) - cls.minimum_width = FloatProperty( - name="Minimal width", - description="Minimal pixel width for strands (0 - deactivated)", - min=0.0, max=100.0, - default=0.0, - ) - cls.maximum_width = FloatProperty( - name="Maximal width", - description="Maximum extension that strand radius can be increased by", - min=0.0, max=100.0, - default=0.1, - ) - cls.subdivisions = IntProperty( - name="Subdivisions", - description="Number of subdivisions used in Cardinal curve intersection (power of 2)", - min=0, max=24, - default=4, - ) @classmethod def unregister(cls): @@ -1209,6 +1228,126 @@ def update_render_passes(self, context): class CyclesRenderLayerSettings(bpy.types.PropertyGroup): + + pass_debug_bvh_traversed_nodes: BoolProperty( + name="Debug BVH Traversed Nodes", + description="Store Debug BVH Traversed Nodes pass", + default=False, + update=update_render_passes, + ) + pass_debug_bvh_traversed_instances: BoolProperty( + name="Debug BVH Traversed Instances", + description="Store Debug BVH Traversed Instances pass", + default=False, + update=update_render_passes, + ) + pass_debug_bvh_intersections: BoolProperty( + name="Debug BVH Intersections", + description="Store Debug BVH Intersections", + default=False, + update=update_render_passes, + ) + pass_debug_ray_bounces: BoolProperty( + name="Debug Ray Bounces", + description="Store Debug Ray Bounces pass", + default=False, + update=update_render_passes, + ) + pass_debug_render_time: BoolProperty( + name="Debug Render Time", + description="Render time in milliseconds per sample and pixel", + default=False, + update=update_render_passes, + ) + use_pass_volume_direct: BoolProperty( + name="Volume Direct", + description="Deliver direct volumetric scattering pass", + default=False, + update=update_render_passes, + ) + use_pass_volume_indirect: BoolProperty( + name="Volume Indirect", + description="Deliver indirect volumetric scattering pass", + default=False, + update=update_render_passes, + ) + + use_denoising: BoolProperty( + name="Use Denoising", + description="Denoise the rendered image", + default=False, + update=update_render_passes, + ) + denoising_diffuse_direct: BoolProperty( + name="Diffuse Direct", + description="Denoise the direct diffuse lighting", + default=True, + ) + denoising_diffuse_indirect: BoolProperty( + name="Diffuse Indirect", + description="Denoise the indirect diffuse lighting", + default=True, + ) + denoising_glossy_direct: BoolProperty( + name="Glossy Direct", + description="Denoise the direct glossy lighting", + default=True, + ) + denoising_glossy_indirect: BoolProperty( + name="Glossy Indirect", + description="Denoise the indirect glossy lighting", + default=True, + ) + denoising_transmission_direct: BoolProperty( + name="Transmission Direct", + description="Denoise the direct transmission lighting", + default=True, + ) + denoising_transmission_indirect: BoolProperty( + name="Transmission Indirect", + description="Denoise the indirect transmission lighting", + default=True, + ) + denoising_subsurface_direct: BoolProperty( + name="Subsurface Direct", + description="Denoise the direct subsurface lighting", + default=True, + ) + denoising_subsurface_indirect: BoolProperty( + name="Subsurface Indirect", + description="Denoise the indirect subsurface lighting", + default=True, + ) + denoising_strength: FloatProperty( + name="Denoising Strength", + description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)", + min=0.0, max=1.0, + default=0.5, + ) + denoising_feature_strength: FloatProperty( + name="Denoising Feature Strength", + description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)", + min=0.0, max=1.0, + default=0.5, + ) + denoising_radius: IntProperty( + name="Denoising Radius", + description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)", + min=1, max=25, + default=8, + ) + denoising_relative_pca: BoolProperty( + name="Relative filter", + description="When removing pixels that don't carry information, use a relative threshold instead of an absolute one (can help to reduce artifacts, but might cause detail loss around edges)", + default=False, + ) + denoising_store_passes: BoolProperty( + name="Store denoising passes", + description="Store the denoising feature passes and the noisy image", + default=False, + update=update_render_passes, + ) + @classmethod def register(cls): bpy.types.ViewLayer.cycles = PointerProperty( @@ -1216,124 +1355,6 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup): description="Cycles ViewLayer Settings", type=cls, ) - cls.pass_debug_bvh_traversed_nodes = BoolProperty( - name="Debug BVH Traversed Nodes", - description="Store Debug BVH Traversed Nodes pass", - default=False, - update=update_render_passes, - ) - cls.pass_debug_bvh_traversed_instances = BoolProperty( - name="Debug BVH Traversed Instances", - description="Store Debug BVH Traversed Instances pass", - default=False, - update=update_render_passes, - ) - cls.pass_debug_bvh_intersections = BoolProperty( - name="Debug BVH Intersections", - description="Store Debug BVH Intersections", - default=False, - update=update_render_passes, - ) - cls.pass_debug_ray_bounces = BoolProperty( - name="Debug Ray Bounces", - description="Store Debug Ray Bounces pass", - default=False, - update=update_render_passes, - ) - cls.pass_debug_render_time = BoolProperty( - name="Debug Render Time", - description="Render time in milliseconds per sample and pixel", - default=False, - update=update_render_passes, - ) - cls.use_pass_volume_direct = BoolProperty( - name="Volume Direct", - description="Deliver direct volumetric scattering pass", - default=False, - update=update_render_passes, - ) - cls.use_pass_volume_indirect = BoolProperty( - name="Volume Indirect", - description="Deliver indirect volumetric scattering pass", - default=False, - update=update_render_passes, - ) - - cls.use_denoising = BoolProperty( - name="Use Denoising", - description="Denoise the rendered image", - default=False, - update=update_render_passes, - ) - cls.denoising_diffuse_direct = BoolProperty( - name="Diffuse Direct", - description="Denoise the direct diffuse lighting", - default=True, - ) - cls.denoising_diffuse_indirect = BoolProperty( - name="Diffuse Indirect", - description="Denoise the indirect diffuse lighting", - default=True, - ) - cls.denoising_glossy_direct = BoolProperty( - name="Glossy Direct", - description="Denoise the direct glossy lighting", - default=True, - ) - cls.denoising_glossy_indirect = BoolProperty( - name="Glossy Indirect", - description="Denoise the indirect glossy lighting", - default=True, - ) - cls.denoising_transmission_direct = BoolProperty( - name="Transmission Direct", - description="Denoise the direct transmission lighting", - default=True, - ) - cls.denoising_transmission_indirect = BoolProperty( - name="Transmission Indirect", - description="Denoise the indirect transmission lighting", - default=True, - ) - cls.denoising_subsurface_direct = BoolProperty( - name="Subsurface Direct", - description="Denoise the direct subsurface lighting", - default=True, - ) - cls.denoising_subsurface_indirect = BoolProperty( - name="Subsurface Indirect", - description="Denoise the indirect subsurface lighting", - default=True, - ) - cls.denoising_strength = FloatProperty( - name="Denoising Strength", - description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)", - min=0.0, max=1.0, - default=0.5, - ) - cls.denoising_feature_strength = FloatProperty( - name="Denoising Feature Strength", - description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)", - min=0.0, max=1.0, - default=0.5, - ) - cls.denoising_radius = IntProperty( - name="Denoising Radius", - description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)", - min=1, max=25, - default=8, - ) - cls.denoising_relative_pca = BoolProperty( - name="Relative filter", - description="When removing pixels that don't carry information, use a relative threshold instead of an absolute one (can help to reduce artifacts, but might cause detail loss around edges)", - default=False, - ) - cls.denoising_store_passes = BoolProperty( - name="Store denoising passes", - description="Store the denoising feature passes and the noisy image", - default=False, - update=update_render_passes, - ) @classmethod def unregister(cls): diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 0ad3a8ba5ac..76706a83e30 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -129,15 +129,15 @@ def draw_samples_info(layout, context): if use_branched_path(context) or (cscene.use_square_samples and integrator == 'PATH'): col = layout.column(align=True) col.scale_y = 0.6 - col.label("Total Samples:") + col.label(text="Total Samples:") col.separator() if integrator == 'PATH': - col.label("%s AA" % aa) + col.label(text="%s AA" % aa) else: - col.label("%s AA, %s Diffuse, %s Glossy, %s Transmission" % + col.label(text="%s AA, %s Diffuse, %s Glossy, %s Transmission" % (aa, d * aa, g * aa, t * aa)) col.separator() - col.label("%s AO, %s Mesh Light, %s Subsurface, %s Volume" % + col.label(text="%s AO, %s Mesh Light, %s Subsurface, %s Volume" % (ao * aa, ml * aa, sss * aa, vol * aa)) @@ -655,13 +655,13 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel): view_layer = context.view_layer col = layout.column() - col.prop(view_layer, "use_sky", "Use Environment") - col.prop(view_layer, "use_ao", "Use Ambient Occlusion") - col.prop(view_layer, "use_solid", "Use Surfaces") - col.prop(view_layer, "use_strand", "Use Hair") + col.prop(view_layer, "use_sky", text="Use Environment") + col.prop(view_layer, "use_ao", text="Use Ambient Occlusion") + col.prop(view_layer, "use_solid", text="Use Surfaces") + col.prop(view_layer, "use_strand", text="Use Hair") if with_freestyle: row = col.row() - row.prop(view_layer, "use_freestyle", "Use Freestyle") + row.prop(view_layer, "use_freestyle", text="Use Freestyle") row.active = rd.use_freestyle @@ -802,28 +802,28 @@ class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel): layout.use_property_split = False - split = layout.split(percentage=0.5) + split = layout.split(factor=0.5) split.label(text="Diffuse") col = split.column() row = col.row(align=True) row.prop(cycles_view_layer, "denoising_diffuse_direct", text="Direct", toggle=True) row.prop(cycles_view_layer, "denoising_diffuse_indirect", text="Indirect", toggle=True) - split = layout.split(percentage=0.5) + split = layout.split(factor=0.5) split.label(text="Glossy") col = split.column() row = col.row(align=True) row.prop(cycles_view_layer, "denoising_glossy_direct", text="Direct", toggle=True) row.prop(cycles_view_layer, "denoising_glossy_indirect", text="Indirect", toggle=True) - split = layout.split(percentage=0.5) + split = layout.split(factor=0.5) split.label(text="Transmission") col = split.column() row = col.row(align=True) row.prop(cycles_view_layer, "denoising_transmission_direct", text="Direct", toggle=True) row.prop(cycles_view_layer, "denoising_transmission_indirect", text="Indirect", toggle=True) - split = layout.split(percentage=0.5) + split = layout.split(factor=0.5) split.label(text="Subsurface") col = split.column() row = col.row(align=True) @@ -974,7 +974,7 @@ class CYCLES_PT_context_material(CyclesButtonsPanel, Panel): row.operator("object.material_slot_select", text="Select") row.operator("object.material_slot_deselect", text="Deselect") - split = layout.split(percentage=0.65) + split = layout.split(factor=0.65) if ob: split.template_ID(ob, "active_material", new="material.new") @@ -1671,7 +1671,7 @@ class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel): col = layout.column() - col.label('CPU Flags:') + col.label(text="CPU Flags:") row = col.row(align=True) row.prop(cscene, "debug_use_cpu_sse2", toggle=True) row.prop(cscene, "debug_use_cpu_sse3", toggle=True) @@ -1684,14 +1684,14 @@ class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel): col.separator() col = layout.column() - col.label('CUDA Flags:') + col.label(text="CUDA Flags:") col.prop(cscene, "debug_use_cuda_adaptive_compile") col.prop(cscene, "debug_use_cuda_split_kernel") col.separator() col = layout.column() - col.label('OpenCL Flags:') + col.label(text="OpenCL Flags:") col.prop(cscene, "debug_opencl_kernel_type", text="Kernel") col.prop(cscene, "debug_opencl_device_type", text="Device") col.prop(cscene, "debug_opencl_kernel_single_program", text="Single Program") diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 05adb6f5fe0..4ac0e1f21c1 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -412,21 +412,19 @@ void BlenderSession::render(BL::Depsgraph& b_depsgraph_) PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles"); bool use_denoising = get_boolean(crl, "use_denoising"); - buffer_params.denoising_data_pass = use_denoising; + session->tile_manager.schedule_denoising = use_denoising; + buffer_params.denoising_data_pass = use_denoising; + buffer_params.denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES); + session->params.use_denoising = use_denoising; + session->params.denoising_radius = get_int(crl, "denoising_radius"); + session->params.denoising_strength = get_float(crl, "denoising_strength"); + session->params.denoising_feature_strength = get_float(crl, "denoising_feature_strength"); + session->params.denoising_relative_pca = get_boolean(crl, "denoising_relative_pca"); + scene->film->denoising_data_pass = buffer_params.denoising_data_pass; - scene->film->denoising_flags = 0; - if(!get_boolean(crl, "denoising_diffuse_direct")) scene->film->denoising_flags |= DENOISING_CLEAN_DIFFUSE_DIR; - if(!get_boolean(crl, "denoising_diffuse_indirect")) scene->film->denoising_flags |= DENOISING_CLEAN_DIFFUSE_IND; - if(!get_boolean(crl, "denoising_glossy_direct")) scene->film->denoising_flags |= DENOISING_CLEAN_GLOSSY_DIR; - if(!get_boolean(crl, "denoising_glossy_indirect")) scene->film->denoising_flags |= DENOISING_CLEAN_GLOSSY_IND; - if(!get_boolean(crl, "denoising_transmission_direct")) scene->film->denoising_flags |= DENOISING_CLEAN_TRANSMISSION_DIR; - if(!get_boolean(crl, "denoising_transmission_indirect")) scene->film->denoising_flags |= DENOISING_CLEAN_TRANSMISSION_IND; - if(!get_boolean(crl, "denoising_subsurface_direct")) scene->film->denoising_flags |= DENOISING_CLEAN_SUBSURFACE_DIR; - if(!get_boolean(crl, "denoising_subsurface_indirect")) scene->film->denoising_flags |= DENOISING_CLEAN_SUBSURFACE_IND; - scene->film->denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES); - buffer_params.denoising_clean_pass = scene->film->denoising_clean_pass; + scene->film->denoising_clean_pass = buffer_params.denoising_clean_pass; session->params.denoising_radius = get_int(crl, "denoising_radius"); session->params.denoising_strength = get_float(crl, "denoising_strength"); session->params.denoising_feature_strength = get_float(crl, "denoising_feature_strength"); diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 62c160ca503..439f6bdd32e 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -1038,7 +1038,7 @@ static void add_nodes(Scene *scene, for(b_node->internal_links.begin(b_link); b_link != b_node->internal_links.end(); ++b_link) { BL::NodeSocket to_socket(b_link->to_socket()); SocketType::Type to_socket_type = convert_socket_type(to_socket); - if (to_socket_type == SocketType::UNDEFINED) { + if(to_socket_type == SocketType::UNDEFINED) { continue; } @@ -1065,7 +1065,7 @@ static void add_nodes(Scene *scene, */ for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) { SocketType::Type input_type = convert_socket_type(*b_input); - if (input_type == SocketType::UNDEFINED) { + if(input_type == SocketType::UNDEFINED) { continue; } @@ -1081,7 +1081,7 @@ static void add_nodes(Scene *scene, } for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) { SocketType::Type output_type = convert_socket_type(*b_output); - if (output_type == SocketType::UNDEFINED) { + if(output_type == SocketType::UNDEFINED) { continue; } diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index d679ad1ee2e..4989746ae6a 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -473,6 +473,7 @@ int BlenderSync::get_denoising_pass(BL::RenderPass& b_pass) MAP_PASS("Shadow B", DENOISING_PASS_SHADOW_B); MAP_PASS("Image", DENOISING_PASS_COLOR); MAP_PASS("Image Variance", DENOISING_PASS_COLOR_VAR); + MAP_PASS("Clean", DENOISING_PASS_CLEAN); #undef MAP_PASS return -1; @@ -502,6 +503,7 @@ array<Pass> BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay, Pass::add(pass_type, passes); } + scene->film->denoising_flags = 0; PointerRNA crp = RNA_pointer_get(&b_view_layer.ptr, "cycles"); if(get_boolean(crp, "denoising_store_passes") && get_boolean(crp, "use_denoising")) @@ -516,6 +518,21 @@ array<Pass> BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay, b_engine.add_pass("Denoising Shadow B", 3, "XYV", b_view_layer.name().c_str()); b_engine.add_pass("Denoising Image", 3, "RGB", b_view_layer.name().c_str()); b_engine.add_pass("Denoising Image Variance", 3, "RGB", b_view_layer.name().c_str()); + +#define MAP_OPTION(name, flag) if(!get_boolean(crp, name)) scene->film->denoising_flags |= flag; + MAP_OPTION("denoising_diffuse_direct", DENOISING_CLEAN_DIFFUSE_DIR); + MAP_OPTION("denoising_diffuse_indirect", DENOISING_CLEAN_DIFFUSE_IND); + MAP_OPTION("denoising_glossy_direct", DENOISING_CLEAN_GLOSSY_DIR); + MAP_OPTION("denoising_glossy_indirect", DENOISING_CLEAN_GLOSSY_IND); + MAP_OPTION("denoising_transmission_direct", DENOISING_CLEAN_TRANSMISSION_DIR); + MAP_OPTION("denoising_transmission_indirect", DENOISING_CLEAN_TRANSMISSION_IND); + MAP_OPTION("denoising_subsurface_direct", DENOISING_CLEAN_SUBSURFACE_DIR); + MAP_OPTION("denoising_subsurface_indirect", DENOISING_CLEAN_SUBSURFACE_IND); +#undef MAP_OPTION + + if(scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES) { + b_engine.add_pass("Denoising Clean", 3, "RGB", b_view_layer.name().c_str()); + } } #ifdef __KERNEL_DEBUG__ if(get_boolean(crp, "pass_debug_bvh_traversed_nodes")) { @@ -618,7 +635,15 @@ SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene, params.texture_limit = 0; } - params.bvh_layout = DebugFlags().cpu.bvh_layout; + /* TODO(sergey): Once OSL supports per-microarchitecture optimization get + * rid of this. + */ + if(params.shadingsystem == SHADINGSYSTEM_OSL) { + params.bvh_layout = BVH_LAYOUT_BVH4; + } + else { + params.bvh_layout = DebugFlags().cpu.bvh_layout; + } return params; } diff --git a/intern/cycles/bvh/CMakeLists.txt b/intern/cycles/bvh/CMakeLists.txt index b8171e7f70d..fcd28572fdf 100644 --- a/intern/cycles/bvh/CMakeLists.txt +++ b/intern/cycles/bvh/CMakeLists.txt @@ -10,6 +10,7 @@ set(SRC bvh.cpp bvh2.cpp bvh4.cpp + bvh8.cpp bvh_binning.cpp bvh_build.cpp bvh_node.cpp @@ -22,6 +23,7 @@ set(SRC_HEADERS bvh.h bvh2.h bvh4.h + bvh8.h bvh_binning.h bvh_build.h bvh_node.h diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index b524ca07d8d..bc73a3ad264 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -22,6 +22,7 @@ #include "bvh/bvh2.h" #include "bvh/bvh4.h" +#include "bvh/bvh8.h" #include "bvh/bvh_build.h" #include "bvh/bvh_node.h" @@ -38,6 +39,7 @@ const char *bvh_layout_name(BVHLayout layout) switch(layout) { case BVH_LAYOUT_BVH2: return "BVH2"; case BVH_LAYOUT_BVH4: return "BVH4"; + case BVH_LAYOUT_BVH8: return "BVH8"; case BVH_LAYOUT_NONE: return "NONE"; case BVH_LAYOUT_ALL: return "ALL"; } @@ -92,6 +94,8 @@ BVH *BVH::create(const BVHParams& params, const vector<Object*>& objects) return new BVH2(params, objects); case BVH_LAYOUT_BVH4: return new BVH4(params, objects); + case BVH_LAYOUT_BVH8: + return new BVH8(params, objects); case BVH_LAYOUT_NONE: case BVH_LAYOUT_ALL: break; @@ -215,6 +219,38 @@ void BVH::refit_primitives(int start, int end, BoundBox& bbox, uint& visibility) } } visibility |= ob->visibility_for_tracing(); + + } +} + +bool BVH::leaf_check(const BVHNode *node, BVH_TYPE bvh) +{ + if(node->is_leaf()) { + return node->is_unaligned; + } + else { + return node_is_unaligned(node, bvh); + } +} + +bool BVH::node_is_unaligned(const BVHNode *node, BVH_TYPE bvh) +{ + const BVHNode *node0 = node->get_child(0); + const BVHNode *node1 = node->get_child(1); + + switch(bvh) { + case bvh2: + return node0->is_unaligned || node1->is_unaligned; + break; + case bvh4: + return leaf_check(node0, bvh2) || leaf_check(node1, bvh2); + break; + case bvh8: + return leaf_check(node0, bvh4) || leaf_check(node1, bvh4); + break; + default: + assert(0); + return false; } } @@ -291,8 +327,8 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) * BVH's are stored in global arrays. This function merges them into the * top level BVH, adjusting indexes and offsets where appropriate. */ - /* TODO(sergey): This code needs adjustment for wider BVH than 4. */ const bool use_qbvh = (params.bvh_layout == BVH_LAYOUT_BVH4); + const bool use_obvh = (params.bvh_layout == BVH_LAYOUT_BVH8); /* Adjust primitive index to point to the triangle in the global array, for * meshes with transform applied and already in the top level BVH. @@ -469,14 +505,26 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) for(size_t i = 0, j = 0; i < bvh_nodes_size; j++) { size_t nsize, nsize_bbox; if(bvh_nodes[i].x & PATH_RAY_NODE_UNALIGNED) { - nsize = use_qbvh - ? BVH_UNALIGNED_QNODE_SIZE - : BVH_UNALIGNED_NODE_SIZE; - nsize_bbox = (use_qbvh)? 13: 0; + if(use_obvh) { + nsize = BVH_UNALIGNED_ONODE_SIZE; + nsize_bbox = BVH_UNALIGNED_ONODE_SIZE-1; + } + else { + nsize = use_qbvh + ? BVH_UNALIGNED_QNODE_SIZE + : BVH_UNALIGNED_NODE_SIZE; + nsize_bbox = (use_qbvh) ? BVH_UNALIGNED_QNODE_SIZE-1 : 0; + } } else { - nsize = (use_qbvh)? BVH_QNODE_SIZE: BVH_NODE_SIZE; - nsize_bbox = (use_qbvh)? 7: 0; + if(use_obvh) { + nsize = BVH_ONODE_SIZE; + nsize_bbox = BVH_ONODE_SIZE-1; + } + else { + nsize = (use_qbvh)? BVH_QNODE_SIZE: BVH_NODE_SIZE; + nsize_bbox = (use_qbvh)? BVH_QNODE_SIZE-1 : 0; + } } memcpy(pack_nodes + pack_nodes_offset, @@ -485,16 +533,29 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) /* Modify offsets into arrays */ int4 data = bvh_nodes[i + nsize_bbox]; - - data.z += (data.z < 0)? -noffset_leaf: noffset; - data.w += (data.w < 0)? -noffset_leaf: noffset; - - if(use_qbvh) { - data.x += (data.x < 0)? -noffset_leaf: noffset; - data.y += (data.y < 0)? -noffset_leaf: noffset; + int4 data1 = bvh_nodes[i + nsize_bbox-1]; + if(use_obvh) { + data.z += (data.z < 0) ? -noffset_leaf : noffset; + data.w += (data.w < 0) ? -noffset_leaf : noffset; + data.x += (data.x < 0) ? -noffset_leaf : noffset; + data.y += (data.y < 0) ? -noffset_leaf : noffset; + data1.z += (data1.z < 0) ? -noffset_leaf : noffset; + data1.w += (data1.w < 0) ? -noffset_leaf : noffset; + data1.x += (data1.x < 0) ? -noffset_leaf : noffset; + data1.y += (data1.y < 0) ? -noffset_leaf : noffset; + } + else { + data.z += (data.z < 0) ? -noffset_leaf : noffset; + data.w += (data.w < 0) ? -noffset_leaf : noffset; + if(use_qbvh) { + data.x += (data.x < 0)? -noffset_leaf: noffset; + data.y += (data.y < 0)? -noffset_leaf: noffset; + } } - pack_nodes[pack_nodes_offset + nsize_bbox] = data; + if(use_obvh) { + pack_nodes[pack_nodes_offset + nsize_bbox - 1] = data1; + } /* Usually this copies nothing, but we better * be prepared for possible node size extension. diff --git a/intern/cycles/bvh/bvh.h b/intern/cycles/bvh/bvh.h index 6a82f915692..86be0bae4be 100644 --- a/intern/cycles/bvh/bvh.h +++ b/intern/cycles/bvh/bvh.h @@ -73,6 +73,12 @@ struct PackedBVH { } }; +enum BVH_TYPE { + bvh2, + bvh4, + bvh8 +}; + /* BVH */ class BVH @@ -93,6 +99,8 @@ protected: /* Refit range of primitives. */ void refit_primitives(int start, int end, BoundBox& bbox, uint& visibility); + static __forceinline bool leaf_check(const BVHNode *node, BVH_TYPE bvh); + static bool node_is_unaligned(const BVHNode *node, BVH_TYPE bvh); /* triangles and strands */ void pack_primitives(); diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp index 9d89d2b6afb..4a423c16559 100644 --- a/intern/cycles/bvh/bvh2.cpp +++ b/intern/cycles/bvh/bvh2.cpp @@ -25,13 +25,6 @@ CCL_NAMESPACE_BEGIN -static bool node_bvh_is_unaligned(const BVHNode *node) -{ - const BVHNode *node0 = node->get_child(0), - *node1 = node->get_child(1); - return node0->is_unaligned || node1->is_unaligned; -} - BVH2::BVH2(const BVHParams& params_, const vector<Object*>& objects_) : BVH(params_, objects_) { @@ -195,7 +188,7 @@ void BVH2::pack_nodes(const BVHNode *root) } else { stack.push_back(BVHStackEntry(root, nextNodeIdx)); - nextNodeIdx += node_bvh_is_unaligned(root) + nextNodeIdx += node_is_unaligned(root, bvh2) ? BVH_UNALIGNED_NODE_SIZE : BVH_NODE_SIZE; } @@ -218,7 +211,7 @@ void BVH2::pack_nodes(const BVHNode *root) } else { idx[i] = nextNodeIdx; - nextNodeIdx += node_bvh_is_unaligned(e.node->get_child(i)) + nextNodeIdx += node_is_unaligned(e.node->get_child(i), bvh2) ? BVH_UNALIGNED_NODE_SIZE : BVH_NODE_SIZE; } diff --git a/intern/cycles/bvh/bvh4.cpp b/intern/cycles/bvh/bvh4.cpp index 4faf47af7bb..a449587e607 100644 --- a/intern/cycles/bvh/bvh4.cpp +++ b/intern/cycles/bvh/bvh4.cpp @@ -30,27 +30,6 @@ CCL_NAMESPACE_BEGIN * Perhaps we can merge nodes in actual tree and make our * life easier all over the place. */ -static bool node_qbvh_is_unaligned(const BVHNode *node) -{ - const BVHNode *node0 = node->get_child(0), - *node1 = node->get_child(1); - bool has_unaligned = false; - if(node0->is_leaf()) { - has_unaligned |= node0->is_unaligned; - } - else { - has_unaligned |= node0->get_child(0)->is_unaligned; - has_unaligned |= node0->get_child(1)->is_unaligned; - } - if(node1->is_leaf()) { - has_unaligned |= node1->is_unaligned; - } - else { - has_unaligned |= node1->get_child(0)->is_unaligned; - has_unaligned |= node1->get_child(1)->is_unaligned; - } - return has_unaligned; -} BVH4::BVH4(const BVHParams& params_, const vector<Object*>& objects_) : BVH(params_, objects_) @@ -304,7 +283,7 @@ void BVH4::pack_nodes(const BVHNode *root) } else { stack.push_back(BVHStackEntry(root, nextNodeIdx)); - nextNodeIdx += node_qbvh_is_unaligned(root) + nextNodeIdx += node_is_unaligned(root, bvh4) ? BVH_UNALIGNED_QNODE_SIZE : BVH_QNODE_SIZE; } @@ -348,7 +327,7 @@ void BVH4::pack_nodes(const BVHNode *root) } else { idx = nextNodeIdx; - nextNodeIdx += node_qbvh_is_unaligned(nodes[i]) + nextNodeIdx += node_is_unaligned(nodes[i], bvh4) ? BVH_UNALIGNED_QNODE_SIZE : BVH_QNODE_SIZE; } @@ -438,7 +417,7 @@ void BVH4::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility) visibility, 0.0f, 1.0f, - 4); + num_nodes); } else { pack_aligned_node(idx, @@ -447,7 +426,7 @@ void BVH4::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility) visibility, 0.0f, 1.0f, - 4); + num_nodes); } } } diff --git a/intern/cycles/bvh/bvh8.cpp b/intern/cycles/bvh/bvh8.cpp new file mode 100644 index 00000000000..70d003d938a --- /dev/null +++ b/intern/cycles/bvh/bvh8.cpp @@ -0,0 +1,512 @@ +/* +* Original code Copyright 2017, Intel Corporation +* Modifications Copyright 2018, Blender Foundation. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* * Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Intel Corporation nor the names of its contributors +* may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "bvh/bvh8.h" + +#include "render/mesh.h" +#include "render/object.h" + +#include "bvh/bvh_node.h" +#include "bvh/bvh_unaligned.h" + +CCL_NAMESPACE_BEGIN + +BVH8::BVH8(const BVHParams& params_, const vector<Object*>& objects_) +: BVH(params_, objects_) +{ +} + +void BVH8::pack_leaf(const BVHStackEntry& e, const LeafNode *leaf) +{ + float4 data[BVH_ONODE_LEAF_SIZE]; + memset(data, 0, sizeof(data)); + if(leaf->num_triangles() == 1 && pack.prim_index[leaf->lo] == -1) { + /* object */ + data[0].x = __int_as_float(~(leaf->lo)); + data[0].y = __int_as_float(0); + } + else { + /* triangle */ + data[0].x = __int_as_float(leaf->lo); + data[0].y = __int_as_float(leaf->hi); + } + data[0].z = __uint_as_float(leaf->visibility); + if(leaf->num_triangles() != 0) { + data[0].w = __uint_as_float(pack.prim_type[leaf->lo]); + } + + memcpy(&pack.leaf_nodes[e.idx], data, sizeof(float4)*BVH_ONODE_LEAF_SIZE); +} + +void BVH8::pack_inner(const BVHStackEntry& e, + const BVHStackEntry *en, + int num) +{ + bool has_unaligned = false; + /* Check whether we have to create unaligned node or all nodes are aligned + * and we can cut some corner here. + */ + if(params.use_unaligned_nodes) { + for(int i = 0; i < num; i++) { + if(en[i].node->is_unaligned) { + has_unaligned = true; + break; + } + } + } + if(has_unaligned) { + /* There's no unaligned children, pack into AABB node. */ + pack_unaligned_inner(e, en, num); + } + else { + /* Create unaligned node with orientation transform for each of the + * children. + */ + pack_aligned_inner(e, en, num); + } +} + +void BVH8::pack_aligned_inner(const BVHStackEntry& e, + const BVHStackEntry *en, + int num) +{ + BoundBox bounds[8]; + int child[8]; + for(int i = 0; i < num; ++i) { + bounds[i] = en[i].node->bounds; + child[i] = en[i].encodeIdx(); + } + pack_aligned_node(e.idx, + bounds, + child, + e.node->visibility, + e.node->time_from, + e.node->time_to, + num); +} + +void BVH8::pack_aligned_node(int idx, + const BoundBox *bounds, + const int *child, + const uint visibility, + const float time_from, + const float time_to, + const int num) +{ + float8 data[8]; + memset(data, 0, sizeof(data)); + + data[0].a = __uint_as_float(visibility & ~PATH_RAY_NODE_UNALIGNED); + data[0].b = time_from; + data[0].c = time_to; + for(int i = 0; i < num; i++) { + float3 bb_min = bounds[i].min; + float3 bb_max = bounds[i].max; + + data[1][i] = bb_min.x; + data[2][i] = bb_max.x; + data[3][i] = bb_min.y; + data[4][i] = bb_max.y; + data[5][i] = bb_min.z; + data[6][i] = bb_max.z; + + data[7][i] = __int_as_float(child[i]); + } + + for(int i = num; i < 8; i++) { + /* We store BB which would never be recorded as intersection + * so kernel might safely assume there are always 4 child nodes. + */ + data[1][i] = FLT_MAX; + data[2][i] = -FLT_MAX; + + data[3][i] = FLT_MAX; + data[4][i] = -FLT_MAX; + + data[5][i] = FLT_MAX; + data[6][i] = -FLT_MAX; + + data[7][i] = __int_as_float(0); + } + memcpy(&pack.nodes[idx], data, sizeof(float4)*BVH_ONODE_SIZE); +} + +void BVH8::pack_unaligned_inner(const BVHStackEntry& e, + const BVHStackEntry *en, + int num) +{ + Transform aligned_space[8]; + BoundBox bounds[8]; + int child[8]; + for(int i = 0; i < num; ++i) { + aligned_space[i] = en[i].node->get_aligned_space(); + bounds[i] = en[i].node->bounds; + child[i] = en[i].encodeIdx(); + } + pack_unaligned_node(e.idx, + aligned_space, + bounds, + child, + e.node->visibility, + e.node->time_from, + e.node->time_to, + num); +} + +void BVH8::pack_unaligned_node(int idx, + const Transform *aligned_space, + const BoundBox *bounds, + const int *child, + const uint visibility, + const float time_from, + const float time_to, + const int num) +{ + float8 data[BVH_UNALIGNED_ONODE_SIZE]; + memset(data, 0, sizeof(data)); + data[0].a = __uint_as_float(visibility | PATH_RAY_NODE_UNALIGNED); + data[0].b = time_from; + data[0].c = time_to; + + for(int i = 0; i < num; i++) { + Transform space = BVHUnaligned::compute_node_transform( + bounds[i], + aligned_space[i]); + + data[1][i] = space.x.x; + data[2][i] = space.x.y; + data[3][i] = space.x.z; + + data[4][i] = space.y.x; + data[5][i] = space.y.y; + data[6][i] = space.y.z; + + data[7][i] = space.z.x; + data[8][i] = space.z.y; + data[9][i] = space.z.z; + + data[10][i] = space.x.w; + data[11][i] = space.y.w; + data[12][i] = space.z.w; + + data[13][i] = __int_as_float(child[i]); + } + + for(int i = num; i < 8; i++) { + /* We store BB which would never be recorded as intersection + * so kernel might safely assume there are always 4 child nodes. + */ + + data[1][i] = 1.0f; + data[2][i] = 0.0f; + data[3][i] = 0.0f; + + data[4][i] = 0.0f; + data[5][i] = 0.0f; + data[6][i] = 0.0f; + + data[7][i] = 0.0f; + data[8][i] = 0.0f; + data[9][i] = 0.0f; + + data[10][i] = -FLT_MAX; + data[11][i] = -FLT_MAX; + data[12][i] = -FLT_MAX; + + data[13][i] = __int_as_float(0); + } + + memcpy(&pack.nodes[idx], data, sizeof(float4)*BVH_UNALIGNED_ONODE_SIZE); +} + +/* Quad SIMD Nodes */ + +void BVH8::pack_nodes(const BVHNode *root) +{ + /* Calculate size of the arrays required. */ + const size_t num_nodes = root->getSubtreeSize(BVH_STAT_ONODE_COUNT); + const size_t num_leaf_nodes = root->getSubtreeSize(BVH_STAT_LEAF_COUNT); + assert(num_leaf_nodes <= num_nodes); + const size_t num_inner_nodes = num_nodes - num_leaf_nodes; + size_t node_size; + if(params.use_unaligned_nodes) { + const size_t num_unaligned_nodes = + root->getSubtreeSize(BVH_STAT_UNALIGNED_INNER_ONODE_COUNT); + node_size = (num_unaligned_nodes * BVH_UNALIGNED_ONODE_SIZE) + + (num_inner_nodes - num_unaligned_nodes) * BVH_ONODE_SIZE; + } + else { + node_size = num_inner_nodes * BVH_ONODE_SIZE; + } + /* Resize arrays. */ + pack.nodes.clear(); + pack.leaf_nodes.clear(); + /* For top level BVH, first merge existing BVH's so we know the offsets. */ + if(params.top_level) { + pack_instances(node_size, num_leaf_nodes*BVH_ONODE_LEAF_SIZE); + } + else { + pack.nodes.resize(node_size); + pack.leaf_nodes.resize(num_leaf_nodes*BVH_ONODE_LEAF_SIZE); + } + + int nextNodeIdx = 0, nextLeafNodeIdx = 0; + + vector<BVHStackEntry> stack; + stack.reserve(BVHParams::MAX_DEPTH*2); + if(root->is_leaf()) { + stack.push_back(BVHStackEntry(root, nextLeafNodeIdx++)); + } + else { + stack.push_back(BVHStackEntry(root, nextNodeIdx)); + nextNodeIdx += node_is_unaligned(root, bvh8) + ? BVH_UNALIGNED_ONODE_SIZE + : BVH_ONODE_SIZE; + } + + while(stack.size()) { + BVHStackEntry e = stack.back(); + stack.pop_back(); + + if(e.node->is_leaf()) { + /* leaf node */ + const LeafNode *leaf = reinterpret_cast<const LeafNode*>(e.node); + pack_leaf(e, leaf); + } + else { + /* Inner node. */ + const BVHNode *node = e.node; + const BVHNode *node0 = node->get_child(0); + const BVHNode *node1 = node->get_child(1); + /* Collect nodes. */ + const BVHNode *nodes[8]; + int numnodes = 0; + if(node0->is_leaf()) { + nodes[numnodes++] = node0; + } + else { + const BVHNode *node00 = node0->get_child(0), + *node01 = node0->get_child(1); + if(node00->is_leaf()) { + nodes[numnodes++] = node00; + } + else { + nodes[numnodes++] = node00->get_child(0); + nodes[numnodes++] = node00->get_child(1); + } + if(node01->is_leaf()) { + nodes[numnodes++] = node01; + } + else { + nodes[numnodes++] = node01->get_child(0); + nodes[numnodes++] = node01->get_child(1); + } + } + if(node1->is_leaf()) { + nodes[numnodes++] = node1; + } + else { + const BVHNode *node10 = node1->get_child(0), + *node11 = node1->get_child(1); + if(node10->is_leaf()) { + nodes[numnodes++] = node10; + } + else { + nodes[numnodes++] = node10->get_child(0); + nodes[numnodes++] = node10->get_child(1); + } + if(node11->is_leaf()) { + nodes[numnodes++] = node11; + } + else { + nodes[numnodes++] = node11->get_child(0); + nodes[numnodes++] = node11->get_child(1); + } + } + /* Push entries on the stack. */ + for(int i = 0; i < numnodes; ++i) { + int idx; + if(nodes[i]->is_leaf()) { + idx = nextLeafNodeIdx++; + } + else { + idx = nextNodeIdx; + nextNodeIdx += node_is_unaligned(nodes[i], bvh8) + ? BVH_UNALIGNED_ONODE_SIZE + : BVH_ONODE_SIZE; + } + stack.push_back(BVHStackEntry(nodes[i], idx)); + } + /* Set node. */ + pack_inner(e, &stack[stack.size() - numnodes], numnodes); + } + } + assert(node_size == nextNodeIdx); + /* Root index to start traversal at, to handle case of single leaf node. */ + pack.root_index = (root->is_leaf()) ? -1 : 0; +} + +void BVH8::refit_nodes() +{ + assert(!params.top_level); + + BoundBox bbox = BoundBox::empty; + uint visibility = 0; + refit_node(0, (pack.root_index == -1)? true: false, bbox, visibility); +} + +void BVH8::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility) +{ + if(leaf) { + int4 *data = &pack.leaf_nodes[idx]; + int4 c = data[0]; + /* Refit leaf node. */ + for(int prim = c.x; prim < c.y; prim++) { + int pidx = pack.prim_index[prim]; + int tob = pack.prim_object[prim]; + Object *ob = objects[tob]; + + if(pidx == -1) { + /* Object instance. */ + bbox.grow(ob->bounds); + } + else { + /* Primitives. */ + const Mesh *mesh = ob->mesh; + + if(pack.prim_type[prim] & PRIMITIVE_ALL_CURVE) { + /* Curves. */ + int str_offset = (params.top_level) ? mesh->curve_offset : 0; + Mesh::Curve curve = mesh->get_curve(pidx - str_offset); + int k = PRIMITIVE_UNPACK_SEGMENT(pack.prim_type[prim]); + + curve.bounds_grow(k, &mesh->curve_keys[0], &mesh->curve_radius[0], bbox); + + visibility |= PATH_RAY_CURVE; + + /* Motion curves. */ + if(mesh->use_motion_blur) { + Attribute *attr = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); + + if(attr) { + size_t mesh_size = mesh->curve_keys.size(); + size_t steps = mesh->motion_steps - 1; + float3 *key_steps = attr->data_float3(); + + for(size_t i = 0; i < steps; i++) { + curve.bounds_grow(k, key_steps + i*mesh_size, &mesh->curve_radius[0], bbox); + } + } + } + } + else { + /* Triangles. */ + int tri_offset = (params.top_level) ? mesh->tri_offset : 0; + Mesh::Triangle triangle = mesh->get_triangle(pidx - tri_offset); + const float3 *vpos = &mesh->verts[0]; + + triangle.bounds_grow(vpos, bbox); + + /* Motion triangles. */ + if(mesh->use_motion_blur) { + Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); + + if(attr) { + size_t mesh_size = mesh->verts.size(); + size_t steps = mesh->motion_steps - 1; + float3 *vert_steps = attr->data_float3(); + + for(size_t i = 0; i < steps; i++) { + triangle.bounds_grow(vert_steps + i*mesh_size, bbox); + } + } + } + } + } + + visibility |= ob->visibility; + } + + float4 leaf_data[BVH_ONODE_LEAF_SIZE]; + leaf_data[0].x = __int_as_float(c.x); + leaf_data[0].y = __int_as_float(c.y); + leaf_data[0].z = __uint_as_float(visibility); + leaf_data[0].w = __uint_as_float(c.w); + memcpy(&pack.leaf_nodes[idx], leaf_data, sizeof(float4)*BVH_ONODE_LEAF_SIZE); + } + else { + float8 *data = (float8*)&pack.nodes[idx]; + bool is_unaligned = (__float_as_uint(data[0].a) & PATH_RAY_NODE_UNALIGNED) != 0; + /* Refit inner node, set bbox from children. */ + BoundBox child_bbox[8] = { BoundBox::empty, BoundBox::empty, + BoundBox::empty, BoundBox::empty, + BoundBox::empty, BoundBox::empty, + BoundBox::empty, BoundBox::empty }; + int child[8]; + uint child_visibility[8] = { 0 }; + int num_nodes = 0; + + for(int i = 0; i < 8; ++i) { + child[i] = __float_as_int(data[(is_unaligned) ? 13: 7][i]); + + if(child[i] != 0) { + refit_node((child[i] < 0)? -child[i]-1: child[i], (child[i] < 0), + child_bbox[i], child_visibility[i]); + ++num_nodes; + bbox.grow(child_bbox[i]); + visibility |= child_visibility[i]; + } + } + + if(is_unaligned) { + Transform aligned_space[8] = { transform_identity(), transform_identity(), + transform_identity(), transform_identity(), + transform_identity(), transform_identity(), + transform_identity(), transform_identity()}; + pack_unaligned_node(idx, + aligned_space, + child_bbox, + child, + visibility, + 0.0f, + 1.0f, + num_nodes); + } + else { + pack_aligned_node(idx, + child_bbox, + child, + visibility, + 0.0f, + 1.0f, + num_nodes); + } + } +} + +CCL_NAMESPACE_END diff --git a/intern/cycles/bvh/bvh8.h b/intern/cycles/bvh/bvh8.h new file mode 100644 index 00000000000..274a2442c7e --- /dev/null +++ b/intern/cycles/bvh/bvh8.h @@ -0,0 +1,98 @@ +/* +* Original code Copyright 2017, Intel Corporation +* Modifications Copyright 2018, Blender Foundation. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* * Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Intel Corporation nor the names of its contributors +* may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef __BVH8_H__ +#define __BVH8_H__ + +#include "bvh/bvh.h" +#include "bvh/bvh_params.h" + +#include "util/util_types.h" +#include "util/util_vector.h" + +CCL_NAMESPACE_BEGIN + +class BVHNode; +struct BVHStackEntry; +class BVHParams; +class BoundBox; +class LeafNode; +class Object; +class Progress; + +#define BVH_ONODE_SIZE 16 +#define BVH_ONODE_LEAF_SIZE 1 +#define BVH_UNALIGNED_ONODE_SIZE 28 + +/* BVH8 +* +* Octo BVH, with each node having eight children, to use with SIMD instructions. +*/ +class BVH8 : public BVH { +protected: + /* constructor */ + friend class BVH; + BVH8(const BVHParams& params, const vector<Object*>& objects); + + /* pack */ + void pack_nodes(const BVHNode *root); + + void pack_leaf(const BVHStackEntry& e, const LeafNode *leaf); + void pack_inner(const BVHStackEntry& e, const BVHStackEntry *en, int num); + + void pack_aligned_inner(const BVHStackEntry& e, + const BVHStackEntry *en, + int num); + void pack_aligned_node(int idx, + const BoundBox *bounds, + const int *child, + const uint visibility, + const float time_from, + const float time_to, + const int num); + + void pack_unaligned_inner(const BVHStackEntry& e, + const BVHStackEntry *en, + int num); + void pack_unaligned_node(int idx, + const Transform *aligned_space, + const BoundBox *bounds, + const int *child, + const uint visibility, + const float time_from, + const float time_to, + const int num); + + /* refit */ + void refit_nodes(); + void refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility); +}; + +CCL_NAMESPACE_END + +#endif /* __BVH8_H__ */ diff --git a/intern/cycles/bvh/bvh_node.cpp b/intern/cycles/bvh/bvh_node.cpp index 879d07b9625..fd8b4977699 100644 --- a/intern/cycles/bvh/bvh_node.cpp +++ b/intern/cycles/bvh/bvh_node.cpp @@ -61,6 +61,55 @@ int BVHNode::getSubtreeSize(BVH_STAT stat) const } } return cnt; + case BVH_STAT_ONODE_COUNT: + cnt = 1; + for(int i = 0; i < num_children(); i++) { + BVHNode *node = get_child(i); + if(node->is_leaf()) { + cnt += 1; + } + else { + for(int j = 0; j < node->num_children(); j++) + { + BVHNode *node_next = node->get_child(j); + if(node_next->is_leaf()) { + cnt += 1; + } + else { + for(int k = 0; k < node_next->num_children(); k++) { + cnt += node_next->get_child(k)->getSubtreeSize(stat); + } + } + } + } + } + return cnt; + case BVH_STAT_UNALIGNED_INNER_ONODE_COUNT: + { + bool has_unaligned = false; + for(int i = 0; i < num_children(); i++) { + BVHNode *node = get_child(i); + if(node->is_leaf()) { + has_unaligned |= node->is_unaligned; + } + else { + for(int j = 0; j < node->num_children(); j++) { + BVHNode *node_next = node->get_child(j); + if(node_next->is_leaf()) { + has_unaligned |= node_next->is_unaligned; + } + else { + for(int k = 0; k < node_next->num_children(); k++) { + cnt += node_next->get_child(k)->getSubtreeSize(stat); + has_unaligned |= node_next->get_child(k)->is_unaligned; + } + } + } + } + } + cnt += has_unaligned? 1: 0; + } + return cnt; case BVH_STAT_ALIGNED_COUNT: if(!is_unaligned) { cnt = 1; diff --git a/intern/cycles/bvh/bvh_node.h b/intern/cycles/bvh/bvh_node.h index 94cf5ab730c..ed89d52a50a 100644 --- a/intern/cycles/bvh/bvh_node.h +++ b/intern/cycles/bvh/bvh_node.h @@ -39,6 +39,8 @@ enum BVH_STAT { BVH_STAT_ALIGNED_LEAF_COUNT, BVH_STAT_UNALIGNED_LEAF_COUNT, BVH_STAT_DEPTH, + BVH_STAT_ONODE_COUNT, + BVH_STAT_UNALIGNED_INNER_ONODE_COUNT, }; class BVHParams; diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index be0dcc20755..7c72ab1a009 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -471,9 +471,10 @@ public: int w = align_up(rect.z-rect.x, 4); int h = rect.w-rect.y; - float *blurDifference = (float*) task->nlm_state.temporary_1_ptr; - float *difference = (float*) task->nlm_state.temporary_2_ptr; - float *weightAccum = (float*) task->nlm_state.temporary_3_ptr; + float *temporary_mem = (float*) task->buffer.temporary_mem.device_pointer; + float *blurDifference = temporary_mem; + float *difference = temporary_mem + task->buffer.pass_stride; + float *weightAccum = temporary_mem + 2*task->buffer.pass_stride; memset(weightAccum, 0, sizeof(float)*w*h); memset((float*) out_ptr, 0, sizeof(float)*w*h); @@ -537,8 +538,9 @@ public: mem_zero(task->storage.XtWX); mem_zero(task->storage.XtWY); - float *difference = (float*) task->reconstruction_state.temporary_1_ptr; - float *blurDifference = (float*) task->reconstruction_state.temporary_2_ptr; + float *temporary_mem = (float*) task->buffer.temporary_mem.device_pointer; + float *difference = temporary_mem; + float *blurDifference = temporary_mem + task->buffer.pass_stride; int r = task->radius; for(int i = 0; i < (2*r+1)*(2*r+1); i++) { @@ -713,6 +715,7 @@ public: denoising.filter_area = make_int4(tile.x, tile.y, tile.w, tile.h); denoising.render_buffer.samples = tile.sample; + denoising.buffer.gpu_temporary_mem = false; denoising.run_denoising(&tile); } @@ -1025,9 +1028,12 @@ void device_cpu_info(vector<DeviceInfo>& devices) info.num = 0; info.advanced_shading = true; info.bvh_layout_mask = BVH_LAYOUT_BVH2; - if (system_cpu_support_sse2()) { + if(system_cpu_support_sse2()) { info.bvh_layout_mask |= BVH_LAYOUT_BVH4; } + if(system_cpu_support_avx2()) { + info.bvh_layout_mask |= BVH_LAYOUT_BVH8; + } info.has_volume_decoupled = true; info.has_osl = true; info.has_half_images = true; diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index c9ec1cc1219..830cc207d54 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1294,23 +1294,19 @@ public: float a = task->nlm_state.a; float k_2 = task->nlm_state.k_2; - int shift_stride = stride*h; + int pass_stride = task->buffer.pass_stride; int num_shifts = (2*r+1)*(2*r+1); - int mem_size = sizeof(float)*shift_stride*num_shifts; int channel_offset = 0; - device_only_memory<uchar> temporary_mem(this, "Denoising temporary_mem"); - temporary_mem.alloc_to_device(2*mem_size); - if(have_error()) return false; - CUdeviceptr difference = cuda_device_ptr(temporary_mem.device_pointer); - CUdeviceptr blurDifference = difference + mem_size; + CUdeviceptr difference = cuda_device_ptr(task->buffer.temporary_mem.device_pointer); + CUdeviceptr blurDifference = difference + sizeof(float)*pass_stride*num_shifts; + CUdeviceptr weightAccum = difference + 2*sizeof(float)*pass_stride*num_shifts; - CUdeviceptr weightAccum = task->nlm_state.temporary_3_ptr; - cuda_assert(cuMemsetD8(weightAccum, 0, sizeof(float)*shift_stride)); - cuda_assert(cuMemsetD8(out_ptr, 0, sizeof(float)*shift_stride)); + cuda_assert(cuMemsetD8(weightAccum, 0, sizeof(float)*pass_stride)); + cuda_assert(cuMemsetD8(out_ptr, 0, sizeof(float)*pass_stride)); { CUfunction cuNLMCalcDifference, cuNLMBlur, cuNLMCalcWeight, cuNLMUpdateOutput; @@ -1326,10 +1322,10 @@ public: CUDA_GET_BLOCKSIZE_1D(cuNLMCalcDifference, w*h, num_shifts); - void *calc_difference_args[] = {&guide_ptr, &variance_ptr, &difference, &w, &h, &stride, &shift_stride, &r, &channel_offset, &a, &k_2}; - void *blur_args[] = {&difference, &blurDifference, &w, &h, &stride, &shift_stride, &r, &f}; - void *calc_weight_args[] = {&blurDifference, &difference, &w, &h, &stride, &shift_stride, &r, &f}; - void *update_output_args[] = {&blurDifference, &image_ptr, &out_ptr, &weightAccum, &w, &h, &stride, &shift_stride, &r, &f}; + void *calc_difference_args[] = {&guide_ptr, &variance_ptr, &difference, &w, &h, &stride, &pass_stride, &r, &channel_offset, &a, &k_2}; + void *blur_args[] = {&difference, &blurDifference, &w, &h, &stride, &pass_stride, &r, &f}; + void *calc_weight_args[] = {&blurDifference, &difference, &w, &h, &stride, &pass_stride, &r, &f}; + void *update_output_args[] = {&blurDifference, &image_ptr, &out_ptr, &weightAccum, &w, &h, &stride, &pass_stride, &r, &f}; CUDA_LAUNCH_KERNEL_1D(cuNLMCalcDifference, calc_difference_args); CUDA_LAUNCH_KERNEL_1D(cuNLMBlur, blur_args); @@ -1338,8 +1334,6 @@ public: CUDA_LAUNCH_KERNEL_1D(cuNLMUpdateOutput, update_output_args); } - temporary_mem.free(); - { CUfunction cuNLMNormalize; cuda_assert(cuModuleGetFunction(&cuNLMNormalize, cuFilterModule, "kernel_cuda_filter_nlm_normalize")); @@ -1614,6 +1608,7 @@ public: denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h); denoising.render_buffer.samples = rtile.sample; + denoising.buffer.gpu_temporary_mem = true; denoising.run_denoising(&rtile); } diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp index c0d4634262d..23c18fa15b2 100644 --- a/intern/cycles/device/device_denoising.cpp +++ b/intern/cycles/device/device_denoising.cpp @@ -51,10 +51,8 @@ DenoisingTask::~DenoisingTask() storage.XtWY.free(); storage.transform.free(); storage.rank.free(); - storage.temporary_1.free(); - storage.temporary_2.free(); - storage.temporary_color.free(); buffer.mem.free(); + buffer.temporary_mem.free(); tile_info_mem.free(); } @@ -99,6 +97,16 @@ void DenoisingTask::setup_denoising_buffer() /* Pad the total size by four floats since the SIMD kernels might go a bit over the end. */ int mem_size = align_up(buffer.pass_stride * buffer.passes + 4, alignment_floats); buffer.mem.alloc_to_device(mem_size, false); + + /* CPUs process shifts sequentially while GPUs process them in parallel. */ + int num_shifts = 1; + if(buffer.gpu_temporary_mem) { + /* Shadowing prefiltering uses a radius of 6, so allocate at least that much. */ + int max_radius = max(radius, 6); + num_shifts = (2*max_radius + 1) * (2*max_radius + 1); + } + /* Allocate two layers per shift as well as one for the weight accumulation. */ + buffer.temporary_mem.alloc_to_device((2*num_shifts + 1) * buffer.pass_stride); } void DenoisingTask::prefilter_shadowing() @@ -111,13 +119,6 @@ void DenoisingTask::prefilter_shadowing() device_sub_ptr sample_var_var (buffer.mem, 3*buffer.pass_stride, buffer.pass_stride); device_sub_ptr buffer_var (buffer.mem, 5*buffer.pass_stride, buffer.pass_stride); device_sub_ptr filtered_var (buffer.mem, 6*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_1(buffer.mem, 7*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_2(buffer.mem, 8*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_3(buffer.mem, 9*buffer.pass_stride, buffer.pass_stride); - - nlm_state.temporary_1_ptr = *nlm_temporary_1; - nlm_state.temporary_2_ptr = *nlm_temporary_2; - nlm_state.temporary_3_ptr = *nlm_temporary_3; /* Get the A/B unfiltered passes, the combined sample variance, the estimated variance of the sample variance and the buffer variance. */ functions.divide_shadow(*unfiltered_a, *unfiltered_b, *sample_var, *sample_var_var, *buffer_var); @@ -154,13 +155,6 @@ void DenoisingTask::prefilter_features() { device_sub_ptr unfiltered (buffer.mem, 8*buffer.pass_stride, buffer.pass_stride); device_sub_ptr variance (buffer.mem, 9*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_1(buffer.mem, 10*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_2(buffer.mem, 11*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_3(buffer.mem, 12*buffer.pass_stride, buffer.pass_stride); - - nlm_state.temporary_1_ptr = *nlm_temporary_1; - nlm_state.temporary_2_ptr = *nlm_temporary_2; - nlm_state.temporary_3_ptr = *nlm_temporary_3; int mean_from[] = { 0, 1, 2, 12, 6, 7, 8 }; int variance_from[] = { 3, 4, 5, 13, 9, 10, 11}; @@ -183,17 +177,11 @@ void DenoisingTask::prefilter_color() int variance_to[] = {11, 12, 13}; int num_color_passes = 3; - storage.temporary_color.alloc_to_device(3*buffer.pass_stride, false); - device_sub_ptr nlm_temporary_1(storage.temporary_color, 0*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_2(storage.temporary_color, 1*buffer.pass_stride, buffer.pass_stride); - device_sub_ptr nlm_temporary_3(storage.temporary_color, 2*buffer.pass_stride, buffer.pass_stride); - - nlm_state.temporary_1_ptr = *nlm_temporary_1; - nlm_state.temporary_2_ptr = *nlm_temporary_2; - nlm_state.temporary_3_ptr = *nlm_temporary_3; + device_only_memory<float> temporary_color(device, "denoising temporary color"); + temporary_color.alloc_to_device(3*buffer.pass_stride, false); for(int pass = 0; pass < num_color_passes; pass++) { - device_sub_ptr color_pass(storage.temporary_color, pass*buffer.pass_stride, buffer.pass_stride); + device_sub_ptr color_pass(temporary_color, pass*buffer.pass_stride, buffer.pass_stride); device_sub_ptr color_var_pass(buffer.mem, variance_to[pass]*buffer.pass_stride, buffer.pass_stride); functions.get_feature(mean_from[pass], variance_from[pass], *color_pass, *color_var_pass); } @@ -201,9 +189,7 @@ void DenoisingTask::prefilter_color() device_sub_ptr depth_pass (buffer.mem, 0, buffer.pass_stride); device_sub_ptr color_var_pass(buffer.mem, variance_to[0]*buffer.pass_stride, 3*buffer.pass_stride); device_sub_ptr output_pass (buffer.mem, mean_to[0]*buffer.pass_stride, 3*buffer.pass_stride); - functions.detect_outliers(storage.temporary_color.device_pointer, *color_var_pass, *depth_pass, *output_pass); - - storage.temporary_color.free(); + functions.detect_outliers(temporary_color.device_pointer, *color_var_pass, *depth_pass, *output_pass); } void DenoisingTask::construct_transform() @@ -219,14 +205,6 @@ void DenoisingTask::construct_transform() void DenoisingTask::reconstruct() { - - device_only_memory<float> temporary_1(device, "Denoising NLM temporary 1"); - device_only_memory<float> temporary_2(device, "Denoising NLM temporary 2"); - temporary_1.alloc_to_device(buffer.pass_stride, false); - temporary_2.alloc_to_device(buffer.pass_stride, false); - reconstruction_state.temporary_1_ptr = temporary_1.device_pointer; - reconstruction_state.temporary_2_ptr = temporary_2.device_pointer; - storage.XtWX.alloc_to_device(storage.w*storage.h*XTWX_SIZE, false); storage.XtWY.alloc_to_device(storage.w*storage.h*XTWY_SIZE, false); diff --git a/intern/cycles/device/device_denoising.h b/intern/cycles/device/device_denoising.h index e0da52867f1..7474f71ff78 100644 --- a/intern/cycles/device/device_denoising.h +++ b/intern/cycles/device/device_denoising.h @@ -96,9 +96,6 @@ public: /* Stores state of the current Reconstruction operation, * which is accessed by the device in order to perform the operation. */ struct ReconstructionState { - device_ptr temporary_1_ptr; /* There two images are used as temporary storage. */ - device_ptr temporary_2_ptr; - int4 filter_window; int4 buffer_params; @@ -109,10 +106,6 @@ public: /* Stores state of the current NLM operation, * which is accessed by the device in order to perform the operation. */ struct NLMState { - device_ptr temporary_1_ptr; /* There three images are used as temporary storage. */ - device_ptr temporary_2_ptr; - device_ptr temporary_3_ptr; - int r; /* Search radius of the filter. */ int f; /* Patch size of the filter. */ float a; /* Variance compensation factor in the MSE estimation. */ @@ -126,9 +119,6 @@ public: device_only_memory<int> rank; device_only_memory<float> XtWX; device_only_memory<float3> XtWY; - device_only_memory<float> temporary_1; - device_only_memory<float> temporary_2; - device_only_memory<float> temporary_color; int w; int h; @@ -136,10 +126,7 @@ public: : transform(device, "denoising transform"), rank(device, "denoising rank"), XtWX(device, "denoising XtWX"), - XtWY(device, "denoising XtWY"), - temporary_1(device, "denoising NLM temporary 1"), - temporary_2(device, "denoising NLM temporary 2"), - temporary_color(device, "denoising temporary color") + XtWY(device, "denoising XtWY") {} } storage; @@ -155,9 +142,13 @@ public: int h; int width; device_only_memory<float> mem; + device_only_memory<float> temporary_mem; + + bool gpu_temporary_mem; DenoiseBuffers(Device *device) - : mem(device, "denoising pixel buffer") + : mem(device, "denoising pixel buffer"), + temporary_mem(device, "denoising temporary mem") {} } buffer; diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index 9a50d217321..69a2bd7adcb 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -738,7 +738,6 @@ bool OpenCLDeviceBase::denoising_non_local_means(device_ptr image_ptr, device_ptr out_ptr, DenoisingTask *task) { - int stride = task->buffer.stride; int w = task->buffer.width; int h = task->buffer.h; @@ -747,24 +746,23 @@ bool OpenCLDeviceBase::denoising_non_local_means(device_ptr image_ptr, float a = task->nlm_state.a; float k_2 = task->nlm_state.k_2; - int shift_stride = stride*h; + int pass_stride = task->buffer.pass_stride; int num_shifts = (2*r+1)*(2*r+1); - int mem_size = sizeof(float)*shift_stride*num_shifts; - cl_mem weightAccum = CL_MEM_PTR(task->nlm_state.temporary_3_ptr); - - cl_mem difference = clCreateBuffer(cxContext, CL_MEM_READ_WRITE, mem_size, NULL, &ciErr); - opencl_assert_err(ciErr, "clCreateBuffer denoising_non_local_means"); - cl_mem blurDifference = clCreateBuffer(cxContext, CL_MEM_READ_WRITE, mem_size, NULL, &ciErr); - opencl_assert_err(ciErr, "clCreateBuffer denoising_non_local_means"); + device_sub_ptr difference(task->buffer.temporary_mem, 0, pass_stride*num_shifts); + device_sub_ptr blurDifference(task->buffer.temporary_mem, pass_stride*num_shifts, pass_stride*num_shifts); + device_sub_ptr weightAccum(task->buffer.temporary_mem, 2*pass_stride*num_shifts, pass_stride); + cl_mem weightAccum_mem = CL_MEM_PTR(*weightAccum); + cl_mem difference_mem = CL_MEM_PTR(*difference); + cl_mem blurDifference_mem = CL_MEM_PTR(*blurDifference); cl_mem image_mem = CL_MEM_PTR(image_ptr); cl_mem guide_mem = CL_MEM_PTR(guide_ptr); cl_mem variance_mem = CL_MEM_PTR(variance_ptr); cl_mem out_mem = CL_MEM_PTR(out_ptr); - mem_zero_kernel(task->nlm_state.temporary_3_ptr, sizeof(float)*w*h); - mem_zero_kernel(out_ptr, sizeof(float)*w*h); + mem_zero_kernel(*difference, sizeof(float)*pass_stride); + mem_zero_kernel(out_ptr, sizeof(float)*pass_stride); cl_kernel ckNLMCalcDifference = denoising_program(ustring("filter_nlm_calc_difference")); cl_kernel ckNLMBlur = denoising_program(ustring("filter_nlm_blur")); @@ -775,29 +773,29 @@ bool OpenCLDeviceBase::denoising_non_local_means(device_ptr image_ptr, kernel_set_args(ckNLMCalcDifference, 0, guide_mem, variance_mem, - difference, + difference_mem, w, h, stride, - shift_stride, + pass_stride, r, 0, a, k_2); kernel_set_args(ckNLMBlur, 0, - difference, - blurDifference, + difference_mem, + blurDifference_mem, w, h, stride, - shift_stride, + pass_stride, r, f); kernel_set_args(ckNLMCalcWeight, 0, - blurDifference, - difference, + blurDifference_mem, + difference_mem, w, h, stride, - shift_stride, + pass_stride, r, f); kernel_set_args(ckNLMUpdateOutput, 0, - blurDifference, + blurDifference_mem, image_mem, out_mem, - weightAccum, + weightAccum_mem, w, h, stride, - shift_stride, + pass_stride, r, f); enqueue_kernel(ckNLMCalcDifference, w*h, num_shifts, true); @@ -806,11 +804,8 @@ bool OpenCLDeviceBase::denoising_non_local_means(device_ptr image_ptr, enqueue_kernel(ckNLMBlur, w*h, num_shifts, true); enqueue_kernel(ckNLMUpdateOutput, w*h, num_shifts, true); - opencl_assert(clReleaseMemObject(difference)); - opencl_assert(clReleaseMemObject(blurDifference)); - kernel_set_args(ckNLMNormalize, 0, - out_mem, weightAccum, w, h, stride); + out_mem, weightAccum_mem, w, h, stride); enqueue_kernel(ckNLMNormalize, w, h); return true; @@ -1081,6 +1076,7 @@ void OpenCLDeviceBase::denoise(RenderTile &rtile, DenoisingTask& denoising) denoising.filter_area = make_int4(rtile.x, rtile.y, rtile.w, rtile.h); denoising.render_buffer.samples = rtile.sample; + denoising.buffer.gpu_temporary_mem = true; denoising.run_denoising(&rtile); } diff --git a/intern/cycles/device/opencl/opencl_util.cpp b/intern/cycles/device/opencl/opencl_util.cpp index d6304ba688a..895e4149a3a 100644 --- a/intern/cycles/device/opencl/opencl_util.cpp +++ b/intern/cycles/device/opencl/opencl_util.cpp @@ -1139,13 +1139,13 @@ string OpenCLInfo::get_readable_device_name(cl_device_id device_id) /* Special exception for AMD Vega, need to be able to tell * Vega 56 from 64 apart. */ - if (name == "Radeon RX Vega") { + if(name == "Radeon RX Vega") { cl_int max_compute_units = 0; - if (clGetDeviceInfo(device_id, - CL_DEVICE_MAX_COMPUTE_UNITS, - sizeof(max_compute_units), - &max_compute_units, - NULL) == CL_SUCCESS) + if(clGetDeviceInfo(device_id, + CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(max_compute_units), + &max_compute_units, + NULL) == CL_SUCCESS) { name += " " + to_string(max_compute_units); } diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp index 5960d9aa7d5..19fe0a168ea 100644 --- a/intern/cycles/graph/node.cpp +++ b/intern/cycles/graph/node.cpp @@ -443,7 +443,7 @@ template<typename T> void array_hash(const Node *node, const SocketType& socket, MD5Hash& md5) { const array<T>& a = *(const array<T>*)(((char*)node) + socket.struct_offset); - for (size_t i = 0; i < a.size(); i++) { + for(size_t i = 0; i < a.size(); i++) { md5.append((uint8_t*)&a[i], sizeof(T)); } } @@ -452,7 +452,7 @@ void float3_array_hash(const Node *node, const SocketType& socket, MD5Hash& md5) { /* Don't compare 4th element used for padding. */ const array<float3>& a = *(const array<float3>*)(((char*)node) + socket.struct_offset); - for (size_t i = 0; i < a.size(); i++) { + for(size_t i = 0; i < a.size(); i++) { md5.append((uint8_t*)&a[i], sizeof(float) * 3); } } diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 118e18374a1..c6e92c6d89d 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -76,6 +76,12 @@ set(SRC_BVH_HEADERS bvh/qbvh_traversal.h bvh/qbvh_volume.h bvh/qbvh_volume_all.h + bvh/obvh_nodes.h + bvh/obvh_shadow_all.h + bvh/obvh_local.h + bvh/obvh_traversal.h + bvh/obvh_volume.h + bvh/obvh_volume_all.h ) set(SRC_HEADERS @@ -270,6 +276,8 @@ set(SRC_UTIL_HEADERS ../util/util_types_float3_impl.h ../util/util_types_float4.h ../util/util_types_float4_impl.h + ../util/util_types_float8.h + ../util/util_types_float8_impl.h ../util/util_types_int2.h ../util/util_types_int2_impl.h ../util/util_types_int3.h diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h index de1503e5564..2ad55d041bf 100644 --- a/intern/cycles/kernel/bvh/bvh.h +++ b/intern/cycles/kernel/bvh/bvh.h @@ -32,6 +32,9 @@ CCL_NAMESPACE_BEGIN /* Common QBVH functions. */ #ifdef __QBVH__ # include "kernel/bvh/qbvh_nodes.h" +#ifdef __KERNEL_AVX2__ +# include "kernel/bvh/obvh_nodes.h" +#endif #endif /* Regular BVH traversal */ diff --git a/intern/cycles/kernel/bvh/bvh_local.h b/intern/cycles/kernel/bvh/bvh_local.h index 6356c197dd1..8def71bc890 100644 --- a/intern/cycles/kernel/bvh/bvh_local.h +++ b/intern/cycles/kernel/bvh/bvh_local.h @@ -19,6 +19,9 @@ #ifdef __QBVH__ # include "kernel/bvh/qbvh_local.h" +# ifdef __KERNEL_AVX2__ +# include "kernel/bvh/obvh_local.h" +# endif #endif #if BVH_FEATURE(BVH_HAIR) @@ -254,6 +257,15 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg, int max_hits) { switch(kernel_data.bvh.bvh_layout) { +#ifdef __KERNEL_AVX2__ + case BVH_LAYOUT_BVH8: + return BVH_FUNCTION_FULL_NAME(OBVH)(kg, + ray, + local_isect, + local_object, + lcg_state, + max_hits); +#endif #ifdef __QBVH__ case BVH_LAYOUT_BVH4: return BVH_FUNCTION_FULL_NAME(QBVH)(kg, diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h b/intern/cycles/kernel/bvh/bvh_shadow_all.h index cfc567ff9ca..d525b29fd94 100644 --- a/intern/cycles/kernel/bvh/bvh_shadow_all.h +++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h @@ -19,6 +19,9 @@ #ifdef __QBVH__ # include "kernel/bvh/qbvh_shadow_all.h" +#ifdef __KERNEL_AVX2__ +# include "kernel/bvh/obvh_shadow_all.h" +#endif #endif #if BVH_FEATURE(BVH_HAIR) @@ -396,6 +399,15 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg, uint *num_hits) { switch(kernel_data.bvh.bvh_layout) { +#ifdef __KERNEL_AVX2__ + case BVH_LAYOUT_BVH8: + return BVH_FUNCTION_FULL_NAME(OBVH)(kg, + ray, + isect_array, + visibility, + max_hits, + num_hits); +#endif #ifdef __QBVH__ case BVH_LAYOUT_BVH4: return BVH_FUNCTION_FULL_NAME(QBVH)(kg, diff --git a/intern/cycles/kernel/bvh/bvh_traversal.h b/intern/cycles/kernel/bvh/bvh_traversal.h index 551625eae78..e95d2408201 100644 --- a/intern/cycles/kernel/bvh/bvh_traversal.h +++ b/intern/cycles/kernel/bvh/bvh_traversal.h @@ -20,6 +20,9 @@ #ifdef __QBVH__ # include "kernel/bvh/qbvh_traversal.h" #endif +#ifdef __KERNEL_AVX2__ +# include "kernel/bvh/obvh_traversal.h" +#endif #if BVH_FEATURE(BVH_HAIR) # define NODE_INTERSECT bvh_node_intersect @@ -427,6 +430,19 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg, ) { switch(kernel_data.bvh.bvh_layout) { +#ifdef __KERNEL_AVX2__ + case BVH_LAYOUT_BVH8: + return BVH_FUNCTION_FULL_NAME(OBVH)(kg, + ray, + isect, + visibility +# if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH) + , lcg_state, + difl, + extmax +# endif + ); +#endif #ifdef __QBVH__ case BVH_LAYOUT_BVH4: return BVH_FUNCTION_FULL_NAME(QBVH)(kg, diff --git a/intern/cycles/kernel/bvh/bvh_types.h b/intern/cycles/kernel/bvh/bvh_types.h index ead424aaaaf..4ca0dc2225e 100644 --- a/intern/cycles/kernel/bvh/bvh_types.h +++ b/intern/cycles/kernel/bvh/bvh_types.h @@ -32,7 +32,7 @@ CCL_NAMESPACE_BEGIN /* 64 object BVH + 64 mesh BVH + 64 object node splitting */ #define BVH_STACK_SIZE 192 #define BVH_QSTACK_SIZE 384 - +#define BVH_OSTACK_SIZE 768 /* BVH intersection function variations */ #define BVH_INSTANCING 1 diff --git a/intern/cycles/kernel/bvh/bvh_volume.h b/intern/cycles/kernel/bvh/bvh_volume.h index ce5fc7be33d..7d03855cb8f 100644 --- a/intern/cycles/kernel/bvh/bvh_volume.h +++ b/intern/cycles/kernel/bvh/bvh_volume.h @@ -19,6 +19,9 @@ #ifdef __QBVH__ # include "kernel/bvh/qbvh_volume.h" +#ifdef __KERNEL_AVX2__ +# include "kernel/bvh/obvh_volume.h" +#endif #endif #if BVH_FEATURE(BVH_HAIR) @@ -310,6 +313,13 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg, const uint visibility) { switch(kernel_data.bvh.bvh_layout) { +#ifdef __KERNEL_AVX2__ + case BVH_LAYOUT_BVH8: + return BVH_FUNCTION_FULL_NAME(OBVH)(kg, + ray, + isect, + visibility); +#endif #ifdef __QBVH__ case BVH_LAYOUT_BVH4: return BVH_FUNCTION_FULL_NAME(QBVH)(kg, diff --git a/intern/cycles/kernel/bvh/bvh_volume_all.h b/intern/cycles/kernel/bvh/bvh_volume_all.h index 2ee29ac9c27..3d9b598914f 100644 --- a/intern/cycles/kernel/bvh/bvh_volume_all.h +++ b/intern/cycles/kernel/bvh/bvh_volume_all.h @@ -19,6 +19,9 @@ #ifdef __QBVH__ # include "kernel/bvh/qbvh_volume_all.h" +#ifdef __KERNEL_AVX2__ +# include "kernel/bvh/obvh_volume_all.h" +#endif #endif #if BVH_FEATURE(BVH_HAIR) @@ -386,6 +389,14 @@ ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg, const uint visibility) { switch(kernel_data.bvh.bvh_layout) { +#ifdef __KERNEL_AVX2__ + case BVH_LAYOUT_BVH8: + return BVH_FUNCTION_FULL_NAME(OBVH)(kg, + ray, + isect_array, + max_hits, + visibility); +#endif #ifdef __QBVH__ case BVH_LAYOUT_BVH4: return BVH_FUNCTION_FULL_NAME(QBVH)(kg, diff --git a/intern/cycles/kernel/bvh/obvh_local.h b/intern/cycles/kernel/bvh/obvh_local.h new file mode 100644 index 00000000000..50bcfa79b6c --- /dev/null +++ b/intern/cycles/kernel/bvh/obvh_local.h @@ -0,0 +1,409 @@ +/* + * Copyright 2011-2013 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This is a template BVH traversal function for subsurface scattering, where + * various features can be enabled/disabled. This way we can compile optimized + * versions for each case without new features slowing things down. + * + * BVH_MOTION: motion blur rendering + * + */ + +#if BVH_FEATURE(BVH_HAIR) +# define NODE_INTERSECT obvh_node_intersect +#else +# define NODE_INTERSECT obvh_aligned_node_intersect +#endif + +ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg, + const Ray *ray, + LocalIntersection *local_isect, + int local_object, + uint *lcg_state, + int max_hits) +{ + /* Traversal stack in CUDA thread-local memory. */ + OBVHStackItem traversal_stack[BVH_OSTACK_SIZE]; + traversal_stack[0].addr = ENTRYPOINT_SENTINEL; + + /* Traversal variables in registers. */ + int stack_ptr = 0; + int node_addr = kernel_tex_fetch(__object_node, local_object); + + /* Ray parameters in registers. */ + float3 P = ray->P; + float3 dir = bvh_clamp_direction(ray->D); + float3 idir = bvh_inverse_direction(dir); + int object = OBJECT_NONE; + float isect_t = ray->t; + + local_isect->num_hits = 0; + + const int object_flag = kernel_tex_fetch(__object_flag, local_object); + if(!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { +#if BVH_FEATURE(BVH_MOTION) + Transform ob_itfm; + isect_t = bvh_instance_motion_push(kg, + local_object, + ray, + &P, + &dir, + &idir, + isect_t, + &ob_itfm); +#else + isect_t = bvh_instance_push(kg, local_object, ray, &P, &dir, &idir, isect_t); +#endif + object = local_object; + } + +#ifndef __KERNEL_SSE41__ + if(!isfinite(P.x)) { + return false; + } +#endif + + avxf tnear(0.0f), tfar(isect_t); +#if BVH_FEATURE(BVH_HAIR) + avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +#endif + avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z)); + +#ifdef __KERNEL_AVX2__ + float3 P_idir = P*idir; + avx3f P_idir4(P_idir.x, P_idir.y, P_idir.z); +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + avx3f org4(avxf(P.x), avxf(P.y), avxf(P.z)); +#endif + + /* Offsets to select the side that becomes the lower or upper bound. */ + int near_x, near_y, near_z; + int far_x, far_y, far_z; + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + + /* Traversal loop. */ + do { + do { + /* Traverse internal nodes. */ + while(node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) { + avxf dist; + int child_mask = NODE_INTERSECT(kg, + tnear, + tfar, +#ifdef __KERNEL_AVX2__ + P_idir4, +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4, +#endif +#if BVH_FEATURE(BVH_HAIR) + dir4, +#endif + idir4, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + &dist); + + if(child_mask != 0) { + float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr+0); + avxf cnodes; +#if BVH_FEATURE(BVH_HAIR) + if(__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+26); + } + else +#endif + { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+14); + } + + /* One child is hit, continue with that child. */ + int r = __bscf(child_mask); + if(child_mask == 0) { + node_addr = __float_as_int(cnodes[r]); + continue; + } + + /* Two children are hit, push far child, and continue with + * closer child. + */ + int c0 = __float_as_int(cnodes[r]); + float d0 = ((float*)&dist)[r]; + r = __bscf(child_mask); + int c1 = __float_as_int(cnodes[r]); + float d1 = ((float*)&dist)[r]; + if(child_mask == 0) { + if(d1 < d0) { + node_addr = c1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + continue; + } + else { + node_addr = c0; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + continue; + } + } + + /* Here starts the slow path for 3 or 4 hit children. We push + * all nodes onto the stack to sort them there. + */ + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + + /* Three children are hit, push all onto stack and sort 3 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c2 = __float_as_int(cnodes[r]); + float d2 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Four children are hit, push all onto stack and sort 4 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c3 = __float_as_int(cnodes[r]); + float d3 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + + /* Five children are hit, push all onto stack and sort 5 + * stack items, continue with closest child + */ + r = __bscf(child_mask); + int c4 = __float_as_int(cnodes[r]); + float d4 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + /* Six children are hit, push all onto stack and sort 6 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c5 = __float_as_int(cnodes[r]); + float d5 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + + /* Seven children are hit, push all onto stack and sort 7 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c6 = __float_as_int(cnodes[r]); + float d6 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + /* Eight children are hit, push all onto stack and sort 8 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c7 = __float_as_int(cnodes[r]); + float d7 = ((float*)&dist)[r]; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c7; + traversal_stack[stack_ptr].dist = d7; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6], + &traversal_stack[stack_ptr - 7]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + } + + /* If node is leaf, fetch triangle list. */ + if(node_addr < 0) { + float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr-1)); + int prim_addr = __float_as_int(leaf.x); + + int prim_addr2 = __float_as_int(leaf.y); + const uint type = __float_as_int(leaf.w); + + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + + /* Primitive intersection. */ + switch(type & PRIMITIVE_ALL) { + case PRIMITIVE_TRIANGLE: { + /* Intersect ray against primitive, */ + for(; prim_addr < prim_addr2; prim_addr++) { + kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + if(triangle_intersect_local(kg, + local_isect, + P, + dir, + object, + local_object, + prim_addr, + isect_t, + lcg_state, + max_hits)) + { + return true; + } + } + break; + } +#if BVH_FEATURE(BVH_MOTION) + case PRIMITIVE_MOTION_TRIANGLE: { + /* Intersect ray against primitive. */ + for(; prim_addr < prim_addr2; prim_addr++) { + kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + if(motion_triangle_intersect_local(kg, + local_isect, + P, + dir, + ray->time, + object, + local_object, + prim_addr, + isect_t, + lcg_state, + max_hits)) + { + return true; + } + } + break; + } +#endif + default: + break; + } + } + } while(node_addr != ENTRYPOINT_SENTINEL); + } while(node_addr != ENTRYPOINT_SENTINEL); + return false; +} + +#undef NODE_INTERSECT diff --git a/intern/cycles/kernel/bvh/obvh_nodes.h b/intern/cycles/kernel/bvh/obvh_nodes.h new file mode 100644 index 00000000000..93f35f6dffb --- /dev/null +++ b/intern/cycles/kernel/bvh/obvh_nodes.h @@ -0,0 +1,532 @@ +/* + * Copyright 2011-2014, Blender Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Aligned nodes intersection AVX code is adopted from Embree, + */ + +struct OBVHStackItem { + int addr; + float dist; +}; + +ccl_device_inline void obvh_near_far_idx_calc(const float3& idir, + int *ccl_restrict near_x, + int *ccl_restrict near_y, + int *ccl_restrict near_z, + int *ccl_restrict far_x, + int *ccl_restrict far_y, + int *ccl_restrict far_z) + +{ +#ifdef __KERNEL_SSE__ + *near_x = 0; *far_x = 1; + *near_y = 2; *far_y = 3; + *near_z = 4; *far_z = 5; + + const size_t mask = movemask(ssef(idir.m128)); + + const int mask_x = mask & 1; + const int mask_y = (mask & 2) >> 1; + const int mask_z = (mask & 4) >> 2; + + *near_x += mask_x; *far_x -= mask_x; + *near_y += mask_y; *far_y -= mask_y; + *near_z += mask_z; *far_z -= mask_z; +#else + if(idir.x >= 0.0f) { *near_x = 0; *far_x = 1; } else { *near_x = 1; *far_x = 0; } + if(idir.y >= 0.0f) { *near_y = 2; *far_y = 3; } else { *near_y = 3; *far_y = 2; } + if(idir.z >= 0.0f) { *near_z = 4; *far_z = 5; } else { *near_z = 5; *far_z = 4; } +#endif +} + +ccl_device_inline void obvh_item_swap(OBVHStackItem *ccl_restrict a, + OBVHStackItem *ccl_restrict b) +{ + OBVHStackItem tmp = *a; + *a = *b; + *b = tmp; +} + +ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1, + OBVHStackItem *ccl_restrict s2, + OBVHStackItem *ccl_restrict s3) +{ + if(s2->dist < s1->dist) { obvh_item_swap(s2, s1); } + if(s3->dist < s2->dist) { obvh_item_swap(s3, s2); } + if(s2->dist < s1->dist) { obvh_item_swap(s2, s1); } +} + +ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1, + OBVHStackItem *ccl_restrict s2, + OBVHStackItem *ccl_restrict s3, + OBVHStackItem *ccl_restrict s4) +{ + if(s2->dist < s1->dist) { obvh_item_swap(s2, s1); } + if(s4->dist < s3->dist) { obvh_item_swap(s4, s3); } + if(s3->dist < s1->dist) { obvh_item_swap(s3, s1); } + if(s4->dist < s2->dist) { obvh_item_swap(s4, s2); } + if(s3->dist < s2->dist) { obvh_item_swap(s3, s2); } +} + +ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1, + OBVHStackItem *ccl_restrict s2, + OBVHStackItem *ccl_restrict s3, + OBVHStackItem *ccl_restrict s4, + OBVHStackItem *ccl_restrict s5) +{ + obvh_stack_sort(s1, s2, s3, s4); + if(s5->dist < s4->dist) { + obvh_item_swap(s4, s5); + if(s4->dist < s3->dist) { + obvh_item_swap(s3, s4); + if(s3->dist < s2->dist) { + obvh_item_swap(s2, s3); + if(s2->dist < s1->dist) { + obvh_item_swap(s1, s2); + } + } + } + } +} + +ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1, + OBVHStackItem *ccl_restrict s2, + OBVHStackItem *ccl_restrict s3, + OBVHStackItem *ccl_restrict s4, + OBVHStackItem *ccl_restrict s5, + OBVHStackItem *ccl_restrict s6) +{ + obvh_stack_sort(s1, s2, s3, s4, s5); + if(s6->dist < s5->dist) { + obvh_item_swap(s5, s6); + if(s5->dist < s4->dist) { + obvh_item_swap(s4, s5); + if(s4->dist < s3->dist) { + obvh_item_swap(s3, s4); + if(s3->dist < s2->dist) { + obvh_item_swap(s2, s3); + if(s2->dist < s1->dist) { + obvh_item_swap(s1, s2); + } + } + } + } + } +} + +ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1, + OBVHStackItem *ccl_restrict s2, + OBVHStackItem *ccl_restrict s3, + OBVHStackItem *ccl_restrict s4, + OBVHStackItem *ccl_restrict s5, + OBVHStackItem *ccl_restrict s6, + OBVHStackItem *ccl_restrict s7) +{ + obvh_stack_sort(s1, s2, s3, s4, s5, s6); + if(s7->dist < s6->dist) { + obvh_item_swap(s6, s7); + if(s6->dist < s5->dist) { + obvh_item_swap(s5, s6); + if(s5->dist < s4->dist) { + obvh_item_swap(s4, s5); + if(s4->dist < s3->dist) { + obvh_item_swap(s3, s4); + if(s3->dist < s2->dist) { + obvh_item_swap(s2, s3); + if(s2->dist < s1->dist) { + obvh_item_swap(s1, s2); + } + } + } + } + } + } +} + +ccl_device_inline void obvh_stack_sort(OBVHStackItem *ccl_restrict s1, + OBVHStackItem *ccl_restrict s2, + OBVHStackItem *ccl_restrict s3, + OBVHStackItem *ccl_restrict s4, + OBVHStackItem *ccl_restrict s5, + OBVHStackItem *ccl_restrict s6, + OBVHStackItem *ccl_restrict s7, + OBVHStackItem *ccl_restrict s8) +{ + obvh_stack_sort(s1, s2, s3, s4, s5, s6, s7); + if(s8->dist < s7->dist) { + obvh_item_swap(s7, s8); + if(s7->dist < s6->dist) { + obvh_item_swap(s6, s7); + if(s6->dist < s5->dist) { + obvh_item_swap(s5, s6); + if(s5->dist < s4->dist) { + obvh_item_swap(s4, s5); + if(s4->dist < s3->dist) { + obvh_item_swap(s3, s4); + if(s3->dist < s2->dist) { + obvh_item_swap(s2, s3); + if(s2->dist < s1->dist) { + obvh_item_swap(s1, s2); + } + } + } + } + } + } + } +} + +/* Axis-aligned nodes intersection */ + +ccl_device_inline int obvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg, + const avxf& isect_near, + const avxf& isect_far, +#ifdef __KERNEL_AVX2__ + const avx3f& org_idir, +#else + const avx3f& org, +#endif + const avx3f& idir, + const int near_x, + const int near_y, + const int near_z, + const int far_x, + const int far_y, + const int far_z, + const int node_addr, + avxf *ccl_restrict dist) +{ + const int offset = node_addr + 2; +#ifdef __KERNEL_AVX2__ + const avxf tnear_x = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset+near_x*2), idir.x, org_idir.x); + const avxf tnear_y = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset+near_y*2), idir.y, org_idir.y); + const avxf tnear_z = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset+near_z*2), idir.z, org_idir.z); + const avxf tfar_x = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset+far_x*2), idir.x, org_idir.x); + const avxf tfar_y = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset+far_y*2), idir.y, org_idir.y); + const avxf tfar_z = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset+far_z*2), idir.z, org_idir.z); + + const avxf tnear = max4(tnear_x, tnear_y, tnear_z, isect_near); + const avxf tfar = min4(tfar_x, tfar_y, tfar_z, isect_far); + const avxb vmask = tnear <= tfar; + int mask = (int)movemask(vmask); + *dist = tnear; + return mask; +#else + return 0; +#endif +} + +ccl_device_inline int obvh_aligned_node_intersect_robust( + KernelGlobals *ccl_restrict kg, + const avxf& isect_near, + const avxf& isect_far, +#ifdef __KERNEL_AVX2__ + const avx3f& P_idir, +#else + const avx3f& P, +#endif + const avx3f& idir, + const int near_x, + const int near_y, + const int near_z, + const int far_x, + const int far_y, + const int far_z, + const int node_addr, + const float difl, + avxf *ccl_restrict dist) +{ + const int offset = node_addr + 2; +#ifdef __KERNEL_AVX2__ + const avxf tnear_x = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset + near_x * 2), idir.x, P_idir.x); + const avxf tfar_x = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset + far_x * 2), idir.x, P_idir.x); + const avxf tnear_y = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset + near_y * 2), idir.y, P_idir.y); + const avxf tfar_y = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset + far_y * 2), idir.y, P_idir.y); + const avxf tnear_z = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset + near_z * 2), idir.z, P_idir.z); + const avxf tfar_z = msub(kernel_tex_fetch_avxf(__bvh_nodes, offset + far_z * 2), idir.z, P_idir.z); + + const float round_down = 1.0f - difl; + const float round_up = 1.0f + difl; + const avxf tnear = max4(tnear_x, tnear_y, tnear_z, isect_near); + const avxf tfar = min4(tfar_x, tfar_y, tfar_z, isect_far); + const avxb vmask = round_down*tnear <= round_up*tfar; + int mask = (int)movemask(vmask); + *dist = tnear; + return mask; +#else + return 0; +#endif +} + +/* Unaligned nodes intersection */ + +ccl_device_inline int obvh_unaligned_node_intersect( + KernelGlobals *ccl_restrict kg, + const avxf& isect_near, + const avxf& isect_far, +#ifdef __KERNEL_AVX2__ + const avx3f& org_idir, +#endif + const avx3f& org, + const avx3f& dir, + const avx3f& idir, + const int near_x, + const int near_y, + const int near_z, + const int far_x, + const int far_y, + const int far_z, + const int node_addr, + avxf *ccl_restrict dist) +{ + const int offset = node_addr; + const avxf tfm_x_x = kernel_tex_fetch_avxf(__bvh_nodes, offset+2); + const avxf tfm_x_y = kernel_tex_fetch_avxf(__bvh_nodes, offset+4); + const avxf tfm_x_z = kernel_tex_fetch_avxf(__bvh_nodes, offset+6); + + const avxf tfm_y_x = kernel_tex_fetch_avxf(__bvh_nodes, offset+8); + const avxf tfm_y_y = kernel_tex_fetch_avxf(__bvh_nodes, offset+10); + const avxf tfm_y_z = kernel_tex_fetch_avxf(__bvh_nodes, offset+12); + + const avxf tfm_z_x = kernel_tex_fetch_avxf(__bvh_nodes, offset+14); + const avxf tfm_z_y = kernel_tex_fetch_avxf(__bvh_nodes, offset+16); + const avxf tfm_z_z = kernel_tex_fetch_avxf(__bvh_nodes, offset+18); + + const avxf tfm_t_x = kernel_tex_fetch_avxf(__bvh_nodes, offset+20); + const avxf tfm_t_y = kernel_tex_fetch_avxf(__bvh_nodes, offset+22); + const avxf tfm_t_z = kernel_tex_fetch_avxf(__bvh_nodes, offset+24); + + const avxf aligned_dir_x = dir.x*tfm_x_x + dir.y*tfm_x_y + dir.z*tfm_x_z, + aligned_dir_y = dir.x*tfm_y_x + dir.y*tfm_y_y + dir.z*tfm_y_z, + aligned_dir_z = dir.x*tfm_z_x + dir.y*tfm_z_y + dir.z*tfm_z_z; + + const avxf aligned_P_x = org.x*tfm_x_x + org.y*tfm_x_y + org.z*tfm_x_z + tfm_t_x, + aligned_P_y = org.x*tfm_y_x + org.y*tfm_y_y + org.z*tfm_y_z + tfm_t_y, + aligned_P_z = org.x*tfm_z_x + org.y*tfm_z_y + org.z*tfm_z_z + tfm_t_z; + + const avxf neg_one(-1.0f); + const avxf nrdir_x = neg_one / aligned_dir_x, + nrdir_y = neg_one / aligned_dir_y, + nrdir_z = neg_one / aligned_dir_z; + + const avxf tlower_x = aligned_P_x * nrdir_x, + tlower_y = aligned_P_y * nrdir_y, + tlower_z = aligned_P_z * nrdir_z; + + const avxf tupper_x = tlower_x - nrdir_x, + tupper_y = tlower_y - nrdir_y, + tupper_z = tlower_z - nrdir_z; + + const avxf tnear_x = min(tlower_x, tupper_x); + const avxf tnear_y = min(tlower_y, tupper_y); + const avxf tnear_z = min(tlower_z, tupper_z); + const avxf tfar_x = max(tlower_x, tupper_x); + const avxf tfar_y = max(tlower_y, tupper_y); + const avxf tfar_z = max(tlower_z, tupper_z); + const avxf tnear = max4(isect_near, tnear_x, tnear_y, tnear_z); + const avxf tfar = min4(isect_far, tfar_x, tfar_y, tfar_z); + const avxb vmask = tnear <= tfar; + *dist = tnear; + return movemask(vmask); +} + +ccl_device_inline int obvh_unaligned_node_intersect_robust( + KernelGlobals *ccl_restrict kg, + const avxf& isect_near, + const avxf& isect_far, +#ifdef __KERNEL_AVX2__ + const avx3f& P_idir, +#endif + const avx3f& P, + const avx3f& dir, + const avx3f& idir, + const int near_x, + const int near_y, + const int near_z, + const int far_x, + const int far_y, + const int far_z, + const int node_addr, + const float difl, + avxf *ccl_restrict dist) +{ + const int offset = node_addr; + const avxf tfm_x_x = kernel_tex_fetch_avxf(__bvh_nodes, offset+2); + const avxf tfm_x_y = kernel_tex_fetch_avxf(__bvh_nodes, offset+4); + const avxf tfm_x_z = kernel_tex_fetch_avxf(__bvh_nodes, offset+6); + + const avxf tfm_y_x = kernel_tex_fetch_avxf(__bvh_nodes, offset+8); + const avxf tfm_y_y = kernel_tex_fetch_avxf(__bvh_nodes, offset+10); + const avxf tfm_y_z = kernel_tex_fetch_avxf(__bvh_nodes, offset+12); + + const avxf tfm_z_x = kernel_tex_fetch_avxf(__bvh_nodes, offset+14); + const avxf tfm_z_y = kernel_tex_fetch_avxf(__bvh_nodes, offset+16); + const avxf tfm_z_z = kernel_tex_fetch_avxf(__bvh_nodes, offset+18); + + const avxf tfm_t_x = kernel_tex_fetch_avxf(__bvh_nodes, offset+20); + const avxf tfm_t_y = kernel_tex_fetch_avxf(__bvh_nodes, offset+22); + const avxf tfm_t_z = kernel_tex_fetch_avxf(__bvh_nodes, offset+24); + + const avxf aligned_dir_x = dir.x*tfm_x_x + dir.y*tfm_x_y + dir.z*tfm_x_z, + aligned_dir_y = dir.x*tfm_y_x + dir.y*tfm_y_y + dir.z*tfm_y_z, + aligned_dir_z = dir.x*tfm_z_x + dir.y*tfm_z_y + dir.z*tfm_z_z; + + const avxf aligned_P_x = P.x*tfm_x_x + P.y*tfm_x_y + P.z*tfm_x_z + tfm_t_x, + aligned_P_y = P.x*tfm_y_x + P.y*tfm_y_y + P.z*tfm_y_z + tfm_t_y, + aligned_P_z = P.x*tfm_z_x + P.y*tfm_z_y + P.z*tfm_z_z + tfm_t_z; + + const avxf neg_one(-1.0f); + const avxf nrdir_x = neg_one / aligned_dir_x, + nrdir_y = neg_one / aligned_dir_y, + nrdir_z = neg_one / aligned_dir_z; + + const avxf tlower_x = aligned_P_x * nrdir_x, + tlower_y = aligned_P_y * nrdir_y, + tlower_z = aligned_P_z * nrdir_z; + + const avxf tupper_x = tlower_x - nrdir_x, + tupper_y = tlower_y - nrdir_y, + tupper_z = tlower_z - nrdir_z; + + const float round_down = 1.0f - difl; + const float round_up = 1.0f + difl; + + const avxf tnear_x = min(tlower_x, tupper_x); + const avxf tnear_y = min(tlower_y, tupper_y); + const avxf tnear_z = min(tlower_z, tupper_z); + const avxf tfar_x = max(tlower_x, tupper_x); + const avxf tfar_y = max(tlower_y, tupper_y); + const avxf tfar_z = max(tlower_z, tupper_z); + + const avxf tnear = max4(isect_near, tnear_x, tnear_y, tnear_z); + const avxf tfar = min4(isect_far, tfar_x, tfar_y, tfar_z); + const avxb vmask = round_down*tnear <= round_up*tfar; + *dist = tnear; + return movemask(vmask); +} + +/* Intersectors wrappers. + * + * They'll check node type and call appropriate intersection code. + */ + +ccl_device_inline int obvh_node_intersect( + KernelGlobals *ccl_restrict kg, + const avxf& isect_near, + const avxf& isect_far, +#ifdef __KERNEL_AVX2__ + const avx3f& org_idir, +#endif + const avx3f& org, + const avx3f& dir, + const avx3f& idir, + const int near_x, + const int near_y, + const int near_z, + const int far_x, + const int far_y, + const int far_z, + const int node_addr, + avxf *ccl_restrict dist) +{ + const int offset = node_addr; + const float4 node = kernel_tex_fetch(__bvh_nodes, offset); + if(__float_as_uint(node.x) & PATH_RAY_NODE_UNALIGNED) { + return obvh_unaligned_node_intersect(kg, + isect_near, + isect_far, +#ifdef __KERNEL_AVX2__ + org_idir, +#endif + org, + dir, + idir, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + dist); + } + else { + return obvh_aligned_node_intersect(kg, + isect_near, + isect_far, +#ifdef __KERNEL_AVX2__ + org_idir, +#else + org, +#endif + idir, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + dist); + } +} + +ccl_device_inline int obvh_node_intersect_robust( + KernelGlobals *ccl_restrict kg, + const avxf& isect_near, + const avxf& isect_far, +#ifdef __KERNEL_AVX2__ + const avx3f& P_idir, +#endif + const avx3f& P, + const avx3f& dir, + const avx3f& idir, + const int near_x, + const int near_y, + const int near_z, + const int far_x, + const int far_y, + const int far_z, + const int node_addr, + const float difl, + avxf *ccl_restrict dist) +{ + const int offset = node_addr; + const float4 node = kernel_tex_fetch(__bvh_nodes, offset); + if(__float_as_uint(node.x) & PATH_RAY_NODE_UNALIGNED) { + return obvh_unaligned_node_intersect_robust(kg, + isect_near, + isect_far, +#ifdef __KERNEL_AVX2__ + P_idir, +#endif + P, + dir, + idir, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + difl, + dist); + } + else { + return obvh_aligned_node_intersect_robust(kg, + isect_near, + isect_far, +#ifdef __KERNEL_AVX2__ + P_idir, +#else + P, +#endif + idir, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + difl, + dist); + } +} diff --git a/intern/cycles/kernel/bvh/obvh_shadow_all.h b/intern/cycles/kernel/bvh/obvh_shadow_all.h new file mode 100644 index 00000000000..3e877065127 --- /dev/null +++ b/intern/cycles/kernel/bvh/obvh_shadow_all.h @@ -0,0 +1,687 @@ +/* + * Copyright 2011-2013 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This is a template BVH traversal function, where various features can be + * enabled/disabled. This way we can compile optimized versions for each case + * without new features slowing things down. + * + * BVH_INSTANCING: object instancing + * BVH_HAIR: hair curve rendering + * BVH_MOTION: motion blur rendering + * + */ + +#if BVH_FEATURE(BVH_HAIR) +# define NODE_INTERSECT obvh_node_intersect +#else +# define NODE_INTERSECT obvh_aligned_node_intersect +#endif + +ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg, + const Ray *ray, + Intersection *isect_array, + const int skip_object, + const uint max_hits, + uint *num_hits) +{ + /* TODO(sergey): + * - Test if pushing distance on the stack helps. + * - Likely and unlikely for if() statements. + * - Test restrict attribute for pointers. + */ + + /* Traversal stack in CUDA thread-local memory. */ + OBVHStackItem traversal_stack[BVH_OSTACK_SIZE]; + traversal_stack[0].addr = ENTRYPOINT_SENTINEL; + + /* Traversal variables in registers. */ + int stack_ptr = 0; + int node_addr = kernel_data.bvh.root; + + /* Ray parameters in registers. */ + const float tmax = ray->t; + float3 P = ray->P; + float3 dir = bvh_clamp_direction(ray->D); + float3 idir = bvh_inverse_direction(dir); + int object = OBJECT_NONE; + float isect_t = tmax; + +#if BVH_FEATURE(BVH_MOTION) + Transform ob_itfm; +#endif + + *num_hits = 0; + isect_array->t = tmax; + +#ifndef __KERNEL_SSE41__ + if(!isfinite(P.x)) { + return false; + } +#endif + +#if BVH_FEATURE(BVH_INSTANCING) + int num_hits_in_instance = 0; +#endif + + avxf tnear(0.0f), tfar(isect_t); +#if BVH_FEATURE(BVH_HAIR) + avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +#endif + avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z)); + +#ifdef __KERNEL_AVX2__ + float3 P_idir = P*idir; + avx3f P_idir4(P_idir.x, P_idir.y, P_idir.z); +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + avx3f org4(avxf(P.x), avxf(P.y), avxf(P.z)); +#endif + + /* Offsets to select the side that becomes the lower or upper bound. */ + int near_x, near_y, near_z; + int far_x, far_y, far_z; + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + + /* Traversal loop. */ + do { + do { + /* Traverse internal nodes. */ + while(node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) { + float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr+0); + (void)inodes; + + if(false +#ifdef __VISIBILITY_FLAG__ + || ((__float_as_uint(inodes.x) & PATH_RAY_SHADOW) == 0) +#endif +#if BVH_FEATURE(BVH_MOTION) + || UNLIKELY(ray->time < inodes.y) + || UNLIKELY(ray->time > inodes.z) +#endif + ) { + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + avxf dist; + int child_mask = NODE_INTERSECT(kg, + tnear, + tfar, +#ifdef __KERNEL_AVX2__ + P_idir4, +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) +//#if !defined(__KERNEL_AVX2__) + org4, +#endif +#if BVH_FEATURE(BVH_HAIR) + dir4, +#endif + idir4, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + &dist); + + if(child_mask != 0) { + avxf cnodes; +#if BVH_FEATURE(BVH_HAIR) + if(__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+26); + } + else +#endif + { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+14); + } + + /* One child is hit, continue with that child. */ + int r = __bscf(child_mask); + if(child_mask == 0) { + node_addr = __float_as_int(cnodes[r]); + continue; + } + + /* Two children are hit, push far child, and continue with + * closer child. + */ + int c0 = __float_as_int(cnodes[r]); + float d0 = ((float*)&dist)[r]; + r = __bscf(child_mask); + int c1 = __float_as_int(cnodes[r]); + float d1 = ((float*)&dist)[r]; + if(child_mask == 0) { + if(d1 < d0) { + node_addr = c1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + continue; + } + else { + node_addr = c0; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + continue; + } + } + + /* Here starts the slow path for 3 or 4 hit children. We push + * all nodes onto the stack to sort them there. + */ + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + + /* Three children are hit, push all onto stack and sort 3 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c2 = __float_as_int(cnodes[r]); + float d2 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Four children are hit, push all onto stack and sort 4 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c3 = __float_as_int(cnodes[r]); + float d3 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + + /* Five children are hit, push all onto stack and sort 5 + * stack items, continue with closest child + */ + r = __bscf(child_mask); + int c4 = __float_as_int(cnodes[r]); + float d4 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Six children are hit, push all onto stack and sort 6 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c5 = __float_as_int(cnodes[r]); + float d5 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + + /* Seven children are hit, push all onto stack and sort 7 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c6 = __float_as_int(cnodes[r]); + float d6 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Eight children are hit, push all onto stack and sort 8 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c7 = __float_as_int(cnodes[r]); + float d7 = ((float*)&dist)[r]; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c7; + traversal_stack[stack_ptr].dist = d7; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6], + &traversal_stack[stack_ptr - 7]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + } + + /* If node is leaf, fetch triangle list. */ + if(node_addr < 0) { + float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr-1)); +#ifdef __VISIBILITY_FLAG__ + if((__float_as_uint(leaf.z) & PATH_RAY_SHADOW) == 0) { + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } +#endif + + int prim_addr = __float_as_int(leaf.x); + +#if BVH_FEATURE(BVH_INSTANCING) + if(prim_addr >= 0) { +#endif + int prim_addr2 = __float_as_int(leaf.y); + const uint type = __float_as_int(leaf.w); + const uint p_type = type & PRIMITIVE_ALL; + + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + + /* Primitive intersection. */ + if(p_type == PRIMITIVE_TRIANGLE) { + int prim_count = prim_addr2 - prim_addr; + if(prim_count < 3) { + while(prim_addr < prim_addr2) { + kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type); + int hit = triangle_intersect(kg, + isect_array, + P, + dir, + PATH_RAY_SHADOW, + object, + prim_addr); + /* Shadow ray early termination. */ + if(hit) { + /* detect if this surface has a shader with transparent shadows */ + + /* todo: optimize so primitive visibility flag indicates if + * the primitive has a transparent shadow shader? */ + int prim = kernel_tex_fetch(__prim_index, isect_array->prim); + int shader = 0; + +#ifdef __HAIR__ + if(kernel_tex_fetch(__prim_type, isect_array->prim) & PRIMITIVE_ALL_TRIANGLE) +#endif + { + shader = kernel_tex_fetch(__tri_shader, prim); + } +#ifdef __HAIR__ + else { + float4 str = kernel_tex_fetch(__curves, prim); + shader = __float_as_int(str.z); + } +#endif + int flag = kernel_tex_fetch(__shaders, (shader & SHADER_MASK)).flags; + + /* if no transparent shadows, all light is blocked */ + if(!(flag & SD_HAS_TRANSPARENT_SHADOW)) { + return true; + } + /* if maximum number of hits reached, block all light */ + else if(*num_hits == max_hits) { + return true; + } + + /* move on to next entry in intersections array */ + isect_array++; + (*num_hits)++; +#if BVH_FEATURE(BVH_INSTANCING) + num_hits_in_instance++; +#endif + + isect_array->t = isect_t; + } + + prim_addr++; + } //while + } else { + kernel_assert((kernel_tex_fetch(__prim_type, (prim_addr)) & PRIMITIVE_ALL) == p_type); + +#if BVH_FEATURE(BVH_INSTANCING) + int* nhiptr = &num_hits_in_instance; +#else + int nhi= 0; + int *nhiptr = &nhi; +#endif + + int result = triangle_intersect8(kg, + &isect_array, + P, + dir, + PATH_RAY_SHADOW, + object, + prim_addr, + prim_count, + num_hits, + max_hits, + nhiptr, + isect_t); + if(result == 2) { + return true; + } + } // prim_count + } // PRIMITIVE_TRIANGLE + else { + while(prim_addr < prim_addr2) { + kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type); + +#ifdef __SHADOW_TRICKS__ + uint tri_object = (object == OBJECT_NONE) + ? kernel_tex_fetch(__prim_object, prim_addr) + : object; + if(tri_object == skip_object) { + ++prim_addr; + continue; + } +#endif + + bool hit; + + /* todo: specialized intersect functions which don't fill in + * isect unless needed and check SD_HAS_TRANSPARENT_SHADOW? + * might give a few % performance improvement */ + + switch(p_type) { + +#if BVH_FEATURE(BVH_MOTION) + case PRIMITIVE_MOTION_TRIANGLE: { + hit = motion_triangle_intersect(kg, + isect_array, + P, + dir, + ray->time, + PATH_RAY_SHADOW, + object, + prim_addr); + break; + } +#endif +#if BVH_FEATURE(BVH_HAIR) + case PRIMITIVE_CURVE: + case PRIMITIVE_MOTION_CURVE: { + const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr); + if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { + hit = cardinal_curve_intersect(kg, + isect_array, + P, + dir, + PATH_RAY_SHADOW, + object, + prim_addr, + ray->time, + curve_type, + NULL, + 0, 0); + } + else { + hit = curve_intersect(kg, + isect_array, + P, + dir, + PATH_RAY_SHADOW, + object, + prim_addr, + ray->time, + curve_type, + NULL, + 0, 0); + } + break; + } +#endif + default: { + hit = false; + break; + } + } + + /* Shadow ray early termination. */ + if(hit) { + /* detect if this surface has a shader with transparent shadows */ + + /* todo: optimize so primitive visibility flag indicates if + * the primitive has a transparent shadow shader? */ + int prim = kernel_tex_fetch(__prim_index, isect_array->prim); + int shader = 0; + +#ifdef __HAIR__ + if(kernel_tex_fetch(__prim_type, isect_array->prim) & PRIMITIVE_ALL_TRIANGLE) +#endif + { + shader = kernel_tex_fetch(__tri_shader, prim); + } +#ifdef __HAIR__ + else { + float4 str = kernel_tex_fetch(__curves, prim); + shader = __float_as_int(str.z); + } +#endif + int flag = kernel_tex_fetch(__shaders, (shader & SHADER_MASK)).flags; + + /* if no transparent shadows, all light is blocked */ + if(!(flag & SD_HAS_TRANSPARENT_SHADOW)) { + return true; + } + /* if maximum number of hits reached, block all light */ + else if(*num_hits == max_hits) { + return true; + } + + /* move on to next entry in intersections array */ + isect_array++; + (*num_hits)++; +#if BVH_FEATURE(BVH_INSTANCING) + num_hits_in_instance++; +#endif + + isect_array->t = isect_t; + } + + prim_addr++; + }//while prim + } + } +#if BVH_FEATURE(BVH_INSTANCING) + else { + /* Instance push. */ + object = kernel_tex_fetch(__prim_object, -prim_addr-1); + +# if BVH_FEATURE(BVH_MOTION) + isect_t = bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, isect_t, &ob_itfm); +# else + isect_t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect_t); +# endif + + num_hits_in_instance = 0; + isect_array->t = isect_t; + + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + tfar = avxf(isect_t); +# if BVH_FEATURE(BVH_HAIR) + dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +# endif + idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z)); +# ifdef __KERNEL_AVX2__ + P_idir = P*idir; + P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z); +# endif +# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z)); +# endif + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL; + + node_addr = kernel_tex_fetch(__object_node, object); + + } + } +#endif /* FEATURE(BVH_INSTANCING) */ + } while(node_addr != ENTRYPOINT_SENTINEL); + +#if BVH_FEATURE(BVH_INSTANCING) + if(stack_ptr >= 0) { + kernel_assert(object != OBJECT_NONE); + + /* Instance pop. */ + if(num_hits_in_instance) { + float t_fac; +# if BVH_FEATURE(BVH_MOTION) + bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm); +# else + bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac); +# endif + /* Scale isect->t to adjust for instancing. */ + for(int i = 0; i < num_hits_in_instance; i++) { + (isect_array-i-1)->t *= t_fac; + } + } + else { +# if BVH_FEATURE(BVH_MOTION) + bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX, &ob_itfm); +# else + bvh_instance_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX); +# endif + } + + isect_t = tmax; + isect_array->t = isect_t; + + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + tfar = avxf(isect_t); +# if BVH_FEATURE(BVH_HAIR) + dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +# endif + idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z)); +# ifdef __KERNEL_AVX2__ + P_idir = P*idir; + P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z); +# endif +# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z)); +# endif + + object = OBJECT_NONE; + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + } +#endif /* FEATURE(BVH_INSTANCING) */ + } while(node_addr != ENTRYPOINT_SENTINEL); + + return false; +} + +#undef NODE_INTERSECT diff --git a/intern/cycles/kernel/bvh/obvh_traversal.h b/intern/cycles/kernel/bvh/obvh_traversal.h new file mode 100644 index 00000000000..2021d8e1143 --- /dev/null +++ b/intern/cycles/kernel/bvh/obvh_traversal.h @@ -0,0 +1,642 @@ +/* + * Copyright 2011-2013 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This is a template BVH traversal function, where various features can be + * enabled/disabled. This way we can compile optimized versions for each case + * without new features slowing things down. + * + * BVH_INSTANCING: object instancing + * BVH_HAIR: hair curve rendering + * BVH_HAIR_MINIMUM_WIDTH: hair curve rendering with minimum width + * BVH_MOTION: motion blur rendering + * + */ + +#if BVH_FEATURE(BVH_HAIR) +# define NODE_INTERSECT obvh_node_intersect +# define NODE_INTERSECT_ROBUST obvh_node_intersect_robust +#else +# define NODE_INTERSECT obvh_aligned_node_intersect +# define NODE_INTERSECT_ROBUST obvh_aligned_node_intersect_robust +#endif + +ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg, + const Ray *ray, + Intersection *isect, + const uint visibility +#if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH) + ,uint *lcg_state, + float difl, + float extmax +#endif + ) +{ + /* Traversal stack in CUDA thread-local memory. */ + OBVHStackItem traversal_stack[BVH_OSTACK_SIZE]; + traversal_stack[0].addr = ENTRYPOINT_SENTINEL; + traversal_stack[0].dist = -FLT_MAX; + + /* Traversal variables in registers. */ + int stack_ptr = 0; + int node_addr = kernel_data.bvh.root; + float node_dist = -FLT_MAX; + + /* Ray parameters in registers. */ + float3 P = ray->P; + float3 dir = bvh_clamp_direction(ray->D); + float3 idir = bvh_inverse_direction(dir); + int object = OBJECT_NONE; + +#if BVH_FEATURE(BVH_MOTION) + Transform ob_itfm; +#endif + +#ifndef __KERNEL_SSE41__ + if(!isfinite(P.x)) { + return false; + } +#endif + + isect->t = ray->t; + isect->u = 0.0f; + isect->v = 0.0f; + isect->prim = PRIM_NONE; + isect->object = OBJECT_NONE; + + BVH_DEBUG_INIT(); + avxf tnear(0.0f), tfar(ray->t); +#if BVH_FEATURE(BVH_HAIR) + avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +#endif + avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z)); + +#ifdef __KERNEL_AVX2__ + float3 P_idir = P*idir; + avx3f P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z); +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + avx3f org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z)); +#endif + + /* Offsets to select the side that becomes the lower or upper bound. */ + int near_x, near_y, near_z; + int far_x, far_y, far_z; + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + /* Traversal loop. */ + do { + do { + /* Traverse internal nodes. */ + while(node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) { + float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr+0); + (void)inodes; + + if(UNLIKELY(node_dist > isect->t) +#if BVH_FEATURE(BVH_MOTION) + || UNLIKELY(ray->time < inodes.y) + || UNLIKELY(ray->time > inodes.z) +#endif +#ifdef __VISIBILITY_FLAG__ + || (__float_as_uint(inodes.x) & visibility) == 0 +#endif + ) + { + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + continue; + } + + int child_mask; + avxf dist; + + BVH_DEBUG_NEXT_NODE(); + +#if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH) + if(difl != 0.0f) { + /* NOTE: We extend all the child BB instead of fetching + * and checking visibility flags for each of the, + * + * Need to test if doing opposite would be any faster. + */ + child_mask = NODE_INTERSECT_ROBUST(kg, + tnear, + tfar, +# ifdef __KERNEL_AVX2__ + P_idir4, +# endif +# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4, +# endif +# if BVH_FEATURE(BVH_HAIR) + dir4, +# endif + idir4, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + difl, + &dist); + } + else +#endif /* BVH_HAIR_MINIMUM_WIDTH */ + { + child_mask = NODE_INTERSECT(kg, + tnear, + tfar, +#ifdef __KERNEL_AVX2__ + P_idir4, +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4, +#endif +#if BVH_FEATURE(BVH_HAIR) + dir4, +#endif + idir4, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + &dist); + } + + if(child_mask != 0) { + avxf cnodes; + /* TODO(sergey): Investigate whether moving cnodes upwards + * gives a speedup (will be different cache pattern but will + * avoid extra check here), + */ +#if BVH_FEATURE(BVH_HAIR) + if(__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+26); + } + else +#endif + { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+14); + } + + /* One child is hit, continue with that child. */ + int r = __bscf(child_mask); + float d0 = ((float*)&dist)[r]; + if(child_mask == 0) { + node_addr = __float_as_int(cnodes[r]); + node_dist = d0; + continue; + } + + /* Two children are hit, push far child, and continue with + * closer child. + */ + int c0 = __float_as_int(cnodes[r]); + r = __bscf(child_mask); + int c1 = __float_as_int(cnodes[r]); + float d1 = ((float*)&dist)[r]; + if(child_mask == 0) { + if(d1 < d0) { + node_addr = c1; + node_dist = d1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + continue; + } + else { + node_addr = c0; + node_dist = d0; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + continue; + } + } + + /* Here starts the slow path for 3 or 4 hit children. We push + * all nodes onto the stack to sort them there. + */ + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + + /* Three children are hit, push all onto stack and sort 3 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c2 = __float_as_int(cnodes[r]); + float d2 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2]); + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + continue; + } + + /* Four children are hit, push all onto stack and sort 4 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c3 = __float_as_int(cnodes[r]); + float d3 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3]); + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + + /* Five children are hit, push all onto stack and sort 5 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c4 = __float_as_int(cnodes[r]); + float d4 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4]); + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + continue; + } + + /* Six children are hit, push all onto stack and sort 6 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c5 = __float_as_int(cnodes[r]); + float d5 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5]); + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + + /* Seven children are hit, push all onto stack and sort 7 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c6 = __float_as_int(cnodes[r]); + float d6 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6]); + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + continue; + } + + /* Eight children are hit, push all onto stack and sort 8 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c7 = __float_as_int(cnodes[r]); + float d7 = ((float*)&dist)[r]; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c7; + traversal_stack[stack_ptr].dist = d7; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6], + &traversal_stack[stack_ptr - 7]); + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + continue; + } + + + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + } + + /* If node is leaf, fetch triangle list. */ + if(node_addr < 0) { + float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr-1)); + +#ifdef __VISIBILITY_FLAG__ + if(UNLIKELY((node_dist > isect->t) || + ((__float_as_uint(leaf.z) & visibility) == 0))) +#else + if(UNLIKELY((node_dist > isect->t))) +#endif + { + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + continue; + } + int prim_addr = __float_as_int(leaf.x); + +#if BVH_FEATURE(BVH_INSTANCING) + if(prim_addr >= 0) { +#endif + int prim_addr2 = __float_as_int(leaf.y); + const uint type = __float_as_int(leaf.w); + + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + + /* Primitive intersection. */ + switch(type & PRIMITIVE_ALL) { + case PRIMITIVE_TRIANGLE: { + int prim_count = prim_addr2 - prim_addr; + if(prim_count < 3) { + for(; prim_addr < prim_addr2; prim_addr++) { + BVH_DEBUG_NEXT_INTERSECTION(); + kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + if(triangle_intersect(kg, + isect, + P, + dir, + visibility, + object, + prim_addr)) + { + tfar = avxf(isect->t); + /* Shadow ray early termination. */ + if(visibility == PATH_RAY_SHADOW_OPAQUE) { + return true; + } + } + }//for + } + else { + kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + if(triangle_intersect8(kg, + &isect, + P, + dir, + visibility, + object, + prim_addr, + prim_count, + 0, + 0, + NULL, + 0.0f)) + { + tfar = avxf(isect->t); + if(visibility == PATH_RAY_SHADOW_OPAQUE) { + return true; + } + } + }//prim count + break; + } +#if BVH_FEATURE(BVH_MOTION) + case PRIMITIVE_MOTION_TRIANGLE: { + for(; prim_addr < prim_addr2; prim_addr++) { + BVH_DEBUG_NEXT_INTERSECTION(); + kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + if(motion_triangle_intersect(kg, + isect, + P, + dir, + ray->time, + visibility, + object, + prim_addr)) + { + tfar = avxf(isect->t); + /* Shadow ray early termination. */ + if(visibility == PATH_RAY_SHADOW_OPAQUE) { + return true; + } + } + } + break; + } +#endif /* BVH_FEATURE(BVH_MOTION) */ +#if BVH_FEATURE(BVH_HAIR) + case PRIMITIVE_CURVE: + case PRIMITIVE_MOTION_CURVE: { + for(; prim_addr < prim_addr2; prim_addr++) { + BVH_DEBUG_NEXT_INTERSECTION(); + const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr); + kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL)); + bool hit; + if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { + hit = cardinal_curve_intersect(kg, + isect, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + lcg_state, + difl, + extmax); + } + else { + hit = curve_intersect(kg, + isect, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + lcg_state, + difl, + extmax); + } + if(hit) { + tfar = avxf(isect->t); + /* Shadow ray early termination. */ + if(visibility == PATH_RAY_SHADOW_OPAQUE) { + return true; + } + } + } + break; + } +#endif /* BVH_FEATURE(BVH_HAIR) */ + } + } +#if BVH_FEATURE(BVH_INSTANCING) + else { + /* Instance push. */ + object = kernel_tex_fetch(__prim_object, -prim_addr-1); + +# if BVH_FEATURE(BVH_MOTION) + qbvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &node_dist, &ob_itfm); +# else + qbvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t, &node_dist); +# endif + + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + tfar = avxf(isect->t); +# if BVH_FEATURE(BVH_HAIR) + dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +# endif + idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z)); +# ifdef __KERNEL_AVX2__ + P_idir = P*idir; + P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z); +# endif +# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z)); +# endif + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL; + traversal_stack[stack_ptr].dist = -FLT_MAX; + + node_addr = kernel_tex_fetch(__object_node, object); + + BVH_DEBUG_NEXT_INSTANCE(); + } + } +#endif /* FEATURE(BVH_INSTANCING) */ + } while(node_addr != ENTRYPOINT_SENTINEL); + +#if BVH_FEATURE(BVH_INSTANCING) + if(stack_ptr >= 0) { + kernel_assert(object != OBJECT_NONE); + + /* Instance pop. */ +# if BVH_FEATURE(BVH_MOTION) + isect->t = bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, isect->t, &ob_itfm); +# else + isect->t = bvh_instance_pop(kg, object, ray, &P, &dir, &idir, isect->t); +# endif + + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + tfar = avxf(isect->t); +# if BVH_FEATURE(BVH_HAIR) + dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +# endif + idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z)); +# ifdef __KERNEL_AVX2__ + P_idir = P*idir; + P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z); +# endif +# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z)); +# endif + + object = OBJECT_NONE; + node_addr = traversal_stack[stack_ptr].addr; + node_dist = traversal_stack[stack_ptr].dist; + --stack_ptr; + } +#endif /* FEATURE(BVH_INSTANCING) */ + } while(node_addr != ENTRYPOINT_SENTINEL); + + return (isect->prim != PRIM_NONE); +} + +#undef NODE_INTERSECT +#undef NODE_INTERSECT_ROBUST diff --git a/intern/cycles/kernel/bvh/obvh_volume.h b/intern/cycles/kernel/bvh/obvh_volume.h new file mode 100644 index 00000000000..da9ddbd4f24 --- /dev/null +++ b/intern/cycles/kernel/bvh/obvh_volume.h @@ -0,0 +1,483 @@ +/* + * Copyright 2011-2013 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This is a template BVH traversal function for volumes, where + * various features can be enabled/disabled. This way we can compile optimized + * versions for each case without new features slowing things down. + * + * BVH_INSTANCING: object instancing + * BVH_MOTION: motion blur rendering + * + */ + +#if BVH_FEATURE(BVH_HAIR) +# define NODE_INTERSECT obvh_node_intersect +#else +# define NODE_INTERSECT obvh_aligned_node_intersect +#endif + +ccl_device bool BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg, + const Ray *ray, + Intersection *isect, + const uint visibility) +{ + /* Traversal stack in CUDA thread-local memory. */ + OBVHStackItem traversal_stack[BVH_OSTACK_SIZE]; + traversal_stack[0].addr = ENTRYPOINT_SENTINEL; + + /* Traversal variables in registers. */ + int stack_ptr = 0; + int node_addr = kernel_data.bvh.root; + + /* Ray parameters in registers. */ + float3 P = ray->P; + float3 dir = bvh_clamp_direction(ray->D); + float3 idir = bvh_inverse_direction(dir); + int object = OBJECT_NONE; + +#if BVH_FEATURE(BVH_MOTION) + Transform ob_itfm; +#endif + +#ifndef __KERNEL_SSE41__ + if(!isfinite(P.x)) { + return false; + } +#endif + + isect->t = ray->t; + isect->u = 0.0f; + isect->v = 0.0f; + isect->prim = PRIM_NONE; + isect->object = OBJECT_NONE; + + avxf tnear(0.0f), tfar(ray->t); +#if BVH_FEATURE(BVH_HAIR) + avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +#endif + avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z)); + +#ifdef __KERNEL_AVX2__ + float3 P_idir = P*idir; + avx3f P_idir4(P_idir.x, P_idir.y, P_idir.z); +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + avx3f org4(avxf(P.x), avxf(P.y), avxf(P.z)); +#endif + + /* Offsets to select the side that becomes the lower or upper bound. */ + int near_x, near_y, near_z; + int far_x, far_y, far_z; + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + + /* Traversal loop. */ + do { + do { + /* Traverse internal nodes. */ + while(node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) { + float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr+0); + +#ifdef __VISIBILITY_FLAG__ + if((__float_as_uint(inodes.x) & visibility) == 0) { + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } +#endif + + avxf dist; + int child_mask = NODE_INTERSECT(kg, + tnear, + tfar, +#ifdef __KERNEL_AVX2__ + P_idir4, +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4, +#endif +#if BVH_FEATURE(BVH_HAIR) + dir4, +#endif + idir4, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + &dist); + + if(child_mask != 0) { + avxf cnodes; +#if BVH_FEATURE(BVH_HAIR) + if(__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+26); + } + else +#endif + { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+14); + } + + /* One child is hit, continue with that child. */ + int r = __bscf(child_mask); + if(child_mask == 0) { + node_addr = __float_as_int(cnodes[r]); + continue; + } + + /* Two children are hit, push far child, and continue with + * closer child. + */ + int c0 = __float_as_int(cnodes[r]); + float d0 = ((float*)&dist)[r]; + r = __bscf(child_mask); + int c1 = __float_as_int(cnodes[r]); + float d1 = ((float*)&dist)[r]; + if(child_mask == 0) { + if(d1 < d0) { + node_addr = c1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + continue; + } + else { + node_addr = c0; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + continue; + } + } + + /* Here starts the slow path for 3 or 4 hit children. We push + * all nodes onto the stack to sort them there. + */ + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + + /* Three children are hit, push all onto stack and sort 3 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c2 = __float_as_int(cnodes[r]); + float d2 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Four children are hit, push all onto stack and sort 4 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c3 = __float_as_int(cnodes[r]); + float d3 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + + /* Five children are hit, push all onto stack and sort 5 + * stack items, continue with closest child + */ + r = __bscf(child_mask); + int c4 = __float_as_int(cnodes[r]); + float d4 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Six children are hit, push all onto stack and sort 6 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c5 = __float_as_int(cnodes[r]); + float d5 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + + /* Seven children are hit, push all onto stack and sort 7 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c6 = __float_as_int(cnodes[r]); + float d6 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Eight children are hit, push all onto stack and sort 8 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c7 = __float_as_int(cnodes[r]); + float d7 = ((float*)&dist)[r]; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c7; + traversal_stack[stack_ptr].dist = d7; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6], + &traversal_stack[stack_ptr - 7]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + } + + /* If node is leaf, fetch triangle list. */ + if(node_addr < 0) { + float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr-1)); + + if((__float_as_uint(leaf.z) & visibility) == 0) { + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + int prim_addr = __float_as_int(leaf.x); + +#if BVH_FEATURE(BVH_INSTANCING) + if(prim_addr >= 0) { +#endif + int prim_addr2 = __float_as_int(leaf.y); + const uint type = __float_as_int(leaf.w); + const uint p_type = type & PRIMITIVE_ALL; + + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + + /* Primitive intersection. */ + switch(p_type) { + case PRIMITIVE_TRIANGLE: { + for(; prim_addr < prim_addr2; prim_addr++) { + kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + /* Only primitives from volume object. */ + uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, prim_addr): object; + int object_flag = kernel_tex_fetch(__object_flag, tri_object); + if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) { + continue; + } + /* Intersect ray against primitive. */ + triangle_intersect(kg, isect, P, dir, visibility, object, prim_addr); + } + break; + } +#if BVH_FEATURE(BVH_MOTION) + case PRIMITIVE_MOTION_TRIANGLE: { + for(; prim_addr < prim_addr2; prim_addr++) { + kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + /* Only primitives from volume object. */ + uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, prim_addr): object; + int object_flag = kernel_tex_fetch(__object_flag, tri_object); + if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) { + continue; + } + /* Intersect ray against primitive. */ + motion_triangle_intersect(kg, isect, P, dir, ray->time, visibility, object, prim_addr); + } + break; + } +#endif + } + } +#if BVH_FEATURE(BVH_INSTANCING) + else { + /* Instance push. */ + object = kernel_tex_fetch(__prim_object, -prim_addr-1); + int object_flag = kernel_tex_fetch(__object_flag, object); + if(object_flag & SD_OBJECT_HAS_VOLUME) { +# if BVH_FEATURE(BVH_MOTION) + isect->t = bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, isect->t, &ob_itfm); +# else + isect->t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect->t); +# endif + + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + tfar = avxf(isect->t); +# if BVH_FEATURE(BVH_HAIR) + dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +# endif + idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z)); +# ifdef __KERNEL_AVX2__ + P_idir = P*idir; + P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z); +# endif +# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z)); +# endif + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL; + + node_addr = kernel_tex_fetch(__object_node, object); + } + else { + /* Pop. */ + object = OBJECT_NONE; + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + } + } + } +#endif /* FEATURE(BVH_INSTANCING) */ + } while(node_addr != ENTRYPOINT_SENTINEL); + +#if BVH_FEATURE(BVH_INSTANCING) + if(stack_ptr >= 0) { + kernel_assert(object != OBJECT_NONE); + + /* Instance pop. */ +# if BVH_FEATURE(BVH_MOTION) + isect->t = bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, isect->t, &ob_itfm); +# else + isect->t = bvh_instance_pop(kg, object, ray, &P, &dir, &idir, isect->t); +# endif + + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + tfar = avxf(isect->t); +# if BVH_FEATURE(BVH_HAIR) + dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +# endif + idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z)); +# ifdef __KERNEL_AVX2__ + P_idir = P*idir; + P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z); +# endif +# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z)); +# endif + + object = OBJECT_NONE; + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + } +#endif /* FEATURE(BVH_INSTANCING) */ + } while(node_addr != ENTRYPOINT_SENTINEL); + + return (isect->prim != PRIM_NONE); +} + +#undef NODE_INTERSECT diff --git a/intern/cycles/kernel/bvh/obvh_volume_all.h b/intern/cycles/kernel/bvh/obvh_volume_all.h new file mode 100644 index 00000000000..a88573e6f86 --- /dev/null +++ b/intern/cycles/kernel/bvh/obvh_volume_all.h @@ -0,0 +1,554 @@ +/* + * Copyright 2011-2013 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This is a template BVH traversal function for volumes, where + * various features can be enabled/disabled. This way we can compile optimized + * versions for each case without new features slowing things down. + * + * BVH_INSTANCING: object instancing + * BVH_MOTION: motion blur rendering + * + */ + +#if BVH_FEATURE(BVH_HAIR) +# define NODE_INTERSECT obvh_node_intersect +#else +# define NODE_INTERSECT obvh_aligned_node_intersect +#endif + +ccl_device uint BVH_FUNCTION_FULL_NAME(OBVH)(KernelGlobals *kg, + const Ray *ray, + Intersection *isect_array, + const uint max_hits, + const uint visibility) +{ + /* Traversal stack in CUDA thread-local memory. */ + OBVHStackItem traversal_stack[BVH_OSTACK_SIZE]; + traversal_stack[0].addr = ENTRYPOINT_SENTINEL; + + /* Traversal variables in registers. */ + int stack_ptr = 0; + int node_addr = kernel_data.bvh.root; + + /* Ray parameters in registers. */ + const float tmax = ray->t; + float3 P = ray->P; + float3 dir = bvh_clamp_direction(ray->D); + float3 idir = bvh_inverse_direction(dir); + int object = OBJECT_NONE; + float isect_t = tmax; + +#if BVH_FEATURE(BVH_MOTION) + Transform ob_itfm; +#endif + + uint num_hits = 0; + isect_array->t = tmax; + +#ifndef __KERNEL_SSE41__ + if(!isfinite(P.x)) { + return 0; + } +#endif + +#if BVH_FEATURE(BVH_INSTANCING) + int num_hits_in_instance = 0; +#endif + + avxf tnear(0.0f), tfar(isect_t); +#if BVH_FEATURE(BVH_HAIR) + avx3f dir4(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +#endif + avx3f idir4(avxf(idir.x), avxf(idir.y), avxf(idir.z)); + +#ifdef __KERNEL_AVX2__ + float3 P_idir = P*idir; + avx3f P_idir4(P_idir.x, P_idir.y, P_idir.z); +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + avx3f org4(avxf(P.x), avxf(P.y), avxf(P.z)); +#endif + + /* Offsets to select the side that becomes the lower or upper bound. */ + int near_x, near_y, near_z; + int far_x, far_y, far_z; + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + + /* Traversal loop. */ + do { + do { + /* Traverse internal nodes. */ + while(node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) { + float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr+0); + +#ifdef __VISIBILITY_FLAG__ + if((__float_as_uint(inodes.x) & visibility) == 0) { + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } +#endif + + avxf dist; + int child_mask = NODE_INTERSECT(kg, + tnear, + tfar, +#ifdef __KERNEL_AVX2__ + P_idir4, +#endif +#if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4, +#endif +#if BVH_FEATURE(BVH_HAIR) + dir4, +#endif + idir4, + near_x, near_y, near_z, + far_x, far_y, far_z, + node_addr, + &dist); + + if(child_mask != 0) { + avxf cnodes; +#if BVH_FEATURE(BVH_HAIR) + if(__float_as_uint(inodes.x) & PATH_RAY_NODE_UNALIGNED) { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+26); + } + else +#endif + { + cnodes = kernel_tex_fetch_avxf(__bvh_nodes, node_addr+14); + } + + /* One child is hit, continue with that child. */ + int r = __bscf(child_mask); + if(child_mask == 0) { + node_addr = __float_as_int(cnodes[r]); + continue; + } + + /* Two children are hit, push far child, and continue with + * closer child. + */ + int c0 = __float_as_int(cnodes[r]); + float d0 = ((float*)&dist)[r]; + r = __bscf(child_mask); + int c1 = __float_as_int(cnodes[r]); + float d1 = ((float*)&dist)[r]; + if(child_mask == 0) { + if(d1 < d0) { + node_addr = c1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + continue; + } + else { + node_addr = c0; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + continue; + } + } + + /* Here starts the slow path for 3 or 4 hit children. We push + * all nodes onto the stack to sort them there. + */ + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c1; + traversal_stack[stack_ptr].dist = d1; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c0; + traversal_stack[stack_ptr].dist = d0; + + /* Three children are hit, push all onto stack and sort 3 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c2 = __float_as_int(cnodes[r]); + float d2 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Four children are hit, push all onto stack and sort 4 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c3 = __float_as_int(cnodes[r]); + float d3 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c3; + traversal_stack[stack_ptr].dist = d3; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c2; + traversal_stack[stack_ptr].dist = d2; + + /* Five children are hit, push all onto stack and sort 5 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c4 = __float_as_int(cnodes[r]); + float d4 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Six children are hit, push all onto stack and sort 6 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c5 = __float_as_int(cnodes[r]); + float d5 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c5; + traversal_stack[stack_ptr].dist = d5; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c4; + traversal_stack[stack_ptr].dist = d4; + + /* Seven children are hit, push all onto stack and sort 7 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c6 = __float_as_int(cnodes[r]); + float d6 = ((float*)&dist)[r]; + if(child_mask == 0) { + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + /* Eight children are hit, push all onto stack and sort 8 + * stack items, continue with closest child. + */ + r = __bscf(child_mask); + int c7 = __float_as_int(cnodes[r]); + float d7 = ((float*)&dist)[r]; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c7; + traversal_stack[stack_ptr].dist = d7; + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = c6; + traversal_stack[stack_ptr].dist = d6; + obvh_stack_sort(&traversal_stack[stack_ptr], + &traversal_stack[stack_ptr - 1], + &traversal_stack[stack_ptr - 2], + &traversal_stack[stack_ptr - 3], + &traversal_stack[stack_ptr - 4], + &traversal_stack[stack_ptr - 5], + &traversal_stack[stack_ptr - 6], + &traversal_stack[stack_ptr - 7]); + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + } + + /* If node is leaf, fetch triangle list. */ + if(node_addr < 0) { + float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr-1)); + + if((__float_as_uint(leaf.z) & visibility) == 0) { + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + continue; + } + + int prim_addr = __float_as_int(leaf.x); + +#if BVH_FEATURE(BVH_INSTANCING) + if(prim_addr >= 0) { +#endif + int prim_addr2 = __float_as_int(leaf.y); + const uint type = __float_as_int(leaf.w); + const uint p_type = type & PRIMITIVE_ALL; + bool hit; + + /* Pop. */ + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + + /* Primitive intersection. */ + switch(p_type) { + case PRIMITIVE_TRIANGLE: { + for(; prim_addr < prim_addr2; prim_addr++) { + kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + /* Only primitives from volume object. */ + uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, prim_addr): object; + int object_flag = kernel_tex_fetch(__object_flag, tri_object); + if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) { + continue; + } + /* Intersect ray against primitive. */ + hit = triangle_intersect(kg, isect_array, P, dir, visibility, object, prim_addr); + if(hit) { + /* Move on to next entry in intersections array. */ + isect_array++; + num_hits++; +#if BVH_FEATURE(BVH_INSTANCING) + num_hits_in_instance++; +#endif + isect_array->t = isect_t; + if(num_hits == max_hits) { +#if BVH_FEATURE(BVH_INSTANCING) +# if BVH_FEATURE(BVH_MOTION) + float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir)); +# else + Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + float t_fac = 1.0f / len(transform_direction(&itfm, dir)); +# endif + for(int i = 0; i < num_hits_in_instance; i++) { + (isect_array-i-1)->t *= t_fac; + } +#endif /* BVH_FEATURE(BVH_INSTANCING) */ + return num_hits; + } + } + } + break; + } +#if BVH_FEATURE(BVH_MOTION) + case PRIMITIVE_MOTION_TRIANGLE: { + for(; prim_addr < prim_addr2; prim_addr++) { + kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + /* Only primitives from volume object. */ + uint tri_object = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, prim_addr): object; + int object_flag = kernel_tex_fetch(__object_flag, tri_object); + if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) { + continue; + } + /* Intersect ray against primitive. */ + hit = motion_triangle_intersect(kg, isect_array, P, dir, ray->time, visibility, object, prim_addr); + if(hit) { + /* Move on to next entry in intersections array. */ + isect_array++; + num_hits++; +# if BVH_FEATURE(BVH_INSTANCING) + num_hits_in_instance++; +# endif + isect_array->t = isect_t; + if(num_hits == max_hits) { +# if BVH_FEATURE(BVH_INSTANCING) +# if BVH_FEATURE(BVH_MOTION) + float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir)); +# else + Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + float t_fac = 1.0f / len(transform_direction(&itfm, dir)); +# endif + for(int i = 0; i < num_hits_in_instance; i++) { + (isect_array-i-1)->t *= t_fac; + } +# endif /* BVH_FEATURE(BVH_INSTANCING) */ + return num_hits; + } + } + } + break; + } +#endif + } + } +#if BVH_FEATURE(BVH_INSTANCING) + else { + /* Instance push. */ + object = kernel_tex_fetch(__prim_object, -prim_addr-1); + int object_flag = kernel_tex_fetch(__object_flag, object); + if(object_flag & SD_OBJECT_HAS_VOLUME) { +# if BVH_FEATURE(BVH_MOTION) + isect_t = bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, isect_t, &ob_itfm); +# else + isect_t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect_t); +# endif + + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + tfar = avxf(isect_t); + idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z)); +# if BVH_FEATURE(BVH_HAIR) + dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +# endif +# ifdef __KERNEL_AVX2__ + P_idir = P*idir; + P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z); +# endif +# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z)); +# endif + + num_hits_in_instance = 0; + isect_array->t = isect_t; + + ++stack_ptr; + kernel_assert(stack_ptr < BVH_OSTACK_SIZE); + traversal_stack[stack_ptr].addr = ENTRYPOINT_SENTINEL; + + node_addr = kernel_tex_fetch(__object_node, object); + } + else { + /* Pop. */ + object = OBJECT_NONE; + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + } + } + } +#endif /* FEATURE(BVH_INSTANCING) */ + } while(node_addr != ENTRYPOINT_SENTINEL); + +#if BVH_FEATURE(BVH_INSTANCING) + if(stack_ptr >= 0) { + kernel_assert(object != OBJECT_NONE); + + /* Instance pop. */ + if(num_hits_in_instance) { + float t_fac; +# if BVH_FEATURE(BVH_MOTION) + bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm); +# else + bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac); +# endif + /* Scale isect->t to adjust for instancing. */ + for(int i = 0; i < num_hits_in_instance; i++) { + (isect_array-i-1)->t *= t_fac; + } + } + else { +# if BVH_FEATURE(BVH_MOTION) + bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX, &ob_itfm); +# else + bvh_instance_pop(kg, object, ray, &P, &dir, &idir, FLT_MAX); +# endif + } + + isect_t = tmax; + isect_array->t = isect_t; + + obvh_near_far_idx_calc(idir, + &near_x, &near_y, &near_z, + &far_x, &far_y, &far_z); + tfar = avxf(isect_t); +# if BVH_FEATURE(BVH_HAIR) + dir4 = avx3f(avxf(dir.x), avxf(dir.y), avxf(dir.z)); +# endif + idir4 = avx3f(avxf(idir.x), avxf(idir.y), avxf(idir.z)); +# ifdef __KERNEL_AVX2__ + P_idir = P*idir; + P_idir4 = avx3f(P_idir.x, P_idir.y, P_idir.z); +# endif +# if BVH_FEATURE(BVH_HAIR) || !defined(__KERNEL_AVX2__) + org4 = avx3f(avxf(P.x), avxf(P.y), avxf(P.z)); +# endif + + object = OBJECT_NONE; + node_addr = traversal_stack[stack_ptr].addr; + --stack_ptr; + } +#endif /* FEATURE(BVH_INSTANCING) */ + } while(node_addr != ENTRYPOINT_SENTINEL); + + return num_hits; +} + +#undef NODE_INTERSECT diff --git a/intern/cycles/kernel/bvh/qbvh_nodes.h b/intern/cycles/kernel/bvh/qbvh_nodes.h index 3036efd4198..2e622af1758 100644 --- a/intern/cycles/kernel/bvh/qbvh_nodes.h +++ b/intern/cycles/kernel/bvh/qbvh_nodes.h @@ -85,7 +85,8 @@ ccl_device_inline void qbvh_stack_sort(QBVHStackItem *ccl_restrict s1, /* Axis-aligned nodes intersection */ -ccl_device_inline int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg, +//ccl_device_inline int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg, +static int qbvh_aligned_node_intersect(KernelGlobals *ccl_restrict kg, const ssef& isect_near, const ssef& isect_far, #ifdef __KERNEL_AVX2__ diff --git a/intern/cycles/kernel/closure/bsdf_hair_principled.h b/intern/cycles/kernel/closure/bsdf_hair_principled.h index 4ee58089384..b3b56be39ff 100644 --- a/intern/cycles/kernel/closure/bsdf_hair_principled.h +++ b/intern/cycles/kernel/closure/bsdf_hair_principled.h @@ -120,7 +120,7 @@ ccl_device_inline float bessel_I0(float x) /* Logarithm of the Bessel function of the first kind. */ ccl_device_inline float log_bessel_I0(float x) { - if (x > 12.0f) { + if(x > 12.0f) { /* log(1/x) == -log(x) iff x > 0. * This is only used with positive cosines */ return x + 0.5f * (1.f / (8.0f * x) - M_LN_2PI_F - logf(x)); diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h b/intern/cycles/kernel/geom/geom_triangle_intersect.h index a2b1e050e58..aa6b102a0f3 100644 --- a/intern/cycles/kernel/geom/geom_triangle_intersect.h +++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h @@ -1,4 +1,4 @@ -/* + /* * Copyright 2014, Blender Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -70,7 +70,483 @@ ccl_device_inline bool triangle_intersect(KernelGlobals *kg, return false; } -/* Special ray intersection routines for local intersection. In that case we +#ifdef __KERNEL_AVX2__ + +#define cross256(A,B, C,D) _mm256_fmsub_ps(A,B, _mm256_mul_ps(C,D)) +#if defined(__KERNEL_CUDA__) && __CUDA_ARCH__ < 300 +ccl_device_inline +#else +ccl_device_forceinline +#endif +int ray_triangle_intersect8(KernelGlobals *kg, + float3 ray_P, + float3 ray_dir, + Intersection **isect, + uint visibility, + int object, + __m256 *triA, + __m256 *triB, + __m256 *triC, + int prim_addr, + int prim_num, + uint *num_hits, + uint max_hits, + int *num_hits_in_instance, + float isec_t) +{ + + const unsigned char prim_num_mask = (1 << prim_num) - 1; + + const __m256i zero256 = _mm256_setzero_si256(); + + const __m256 Px256 = _mm256_set1_ps(ray_P.x); + const __m256 Py256 = _mm256_set1_ps(ray_P.y); + const __m256 Pz256 = _mm256_set1_ps(ray_P.z); + + const __m256 dirx256 = _mm256_set1_ps(ray_dir.x); + const __m256 diry256 = _mm256_set1_ps(ray_dir.y); + const __m256 dirz256 = _mm256_set1_ps(ray_dir.z); + + /* Calculate vertices relative to ray origin. */ + /* const float3 v0 = tri_c - P; + const float3 v1 = tri_a - P; + const float3 v2 = tri_b - P; */ + + __m256 v0_x_256 = _mm256_sub_ps(triC[0], Px256); + __m256 v0_y_256 = _mm256_sub_ps(triC[1], Py256); + __m256 v0_z_256 = _mm256_sub_ps(triC[2], Pz256); + + __m256 v1_x_256 = _mm256_sub_ps(triA[0], Px256); + __m256 v1_y_256 = _mm256_sub_ps(triA[1], Py256); + __m256 v1_z_256 = _mm256_sub_ps(triA[2], Pz256); + + __m256 v2_x_256 = _mm256_sub_ps(triB[0], Px256); + __m256 v2_y_256 = _mm256_sub_ps(triB[1], Py256); + __m256 v2_z_256 = _mm256_sub_ps(triB[2], Pz256); + + __m256 v0_v1_x_256 = _mm256_add_ps(v0_x_256, v1_x_256); + __m256 v0_v1_y_256 = _mm256_add_ps(v0_y_256, v1_y_256); + __m256 v0_v1_z_256 = _mm256_add_ps(v0_z_256, v1_z_256); + + __m256 v0_v2_x_256 = _mm256_add_ps(v0_x_256, v2_x_256); + __m256 v0_v2_y_256 = _mm256_add_ps(v0_y_256, v2_y_256); + __m256 v0_v2_z_256 = _mm256_add_ps(v0_z_256, v2_z_256); + + __m256 v1_v2_x_256 = _mm256_add_ps(v1_x_256, v2_x_256); + __m256 v1_v2_y_256 = _mm256_add_ps(v1_y_256, v2_y_256); + __m256 v1_v2_z_256 = _mm256_add_ps(v1_z_256, v2_z_256); + + /* Calculate triangle edges. + const float3 e0 = v2 - v0; + const float3 e1 = v0 - v1; + const float3 e2 = v1 - v2;*/ + + __m256 e0_x_256 = _mm256_sub_ps(v2_x_256, v0_x_256); + __m256 e0_y_256 = _mm256_sub_ps(v2_y_256, v0_y_256); + __m256 e0_z_256 = _mm256_sub_ps(v2_z_256, v0_z_256); + + __m256 e1_x_256 = _mm256_sub_ps(v0_x_256, v1_x_256); + __m256 e1_y_256 = _mm256_sub_ps(v0_y_256, v1_y_256); + __m256 e1_z_256 = _mm256_sub_ps(v0_z_256, v1_z_256); + + __m256 e2_x_256 = _mm256_sub_ps(v1_x_256, v2_x_256); + __m256 e2_y_256 = _mm256_sub_ps(v1_y_256, v2_y_256); + __m256 e2_z_256 = _mm256_sub_ps(v1_z_256, v2_z_256); + + /* Perform edge tests. + const float U = dot(cross(v2 + v0, e0), ray_dir); + const float V = dot(cross(v0 + v1, e1), ray_dir); + const float W = dot(cross(v1 + v2, e2), ray_dir);*/ + + //cross (AyBz - AzBy, AzBx -AxBz, AxBy - AyBx) + __m256 U_x_256 = cross256(v0_v2_y_256, e0_z_256, v0_v2_z_256, e0_y_256); + __m256 U_y_256 = cross256(v0_v2_z_256, e0_x_256, v0_v2_x_256, e0_z_256); + __m256 U_z_256 = cross256(v0_v2_x_256, e0_y_256, v0_v2_y_256, e0_x_256); + //vertical dot + __m256 U_256 = _mm256_mul_ps(U_x_256, dirx256); + U_256 = _mm256_fmadd_ps(U_y_256, diry256, U_256); //_mm256_add_ps(U_256, _mm256_mul_ps(U_y_256, diry256)); + U_256 = _mm256_fmadd_ps(U_z_256, dirz256, U_256); //_mm256_add_ps(U_256, _mm256_mul_ps(U_z_256, dirz256)); + + __m256 V_x_256 = cross256(v0_v1_y_256, e1_z_256, v0_v1_z_256, e1_y_256); + __m256 V_y_256 = cross256(v0_v1_z_256, e1_x_256, v0_v1_x_256, e1_z_256); + __m256 V_z_256 = cross256(v0_v1_x_256, e1_y_256, v0_v1_y_256, e1_x_256); + //vertical dot + __m256 V_256 = _mm256_mul_ps(V_x_256, dirx256); + V_256 = _mm256_fmadd_ps(V_y_256, diry256, V_256);// _mm256_add_ps(V_256, _mm256_mul_ps(V_y_256, diry256)); + V_256 = _mm256_fmadd_ps(V_z_256, dirz256, V_256);// _mm256_add_ps(V_256, _mm256_mul_ps(V_z_256, dirz256)); + + __m256 W_x_256 = cross256(v1_v2_y_256, e2_z_256, v1_v2_z_256, e2_y_256); + __m256 W_y_256 = cross256(v1_v2_z_256, e2_x_256, v1_v2_x_256, e2_z_256); + __m256 W_z_256 = cross256(v1_v2_x_256, e2_y_256, v1_v2_y_256, e2_x_256); + //vertical dot + __m256 W_256 = _mm256_mul_ps(W_x_256, dirx256); + W_256 = _mm256_fmadd_ps(W_y_256, diry256,W_256);//_mm256_add_ps(W_256, _mm256_mul_ps(W_y_256, diry256)); + W_256 = _mm256_fmadd_ps(W_z_256, dirz256,W_256);//_mm256_add_ps(W_256, _mm256_mul_ps(W_z_256, dirz256)); + + //const float minUVW = min(U, min(V, W)); + //const float maxUVW = max(U, max(V, W)); +#if 0 + __m256 minUVW_256 = _mm256_min_ps(U_256, _mm256_min_ps(V_256, W_256)); + __m256 maxUVW_256 = _mm256_max_ps(U_256, _mm256_max_ps(V_256, W_256)); + + //if(minUVW < 0.0f && maxUVW > 0.0f) + __m256i mask_minmaxUVW_256 = _mm256_and_si256( + _mm256_cmpgt_epi32(zero256, _mm256_castps_si256(minUVW_256)), + //_mm256_castps_si256(minUVW_256), + _mm256_cmpgt_epi32(_mm256_castps_si256(maxUVW_256), zero256)); +#else + __m256i U_256_1 = _mm256_srli_epi32(_mm256_castps_si256(U_256), 31); + __m256i V_256_1 = _mm256_srli_epi32(_mm256_castps_si256(V_256), 31); + __m256i W_256_1 = _mm256_srli_epi32(_mm256_castps_si256(W_256), 31); + __m256i UVW_256_1 = _mm256_add_epi32(_mm256_add_epi32(U_256_1, V_256_1), W_256_1); + + const __m256i one256 = _mm256_set1_epi32(1); + const __m256i two256 = _mm256_set1_epi32(2); + + __m256i mask_minmaxUVW_256 = _mm256_or_si256( + _mm256_cmpeq_epi32(one256, UVW_256_1), + _mm256_cmpeq_epi32(two256, UVW_256_1) ); +#endif + + unsigned char mask_minmaxUVW_pos = _mm256_movemask_ps(_mm256_castsi256_ps(mask_minmaxUVW_256)); + if((mask_minmaxUVW_pos & prim_num_mask) == prim_num_mask) { //all bits set + return false; + } + + /* Calculate geometry normal and denominator. */ + // const float3 Ng1 = cross(e1, e0); + //const Vec3vfM Ng1 = stable_triangle_normal(e2,e1,e0); + + __m256 Ng1_x_256 = cross256(e1_y_256, e0_z_256, e1_z_256, e0_y_256); + __m256 Ng1_y_256 = cross256(e1_z_256, e0_x_256, e1_x_256, e0_z_256); + __m256 Ng1_z_256 = cross256(e1_x_256, e0_y_256, e1_y_256, e0_x_256); + + //const float3 Ng = Ng1 + Ng1; + Ng1_x_256 = _mm256_add_ps(Ng1_x_256, Ng1_x_256); + Ng1_y_256 = _mm256_add_ps(Ng1_y_256, Ng1_y_256); + Ng1_z_256 = _mm256_add_ps(Ng1_z_256, Ng1_z_256); + + //const float den = dot3(Ng, dir); + //vertical dot + __m256 den_256 = _mm256_mul_ps(Ng1_x_256, dirx256); + den_256 = _mm256_fmadd_ps(Ng1_y_256, diry256,den_256);//_mm256_add_ps(den_256, _mm256_mul_ps(Ng1_y_256, diry256)); + den_256 = _mm256_fmadd_ps(Ng1_z_256, dirz256,den_256);//_mm256_add_ps(den_256, _mm256_mul_ps(Ng1_z_256, dirz256)); + + // __m256i maskden256 = _mm256_cmpeq_epi32(_mm256_castps_si256(den_256), zero256); + + /* Perform depth test. */ + //const float T = dot3(v0, Ng); + __m256 T_256 = _mm256_mul_ps(Ng1_x_256, v0_x_256); + T_256 = _mm256_fmadd_ps(Ng1_y_256, v0_y_256,T_256);//_mm256_add_ps(T_256, _mm256_mul_ps(Ng1_y_256, v0_y_256)); + T_256 = _mm256_fmadd_ps(Ng1_z_256, v0_z_256,T_256);//_mm256_add_ps(T_256, _mm256_mul_ps(Ng1_z_256, v0_z_256)); + + //const int sign_den = (__float_as_int(den) & 0x80000000); + const __m256i c0x80000000 = _mm256_set1_epi32(0x80000000); + __m256i sign_den_256 = _mm256_and_si256(_mm256_castps_si256(den_256), c0x80000000); + + //const float sign_T = xor_signmask(T, sign_den); + __m256 sign_T_256 = _mm256_castsi256_ps(_mm256_xor_si256(_mm256_castps_si256(T_256), sign_den_256)); + + /*if((sign_T < 0.0f) || mask_minmaxUVW_pos { return false;} */ + unsigned char mask_sign_T = _mm256_movemask_ps(sign_T_256); + if(((mask_minmaxUVW_pos | mask_sign_T) & prim_num_mask) == prim_num_mask) { + return false; + } /**/ + + __m256 xor_signmask_256 = _mm256_castsi256_ps(_mm256_xor_si256(_mm256_castps_si256(den_256), sign_den_256)); + + + ccl_align(32) float den8[8], U8[8], V8[8], T8[8], sign_T8[8], xor_signmask8[8]; + ccl_align(32) unsigned int mask_minmaxUVW8[8]; + + if(visibility == PATH_RAY_SHADOW_OPAQUE){ + __m256i mask_final_256 = _mm256_cmpeq_epi32(mask_minmaxUVW_256, zero256);//~mask_minmaxUVW_256 + + __m256i maskden256 = _mm256_cmpeq_epi32(_mm256_castps_si256(den_256), zero256); + + __m256i mask0 = _mm256_cmpgt_epi32(zero256, _mm256_castps_si256(sign_T_256)); + __m256 rayt_256 = _mm256_set1_ps((*isect)->t); + + __m256i mask1 = _mm256_cmpgt_epi32(_mm256_castps_si256(sign_T_256), + _mm256_castps_si256( + _mm256_mul_ps(_mm256_castsi256_ps(_mm256_xor_si256(_mm256_castps_si256(den_256), sign_den_256)), rayt_256) + ) + ); + /* __m256i mask1 = _mm256_castps_si256(_mm256_cmp_ps(sign_T_256, + _mm256_mul_ps(_mm256_castsi256_ps(_mm256_xor_si256(_mm256_castps_si256(den_256), sign_den_256)), rayt_256), + _CMP_GT_OS + ) );*/ + + mask0 = _mm256_or_si256(mask1, mask0); + //unsigned char mask = _mm256_movemask_ps(_mm256_castsi256_ps(mask0)); + //unsigned char maskden = _mm256_movemask_ps(_mm256_castsi256_ps(maskden256)); + //unsigned char mask_final = ((~mask) & (~maskden) & (~mask_minmaxUVW_pos)); + mask_final_256 = _mm256_andnot_si256(mask0, mask_final_256); //(~mask_minmaxUVW_pos) &(~mask) + mask_final_256 = _mm256_andnot_si256(maskden256, mask_final_256); //(~mask_minmaxUVW_pos) &(~mask) & (~maskden) + + unsigned char mask_final = _mm256_movemask_ps(_mm256_castsi256_ps(mask_final_256)); + if((mask_final & prim_num_mask) == 0) { //all bits NOT set + return false; + } /**/ + + unsigned long i = 0; +#if defined(_MSC_VER) + unsigned char res = _BitScanForward(&i, (unsigned long)mask_final); +#else + i = __builtin_ffs(mask_final)-1; +#endif + + den_256 = _mm256_rcp_ps(den_256); //inv_den + U_256 = _mm256_mul_ps(U_256, den_256); //*inv_den + V_256 = _mm256_mul_ps(V_256, den_256); //*inv_den + T_256 = _mm256_mul_ps(T_256, den_256); //*inv_den + + _mm256_store_ps(U8, U_256); + _mm256_store_ps(V8, V_256); + _mm256_store_ps(T8, T_256); + + + //here we assume (kernel_tex_fetch(__prim_visibility, (prim_addr +i)) & visibility) is always true + + (*isect)->u = U8[i]; + (*isect)->v = V8[i]; + (*isect)->t = T8[i]; + + (*isect)->prim = (prim_addr + i); + (*isect)->object = object; + (*isect)->type = PRIMITIVE_TRIANGLE; + + return true; + } + else { + _mm256_store_ps(den8, den_256); + _mm256_store_ps(U8, U_256); + _mm256_store_ps(V8, V_256); + _mm256_store_ps(T8, T_256); + + _mm256_store_ps(sign_T8, sign_T_256); + _mm256_store_ps(xor_signmask8, xor_signmask_256); + _mm256_store_si256((__m256i*)mask_minmaxUVW8, mask_minmaxUVW_256); + + int ret = false; + + if(visibility == PATH_RAY_SHADOW) { + for(int i = 0; i < prim_num; i++) { + if(!mask_minmaxUVW8[i]) { +#ifdef __VISIBILITY_FLAG__ + if(kernel_tex_fetch(__prim_visibility, (prim_addr + i)) & visibility) +#endif + { + if((sign_T8[i] >= 0.0f) && + (sign_T8[i] <= (*isect)->t * xor_signmask8[i])) + { + if(den8[i]) { + const float inv_den = 1.0f / den8[i]; + + (*isect)->u = U8[i] * inv_den; + (*isect)->v = V8[i] * inv_den; + (*isect)->t = T8[i] * inv_den; + + (*isect)->prim = (prim_addr + i); + (*isect)->object = object; + (*isect)->type = PRIMITIVE_TRIANGLE; + + int prim = kernel_tex_fetch(__prim_index, (*isect)->prim); + int shader = 0; + +#ifdef __HAIR__ + if(kernel_tex_fetch(__prim_type, (*isect)->prim) & PRIMITIVE_ALL_TRIANGLE) +#endif + { + shader = kernel_tex_fetch(__tri_shader, prim); + } +#ifdef __HAIR__ + else { + float4 str = kernel_tex_fetch(__curves, prim); + shader = __float_as_int(str.z); + } +#endif + int flag = kernel_tex_fetch(__shaders, (shader & SHADER_MASK)).flags; + + /* if no transparent shadows, all light is blocked */ + if(!(flag & SD_HAS_TRANSPARENT_SHADOW)) { + return 2; + } + /* if maximum number of hits reached, block all light */ + else if(*num_hits == max_hits) { + return 2; + } + /* move on to next entry in intersections array */ + ret = true; + + (*isect)++; + (*num_hits)++; + + (*num_hits_in_instance)++; + + (*isect)->t = isec_t; + + } //den + } //if sign + } //vis + }//if mask + } //for + } + else { //default case + for(int i = 0; i < prim_num; i++) { + if(!mask_minmaxUVW8[i]) { +#ifdef __VISIBILITY_FLAG__ + if(kernel_tex_fetch(__prim_visibility, (prim_addr + i)) & visibility) +#endif + { + if((sign_T8[i] >= 0.0f) && + (sign_T8[i] <= (*isect)->t * xor_signmask8[i])) + { + if(den8[i]) { + const float inv_den = 1.0f / den8[i]; + + (*isect)->u = U8[i] * inv_den; + (*isect)->v = V8[i] * inv_den; + (*isect)->t = T8[i] * inv_den; + + (*isect)->prim = (prim_addr + i); + (*isect)->object = object; + (*isect)->type = PRIMITIVE_TRIANGLE; + + ret = true; + } //den + } //if sign + } //vis + }//if mask + } //for + } //default + return ret; +}// else PATH_RAY_SHADOW_OPAQUE + +} + +//vz static +ccl_device_inline +int triangle_intersect8(KernelGlobals *kg, + Intersection **isect, + float3 P, + float3 dir, + uint visibility, + int object, + int prim_addr, + int prim_num, + uint *num_hits, + uint max_hits, + int *num_hits_in_instance, + float isec_t) + { + __m128 tri_a[8], tri_b[8], tri_c[8]; + __m256 tritmp[12], tri[12]; + __m256 triA[3], triB[3], triC[3]; + + int i, r; + + uint tri_vindex = kernel_tex_fetch(__prim_tri_index, prim_addr); + for(i = 0; i < prim_num; i++) { + tri_a[i] = *(__m128*)&kg->__prim_tri_verts.data[tri_vindex++]; + tri_b[i] = *(__m128*)&kg->__prim_tri_verts.data[tri_vindex++]; + tri_c[i] = *(__m128*)&kg->__prim_tri_verts.data[tri_vindex++]; + } + //create 9 or 12 placeholders + tri[0] = _mm256_castps128_ps256(tri_a[0]); //_mm256_zextps128_ps256 + tri[1] = _mm256_castps128_ps256(tri_b[0]);//_mm256_zextps128_ps256 + tri[2] = _mm256_castps128_ps256(tri_c[0]);//_mm256_zextps128_ps256 + + tri[3] = _mm256_castps128_ps256(tri_a[1]); //_mm256_zextps128_ps256 + tri[4] = _mm256_castps128_ps256(tri_b[1]);//_mm256_zextps128_ps256 + tri[5] = _mm256_castps128_ps256(tri_c[1]);//_mm256_zextps128_ps256 + + tri[6] = _mm256_castps128_ps256(tri_a[2]); //_mm256_zextps128_ps256 + tri[7] = _mm256_castps128_ps256(tri_b[2]);//_mm256_zextps128_ps256 + tri[8] = _mm256_castps128_ps256(tri_c[2]);//_mm256_zextps128_ps256 + + if(prim_num > 3) { + tri[9] = _mm256_castps128_ps256(tri_a[3]); //_mm256_zextps128_ps256 + tri[10] = _mm256_castps128_ps256(tri_b[3]);//_mm256_zextps128_ps256 + tri[11] = _mm256_castps128_ps256(tri_c[3]);//_mm256_zextps128_ps256 + } + + for(i = 4, r = 0; i < prim_num; i ++, r += 3) { + tri[r] = _mm256_insertf128_ps(tri[r] , tri_a[i], 1); + tri[r + 1] = _mm256_insertf128_ps(tri[r + 1], tri_b[i], 1); + tri[r + 2] = _mm256_insertf128_ps(tri[r + 2], tri_c[i], 1); + } + + //------------------------------------------------ + //0! Xa0 Ya0 Za0 1 Xa4 Ya4 Za4 1 + //1! Xb0 Yb0 Zb0 1 Xb4 Yb4 Zb4 1 + //2! Xc0 Yc0 Zc0 1 Xc4 Yc4 Zc4 1 + + //3! Xa1 Ya1 Za1 1 Xa5 Ya5 Za5 1 + //4! Xb1 Yb1 Zb1 1 Xb5 Yb5 Zb5 1 + //5! Xc1 Yc1 Zc1 1 Xc5 Yc5 Zc5 1 + + //6! Xa2 Ya2 Za2 1 Xa6 Ya6 Za6 1 + //7! Xb2 Yb2 Zb2 1 Xb6 Yb6 Zb6 1 + //8! Xc2 Yc2 Zc2 1 Xc6 Yc6 Zc6 1 + + //9! Xa3 Ya3 Za3 1 Xa7 Ya7 Za7 1 + //10! Xb3 Yb3 Zb3 1 Xb7 Yb7 Zb7 1 + //11! Xc3 Yc3 Zc3 1 Xc7 Yc7 Zc7 1 + + //"transpose" + tritmp[0] = _mm256_unpacklo_ps(tri[0], tri[3]); //0! Xa0 Xa1 Ya0 Ya1 Xa4 Xa5 Ya4 Ya5 + tritmp[1] = _mm256_unpackhi_ps(tri[0], tri[3]); //1! Za0 Za1 1 1 Za4 Za5 1 1 + + tritmp[2] = _mm256_unpacklo_ps(tri[6], tri[9]); //2! Xa2 Xa3 Ya2 Ya3 Xa6 Xa7 Ya6 Ya7 + tritmp[3] = _mm256_unpackhi_ps(tri[6], tri[9]); //3! Za2 Za3 1 1 Za6 Za7 1 1 + + tritmp[4] = _mm256_unpacklo_ps(tri[1], tri[4]); //4! Xb0 Xb1 Yb0 Yb1 Xb4 Xb5 Yb4 Yb5 + tritmp[5] = _mm256_unpackhi_ps(tri[1], tri[4]); //5! Zb0 Zb1 1 1 Zb4 Zb5 1 1 + + tritmp[6] = _mm256_unpacklo_ps(tri[7], tri[10]); //6! Xb2 Xb3 Yb2 Yb3 Xb6 Xb7 Yb6 Yb7 + tritmp[7] = _mm256_unpackhi_ps(tri[7], tri[10]); //7! Zb2 Zb3 1 1 Zb6 Zb7 1 1 + + tritmp[8] = _mm256_unpacklo_ps(tri[2], tri[5]); //8! Xc0 Xc1 Yc0 Yc1 Xc4 Xc5 Yc4 Yc5 + tritmp[9] = _mm256_unpackhi_ps(tri[2], tri[5]); //9! Zc0 Zc1 1 1 Zc4 Zc5 1 1 + + tritmp[10] = _mm256_unpacklo_ps(tri[8], tri[11]); //10! Xc2 Xc3 Yc2 Yc3 Xc6 Xc7 Yc6 Yc7 + tritmp[11] = _mm256_unpackhi_ps(tri[8], tri[11]); //11! Zc2 Zc3 1 1 Zc6 Zc7 1 1 + + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + triA[0] = _mm256_castpd_ps(_mm256_unpacklo_pd(_mm256_castps_pd(tritmp[0]), _mm256_castps_pd(tritmp[2]))); // Xa0 Xa1 Xa2 Xa3 Xa4 Xa5 Xa6 Xa7 + triA[1] = _mm256_castpd_ps(_mm256_unpackhi_pd(_mm256_castps_pd(tritmp[0]), _mm256_castps_pd(tritmp[2]))); // Ya0 Ya1 Ya2 Ya3 Ya4 Ya5 Ya6 Ya7 + triA[2] = _mm256_castpd_ps(_mm256_unpacklo_pd(_mm256_castps_pd(tritmp[1]), _mm256_castps_pd(tritmp[3]))); // Za0 Za1 Za2 Za3 Za4 Za5 Za6 Za7 + + triB[0] = _mm256_castpd_ps(_mm256_unpacklo_pd(_mm256_castps_pd(tritmp[4]), _mm256_castps_pd(tritmp[6]))); // Xb0 Xb1 Xb2 Xb3 Xb4 Xb5 Xb5 Xb7 + triB[1] = _mm256_castpd_ps(_mm256_unpackhi_pd(_mm256_castps_pd(tritmp[4]), _mm256_castps_pd(tritmp[6]))); // Yb0 Yb1 Yb2 Yb3 Yb4 Yb5 Yb5 Yb7 + triB[2] = _mm256_castpd_ps(_mm256_unpacklo_pd(_mm256_castps_pd(tritmp[5]), _mm256_castps_pd(tritmp[7]))); // Zb0 Zb1 Zb2 Zb3 Zb4 Zb5 Zb5 Zb7 + + triC[0] = _mm256_castpd_ps(_mm256_unpacklo_pd(_mm256_castps_pd(tritmp[8]), _mm256_castps_pd(tritmp[10]))); //Xc0 Xc1 Xc2 Xc3 Xc4 Xc5 Xc6 Xc7 + triC[1] = _mm256_castpd_ps(_mm256_unpackhi_pd(_mm256_castps_pd(tritmp[8]), _mm256_castps_pd(tritmp[10]))); //Yc0 Yc1 Yc2 Yc3 Yc4 Yc5 Yc6 Yc7 + triC[2] = _mm256_castpd_ps(_mm256_unpacklo_pd(_mm256_castps_pd(tritmp[9]), _mm256_castps_pd(tritmp[11]))); //Zc0 Zc1 Zc2 Zc3 Zc4 Zc5 Zc6 Zc7 + + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + + int result = ray_triangle_intersect8(kg, P, + dir, + isect, + visibility, object, + triA, + triB, + triC, + prim_addr, + prim_num, + num_hits, + max_hits, + num_hits_in_instance, + isec_t); + return result; +} + +#endif /* __KERNEL_AVX2__ */ + +/* Special ray intersection routines for subsurface scattering. In that case we * only want to intersect with primitives in the same object, and if case of * multiple hits we pick a single random primitive as the intersection point. * Returns whether traversal should be stopped. @@ -83,7 +559,7 @@ ccl_device_inline bool triangle_intersect_local( float3 P, float3 dir, int object, - int local_object, + int local_object, int prim_addr, float tmax, uint *lcg_state, diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h index 2f955741797..aa7a16afa1d 100644 --- a/intern/cycles/kernel/kernel_compat_cpu.h +++ b/intern/cycles/kernel/kernel_compat_cpu.h @@ -71,15 +71,13 @@ CCL_NAMESPACE_BEGIN /* Texture types to be compatible with CUDA textures. These are really just * simple arrays and after inlining fetch hopefully revert to being a simple * pointer lookup. */ - template<typename T> struct texture { ccl_always_inline const T& fetch(int index) { kernel_assert(index >= 0 && index < width); return data[index]; } - -#ifdef __KERNEL_AVX__ +#if defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__) /* Reads 256 bytes but indexes in blocks of 128 bytes to maintain * compatibility with existing indicies and data structures. */ @@ -90,7 +88,6 @@ template<typename T> struct texture { ssef *ssef_node_data = &ssef_data[index]; return _mm256_loadu_ps((float *)ssef_node_data); } - #endif #ifdef __KERNEL_SSE2__ @@ -148,6 +145,10 @@ ccl_device_inline void print_sse3i(const char *label, sse3i& a) print_ssei(label, a.z); } +#if defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__) +typedef vector3<avxf> avx3f; +#endif + #endif CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h index b13fabde268..e85050df4bb 100644 --- a/intern/cycles/kernel/kernel_path_state.h +++ b/intern/cycles/kernel/kernel_path_state.h @@ -170,7 +170,7 @@ ccl_device_inline bool path_state_volume_next(KernelGlobals *kg, ccl_addr_space /* For volume bounding meshes we pass through without counting transparent * bounces, only sanity check in case self intersection gets us stuck. */ state->volume_bounds_bounce++; - if (state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) { + if(state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) { return false; } diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index b83460b3ffb..e834b701f96 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -1010,7 +1010,7 @@ ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, DiffuseBsdf *bsdf = (DiffuseBsdf*)bsdf_alloc(sd, sizeof(DiffuseBsdf), make_float3(0.8f, 0.8f, 0.8f)); - if (bsdf != NULL) { + if(bsdf != NULL) { bsdf->N = sd->N; sd->flag |= bsdf_diffuse_setup(bsdf); } diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 85548484873..e93100a6442 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -454,6 +454,7 @@ typedef enum DenoisingPassOffsets { DENOISING_PASS_SHADOW_B = 17, DENOISING_PASS_COLOR = 20, DENOISING_PASS_COLOR_VAR = 23, + DENOISING_PASS_CLEAN = 26, DENOISING_PASS_SIZE_BASE = 26, DENOISING_PASS_SIZE_CLEAN = 3, @@ -1383,8 +1384,9 @@ typedef enum KernelBVHLayout { BVH_LAYOUT_BVH2 = (1 << 0), BVH_LAYOUT_BVH4 = (1 << 1), + BVH_LAYOUT_BVH8 = (1 << 2), - BVH_LAYOUT_DEFAULT = BVH_LAYOUT_BVH4, + BVH_LAYOUT_DEFAULT = BVH_LAYOUT_BVH8, BVH_LAYOUT_ALL = (unsigned int)(-1), } KernelBVHLayout; diff --git a/intern/cycles/kernel/osl/osl_bssrdf.cpp b/intern/cycles/kernel/osl/osl_bssrdf.cpp index 2ebfd5f0c2f..66ec8a996ca 100644 --- a/intern/cycles/kernel/osl/osl_bssrdf.cpp +++ b/intern/cycles/kernel/osl/osl_bssrdf.cpp @@ -69,22 +69,22 @@ public: void setup(ShaderData *sd, int path_flag, float3 weight) { - if (method == u_cubic) { + if(method == u_cubic) { alloc(sd, path_flag, weight, CLOSURE_BSSRDF_CUBIC_ID); } - else if (method == u_gaussian) { + else if(method == u_gaussian) { alloc(sd, path_flag, weight, CLOSURE_BSSRDF_GAUSSIAN_ID); } - else if (method == u_burley) { + else if(method == u_burley) { alloc(sd, path_flag, weight, CLOSURE_BSSRDF_BURLEY_ID); } - else if (method == u_principled) { + else if(method == u_principled) { alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_ID); } - else if (method == u_random_walk) { + else if(method == u_random_walk) { alloc(sd, path_flag, weight, CLOSURE_BSSRDF_RANDOM_WALK_ID); } - else if (method == u_principled_random_walk) { + else if(method == u_principled_random_walk) { alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_RANDOM_WALK_ID); } } diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp index 8c7ae30725c..169351d5ad9 100644 --- a/intern/cycles/kernel/osl/osl_closures.cpp +++ b/intern/cycles/kernel/osl/osl_closures.cpp @@ -200,11 +200,9 @@ public: void setup(ShaderData *sd, int path_flag, float3 weight) { - if(!skip(sd, path_flag, LABEL_GLOSSY)) - { + if(!skip(sd, path_flag, LABEL_GLOSSY)) { PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)alloc(sd, path_flag, weight); - if (!bsdf) - { + if(!bsdf) { return; } diff --git a/intern/cycles/kernel/svm/svm_ao.h b/intern/cycles/kernel/svm/svm_ao.h index d2d36cefd50..0337c88a543 100644 --- a/intern/cycles/kernel/svm/svm_ao.h +++ b/intern/cycles/kernel/svm/svm_ao.h @@ -98,11 +98,11 @@ ccl_device void svm_node_ao(KernelGlobals *kg, float3 normal = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N; float ao = svm_ao(kg, sd, normal, state, dist, samples, flags); - if (stack_valid(out_ao_offset)) { + if(stack_valid(out_ao_offset)) { stack_store_float(stack, out_ao_offset, ao); } - if (stack_valid(out_color_offset)) { + if(stack_valid(out_color_offset)) { float3 color = stack_load_float3(stack, color_offset); stack_store_float3(stack, out_color_offset, ao * color); } diff --git a/intern/cycles/kernel/svm/svm_bevel.h b/intern/cycles/kernel/svm/svm_bevel.h index 19cdb71c20f..79d0fb6ddbe 100644 --- a/intern/cycles/kernel/svm/svm_bevel.h +++ b/intern/cycles/kernel/svm/svm_bevel.h @@ -148,11 +148,11 @@ ccl_device_noinline float3 svm_bevel( int prim = kernel_tex_fetch(__prim_index, isect.hits[hit].prim); int shader = kernel_tex_fetch(__tri_shader, prim); - if (shader & SHADER_SMOOTH_NORMAL) { + if(shader & SHADER_SMOOTH_NORMAL) { float u = isect.hits[hit].u; float v = isect.hits[hit].v; - if (sd->type & PRIMITIVE_TRIANGLE) { + if(sd->type & PRIMITIVE_TRIANGLE) { N = triangle_smooth_normal(kg, N, prim, u, v); } #ifdef __OBJECT_MOTION__ diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h index aa253223c93..cce0e0eefe0 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -757,7 +757,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * const AttributeDescriptor attr_descr_random = find_attribute(kg, sd, data_node4.y); float random = 0.0f; - if (attr_descr_random.offset != ATTR_STD_NOT_FOUND) { + if(attr_descr_random.offset != ATTR_STD_NOT_FOUND) { random = primitive_attribute_float(kg, sd, attr_descr_random, NULL, NULL); } else { @@ -769,7 +769,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * if(bsdf) { PrincipledHairExtra *extra = (PrincipledHairExtra*)closure_alloc_extra(sd, sizeof(PrincipledHairExtra)); - if (!extra) + if(!extra) break; /* Random factors range: [-randomization/2, +randomization/2]. */ diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h index d3490ab284f..669b174e4a3 100644 --- a/intern/cycles/kernel/svm/svm_math_util.h +++ b/intern/cycles/kernel/svm/svm_math_util.h @@ -94,13 +94,13 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2) Fac = fabsf(Fac1); else if(type == NODE_MATH_ARCTAN2) Fac = atan2f(Fac1, Fac2); - else if (type == NODE_MATH_FLOOR) + else if(type == NODE_MATH_FLOOR) Fac = floorf(Fac1); - else if (type == NODE_MATH_CEIL) + else if(type == NODE_MATH_CEIL) Fac = ceilf(Fac1); - else if (type == NODE_MATH_FRACT) + else if(type == NODE_MATH_FRACT) Fac = Fac1 - floorf(Fac1); - else if (type == NODE_MATH_SQRT) + else if(type == NODE_MATH_SQRT) Fac = safe_sqrtf(Fac1); else if(type == NODE_MATH_CLAMP) Fac = saturate(Fac1); diff --git a/intern/cycles/kernel/svm/svm_voronoi.h b/intern/cycles/kernel/svm/svm_voronoi.h index 75af910d940..d661df54ead 100644 --- a/intern/cycles/kernel/svm/svm_voronoi.h +++ b/intern/cycles/kernel/svm/svm_voronoi.h @@ -32,6 +32,11 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance, da[2] = 1e10f; da[3] = 1e10f; + pa[0] = make_float3(0.0f, 0.0f, 0.0f); + pa[1] = make_float3(0.0f, 0.0f, 0.0f); + pa[2] = make_float3(0.0f, 0.0f, 0.0f); + pa[3] = make_float3(0.0f, 0.0f, 0.0f); + int3 xyzi = quick_floor_to_int3(p); for(int xx = -1; xx <= 1; xx++) { @@ -65,7 +70,7 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance, } /* To keep the shortest four distances and associated points we have to keep them in sorted order. */ - if (d < da[0]) { + if(d < da[0]) { da[3] = da[2]; da[2] = da[1]; da[1] = da[0]; @@ -76,7 +81,7 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance, pa[1] = pa[0]; pa[0] = vp; } - else if (d < da[1]) { + else if(d < da[1]) { da[3] = da[2]; da[2] = da[1]; da[1] = d; @@ -85,14 +90,14 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance, pa[2] = pa[1]; pa[1] = vp; } - else if (d < da[2]) { + else if(d < da[2]) { da[3] = da[2]; da[2] = d; pa[3] = pa[2]; pa[2] = vp; } - else if (d < da[3]) { + else if(d < da[3]) { da[3] = d; pa[3] = vp; } diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index a258b465fa2..de2b38340e9 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -160,7 +160,7 @@ bool RenderBuffers::get_denoising_pass_rect(int offset, float exposure, int samp (offset == DENOISING_PASS_DEPTH_VAR) || (offset == DENOISING_PASS_COLOR_VAR); - if(offset == DENOISING_PASS_COLOR) { + if(offset == DENOISING_PASS_COLOR || offset == DENOISING_PASS_CLEAN) { scale *= exposure; } else if(offset == DENOISING_PASS_COLOR_VAR) { diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 3a9e2981418..eea1bed58dc 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -245,7 +245,7 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to) ShaderNode *convert; ShaderInput *convert_in; - if (to->type() == SocketType::CLOSURE) { + if(to->type() == SocketType::CLOSURE) { EmissionNode *emission = new EmissionNode(); emission->color = make_float3(1.0f, 1.0f, 1.0f); emission->strength = 1.0f; diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 49cfae4888b..a5854f022cd 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -549,7 +549,7 @@ void LightManager::device_update_background(Device *device, /* get the resolution from the light's size (we stuff it in there) */ int2 res = make_int2(background_light->map_resolution, background_light->map_resolution/2); /* If the resolution isn't set manually, try to find an environment texture. */ - if (res.x == 0) { + if(res.x == 0) { Shader *shader = (scene->background->shader) ? scene->background->shader : scene->default_background; foreach(ShaderNode *node, shader->graph->nodes) { if(node->type == EnvironmentTextureNode::node_type) { @@ -561,12 +561,12 @@ void LightManager::device_update_background(Device *device, } } } - if (res.x > 0 && res.y > 0) { + if(res.x > 0 && res.y > 0) { VLOG(2) << "Automatically set World MIS resolution to " << res.x << " by " << res.y << "\n"; } } /* If it's still unknown, just use the default. */ - if (res.x == 0 || res.y == 0) { + if(res.x == 0 || res.y == 0) { res = make_int2(1024, 512); VLOG(2) << "Setting World MIS resolution to default\n"; } diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index cce851612db..06a2baa8a38 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -951,9 +951,9 @@ void VoronoiTextureNode::compile(SVMCompiler& compiler) ShaderOutput *color_out = output("Color"); ShaderOutput *fac_out = output("Fac"); - if (vector_in->link) compiler.stack_assign(vector_in); - if (scale_in->link) compiler.stack_assign(scale_in); - if (exponent_in->link) compiler.stack_assign(exponent_in); + if(vector_in->link) compiler.stack_assign(vector_in); + if(scale_in->link) compiler.stack_assign(scale_in); + if(exponent_in->link) compiler.stack_assign(exponent_in); int vector_offset = tex_mapping.compile_begin(compiler, vector_in); @@ -2853,7 +2853,7 @@ void AmbientOcclusionNode::compile(SVMCompiler& compiler) int flags = (inside? NODE_AO_INSIDE : 0) | (only_local? NODE_AO_ONLY_LOCAL : 0); - if (!distance_in->link && distance == 0.0f) { + if(!distance_in->link && distance == 0.0f) { flags |= NODE_AO_GLOBAL_RADIUS; } diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index fdd872f62b9..496e9d9491a 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -66,6 +66,14 @@ OSLShaderManager::~OSLShaderManager() { shading_system_free(); texture_system_free(); +#ifdef OSL_HAS_BLENDER_CLEANUP_FIX + /* There is a problem with llvm+osl: The order global destructors across + * different compilation units run cannot be guaranteed, on windows this means + * that the llvm destructors run before the osl destructors, causing a crash + * when the process exits. the OSL in svn has a special cleanup hack to + * sidestep this behavior */ + OSL::pvt::LLVM_Util::Cleanup(); +#endif } void OSLShaderManager::reset(Scene * /*scene*/) diff --git a/intern/cycles/render/osl.h b/intern/cycles/render/osl.h index 09d1a54d0b9..966fc1965d7 100644 --- a/intern/cycles/render/osl.h +++ b/intern/cycles/render/osl.h @@ -26,6 +26,7 @@ #include "render/shader.h" #ifdef WITH_OSL +#include <OSL/llvm_util.h> #include <OSL/oslcomp.h> #include <OSL/oslexec.h> #include <OSL/oslquery.h> diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt index 508f44e7c4d..291f9a9fcae 100644 --- a/intern/cycles/util/CMakeLists.txt +++ b/intern/cycles/util/CMakeLists.txt @@ -78,6 +78,7 @@ set(SRC_HEADERS util_sky_model.h util_sky_model_data.h util_avxf.h + util_avxb.h util_sseb.h util_ssef.h util_ssei.h @@ -98,7 +99,9 @@ set(SRC_HEADERS util_types_float3_impl.h util_types_float4.h util_types_float4_impl.h - util_types_int2.h + util_types_float8.h + util_types_float8_impl.h + util_types_int2.h util_types_int2_impl.h util_types_int3.h util_types_int3_impl.h diff --git a/intern/cycles/util/util_avxb.h b/intern/cycles/util/util_avxb.h new file mode 100644 index 00000000000..60d9bb44256 --- /dev/null +++ b/intern/cycles/util/util_avxb.h @@ -0,0 +1,191 @@ +/* + * Copyright 2011-2013 Intel Corporation + * Modifications Copyright 2014, Blender Foundation. + * + * Licensed under the Apache License, Version 2.0(the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __UTIL_AVXB_H__ +#define __UTIL_AVXB_H__ + +CCL_NAMESPACE_BEGIN + +struct avxf; + +/*! 4-wide SSE bool type. */ +struct avxb +{ + typedef avxb Mask; // mask type + typedef avxf Float; // float type + + enum { size = 8 }; // number of SIMD elements + union { __m256 m256; int32_t v[8]; }; // data + + //////////////////////////////////////////////////////////////////////////////// + /// Constructors, Assignment & Cast Operators + //////////////////////////////////////////////////////////////////////////////// + + __forceinline avxb ( ) {} + __forceinline avxb ( const avxb& other ) { m256 = other.m256; } + __forceinline avxb& operator=( const avxb& other ) { m256 = other.m256; return *this; } + + __forceinline avxb( const __m256 input ) : m256(input) {} + __forceinline operator const __m256&( void ) const { return m256; } + __forceinline operator const __m256i( void ) const { return _mm256_castps_si256(m256); } + __forceinline operator const __m256d( void ) const { return _mm256_castps_pd(m256); } + + //__forceinline avxb ( bool a ) + // : m256(_mm_lookupmask_ps[(size_t(a) << 3) | (size_t(a) << 2) | (size_t(a) << 1) | size_t(a)]) {} + //__forceinline avxb ( bool a, bool b) + // : m256(_mm_lookupmask_ps[(size_t(b) << 3) | (size_t(a) << 2) | (size_t(b) << 1) | size_t(a)]) {} + //__forceinline avxb ( bool a, bool b, bool c, bool d) + // : m256(_mm_lookupmask_ps[(size_t(d) << 3) | (size_t(c) << 2) | (size_t(b) << 1) | size_t(a)]) {} + //__forceinline avxb(int mask) { + // assert(mask >= 0 && mask < 16); + // m128 = _mm_lookupmask_ps[mask]; + //} + + //////////////////////////////////////////////////////////////////////////////// + /// Constants + //////////////////////////////////////////////////////////////////////////////// + + __forceinline avxb( FalseTy ) : m256(_mm256_setzero_ps()) {} + __forceinline avxb( TrueTy ) : m256(_mm256_castsi256_ps(_mm256_cmpeq_epi32(_mm256_setzero_si256(), _mm256_setzero_si256()))) {} + + //////////////////////////////////////////////////////////////////////////////// + /// Array Access + //////////////////////////////////////////////////////////////////////////////// + + __forceinline bool operator []( const size_t i ) const { assert(i < 8); return (_mm256_movemask_ps(m256) >> i) & 1; } + __forceinline int32_t& operator []( const size_t i ) { assert(i < 8); return v[i]; } +}; + +//////////////////////////////////////////////////////////////////////////////// +/// Unary Operators +//////////////////////////////////////////////////////////////////////////////// + +__forceinline const avxb operator !( const avxb& a ) { return _mm256_xor_ps(a, avxb(True)); } + +//////////////////////////////////////////////////////////////////////////////// +/// Binary Operators +//////////////////////////////////////////////////////////////////////////////// + +__forceinline const avxb operator &( const avxb& a, const avxb& b ) { return _mm256_and_ps(a, b); } +__forceinline const avxb operator |( const avxb& a, const avxb& b ) { return _mm256_or_ps (a, b); } +__forceinline const avxb operator ^( const avxb& a, const avxb& b ) { return _mm256_xor_ps(a, b); } + +//////////////////////////////////////////////////////////////////////////////// +/// Assignment Operators +//////////////////////////////////////////////////////////////////////////////// + +__forceinline const avxb operator &=( avxb& a, const avxb& b ) { return a = a & b; } +__forceinline const avxb operator |=( avxb& a, const avxb& b ) { return a = a | b; } +__forceinline const avxb operator ^=( avxb& a, const avxb& b ) { return a = a ^ b; } + +//////////////////////////////////////////////////////////////////////////////// +/// Comparison Operators + Select +//////////////////////////////////////////////////////////////////////////////// + +__forceinline const avxb operator !=( const avxb& a, const avxb& b ) { return _mm256_xor_ps(a, b); } +__forceinline const avxb operator ==( const avxb& a, const avxb& b ) { return _mm256_castsi256_ps(_mm256_cmpeq_epi32(a, b)); } + +__forceinline const avxb select( const avxb& m, const avxb& t, const avxb& f ) { +#if defined(__KERNEL_SSE41__) + return _mm256_blendv_ps(f, t, m); +#else + return _mm256_or_ps(_mm256_and_ps(m, t), _mm256_andnot_ps(m, f)); +#endif +} + +//////////////////////////////////////////////////////////////////////////////// +/// Movement/Shifting/Shuffling Functions +//////////////////////////////////////////////////////////////////////////////// + +__forceinline const avxb unpacklo( const avxb& a, const avxb& b ) { return _mm256_unpacklo_ps(a, b); } +__forceinline const avxb unpackhi( const avxb& a, const avxb& b ) { return _mm256_unpackhi_ps(a, b); } + +#define _MM256_SHUFFLE(fp7,fp6,fp5,fp4,fp3,fp2,fp1,fp0) (((fp7) << 14) | ((fp6) << 12) | ((fp5) << 10) | ((fp4) << 8) | \ + ((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | ((fp0))) + +template<size_t i0, size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, size_t i6, size_t i7> +__forceinline const avxb shuffle( const avxb& a ) { + return _mm256_cvtepi32_ps(_mm256_shuffle_epi32(a, _MM256_SHUFFLE(i7, i6, i5, i4, i3, i2, i1, i0))); +} + +/* +template<> __forceinline const avxb shuffle<0, 1, 0, 1, 0, 1, 0, 1>( const avxb& a ) { + return _mm_movelh_ps(a, a); +} + +template<> __forceinline const sseb shuffle<2, 3, 2, 3>( const sseb& a ) { + return _mm_movehl_ps(a, a); +} + +template<size_t i0, size_t i1, size_t i2, size_t i3> __forceinline const sseb shuffle( const sseb& a, const sseb& b ) { + return _mm_shuffle_ps(a, b, _MM_SHUFFLE(i3, i2, i1, i0)); +} + +template<> __forceinline const sseb shuffle<0, 1, 0, 1>( const sseb& a, const sseb& b ) { + return _mm_movelh_ps(a, b); +} + +template<> __forceinline const sseb shuffle<2, 3, 2, 3>( const sseb& a, const sseb& b ) { + return _mm_movehl_ps(b, a); +} + +#if defined(__KERNEL_SSE3__) +template<> __forceinline const sseb shuffle<0, 0, 2, 2>( const sseb& a ) { return _mm_moveldup_ps(a); } +template<> __forceinline const sseb shuffle<1, 1, 3, 3>( const sseb& a ) { return _mm_movehdup_ps(a); } +#endif + +#if defined(__KERNEL_SSE41__) +template<size_t dst, size_t src, size_t clr> __forceinline const sseb insert( const sseb& a, const sseb& b ) { return _mm_insert_ps(a, b, (dst << 4) | (src << 6) | clr); } +template<size_t dst, size_t src> __forceinline const sseb insert( const sseb& a, const sseb& b ) { return insert<dst, src, 0>(a, b); } +template<size_t dst> __forceinline const sseb insert( const sseb& a, const bool b ) { return insert<dst,0>(a, sseb(b)); } +#endif +*/ + +//////////////////////////////////////////////////////////////////////////////// +/// Reduction Operations +//////////////////////////////////////////////////////////////////////////////// + +#if defined(__KERNEL_SSE41__) +__forceinline size_t popcnt( const avxb& a ) { return __popcnt(_mm256_movemask_ps(a)); } +#else +__forceinline size_t popcnt( const avxb& a ) { return bool(a[0])+bool(a[1])+bool(a[2])+bool(a[3])+bool(a[4])+ + bool(a[5])+bool(a[6])+bool(a[7]); } +#endif + +__forceinline bool reduce_and( const avxb& a ) { return _mm256_movemask_ps(a) == 0xf; } +__forceinline bool reduce_or ( const avxb& a ) { return _mm256_movemask_ps(a) != 0x0; } +__forceinline bool all ( const avxb& b ) { return _mm256_movemask_ps(b) == 0xf; } +__forceinline bool any ( const avxb& b ) { return _mm256_movemask_ps(b) != 0x0; } +__forceinline bool none ( const avxb& b ) { return _mm256_movemask_ps(b) == 0x0; } + +__forceinline size_t movemask( const avxb& a ) { return _mm256_movemask_ps(a); } + +//////////////////////////////////////////////////////////////////////////////// +/// Debug Functions +//////////////////////////////////////////////////////////////////////////////// + +ccl_device_inline void print_avxb(const char *label, const avxb &a) +{ + printf("%s: %df %df %df %df %df %df %df %d\n", + label, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); +} + +#endif + +CCL_NAMESPACE_END + +//#endif diff --git a/intern/cycles/util/util_avxf.h b/intern/cycles/util/util_avxf.h index 2451213963a..5596702ca20 100644 --- a/intern/cycles/util/util_avxf.h +++ b/intern/cycles/util/util_avxf.h @@ -19,7 +19,8 @@ CCL_NAMESPACE_BEGIN -#ifdef __KERNEL_AVX__ +struct avxb; + struct avxf { typedef avxf Float; @@ -53,6 +54,9 @@ struct avxf __forceinline avxf(float a7, float a6, float a5, float a4, float a3, float a2, float a1, float a0) : m256(_mm256_set_ps(a7, a6, a5, a4, a3, a2, a1, a0)) {} + __forceinline avxf(float3 a) : + m256(_mm256_set_ps(a.w, a.z, a.y, a.x, a.w, a.z, a.y, a.x)) {} + __forceinline avxf(int a3, int a2, int a1, int a0) { @@ -73,8 +77,24 @@ struct avxf m256 = _mm256_insertf128_ps(foo, b, 1); } + __forceinline const float& operator [](const size_t i) const { assert(i < 8); return f[i]; } + __forceinline float& operator [](const size_t i) { assert(i < 8); return f[i]; } }; +__forceinline avxf cross(const avxf& a, const avxf& b) +{ + avxf r(0.0, a[4]*b[5] - a[5]*b[4], a[6]*b[4] - a[4]*b[6], a[5]*b[6] - a[6]*b[5], + 0.0, a[0]*b[1] - a[1]*b[0], a[2]*b[0] - a[0]*b[2], a[1]*b[2] - a[2]*b[1]); + return r; +} + +__forceinline void dot3(const avxf& a, const avxf& b, float &den, float &den2) +{ + const avxf t = _mm256_mul_ps(a.m256, b.m256); + den = ((float*)&t)[0] + ((float*)&t)[1] + ((float*)&t)[2]; + den2 = ((float*)&t)[4] + ((float*)&t)[5] + ((float*)&t)[6]; +} + //////////////////////////////////////////////////////////////////////////////// /// Unary Operators //////////////////////////////////////////////////////////////////////////////// @@ -107,6 +127,9 @@ __forceinline const avxf operator^(const avxf& a, const avxf& b) { return _mm256 __forceinline const avxf operator&(const avxf& a, const avxf& b) { return _mm256_and_ps(a.m256,b.m256); } +__forceinline const avxf max(const avxf& a, const avxf& b) { return _mm256_max_ps(a.m256, b.m256); } +__forceinline const avxf min(const avxf& a, const avxf& b) { return _mm256_min_ps(a.m256, b.m256); } + //////////////////////////////////////////////////////////////////////////////// /// Movement/Shifting/Shuffling Functions //////////////////////////////////////////////////////////////////////////////// @@ -160,6 +183,18 @@ ccl_device_inline const avxf blend(const avxf &a, const avxf &b) return blend<S0,S1,S2,S3,S0,S1,S2,S3>(a,b); } +//#if defined(__KERNEL_SSE41__) +__forceinline avxf maxi(const avxf& a, const avxf& b) { + const avxf ci = _mm256_max_ps(a, b); + return ci; +} + +__forceinline avxf mini(const avxf& a, const avxf& b) { + const avxf ci = _mm256_min_ps(a, b); + return ci; +} +//#endif + //////////////////////////////////////////////////////////////////////////////// /// Ternary Operators //////////////////////////////////////////////////////////////////////////////// @@ -178,6 +213,19 @@ __forceinline const avxf nmadd(const avxf& a, const avxf& b, const avxf& c) { return c-(a*b); #endif } +__forceinline const avxf msub(const avxf& a, const avxf& b, const avxf& c) { + return _mm256_fmsub_ps(a, b, c); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Comparison Operators +//////////////////////////////////////////////////////////////////////////////// +#ifdef __KERNEL_AVX2__ +__forceinline const avxb operator <=(const avxf& a, const avxf& b) { + return _mm256_cmp_ps(a.m256, b.m256, _CMP_LE_OS); +} +#endif + #endif #ifndef _mm256_set_m128 @@ -189,5 +237,3 @@ __forceinline const avxf nmadd(const avxf& a, const avxf& b, const avxf& c) { _mm256_set_m128(_mm_loadu_ps(hiaddr), _mm_loadu_ps(loaddr)) CCL_NAMESPACE_END - -#endif diff --git a/intern/cycles/util/util_debug.cpp b/intern/cycles/util/util_debug.cpp index 9a66a372822..68e6f261057 100644 --- a/intern/cycles/util/util_debug.cpp +++ b/intern/cycles/util/util_debug.cpp @@ -57,7 +57,19 @@ void DebugFlags::CPU::reset() #undef STRINGIFY #undef CHECK_CPU_FLAGS - bvh_layout = BVH_LAYOUT_DEFAULT; + if(getenv("CYCLES_BVH2") != NULL) { + bvh_layout = BVH_LAYOUT_BVH2; + } + else if(getenv("CYCLES_BVH4") != NULL) { + bvh_layout = BVH_LAYOUT_BVH4; + } + else if(getenv("CYCLES_BVH8") != NULL) { + bvh_layout = BVH_LAYOUT_BVH8; + } + else { + bvh_layout = BVH_LAYOUT_DEFAULT; + } + split_kernel = false; } diff --git a/intern/cycles/util/util_math_intersect.h b/intern/cycles/util/util_math_intersect.h index 5f15487df57..bc3dd1500a9 100644 --- a/intern/cycles/util/util_math_intersect.h +++ b/intern/cycles/util/util_math_intersect.h @@ -136,10 +136,10 @@ ccl_device_forceinline bool ray_triangle_intersect( #if defined(__KERNEL_SSE2__) && defined (__KERNEL_SSE__) int uvw_sign = movemask(UVWW) & 0x7; - if (uvw_sign != 0) - { - if (uvw_sign != 0x7) + if(uvw_sign != 0) { + if(uvw_sign != 0x7) { return false; + } } #else const float minUVW = min(U, min(V, W)); diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp index 8ae5b63b2f9..1b039888452 100644 --- a/intern/cycles/util/util_system.cpp +++ b/intern/cycles/util/util_system.cpp @@ -107,25 +107,26 @@ unsigned short system_cpu_process_groups(unsigned short max_groups, #if !defined(_WIN32) || defined(FREE_WINDOWS) static void __cpuid(int data[4], int selector) { -#ifdef __x86_64__ +#if defined(__x86_64__) asm("cpuid" : "=a" (data[0]), "=b" (data[1]), "=c" (data[2]), "=d" (data[3]) : "a"(selector)); -#else -#ifdef __i386__ +#elif defined(__i386__) asm("pushl %%ebx \n\t" - "cpuid \n\t" - "movl %%ebx, %1 \n\t" - "popl %%ebx \n\t" : "=a" (data[0]), "=r" (data[1]), "=c" (data[2]), "=d" (data[3]) : "a"(selector)); + "cpuid \n\t" + "movl %%ebx, %1 \n\t" + "popl %%ebx \n\t" + : "=a" (data[0]), "=r" (data[1]), "=c" (data[2]), "=d" (data[3]) + : "a"(selector) + : "ebx"); #else data[0] = data[1] = data[2] = data[3] = 0; #endif -#endif } #endif string system_cpu_brand_string() { - char buf[48]; - int result[4]; + char buf[48] = {0}; + int result[4] = {0}; __cpuid(result, 0x80000000); @@ -300,7 +301,7 @@ size_t system_physical_ram() #elif defined(__APPLE__) uint64_t ram = 0; size_t len = sizeof(ram); - if (sysctlbyname("hw.memsize", &ram, &len, NULL, 0) == 0) { + if(sysctlbyname("hw.memsize", &ram, &len, NULL, 0) == 0) { return ram; } return 0; diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index dfe755a8789..96c549b9be5 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -121,6 +121,7 @@ CCL_NAMESPACE_END #include "util/util_types_float2.h" #include "util/util_types_float3.h" #include "util/util_types_float4.h" +#include "util/util_types_float8.h" #include "util/util_types_vector3.h" @@ -140,6 +141,7 @@ CCL_NAMESPACE_END #include "util/util_types_float2_impl.h" #include "util/util_types_float3_impl.h" #include "util/util_types_float4_impl.h" +#include "util/util_types_float8_impl.h" #include "util/util_types_vector3_impl.h" @@ -148,7 +150,10 @@ CCL_NAMESPACE_END # include "util/util_sseb.h" # include "util/util_ssei.h" # include "util/util_ssef.h" +#if defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__) +# include "util/util_avxb.h" # include "util/util_avxf.h" #endif +#endif #endif /* __UTIL_TYPES_H__ */ diff --git a/intern/cycles/util/util_types_float8.h b/intern/cycles/util/util_types_float8.h new file mode 100644 index 00000000000..64ec5a71355 --- /dev/null +++ b/intern/cycles/util/util_types_float8.h @@ -0,0 +1,71 @@ +/* +* Original code Copyright 2017, Intel Corporation +* Modifications Copyright 2018, Blender Foundation. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* * Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Intel Corporation nor the names of its contributors +* may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef __UTIL_TYPES_FLOAT8_H__ +#define __UTIL_TYPES_FLOAT8_H__ + +#ifndef __UTIL_TYPES_H__ +# error "Do not include this file directly, include util_types.h instead." +#endif + +CCL_NAMESPACE_BEGIN + +#ifndef __KERNEL_GPU__ + +struct ccl_try_align(16) float8 { +#ifdef __KERNEL_AVX2__ + union { + __m256 m256; + struct { float a, b, c, d, e, f, g, h; }; + }; + + __forceinline float8(); + __forceinline float8(const float8& a); + __forceinline explicit float8(const __m256& a); + + __forceinline operator const __m256&(void) const; + __forceinline operator __m256&(void); + + __forceinline float8& operator =(const float8& a); + +#else /* __KERNEL_AVX2__ */ + float a, b, c, d, e, f, g, h; +#endif /* __KERNEL_AVX2__ */ + + __forceinline float operator[](int i) const; + __forceinline float& operator[](int i); +}; + +ccl_device_inline float8 make_float8(float f); +ccl_device_inline float8 make_float8(float a, float b, float c, float d, + float e, float f, float g, float h); +#endif /* __KERNEL_GPU__ */ + +CCL_NAMESPACE_END + +#endif /* __UTIL_TYPES_FLOAT8_H__ */ diff --git a/intern/cycles/util/util_types_float8_impl.h b/intern/cycles/util/util_types_float8_impl.h new file mode 100644 index 00000000000..ebf8260bc7c --- /dev/null +++ b/intern/cycles/util/util_types_float8_impl.h @@ -0,0 +1,114 @@ +/* +* Original code Copyright 2017, Intel Corporation +* Modifications Copyright 2018, Blender Foundation. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* * Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Intel Corporation nor the names of its contributors +* may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef __UTIL_TYPES_FLOAT8_IMPL_H__ +#define __UTIL_TYPES_FLOAT8_IMPL_H__ + +#ifndef __UTIL_TYPES_H__ +# error "Do not include this file directly, include util_types.h instead." +#endif + +#ifndef __KERNEL_GPU__ +# include <cstdio> +#endif + +CCL_NAMESPACE_BEGIN + +#ifndef __KERNEL_GPU__ +#ifdef __KERNEL_AVX2__ +__forceinline float8::float8() +{ +} + +__forceinline float8::float8(const float8& f) + : m256(f.m256) +{ +} + +__forceinline float8::float8(const __m256& f) + : m256(f) +{ +} + +__forceinline float8::operator const __m256&(void) const +{ + return m256; +} + +__forceinline float8::operator __m256&(void) +{ + return m256; +} + +__forceinline float8& float8::operator =(const float8& f) +{ + m256 = f.m256; + return *this; +} +#endif /* __KERNEL_AVX2__ */ + +__forceinline float float8::operator[](int i) const +{ + util_assert(i >= 0); + util_assert(i < 8); + return *(&a + i); +} + +__forceinline float& float8::operator[](int i) +{ + util_assert(i >= 0); + util_assert(i < 8); + return *(&a + i); +} + +ccl_device_inline float8 make_float8(float f) +{ +#ifdef __KERNEL_AVX2__ + float8 r(_mm256_set1_ps(f)); +#else + float8 r = {f, f, f, f, f, f, f, f}; +#endif + return r; +} + +ccl_device_inline float8 make_float8(float a, float b, float c, float d, + float e, float f, float g, float h) +{ +#ifdef __KERNEL_AVX2__ + float8 r(_mm256_set_ps(a, b, c, d, e, f, g, h)); +#else + float8 r = {a, b, c, d, e, f, g, h}; +#endif + return r; +} + +#endif /* __KERNEL_GPU__ */ + +CCL_NAMESPACE_END + +#endif /* __UTIL_TYPES_FLOAT8_IMPL_H__ */ diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 924173a6c68..99fa5026c03 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1362,7 +1362,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, * will not be dispatched to OUR active window if we minimize one of OUR windows. */ if (LOWORD(wParam) == WA_INACTIVE) window->lostMouseCapture(); - + window->processWin32TabletActivateEvent(GET_WM_ACTIVATE_STATE(wParam, lParam)); lResult = ::DefWindowProc(hwnd, msg, wParam, lParam); break; } diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 676a29f28d4..70edc66d570 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -265,23 +265,22 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, GHOST_WIN32_WTInfo fpWTInfo = (GHOST_WIN32_WTInfo) ::GetProcAddress(m_wintab, "WTInfoA"); GHOST_WIN32_WTOpen fpWTOpen = (GHOST_WIN32_WTOpen) ::GetProcAddress(m_wintab, "WTOpenA"); - // let's see if we can initialize tablet here - /* check if WinTab available. */ - if (fpWTInfo && fpWTInfo(0, 0, NULL)) { + // Let's see if we can initialize tablet here. + // Check if WinTab available by getting system context info. + LOGCONTEXT lc = { 0 }; + lc.lcOptions |= CXO_SYSTEM; + if (fpWTInfo && fpWTInfo(WTI_DEFSYSCTX, 0, &lc)) { // Now init the tablet - LOGCONTEXT lc; /* The maximum tablet size, pressure and orientation (tilt) */ AXIS TabletX, TabletY, Pressure, Orientation[3]; // Open a Wintab context - // Get default context information - fpWTInfo(WTI_DEFCONTEXT, 0, &lc); - // Open the context lc.lcPktData = PACKETDATA; lc.lcPktMode = PACKETMODE; - lc.lcOptions |= CXO_MESSAGES | CXO_SYSTEM; + lc.lcOptions |= CXO_MESSAGES; + lc.lcMoveMask = PACKETDATA; /* Set the entire tablet as active */ fpWTInfo(WTI_DEVICES, DVC_X, &TabletX); @@ -309,11 +308,17 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, } if (fpWTOpen) { - m_tablet = fpWTOpen(m_hWnd, &lc, TRUE); + // The Wintab spec says we must open the context disabled if we are using cursor masks. + m_tablet = fpWTOpen(m_hWnd, &lc, FALSE); if (m_tablet) { m_tabletData = new GHOST_TabletData(); m_tabletData->Active = GHOST_kTabletModeNone; } + + GHOST_WIN32_WTEnable fpWTEnable = (GHOST_WIN32_WTEnable) ::GetProcAddress(m_wintab, "WTEnable"); + if (fpWTEnable) { + fpWTEnable(m_tablet, TRUE); + } } } } @@ -835,6 +840,23 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCursorShape(GHOST_TStandardCursor cur return GHOST_kSuccess; } +void GHOST_WindowWin32::processWin32TabletActivateEvent(WORD state) +{ + if (!m_tablet) { + return; + } + + GHOST_WIN32_WTEnable fpWTEnable = (GHOST_WIN32_WTEnable) ::GetProcAddress(m_wintab, "WTEnable"); + GHOST_WIN32_WTOverlap fpWTOverlap = (GHOST_WIN32_WTOverlap) ::GetProcAddress(m_wintab, "WTOverlap"); + + if (fpWTEnable) { + fpWTEnable(m_tablet, state); + if (fpWTOverlap && state) { + fpWTOverlap(m_tablet, TRUE); + } + } +} + void GHOST_WindowWin32::processWin32TabletInitEvent() { if (m_wintab && m_tabletData) { diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h index d998e86c9b1..c72669ed898 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.h +++ b/intern/ghost/intern/GHOST_WindowWin32.h @@ -56,6 +56,7 @@ typedef UINT (API * GHOST_WIN32_WTInfo)(UINT, UINT, LPVOID); typedef HCTX (API * GHOST_WIN32_WTOpen)(HWND, LPLOGCONTEXTA, BOOL); typedef BOOL (API * GHOST_WIN32_WTClose)(HCTX); typedef BOOL (API * GHOST_WIN32_WTPacket)(HCTX, UINT, LPVOID); +typedef BOOL (API * GHOST_WIN32_WTEnable)(HCTX, BOOL); typedef BOOL (API * GHOST_WIN32_WTOverlap)(HCTX, BOOL); // typedefs for user32 functions to allow dynamic loading of Windows 10 DPI scaling functions @@ -249,6 +250,7 @@ public: return m_tabletData; } + void processWin32TabletActivateEvent(WORD state); void processWin32TabletInitEvent(); void processWin32TabletEvent(WPARAM wParam, LPARAM lParam); void bringTabletContextToFront(); diff --git a/intern/opencolorio/CMakeLists.txt b/intern/opencolorio/CMakeLists.txt index 10898e4239b..2fd54363db5 100644 --- a/intern/opencolorio/CMakeLists.txt +++ b/intern/opencolorio/CMakeLists.txt @@ -64,6 +64,9 @@ if(WITH_OPENCOLORIO) list(APPEND INC_SYS ${BOOST_INCLUDE_DIR} ) + add_definitions( + -DOpenColorIO_STATIC + ) endif() data_to_c_simple(gpu_shader_display_transform.glsl SRC) diff --git a/intern/openvdb/CMakeLists.txt b/intern/openvdb/CMakeLists.txt index f666dc78e75..9ac0817903b 100644 --- a/intern/openvdb/CMakeLists.txt +++ b/intern/openvdb/CMakeLists.txt @@ -38,6 +38,7 @@ set(SRC if(WITH_OPENVDB) add_definitions( -DWITH_OPENVDB + ${OPENVDB_DEFINITIONS} ) if(WITH_OPENVDB_3_ABI_COMPATIBLE) diff --git a/release/datafiles/blender_icons.svg b/release/datafiles/blender_icons.svg index 4174c575e67..e0df177e36a 100644 --- a/release/datafiles/blender_icons.svg +++ b/release/datafiles/blender_icons.svg @@ -31694,94 +31694,6 @@ id="stop32081" /> </linearGradient> <linearGradient - id="linearGradient16201" - inkscape:collect="always"> - <stop - id="stop16197" - offset="0" - style="stop-color:#3162a3;stop-opacity:1" /> - <stop - id="stop16199" - offset="1" - style="stop-color:#f7fefe;stop-opacity:1" /> - </linearGradient> - <linearGradient - inkscape:collect="always" - id="linearGradient32049"> - <stop - style="stop-color:#000000;stop-opacity:0.502" - offset="0" - id="stop32045" /> - <stop - style="stop-color:#000000;stop-opacity:0;" - offset="1" - id="stop32047" /> - </linearGradient> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient32083" - id="linearGradient1839" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.9995967,0,0,1.0002103,-78.949724,-0.02739749)" - x1="130.96371" - y1="93.79351" - x2="130.95943" - y2="102.0938" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient32049" - id="linearGradient1843" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.99959671,0,0,1.0002103,-77.491851,-1.6095542)" - x1="134.59244" - y1="102.70123" - x2="129.80527" - y2="99.260376" /> - <radialGradient - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(1.0756796,0,0,1.0756796,169.29413,52.235312)" - r="2.5804064" - fy="221.18524" - fx="126.53663" - cy="221.18524" - cx="126.53663" - id="radialGradient16215-8-6" - xlink:href="#linearGradient18134" - inkscape:collect="always" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient32275" - id="linearGradient1837" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.24672296,0,0,0.24587247,48.791231,-7.4945859)" - x1="-106.86201" - y1="54.004005" - x2="-118.21918" - y2="42.824642" /> - <linearGradient - inkscape:collect="always" - id="linearGradient32275"> - <stop - style="stop-color:#ffffff;stop-opacity:0.502" - offset="0" - id="stop32271" /> - <stop - style="stop-color:#ffffff;stop-opacity:0.502" - offset="1" - id="stop32273" /> - </linearGradient> - <radialGradient - gradientTransform="matrix(0.74982815,0,0,0.74524045,-395.41513,-347.41042)" - r="8" - fy="116.10581" - fx="135.00543" - cy="116.10581" - cx="135.00543" - gradientUnits="userSpaceOnUse" - id="radialGradient16343-7" - xlink:href="#linearGradient20909" - inkscape:collect="always" /> - <linearGradient id="linearGradient20909"> <stop id="stop20905" @@ -31793,70 +31705,6 @@ style="stop-color:#be6405;stop-opacity:1" /> </linearGradient> <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient18134" - id="linearGradient1833" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.68749955,0,0,0.68749925,174.25458,209.80705)" - x1="125.81818" - y1="111.81818" - x2="143.88347" - y2="129.27184" /> - <radialGradient - r="4.0908751" - fy="224.26517" - fx="129.04718" - cy="224.26517" - cx="129.04718" - gradientTransform="matrix(2.3313393,0.09414236,-0.07778124,1.9261749,-17.080128,-154.09391)" - gradientUnits="userSpaceOnUse" - id="radialGradient16345-9" - xlink:href="#linearGradient20915" - inkscape:collect="always" /> - <linearGradient - inkscape:collect="always" - id="linearGradient20915"> - <stop - style="stop-color:#efa351;stop-opacity:1" - offset="0" - id="stop20911" /> - <stop - style="stop-color:#f7fefe;stop-opacity:1" - offset="1" - id="stop20913" /> - </linearGradient> - <radialGradient - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(1.0756796,0,0,1.0756796,126.28771,52.31486)" - r="2.5804064" - fy="221.18524" - fx="126.53663" - cy="221.18524" - cx="126.53663" - id="radialGradient16215-2" - xlink:href="#linearGradient18134" - inkscape:collect="always" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient37542" - id="linearGradient15186" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(0.9995967,0,0,1.0002103,-78.949724,-0.02739749)" - x1="109.04134" - y1="75.666725" - x2="135.45256" - y2="103.11092" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient319" - id="linearGradient15188" - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(1.1000194,0,0,1.0998287,-4.6508478,-9.2334126)" - x1="47.655102" - y1="93.805557" - x2="59.057678" - y2="105.27895" /> - <linearGradient id="linearGradient16192"> <stop style="stop-color:#b69f83;stop-opacity:1" @@ -31867,58 +31715,6 @@ offset="1" id="stop16190" /> </linearGradient> - <radialGradient - gradientTransform="matrix(0.74982815,0,0,0.74524045,-395.41513,-347.41042)" - r="8" - fy="116.10581" - fx="135.00543" - cy="116.10581" - cx="135.00543" - gradientUnits="userSpaceOnUse" - id="radialGradient16343" - xlink:href="#linearGradient16192" - inkscape:collect="always" /> - <linearGradient - gradientTransform="matrix(0.68749955,0,0,0.68749925,174.25458,209.80705)" - y2="129.27184" - x2="143.88347" - y1="111.81818" - x1="125.81818" - gradientUnits="userSpaceOnUse" - id="linearGradient15938" - xlink:href="#linearGradient18134" - inkscape:collect="always" /> - <radialGradient - r="4.0908751" - fy="224.26517" - fx="129.04718" - cy="224.26517" - cx="129.04718" - gradientTransform="matrix(2.3313393,0.09414236,-0.07778124,1.9261749,-17.080128,-154.09391)" - gradientUnits="userSpaceOnUse" - id="radialGradient16345" - xlink:href="#linearGradient16201" - inkscape:collect="always" /> - <radialGradient - gradientUnits="userSpaceOnUse" - gradientTransform="matrix(1.0756796,0,0,1.0756796,126.28771,52.31486)" - r="2.5804064" - fy="221.18524" - fx="126.53663" - cy="221.18524" - cx="126.53663" - id="radialGradient16215" - xlink:href="#linearGradient18134" - inkscape:collect="always" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient27277-1-8" - id="linearGradient18811" - gradientUnits="userSpaceOnUse" - x1="4.1933641" - y1="199.12067" - x2="17.16466" - y2="211.01585" /> <mask maskUnits="userSpaceOnUse" id="mask25369-1"> @@ -32205,6 +32001,162 @@ y1="238" x2="226.625" y2="251.71078" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient18495" + id="radialGradient45309-02" + cx="336.42892" + cy="611.10455" + fx="336.42892" + fy="611.10455" + r="5.9852905" + gradientTransform="matrix(1.0070601,0.03386866,-0.03770425,1.1211085,20.665977,-85.772965)" + gradientUnits="userSpaceOnUse" /> + <filter + style="color-interpolation-filters:sRGB" + inkscape:collect="always" + id="filter24186-3-2-2" + x="-0.12810811" + width="1.2562162" + y="-0.11285714" + height="1.2257143"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.395" + id="feGaussianBlur24188-3-7-2" /> + </filter> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient319-9-1" + id="linearGradient42578" + gradientUnits="userSpaceOnUse" + gradientTransform="translate(301.02752,449.99999)" + x1="25.963812" + y1="155.66899" + x2="29.972469" + y2="168" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient1610-06-1-5" + id="linearGradient42580" + gradientUnits="userSpaceOnUse" + x1="335.96875" + y1="607.09375" + x2="337.04251" + y2="628.20752" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient15859-1-3" + id="linearGradient42617" + gradientUnits="userSpaceOnUse" + x1="12.602254" + y1="206.13333" + x2="26.167894" + y2="220.66356" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient48327-1" + id="radialGradient42840" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(2.4461753,0.01083717,0.0036163,6.752143,-191.34795,-740.3814)" + cx="131.99811" + cy="126.63337" + fx="131.99811" + fy="126.63337" + r="9.1978254" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient10069-74-1" + id="linearGradient42842" + gradientUnits="userSpaceOnUse" + x1="125.20553" + y1="111.38132" + x2="132.35237" + y2="118.69846" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient319-7409-3-7" + id="linearGradient42844" + gradientUnits="userSpaceOnUse" + x1="130.60338" + y1="115.87343" + x2="143.88347" + y2="129.27184" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient319-7409-3-7" + id="linearGradient42846" + gradientUnits="userSpaceOnUse" + x1="125.81818" + y1="111.81818" + x2="143.88347" + y2="129.27184" /> + <filter + style="color-interpolation-filters:sRGB" + inkscape:collect="always" + x="-0.71999419" + width="2.4399884" + y="-0.72000581" + height="2.4400115" + id="filter31351-7"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.83077614" + id="feGaussianBlur31353-1" /> + </filter> + <mask + maskUnits="userSpaceOnUse" + id="mask43822-7"> + <rect + y="208" + x="754" + height="9" + width="12" + id="rect43824-6" + style="display:inline;overflow:visible;visibility:visible;opacity:0.93999993;fill:url(#linearGradient43826);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:new" /> + </mask> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient37542" + id="linearGradient43187" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.888889,0,0,1,61.53822,346.48241)" + x1="246.89435" + y1="-4.4418921" + x2="277.68143" + y2="30.743095" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient319" + id="linearGradient43189" + gradientUnits="userSpaceOnUse" + gradientTransform="translate(218.01612,129)" + x1="87.03125" + y1="241" + x2="92.8125" + y2="245.625" /> + <mask + maskUnits="userSpaceOnUse" + id="mask43822-5"> + <rect + y="208" + x="754" + height="9" + width="12" + id="rect43824-61" + style="display:inline;overflow:visible;visibility:visible;opacity:0.93999993;fill:url(#linearGradient43826);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:new" /> + </mask> + <mask + maskUnits="userSpaceOnUse" + id="mask43822-7-6"> + <rect + y="208" + x="754" + height="9" + width="12" + id="rect43824-6-2" + style="display:inline;overflow:visible;visibility:visible;opacity:0.93999993;fill:url(#linearGradient43826);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:new" /> + </mask> </defs> <sodipodi:namedview id="base" @@ -92328,305 +92280,6 @@ inkscape:connector-curvature="0" /> </g> </g> - <g - transform="translate(63,-21)" - style="display:inline;enable-background:new" - id="ICON_LIBRARY_DATA_DIRECT-3"> - <g - transform="translate(0,128)" - id="g24024-6"> - <rect - style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" - id="rect22150-0" - width="16" - height="16" - x="299" - y="365" /> - <path - inkscape:export-ydpi="90" - inkscape:export-xdpi="90" - inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\Kopia blender\.blender\icons\jendrzych's iconset.png" - sodipodi:nodetypes="cccccc" - id="path12337-6" - d="m 304.20488,366.47791 h 8.33334 v 13 h -11 l -1e-5,-10 z" - style="display:inline;fill:url(#linearGradient14966);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none" - inkscape:connector-curvature="0" /> - <path - transform="matrix(1.2999758,0,0,1.2999988,365.56499,31.43979)" - sodipodi:nodetypes="ccc" - id="path12339-2" - style="display:inline;opacity:0.7;fill:none;stroke:#000000;stroke-width:0.76923829px;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:1;filter:url(#filter31351-5)" - d="M -48.500031,260.50809 -46.5,260.5 l -3.1e-5,-1.99191" - inkscape:connector-curvature="0" /> - <path - sodipodi:nodetypes="cccc" - id="path12341-6" - d="m 301.01612,370 h 4 v -4 z" - style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none" - inkscape:connector-curvature="0" /> - <path - sodipodi:nodetypes="cccc" - id="path12343-18" - style="display:inline;fill:none;stroke:url(#linearGradient14968);stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" - d="m 302.51612,371.00001 v 7.5 m 3.5,-11 h 5.5" - inkscape:connector-curvature="0" /> - <path - inkscape:export-ydpi="90" - inkscape:export-xdpi="90" - inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\Kopia blender\.blender\icons\jendrzych's iconset.png" - d="m 301.53822,368.97791 v 10.5 h 11 v -13 h -8.5 z" - style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - id="path12345-79" - sodipodi:nodetypes="cccccc" - inkscape:connector-curvature="0" /> - </g> - <path - transform="rotate(90,390.14304,130.94532)" - mask="url(#mask43822-1)" - sodipodi:nodetypes="cccccccc" - id="path43815-2" - d="m 765.0088,212.5 -3.9824,3.5 -0.0176,-2 h -6.9736 l -0.0132,-3 h 6.9868 l 0.004,-2 z" - style="display:inline;opacity:0.93999993;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;enable-background:new" - inkscape:transform-center-x="1" - inkscape:transform-center-y="2" - inkscape:connector-curvature="0" /> - <rect - y="388.14911" - x="236.65889" - height="15.857694" - width="15.371461" - id="rect24007-4-3" - style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.73221993;marker:none;enable-background:accumulate" /> - <rect - style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:8.5497179;marker:none;enable-background:accumulate" - id="rect15296-7-7" - width="48.855526" - height="48.855526" - x="-358.88776" - y="435.15311" /> - <g - transform="matrix(1.0409533,0,0,1.0409533,-31.873537,156.12279)" - id="ICON_OUTLINER_OB_LIGHTPROBE" - style="display:inline;opacity:1;enable-background:new"> - <ellipse - id="path15301-7-9" - style="display:inline;fill:white;fill-opacity:1;fill-rule:nonzero;stroke:#422200;stroke-width:0.90000004;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new" - cx="265.0126" - cy="290.93195" - rx="6.4540777" - ry="6.4615378" /> - <ellipse - style="display:inline;opacity:1;fill:url(#radialGradient16343-7);fill-opacity:1.0;fill-rule:nonzero;stroke:none;stroke-width:0.74753082;enable-background:new" - id="path15303-40-2" - transform="matrix(-0.99371287,-0.11195862,0.11396043,-0.99348529,0,0)" - cx="-296.43781" - cy="-259.47205" - rx="5.9986253" - ry="5.9619236" /> - <ellipse - id="path15305-1-2" - style="display:inline;fill:none;stroke:url(#linearGradient1833);stroke-width:1.00000083;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new" - cx="265.00449" - cy="290.93195" - rx="5.4999962" - ry="5.4999943" /> - <path - style="display:inline;opacity:1;fill:url(#radialGradient16345-9);fill-opacity:1;stroke:none;stroke-width:1.70456684;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers;enable-background:new" - d="m 269.25291,290.16569 c 0,1.9641 -1.9029,2.10245 -4.25024,2.10245 -2.34735,0 -4.25025,-0.13833 -4.25025,-2.10245 0,-1.96408 1.9029,-3.5563 4.25025,-3.5563 2.34734,0 4.25024,1.59222 4.25024,3.5563 z" - id="path16194-8" - inkscape:connector-curvature="0" - sodipodi:nodetypes="cscsc" /> - <circle - style="display:inline;opacity:1;fill:url(#radialGradient16215-2);fill-opacity:1;stroke:none;stroke-width:1.70456684;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers;enable-background:new" - id="path16207-97" - cx="262.40057" - cy="290.23932" - r="2.7756906" /> - </g> - <rect - y="388.53351" - x="276.20624" - height="15.857694" - width="15.371461" - id="rect41257-5-3" - style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.73221993;marker:none;enable-background:accumulate" /> - <g - style="display:inline;opacity:1;stroke-width:0.92378205;enable-background:new" - id="ICON_LIGHTPROBE_GRID" - transform="matrix(4.1824085,0,0,4.3147085,197.8811,376.91182)" - inkscape:label="#ICON_LIGHTPROBE_GRID"> - <g - id="g41259-1-1" - style="display:inline;stroke-width:0.92378205;enable-background:new" - transform="matrix(0.26467734,0,0,0.26447615,7.1493505,-21.614208)"> - <rect - style="fill:url(#linearGradient15186);fill-opacity:1;fill-rule:nonzero;stroke:black;stroke-width:0.73904407;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="rect41261-7-2" - width="11.995742" - height="12.004883" - x="46.499645" - y="92.490814" /> - <path - inkscape:connector-curvature="0" - style="fill:#fdfefe;fill-opacity:1;stroke:none;stroke-width:0.92380506px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" - d="m 46.907234,96.606288 v -3.716421 l 3.713597,5e-6 v 3.716421 z" - id="path41263-3-9" - sodipodi:nodetypes="ccccc" /> - <path - inkscape:connector-curvature="0" - style="display:inline;fill:#6289b8;fill-opacity:1;stroke:none;stroke-width:0.92380506px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new" - d="m 50.631333,96.588054 v -3.698738 l 3.695921,1.2e-5 v 3.698738 z" - id="path41263-3-7-3" - sodipodi:nodetypes="ccccc" /> - <path - inkscape:connector-curvature="0" - style="display:inline;fill:#4e709a;fill-opacity:1;stroke:none;stroke-width:0.92380506px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new" - d="m 54.316208,96.645534 v -3.751799 l 3.784289,1.2e-5 v 3.751798 z" - id="path41263-3-7-9-19" - sodipodi:nodetypes="ccccc" /> - <path - inkscape:connector-curvature="0" - style="display:inline;fill:#6289b8;fill-opacity:1;stroke:none;stroke-width:0.92380506px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new" - d="m 46.906687,100.31554 v -3.703172 l 3.709175,1.2e-5 v 3.70317 z" - id="path41263-3-7-2-4" - sodipodi:nodetypes="ccccc" /> - <path - inkscape:connector-curvature="0" - style="display:inline;fill:#3c5d86;fill-opacity:1;stroke:none;stroke-width:0.92380506px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new" - d="m 54.325051,100.3509 v -3.796008 l 3.810799,1.2e-5 v 3.796016 z" - id="path41263-3-7-9-1-7" - sodipodi:nodetypes="ccccc" /> - <path - inkscape:connector-curvature="0" - style="display:inline;fill:#4e709a;fill-opacity:1;stroke:none;stroke-width:0.92380506px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new" - d="m 50.57831,100.31995 v -3.769487 l 3.748939,1e-5 v 3.769487 z" - id="path41263-3-7-9-2-8" - sodipodi:nodetypes="ccccc" /> - <path - inkscape:connector-curvature="0" - style="display:inline;fill:#bba891;fill-opacity:1;stroke:none;stroke-width:0.92380506px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new" - d="m 46.904544,104.10308 v -3.78489 l 3.691501,1e-5 v 3.7849 z" - id="path41263-3-7-9-2-2-4" - sodipodi:nodetypes="ccccc" /> - <path - inkscape:connector-curvature="0" - style="display:inline;fill:#65492b;fill-opacity:1;stroke:none;stroke-width:0.92380506px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new" - d="m 50.595983,104.10048 v -3.77389 l 3.771034,1e-5 v 3.77389 z" - id="path41263-3-7-9-2-2-7-5" - sodipodi:nodetypes="ccccc" /> - <path - inkscape:connector-curvature="0" - style="display:inline;fill:#422200;fill-opacity:1;stroke:none;stroke-width:0.92380506px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new" - d="m 54.355973,104.10187 v -3.76645 l 3.763582,1e-5 v 3.76645 z" - id="path41263-3-7-9-2-2-7-6-0" - sodipodi:nodetypes="ccccc" /> - </g> - <path - inkscape:connector-curvature="0" - d="m 21.528344,3.0779311 v 2.704597 m -0.986891,-2.704597 v 2.704597 m 1.850422,-0.860554 h -2.713953 m 2.713953,-0.983488 h -2.713953" - style="display:inline;fill:none;stroke:url(#linearGradient1837);stroke-width:0.24441732;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new" - id="path41281-4-3" /> - </g> - <rect - style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.73221993;marker:none;enable-background:accumulate" - id="rect31205-8-6" - width="15.371461" - height="15.857694" - x="256.10117" - y="388.50687" /> - <g - transform="matrix(0.96071629,0,0,0.99110589,-29.963907,107.82778)" - id="ICON_LIGHTPROBE_PLANAR" - style="display:inline;opacity:1;enable-background:new"> - <g - transform="matrix(1.0003553,0,0,0.9995949,255.07114,193.09317)" - style="display:inline" - id="g9148-9-0"> - <path - sodipodi:nodetypes="ccccc" - inkscape:connector-curvature="0" - id="rect9150-2-6" - d="m 45.5,91.491928 12.995382,2.511515 v 8.228337 L 45.5,104.49568 Z" - style="fill:url(#linearGradient1839);fill-opacity:1;fill-rule:nonzero;stroke:black;stroke-width:0.80001998;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <path - inkscape:connector-curvature="0" - sodipodi:nodetypes="ccccc" - id="path9152-7-3" - d="M 46.49945,103.49527 V 92.492523 l 10.996287,2.228527 v 6.75793 z" - style="fill:none;stroke:url(#linearGradient15188);stroke-width:1.0000248px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> - <path - sodipodi:nodetypes="ccccc" - inkscape:connector-curvature="0" - id="rect9150-2-7-2" - d="m 47.081592,93.111072 9.92023,2.069352 0.01767,5.911376 -10.061616,1.82172 z" - style="display:inline;fill:url(#linearGradient1843);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80001998;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new" /> - </g> - <circle - style="display:inline;opacity:1;fill:url(#radialGradient16215-8-6);fill-opacity:1;stroke:none;stroke-width:1.70456684;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers;enable-background:new" - id="path16207-4-0" - cx="305.40698" - cy="290.15979" - r="2.7756906" /> - </g> - <g - id="layer1-2" - inkscape:label="Capa 1" - transform="matrix(3.7795276,0,0,3.7795276,-191.20889,408.4512)"> - <rect - y="1.3906925" - x="7.0330977" - height="4.2333331" - width="4.2333331" - id="rect24007-4" - style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.74083334;marker:none;enable-background:accumulate" /> - <rect - style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.74083334;marker:none;enable-background:accumulate" - id="rect15296-7" - width="4.2333331" - height="4.2333331" - x="1.4538921" - y="1.3897316" /> - <g - id="ICON_LIGHTPROBE_CUBEMAP" - style="display:inline;opacity:1;enable-background:new" - transform="matrix(0.26458333,0,0,0.26458333,45.041487,-80.256633)"> - <ellipse - id="path15301-7" - style="display:inline;fill:white;fill-opacity:1;fill-rule:nonzero;stroke:black;stroke-width:0.90000004;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new" - cx="265.0126" - cy="290.93195" - rx="6.4540777" - ry="6.4615378" /> - <ellipse - style="display:inline;opacity:1;fill:url(#radialGradient16343);fill-opacity:1.0;fill-rule:nonzero;stroke:none;stroke-width:0.74753082;enable-background:new" - id="path15303-40" - transform="matrix(-0.99371287,-0.11195862,0.11396043,-0.99348529,0,0)" - cx="-296.43781" - cy="-259.47205" - rx="5.9986253" - ry="5.9619236" /> - <ellipse - id="path15305-1" - style="display:inline;fill:none;stroke:url(#linearGradient15938);stroke-width:1.00000083;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new" - cx="265.00449" - cy="290.93195" - rx="5.4999962" - ry="5.4999943" /> - <path - style="display:inline;opacity:1;fill:url(#radialGradient16345);fill-opacity:1;stroke:none;stroke-width:1.70456684;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers;enable-background:new" - d="m 269.25291,290.16569 c 0,1.9641 -1.9029,2.10245 -4.25024,2.10245 -2.34735,0 -4.25025,-0.13833 -4.25025,-2.10245 0,-1.96408 1.9029,-3.5563 4.25025,-3.5563 2.34734,0 4.25024,1.59222 4.25024,3.5563 z" - id="path16194" - inkscape:connector-curvature="0" - sodipodi:nodetypes="cscsc" /> - <circle - style="display:inline;opacity:1;fill:url(#radialGradient16215);fill-opacity:1;stroke:none;stroke-width:1.70456684;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers;enable-background:new" - id="path16207" - cx="262.40057" - cy="290.23932" - r="2.7756906" /> - </g> - </g> - </g> <path id="path14068" style="display:inline;overflow:visible;visibility:visible;opacity:0.35;fill:none;stroke:url(#radialGradient23167-6);stroke-width:2.12000012;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" @@ -92968,46 +92621,6 @@ id="g56716-3" /> </g> <g - transform="translate(461.99301,376.87052)" - style="display:inline;enable-background:new" - id="ICON_SOLO_OFF-1"> - <rect - y="198.9792" - x="4.9506397" - height="16" - width="16" - id="rect23018-5-4-2" - style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" /> - <g - transform="matrix(0.94058502,0,0,0.94058502,0.9128606,12.74924)" - id="g56716-7"> - <path - sodipodi:type="star" - style="fill:url(#linearGradient18811);fill-opacity:1.0;stroke:#000000;stroke-width:0.96882826;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.80000001" - id="path15855-0" - sodipodi:sides="5" - sodipodi:cx="13.700194" - sodipodi:cy="207.20645" - sodipodi:r1="7.1873641" - sodipodi:r2="3.3158474" - sodipodi:arg1="0.94697287" - sodipodi:arg2="1.5618338" - inkscape:flatsided="false" - inkscape:rounded="0" - inkscape:randomized="0" - d="m 17.898641,213.04008 -4.168729,-2.51791 -4.280439,2.47993 1.106473,-4.74277 -3.6812884,-3.3046 4.8525664,-0.41328 2.005278,-4.52229 1.892578,4.48735 4.920618,0.50967 -3.682889,3.18662 z" - inkscape:transform-center-x="-0.010954063" - inkscape:transform-center-y="-0.74285516" - transform="matrix(1.0972098,0,0,1.0975406,-2.0923019,-19.740595)" /> - <path - style="fill:none;stroke:#ffffff;stroke-width:1.06316817;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:0.51147538" - d="m 12.931855,202.51514 -1.201334,2.70994 c -0.137665,0.32193 -0.454082,0.55986 -0.800889,0.60222 l -2.9032248,0.26765 2.2358168,1.97391 c 0.261321,0.2395 0.380487,0.62447 0.300333,0.97022 l -0.667408,2.81032" - id="path15869-9" - inkscape:connector-curvature="0" - sodipodi:nodetypes="ccccccc" /> - </g> - </g> - <g style="display:inline;enable-background:new" transform="translate(168.01766,128.03044)" id="ICON_GRID-3" @@ -93788,6 +93401,540 @@ id="path15475-0-6-8-7" inkscape:connector-curvature="0" sodipodi:nodetypes="cc" /> + <g + id="g7004" + transform="translate(126.03866,42.479059)" + style="display:inline;opacity:0.8;enable-background:new"> + <path + sodipodi:nodetypes="ccccc" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 57.5,410.5 v 2 h -2 v -2 z" + id="path6988" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + id="path6990" + d="m 59.5,420.5 v 1.9999 h -2 V 420.5 Z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + sodipodi:nodetypes="ccccc" /> + <path + inkscape:connector-curvature="0" + id="path6994" + d="m 51.5,415.5 v 2 h -2 v -2 z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + sodipodi:nodetypes="ccccc" /> + <path + sodipodi:nodetypes="cccccccccccc" + inkscape:connector-curvature="0" + id="path6998" + style="display:inline;opacity:0.9;fill:none;stroke:#ffffff;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;enable-background:new" + d="m 62.5,411.49995 -3,5e-5 m -4,0 -8,-5e-5 m 15,5 -9,5e-5 m -4,0 -2,-5e-5 m 15,5 -1,5e-5 m -4,0 -10,-5e-5" /> + </g> + <g + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + transform="translate(-28.153595,-46.022098)" + id="ICON_PREFERENCES-3" + style="display:inline;enable-background:new"> + <rect + y="602" + x="327" + height="16" + width="16" + id="rect42947-6" + style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" /> + <g + id="g42949-1"> + <g + style="opacity:0.85" + id="g42951-2"> + <path + style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 341.5161,616.38229 340.5,617.5 l -10.73389,-10e-6 -1.25,-1.25 L 328.5,605.5 h 13 z" + id="path42953-9" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + sodipodi:nodetypes="ccccccc" + inkscape:connector-curvature="0" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + id="path42955-3" + d="m 340,616 h -8.25 v -1 H 340 Z" + style="display:inline;overflow:visible;visibility:visible;fill:#999999;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.9999994px;marker:none;enable-background:accumulate" + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" /> + <rect + style="display:inline;overflow:visible;visibility:visible;opacity:0.2;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.9999994px;marker:none;enable-background:accumulate" + id="rect38927-1" + width="11.970581" + height="8.0306396" + x="329.02942" + y="605.96936" /> + <rect + y="605.96936" + x="329.02942" + height="8.0306396" + width="11.970581" + id="rect45307-9" + style="display:inline;overflow:visible;visibility:visible;opacity:0.3;fill:url(#radialGradient45309-02);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.9999994px;marker:none;enable-background:accumulate" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + id="path42957-4" + d="m 340.48389,606.50001 c -3.66204,-3e-5 -7.70403,2e-5 -10.98389,-10e-6 l 0.002,10.00007 10.99778,-7e-5 -0.0161,-9.99999 z" + style="display:inline;overflow:visible;visibility:visible;fill:none;stroke:url(#linearGradient42578);stroke-width:0.99999923px;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" /> + <rect + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + y="615" + x="330" + height="1.0000043" + width="1" + id="rect42959-7" + style="display:inline;overflow:visible;visibility:visible;fill:#d40000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate" /> + <path + sodipodi:nodetypes="ccccc" + style="display:inline;overflow:visible;visibility:visible;opacity:0.35;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.9999994px;marker:none;enable-background:accumulate" + d="m 340.5,614 h -11 v -1 h 11 z" + id="path38929-8" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + inkscape:connector-curvature="0" /> + </g> + <path + style="opacity:0.25;fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter24186-3-2-2)" + d="m 337.7,606.7 v 2.75 l 2,1.5 v 2.5 l -0.25,0.25 h -1.75 v -2 h -2 v 2 h -1.75 l -0.25,-0.25 v -2.5 l 2,-1.5 v -2.75 z" + id="path42961-4" + sodipodi:nodetypes="ccccccccccccccc" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="ccccccccccccccccccccccccc" + id="path42963-5" + d="m 333.75,602.5 h 1.75 c 0,0 0,2 0,2 h 2 v -2 h 1.75 l 0.25,0.25 v 2.5 l -2,1.5 v 2.5 l 2,1.5 v 2.5 l -0.25,0.25 h -1.75 v -2 h -2 v 2 h -1.75 l -0.25,-0.25 v -2.5 l 2,-1.5 v -2.5 l -2,-1.5 v -2.5 z" + style="fill:#ffffff;fill-rule:evenodd;stroke:url(#linearGradient42580);stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + inkscape:connector-curvature="0" /> + </g> + </g> + <g + transform="translate(315.05087,356.60901)" + style="display:inline;enable-background:new" + id="ICON_SOLO_ON-6"> + <rect + y="198.9792" + x="4.9506397" + height="16" + width="16" + id="rect23018-5-4-4-1" + style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" /> + <g + transform="matrix(0.94058502,0,0,0.94058502,0.9128606,12.74924)" + id="g56716-9-0"> + <path + sodipodi:type="star" + style="fill:url(#linearGradient42617);fill-opacity:1;stroke:#341b00;stroke-width:0.96882826;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path15855-2-6" + sodipodi:sides="5" + sodipodi:cx="13.700194" + sodipodi:cy="207.20645" + sodipodi:r1="7.1873641" + sodipodi:r2="3.3158474" + sodipodi:arg1="0.94697287" + sodipodi:arg2="1.5618338" + inkscape:flatsided="false" + inkscape:rounded="0" + inkscape:randomized="0" + d="m 17.898641,213.04008 -4.168729,-2.51791 -4.280439,2.47993 1.106473,-4.74277 -3.6812884,-3.3046 4.8525664,-0.41328 2.005278,-4.52229 1.892578,4.48735 4.920618,0.50967 -3.682889,3.18662 z" + inkscape:transform-center-x="-0.010954063" + inkscape:transform-center-y="-0.74285516" + transform="matrix(1.0972098,0,0,1.0975406,-2.0923019,-19.740595)" /> + <path + style="fill:none;stroke:#ffffff;stroke-width:1.06316817;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1" + d="m 12.931855,202.51514 -1.201334,2.70994 c -0.137665,0.32193 -0.454082,0.55986 -0.800889,0.60222 l -2.9032248,0.26765 2.2358168,1.97391 c 0.261321,0.2395 0.380487,0.62447 0.300333,0.97022 l -0.667408,2.81032" + id="path15869-5-3" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + </g> + </g> + <g + style="display:inline;enable-background:new" + id="g42838" + transform="translate(84.038997,23)"> + <g + id="g42836"> + <rect + style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" + id="rect42818" + width="16" + height="16" + x="26" + y="92" /> + <circle + r="8" + cy="118" + cx="132" + style="display:inline;opacity:0.75;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="circle42820" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + transform="matrix(-0.7606373,-0.08449162,0.08669728,-0.7451645,124.04885,199.0823)" /> + <circle + r="8" + cy="118" + cx="132" + transform="matrix(0.8125001,0,0,0.8125002,-73.250026,4.1249738)" + id="circle42822" + style="fill:none;stroke:#000000;stroke-width:1.23076892;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <path + sodipodi:open="true" + transform="matrix(0.8077059,0,0,-0.2072667,-72.578821,124.6156)" + sodipodi:end="3.12636" + sodipodi:start="0" + d="m 140,118 a 8,10.07671 0 0 1 -7.93907,10.07642 8,10.07671 0 0 1 -8.06,-9.92293" + sodipodi:ry="10.07671" + sodipodi:rx="8" + sodipodi:cy="118" + sodipodi:cx="132" + id="path42824" + style="opacity:0.1;fill:none;stroke:url(#radialGradient42840);stroke-width:2.44404984;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + sodipodi:type="arc" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <circle + r="8" + cy="118" + cx="132" + style="display:inline;opacity:0.15;fill:url(#linearGradient42842);fill-opacity:1;fill-rule:nonzero;stroke:none;enable-background:new" + id="circle42826" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\Kopia blender\.blender\icons\blender's iconset.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" + transform="matrix(-0.7451139,-0.08394973,0.08492792,-0.7403854,122.33348,198.48526)" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + sodipodi:open="true" + sodipodi:end="3.12636" + sodipodi:start="0" + d="m 140,118 a 8,8 0 0 1 -7.93907,7.99977 8,8 0 0 1 -8.06,-7.87791" + sodipodi:ry="8" + sodipodi:rx="8" + sodipodi:cy="118" + sodipodi:cx="132" + id="path42828" + style="display:inline;fill:none;stroke:#000000;stroke-width:1.50070953;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + sodipodi:type="arc" + transform="matrix(0.780896,0,0,0.2786183,-69.081831,66.644097)" /> + <circle + r="8" + cy="118" + cx="132" + transform="matrix(0.6875009,0,0,0.687501,-56.75013,18.874887)" + id="circle42830" + style="display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:none;stroke:url(#linearGradient42844);stroke-width:1.45454454;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:new" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <path + transform="matrix(0,0.7811136,-0.34375,0,74.562502,-3.1287373)" + sodipodi:open="true" + sodipodi:end="6.2712816" + sodipodi:start="0" + d="m 140,118 a 8,8 0 0 1 -7.97619,7.99996 8,8 0 0 1 -8.02367,-7.95235 8,8 0 0 1 7.92844,-8.04729 8,8 0 0 1 8.07085,7.90445" + sodipodi:ry="8" + sodipodi:rx="8" + sodipodi:cy="118" + sodipodi:cx="132" + id="path42832" + style="display:inline;fill:none;stroke:#000000;stroke-width:1.35088885;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + sodipodi:type="arc" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <circle + r="8" + cy="118" + cx="132" + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + style="display:inline;overflow:visible;visibility:visible;opacity:0.18000004;fill:none;stroke:url(#linearGradient42846);stroke-width:1.0666672;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:new" + id="circle42834" + transform="matrix(0.9374995,0,0,0.9374996,-89.749939,-10.62495)" /> + </g> + </g> + <g + style="display:inline;enable-background:new;opacity:0.7" + id="ICON_DOT-1" + transform="translate(112.05535,339.92702)"> + <rect + y="111" + x="103" + height="16" + width="16" + id="rect24489-4" + style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" /> + <circle + transform="matrix(-0.248353,0.02816779,0.02830718,0.248422,140.45214,86.01031)" + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + id="path10768-9" + style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;opacity:1" + cx="132" + cy="118" + r="8" /> + </g> + <path + style="display:inline;opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new" + d="m 265.05663,454.00567 4.99112,5.02507 -4.99112,4.97493 -5,-5 z" + id="path23352" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + id="path23378" + d="m 243.85662,453.95566 4.99112,5.02507 -4.99112,4.97493 -5,-5 z" + style="display:inline;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new" + sodipodi:nodetypes="ccccc" /> + <g + transform="matrix(-1,0,0,1,529.37263,-42.471164)" + style="display:inline;enable-background:new" + id="g12146"> + <path + inkscape:connector-curvature="0" + d="m 237.171,504.53983 5.34213,0.008 m -2.18083,-4.04784 -4,4 M 240.5,508.5 l -4.1677,-4.00001" + style="display:inline;opacity:1;fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:7.40000057;stroke-opacity:1;enable-background:new" + id="path10766-9" + sodipodi:nodetypes="cccccc" /> + <path + sodipodi:nodetypes="cz" + id="path12139" + style="display:inline;opacity:1;fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:7.40000057;stroke-opacity:1;enable-background:new" + d="m 246.5,499.5 c -2.5,-2.5 -0.25,-4.25 4,-5" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + d="m 246.5,499.5 c 3.5,3.5 2.75,5.04783 -3.98687,5.04783" + style="display:inline;opacity:1;fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:7.40000057;stroke-opacity:1;enable-background:new" + id="path12141" + sodipodi:nodetypes="cz" /> + </g> + <g + transform="translate(63.014518,-20.992088)" + style="display:inline;enable-background:new" + id="ICON_LIBRARY_DATA_DIRECT-6"> + <g + transform="translate(0,128)" + id="g24024-5"> + <rect + style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" + id="rect22150-6" + width="16" + height="16" + x="299" + y="365" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\Kopia blender\.blender\icons\jendrzych's iconset.png" + sodipodi:nodetypes="cccccc" + id="path12337-39" + d="m 304.20488,366.47791 h 8.33334 v 13 h -11 l -1e-5,-10 z" + style="display:inline;fill:url(#linearGradient43187);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none" + inkscape:connector-curvature="0" /> + <path + transform="matrix(1.2999758,0,0,1.2999988,365.56499,31.43979)" + sodipodi:nodetypes="ccc" + id="path12339-4" + style="display:inline;opacity:0.7;fill:none;stroke:#000000;stroke-width:0.76923829px;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:1;filter:url(#filter31351-7)" + d="M -48.500031,260.50809 -46.5,260.5 l -3.1e-5,-1.99191" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="cccc" + id="path12341-8" + d="m 301.01612,370 h 4 v -4 z" + style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="cccc" + id="path12343-12" + style="display:inline;fill:none;stroke:url(#linearGradient43189);stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" + d="m 302.51612,371.00001 v 7.5 m 3.5,-11 h 5.5" + inkscape:connector-curvature="0" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\Kopia blender\.blender\icons\jendrzych's iconset.png" + d="m 301.53822,368.97791 v 10.5 h 11 v -13 h -8.5 z" + style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path12345-9" + sodipodi:nodetypes="cccccc" + inkscape:connector-curvature="0" /> + </g> + <path + transform="matrix(0,1,1,0,95.24196,-260.68059)" + mask="url(#mask43822-7)" + sodipodi:nodetypes="cccccccc" + id="path43815-3" + d="m 765.0088,212.5 -3.9824,3.5 -0.0176,-2 h -6.9736 l -0.0132,-3 h 6.9868 l 0.004,-2 z" + style="display:inline;opacity:0.93999993;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;enable-background:new" + inkscape:transform-center-x="-1" + inkscape:transform-center-y="2" + inkscape:connector-curvature="0" /> + </g> + <g + transform="translate(0.05047111,-42.001653)" + style="display:inline;enable-background:new" + id="ICON_LIBRARY_DATA_DIRECT-9"> + <g + transform="translate(0,128)" + id="g24024-8"> + <rect + style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" + id="rect22150-4" + width="16" + height="16" + x="299" + y="365" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\Kopia blender\.blender\icons\jendrzych's iconset.png" + d="m 301.53822,368.97791 v 10.5 h 11 v -13 h -8.5 z" + style="fill:none;stroke:#ffffff;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.92765957" + id="path12345-4" + sodipodi:nodetypes="cccccc" + inkscape:connector-curvature="0" /> + </g> + <path + transform="translate(-454.0088,290)" + mask="url(#mask43822-5)" + sodipodi:nodetypes="cccccccc" + id="path43815-4" + d="m 765.0088,212.5 -3.9824,3.5 -0.0176,-2 h -6.9736 l -0.0132,-3 h 6.9868 l 0.004,-2 z" + style="display:inline;opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;enable-background:new" + inkscape:transform-center-x="-2" + inkscape:transform-center-y="1" + inkscape:connector-curvature="0" /> + </g> + <g + transform="translate(20.991155,-41.985633)" + style="display:inline;enable-background:new" + id="ICON_LIBRARY_DATA_DIRECT-6-8"> + <g + transform="translate(0,128)" + id="g24024-5-5"> + <rect + style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" + id="rect22150-6-7" + width="16" + height="16" + x="299" + y="365" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\Kopia blender\.blender\icons\jendrzych's iconset.png" + d="m 301.53822,368.97791 v 10.5 h 11 v -13 h -8.5 z" + style="fill:none;stroke:#ffffff;stroke-width:0.80000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path12345-9-9" + sodipodi:nodetypes="cccccc" + inkscape:connector-curvature="0" /> + </g> + <path + transform="matrix(0,1,1,0,95.24196,-260.68059)" + mask="url(#mask43822-7-6)" + sodipodi:nodetypes="cccccccc" + id="path43815-3-7" + d="m 765.0088,212.5 -3.9824,3.5 -0.0176,-2 h -6.9736 l -0.0132,-3 h 6.9868 l 0.004,-2 z" + style="display:inline;opacity:1;fill:#fefefe;fill-opacity:1;fill-rule:nonzero;stroke:none;enable-background:new" + inkscape:transform-center-x="-1" + inkscape:transform-center-y="2" + inkscape:connector-curvature="0" /> + </g> + <g + id="g5040" + transform="translate(335.99091,-63.042558)" + style="display:inline;opacity:1;enable-background:new"> + <rect + ry="0" + rx="0" + y="514" + x="-42" + height="16" + width="16" + id="rect4914" + style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" + transform="scale(-1,1)" /> + <path + inkscape:connector-curvature="0" + style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + d="m 37.5,519.99995 v -0.75 c 0,-1.75 -0.75,-2.75 -3.00003,-2.75008 C 32.25,516.49995 31.5,517.49995 31.5,519.24995 V 520" + id="path4905" + sodipodi:nodetypes="csccc" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <path + style="fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + d="m 38.5,521.49995 h -8 v 6.00003 h 8 z" + id="rect4909" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccc" /> + <path + id="rect36043-2-8-6" + d="m 34,523 h 1 v 2 h -1 z" + style="display:inline;overflow:visible;visibility:visible;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.29999995;marker:none;enable-background:accumulate" + inkscape:connector-curvature="0" /> + </g> + <g + id="g5034" + transform="translate(314.99091,-84.042558)" + style="display:inline;opacity:0.7;enable-background:new"> + <rect + transform="scale(-1,1)" + style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" + id="rect4998" + width="16" + height="16" + x="-42" + y="535" + rx="0" + ry="0" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Documents and Settings\Tata\Pulpit\BLENDER ICONSET\blender-cvs-windows\.blender\.blender\icons\jendrzych's iconset.png" + sodipodi:nodetypes="csccc" + id="path5000" + d="m 33.5,541 v -0.75005 c 0,-1.75 -0.75,-2.75 -3.00003,-2.75008 C 28.25,537.49995 27.5,538.49995 27.5,540.24995 V 541" + style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" + id="path5002" + d="m 40.5,542.49995 h -8 v 6.00003 h 8 z" + style="fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <path + inkscape:connector-curvature="0" + style="display:inline;overflow:visible;visibility:visible;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.29999995;marker:none;enable-background:accumulate" + d="m 36,544 h 1 v 2 h -1 z" + id="path5004" /> + </g> </g> <g inkscape:groupmode="layer" diff --git a/release/datafiles/blender_icons16/icon16_decorate.dat b/release/datafiles/blender_icons16/icon16_decorate.dat Binary files differnew file mode 100644 index 00000000000..0847abef093 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_decorate.dat diff --git a/release/datafiles/blender_icons16/icon16_decorate_animate.dat b/release/datafiles/blender_icons16/icon16_decorate_animate.dat Binary files differnew file mode 100644 index 00000000000..386ff9bf849 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_decorate_animate.dat diff --git a/release/datafiles/blender_icons16/icon16_decorate_driver.dat b/release/datafiles/blender_icons16/icon16_decorate_driver.dat Binary files differnew file mode 100644 index 00000000000..483ea2bfa13 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_decorate_driver.dat diff --git a/release/datafiles/blender_icons16/icon16_decorate_keyframe.dat b/release/datafiles/blender_icons16/icon16_decorate_keyframe.dat Binary files differnew file mode 100644 index 00000000000..b765e6d9fac --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_decorate_keyframe.dat diff --git a/release/datafiles/blender_icons16/icon16_decorate_linked.dat b/release/datafiles/blender_icons16/icon16_decorate_linked.dat Binary files differnew file mode 100644 index 00000000000..1980b63027f --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_decorate_linked.dat diff --git a/release/datafiles/blender_icons16/icon16_decorate_locked.dat b/release/datafiles/blender_icons16/icon16_decorate_locked.dat Binary files differnew file mode 100644 index 00000000000..b8bb9b67786 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_decorate_locked.dat diff --git a/release/datafiles/blender_icons16/icon16_decorate_override.dat b/release/datafiles/blender_icons16/icon16_decorate_override.dat Binary files differnew file mode 100644 index 00000000000..d8540da683d --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_decorate_override.dat diff --git a/release/datafiles/blender_icons16/icon16_decorate_unlocked.dat b/release/datafiles/blender_icons16/icon16_decorate_unlocked.dat Binary files differnew file mode 100644 index 00000000000..c40ba1b9d20 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_decorate_unlocked.dat diff --git a/release/datafiles/blender_icons16/icon16_overlay.dat b/release/datafiles/blender_icons16/icon16_overlay.dat Binary files differnew file mode 100644 index 00000000000..a7ae9d89789 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_overlay.dat diff --git a/release/datafiles/blender_icons16/icon16_preset.dat b/release/datafiles/blender_icons16/icon16_preset.dat Binary files differindex 52026e95a1a..b56e06b4607 100644 --- a/release/datafiles/blender_icons16/icon16_preset.dat +++ b/release/datafiles/blender_icons16/icon16_preset.dat diff --git a/release/datafiles/blender_icons16/icon16_shaderfx.dat b/release/datafiles/blender_icons16/icon16_shaderfx.dat Binary files differnew file mode 100644 index 00000000000..df43d56ae6a --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_shaderfx.dat diff --git a/release/datafiles/blender_icons16/icon16_tool_settings.dat b/release/datafiles/blender_icons16/icon16_tool_settings.dat Binary files differnew file mode 100644 index 00000000000..1d0d5066024 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_tool_settings.dat diff --git a/release/datafiles/blender_icons32/icon32_decorate.dat b/release/datafiles/blender_icons32/icon32_decorate.dat Binary files differnew file mode 100644 index 00000000000..1ee25791fcb --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_decorate.dat diff --git a/release/datafiles/blender_icons32/icon32_decorate_animate.dat b/release/datafiles/blender_icons32/icon32_decorate_animate.dat Binary files differnew file mode 100644 index 00000000000..a7cedea98e7 --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_decorate_animate.dat diff --git a/release/datafiles/blender_icons32/icon32_decorate_driver.dat b/release/datafiles/blender_icons32/icon32_decorate_driver.dat Binary files differnew file mode 100644 index 00000000000..68a190ba1ea --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_decorate_driver.dat diff --git a/release/datafiles/blender_icons32/icon32_decorate_keyframe.dat b/release/datafiles/blender_icons32/icon32_decorate_keyframe.dat Binary files differnew file mode 100644 index 00000000000..60d2a460b43 --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_decorate_keyframe.dat diff --git a/release/datafiles/blender_icons32/icon32_decorate_linked.dat b/release/datafiles/blender_icons32/icon32_decorate_linked.dat Binary files differnew file mode 100644 index 00000000000..76f6621a617 --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_decorate_linked.dat diff --git a/release/datafiles/blender_icons32/icon32_decorate_locked.dat b/release/datafiles/blender_icons32/icon32_decorate_locked.dat Binary files differnew file mode 100644 index 00000000000..2232f98170f --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_decorate_locked.dat diff --git a/release/datafiles/blender_icons32/icon32_decorate_override.dat b/release/datafiles/blender_icons32/icon32_decorate_override.dat Binary files differnew file mode 100644 index 00000000000..86311d70fde --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_decorate_override.dat diff --git a/release/datafiles/blender_icons32/icon32_decorate_unlocked.dat b/release/datafiles/blender_icons32/icon32_decorate_unlocked.dat Binary files differnew file mode 100644 index 00000000000..cd151b8f306 --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_decorate_unlocked.dat diff --git a/release/datafiles/blender_icons32/icon32_overlay.dat b/release/datafiles/blender_icons32/icon32_overlay.dat Binary files differnew file mode 100644 index 00000000000..3edccff0d5b --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_overlay.dat diff --git a/release/datafiles/blender_icons32/icon32_preset.dat b/release/datafiles/blender_icons32/icon32_preset.dat Binary files differindex 57d5d2536f1..f46bbac8a4d 100644 --- a/release/datafiles/blender_icons32/icon32_preset.dat +++ b/release/datafiles/blender_icons32/icon32_preset.dat diff --git a/release/datafiles/blender_icons32/icon32_shaderfx.dat b/release/datafiles/blender_icons32/icon32_shaderfx.dat Binary files differnew file mode 100644 index 00000000000..2888d09831f --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_shaderfx.dat diff --git a/release/datafiles/blender_icons32/icon32_tool_settings.dat b/release/datafiles/blender_icons32/icon32_tool_settings.dat Binary files differnew file mode 100644 index 00000000000..05680aaa4c6 --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_tool_settings.dat diff --git a/release/datafiles/icons/brush.gpencil.draw.eraser_hard.dat b/release/datafiles/icons/brush.gpencil.draw.eraser_hard.dat Binary files differindex dc3248e21d9..3e1b77e4661 100644 --- a/release/datafiles/icons/brush.gpencil.draw.eraser_hard.dat +++ b/release/datafiles/icons/brush.gpencil.draw.eraser_hard.dat diff --git a/release/datafiles/icons/brush.gpencil.draw.eraser_soft.dat b/release/datafiles/icons/brush.gpencil.draw.eraser_soft.dat Binary files differindex 59690beafdf..777e3aabe40 100644 --- a/release/datafiles/icons/brush.gpencil.draw.eraser_soft.dat +++ b/release/datafiles/icons/brush.gpencil.draw.eraser_soft.dat diff --git a/release/datafiles/icons/brush.gpencil.draw.eraser_stroke.dat b/release/datafiles/icons/brush.gpencil.draw.eraser_stroke.dat Binary files differindex 34297792983..ad9216a2247 100644 --- a/release/datafiles/icons/brush.gpencil.draw.eraser_stroke.dat +++ b/release/datafiles/icons/brush.gpencil.draw.eraser_stroke.dat diff --git a/release/datafiles/icons/brush.gpencil.draw_block.dat b/release/datafiles/icons/brush.gpencil.draw_block.dat Binary files differindex 1364afebdda..fe4175c6d09 100644 --- a/release/datafiles/icons/brush.gpencil.draw_block.dat +++ b/release/datafiles/icons/brush.gpencil.draw_block.dat diff --git a/release/datafiles/icons/brush.gpencil.draw_fill.dat b/release/datafiles/icons/brush.gpencil.draw_fill.dat Binary files differindex 96689cf40d3..82e6f6bbac9 100644 --- a/release/datafiles/icons/brush.gpencil.draw_fill.dat +++ b/release/datafiles/icons/brush.gpencil.draw_fill.dat diff --git a/release/datafiles/icons/brush.gpencil.draw_ink.dat b/release/datafiles/icons/brush.gpencil.draw_ink.dat Binary files differindex d7edb1378ff..3137a3f431a 100644 --- a/release/datafiles/icons/brush.gpencil.draw_ink.dat +++ b/release/datafiles/icons/brush.gpencil.draw_ink.dat diff --git a/release/datafiles/icons/brush.gpencil.draw_marker.dat b/release/datafiles/icons/brush.gpencil.draw_marker.dat Binary files differindex a78e6dff14e..b0b821109a3 100644 --- a/release/datafiles/icons/brush.gpencil.draw_marker.dat +++ b/release/datafiles/icons/brush.gpencil.draw_marker.dat diff --git a/release/datafiles/icons/brush.gpencil.draw_noise.dat b/release/datafiles/icons/brush.gpencil.draw_noise.dat Binary files differindex f2af5b179e0..d29c0624704 100644 --- a/release/datafiles/icons/brush.gpencil.draw_noise.dat +++ b/release/datafiles/icons/brush.gpencil.draw_noise.dat diff --git a/release/datafiles/icons/brush.gpencil.draw_pen.dat b/release/datafiles/icons/brush.gpencil.draw_pen.dat Binary files differindex c21eaea8bc2..d31e2055687 100644 --- a/release/datafiles/icons/brush.gpencil.draw_pen.dat +++ b/release/datafiles/icons/brush.gpencil.draw_pen.dat diff --git a/release/datafiles/icons/brush.gpencil.draw_pencil.dat b/release/datafiles/icons/brush.gpencil.draw_pencil.dat Binary files differindex 2dec6be4d58..4643afc07e5 100644 --- a/release/datafiles/icons/brush.gpencil.draw_pencil.dat +++ b/release/datafiles/icons/brush.gpencil.draw_pencil.dat diff --git a/release/datafiles/icons/brush.paint_texture.airbrush.dat b/release/datafiles/icons/brush.paint_texture.airbrush.dat Binary files differindex 28ab3224ae8..07fb885654e 100644 --- a/release/datafiles/icons/brush.paint_texture.airbrush.dat +++ b/release/datafiles/icons/brush.paint_texture.airbrush.dat diff --git a/release/datafiles/icons/brush.paint_texture.clone.dat b/release/datafiles/icons/brush.paint_texture.clone.dat Binary files differindex 7018a463223..63070e716ba 100644 --- a/release/datafiles/icons/brush.paint_texture.clone.dat +++ b/release/datafiles/icons/brush.paint_texture.clone.dat diff --git a/release/datafiles/icons/brush.paint_texture.draw.dat b/release/datafiles/icons/brush.paint_texture.draw.dat Binary files differindex fe3c9eae237..8aa4d4a1347 100644 --- a/release/datafiles/icons/brush.paint_texture.draw.dat +++ b/release/datafiles/icons/brush.paint_texture.draw.dat diff --git a/release/datafiles/icons/brush.paint_texture.fill.dat b/release/datafiles/icons/brush.paint_texture.fill.dat Binary files differindex 004059e389c..d4089476383 100644 --- a/release/datafiles/icons/brush.paint_texture.fill.dat +++ b/release/datafiles/icons/brush.paint_texture.fill.dat diff --git a/release/datafiles/icons/brush.paint_texture.mask.dat b/release/datafiles/icons/brush.paint_texture.mask.dat Binary files differindex b447ad334ec..a7d6bf0280f 100644 --- a/release/datafiles/icons/brush.paint_texture.mask.dat +++ b/release/datafiles/icons/brush.paint_texture.mask.dat diff --git a/release/datafiles/icons/brush.paint_texture.multiply.dat b/release/datafiles/icons/brush.paint_texture.multiply.dat Binary files differindex 948993203be..308d241f887 100644 --- a/release/datafiles/icons/brush.paint_texture.multiply.dat +++ b/release/datafiles/icons/brush.paint_texture.multiply.dat diff --git a/release/datafiles/icons/brush.paint_texture.smear.dat b/release/datafiles/icons/brush.paint_texture.smear.dat Binary files differindex c9ea7e4e7ce..071776c2ac1 100644 --- a/release/datafiles/icons/brush.paint_texture.smear.dat +++ b/release/datafiles/icons/brush.paint_texture.smear.dat diff --git a/release/datafiles/icons/brush.paint_vertex.alpha.dat b/release/datafiles/icons/brush.paint_vertex.alpha.dat Binary files differindex 4251fc7a911..f16bd8162ec 100644 --- a/release/datafiles/icons/brush.paint_vertex.alpha.dat +++ b/release/datafiles/icons/brush.paint_vertex.alpha.dat diff --git a/release/datafiles/icons/brush.paint_vertex.blur.dat b/release/datafiles/icons/brush.paint_vertex.blur.dat Binary files differindex 72d1ba8637b..4c517526569 100644 --- a/release/datafiles/icons/brush.paint_vertex.blur.dat +++ b/release/datafiles/icons/brush.paint_vertex.blur.dat diff --git a/release/datafiles/icons/brush.paint_vertex.mix.dat b/release/datafiles/icons/brush.paint_vertex.mix.dat Binary files differindex b312034faf8..ac8c3b07141 100644 --- a/release/datafiles/icons/brush.paint_vertex.mix.dat +++ b/release/datafiles/icons/brush.paint_vertex.mix.dat diff --git a/release/datafiles/icons/brush.paint_vertex.smear.dat b/release/datafiles/icons/brush.paint_vertex.smear.dat Binary files differindex 8d351e003c5..8ce6227be11 100644 --- a/release/datafiles/icons/brush.paint_vertex.smear.dat +++ b/release/datafiles/icons/brush.paint_vertex.smear.dat diff --git a/release/datafiles/icons/brush.paint_weight.blur.dat b/release/datafiles/icons/brush.paint_weight.blur.dat Binary files differindex 5b06ce12f4d..8af2e7a2e05 100644 --- a/release/datafiles/icons/brush.paint_weight.blur.dat +++ b/release/datafiles/icons/brush.paint_weight.blur.dat diff --git a/release/datafiles/icons/brush.paint_weight.darken.dat b/release/datafiles/icons/brush.paint_weight.darken.dat Binary files differindex fa89aaa64ad..382ee47b180 100644 --- a/release/datafiles/icons/brush.paint_weight.darken.dat +++ b/release/datafiles/icons/brush.paint_weight.darken.dat diff --git a/release/datafiles/icons/brush.paint_weight.draw.dat b/release/datafiles/icons/brush.paint_weight.draw.dat Binary files differindex 7b7ca278ad9..029654c0ed8 100644 --- a/release/datafiles/icons/brush.paint_weight.draw.dat +++ b/release/datafiles/icons/brush.paint_weight.draw.dat diff --git a/release/datafiles/icons/brush.paint_weight.lighten.dat b/release/datafiles/icons/brush.paint_weight.lighten.dat Binary files differindex 9efd7905161..0621806f077 100644 --- a/release/datafiles/icons/brush.paint_weight.lighten.dat +++ b/release/datafiles/icons/brush.paint_weight.lighten.dat diff --git a/release/datafiles/icons/brush.paint_weight.mix.dat b/release/datafiles/icons/brush.paint_weight.mix.dat Binary files differindex a1da9a90172..0a9fc5b2905 100644 --- a/release/datafiles/icons/brush.paint_weight.mix.dat +++ b/release/datafiles/icons/brush.paint_weight.mix.dat diff --git a/release/datafiles/icons/brush.paint_weight.multiply.dat b/release/datafiles/icons/brush.paint_weight.multiply.dat Binary files differindex 4bfa047f525..dcd6f8bca99 100644 --- a/release/datafiles/icons/brush.paint_weight.multiply.dat +++ b/release/datafiles/icons/brush.paint_weight.multiply.dat diff --git a/release/datafiles/icons/brush.particle.add.dat b/release/datafiles/icons/brush.particle.add.dat Binary files differindex ee785ef7dc6..6cb48f297de 100644 --- a/release/datafiles/icons/brush.particle.add.dat +++ b/release/datafiles/icons/brush.particle.add.dat diff --git a/release/datafiles/icons/brush.particle.comb.dat b/release/datafiles/icons/brush.particle.comb.dat Binary files differindex 39fd44debdc..d00a009217c 100644 --- a/release/datafiles/icons/brush.particle.comb.dat +++ b/release/datafiles/icons/brush.particle.comb.dat diff --git a/release/datafiles/icons/brush.particle.cut.dat b/release/datafiles/icons/brush.particle.cut.dat Binary files differindex 3a62a9c1900..b954629a0da 100644 --- a/release/datafiles/icons/brush.particle.cut.dat +++ b/release/datafiles/icons/brush.particle.cut.dat diff --git a/release/datafiles/icons/brush.particle.length.dat b/release/datafiles/icons/brush.particle.length.dat Binary files differindex 169b8ba6239..59d585e10b8 100644 --- a/release/datafiles/icons/brush.particle.length.dat +++ b/release/datafiles/icons/brush.particle.length.dat diff --git a/release/datafiles/icons/brush.particle.puff.dat b/release/datafiles/icons/brush.particle.puff.dat Binary files differindex e9d626123b1..bf2d78f1a3f 100644 --- a/release/datafiles/icons/brush.particle.puff.dat +++ b/release/datafiles/icons/brush.particle.puff.dat diff --git a/release/datafiles/icons/brush.particle.smooth.dat b/release/datafiles/icons/brush.particle.smooth.dat Binary files differindex 5424bd53ac9..d6fdd7b17b6 100644 --- a/release/datafiles/icons/brush.particle.smooth.dat +++ b/release/datafiles/icons/brush.particle.smooth.dat diff --git a/release/datafiles/icons/brush.particle.weight.dat b/release/datafiles/icons/brush.particle.weight.dat Binary files differindex 75d78e63625..ee14fa4eda5 100644 --- a/release/datafiles/icons/brush.particle.weight.dat +++ b/release/datafiles/icons/brush.particle.weight.dat diff --git a/release/datafiles/icons/brush.sculpt.blob.dat b/release/datafiles/icons/brush.sculpt.blob.dat Binary files differindex 7a89e46b1a2..d9e14dca776 100644 --- a/release/datafiles/icons/brush.sculpt.blob.dat +++ b/release/datafiles/icons/brush.sculpt.blob.dat diff --git a/release/datafiles/icons/brush.sculpt.clay.dat b/release/datafiles/icons/brush.sculpt.clay.dat Binary files differindex 4ac0b436892..ccabd4928ec 100644 --- a/release/datafiles/icons/brush.sculpt.clay.dat +++ b/release/datafiles/icons/brush.sculpt.clay.dat diff --git a/release/datafiles/icons/brush.sculpt.clay_strips.dat b/release/datafiles/icons/brush.sculpt.clay_strips.dat Binary files differindex d0ffde34e79..90356252abd 100644 --- a/release/datafiles/icons/brush.sculpt.clay_strips.dat +++ b/release/datafiles/icons/brush.sculpt.clay_strips.dat diff --git a/release/datafiles/icons/brush.sculpt.crease.dat b/release/datafiles/icons/brush.sculpt.crease.dat Binary files differindex e89ef4c11f8..9a24552932e 100644 --- a/release/datafiles/icons/brush.sculpt.crease.dat +++ b/release/datafiles/icons/brush.sculpt.crease.dat diff --git a/release/datafiles/icons/brush.sculpt.draw.dat b/release/datafiles/icons/brush.sculpt.draw.dat Binary files differindex 299f6033b1c..86a52f1d180 100644 --- a/release/datafiles/icons/brush.sculpt.draw.dat +++ b/release/datafiles/icons/brush.sculpt.draw.dat diff --git a/release/datafiles/icons/brush.sculpt.fill.dat b/release/datafiles/icons/brush.sculpt.fill.dat Binary files differindex 17f2332a10b..71586e9cc6a 100644 --- a/release/datafiles/icons/brush.sculpt.fill.dat +++ b/release/datafiles/icons/brush.sculpt.fill.dat diff --git a/release/datafiles/icons/brush.sculpt.flatten.dat b/release/datafiles/icons/brush.sculpt.flatten.dat Binary files differindex 9aaea1805f8..e4041326d20 100644 --- a/release/datafiles/icons/brush.sculpt.flatten.dat +++ b/release/datafiles/icons/brush.sculpt.flatten.dat diff --git a/release/datafiles/icons/brush.sculpt.grab.dat b/release/datafiles/icons/brush.sculpt.grab.dat Binary files differindex 4f76dfd9200..a9deacd96d7 100644 --- a/release/datafiles/icons/brush.sculpt.grab.dat +++ b/release/datafiles/icons/brush.sculpt.grab.dat diff --git a/release/datafiles/icons/brush.sculpt.inflate.dat b/release/datafiles/icons/brush.sculpt.inflate.dat Binary files differindex 1205282a316..94185909370 100644 --- a/release/datafiles/icons/brush.sculpt.inflate.dat +++ b/release/datafiles/icons/brush.sculpt.inflate.dat diff --git a/release/datafiles/icons/brush.sculpt.layer.dat b/release/datafiles/icons/brush.sculpt.layer.dat Binary files differindex cc19273055b..db515ea511b 100644 --- a/release/datafiles/icons/brush.sculpt.layer.dat +++ b/release/datafiles/icons/brush.sculpt.layer.dat diff --git a/release/datafiles/icons/brush.sculpt.mask.dat b/release/datafiles/icons/brush.sculpt.mask.dat Binary files differindex 7a14f45e468..7ca372c4f2a 100644 --- a/release/datafiles/icons/brush.sculpt.mask.dat +++ b/release/datafiles/icons/brush.sculpt.mask.dat diff --git a/release/datafiles/icons/brush.sculpt.nudge.dat b/release/datafiles/icons/brush.sculpt.nudge.dat Binary files differindex bdf8ee3384c..3ca9e8958d6 100644 --- a/release/datafiles/icons/brush.sculpt.nudge.dat +++ b/release/datafiles/icons/brush.sculpt.nudge.dat diff --git a/release/datafiles/icons/brush.sculpt.pinch.dat b/release/datafiles/icons/brush.sculpt.pinch.dat Binary files differindex 74c533b6743..35831be0808 100644 --- a/release/datafiles/icons/brush.sculpt.pinch.dat +++ b/release/datafiles/icons/brush.sculpt.pinch.dat diff --git a/release/datafiles/icons/brush.sculpt.rotate.dat b/release/datafiles/icons/brush.sculpt.rotate.dat Binary files differindex 206a45f80b4..01eee00e01f 100644 --- a/release/datafiles/icons/brush.sculpt.rotate.dat +++ b/release/datafiles/icons/brush.sculpt.rotate.dat diff --git a/release/datafiles/icons/brush.sculpt.scrape.dat b/release/datafiles/icons/brush.sculpt.scrape.dat Binary files differindex 73f0092a6bd..884b0e89fd3 100644 --- a/release/datafiles/icons/brush.sculpt.scrape.dat +++ b/release/datafiles/icons/brush.sculpt.scrape.dat diff --git a/release/datafiles/icons/brush.sculpt.smooth.dat b/release/datafiles/icons/brush.sculpt.smooth.dat Binary files differindex 7314044c54b..499fe022e21 100644 --- a/release/datafiles/icons/brush.sculpt.smooth.dat +++ b/release/datafiles/icons/brush.sculpt.smooth.dat diff --git a/release/datafiles/icons/brush.sculpt.snake_hook.dat b/release/datafiles/icons/brush.sculpt.snake_hook.dat Binary files differindex c6570d72ac2..c0252f04199 100644 --- a/release/datafiles/icons/brush.sculpt.snake_hook.dat +++ b/release/datafiles/icons/brush.sculpt.snake_hook.dat diff --git a/release/datafiles/icons/brush.sculpt.thumb.dat b/release/datafiles/icons/brush.sculpt.thumb.dat Binary files differindex dd63338c269..c862a0da2c3 100644 --- a/release/datafiles/icons/brush.sculpt.thumb.dat +++ b/release/datafiles/icons/brush.sculpt.thumb.dat diff --git a/release/datafiles/icons/brush.vertex.average.dat b/release/datafiles/icons/brush.vertex.average.dat Binary files differindex 397452cc619..b46c54fd4eb 100644 --- a/release/datafiles/icons/brush.vertex.average.dat +++ b/release/datafiles/icons/brush.vertex.average.dat diff --git a/release/datafiles/icons/brush.weight.add.dat b/release/datafiles/icons/brush.weight.add.dat Binary files differindex addabf9a8d6..6fff2232911 100644 --- a/release/datafiles/icons/brush.weight.add.dat +++ b/release/datafiles/icons/brush.weight.add.dat diff --git a/release/datafiles/icons/brush.weight.subtract.dat b/release/datafiles/icons/brush.weight.subtract.dat Binary files differindex 8f37362c9dd..e0f21056cc8 100644 --- a/release/datafiles/icons/brush.weight.subtract.dat +++ b/release/datafiles/icons/brush.weight.subtract.dat diff --git a/release/datafiles/icons/none.dat b/release/datafiles/icons/none.dat Binary files differindex 9842840ec78..3c25c871428 100644 --- a/release/datafiles/icons/none.dat +++ b/release/datafiles/icons/none.dat diff --git a/release/datafiles/icons/ops.armature.bone.roll.dat b/release/datafiles/icons/ops.armature.bone.roll.dat Binary files differindex f49518cebe4..db5eb1de211 100644 --- a/release/datafiles/icons/ops.armature.bone.roll.dat +++ b/release/datafiles/icons/ops.armature.bone.roll.dat diff --git a/release/datafiles/icons/ops.armature.extrude.cursor.dat b/release/datafiles/icons/ops.armature.extrude.cursor.dat Binary files differindex 92e08821f96..ec8f2432052 100644 --- a/release/datafiles/icons/ops.armature.extrude.cursor.dat +++ b/release/datafiles/icons/ops.armature.extrude.cursor.dat diff --git a/release/datafiles/icons/ops.armature.extrude.dat b/release/datafiles/icons/ops.armature.extrude.dat Binary files differindex 21aca62e332..2194c5bf556 100644 --- a/release/datafiles/icons/ops.armature.extrude.dat +++ b/release/datafiles/icons/ops.armature.extrude.dat diff --git a/release/datafiles/icons/ops.curve.draw.dat b/release/datafiles/icons/ops.curve.draw.dat Binary files differnew file mode 100644 index 00000000000..5622b99a1f3 --- /dev/null +++ b/release/datafiles/icons/ops.curve.draw.dat diff --git a/release/datafiles/icons/ops.curve.dupli_extrude_cursor.dat b/release/datafiles/icons/ops.curve.dupli_extrude_cursor.dat Binary files differnew file mode 100644 index 00000000000..509ca7c9440 --- /dev/null +++ b/release/datafiles/icons/ops.curve.dupli_extrude_cursor.dat diff --git a/release/datafiles/icons/ops.generic.cursor.dat b/release/datafiles/icons/ops.generic.cursor.dat Binary files differindex 75e10579319..10539aaffa7 100644 --- a/release/datafiles/icons/ops.generic.cursor.dat +++ b/release/datafiles/icons/ops.generic.cursor.dat diff --git a/release/datafiles/icons/ops.generic.select_border.dat b/release/datafiles/icons/ops.generic.select_border.dat Binary files differindex b9535bb330a..eed66f3f680 100644 --- a/release/datafiles/icons/ops.generic.select_border.dat +++ b/release/datafiles/icons/ops.generic.select_border.dat diff --git a/release/datafiles/icons/ops.generic.select_circle.dat b/release/datafiles/icons/ops.generic.select_circle.dat Binary files differindex 5a28b67e977..71877f45590 100644 --- a/release/datafiles/icons/ops.generic.select_circle.dat +++ b/release/datafiles/icons/ops.generic.select_circle.dat diff --git a/release/datafiles/icons/ops.generic.select_lasso.dat b/release/datafiles/icons/ops.generic.select_lasso.dat Binary files differindex f1ff760a00b..cfd8a26b527 100644 --- a/release/datafiles/icons/ops.generic.select_lasso.dat +++ b/release/datafiles/icons/ops.generic.select_lasso.dat diff --git a/release/datafiles/icons/ops.gpencil.draw.dat b/release/datafiles/icons/ops.gpencil.draw.dat Binary files differindex 3614d18356a..c15fbc443bd 100644 --- a/release/datafiles/icons/ops.gpencil.draw.dat +++ b/release/datafiles/icons/ops.gpencil.draw.dat diff --git a/release/datafiles/icons/ops.gpencil.draw.eraser.dat b/release/datafiles/icons/ops.gpencil.draw.eraser.dat Binary files differindex 42b7d693898..b25e5b436b8 100644 --- a/release/datafiles/icons/ops.gpencil.draw.eraser.dat +++ b/release/datafiles/icons/ops.gpencil.draw.eraser.dat diff --git a/release/datafiles/icons/ops.gpencil.draw.line.dat b/release/datafiles/icons/ops.gpencil.draw.line.dat Binary files differindex d725b8f5e11..3ae7d347522 100644 --- a/release/datafiles/icons/ops.gpencil.draw.line.dat +++ b/release/datafiles/icons/ops.gpencil.draw.line.dat diff --git a/release/datafiles/icons/ops.gpencil.draw.poly.dat b/release/datafiles/icons/ops.gpencil.draw.poly.dat Binary files differindex 296b7cddd8c..5e28b8c121c 100644 --- a/release/datafiles/icons/ops.gpencil.draw.poly.dat +++ b/release/datafiles/icons/ops.gpencil.draw.poly.dat diff --git a/release/datafiles/icons/ops.gpencil.edit_bend.dat b/release/datafiles/icons/ops.gpencil.edit_bend.dat Binary files differindex 401791a2889..b81b6188cdd 100644 --- a/release/datafiles/icons/ops.gpencil.edit_bend.dat +++ b/release/datafiles/icons/ops.gpencil.edit_bend.dat diff --git a/release/datafiles/icons/ops.gpencil.edit_mirror.dat b/release/datafiles/icons/ops.gpencil.edit_mirror.dat Binary files differindex ee073664f78..6f36f592501 100644 --- a/release/datafiles/icons/ops.gpencil.edit_mirror.dat +++ b/release/datafiles/icons/ops.gpencil.edit_mirror.dat diff --git a/release/datafiles/icons/ops.gpencil.edit_shear.dat b/release/datafiles/icons/ops.gpencil.edit_shear.dat Binary files differindex e6b51f988f8..86e90276754 100644 --- a/release/datafiles/icons/ops.gpencil.edit_shear.dat +++ b/release/datafiles/icons/ops.gpencil.edit_shear.dat diff --git a/release/datafiles/icons/ops.gpencil.edit_to_sphere.dat b/release/datafiles/icons/ops.gpencil.edit_to_sphere.dat Binary files differindex 4b0b2098713..64e5d333a78 100644 --- a/release/datafiles/icons/ops.gpencil.edit_to_sphere.dat +++ b/release/datafiles/icons/ops.gpencil.edit_to_sphere.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_clone.dat b/release/datafiles/icons/ops.gpencil.sculpt_clone.dat Binary files differindex abb6bcb50ed..1e3a499fca4 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_clone.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_clone.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_grab.dat b/release/datafiles/icons/ops.gpencil.sculpt_grab.dat Binary files differindex a9eb4a1c57f..f502f160dc6 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_grab.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_grab.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_pinch.dat b/release/datafiles/icons/ops.gpencil.sculpt_pinch.dat Binary files differindex 0241ddcf314..765dd8d14cf 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_pinch.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_pinch.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_push.dat b/release/datafiles/icons/ops.gpencil.sculpt_push.dat Binary files differindex 101441ab8ba..79c0cb9e744 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_push.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_push.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_randomize.dat b/release/datafiles/icons/ops.gpencil.sculpt_randomize.dat Binary files differindex cfd1e186f61..459167a9df0 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_randomize.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_randomize.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_smooth.dat b/release/datafiles/icons/ops.gpencil.sculpt_smooth.dat Binary files differindex 90ba16d846a..90e93815a34 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_smooth.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_smooth.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_strength.dat b/release/datafiles/icons/ops.gpencil.sculpt_strength.dat Binary files differindex d3f48931831..e526869cb42 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_strength.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_strength.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_thickness.dat b/release/datafiles/icons/ops.gpencil.sculpt_thickness.dat Binary files differindex 1e558806888..f138aaf8559 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_thickness.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_thickness.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_twist.dat b/release/datafiles/icons/ops.gpencil.sculpt_twist.dat Binary files differindex 4ce958cb7ec..34f8eaaf7cf 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_twist.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_twist.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_weight.dat b/release/datafiles/icons/ops.gpencil.sculpt_weight.dat Binary files differindex d5441fcbeb9..b10c79358bb 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_weight.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_weight.dat diff --git a/release/datafiles/icons/ops.mesh.bisect.dat b/release/datafiles/icons/ops.mesh.bisect.dat Binary files differindex d2ac4d8f690..157e6148f7c 100644 --- a/release/datafiles/icons/ops.mesh.bisect.dat +++ b/release/datafiles/icons/ops.mesh.bisect.dat diff --git a/release/datafiles/icons/ops.mesh.dupli_extrude_cursor.dat b/release/datafiles/icons/ops.mesh.dupli_extrude_cursor.dat Binary files differindex 207d1b2bb41..9c2c5efb5da 100644 --- a/release/datafiles/icons/ops.mesh.dupli_extrude_cursor.dat +++ b/release/datafiles/icons/ops.mesh.dupli_extrude_cursor.dat diff --git a/release/datafiles/icons/ops.mesh.extrude_faces_move.dat b/release/datafiles/icons/ops.mesh.extrude_faces_move.dat Binary files differindex 9804188f9e0..59ba065f61e 100644 --- a/release/datafiles/icons/ops.mesh.extrude_faces_move.dat +++ b/release/datafiles/icons/ops.mesh.extrude_faces_move.dat diff --git a/release/datafiles/icons/ops.mesh.extrude_region_shrink_fatten.dat b/release/datafiles/icons/ops.mesh.extrude_region_shrink_fatten.dat Binary files differnew file mode 100644 index 00000000000..75b6e991692 --- /dev/null +++ b/release/datafiles/icons/ops.mesh.extrude_region_shrink_fatten.dat diff --git a/release/datafiles/icons/ops.mesh.knife_tool.dat b/release/datafiles/icons/ops.mesh.knife_tool.dat Binary files differindex bafe16455eb..baa11e44e0e 100644 --- a/release/datafiles/icons/ops.mesh.knife_tool.dat +++ b/release/datafiles/icons/ops.mesh.knife_tool.dat diff --git a/release/datafiles/icons/ops.mesh.loopcut_slide.dat b/release/datafiles/icons/ops.mesh.loopcut_slide.dat Binary files differindex 6278d15e22e..f871f6272b9 100644 --- a/release/datafiles/icons/ops.mesh.loopcut_slide.dat +++ b/release/datafiles/icons/ops.mesh.loopcut_slide.dat diff --git a/release/datafiles/icons/ops.mesh.offset_edge_loops_slide.dat b/release/datafiles/icons/ops.mesh.offset_edge_loops_slide.dat Binary files differindex f4f8728212c..797614ca992 100644 --- a/release/datafiles/icons/ops.mesh.offset_edge_loops_slide.dat +++ b/release/datafiles/icons/ops.mesh.offset_edge_loops_slide.dat diff --git a/release/datafiles/icons/ops.mesh.polybuild_hover.dat b/release/datafiles/icons/ops.mesh.polybuild_hover.dat Binary files differindex 3cd3b1105d1..3c4d326877b 100644 --- a/release/datafiles/icons/ops.mesh.polybuild_hover.dat +++ b/release/datafiles/icons/ops.mesh.polybuild_hover.dat diff --git a/release/datafiles/icons/ops.mesh.primitive_cone_add_gizmo.dat b/release/datafiles/icons/ops.mesh.primitive_cone_add_gizmo.dat Binary files differnew file mode 100644 index 00000000000..b416a693283 --- /dev/null +++ b/release/datafiles/icons/ops.mesh.primitive_cone_add_gizmo.dat diff --git a/release/datafiles/icons/ops.mesh.primitive_cone_add_manipulator.dat b/release/datafiles/icons/ops.mesh.primitive_cone_add_manipulator.dat Binary files differdeleted file mode 100644 index 70357be26db..00000000000 --- a/release/datafiles/icons/ops.mesh.primitive_cone_add_manipulator.dat +++ /dev/null diff --git a/release/datafiles/icons/ops.mesh.primitive_cube_add_gizmo.dat b/release/datafiles/icons/ops.mesh.primitive_cube_add_gizmo.dat Binary files differnew file mode 100644 index 00000000000..39ebdecb5c3 --- /dev/null +++ b/release/datafiles/icons/ops.mesh.primitive_cube_add_gizmo.dat diff --git a/release/datafiles/icons/ops.mesh.primitive_cube_add_manipulator.dat b/release/datafiles/icons/ops.mesh.primitive_cube_add_manipulator.dat Binary files differdeleted file mode 100644 index c3d734f13b6..00000000000 --- a/release/datafiles/icons/ops.mesh.primitive_cube_add_manipulator.dat +++ /dev/null diff --git a/release/datafiles/icons/ops.mesh.primitive_cylinder_add_gizmo.dat b/release/datafiles/icons/ops.mesh.primitive_cylinder_add_gizmo.dat Binary files differnew file mode 100644 index 00000000000..5033ac2d477 --- /dev/null +++ b/release/datafiles/icons/ops.mesh.primitive_cylinder_add_gizmo.dat diff --git a/release/datafiles/icons/ops.mesh.primitive_cylinder_add_manipulator.dat b/release/datafiles/icons/ops.mesh.primitive_cylinder_add_manipulator.dat Binary files differdeleted file mode 100644 index b67ff32a5a8..00000000000 --- a/release/datafiles/icons/ops.mesh.primitive_cylinder_add_manipulator.dat +++ /dev/null diff --git a/release/datafiles/icons/ops.mesh.primitive_grid_add_gizmo.dat b/release/datafiles/icons/ops.mesh.primitive_grid_add_gizmo.dat Binary files differnew file mode 100644 index 00000000000..6a6e9aa0cee --- /dev/null +++ b/release/datafiles/icons/ops.mesh.primitive_grid_add_gizmo.dat diff --git a/release/datafiles/icons/ops.mesh.primitive_grid_add_manipulator.dat b/release/datafiles/icons/ops.mesh.primitive_grid_add_manipulator.dat Binary files differdeleted file mode 100644 index cc0f323d93d..00000000000 --- a/release/datafiles/icons/ops.mesh.primitive_grid_add_manipulator.dat +++ /dev/null diff --git a/release/datafiles/icons/ops.mesh.primitive_sphere_add_gizmo.dat b/release/datafiles/icons/ops.mesh.primitive_sphere_add_gizmo.dat Binary files differnew file mode 100644 index 00000000000..16d1a7346f2 --- /dev/null +++ b/release/datafiles/icons/ops.mesh.primitive_sphere_add_gizmo.dat diff --git a/release/datafiles/icons/ops.mesh.primitive_sphere_add_manipulator.dat b/release/datafiles/icons/ops.mesh.primitive_sphere_add_manipulator.dat Binary files differdeleted file mode 100644 index b807435e547..00000000000 --- a/release/datafiles/icons/ops.mesh.primitive_sphere_add_manipulator.dat +++ /dev/null diff --git a/release/datafiles/icons/ops.mesh.primitive_torus_add_gizmo.dat b/release/datafiles/icons/ops.mesh.primitive_torus_add_gizmo.dat Binary files differnew file mode 100644 index 00000000000..7323e6f4c30 --- /dev/null +++ b/release/datafiles/icons/ops.mesh.primitive_torus_add_gizmo.dat diff --git a/release/datafiles/icons/ops.mesh.primitive_torus_add_manipulator.dat b/release/datafiles/icons/ops.mesh.primitive_torus_add_manipulator.dat Binary files differdeleted file mode 100644 index f441bbb65c1..00000000000 --- a/release/datafiles/icons/ops.mesh.primitive_torus_add_manipulator.dat +++ /dev/null diff --git a/release/datafiles/icons/ops.mesh.rip.dat b/release/datafiles/icons/ops.mesh.rip.dat Binary files differindex 84a3f0ca018..1f1241907cf 100644 --- a/release/datafiles/icons/ops.mesh.rip.dat +++ b/release/datafiles/icons/ops.mesh.rip.dat diff --git a/release/datafiles/icons/ops.mesh.rip_edge.dat b/release/datafiles/icons/ops.mesh.rip_edge.dat Binary files differindex f6587e0de13..d75f9822b80 100644 --- a/release/datafiles/icons/ops.mesh.rip_edge.dat +++ b/release/datafiles/icons/ops.mesh.rip_edge.dat diff --git a/release/datafiles/icons/ops.mesh.spin.dat b/release/datafiles/icons/ops.mesh.spin.dat Binary files differindex 9419a5fe16b..f31fc7fff57 100644 --- a/release/datafiles/icons/ops.mesh.spin.dat +++ b/release/datafiles/icons/ops.mesh.spin.dat diff --git a/release/datafiles/icons/ops.mesh.spin.duplicate.dat b/release/datafiles/icons/ops.mesh.spin.duplicate.dat Binary files differindex 4142b9fb4be..711df60e025 100644 --- a/release/datafiles/icons/ops.mesh.spin.duplicate.dat +++ b/release/datafiles/icons/ops.mesh.spin.duplicate.dat diff --git a/release/datafiles/icons/ops.paint.vertex_color_fill.dat b/release/datafiles/icons/ops.paint.vertex_color_fill.dat Binary files differindex 78189bd97ac..79ccbd32d63 100644 --- a/release/datafiles/icons/ops.paint.vertex_color_fill.dat +++ b/release/datafiles/icons/ops.paint.vertex_color_fill.dat diff --git a/release/datafiles/icons/ops.paint.weight_fill.dat b/release/datafiles/icons/ops.paint.weight_fill.dat Binary files differindex fed0f14f905..7e981715552 100644 --- a/release/datafiles/icons/ops.paint.weight_fill.dat +++ b/release/datafiles/icons/ops.paint.weight_fill.dat diff --git a/release/datafiles/icons/ops.paint.weight_gradient.dat b/release/datafiles/icons/ops.paint.weight_gradient.dat Binary files differindex e3d73c83719..5e9dbbcbb06 100644 --- a/release/datafiles/icons/ops.paint.weight_gradient.dat +++ b/release/datafiles/icons/ops.paint.weight_gradient.dat diff --git a/release/datafiles/icons/ops.sculpt.border_hide.dat b/release/datafiles/icons/ops.sculpt.border_hide.dat Binary files differindex ca2f5b8405a..c8a03286887 100644 --- a/release/datafiles/icons/ops.sculpt.border_hide.dat +++ b/release/datafiles/icons/ops.sculpt.border_hide.dat diff --git a/release/datafiles/icons/ops.sculpt.border_mask.dat b/release/datafiles/icons/ops.sculpt.border_mask.dat Binary files differindex 3a2819168d3..14ba327f38a 100644 --- a/release/datafiles/icons/ops.sculpt.border_mask.dat +++ b/release/datafiles/icons/ops.sculpt.border_mask.dat diff --git a/release/datafiles/icons/ops.transform.edge_slide.dat b/release/datafiles/icons/ops.transform.edge_slide.dat Binary files differindex 6b0a58d4c76..60581f89283 100644 --- a/release/datafiles/icons/ops.transform.edge_slide.dat +++ b/release/datafiles/icons/ops.transform.edge_slide.dat diff --git a/release/datafiles/icons/ops.transform.resize.cage.dat b/release/datafiles/icons/ops.transform.resize.cage.dat Binary files differindex 8eabffad087..e956db71854 100644 --- a/release/datafiles/icons/ops.transform.resize.cage.dat +++ b/release/datafiles/icons/ops.transform.resize.cage.dat diff --git a/release/datafiles/icons/ops.transform.shear.dat b/release/datafiles/icons/ops.transform.shear.dat Binary files differnew file mode 100644 index 00000000000..92912e2cfb7 --- /dev/null +++ b/release/datafiles/icons/ops.transform.shear.dat diff --git a/release/datafiles/icons/ops.transform.shrink_fatten.dat b/release/datafiles/icons/ops.transform.shrink_fatten.dat Binary files differindex 8d1d4c130a4..a26cc2b3115 100644 --- a/release/datafiles/icons/ops.transform.shrink_fatten.dat +++ b/release/datafiles/icons/ops.transform.shrink_fatten.dat diff --git a/release/datafiles/icons/ops.transform.tosphere.dat b/release/datafiles/icons/ops.transform.tosphere.dat Binary files differnew file mode 100644 index 00000000000..b0dc7457b10 --- /dev/null +++ b/release/datafiles/icons/ops.transform.tosphere.dat diff --git a/release/datafiles/icons/ops.transform.vert_slide.dat b/release/datafiles/icons/ops.transform.vert_slide.dat Binary files differindex b0846e25f5e..fd226a021c2 100644 --- a/release/datafiles/icons/ops.transform.vert_slide.dat +++ b/release/datafiles/icons/ops.transform.vert_slide.dat diff --git a/release/scripts/addons b/release/scripts/addons -Subproject 5e7415063426f8c03ef53edc2b412f657279876 +Subproject b5a35bbd39af54dee33fc5ea039e49e6e9f450a diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 96193b047c6..fd5dd884b44 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -157,11 +157,11 @@ class WindowManager(bpy_types.ID): try: draw_func(popup, bpy.context) finally: - self.popover_end__internal(popup, keymap) + self.popover_end__internal(popup, keymap=keymap) def popup_menu_pie(self, event, draw_func, title="", icon='NONE'): import bpy - pie = self.piemenu_begin__internal(title, icon, event) + pie = self.piemenu_begin__internal(title, icon=icon, event=event) if pie: try: @@ -848,7 +848,7 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): layout = self.layout if not searchpaths: - layout.label("* Missing Paths *") + layout.label(text="* Missing Paths *") # collect paths files = [] diff --git a/release/scripts/modules/bpyml.py b/release/scripts/modules/bpyml.py index 3cdbf848a24..d7f03a3f0c1 100644 --- a/release/scripts/modules/bpyml.py +++ b/release/scripts/modules/bpyml.py @@ -182,7 +182,7 @@ if __name__ == "__main__": prop(data='context.scene.render', property='stamp_font_size', text='Font Size') ] ], - split(percentage=0.2)[ + split(factor=0.2)[ prop(data='context.scene.render', property='use_stamp_note', text='Note'), row()[ active(expr='context.scene.render.use_stamp_note'), diff --git a/release/scripts/modules/rna_keymap_ui.py b/release/scripts/modules/rna_keymap_ui.py index e151a81913b..776d2d81d98 100644 --- a/release/scripts/modules/rna_keymap_ui.py +++ b/release/scripts/modules/rna_keymap_ui.py @@ -39,7 +39,7 @@ def _indented_layout(layout, level): level = 0.0001 # Tweak so that a percentage of 0 won't split by half indent = level * indentpx / bpy.context.region.width - split = layout.split(percentage=indent) + split = layout.split(factor=indent) col = split.column() col = split.column() return col @@ -103,7 +103,7 @@ def draw_km(display_keymaps, kc, km, children, layout, level): # "Add New" at end of keymap item list subcol = _indented_layout(col, kmi_level) - subcol = subcol.split(percentage=0.2).column() + subcol = subcol.split(factor=0.2).column() subcol.operator("wm.keyitem_add", text="Add New", text_ctxt=i18n_contexts.id_windowmanager, icon='ZOOMIN') @@ -167,7 +167,7 @@ def draw_kmi(display_keymaps, kc, km, kmi, layout, level): if kmi.show_expanded: box = col.box() - split = box.split(percentage=0.4) + split = box.split(factor=0.4) sub = split.row() if km.is_modal: @@ -349,7 +349,7 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout): # "Add New" at end of keymap item list col = _indented_layout(layout, 1) - subcol = col.split(percentage=0.2).column() + subcol = col.split(factor=0.2).column() subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN') return True @@ -386,7 +386,7 @@ def draw_keymaps(context, layout): # layout.context_pointer_set("keyconfig", wm.keyconfigs.active) # row.operator("wm.keyconfig_remove", text="", icon='X') row.separator() - rowsub = row.split(align=True, percentage=0.33) + rowsub = row.split(factor=0.33, align=True) # postpone drawing into rowsub, so we can set alert! col.separator() diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 0d17c11456e..c987609bafa 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -165,7 +165,7 @@ def draw(layout, context, context_member, property_type, use_edit=True): box = row.box() if use_edit: - split = box.split(percentage=0.75) + split = box.split(factor=0.75) row = split.row(align=True) else: row = box.row(align=True) @@ -214,7 +214,7 @@ class PropertyPanel: rna_item, context_member = rna_idprop_context_value(context, self._context_path, self._property_type) tot = len(rna_item.keys()) if tot: - self.layout().label("%d:" % tot) + self.layout().label(text="%d:" % tot) """ def draw(self, context): diff --git a/release/scripts/presets/keyconfig/3dsmax.py b/release/scripts/presets/keyconfig/3dsmax.py index 8bce68a0a30..fa5d40b1868 100644 --- a/release/scripts/presets/keyconfig/3dsmax.py +++ b/release/scripts/presets/keyconfig/3dsmax.py @@ -11,7 +11,7 @@ kmi = km.keymap_items.new('wm.window_new', 'W', 'PRESS', ctrl=True, alt=True) kmi = km.keymap_items.new('wm.read_homefile', 'N', 'PRESS', ctrl=True) kmi = km.keymap_items.new('wm.save_homefile', 'U', 'PRESS', ctrl=True) kmi = km.keymap_items.new('wm.call_menu', 'O', 'PRESS', shift=True, ctrl=True) -kmi.properties.name = 'INFO_MT_file_open_recent' +kmi.properties.name = 'TOPBAR_MT_file_open_recent' kmi = km.keymap_items.new('wm.open_mainfile', 'O', 'PRESS', ctrl=True) kmi = km.keymap_items.new('wm.open_mainfile', 'F1', 'PRESS') kmi = km.keymap_items.new('wm.link', 'O', 'PRESS', ctrl=True, alt=True) @@ -214,7 +214,7 @@ km = kc.keymaps.new('Pose', space_type='EMPTY', region_type='WINDOW', modal=Fals kmi = km.keymap_items.new('object.parent_set', 'P', 'PRESS', ctrl=True) kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi.properties.name = 'INFO_MT_add' +kmi.properties.name = 'VIEW3D_MT_add' kmi = km.keymap_items.new('pose.hide', 'H', 'PRESS') kmi.properties.unselected = False kmi = km.keymap_items.new('pose.hide', 'H', 'PRESS', shift=True) @@ -333,7 +333,7 @@ kmi = km.keymap_items.new('object.delete', 'DEL', 'PRESS') kmi = km.keymap_items.new('object.delete', 'DEL', 'PRESS', shift=True) kmi.properties.use_global = True kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi.properties.name = 'INFO_MT_add' +kmi.properties.name = 'VIEW3D_MT_add' kmi = km.keymap_items.new('object.duplicates_make_real', 'A', 'PRESS', shift=True, ctrl=True) kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True, ctrl=True) kmi.properties.name = 'VIEW3D_MT_object_apply' @@ -2157,7 +2157,7 @@ kmi = km.keymap_items.new('transform.shrink_fatten', 'S', 'PRESS', alt=True) kmi = km.keymap_items.new('mesh.edge_face_add', 'F', 'PRESS', ctrl=True) kmi = km.keymap_items.new('mesh.duplicate_move', 'D', 'PRESS', shift=True) kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi.properties.name = 'INFO_MT_mesh_add' +kmi.properties.name = 'VIEW3D_MT_mesh_add' kmi = km.keymap_items.new('mesh.separate', 'P', 'PRESS') kmi = km.keymap_items.new('mesh.split', 'Y', 'PRESS') kmi = km.keymap_items.new('mesh.vert_connect', 'J', 'PRESS') @@ -2227,7 +2227,7 @@ kmi.properties.value = '(False,False,True)' km = kc.keymaps.new('Curve', space_type='EMPTY', region_type='WINDOW', modal=False) kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi.properties.name = 'INFO_MT_edit_curve_add' +kmi.properties.name = 'TOPBAR_MT_edit_curve_add' kmi = km.keymap_items.new('curve.handle_type_set', 'V', 'PRESS') kmi = km.keymap_items.new('curve.vertex_add', 'LEFTMOUSE', 'CLICK', ctrl=True) kmi = km.keymap_items.new('curve.select_all', 'LEFTMOUSE', 'CLICK') diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py index c71b7456cff..cf736e1a5a5 100644 --- a/release/scripts/presets/keyconfig/blender_27x.py +++ b/release/scripts/presets/keyconfig/blender_27x.py @@ -8,7 +8,7 @@ keyconfig_data = \ ("wm.call_menu", {"type": 'O', "value": 'PRESS', "shift": True, "ctrl": True}, {"properties": - [("name", 'INFO_MT_file_open_recent'), + [("name", 'TOPBAR_MT_file_open_recent'), ], }, ), @@ -1020,7 +1020,7 @@ keyconfig_data = \ ("wm.call_menu", {"type": 'A', "value": 'PRESS', "shift": True}, {"properties": - [("name", 'INFO_MT_add'), + [("name", 'VIEW3D_MT_add'), ], }, ), @@ -1321,7 +1321,7 @@ keyconfig_data = \ ("wm.call_menu", {"type": 'A', "value": 'PRESS', "shift": True}, {"properties": - [("name", 'INFO_MT_add'), + [("name", 'VIEW3D_MT_add'), ], }, ), @@ -1460,7 +1460,7 @@ keyconfig_data = \ [("wm.call_menu", {"type": 'A', "value": 'PRESS', "shift": True}, {"properties": - [("name", 'INFO_MT_edit_curve_add'), + [("name", 'TOPBAR_MT_edit_curve_add'), ], }, ), @@ -3249,7 +3249,7 @@ keyconfig_data = \ ("wm.call_menu", {"type": 'A', "value": 'PRESS', "shift": True}, {"properties": - [("name", 'INFO_MT_mesh_add'), + [("name", 'VIEW3D_MT_mesh_add'), ], }, ), diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index da1446f6f43..676ccb8bec3 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -12,7 +12,7 @@ kmi = km.keymap_items.new('wm.window_new', 'W', 'PRESS', ctrl=True, alt=True) kmi = km.keymap_items.new('wm.read_homefile', 'N', 'PRESS', ctrl=True) kmi = km.keymap_items.new('wm.save_homefile', 'U', 'PRESS', ctrl=True) kmi = km.keymap_items.new('wm.call_menu', 'O', 'PRESS', shift=True, ctrl=True) -kmi.properties.name = 'INFO_MT_file_open_recent' +kmi.properties.name = 'TOPBAR_MT_file_open_recent' kmi = km.keymap_items.new('wm.open_mainfile', 'O', 'PRESS', ctrl=True) kmi = km.keymap_items.new('wm.open_mainfile', 'F1', 'PRESS') kmi = km.keymap_items.new('wm.link', 'O', 'PRESS', ctrl=True, alt=True) @@ -274,7 +274,7 @@ km = kc.keymaps.new('Pose', space_type='EMPTY', region_type='WINDOW', modal=Fals kmi = km.keymap_items.new('object.parent_set', 'P', 'PRESS') kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi.properties.name = 'INFO_MT_add' +kmi.properties.name = 'VIEW3D_MT_add' kmi = km.keymap_items.new('pose.hide', 'H', 'PRESS', ctrl=True) kmi.properties.unselected = False kmi = km.keymap_items.new('pose.hide', 'H', 'PRESS', alt=True) @@ -383,7 +383,7 @@ kmi.properties.unselected = True kmi = km.keymap_items.new('object.delete', 'BACK_SPACE', 'PRESS') kmi = km.keymap_items.new('object.delete', 'DEL', 'PRESS') kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi.properties.name = 'INFO_MT_add' +kmi.properties.name = 'VIEW3D_MT_add' kmi = km.keymap_items.new('object.duplicates_make_real', 'A', 'PRESS', shift=True, ctrl=True) kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', ctrl=True, alt=True) kmi.properties.name = 'VIEW3D_MT_object_apply' @@ -650,7 +650,7 @@ kmi = km.keymap_items.new('mesh.merge', 'M', 'PRESS', alt=True) kmi = km.keymap_items.new('mesh.edge_face_add', 'F', 'PRESS', alt=True) kmi = km.keymap_items.new('mesh.duplicate_move', 'D', 'PRESS', ctrl=True) kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi.properties.name = 'INFO_MT_mesh_add' +kmi.properties.name = 'VIEW3D_MT_mesh_add' kmi = km.keymap_items.new('mesh.dupli_extrude_cursor', 'MIDDLEMOUSE', 'CLICK', ctrl=True) kmi = km.keymap_items.new('wm.call_menu', 'BACK_SPACE', 'PRESS') kmi.properties.name = 'VIEW3D_MT_edit_mesh_delete' @@ -720,7 +720,7 @@ kmi = km.keymap_items.new_modal('CUT_THROUGH_TOGGLE', 'Z', 'PRESS') km = kc.keymaps.new('Curve', space_type='EMPTY', region_type='WINDOW', modal=False) kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) -kmi.properties.name = 'INFO_MT_edit_curve_add' +kmi.properties.name = 'TOPBAR_MT_edit_curve_add' kmi = km.keymap_items.new('curve.handle_type_set', 'RIGHTMOUSE', 'PRESS') kmi = km.keymap_items.new('curve.vertex_add', 'MIDDLEMOUSE', 'CLICK', ctrl=True) kmi = km.keymap_items.new('curve.select_all', 'A', 'PRESS', ctrl=True) diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index c9499388449..3c9fc012eeb 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -674,14 +674,16 @@ class CLIP_OT_setup_tracking_scene(Operator): # rendersettings setup_collection_recursively( - vlayers["Foreground"].collections[0].children, - "background", - "holdout") + vlayers["Foreground"].collections[0].children, + "background", + "holdout", + ) setup_collection_recursively( - vlayers["Background"].collections[0].children, - "foreground", - "indirect_only") + vlayers["Background"].collections[0].children, + "foreground", + "indirect_only", + ) @staticmethod def _wipeDefaultNodes(tree): diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 28e5e59d780..caf5937cc95 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -103,7 +103,7 @@ class EditExternally(Operator): return {'CANCELLED'} if sd.type == 'IMAGE_EDITOR': - filepath = image.filepath_from_user(sd.image_user) + filepath = image.filepath_from_user(image_user=sd.image_user) else: filepath = image.filepath diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index feb6788349b..73adf56cfd3 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -43,7 +43,6 @@ _modules = [ "properties_data_shaderfx", "properties_data_lightprobe", "properties_data_speaker", - "properties_data_workspace", "properties_mask_common", "properties_material", "properties_material_gpencil", @@ -92,6 +91,9 @@ _modules = [ "space_userpref", "space_view3d", "space_view3d_toolbar", + + # XXX, keep last so panels show after all other tool options. + "properties_workspace", ] import bpy diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py index 352b96c6431..76b87a9011d 100644 --- a/release/scripts/startup/bl_ui/properties_constraint.py +++ b/release/scripts/startup/bl_ui/properties_constraint.py @@ -42,7 +42,7 @@ class ConstraintButtonsPanel: def space_template(layout, con, target=True, owner=True): if target or owner: - split = layout.split(percentage=0.2) + split = layout.split(factor=0.2) split.label(text="Space:") row = split.row() @@ -85,7 +85,7 @@ class ConstraintButtonsPanel: row.label() row.prop(con, "pole_angle") - split = layout.split(percentage=0.33) + split = layout.split(factor=0.33) col = split.column() col.prop(con, "use_tail") col.prop(con, "use_stretch") @@ -183,12 +183,12 @@ class ConstraintButtonsPanel: row = layout.row() row.label(text="Axis Ref:") row.prop(con, "reference_axis", expand=True) - split = layout.split(percentage=0.33) + split = layout.split(factor=0.33) split.row().prop(con, "use_location") row = split.row() row.prop(con, "weight", text="Weight", slider=True) row.active = con.use_location - split = layout.split(percentage=0.33) + split = layout.split(factor=0.33) row = split.row() row.label(text="Lock:") row = split.row() @@ -197,12 +197,12 @@ class ConstraintButtonsPanel: row.prop(con, "lock_location_z", text="Z") split.active = con.use_location - split = layout.split(percentage=0.33) + split = layout.split(factor=0.33) split.row().prop(con, "use_rotation") row = split.row() row.prop(con, "orient_weight", text="Weight", slider=True) row.active = con.use_rotation - split = layout.split(percentage=0.33) + split = layout.split(factor=0.33) row = split.row() row.label(text="Lock:") row = split.row() @@ -420,7 +420,7 @@ class ConstraintButtonsPanel: row.prop(con, "use_y", text="Y") row.prop(con, "use_z", text="Z") - row= layout.row() + row = layout.row() row.prop(con, "use_offset") row = row.row() row.active = con.use_offset @@ -751,7 +751,7 @@ class ConstraintButtonsPanel: if con.shrinkwrap_type == 'PROJECT': row = layout.row(align=True) row.prop(con, "project_axis", expand=True) - split = layout.split(percentage=0.4) + split = layout.split(factor=0.4) split.label(text="Axis Space:") rowsub = split.row() rowsub.prop(con, "project_axis_space", text="") @@ -898,7 +898,7 @@ class ConstraintButtonsPanel: box.prop_search(con, "object_path", cache_file, "object_paths") def SCRIPT(self, context, layout, con): - layout.label("Blender 2.6 doesn't support python constraints yet") + layout.label(text="Blender 2.6 doesn't support python constraints yet") class OBJECT_PT_constraints(ConstraintButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index f7517f34d61..0ecce3b2f78 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -251,7 +251,7 @@ class DATA_PT_camera_dof_aperture(CameraButtonsPanel, Panel): col.prop(dof_options, "ratio") else: col = flow.column() - col.label("Viewport") + col.label(text="Viewport") col.prop(dof_options, "fstop") col.prop(dof_options, "blades") @@ -289,10 +289,13 @@ class DATA_PT_camera_background_image(CameraButtonsPanel, Panel): else: row.label(text="Not Set") - if bg.show_background_image: - row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF') - else: - row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON') + row.prop( + bg, + "show_background_image", + text="", + emboss=False, + icon='RESTRICT_VIEW_OFF' if bg.show_background_image else 'RESTRICT_VIEW_ON', + ) row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index 4002568fb7d..671cff4ebb4 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -328,16 +328,16 @@ class DATA_PT_font(CurveButtonsPanelText, Panel): text = context.curve char = context.curve.edit_format - row = layout.split(percentage=0.25) + row = layout.split(factor=0.25) row.label(text="Regular") row.template_ID(text, "font", open="font.open", unlink="font.unlink") - row = layout.split(percentage=0.25) + row = layout.split(factor=0.25) row.label(text="Bold") row.template_ID(text, "font_bold", open="font.open", unlink="font.unlink") - row = layout.split(percentage=0.25) + row = layout.split(factor=0.25) row.label(text="Italic") row.template_ID(text, "font_italic", open="font.open", unlink="font.unlink") - row = layout.split(percentage=0.25) + row = layout.split(factor=0.25) row.label(text="Bold & Italic") row.template_ID(text, "font_bold_italic", open="font.open", unlink="font.unlink") diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py index a63a8e10c08..8230047657b 100644 --- a/release/scripts/startup/bl_ui/properties_data_gpencil.py +++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py @@ -124,6 +124,9 @@ class GPENCIL_MT_layer_specials(Menu): layout.operator("gpencil.layer_merge", icon='NLA', text="Merge Down") + layout.separator() + layout.menu("VIEW3D_MT_gpencil_copy_layer") + class DATA_PT_gpencil_datapanel(Panel): bl_space_type = 'PROPERTIES' @@ -268,7 +271,7 @@ class DATA_PT_gpencil_onionpanel(Panel): layout.enabled = gpd.use_onion_skinning and gpd.users <= 1 if gpd.use_onion_skinning and gpd.users > 1: - layout.label("Multiuser datablock not supported", icon='ERROR') + layout.label(text="Multiuser datablock not supported", icon='ERROR') GreasePencilOnionPanel.draw_settings(layout, gpd) diff --git a/release/scripts/startup/bl_ui/properties_data_lattice.py b/release/scripts/startup/bl_ui/properties_data_lattice.py index 9aa8a4dee64..c18fd30b128 100644 --- a/release/scripts/startup/bl_ui/properties_data_lattice.py +++ b/release/scripts/startup/bl_ui/properties_data_lattice.py @@ -43,7 +43,7 @@ class DATA_PT_context_lattice(DataButtonsPanel, Panel): lat = context.lattice space = context.space_data - split = layout.split(percentage=0.65) + split = layout.split(factor=0.65) if ob: split.template_ID(ob, "data") split.separator() diff --git a/release/scripts/startup/bl_ui/properties_data_lightprobe.py b/release/scripts/startup/bl_ui/properties_data_lightprobe.py index 5924a796b65..4faf1fcef3d 100644 --- a/release/scripts/startup/bl_ui/properties_data_lightprobe.py +++ b/release/scripts/startup/bl_ui/properties_data_lightprobe.py @@ -65,7 +65,7 @@ class DATA_PT_lightprobe(DataButtonsPanel, Panel): if probe.type == 'GRID': col = layout.column() - col.prop(probe, "influence_distance", "Distance") + col.prop(probe, "influence_distance", text="Distance") col.prop(probe, "falloff") col.prop(probe, "intensity") @@ -77,16 +77,15 @@ class DATA_PT_lightprobe(DataButtonsPanel, Panel): elif probe.type == 'PLANAR': col = layout.column() - col.prop(probe, "influence_distance", "Distance") - col.prop(probe, "falloff") + col.prop(probe, "influence_distance", text="Distance") else: col = layout.column() col.prop(probe, "influence_type") if probe.influence_type == 'ELIPSOID': - col.prop(probe, "influence_distance", "Radius") + col.prop(probe, "influence_distance", text="Radius") else: - col.prop(probe, "influence_distance", "Size") + col.prop(probe, "influence_distance", text="Size") col.prop(probe, "falloff") col.prop(probe, "intensity") @@ -100,10 +99,10 @@ class DATA_PT_lightprobe(DataButtonsPanel, Panel): if probe.type == 'GRID': col.separator() - col.label("Visibility") - col.prop(probe, "visibility_buffer_bias", "Bias") - col.prop(probe, "visibility_bleed_bias", "Bleed Bias") - col.prop(probe, "visibility_blur", "Blur") + col.label(text="Visibility") + col.prop(probe, "visibility_buffer_bias", text="Bias") + col.prop(probe, "visibility_bleed_bias", text="Bleed Bias") + col.prop(probe, "visibility_blur", text="Blur") col.separator() @@ -137,9 +136,9 @@ class DATA_PT_lightprobe_parallax(DataButtonsPanel, Panel): col.prop(probe, "parallax_type") if probe.parallax_type == 'ELIPSOID': - col.prop(probe, "parallax_distance", "Radius") + col.prop(probe, "parallax_distance", text="Radius") else: - col.prop(probe, "parallax_distance", "Size") + col.prop(probe, "parallax_distance", text="Size") class DATA_PT_lightprobe_display(DataButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index f096ff83957..d455b56b3f4 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -92,7 +92,7 @@ class MESH_UL_shape_keys(UIList): # key = data key_block = item if self.layout_type in {'DEFAULT', 'COMPACT'}: - split = layout.split(0.66, False) + split = layout.split(factor=0.66, align=False) split.prop(key_block, "name", text="", emboss=False, icon_value=icon) row = split.row(align=True) if key_block.mute or (obj.mode == 'EDIT' and not (obj.use_shape_key_edit_mode and obj.type == 'MESH')): @@ -326,7 +326,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel): sub.operator("object.shape_key_move", icon='TRIA_UP', text="").type = 'UP' sub.operator("object.shape_key_move", icon='TRIA_DOWN', text="").type = 'DOWN' - split = layout.split(percentage=0.4) + split = layout.split(factor=0.4) row = split.row() row.enabled = enable_edit row.prop(key, "use_relative") diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 20fc6674e55..79113e3c13a 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -164,7 +164,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.prop(md, "hn_strength") layout.prop(md, "set_wn_strength") - def BOOLEAN(self, layout, ob, md): split = layout.split() @@ -230,12 +229,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.prop(md, "eval_factor") layout.label(text="Axis Mapping:") - split = layout.split(percentage=0.5, align=True) + split = layout.split(factor=0.5, align=True) split.alert = (md.forward_axis[-1] == md.up_axis[-1]) - split.label("Forward/Up Axis:") + split.label(text="Forward/Up Axis:") split.prop(md, "forward_axis", text="") split.prop(md, "up_axis", text="") - split = layout.split(percentage=0.5) + split = layout.split(factor=0.5) split.label(text="Flip Axis:") row = split.row() row.prop(md, "flip_axis") @@ -257,12 +256,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): box.row().prop(md, "read_data") def CAST(self, layout, ob, md): - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) split.label(text="Cast Type:") split.prop(md, "cast_type", text="") - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) col = split.column() col.prop(md, "use_x") @@ -329,7 +328,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "vertex_group_factor") col.prop(md, "use_collapse_triangulate") - row = col.split(percentage=0.75) + row = col.split(factor=0.75) row.prop(md, "use_symmetry") row.prop(md, "symmetry_axis", text="") @@ -339,7 +338,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): else: # decimate_type == 'DISSOLVE': layout.prop(md, "angle_limit") layout.prop(md, "use_dissolve_boundaries") - layout.label("Delimit:") + layout.label(text="Delimit:") row = layout.row() row.prop(md, "delimit") layout_info = layout @@ -488,7 +487,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): def LAPLACIANSMOOTH(self, layout, ob, md): layout.prop(md, "iterations") - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) col = split.column() col.label(text="Axis:") @@ -574,7 +573,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.operator("object.meshdeform_bind", text="Bind") def MIRROR(self, layout, ob, md): - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) col = split.column() col.label(text="Axis:") @@ -648,7 +647,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): def OCEAN(self, layout, ob, md): if not bpy.app.build_options.mod_oceansim: - layout.label("Built without OceanSim modifier") + layout.label(text="Built without OceanSim modifier") return layout.prop(md, "geometry_mode") @@ -672,7 +671,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "size") col.prop(md, "spatial_size") - layout.label("Waves:") + layout.label(text="Waves:") split = layout.split() @@ -703,7 +702,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col = split.column() col.active = md.use_foam - col.label("Foam Data Layer Name:") + col.label(text="Foam Data Layer Name:") col.prop(md, "foam_layer_name", text="") layout.separator() @@ -840,7 +839,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col = split.column() col.prop(md, "project_limit", text="Limit") - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) col = split.column() col.label(text="Axis:") @@ -905,7 +904,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.label(text="Settings are inside the Physics tab") def SMOOTH(self, layout, ob, md): - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) col = split.column() col.label(text="Axis:") @@ -963,7 +962,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col.label(text="Material Index Offset:") sub = col.column() - row = sub.split(align=True, percentage=0.4) + row = sub.split(factor=0.4, align=True) row.prop(md, "material_offset", text="") row = row.row(align=True) row.active = md.use_rim @@ -1011,12 +1010,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col = layout.column(align=True) col.scale_y = 0.6 col.separator() - col.label("Final Dicing Rate:") + col.label(text="Final Dicing Rate:") col.separator() render = max(scene.cycles.dicing_rate * ob.cycles.dicing_rate, 0.1) preview = max(scene.cycles.preview_dicing_rate * ob.cycles.dicing_rate, 0.1) - col.label(f"Render {render:10.2f} px, Preview {preview:10.2f} px") + col.label(text=f"Render {render:10.2f} px, Preview {preview:10.2f} px") def SURFACE(self, layout, ob, md): layout.label(text="Settings are inside the Physics tab") @@ -1136,7 +1135,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.prop(md, "start_position_object") layout.prop_search(md, "vertex_group", ob, "vertex_groups") - split = layout.split(percentage=0.33) + split = layout.split(factor=0.33) col = split.column() col.label(text="Texture") col = split.column() @@ -1161,7 +1160,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): def REMESH(self, layout, ob, md): if not bpy.app.build_options.mod_remesh: - layout.label("Built without Remesh modifier") + layout.label(text="Built without Remesh modifier") return layout.prop(md, "mode") @@ -1204,17 +1203,17 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): def vertex_weight_mask(layout, ob, md): layout.label(text="Influence/Mask Options:") - split = layout.split(percentage=0.4) + split = layout.split(factor=0.4) split.label(text="Global Influence:") split.prop(md, "mask_constant", text="") if not md.mask_texture: - split = layout.split(percentage=0.4) + split = layout.split(factor=0.4) split.label(text="Vertex Group Mask:") split.prop_search(md, "mask_vertex_group", ob, "vertex_groups", text="") if not md.mask_vertex_group: - split = layout.split(percentage=0.4) + split = layout.split(factor=0.4) split.label(text="Texture Mask:") split.template_ID(md, "mask_texture", new="texture.new") if md.mask_texture: @@ -1443,7 +1442,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.separator() - split = layout.split(0.333) + split = layout.split(factor=0.333) split.prop(md, "use_vert_data") use_vert = md.use_vert_data row = split.row() @@ -1451,7 +1450,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "vert_mapping", text="") if use_vert: col = layout.column(align=True) - split = col.split(0.333, align=True) + split = col.split(factor=0.333, align=True) sub = split.column(align=True) sub.prop(md, "data_types_verts") sub = split.column(align=True) @@ -1460,11 +1459,11 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): row.label(icon='RIGHTARROW') row.prop(md, "layers_vgroup_select_dst", text="") row = sub.row(align=True) - row.label("", icon='NONE') + row.label(text="", icon='NONE') layout.separator() - split = layout.split(0.333) + split = layout.split(factor=0.333) split.prop(md, "use_edge_data") use_edge = md.use_edge_data row = split.row() @@ -1472,13 +1471,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "edge_mapping", text="") if use_edge: col = layout.column(align=True) - split = col.split(0.333, align=True) + split = col.split(factor=0.333, align=True) sub = split.column(align=True) sub.prop(md, "data_types_edges") layout.separator() - split = layout.split(0.333) + split = layout.split(factor=0.333) split.prop(md, "use_loop_data") use_loop = md.use_loop_data row = split.row() @@ -1486,12 +1485,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "loop_mapping", text="") if use_loop: col = layout.column(align=True) - split = col.split(0.333, align=True) + split = col.split(factor=0.333, align=True) sub = split.column(align=True) sub.prop(md, "data_types_loops") sub = split.column(align=True) row = sub.row(align=True) - row.label("", icon='NONE') + row.label(text="", icon='NONE') row = sub.row(align=True) row.prop(md, "layers_vcol_select_src", text="") row.label(icon='RIGHTARROW') @@ -1504,7 +1503,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.separator() - split = layout.split(0.333) + split = layout.split(factor=0.333) split.prop(md, "use_poly_data") use_poly = md.use_poly_data row = split.row() @@ -1512,7 +1511,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "poly_mapping", text="") if use_poly: col = layout.column(align=True) - split = col.split(0.333, align=True) + split = col.split(factor=0.333, align=True) sub = split.column(align=True) sub.prop(md, "data_types_polys") @@ -1570,7 +1569,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "use_direction_parallel") subcol = col.column(align=True) - subcol.label("Mix Mode:") + subcol.label(text="Mix Mode:") subcol.prop(md, "mix_mode", text="") subcol.prop(md, "mix_factor") row = subcol.row(align=True) @@ -1608,7 +1607,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.operator("object.correctivesmooth_bind", text="Unbind" if is_bind else "Bind") def WEIGHTED_NORMAL(self, layout, ob, md): - layout.label("Weighting Mode:") + layout.label(text="Weighting Mode:") split = layout.split(align=True) col = split.column(align=True) col.prop(md, "mode", text="") @@ -1664,12 +1663,12 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "move_extreme") col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") - col.label("Vertex Group:") + col.label(text="Vertex Group:") row = col.row(align=True) row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") row.prop(md, "invert_vertex", text="", icon="ARROW_LEFTRIGHT") @@ -1679,7 +1678,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "invert_pass", text="", icon="ARROW_LEFTRIGHT") row = layout.row(align=True) - row.label("Affect:") + row.label(text="Affect:") row = layout.row(align=True) row.prop(md, "affect_position", text="Position", icon='MESH_DATA', toggle=True) row.prop(md, "affect_strength", text="Strength", icon='COLOR', toggle=True) @@ -1694,13 +1693,13 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): split = layout.split() col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") col = split.column() - col.label("Vertex Group:") + col.label(text="Vertex Group:") row = col.row(align=True) row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") row.prop(md, "invert_vertex", text="", icon="ARROW_LEFTRIGHT") @@ -1710,7 +1709,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "invert_pass", text="", icon="ARROW_LEFTRIGHT") row = layout.row(align=True) - row.label("Affect:") + row.label(text="Affect:") row = layout.row(align=True) row.prop(md, "affect_position", text="Position", icon='MESH_DATA', toggle=True) row.prop(md, "affect_strength", text="Strength", icon='COLOR', toggle=True) @@ -1730,7 +1729,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "invert_pass", text="", icon="ARROW_LEFTRIGHT") col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") @@ -1744,7 +1743,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): split = layout.split() col = split.column() - col.label("Settings:") + col.label(text="Settings:") row = col.row(align=True) row.enabled = md.mode == 'FIXED' row.prop(md, "step") @@ -1754,7 +1753,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "factor") col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') @@ -1776,12 +1775,12 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "normalize_thickness") col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") - col.label("Vertex Group:") + col.label(text="Vertex Group:") row = col.row(align=True) row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") row.prop(md, "invert_vertex", text="", icon="ARROW_LEFTRIGHT") @@ -1803,7 +1802,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "factor") col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") @@ -1815,19 +1814,18 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "create_materials") row.prop(md, "modify_color") - def GP_COLOR(self, layout, ob, md): gpd = ob.data split = layout.split() col = split.column() - col.label("Color:") + col.label(text="Color:") col.prop(md, "hue", text="H") col.prop(md, "saturation", text="S") col.prop(md, "value", text="V") col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") @@ -1844,16 +1842,16 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): split = layout.split() col = split.column() - col.label("Opacity:") + col.label(text="Opacity:") col.prop(md, "factor") col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") - col.label("Vertex Group:") + col.label(text="Vertex Group:") row = col.row(align=True) row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") row.prop(md, "invert_vertex", text="", icon="ARROW_LEFTRIGHT") @@ -1874,18 +1872,18 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): split = layout.split() col = split.column() - col.label("Offset:") + col.label(text="Offset:") col.prop(md, "offset", text="") col = split.column() - col.label("Shift:") + col.label(text="Shift:") col.prop(md, "shift", text="") row = col.row(align=True) row.prop(md, "lock_axis", expand=True) split = layout.split() col = split.column() - col.label("Rotation:") + col.label(text="Rotation:") col.prop(md, "rotation", text="") col.separator() row = col.row(align=True) @@ -1893,7 +1891,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "rot_factor", text="") col = split.column() - col.label("Scale:") + col.label(text="Scale:") col.prop(md, "scale", text="") col.separator() row = col.row(align=True) @@ -1902,7 +1900,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): split = layout.split() col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") @@ -1937,7 +1935,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): sub.prop(md, "frame_end", text="End") col.separator() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") @@ -1951,12 +1949,12 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "object", text="") col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") - col.label("Vertex Group:") + col.label(text="Vertex Group:") row = col.row(align=True) row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") row.prop(md, "invert_vertex", text="", icon="ARROW_LEFTRIGHT") @@ -1980,7 +1978,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): # layout.separator() # layout.prop(md, "clip") - layout.label("Layer:") + layout.label(text="Layer:") row = layout.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") @@ -2004,12 +2002,12 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): col.prop_search(md, "subtarget", md.object.data, "bones", text="") col = split.column() - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") - col.label("Vertex Group:") + col.label(text="Vertex Group:") row = col.row(align=True) row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") row.prop(md, "invert_vertex", text="", icon="ARROW_LEFTRIGHT") @@ -2050,12 +2048,12 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): col = split.column() col.prop(md, "rotation") - col.label("Layer:") + col.label(text="Layer:") row = col.row(align=True) row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL') row.prop(md, "invert_layers", text="", icon="ARROW_LEFTRIGHT") - col.label("Vertex Group:") + col.label(text="Vertex Group:") row = col.row(align=True) row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") row.prop(md, "invert_vertex", text="", icon="ARROW_LEFTRIGHT") @@ -2064,6 +2062,29 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): row.prop(md, "pass_index", text="Pass") row.prop(md, "invert_pass", text="", icon="ARROW_LEFTRIGHT") + def GP_ARMATURE(self, layout, ob, md): + split = layout.split() + + col = split.column() + col.label(text="Object:") + col.prop(md, "object", text="") + col.prop(md, "use_deform_preserve_volume") + + col = split.column() + col.label(text="Bind To:") + col.prop(md, "use_vertex_groups", text="Vertex Groups") + col.prop(md, "use_bone_envelopes", text="Bone Envelopes") + + layout.separator() + + split = layout.split() + + row = split.row(align=True) + row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") + sub = row.row(align=True) + sub.active = bool(md.vertex_group) + sub.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT') + classes = ( DATA_PT_modifiers, diff --git a/release/scripts/startup/bl_ui/properties_data_speaker.py b/release/scripts/startup/bl_ui/properties_data_speaker.py index d7c93095489..f1482dbe61d 100644 --- a/release/scripts/startup/bl_ui/properties_data_speaker.py +++ b/release/scripts/startup/bl_ui/properties_data_speaker.py @@ -45,7 +45,7 @@ class DATA_PT_context_speaker(DataButtonsPanel, Panel): speaker = context.speaker space = context.space_data - split = layout.split(percentage=0.65) + split = layout.split(factor=0.65) if ob: split.template_ID(ob, "data") diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py index 12ecbeb3e6b..17839258062 100644 --- a/release/scripts/startup/bl_ui/properties_freestyle.py +++ b/release/scripts/startup/bl_ui/properties_freestyle.py @@ -97,7 +97,7 @@ class VIEWLAYER_UL_linesets(UIList): layout.prop(lineset, "show_render", text="", index=index) elif self.layout_type == 'GRID': layout.alignment = 'CENTER' - layout.label("", icon_value=icon) + layout.label(text="", icon_value=icon) class RENDER_MT_lineset_specials(Menu): @@ -151,7 +151,7 @@ class VIEWLAYER_PT_freestyle(ViewLayerFreestyleButtonsPanel, Panel): if freestyle.mode == 'SCRIPT': row = layout.row() - row.label("Style modules:") + row.label(text="Style modules:") row.operator("scene.freestyle_module_add", text="Add") for i, module in enumerate(freestyle.modules): box = layout.box() diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index 8aa57476ddc..ded6106c5c3 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -47,11 +47,11 @@ def gpencil_stroke_placement_settings(context, layout): def gpencil_active_brush_settings_simple(context, layout): brush = context.active_gpencil_brush if brush is None: - layout.label("No Active Brush") + layout.label(text="No Active Brush") return col = layout.column() - col.label("Active Brush: ") + col.label(text="Active Brush: ") row = col.row(align=True) row.operator_context = 'EXEC_REGION_WIN' @@ -121,7 +121,7 @@ class AnnotationDrawingToolsPanel: if context.space_data.type in {'CLIP_EDITOR'}: col.separator() - col.label("Data Source:") + col.label(text="Data Source:") row = col.row(align=True) if is_3d_view: row.prop(context.tool_settings, "grease_pencil_source", expand=True) @@ -360,7 +360,7 @@ class GPENCIL_MT_pie_tool_palette(Menu): row.operator("transform.rotate", icon='MAN_ROT') row.operator("transform.resize", text="Scale", icon='MAN_SCALE') row = col.row(align=True) - row.label("Proportional Edit:") + row.label(text="Proportional Edit:") row.prop(context.tool_settings, "proportional_edit", text="", icon_only=True) row.prop(context.tool_settings, "proportional_edit_falloff", text="", icon_only=True) @@ -430,7 +430,7 @@ class GPENCIL_MT_pie_settings_palette(Menu): # N - Active Layer col = pie.column() - col.label("Active Layer: ") + col.label(text="Active Layer: ") row = col.row() row.operator_context = 'EXEC_REGION_WIN' @@ -448,13 +448,13 @@ class GPENCIL_MT_pie_settings_palette(Menu): if is_editmode: # NW - Move stroke Down col = pie.column(align=True) - col.label("Arrange Strokes") + col.label(text="Arrange Strokes") col.operator("gpencil.stroke_arrange", text="Send to Back").direction = 'BOTTOM' col.operator("gpencil.stroke_arrange", text="Send Backward").direction = 'DOWN' # NE - Move stroke Up col = pie.column(align=True) - col.label("Arrange Strokes") + col.label(text="Arrange Strokes") col.operator("gpencil.stroke_arrange", text="Bring to Front").direction = 'TOP' col.operator("gpencil.stroke_arrange", text="Bring Forward").direction = 'UP' @@ -464,7 +464,7 @@ class GPENCIL_MT_pie_settings_palette(Menu): # SE - Join strokes col = pie.column(align=True) - col.label("Join Strokes") + col.label(text="Join Strokes") row = col.row() row.operator("gpencil.stroke_join", text="Join").type = 'JOIN' row.operator("gpencil.stroke_join", text="Join & Copy").type = 'JOINCOPY' @@ -524,7 +524,7 @@ class GPENCIL_MT_pie_sculpt(Menu): # W - Launch Sculpt Mode col = pie.column() - # col.label("Tool:") + # col.label(text="Tool:") col.prop(settings, "tool", text="") col.operator("gpencil.brush_paint", text="Sculpt", icon='SCULPTMODE_HLT') @@ -637,7 +637,7 @@ class GPENCIL_UL_annotation_layer(UIList): if gpl.lock: layout.active = False - split = layout.split(percentage=0.2) + split = layout.split(factor=0.2) split.prop(gpl, "color", text="", emboss=True) split.prop(gpl, "info", text="", emboss=False) @@ -735,7 +735,6 @@ class AnnotationDataPanel: row.operator("gpencil.active_frame_delete", text="", icon='X') - class GreasePencilOnionPanel: @staticmethod def draw_settings(layout, gp): @@ -793,7 +792,7 @@ class GreasePencilToolsPanel: layout.separator() - layout.label("Proportional Edit:") + layout.label(text="Proportional Edit:") row = layout.row() row.prop(context.tool_settings, "proportional_edit", text="") row.prop(context.tool_settings, "proportional_edit_falloff", text="") diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py index c766c8dedbc..bf32ebfc55a 100644 --- a/release/scripts/startup/bl_ui/properties_mask_common.py +++ b/release/scripts/startup/bl_ui/properties_mask_common.py @@ -177,7 +177,7 @@ class MASK_PT_point: # so do not over-complicate things for now by using single template_ID #col.template_any_ID(parent, "id", "id_type", text="") - col.label("Parent:") + col.label(text="Parent:") col.prop(parent, "id", text="") if parent.id_type == 'MOVIECLIP' and parent.id: diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py index cabd6e5677a..549e3a36420 100644 --- a/release/scripts/startup/bl_ui/properties_material_gpencil.py +++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py @@ -282,7 +282,7 @@ class MATERIAL_PT_gpencil_preview(GPMaterialButtonsPanel, Panel): def draw(self, context): ma = context.object.active_material - self.layout.label(ma.name) + self.layout.label(text=ma.name) self.layout.template_preview(ma) @@ -306,6 +306,7 @@ class MATERIAL_PT_gpencil_options(GPMaterialButtonsPanel, Panel): gpcolor = ma.grease_pencil layout.prop(gpcolor, "pass_index") + class MATERIAL_PT_gpencil_material_presets(PresetMenu): """Material settings""" bl_label = "Material Presets" diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index f1e5102f061..7649925b52b 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -116,11 +116,11 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal col.template_palette(settings, "palette", color=True) if brush.use_gradient: - col.label("Gradient Colors") + col.label(text="Gradient Colors") col.template_color_ramp(brush, "gradient", expand=True) if brush.image_tool == 'DRAW': - col.label("Background Color") + col.label(text="Background Color") row = col.row(align=True) panel.prop_unified_color(row, context, brush, "secondary_color", text="") col.prop(brush, "gradient_stroke_mode", text="Mode") @@ -167,14 +167,14 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal if settings.mode == 'MATERIAL': if len(ob.material_slots) > 1: - col.label("Materials") + col.label(text="Materials") col.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=2) mat = ob.active_material if mat: - col.label("Source Clone Slot") + col.label(text="Source Clone Slot") col.template_list("TEXTURE_UL_texpaintslots", "", mat, "texture_paint_images", mat, "paint_clone_slot", rows=2) @@ -183,9 +183,9 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal mesh = ob.data clone_text = mesh.uv_texture_clone.name if mesh.uv_texture_clone else "" - col.label("Source Clone Image") + col.label(text="Source Clone Image") col.template_ID(settings, "clone_image") - col.label("Source Clone UV Map") + col.label(text="Source Clone UV Map") col.menu("VIEW3D_MT_tools_projectpaint_clone", text=clone_text, translate=False) else: col.prop(brush, "clone_image", text="Image") diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 393c9784be8..ff8aeb3106b 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -119,10 +119,20 @@ class PARTICLE_UL_particle_systems(bpy.types.UIList): layout.prop(psys, "name", text="", emboss=False, icon_value=icon) if md: - layout.prop(md, "show_render", emboss=False, icon_only=True, - icon='RESTRICT_RENDER_OFF' if md.show_render else 'RESTRICT_RENDER_ON') - layout.prop(md, "show_viewport", emboss=False, icon_only=True, - icon='RESTRICT_VIEW_OFF' if md.show_viewport else 'RESTRICT_VIEW_ON') + layout.prop( + md, + "show_render", + emboss=False, + icon_only=True, + icon='RESTRICT_RENDER_OFF' if md.show_render else 'RESTRICT_RENDER_ON', + ) + layout.prop( + md, + "show_viewport", + emboss=False, + icon_only=True, + icon='RESTRICT_VIEW_OFF' if md.show_viewport else 'RESTRICT_VIEW_ON', + ) elif self.layout_type == 'GRID': layout.alignment = 'CENTER' @@ -174,7 +184,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): layout.prop(part, "type", text="Type") elif not psys.settings: - split = layout.split(percentage=0.32) + split = layout.split(factor=0.32) col = split.column() col.label(text="Settings:") @@ -184,7 +194,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): else: part = psys.settings - split = layout.split(percentage=0.32) + split = layout.split(factor=0.32) col = split.column() if part.is_fluid is False: col.label(text="Settings:") @@ -206,7 +216,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): row.prop(psys, "seed") if part: - split = layout.split(percentage=0.65) + split = layout.split(factor=0.65) if part.type == 'HAIR': if psys is not None and psys.is_edited: split.operator("particle.edited_clear", text="Free Edit") @@ -396,10 +406,10 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel): else: label = "ERROR" icon = 'ERROR' - box.label(label, icon=icon) - box.label("Iterations: %d .. %d (avg. %d)" % + box.label(text=label, icon=icon) + box.label(text="Iterations: %d .. %d (avg. %d)" % (result.min_iterations, result.max_iterations, result.avg_iterations)) - box.label("Error: %.5f .. %.5f (avg. %.5f)" % (result.min_error, result.max_error, result.avg_error)) + box.label(text="Error: %.5f .. %.5f (avg. %.5f)" % (result.min_error, result.max_error, result.avg_error)) class PARTICLE_PT_hair_dynamics_structure(ParticleButtonsPanel, Panel): @@ -1801,7 +1811,7 @@ class PARTICLE_PT_children_roughness(ParticleButtonsPanel, Panel): sub.prop(part, "roughness_1_size", text="Size") sub = col.column(align=True) - sub.prop(part, "roughness_endpoint", "Endpoint") + sub.prop(part, "roughness_endpoint", text="Endpoint") sub.prop(part, "roughness_end_shape") sub = col.column(align=True) diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index 11232cd87cd..69d9907ff99 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -67,7 +67,7 @@ class PHYSICS_PT_add(PhysicButtonsPanel, Panel): row = layout.row(align=True) row.alignment = 'RIGHT' - row.label("Enable physics for:") + row.label(text="Enable physics for:") flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True) @@ -185,7 +185,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): if not is_saved: col = layout.column(align=True) col.alignment = 'RIGHT' - col.label("Options are disabled until the file is saved") + col.label(text="Options are disabled until the file is saved") flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True) flow.enabled = enabled and is_saved @@ -195,7 +195,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): subcol = col.column() subcol.active = cache.use_disk_cache - subcol.prop(cache, "use_library_path", "Use Lib Path") + subcol.prop(cache, "use_library_path", text="Use Lib Path") col = flow.column() col.active = cache.use_disk_cache diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py index 424ad6ce5e1..9228c40e13b 100644 --- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py +++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py @@ -43,7 +43,10 @@ class PHYSICS_UL_dynapaint_surfaces(UIList): if surf.use_color_preview: row.prop( - surf, "show_preview", text="", emboss=False, + surf, + "show_preview", + text="", + emboss=False, icon='RESTRICT_VIEW_OFF' if surf.show_preview else 'RESTRICT_VIEW_ON' ) row.prop(surf, "is_active", text="") @@ -466,7 +469,7 @@ class PHYSICS_PT_dp_canvas_output_bake(PhysicButtonsPanel, Panel): row = layout.row(align=True) row.alignment = 'RIGHT' - row.label("Cache Path") + row.label(text="Cache Path") layout.prop(surface, "image_output_path", text="") layout.operator("dpaint.bake", text="Bake Image Sequence", icon='MOD_DYNAMICPAINT') diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py index aaa2892c5c4..ad840bbc89f 100644 --- a/release/scripts/startup/bl_ui/properties_physics_field.py +++ b/release/scripts/startup/bl_ui/properties_physics_field.py @@ -297,7 +297,7 @@ class PHYSICS_PT_field_falloff_radial(PhysicButtonsPanel, Panel): def collision_warning(layout): row = layout.row(align=True) row.alignment = 'RIGHT' - row.label("No collision settings available") + row.label(text="No collision settings available") class PHYSICS_PT_collision(PhysicButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index 23fc39f0f54..b3ec45c2571 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -76,7 +76,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel): if not bpy.app.build_options.mod_fluid: col = layout.column() col.alignment = 'RIGHT' - col.label("Built without fluids") + col.label(text="Built without fluids") return md = context.fluid @@ -290,7 +290,7 @@ class PHYSICS_PT_domain_bake(PhysicButtonsPanel, Panel): row = layout.row(align=True) row.alignment = 'RIGHT' - row.label("Cache Path") + row.label(text="Cache Path") layout.prop(fluid, "filepath", text="") diff --git a/release/scripts/startup/bl_ui/properties_physics_fracture.py b/release/scripts/startup/bl_ui/properties_physics_fracture.py index 686d1cd55a4..122450e3da3 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fracture.py +++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py @@ -71,7 +71,7 @@ class PHYSICS_PT_fracture_advanced(PhysicButtonsPanel, Panel): md = context.fracture ob = context.object - layout.label("Fracture Point Source:") + layout.label(text="Fracture Point Source") col = layout.column() col.context_pointer_set("modifier", md) col.prop(md, "point_source") @@ -91,7 +91,7 @@ class PHYSICS_PT_fracture_advanced(PhysicButtonsPanel, Panel): col.prop(md, "cutter_group") if (md.cutter_group): col.prop(md, "keep_cutter_shards") - col.label("Material Index Offset") + col.label(text="Material Index Offset") row = col.row(align=True) row.prop(md, "material_offset_intersect", text="Intersect") row.prop(md, "material_offset_difference", text="Difference") @@ -137,7 +137,7 @@ class PHYSICS_PT_fracture(PhysicButtonsPanel, Panel): def draw(self, context): md = context.fracture layout = self.layout - layout.label(text="Presets:") + layout.label(text="Presets") sub = layout.row(align=True) sub.menu("FRACTURE_MT_presets", text=bpy.types.FRACTURE_MT_presets.bl_label) sub.operator("fracture.preset_add", text="", icon='ZOOMIN') @@ -215,7 +215,7 @@ class PHYSICS_PT_fracture_simulation(PhysicButtonsPanel, Panel): ob = context.object layout.active = md.use_constraints - layout.label("Constraint Building Settings") + layout.label(text="Constraint Building Settings") row = layout.row() row.prop(md, "use_breaking") row.prop(md, "activate_broken") @@ -230,16 +230,16 @@ class PHYSICS_PT_fracture_simulation(PhysicButtonsPanel, Panel): col.prop(md, "constraint_limit", text="Constraint limit, per MeshIsland") col.prop(md, "contact_dist") - layout.label("Constraint Cluster Settings") + layout.label(text="Constraint Cluster Settings") layout.prop(md, "cluster_count") col = layout.column(align=True) col.prop(md, "cluster_group") col.prop(md, "cluster_constraint_type", text="Cluster Type") if md.use_compounds: - layout.label("Compound Breaking Settings") + layout.label(text="Compound Breaking Settings") else: - layout.label("Constraint Breaking Settings") + layout.label(text="Constraint Breaking Settings") col = layout.column(align=True) col.prop(md, "breaking_threshold", text="Threshold") @@ -253,7 +253,7 @@ class PHYSICS_PT_fracture_simulation(PhysicButtonsPanel, Panel): #col.prop(md, "directional_factor") col.prop(md, "mass_threshold_factor") else: - layout.label("Constraint Special Breaking Settings") + layout.label(text="Constraint Special Breaking Settings") col = layout.column(align=True) row = col.row(align=True) row.prop(md, "breaking_percentage", text="Percentage") @@ -280,7 +280,7 @@ class PHYSICS_PT_fracture_simulation(PhysicButtonsPanel, Panel): row.prop(md, "use_mass_dependent_thresholds", text="Mass Dependent Thresholds") if not md.use_compounds: - layout.label("Constraint Deform Settings") + layout.label(text="Constraint Deform Settings") col = layout.column(align=True) row = col.row(align=True) row.prop(md, "deform_angle", text="Deforming Angle") diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py index 3e3b033b0f1..082abb75f58 100644 --- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py +++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py @@ -27,7 +27,7 @@ from bpy.types import ( def rigid_body_warning(layout): row = layout.row(align=True) row.alignment = 'RIGHT' - row.label("Object does not have a Rigid Body") + row.label(text="Object does not have a Rigid Body") class PHYSICS_PT_rigidbody_panel: diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py index 7f21b14e03c..7c9e843fcad 100644 --- a/release/scripts/startup/bl_ui/properties_physics_smoke.py +++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py @@ -65,7 +65,7 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel): if not bpy.app.build_options.mod_smoke: col = layout.column(align=True) col.alignment = 'RIGHT' - col.label("Built without Smoke modifier") + col.label(text="Built without Smoke modifier") return md = context.smoke @@ -262,7 +262,6 @@ class PHYSICS_PT_smoke_behavior(PhysicButtonsPanel, Panel): col.prop(domain, "vorticity") - class PHYSICS_PT_smoke_behavior_dissolve(PhysicButtonsPanel, Panel): bl_label = "Dissolve" bl_parent_id = 'PHYSICS_PT_smoke_behavior' @@ -323,7 +322,6 @@ class PHYSICS_PT_smoke_flow_texture(PhysicButtonsPanel, Panel): self.layout.prop(flow_smoke, "use_texture", text="") - def draw(self, context): layout = self.layout layout.use_property_split = True @@ -332,7 +330,6 @@ class PHYSICS_PT_smoke_flow_texture(PhysicButtonsPanel, Panel): ob = context.object flow_smoke = context.smoke.flow_settings - sub = flow.column() sub.active = flow_smoke.use_texture sub.prop(flow_smoke, "noise_texture") @@ -350,6 +347,7 @@ class PHYSICS_PT_smoke_flow_texture(PhysicButtonsPanel, Panel): sub.prop(flow_smoke, "texture_offset") + class PHYSICS_PT_smoke_fire(PhysicButtonsPanel, Panel): bl_label = "Flames" bl_parent_id = 'PHYSICS_PT_smoke' @@ -529,7 +527,7 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel): if not bpy.app.build_options.openvdb: row = layout.row(align=True) row.alignment = 'RIGHT' - row.label("Built without OpenVDB support") + row.label(text="Built without OpenVDB support") return col = flow.column() diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index af2b3faafa7..6b8cbc55c08 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -249,7 +249,7 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel): if rd.use_sequencer: col.prop(rd, "use_stamp_strip_meta", text="Use Strip Metadata") - row = layout.split(percentage=0.3) + row = layout.split(factor=0.3) row.prop(rd, "use_stamp_note", text="Note") sub = row.row() sub.active = rd.use_stamp_note @@ -401,14 +401,14 @@ class RENDER_UL_renderviews(UIList): view = item if self.layout_type in {'DEFAULT', 'COMPACT'}: if view.name in {"left", "right"}: - layout.label(view.name, icon_value=icon + (not view.use)) + layout.label(text=view.name, icon_value=icon + (not view.use)) else: layout.prop(view, "name", text="", index=index, icon_value=icon, emboss=False) layout.prop(view, "use", text="", index=index) elif self.layout_type == 'GRID': layout.alignment = 'CENTER' - layout.label("", icon_value=icon + (not view.use)) + layout.label(text="", icon_value=icon + (not view.use)) class RENDER_PT_stereoscopy(RenderButtonsPanel, Panel): @@ -749,9 +749,9 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel): col.prop(props, "gi_visibility_resolution", text="Diffuse Occlusion") layout.use_property_split = False - row = layout.split(percentage=0.5) + row = layout.split(factor=0.5) row.alignment = 'RIGHT' - row.label("Cubemap Display") + row.label(text="Cubemap Display") sub = row.row(align=True) sub.prop(props, "gi_cubemap_draw_size", text="Size") @@ -760,9 +760,9 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel): else: sub.prop(props, "gi_show_cubemaps", text="", toggle=True, icon='HIDE_ON') - row = layout.split(percentage=0.5) + row = layout.split(factor=0.5) row.alignment = 'RIGHT' - row.label("Irradiance Display") + row.label(text="Irradiance Display") sub = row.row(align=True) sub.prop(props, "gi_irradiance_draw_size", text="Size") diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 246919e2a02..4f3c9ed616f 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -71,6 +71,7 @@ class SCENE_PT_scene(SceneButtonsPanel, Panel): def draw(self, context): layout = self.layout layout.use_property_split = True + layout.use_property_decorate = False scene = context.scene @@ -92,6 +93,7 @@ class SCENE_PT_unit(SceneButtonsPanel, Panel): unit = context.scene.unit_settings layout.use_property_split = True + layout.use_property_decorate = False flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True) diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index ae42e3f1d08..e112ad2ec4c 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -145,7 +145,7 @@ class TEXTURE_PT_context(TextureButtonsPanel, Panel): if tex: col.separator() - split = col.split(percentage=0.2) + split = col.split(factor=0.2) split.label(text="Type") split.prop(tex, "type", text="") @@ -907,7 +907,7 @@ class TEXTURE_PT_colors_ramp(TextureButtonsPanel, TextureColorsPoll, Panel): layout.template_color_ramp(tex, "color_ramp", expand=True) else: layout.alignment = 'RIGHT' - layout.label("Please enable the Color Ramp first") + layout.label(text="Please enable the Color Ramp first") class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_data_workspace.py b/release/scripts/startup/bl_ui/properties_workspace.py index 3cda3dd0abd..d07e2dbbaf6 100644 --- a/release/scripts/startup/bl_ui/properties_data_workspace.py +++ b/release/scripts/startup/bl_ui/properties_workspace.py @@ -28,13 +28,25 @@ from rna_prop_ui import PropertyPanel class WorkSpaceButtonsPanel: bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' - bl_context = "workspace" + bl_context = ".workspace" -class WORKSPACE_PT_owner_ids(WorkSpaceButtonsPanel, Panel): - bl_label = "Workspace Add-ons" +class WORKSPACE_PT_main(WorkSpaceButtonsPanel, Panel): + bl_label = "Workspace" bl_options = {'DEFAULT_CLOSED'} + def draw(self, context): + workspace = context.workspace + + layout = self.layout + layout.use_property_split = True + layout.prop(workspace, "object_mode", text="Mode") + + +class WORKSPACE_PT_addons(WorkSpaceButtonsPanel, Panel): + bl_label = "Filter Add-ons" + bl_parent_id = "WORKSPACE_PT_main" + def draw_header(self, context): workspace = context.workspace self.layout.prop(workspace, "use_filter_by_owner", text="") @@ -66,7 +78,7 @@ class WORKSPACE_PT_owner_ids(WorkSpaceButtonsPanel, Panel): text="", emboss=False, ).owner_id = module_name - row.label("%s: %s" % (info["category"], info["name"])) + row.label(text="%s: %s" % (info["category"], info["name"])) if is_enabled: owner_ids.remove(module_name) @@ -82,16 +94,19 @@ class WORKSPACE_PT_owner_ids(WorkSpaceButtonsPanel, Panel): text="", emboss=False, ).owner_id = module_name - row.label(module_name) + row.label(text=module_name) class WORKSPACE_PT_custom_props(WorkSpaceButtonsPanel, PropertyPanel, Panel): + bl_parent_id = "WORKSPACE_PT_main" + _context_path = "workspace" _property_type = bpy.types.WorkSpace classes = ( - WORKSPACE_PT_owner_ids, + WORKSPACE_PT_main, + WORKSPACE_PT_addons, WORKSPACE_PT_custom_props, ) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index c40013b2610..459fd4c5f48 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -756,7 +756,7 @@ class CLIP_PT_tracking_lens(Panel): clip = sc.clip row = layout.row(align=True) - sub = row.split(percentage=0.65, align=True) + sub = row.split(factor=0.65, align=True) if clip.tracking.camera.units == 'MILLIMETERS': sub.prop(clip.tracking.camera, "focal_length") else: @@ -842,7 +842,7 @@ class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel): col = layout.column(align=True) row = col.row(align=True) - row.prop(sc, "show_disabled", "Disabled") + row.prop(sc, "show_disabled", text="Disabled") row.prop(sc, "show_names", text="Info") row = col.row(align=True) diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index efd5e195fb8..f16a906f4cf 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -87,7 +87,7 @@ class DopesheetFilterPopoverBase: is_nla = context.area.type == 'NLA_EDITOR' col = layout.column(align=True) - col.label("With Name:") + col.label(text="With Name:") if not is_nla: row = col.row(align=True) row.prop(dopesheet, "filter_fcurve_name", text="") @@ -97,7 +97,7 @@ class DopesheetFilterPopoverBase: if (not generic_filters_only) and (bpy.data.collections): col = layout.column(align=True) - col.label("In Collection:") + col.label(text="In Collection:") col.prop(dopesheet, "filter_collection", text="") # Standard = Present in all panels @@ -106,7 +106,7 @@ class DopesheetFilterPopoverBase: dopesheet = context.space_data.dopesheet # Object Data Filters - layout.label("Include Sub-Object Data:") + layout.label(text="Include Sub-Object Data:") split = layout.split() # TODO: Add per-channel/axis convenience toggles? @@ -119,7 +119,7 @@ class DopesheetFilterPopoverBase: layout.separator() # datablock filters - layout.label("Include From Types:") + layout.label(text="Include From Types:") flow = layout.grid_flow(row_major=True, columns=2, even_rows=False, align=False) flow.prop(dopesheet, "show_scenes", text="Scenes") @@ -159,7 +159,7 @@ class DopesheetFilterPopoverBase: # performance-related options (users will mostly have these enabled) col = layout.column(align=True) - col.label("Options:") + col.label(text="Options:") col.prop(dopesheet, "use_datablock_sort", icon='NONE') diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py index a85dd591b2f..2f659b8d248 100644 --- a/release/scripts/startup/bl_ui/space_filebrowser.py +++ b/release/scripts/startup/bl_ui/space_filebrowser.py @@ -68,7 +68,7 @@ class FILEBROWSER_HT_header(Header): if params.filter_glob: # if st.active_operator and hasattr(st.active_operator, "filter_glob"): # row.prop(params, "filter_glob", text="") - row.label(params.filter_glob) + row.label(text=params.filter_glob) else: row.prop(params, "use_filter_blender", text="") row.prop(params, "use_filter_backup", text="") diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 24673af319e..95c7072f14a 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -219,7 +219,7 @@ class IMAGE_MT_image(Menu): layout.operator("image.replace", text="Replace...") layout.operator("image.reload", text="Reload") - layout.operator("image.external_edit", "Edit Externally") + layout.operator("image.external_edit", text="Edit Externally") layout.separator() @@ -292,7 +292,7 @@ class IMAGE_MT_uvs_proportional(Menu): layout.separator() - layout.label("Falloff:") + layout.label(text="Falloff:") layout.props_enum(context.tool_settings, "proportional_edit_falloff") @@ -960,10 +960,13 @@ class IMAGE_PT_tools_brush_overlay(BrushButtonsPanel, Panel): col.label(text="Curve:") row = col.row(align=True) - if brush.use_cursor_overlay: - row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF') - else: - row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON') + row.prop( + brush, + "use_cursor_overlay", + text="", + toggle=True, + icon='RESTRICT_VIEW_OFF' if brush.use_cursor_overlay else 'RESTRICT_VIEW_ON', + ) sub = row.row(align=True) sub.prop(brush, "cursor_overlay_alpha", text="Alpha") @@ -973,10 +976,13 @@ class IMAGE_PT_tools_brush_overlay(BrushButtonsPanel, Panel): col.label(text="Texture:") row = col.row(align=True) if tex_slot.map_mode != 'STENCIL': - if brush.use_primary_overlay: - row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF') - else: - row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON') + row.prop( + brush, + "use_primary_overlay", + text="", + toggle=True, + icon='RESTRICT_VIEW_OFF' if brush.use_primary_overlay else 'RESTRICT_VIEW_ON', + ) sub = row.row(align=True) sub.prop(brush, "texture_overlay_alpha", text="Alpha") @@ -986,10 +992,13 @@ class IMAGE_PT_tools_brush_overlay(BrushButtonsPanel, Panel): row = col.row(align=True) if tex_slot_mask.map_mode != 'STENCIL': - if brush.use_secondary_overlay: - row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF') - else: - row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON') + row.prop( + brush, + "use_secondary_overlay", + text="", + toggle=True, + icon='RESTRICT_VIEW_OFF' if brush.use_secondary_overlay else 'RESTRICT_VIEW_ON', + ) sub = row.row(align=True) sub.prop(brush, "mask_overlay_alpha", text="Alpha") @@ -1068,7 +1077,7 @@ class IMAGE_PT_paint_stroke(BrushButtonsPanel, Panel): if brush.use_anchor: col.separator() - col.prop(brush, "use_edge_to_edge", "Edge To Edge") + col.prop(brush, "use_edge_to_edge", text="Edge To Edge") if brush.use_airbrush: col.separator() @@ -1372,7 +1381,7 @@ class IMAGE_PT_view_waveform(ImageScopesPanel, Panel): sima = context.space_data layout.template_waveform(sima, "scopes") - row = layout.split(percentage=0.75) + row = layout.split(factor=0.75) row.prop(sima.scopes, "waveform_alpha") row.prop(sima.scopes, "waveform_mode", text="") diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 9ead34406c2..c106c197ecf 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -427,7 +427,7 @@ class NODE_PT_active_node_properties(Panel): value_inputs = [socket for socket in node.inputs if socket.enabled and not socket.is_linked] if value_inputs: layout.separator() - layout.label("Inputs:") + layout.label(text="Inputs:") for socket in value_inputs: row = layout.row() socket.draw(context, row, node, iface_(socket.name, socket.bl_rna.translation_context)) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 5dfe54d695f..57c7f7cac14 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -36,7 +36,7 @@ def act_strip(context): def draw_color_balance(layout, color_balance): box = layout.box() - split = box.split(percentage=0.35) + split = box.split(factor=0.35) col = split.column(align=True) col.label(text="Lift:") col.separator() @@ -46,7 +46,7 @@ def draw_color_balance(layout, color_balance): split.template_color_picker(color_balance, "lift", value_slider=True, cubic=True) box = layout.box() - split = box.split(percentage=0.35) + split = box.split(factor=0.35) col = split.column(align=True) col.label(text="Gamma:") col.separator() @@ -56,7 +56,7 @@ def draw_color_balance(layout, color_balance): split.template_color_picker(color_balance, "gamma", value_slider=True, lock_luminosity=True, cubic=True) box = layout.box() - split = box.split(percentage=0.35) + split = box.split(factor=0.35) col = split.column(align=True) col.label(text="Gain:") col.separator() @@ -537,16 +537,16 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel): frame_current = scene.frame_current strip = act_strip(context) - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) split.label(text="Name:") split.prop(strip, "name", text="") - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) split.label(text="Type:") split.prop(strip, "type", text="") if strip.type != 'SOUND': - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) split.label(text="Blend:") split.prop(strip, "blend_type", text="") @@ -656,7 +656,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): row.prop(strip, "use_only_boost") elif strip.type == 'SPEED': - layout.prop(strip, "use_default_fade", "Stretch to input strip length") + layout.prop(strip, "use_default_fade", text="Stretch to input strip length") if not strip.use_default_fade: layout.prop(strip, "use_as_speed") if strip.use_as_speed: @@ -707,7 +707,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): if strip_channel > 2: BT_ROW = 4 - col.label("Cut To:") + col.label(text="Cut To:") row = col.row() for i in range(1, strip_channel): @@ -726,7 +726,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): if strip.channel > BT_ROW and (strip_channel - 1) % BT_ROW: for i in range(strip.channel, strip_channel + ((BT_ROW + 1 - strip_channel) % BT_ROW)): - row.label("") + row.label(text="") else: col.separator() col.label(text="Two or more channels are needed below this strip", icon='INFO') @@ -746,7 +746,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): col.prop(strip, "align_x") col.prop(strip, "align_y") - col.label("Location") + col.label(text="Location") row = col.row(align=True) row.prop(strip, "location", text="") col.prop(strip, "wrap_width") @@ -756,7 +756,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): if strip.type == 'SPEED': col.prop(strip, "multiply_speed") elif strip.type in {'CROSS', 'GAMMA_CROSS', 'WIPE', 'ALPHA_OVER', 'ALPHA_UNDER', 'OVER_DROP'}: - col.prop(strip, "use_default_fade", "Default fade") + col.prop(strip, "use_default_fade", text="Default fade") if not strip.use_default_fade: col.prop(strip, "effect_fader", text="Effect Fader") elif strip.type == 'GAUSSIAN_BLUR': @@ -764,7 +764,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): row.prop(strip, "size_x") row.prop(strip, "size_y") elif strip.type == 'COLORMIX': - split = layout.split(percentage=0.35) + split = layout.split(factor=0.35) split.label(text="Blend Mode:") split.prop(strip, "blend_effect", text="") row = layout.row(align=True) @@ -802,7 +802,7 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel): # draw a filename if we have one if seq_type == 'IMAGE': - split = layout.split(percentage=0.2) + split = layout.split(factor=0.2) split.label(text="Path:") split.prop(strip, "directory", text="") @@ -810,26 +810,26 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel): elem = strip.strip_elem_from_frame(scene.frame_current) if elem: - split = layout.split(percentage=0.2) + split = layout.split(factor=0.2) split.label(text="File:") split.prop(elem, "filename", text="") # strip.elements[0] could be a fallback - split = layout.split(percentage=0.4) + split = layout.split(factor=0.4) split.label(text="Color Space:") split.prop(strip.colorspace_settings, "name", text="") - split = layout.split(percentage=0.4) + split = layout.split(factor=0.4) split.label(text="Alpha:") split.prop(strip, "alpha_mode", text="") layout.operator("sequencer.change_path", icon='FILESEL').filter_image = True elif seq_type == 'MOVIE': - split = layout.split(percentage=0.2) + split = layout.split(factor=0.2) split.label(text="Path:") split.prop(strip, "filepath", text="") - split = layout.split(percentage=0.4) + split = layout.split(factor=0.4) split.label(text="Color Space:") split.prop(strip.colorspace_settings, "name", text="") @@ -971,7 +971,7 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel, Panel): if scene: # Warning, this is not a good convention to follow. # Expose here because setting the alpha from the 'Render' menu is very inconvenient. - layout.label("Preview") + layout.label(text="Preview") layout.prop(scene.render, "alpha_mode") if scene: @@ -1049,7 +1049,7 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): col.label(text="Distortion:") col.prop(strip, "undistort") - split = layout.split(percentage=0.6) + split = layout.split(factor=0.6) col = split.column() col.prop(strip, "use_reverse_frames", text="Reverse") col.prop(strip, "use_deinterlace") @@ -1058,7 +1058,7 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): col.prop(strip, "use_flip_x", text="X Flip") col.prop(strip, "use_flip_y", text="Y Flip") - layout.label("Color:") + layout.label(text="Color:") col = layout.column(align=True) col.prop(strip, "color_saturation", text="Saturation") col.prop(strip, "color_multiply", text="Multiply") diff --git a/release/scripts/startup/bl_ui/space_statusbar.py b/release/scripts/startup/bl_ui/space_statusbar.py index dbcfbf165ce..2cc5bd94bd7 100644 --- a/release/scripts/startup/bl_ui/space_statusbar.py +++ b/release/scripts/startup/bl_ui/space_statusbar.py @@ -37,7 +37,7 @@ class STATUSBAR_HT_header(Header): row = layout.row(align=True) if bpy.app.autoexec_fail is True and bpy.app.autoexec_fail_quiet is False: - row.label("Auto-run disabled", icon='ERROR') + row.label(text="Auto-run disabled", icon='ERROR') if bpy.data.is_saved: props = row.operator("wm.revert_mainfile", icon='SCREEN_BACK', text="Reload Trusted") props.use_scripts = True @@ -45,7 +45,7 @@ class STATUSBAR_HT_header(Header): row.operator("script.autoexec_warn_clear", text="Ignore") # include last so text doesn't push buttons out of the header - row.label(bpy.app.autoexec_fail_message) + row.label(text=bpy.app.autoexec_fail_message) layout.template_running_jobs() diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index 8e370326d8c..9ef165a36a6 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -60,17 +60,17 @@ class TEXT_HT_header(Header): if text.filepath: if text.is_dirty: row.label( - iface_(f"File: *{text.filepath:s} (unsaved)"), + text=iface_(f"File: *{text.filepath:s} (unsaved)"), translate=False, ) else: row.label( - iface_(f"File: {text.filepath:s}"), + text=iface_(f"File: {text.filepath:s}"), translate=False, ) else: row.label( - "Text: External" + text="Text: External" if text.library else "Text: Internal" ) diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index 2d9a48a1852..7dc23550f52 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -182,7 +182,7 @@ def marker_menu_generic(layout): # layout.operator_context = 'EXEC_REGION_WIN' layout.column() - layout.operator("marker.add", "Add Marker") + layout.operator("marker.add", text="Add Marker") layout.operator("marker.duplicate", text="Duplicate Marker") if len(bpy.data.scenes) > 10: @@ -245,7 +245,7 @@ class TIME_PT_playback(TimelinePanelButtons, Panel): layout.separator() col = layout.column() - col.label("Play Animation In:") + col.label(text="Play Animation In:") layout.prop(screen, "use_play_top_left_3d_editor", text="Active Editor Only") layout.prop(screen, "use_play_3d_editors") layout.prop(screen, "use_play_animation_editors") @@ -280,18 +280,18 @@ class TIME_PT_keyframing_settings(TimelinePanelButtons, Panel): userprefs = context.user_preferences col = layout.column(align=True) - col.label("Active Keying Set:") + col.label(text="Active Keying Set:") row = col.row(align=True) row.prop_search(scene.keying_sets_all, "active", scene, "keying_sets_all", text="") row.operator("anim.keyframe_insert", text="", icon='KEY_HLT') row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT') col = layout.column(align=True) - col.label("New Keyframe Type:") + col.label(text="New Keyframe Type:") col.prop(toolsettings, "keyframe_type", text="") col = layout.column(align=True) - col.label("Auto Keyframing:") + col.label(text="Auto Keyframing:") row = col.row() row.prop(toolsettings, "auto_keying_mode", text="") row.prop(toolsettings, "use_keyframe_insert_keyingset", text="") diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 9432561ede1..1be86ea7c1c 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -23,8 +23,13 @@ from bpy.types import ( ) __all__ = ( - "ToolSelectPanelHelper", "ToolDef", + "ToolSelectPanelHelper", + "activate_by_name", + "activate_by_name_or_cycle", + "description_from_name", + "keymap_from_name", + "keymap_from_context", ) # Support reloading icons. @@ -70,6 +75,8 @@ ToolDef = namedtuple( ( # The name to display in the interface. "text", + # Description (for tooltip), when not set, use the description of 'operator'. + "description", # The name of the icon to use (found in ``release/datafiles/icons``) or None for no icon. "icon", # An optional cursor to use when this tool is active. @@ -104,6 +111,7 @@ def from_dict(kw_args): (since keymap is a callback). """ kw = { + "description": None, "icon": None, "cursor": None, "widget": None, @@ -273,7 +281,7 @@ class ToolSelectPanelHelper: if space_type == 'VIEW_3D': if mode is None: mode = context.mode - tool = context.workspace.tools.from_space_view3d_mode(mode, create) + tool = context.workspace.tools.from_space_view3d_mode(mode, create=create) if tool is not None: tool.refresh_from_context() return tool @@ -284,7 +292,7 @@ class ToolSelectPanelHelper: mode = 'VIEW' else: mode = space_data.mode - tool = context.workspace.tools.from_space_image_mode(mode, create) + tool = context.workspace.tools.from_space_image_mode(mode, create=create) if tool is not None: tool.refresh_from_context() return tool @@ -377,7 +385,7 @@ class ToolSelectPanelHelper: while True: if is_sep is True: if column_index != column_last: - row.label("") + row.label(text="") col = layout.column(align=True) row = col.row(align=True) row.scale_x = scale_x @@ -387,7 +395,7 @@ class ToolSelectPanelHelper: is_sep = yield row if is_sep is None: if column_index == column_last: - row.label("") + row.label(text="") yield None return @@ -513,19 +521,25 @@ class ToolSelectPanelHelper: self.draw_cls(self.layout, context) @staticmethod - def draw_active_tool_header(context, layout): + def draw_active_tool_header( + context, layout, + *, + show_tool_name=False, + ): # BAD DESIGN WARNING: last used tool workspace = context.workspace space_type = workspace.tools_space_type mode = workspace.tools_mode item, tool, icon_value = ToolSelectPanelHelper._tool_get_active(context, space_type, mode, with_icon=True) if item is None: - return - # Note: we could show 'item.text' here but it makes the layout jitter when switcuing tools. - layout.label(" ", icon_value=icon_value) + return None + # Note: we could show 'item.text' here but it makes the layout jitter when switching tools. + # Add some spacing since the icon is currently assuming regular small icon size. + layout.label(text=" " + item.text if show_tool_name else " ", icon_value=icon_value) draw_settings = item.draw_settings if draw_settings is not None: draw_settings(context, layout, tool) + return tool # The purpose of this menu is to be a generic popup to select between tools @@ -553,7 +567,7 @@ class WM_MT_toolsystem_submenu(Menu): cls, item_group = self._tool_group_from_button(context) if item_group is None: # Should never happen, just in case - layout.label("Unable to find toolbar group") + layout.label(text="Unable to find toolbar group") return for item in item_group: @@ -625,6 +639,44 @@ def activate_by_name_or_cycle(context, space_type, text, offset=1): return True +def description_from_name(context, space_type, text, *, use_operator=True): + # Used directly for tooltips. + cls, item, index = ToolSelectPanelHelper._tool_get_by_name(context, space_type, text) + if item is None: + return False + + # Custom description. + description = item.description + if description is not None: + return description + + # Extract from the operator. + if use_operator: + operator = item.operator + + if operator is None: + if item.keymap is not None: + operator = item.keymap[0].keymap_items[0].idname + + if operator is not None: + import _bpy + return _bpy.ops.get_rna(operator).bl_rna.description + return "" + + +def keymap_from_name(context, space_type, text): + # Used directly for tooltips. + cls, item, index = ToolSelectPanelHelper._tool_get_by_name(context, space_type, text) + if item is None: + return False + + keymap = item.keymap + # List container of one. + if keymap: + return keymap[0] + return "" + + def keymap_from_context(context, space_type): """ Keymap for popup toolbar, currently generated each time. diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index af65ca35c52..003f1fa4a7a 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -163,6 +163,9 @@ class _defs_view3d_generic: return dict( text="Cursor", + description=( + "Set the 3D cursor location, drag to transform" + ), icon="ops.generic.cursor", keymap=( ("view3d.cursor3d", dict(), dict(type='ACTIONMOUSE', value='PRESS')), @@ -196,6 +199,7 @@ class _defs_view3d_generic: ), ) + def _defs_annotate_factory(): class _defs_annotate: @@ -237,7 +241,7 @@ def _defs_annotate_factory(): _defs_annotate.draw_settings_common(context, layout, tool) return dict( - text="Draw Line", + text="Annotate Line", icon="ops.gpencil.draw.line", cursor='CROSSHAIR', keymap=( @@ -254,7 +258,7 @@ def _defs_annotate_factory(): _defs_annotate.draw_settings_common(context, layout, tool) return dict( - text="Draw Polygon", + text="Annotate Polygon", icon="ops.gpencil.draw.poly", cursor='CROSSHAIR', keymap=( @@ -273,7 +277,7 @@ def _defs_annotate_factory(): layout.prop(user_prefs.edit, "grease_pencil_eraser_radius", text="Radius") return dict( - text="Eraser", + text="Annotate Eraser", icon="ops.gpencil.draw.eraser", cursor='CROSSHAIR', # XXX: Always show brush circle when enabled keymap=( @@ -285,6 +289,7 @@ def _defs_annotate_factory(): ) return _defs_annotate + # Needed so annotation gets a keymap per space type. _defs_annotate_image = _defs_annotate_factory() _defs_annotate_view3d = _defs_annotate_factory() @@ -367,6 +372,9 @@ class _defs_transform: return dict( text="Transform", + description=( + "Supports any combination of grab, rotate & scale at once" + ), icon="ops.transform.transform", widget="TRANSFORM_GGT_gizmo", # No keymap default action, only for gizmo! @@ -398,6 +406,9 @@ class _defs_view3d_select: @ToolDef.from_fn def circle(): + def draw_settings(context, layout, tool): + props = tool.operator_properties("view3d.select_circle") + layout.prop(props, "radius") return dict( text="Select Circle", icon="ops.generic.select_circle", @@ -410,6 +421,7 @@ class _defs_view3d_select: dict(deselect=True), dict(type='ACTIONMOUSE', value='PRESS', ctrl=True)), ), + draw_settings=draw_settings, ) @ToolDef.from_fn @@ -483,7 +495,9 @@ class _defs_edit_armature: icon="ops.armature.extrude_move", widget=None, keymap=( - ("armature.click_extrude", dict(), dict(type='ACTIONMOUSE', value='PRESS')), + ("armature.extrude_move", + dict(TRANSFORM_OT_translate=dict(release_confirm=True)), + dict(type='EVT_TWEAK_A', value='ANY')), ), ) @@ -505,7 +519,7 @@ class _defs_edit_mesh: def cube_add(): return dict( text="Add Cube", - icon="ops.mesh.primitive_cube_add_manipulator", + icon="ops.mesh.primitive_cube_add_gizmo", widget=None, keymap=( ("view3d.cursor3d", dict(), dict(type='ACTIONMOUSE', value='CLICK')), @@ -670,12 +684,31 @@ class _defs_edit_mesh: widget="MESH_GGT_extrude", operator="view3d.edit_mesh_extrude_move_normal", keymap=( - ("mesh.extrude_context_move", dict(TRANSFORM_OT_translate=dict(release_confirm=True)), + ("mesh.extrude_context_move", + dict(TRANSFORM_OT_translate=dict(release_confirm=True)), dict(type='EVT_TWEAK_A', value='ANY')), ), ) @ToolDef.from_fn + def extrude_normals(): + def draw_settings(context, layout, tool): + props = tool.operator_properties("mesh.extrude_region_shrink_fatten") + props_macro = props.TRANSFORM_OT_shrink_fatten + layout.prop(props_macro, "use_even_offset") + return dict( + text="Extrude Along Normals", + icon="ops.mesh.extrude_region_shrink_fatten", + widget=None, + keymap=( + ("mesh.extrude_region_shrink_fatten", + dict(TRANSFORM_OT_shrink_fatten=dict(release_confirm=True)), + dict(type='EVT_TWEAK_A', value='ANY')), + ), + draw_settings=draw_settings, + ) + + @ToolDef.from_fn def extrude_individual(): return dict( text="Extrude Individual", @@ -756,6 +789,30 @@ class _defs_edit_mesh: ) @ToolDef.from_fn + def shear(): + return dict( + text="Shear", + icon="ops.transform.shear", + widget=None, + keymap=( + ("transform.shear", dict(release_confirm=True), + dict(type='ACTIONMOUSE', value='PRESS')), + ), + ) + + @ToolDef.from_fn + def tosphere(): + return dict( + text="To Sphere", + icon="ops.transform.tosphere", + widget=None, + keymap=( + ("transform.tosphere", dict(release_confirm=True), + dict(type='ACTIONMOUSE', value='PRESS')), + ), + ) + + @ToolDef.from_fn def shrink_fatten(): def draw_settings(context, layout, tool): props = tool.operator_properties("transform.shrink_fatten") @@ -851,6 +908,19 @@ class _defs_edit_curve: ) @ToolDef.from_fn + def extrude(): + return dict( + text="Extrude", + icon=None, + widget=None, + keymap=( + ("curve.extrude_move", + dict(TRANSFORM_OT_translate=dict(release_confirm=True)), + dict(type='EVT_TWEAK_A', value='ANY')), + ), + ) + + @ToolDef.from_fn def extrude_cursor(): return dict( text="Extrude Cursor", @@ -960,9 +1030,15 @@ class _defs_sculpt: ), ) + class _defs_vertex_paint: @staticmethod + def poll_select_mask(context): + mesh = context.object.data + return mesh.use_paint_mask + + @staticmethod def generate_from_brushes(context): return generate_from_brushes_ex( context, @@ -1006,6 +1082,11 @@ class _defs_texture_paint: class _defs_weight_paint: @staticmethod + def poll_select_mask(context): + mesh = context.object.data + return (mesh.use_paint_mask or mesh.use_paint_mask_vertex) + + @staticmethod def generate_from_brushes(context): return generate_from_brushes_ex( context, @@ -1127,6 +1208,7 @@ class _defs_gpencil_paint: row.template_ID(gp_settings, "material", live_icon=True) else: row.template_greasepencil_color(gp_settings, "material", rows=3, cols=8, scale=0.8) + row.prop(gp_settings, "pin_material", text="") @staticmethod def draw_settings_common(context, layout, tool): @@ -1192,7 +1274,7 @@ class _defs_gpencil_edit: widget=None, keymap=( ("transform.bend", - dict(), + dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), ), ) @@ -1205,7 +1287,7 @@ class _defs_gpencil_edit: widget=None, keymap=( ("transform.mirror", - dict(), + dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), ), ) @@ -1218,7 +1300,7 @@ class _defs_gpencil_edit: widget=None, keymap=( ("transform.shear", - dict(), + dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), ), ) @@ -1231,7 +1313,7 @@ class _defs_gpencil_edit: widget=None, keymap=( ("transform.tosphere", - dict(), + dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')), ), ) @@ -1615,6 +1697,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): None, ( _defs_edit_mesh.extrude, + _defs_edit_mesh.extrude_normals, _defs_edit_mesh.extrude_individual, _defs_edit_mesh.extrude_cursor, ), @@ -1646,6 +1729,10 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): _defs_edit_mesh.push_pull, ), ( + _defs_edit_mesh.shear, + _defs_edit_mesh.tosphere, + ), + ( _defs_edit_mesh.rip_region, _defs_edit_mesh.rip_edge, ), @@ -1659,7 +1746,10 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): *_tools_annotate, None, _defs_edit_curve.draw, - _defs_edit_curve.extrude_cursor, + ( + _defs_edit_curve.extrude, + _defs_edit_curve.extrude_cursor, + ) ], 'PARTICLE': [ _defs_view3d_generic.cursor, @@ -1676,6 +1766,12 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): ], 'PAINT_VERTEX': [ _defs_vertex_paint.generate_from_brushes, + None, + lambda context: ( + VIEW3D_PT_tools_active._tools_select + if _defs_vertex_paint.poll_select_mask(context) + else () + ), ], 'PAINT_WEIGHT': [ # TODO, check for mixed pose mode @@ -1685,8 +1781,11 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): _defs_weight_paint.sample_weight, _defs_weight_paint.sample_weight_group, None, - # TODO, override brush events - *_tools_select, + lambda context: ( + VIEW3D_PT_tools_active._tools_select + if _defs_weight_paint.poll_select_mask(context) + else () + ), None, _defs_weight_paint.gradient, ], diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 8bf8e40d74e..ea120a0e1fb 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -40,7 +40,7 @@ class TOPBAR_HT_upper_bar(Header): layout.operator("wm.splash", text="", icon='BLENDER', emboss=False) - INFO_MT_editor_menus.draw_collapsible(context, layout) + TOPBAR_MT_editor_menus.draw_collapsible(context, layout) layout.separator() @@ -96,7 +96,7 @@ class TOPBAR_HT_lower_bar(Header): # Active Tool # ----------- from .space_toolsystem_common import ToolSelectPanelHelper - ToolSelectPanelHelper.draw_active_tool_header(context, layout) + tool = ToolSelectPanelHelper.draw_active_tool_header(context, layout) # Object Mode Options # ------------------- @@ -107,17 +107,21 @@ class TOPBAR_HT_lower_bar(Header): # (obviously separated for from the users POV) draw_fn = getattr(_draw_left_context_mode, mode, None) if draw_fn is not None: - draw_fn(context, layout) + draw_fn(context, layout, tool) # Note: general mode options should be added to 'draw_right'. if mode == 'SCULPT': - layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + if tool.has_datablock: + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") elif mode == 'PAINT_VERTEX': - layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + if tool.has_datablock: + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") elif mode == 'PAINT_WEIGHT': - layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + if tool.has_datablock: + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") elif mode == 'PAINT_TEXTURE': - layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + if tool.has_datablock: + layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") elif mode == 'EDIT_ARMATURE': pass elif mode == 'EDIT_CURVE': @@ -127,7 +131,10 @@ class TOPBAR_HT_lower_bar(Header): elif mode == 'POSE': pass elif mode == 'PARTICLE': - layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + # Disable, only shows "Brush" panel, which is already in the top-bar. + # if tool.has_datablock: + # layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".paint_common", category="") + pass elif mode == 'GPENCIL_PAINT': layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".greasepencil_paint", category="") @@ -172,6 +179,7 @@ class TOPBAR_HT_lower_bar(Header): if context.tool_settings.gpencil_stroke_placement_view3d in ('ORIGIN', 'CURSOR'): layout.prop(context.tool_settings.gpencil_sculpt, "lockaxis", text='') layout.prop(context.tool_settings, "use_gpencil_draw_onback", text="", icon='ORTHO') + layout.prop(context.tool_settings, "add_gpencil_weight_data", text="", icon='WPAINT_HLT') layout.prop(context.tool_settings, "use_gpencil_additive_drawing", text="", icon='FREEZE') elif mode == 'GPENCIL_SCULPT': @@ -180,7 +188,9 @@ class TOPBAR_HT_lower_bar(Header): class _draw_left_context_mode: @staticmethod - def SCULPT(context, layout): + def SCULPT(context, layout, tool): + if not tool.has_datablock: + return brush = context.tool_settings.sculpt.brush if brush is None: return @@ -191,7 +201,9 @@ class _draw_left_context_mode: UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength") layout.prop(brush, "direction", text="", expand=True) - def PAINT_TEXTURE(context, layout): + def PAINT_TEXTURE(context, layout, tool): + if not tool.has_datablock: + return brush = context.tool_settings.vertex_paint.brush if brush is None: return @@ -202,7 +214,9 @@ class _draw_left_context_mode: UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True, text="Radius") UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength") - def PAINT_VERTEX(context, layout): + def PAINT_VERTEX(context, layout, tool): + if not tool.has_datablock: + return brush = context.tool_settings.vertex_paint.brush if brush is None: return @@ -213,7 +227,9 @@ class _draw_left_context_mode: UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True, text="Radius") UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength") - def PAINT_WEIGHT(context, layout): + def PAINT_WEIGHT(context, layout, tool): + if not tool.has_datablock: + return brush = context.tool_settings.weight_paint.brush if brush is None: return @@ -224,7 +240,7 @@ class _draw_left_context_mode: UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True, text="Radius") UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength") - def PARTICLE(context, layout): + def PARTICLE(context, layout, tool): # See: 'VIEW3D_PT_tools_brush', basically a duplicate settings = context.tool_settings.particle_edit brush = settings.brush @@ -233,21 +249,22 @@ class _draw_left_context_mode: layout.prop(brush, "size", slider=True) if tool == 'ADD': layout.prop(brush, "count") - else: - layout.prop(brush, "strength", slider=True) - if tool == 'ADD': layout.prop(settings, "use_default_interpolate") layout.prop(brush, "steps", slider=True) layout.prop(settings, "default_key_count", slider=True) - elif tool == 'LENGTH': - layout.row().prop(brush, "length_mode", expand=True) - elif tool == 'PUFF': - layout.row().prop(brush, "puff_mode", expand=True) - layout.prop(brush, "use_puff_volume") - -class INFO_MT_editor_menus(Menu): - bl_idname = "INFO_MT_editor_menus" + else: + layout.prop(brush, "strength", slider=True) + + if tool == 'LENGTH': + layout.row().prop(brush, "length_mode", expand=True) + elif tool == 'PUFF': + layout.row().prop(brush, "puff_mode", expand=True) + layout.prop(brush, "use_puff_volume") + + +class TOPBAR_MT_editor_menus(Menu): + bl_idname = "TOPBAR_MT_editor_menus" bl_label = "" def draw(self, context): @@ -255,16 +272,16 @@ class INFO_MT_editor_menus(Menu): @staticmethod def draw_menus(layout, context): - layout.menu("INFO_MT_file") - layout.menu("INFO_MT_edit") + layout.menu("TOPBAR_MT_file") + layout.menu("TOPBAR_MT_edit") - layout.menu("INFO_MT_render") + layout.menu("TOPBAR_MT_render") - layout.menu("INFO_MT_window") - layout.menu("INFO_MT_help") + layout.menu("TOPBAR_MT_window") + layout.menu("TOPBAR_MT_help") -class INFO_MT_file(Menu): +class TOPBAR_MT_file(Menu): bl_label = "File" def draw(self, context): @@ -273,7 +290,7 @@ class INFO_MT_file(Menu): layout.operator_context = 'INVOKE_AREA' layout.operator("wm.read_homefile", text="New", icon='NEW') layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER') - layout.menu("INFO_MT_file_open_recent") + layout.menu("TOPBAR_MT_file_open_recent") layout.operator("wm.revert_mainfile") layout.operator("wm.recover_last_session") layout.operator("wm.recover_auto_save", text="Recover Auto Save...") @@ -299,16 +316,16 @@ class INFO_MT_file(Menu): layout.operator_context = 'INVOKE_AREA' layout.operator("wm.link", text="Link...", icon='LINK_BLEND') layout.operator("wm.append", text="Append...", icon='APPEND_BLEND') - layout.menu("INFO_MT_file_previews") + layout.menu("TOPBAR_MT_file_previews") layout.separator() - layout.menu("INFO_MT_file_import", icon='IMPORT') - layout.menu("INFO_MT_file_export", icon='EXPORT') + layout.menu("TOPBAR_MT_file_import", icon='IMPORT') + layout.menu("TOPBAR_MT_file_export", icon='EXPORT') layout.separator() - layout.menu("INFO_MT_file_external_data") + layout.menu("TOPBAR_MT_file_external_data") layout.separator() @@ -318,8 +335,8 @@ class INFO_MT_file(Menu): layout.operator("wm.quit_blender", text="Quit", icon='QUIT') -class INFO_MT_file_import(Menu): - bl_idname = "INFO_MT_file_import" +class TOPBAR_MT_file_import(Menu): + bl_idname = "TOPBAR_MT_file_import" bl_label = "Import" def draw(self, context): @@ -329,8 +346,8 @@ class INFO_MT_file_import(Menu): self.layout.operator("wm.alembic_import", text="Alembic (.abc)") -class INFO_MT_file_export(Menu): - bl_idname = "INFO_MT_file_export" +class TOPBAR_MT_file_export(Menu): + bl_idname = "TOPBAR_MT_file_export" bl_label = "Export" def draw(self, context): @@ -340,7 +357,7 @@ class INFO_MT_file_export(Menu): self.layout.operator("wm.alembic_export", text="Alembic (.abc)") -class INFO_MT_file_external_data(Menu): +class TOPBAR_MT_file_external_data(Menu): bl_label = "External Data" def draw(self, context): @@ -367,7 +384,7 @@ class INFO_MT_file_external_data(Menu): layout.operator("file.find_missing_files") -class INFO_MT_file_previews(Menu): +class TOPBAR_MT_file_previews(Menu): bl_label = "Data Previews" def draw(self, context): @@ -382,28 +399,7 @@ class INFO_MT_file_previews(Menu): layout.operator("wm.previews_batch_clear") -class INFO_MT_game(Menu): - bl_label = "Game" - - def draw(self, context): - layout = self.layout - - gs = context.scene.game_settings - - layout.operator("view3d.game_start") - - layout.separator() - - layout.prop(gs, "show_debug_properties") - layout.prop(gs, "show_framerate_profile") - layout.prop(gs, "show_physics_visualization") - layout.prop(gs, "use_deprecation_warnings") - layout.prop(gs, "use_animation_record") - layout.separator() - layout.prop(gs, "use_auto_start") - - -class INFO_MT_render(Menu): +class TOPBAR_MT_render(Menu): bl_label = "Render" def draw(self, context): @@ -431,21 +427,7 @@ class INFO_MT_render(Menu): layout.prop(rd, "use_lock_interface", text="Lock Interface") -class INFO_MT_opengl_render(Menu): - bl_label = "OpenGL Render Options" - - def draw(self, context): - layout = self.layout - - rd = context.scene.render - layout.prop(rd, "use_antialiasing") - layout.prop(rd, "use_full_sample") - - layout.prop_menu_enum(rd, "antialiasing_samples") - layout.prop_menu_enum(rd, "alpha_mode") - - -class INFO_MT_edit(Menu): +class TOPBAR_MT_edit(Menu): bl_label = "Edit" def draw(self, context): @@ -482,7 +464,7 @@ class INFO_MT_edit(Menu): layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES') -class INFO_MT_window(Menu): +class TOPBAR_MT_window(Menu): bl_label = "Window" def draw(self, context): @@ -520,7 +502,7 @@ class INFO_MT_window(Menu): layout.operator("wm.set_stereo_3d") -class INFO_MT_help(Menu): +class TOPBAR_MT_help(Menu): bl_label = "Help" def draw(self, context): @@ -591,8 +573,8 @@ class TOPBAR_MT_file_specials(Menu): layout.separator() - layout.menu("INFO_MT_file_import", icon='IMPORT') - layout.menu("INFO_MT_file_export", icon='EXPORT') + layout.menu("TOPBAR_MT_file_import", icon='IMPORT') + layout.menu("TOPBAR_MT_file_export", icon='EXPORT') class TOPBAR_MT_window_specials(Menu): @@ -633,23 +615,43 @@ class TOPBAR_MT_workspace_menu(Menu): layout.operator("workspace.delete", text="Delete") +class TOPBAR_PT_active_tool(Panel): + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_category = "" + bl_context = ".active_tool" # dot on purpose (access from tool settings) + bl_label = "Active Tool" + + def draw(self, context): + layout = self.layout + + # Panel display of topbar tool settings. + # currently displays in tool settings, keep here since the same functionality is used for the topbar. + + layout.use_property_split = True + layout.use_property_decorate = False + + from .space_toolsystem_common import ToolSelectPanelHelper + ToolSelectPanelHelper.draw_active_tool_header(context, layout, show_tool_name=True) + + classes = ( TOPBAR_HT_upper_bar, TOPBAR_HT_lower_bar, TOPBAR_MT_file_specials, TOPBAR_MT_window_specials, TOPBAR_MT_workspace_menu, - INFO_MT_editor_menus, - INFO_MT_file, - INFO_MT_file_import, - INFO_MT_file_export, - INFO_MT_file_external_data, - INFO_MT_file_previews, - INFO_MT_edit, - INFO_MT_game, - INFO_MT_render, - INFO_MT_window, - INFO_MT_help, + TOPBAR_MT_editor_menus, + TOPBAR_MT_file, + TOPBAR_MT_file_import, + TOPBAR_MT_file_export, + TOPBAR_MT_file_external_data, + TOPBAR_MT_file_previews, + TOPBAR_MT_edit, + TOPBAR_MT_render, + TOPBAR_MT_window, + TOPBAR_MT_help, + TOPBAR_PT_active_tool, ) if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 4e12dcc75d4..a4d61f94fce 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -159,17 +159,17 @@ class USERPREF_MT_splash(Menu): row = split.row() if any(bpy.utils.app_template_paths()): - row.label("Template:") + row.label(text="Template:") template = context.user_preferences.app_template row.menu( "USERPREF_MT_templates_splash", text=bpy.path.display_name(template) if template else "Default", ) else: - row.label("") + row.label(text="") row = split.row() - row.label("Interaction:") + row.label(text="Interaction:") text = bpy.path.display_name(context.window_manager.keyconfigs.active.name) if not text: @@ -222,7 +222,7 @@ class USERPREF_PT_interface(Panel): sub = col.column(align=True) - sub.label("3D Viewport Axis:") + sub.label(text="3D Viewport Axis:") sub.row().prop(view, "mini_axis_type", text="") sub = col.column(align=True) @@ -245,7 +245,7 @@ class USERPREF_PT_interface(Panel): col.separator() - col.label("Development:") + col.label(text="Development:") col.prop(view, "show_tooltips_python") col.prop(view, "show_developer_ui") @@ -303,7 +303,7 @@ class USERPREF_PT_interface(Panel): col.prop(view, "show_splash") - col.label("Warnings:") + col.label(text="Warnings:") col.prop(view, "use_quit_dialog") col.separator() @@ -465,7 +465,7 @@ class USERPREF_PT_system(Panel): # 1. Column column = split.column() - colsplit = column.split(percentage=0.85) + colsplit = column.split(factor=0.85) col = colsplit.column() col.label(text="General:") @@ -498,7 +498,7 @@ class USERPREF_PT_system(Panel): # 2. Column column = split.column() - colsplit = column.split(percentage=0.85) + colsplit = column.split(factor=0.85) col = colsplit.column() col.label(text="OpenGL:") @@ -635,16 +635,16 @@ class USERPREF_PT_theme(Panel): col = split.column() def theme_generic_recurse(data): - col.label(data.rna_type.name) + col.label(text=data.rna_type.name) row = col.row() - subsplit = row.split(percentage=0.95) + subsplit = row.split(factor=0.95) - padding1 = subsplit.split(percentage=0.15) + padding1 = subsplit.split(factor=0.15) padding1.column() - subsplit = row.split(percentage=0.85) + subsplit = row.split(factor=0.85) - padding2 = subsplit.split(percentage=0.15) + padding2 = subsplit.split(factor=0.15) padding2.column() colsub_pair = padding1.column(), padding2.column() @@ -677,9 +677,9 @@ class USERPREF_PT_theme(Panel): if prop.identifier in th_delimiters: if i: colsub = colsub_pair[1] - colsub.row().label("") - colsub_pair[0].row().label("") - colsub_pair[1].row().label("") + colsub.row().label(text="") + colsub_pair[0].row().label(text="") + colsub_pair[1].row().label(text="") i = 0 theme_generic_recurse(themedata) @@ -689,9 +689,9 @@ class USERPREF_PT_theme(Panel): row = layout.row() - subsplit = row.split(percentage=0.95) + subsplit = row.split(factor=0.95) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(widget_style, "outline") @@ -700,9 +700,9 @@ class USERPREF_PT_theme(Panel): colsub.row().prop(widget_style, "inner_sel", slider=True) colsub.row().prop(widget_style, "roundness") - subsplit = row.split(percentage=0.85) + subsplit = row.split(factor=0.85) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(widget_style, "text") @@ -747,7 +747,7 @@ class USERPREF_PT_theme(Panel): theme = context.user_preferences.themes[0] - split_themes = layout.split(percentage=0.2) + split_themes = layout.split(factor=0.2) sub = split_themes.column() @@ -761,7 +761,7 @@ class USERPREF_PT_theme(Panel): sub.prop(theme, "theme_area", expand=True) - split = layout.split(percentage=0.4) + split = layout.split(factor=0.4) layout.separator() layout.separator() @@ -837,9 +837,9 @@ class USERPREF_PT_theme(Panel): row = col.row() - subsplit = row.split(percentage=0.95) + subsplit = row.split(factor=0.95) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui_state, "inner_anim") @@ -848,9 +848,9 @@ class USERPREF_PT_theme(Panel): colsub.row().prop(ui_state, "inner_driven_sel") colsub.row().prop(ui_state, "blend") - subsplit = row.split(percentage=0.85) + subsplit = row.split(factor=0.85) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui_state, "inner_key") @@ -861,13 +861,13 @@ class USERPREF_PT_theme(Panel): col.separator() col.separator() - col.label("Styles:") + col.label(text="Styles:") row = col.row() - subsplit = row.split(percentage=0.95) + subsplit = row.split(factor=0.95) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "menu_shadow_fac") @@ -875,9 +875,9 @@ class USERPREF_PT_theme(Panel): colsub.row().prop(ui, "icon_saturation") colsub.row().prop(ui, "editor_outline") - subsplit = row.split(percentage=0.85) + subsplit = row.split(factor=0.85) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "menu_shadow_width") @@ -886,22 +886,22 @@ class USERPREF_PT_theme(Panel): col.separator() col.separator() - col.label("Axis & Gizmo Colors:") + col.label(text="Axis & Gizmo Colors:") row = col.row() - subsplit = row.split(percentage=0.95) + subsplit = row.split(factor=0.95) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "axis_x") colsub.row().prop(ui, "axis_y") colsub.row().prop(ui, "axis_z") - subsplit = row.split(percentage=0.85) + subsplit = row.split(factor=0.85) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "gizmo_primary") @@ -915,22 +915,22 @@ class USERPREF_PT_theme(Panel): col = split.column() for i, ui in enumerate(theme.bone_color_sets, 1): - col.label(iface_(f"Color Set {i:d}"), translate=False) + col.label(text=iface_(f"Color Set {i:d}"), translate=False) row = col.row() - subsplit = row.split(percentage=0.95) + subsplit = row.split(factor=0.95) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "normal") colsub.row().prop(ui, "select") colsub.row().prop(ui, "active") - subsplit = row.split(percentage=0.85) + subsplit = row.split(factor=0.85) - padding = subsplit.split(percentage=0.15) + padding = subsplit.split(factor=0.15) colsub = padding.column() colsub = padding.column() colsub.row().prop(ui, "show_colored_constraints") @@ -973,13 +973,13 @@ class USERPREF_PT_file(Panel): paths = userpref.filepaths system = userpref.system - split = layout.split(percentage=0.7) + split = layout.split(factor=0.7) col = split.column() col.label(text="File Paths:") - colsplit = col.split(percentage=0.95) - col1 = colsplit.split(percentage=0.3) + colsplit = col.split(factor=0.95) + col1 = colsplit.split(factor=0.3) sub = col1.column() sub.label(text="Fonts:") @@ -1003,17 +1003,17 @@ class USERPREF_PT_file(Panel): sub.prop(paths, "render_cache_directory", text="") sub.prop(paths, "i18n_branches_directory", text="") sub.prop(paths, "image_editor", text="") - subsplit = sub.split(percentage=0.3) + subsplit = sub.split(factor=0.3) subsplit.prop(paths, "animation_player_preset", text="") subsplit.prop(paths, "animation_player", text="") col.separator() col.separator() - colsplit = col.split(percentage=0.95) + colsplit = col.split(factor=0.95) sub = colsplit.column() - row = sub.split(percentage=0.3) + row = sub.split(factor=0.3) row.label(text="Auto Execution:") row.prop(system, "use_scripts_auto_execute") @@ -1059,8 +1059,8 @@ class USERPREF_PT_file(Panel): col.label(text="Text Editor:") col.prop(system, "use_tabs_as_spaces") - colsplit = col.split(percentage=0.95) - col1 = colsplit.split(percentage=0.3) + colsplit = col.split(factor=0.95) + col1 = colsplit.split(factor=0.3) sub = col1.column() sub.label(text="Author:") @@ -1258,7 +1258,7 @@ class USERPREF_PT_input(Panel): inputs = userpref.inputs - split = layout.split(percentage=0.25) + split = layout.split(factor=0.25) # Input settings self.draw_input_prefs(inputs, split) @@ -1335,10 +1335,10 @@ class USERPREF_PT_addons(Panel): lines = message.split("\n") box = layout.box() sub = box.row() - sub.label(lines[0]) + sub.label(text=lines[0]) sub.label(icon='ERROR') for l in lines[1:]: - box.label(l) + box.label(text=l) def draw(self, context): import os @@ -1358,7 +1358,7 @@ class USERPREF_PT_addons(Panel): for mod in addon_utils.modules(refresh=False) ] - split = layout.split(percentage=0.2) + split = layout.split(factor=0.2) col = split.column() col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM') @@ -1374,15 +1374,15 @@ class USERPREF_PT_addons(Panel): if addon_utils.error_duplicates: box = col.box() row = box.row() - row.label("Multiple add-ons with the same name found!") + row.label(text="Multiple add-ons with the same name found!") row.label(icon='ERROR') - box.label("Please delete one of each pair:") + box.label(text="Please delete one of each pair:") for (addon_name, addon_file, addon_path) in addon_utils.error_duplicates: box.separator() sub_col = box.column(align=True) - sub_col.label(addon_name + ":") - sub_col.label(" " + addon_file) - sub_col.label(" " + addon_path) + sub_col.label(text=addon_name + ":") + sub_col.label(text=" " + addon_file) + sub_col.label(text=" " + addon_path) if addon_utils.error_encoding: self.draw_error( @@ -1458,27 +1458,27 @@ class USERPREF_PT_addons(Panel): # Expanded UI (only if additional info is available) if info["show_expanded"]: if info["description"]: - split = colsub.row().split(percentage=0.15) + split = colsub.row().split(factor=0.15) split.label(text="Description:") split.label(text=info["description"]) if info["location"]: - split = colsub.row().split(percentage=0.15) + split = colsub.row().split(factor=0.15) split.label(text="Location:") split.label(text=info["location"]) if mod: - split = colsub.row().split(percentage=0.15) + split = colsub.row().split(factor=0.15) split.label(text="File:") split.label(text=mod.__file__, translate=False) if info["author"]: - split = colsub.row().split(percentage=0.15) + split = colsub.row().split(factor=0.15) split.label(text="Author:") split.label(text=info["author"], translate=False) if info["version"]: - split = colsub.row().split(percentage=0.15) + split = colsub.row().split(factor=0.15) split.label(text="Version:") split.label(text=".".join(str(x) for x in info["version"]), translate=False) if info["warning"]: - split = colsub.row().split(percentage=0.15) + split = colsub.row().split(factor=0.15) split.label(text="Warning:") split.label(text=" " + info["warning"], icon='ERROR') @@ -1486,7 +1486,7 @@ class USERPREF_PT_addons(Panel): tot_row = bool(info["wiki_url"]) + bool(user_addon) if tot_row: - split = colsub.row().split(percentage=0.15) + split = colsub.row().split(factor=0.15) split.label(text="Internet:") if info["wiki_url"]: split.operator( @@ -1517,7 +1517,7 @@ class USERPREF_PT_addons(Panel): if draw is not None: addon_preferences_class = type(addon_preferences) box_prefs = col_box.box() - box_prefs.label("Preferences:") + box_prefs.label(text="Preferences:") addon_preferences_class.layout = box_prefs try: draw(context) @@ -1575,7 +1575,7 @@ class StudioLightPanelMixin(): for studio_light in lights: self.draw_studio_light(flow, studio_light) else: - layout.label("No custom {} configured".format(self.bl_label)) + layout.label(text="No custom {} configured".format(self.bl_label)) def draw_studio_light(self, layout, studio_light): box = layout.box() @@ -1634,11 +1634,11 @@ class USERPREF_PT_studiolight_specular(Panel, StudioLightPanelMixin): system = userpref.system light = system.solid_lights[0] - colsplit = column.split(percentage=0.85) + colsplit = column.split(factor=0.85) self.opengl_light_buttons(colsplit, light) light = system.solid_lights[1] - colsplit = column.split(percentage=0.85) + colsplit = column.split(factor=0.85) self.opengl_light_buttons(colsplit, light) light = system.solid_lights[2] diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index e9738458353..e29619800ea 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -232,7 +232,7 @@ class VIEW3D_HT_header(Header): ) row = layout.row(align=True) - row.prop(overlay, "show_overlays", icon='WIRE', text="") + row.prop(overlay, "show_overlays", icon='OVERLAY', text="") sub = row.row(align=True) sub.active = overlay.show_overlays sub.popover(panel="VIEW3D_PT_overlay") @@ -276,17 +276,17 @@ class VIEW3D_MT_editor_menus(Menu): if gp_edit: pass elif mode_string == 'OBJECT': - layout.menu("INFO_MT_add", text="Add") + layout.menu("VIEW3D_MT_add", text="Add") elif mode_string == 'EDIT_MESH': - layout.menu("INFO_MT_mesh_add", text="Add") + layout.menu("VIEW3D_MT_mesh_add", text="Add") elif mode_string == 'EDIT_CURVE': - layout.menu("INFO_MT_curve_add", text="Add") + layout.menu("VIEW3D_MT_curve_add", text="Add") elif mode_string == 'EDIT_SURFACE': - layout.menu("INFO_MT_surface_add", text="Add") + layout.menu("VIEW3D_MT_surface_add", text="Add") elif mode_string == 'EDIT_METABALL': - layout.menu("INFO_MT_metaball_add", text="Add") + layout.menu("VIEW3D_MT_metaball_add", text="Add") elif mode_string == 'EDIT_ARMATURE': - layout.menu("INFO_MT_edit_armature_add", text="Add") + layout.menu("TOPBAR_MT_edit_armature_add", text="Add") if gp_edit: if obj and obj.mode == 'GPENCIL_PAINT': @@ -542,7 +542,7 @@ class VIEW3D_MT_edit_proportional(Menu): layout.separator() - layout.label("Falloff:") + layout.label(text="Falloff:") layout.props_enum(tool_settings, "proportional_edit_falloff") @@ -638,7 +638,7 @@ class VIEW3D_MT_view_navigation(Menu): layout = self.layout layout.operator_enum("view3d.view_orbit", "type") - props = layout.operator("view3d.view_orbit", "Orbit Opposite") + props = layout.operator("view3d.view_orbit", text="Orbit Opposite") props.type = 'ORBITRIGHT' props.angle = pi @@ -1314,9 +1314,8 @@ class VIEW3D_MT_angle_control(Menu): layout.prop(tex_slot, "use_random", text="Random") -# XXX: INFO_MT_ names used to keep backwards compatibility (Add-ons etc. that hook into the menu) -class INFO_MT_mesh_add(Menu): - bl_idname = "INFO_MT_mesh_add" +class VIEW3D_MT_mesh_add(Menu): + bl_idname = "VIEW3D_MT_mesh_add" bl_label = "Mesh" def draw(self, context): @@ -1339,8 +1338,8 @@ class INFO_MT_mesh_add(Menu): layout.operator("mesh.primitive_monkey_add", text="Monkey", icon='MESH_MONKEY') -class INFO_MT_curve_add(Menu): - bl_idname = "INFO_MT_curve_add" +class VIEW3D_MT_curve_add(Menu): + bl_idname = "VIEW3D_MT_curve_add" bl_label = "Curve" def draw(self, context): @@ -1362,8 +1361,8 @@ class INFO_MT_curve_add(Menu): layout.operator("curve.draw", icon='LINE_DATA') -class INFO_MT_surface_add(Menu): - bl_idname = "INFO_MT_surface_add" +class VIEW3D_MT_surface_add(Menu): + bl_idname = "VIEW3D_MT_surface_add" bl_label = "Surface" def draw(self, context): @@ -1380,8 +1379,8 @@ class INFO_MT_surface_add(Menu): layout.operator("surface.primitive_nurbs_surface_torus_add", text="Nurbs Torus", icon='SURFACE_NTORUS') -class INFO_MT_metaball_add(Menu): - bl_idname = "INFO_MT_metaball_add" +class VIEW3D_MT_metaball_add(Menu): + bl_idname = "VIEW3D_MT_metaball_add" bl_label = "Metaball" def draw(self, context): @@ -1391,8 +1390,8 @@ class INFO_MT_metaball_add(Menu): layout.operator_enum("object.metaball_add", "type") -class INFO_MT_edit_curve_add(Menu): - bl_idname = "INFO_MT_edit_curve_add" +class TOPBAR_MT_edit_curve_add(Menu): + bl_idname = "TOPBAR_MT_edit_curve_add" bl_label = "Add" def draw(self, context): @@ -1402,13 +1401,13 @@ class INFO_MT_edit_curve_add(Menu): layout.operator_context = 'EXEC_REGION_WIN' if is_surf: - INFO_MT_surface_add.draw(self, context) + VIEW3D_MT_surface_add.draw(self, context) else: - INFO_MT_curve_add.draw(self, context) + VIEW3D_MT_curve_add.draw(self, context) -class INFO_MT_edit_armature_add(Menu): - bl_idname = "INFO_MT_edit_armature_add" +class TOPBAR_MT_edit_armature_add(Menu): + bl_idname = "TOPBAR_MT_edit_armature_add" bl_label = "Armature" def draw(self, context): @@ -1418,8 +1417,8 @@ class INFO_MT_edit_armature_add(Menu): layout.operator("armature.bone_primitive_add", text="Single Bone", icon='BONE_DATA') -class INFO_MT_armature_add(Menu): - bl_idname = "INFO_MT_armature_add" +class VIEW3D_MT_armature_add(Menu): + bl_idname = "VIEW3D_MT_armature_add" bl_label = "Armature" def draw(self, context): @@ -1429,8 +1428,8 @@ class INFO_MT_armature_add(Menu): layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA') -class INFO_MT_light_add(Menu): - bl_idname = "INFO_MT_light_add" +class VIEW3D_MT_light_add(Menu): + bl_idname = "VIEW3D_MT_light_add" bl_label = "Light" def draw(self, context): @@ -1440,8 +1439,8 @@ class INFO_MT_light_add(Menu): layout.operator_enum("object.light_add", "type") -class INFO_MT_lightprobe_add(Menu): - bl_idname = "INFO_MT_lightprobe_add" +class VIEW3D_MT_lightprobe_add(Menu): + bl_idname = "VIEW3D_MT_lightprobe_add" bl_label = "Light Probe" def draw(self, context): @@ -1451,8 +1450,8 @@ class INFO_MT_lightprobe_add(Menu): layout.operator_enum("object.lightprobe_add", "type") -class INFO_MT_camera_add(Menu): - bl_idname = "INFO_MT_camera_add" +class VIEW3D_MT_camera_add(Menu): + bl_idname = "VIEW3D_MT_camera_add" bl_label = "Camera" def draw(self, context): @@ -1461,7 +1460,7 @@ class INFO_MT_camera_add(Menu): layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA') -class INFO_MT_add(Menu): +class VIEW3D_MT_add(Menu): bl_label = "Add" def draw(self, context): @@ -1474,18 +1473,18 @@ class INFO_MT_add(Menu): layout.operator_context = 'EXEC_REGION_WIN' # layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH') - layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH') + layout.menu("VIEW3D_MT_mesh_add", icon='OUTLINER_OB_MESH') # layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE') - layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE') + layout.menu("VIEW3D_MT_curve_add", icon='OUTLINER_OB_CURVE') # layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE') - layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE') - layout.menu("INFO_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META') + layout.menu("VIEW3D_MT_surface_add", icon='OUTLINER_OB_SURFACE') + layout.menu("VIEW3D_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META') layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT') layout.operator_menu_enum("object.gpencil_add", "type", text="Grease Pencil", icon='OUTLINER_OB_GREASEPENCIL') layout.separator() - layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE') + layout.menu("VIEW3D_MT_armature_add", icon='OUTLINER_OB_ARMATURE') layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE' layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY') layout.separator() @@ -1493,14 +1492,14 @@ class INFO_MT_add(Menu): layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER') layout.separator() - if INFO_MT_camera_add.is_extended(): - layout.menu("INFO_MT_camera_add", icon='OUTLINER_OB_CAMERA') + if VIEW3D_MT_camera_add.is_extended(): + layout.menu("VIEW3D_MT_camera_add", icon='OUTLINER_OB_CAMERA') else: - INFO_MT_camera_add.draw(self, context) + VIEW3D_MT_camera_add.draw(self, context) - layout.menu("INFO_MT_light_add", icon='OUTLINER_OB_LIGHT') + layout.menu("VIEW3D_MT_light_add", icon='OUTLINER_OB_LIGHT') layout.separator() - layout.menu("INFO_MT_lightprobe_add", icon='OUTLINER_OB_LIGHTPROBE') + layout.menu("VIEW3D_MT_lightprobe_add", icon='OUTLINER_OB_LIGHTPROBE') layout.separator() layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_FORCE_FIELD') @@ -3069,8 +3068,8 @@ class VIEW3D_MT_edit_mesh_normals(Menu): layout.operator("mesh.smoothen_normals", text="Smoothen") layout.label(text="Face Strength") - layout.operator("mesh.mod_weighted_strength", text="Face select", icon = "FACESEL").set = False - layout.operator("mesh.mod_weighted_strength", text="Set Strength", icon = "ZOOMIN").set = True + layout.operator("mesh.mod_weighted_strength", text="Face Select", icon='FACESEL').set = False + layout.operator("mesh.mod_weighted_strength", text="Set Strength", icon='ZOOMIN').set = True class VIEW3D_MT_edit_mesh_shading(Menu): @@ -3536,6 +3535,15 @@ class VIEW3D_MT_edit_armature_delete(Menu): # ********** Grease Pencil Stroke menus ********** +class VIEW3D_MT_gpencil_autoweights(Menu): + bl_label = "Generate Weights" + + def draw(self, context): + layout = self.layout + layout.operator("gpencil.generate_weights", text="With Empty Groups").mode = 'NAME' + layout.operator("gpencil.generate_weights", text="With Automatic Weights").mode = 'AUTO' + + class VIEW3D_MT_gpencil_simplify(Menu): bl_label = "Simplify" @@ -3573,6 +3581,28 @@ class VIEW3D_MT_assign_material(Menu): layout.operator("gpencil.stroke_change_color", text=mat.name).material = mat.name +class VIEW3D_MT_gpencil_copy_layer(Menu): + bl_label = "Copy Layer to Object" + + def draw(self, context): + layout = self.layout + view_layer = context.view_layer + obact = context.active_object + gpl = context.active_gpencil_layer + + done = False + if gpl is not None: + for ob in view_layer.objects: + if ob.type == 'GPENCIL' and ob != obact: + layout.operator("gpencil.layer_duplicate_object", text=ob.name).object = ob.name + done = True + + if done is False: + layout.label(text="No destination object", icon="ERROR") + else: + layout.label(text="No layer to copy", icon="ERROR") + + class VIEW3D_MT_edit_gpencil(Menu): bl_label = "Strokes" @@ -3683,6 +3713,9 @@ class VIEW3D_MT_weight_gpencil(Menu): layout.operator("gpencil.vertex_group_invert", text="Invert") layout.operator("gpencil.vertex_group_smooth", text="Smooth") + layout.separator() + layout.menu("VIEW3D_MT_gpencil_autoweights") + class VIEW3D_MT_gpencil_animation(Menu): bl_label = "Animation" @@ -3926,13 +3959,13 @@ class VIEW3D_PT_shading_lighting(Panel): shading = VIEW3D_PT_shading.get_shading(context) col = layout.column() - split = col.split(0.9) + split = col.split(factor=0.9) if shading.type == 'SOLID': split.row().prop(shading, "light", expand=True) col = split.column() - split = layout.split(0.9) + split = layout.split(factor=0.9) col = split.column() sub = col.row() sub.scale_y = 0.6 # smaller matcap/hdri preview @@ -3959,7 +3992,7 @@ class VIEW3D_PT_shading_lighting(Panel): if not shading.use_scene_world: col = layout.column() - split = col.split(0.9) + split = col.split(factor=0.9) col = split.column() sub = col.row() @@ -3970,7 +4003,7 @@ class VIEW3D_PT_shading_lighting(Panel): col.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') if shading.selected_studio_light.orientation == 'WORLD': - split = layout.split(0.9) + split = layout.split(factor=0.9) col = split.column() col.prop(shading, "studiolight_rotate_z", text="Rotation") col.prop(shading, "studiolight_background_alpha") @@ -4000,7 +4033,7 @@ class VIEW3D_PT_shading_color(Panel): layout = self.layout shading = VIEW3D_PT_shading.get_shading(context) - layout.row().label("Background") + layout.row().label(text="Background") layout.row().prop(shading, 'background_type', expand=True) if shading.background_type == 'VIEWPORT': layout.row().prop(shading, "background_color", text="") @@ -4333,6 +4366,9 @@ class VIEW3D_PT_overlay_edit_mesh(Panel): sub.prop(data, "show_edges", text="Edges") sub = split.column() sub.prop(data, "show_faces", text="Faces") + sub = split.column() + sub.active = view.use_occlude_geometry + sub.prop(data, "show_face_center", text="Center") row = col.row(align=True) row.prop(data, "show_edge_crease", text="Creases", toggle=True) @@ -4665,7 +4701,7 @@ class VIEW3D_PT_pivot_point(Panel): layout = self.layout col = layout.column() - col.label("Pivot Point") + col.label(text="Pivot Point") col.prop(toolsettings, "transform_pivot_point", expand=True) if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}): @@ -4692,7 +4728,7 @@ class VIEW3D_PT_snapping(Panel): layout = self.layout col = layout.column() - col.label("Snapping") + col.label(text="Snapping") col.prop(toolsettings, "snap_elements", expand=True) col.separator() @@ -4700,7 +4736,7 @@ class VIEW3D_PT_snapping(Panel): col.prop(toolsettings, "use_snap_grid_absolute") if snap_elements != {'INCREMENT'}: - col.label("Target") + col.label(text="Target") row = col.row(align=True) row.prop(toolsettings, "snap_target", expand=True) @@ -4725,7 +4761,7 @@ class VIEW3D_PT_transform_orientations(Panel): def draw(self, context): layout = self.layout - layout.label("Transform Orientations") + layout.label(text="Transform Orientations") scene = context.scene orientation = scene.current_orientation @@ -4952,6 +4988,12 @@ class VIEW3D_MT_gpencil_edit_specials(Menu): layout.operator("gpencil.stroke_split", text="Split") layout.separator() + layout.operator_menu_enum("gpencil.stroke_arrange", "direction", text="Arrange Strokes") + + layout.separator() + layout.menu("VIEW3D_MT_gpencil_copy_layer") + + layout.separator() layout.operator("gpencil.stroke_join", text="Join").type = 'JOIN' layout.operator("gpencil.stroke_join", text="Join & Copy").type = 'JOINCOPY' @@ -4971,7 +5013,6 @@ class VIEW3D_MT_gpencil_sculpt_specials(Menu): def draw(self, context): layout = self.layout - is_3d_view = context.space_data.type == 'VIEW_3D' layout.operator_context = 'INVOKE_REGION_WIN' layout.menu("VIEW3D_MT_assign_material") @@ -4986,6 +5027,9 @@ class VIEW3D_MT_gpencil_sculpt_specials(Menu): layout.operator("gpencil.stroke_simplify_fixed", text="Simplify") layout.operator("gpencil.stroke_simplify", text="Simplify Adaptative") + if context.mode == 'GPENCIL_WEIGHT': + layout.separator() + layout.menu("VIEW3D_MT_gpencil_autoweights") classes = ( VIEW3D_HT_header, @@ -5025,17 +5069,17 @@ classes = ( VIEW3D_MT_select_paint_mask, VIEW3D_MT_select_paint_mask_vertex, VIEW3D_MT_angle_control, - INFO_MT_mesh_add, - INFO_MT_curve_add, - INFO_MT_surface_add, - INFO_MT_metaball_add, - INFO_MT_edit_curve_add, - INFO_MT_edit_armature_add, - INFO_MT_armature_add, - INFO_MT_light_add, - INFO_MT_lightprobe_add, - INFO_MT_camera_add, - INFO_MT_add, + VIEW3D_MT_mesh_add, + VIEW3D_MT_curve_add, + VIEW3D_MT_surface_add, + VIEW3D_MT_metaball_add, + TOPBAR_MT_edit_curve_add, + TOPBAR_MT_edit_armature_add, + VIEW3D_MT_armature_add, + VIEW3D_MT_light_add, + VIEW3D_MT_lightprobe_add, + VIEW3D_MT_camera_add, + VIEW3D_MT_add, VIEW3D_MT_object, VIEW3D_MT_object_animation, VIEW3D_MT_object_rigid_body, @@ -5102,6 +5146,7 @@ classes = ( VIEW3D_MT_weight_gpencil, VIEW3D_MT_gpencil_animation, VIEW3D_MT_gpencil_simplify, + VIEW3D_MT_gpencil_copy_layer, VIEW3D_MT_edit_curve, VIEW3D_MT_edit_curve_ctrlpoints, VIEW3D_MT_edit_curve_segments, @@ -5130,6 +5175,7 @@ classes = ( VIEW3D_PT_object_type_visibility, VIEW3D_PT_grease_pencil, VIEW3D_PT_gpencil_multi_frame, + VIEW3D_MT_gpencil_autoweights, VIEW3D_MT_gpencil_edit_specials, VIEW3D_MT_gpencil_sculpt_specials, VIEW3D_PT_quad_view, diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 0ccb1a51fef..6915129ef2c 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -94,6 +94,9 @@ class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + ob = context.active_object tool_settings = context.tool_settings @@ -106,13 +109,10 @@ class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel): row.active = ob.data.use_mirror_x row.prop(mesh, "use_mirror_topology") - col = layout.column(align=True) - col.label("Edge Select Mode:") - col.prop(tool_settings, "edge_path_mode", text="") - col.prop(tool_settings, "edge_path_live_unwrap") - col.label("Double Threshold:") - col.prop(tool_settings, "double_threshold", text="") - col.prop(tool_settings, "use_mesh_automerge") # , icon='AUTOMERGE_ON' + layout.prop(tool_settings, "edge_path_mode") + layout.prop(tool_settings, "edge_path_live_unwrap") + layout.prop(tool_settings, "double_threshold") + layout.prop(tool_settings, "use_mesh_automerge") # , icon='AUTOMERGE_ON' # ********** default tools for editmode_curve **************** @@ -134,7 +134,7 @@ class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel): col.prop(cps, "curve_type") if cps.curve_type == 'BEZIER': - col.label("Bezier Options:") + col.label(text="Bezier Options:") col.prop(cps, "error_threshold") col.prop(cps, "fit_method") col.prop(cps, "use_corners_detect") @@ -143,7 +143,7 @@ class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel): col.active = cps.use_corners_detect col.prop(cps, "corner_angle") - col.label("Pressure Radius:") + col.label(text="Pressure Radius:") row = layout.row(align=True) rowsub = row.row(align=True) rowsub.prop(cps, "radius_min", text="Min") @@ -152,13 +152,13 @@ class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel): row.prop(cps, "use_pressure_radius", text="", icon_only=True) col = layout.column() - col.label("Taper Radius:") + col.label(text="Taper Radius:") row = layout.row(align=True) row.prop(cps, "radius_taper_start", text="Start") row.prop(cps, "radius_taper_end", text="End") col = layout.column() - col.label("Projection Depth:") + col.label(text="Projection Depth:") row = layout.row(align=True) row.prop(cps, "depth_mode", expand=True) @@ -222,18 +222,18 @@ class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel): toolsettings = context.tool_settings.image_paint col = layout.column() - col.label("Missing Data", icon='ERROR') + col.label(text="Missing Data", icon='ERROR') if toolsettings.missing_uvs: col.separator() - col.label("Missing UVs", icon='INFO') - col.label("Unwrap the mesh in edit mode or generate a simple UV layer") + col.label(text="Missing UVs", icon='INFO') + col.label(text="Unwrap the mesh in edit mode or generate a simple UV layer") col.operator("paint.add_simple_uvs") if toolsettings.mode == 'MATERIAL': if toolsettings.missing_materials: col.separator() - col.label("Missing Materials", icon='INFO') - col.label("Add a material and paint slot below") + col.label(text="Missing Materials", icon='INFO') + col.label(text="Add a material and paint slot below") col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot") elif toolsettings.missing_texture: ob = context.active_object @@ -241,27 +241,27 @@ class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel): col.separator() if mat: - col.label("Missing Texture Slots", icon='INFO') - col.label("Add a paint slot below") + col.label(text="Missing Texture Slots", icon='INFO') + col.label(text="Add a paint slot below") col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot") else: - col.label("Missing Materials", icon='INFO') - col.label("Add a material and paint slot below") + col.label(text="Missing Materials", icon='INFO') + col.label(text="Add a material and paint slot below") col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot") elif toolsettings.mode == 'IMAGE': if toolsettings.missing_texture: col.separator() - col.label("Missing Canvas", icon='INFO') - col.label("Add or assign a canvas image below") - col.label("Canvas Image:") + col.label(text="Missing Canvas", icon='INFO') + col.label(text="Add or assign a canvas image below") + col.label(text="Canvas Image:") col.template_ID(toolsettings, "canvas", new="image.new", open="image.open") if toolsettings.missing_stencil: col.separator() - col.label("Missing Stencil", icon='INFO') - col.label("Add or assign a stencil image below") - col.label("Stencil Image:") + col.label(text="Missing Stencil", icon='INFO') + col.label(text="Add or assign a stencil image below") + col.label(text="Stencil Image:") col.template_ID(toolsettings, "stencil_image", new="image.new", open="image.open") @@ -295,19 +295,19 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): col.prop(brush, "size", slider=True) if tool == 'ADD': col.prop(brush, "count") + + col = layout.column() + col.prop(settings, "use_default_interpolate") + col.prop(brush, "steps", slider=True) + col.prop(settings, "default_key_count", slider=True) else: col.prop(brush, "strength", slider=True) - if tool == 'ADD': - col = layout.column() - col.prop(settings, "use_default_interpolate") - col.prop(brush, "steps", slider=True) - col.prop(settings, "default_key_count", slider=True) - elif tool == 'LENGTH': - layout.row().prop(brush, "length_mode", expand=True) - elif tool == 'PUFF': - layout.row().prop(brush, "puff_mode", expand=True) - layout.prop(brush, "use_puff_volume") + if tool == 'LENGTH': + layout.row().prop(brush, "length_mode", expand=True) + elif tool == 'PUFF': + layout.row().prop(brush, "puff_mode", expand=True) + layout.prop(brush, "use_puff_volume") # Sculpt Mode # @@ -558,20 +558,20 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel): ob = context.active_object col = layout.column() - col.label("Painting Mode:") + col.label(text="Painting Mode:") col.prop(settings, "mode", text="") col.separator() if settings.mode == 'MATERIAL': if len(ob.material_slots) > 1: - col.label("Materials:") + col.label(text="Materials:") col.template_list("MATERIAL_UL_matslots", "layers", ob, "material_slots", ob, "active_material_index", rows=2) mat = ob.active_material if mat: - col.label("Available Paint Slots:") + col.label(text="Available Paint Slots:") col.template_list("TEXTURE_UL_texpaintslots", "", mat, "texture_paint_images", mat, "paint_active_slot", rows=2) @@ -582,15 +582,15 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel): slot = None if slot and slot.is_valid: - col.label("UV Map:") + col.label(text="UV Map:") col.prop_search(slot, "uv_layer", ob.data, "uv_layers", text="") elif settings.mode == 'IMAGE': mesh = ob.data uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else "" - col.label("Canvas Image:") + col.label(text="Canvas Image:") col.template_ID(settings, "canvas", new="image.new", open="image.open") - col.label("UV Map:") + col.label(text="UV Map:") col.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False) col.separator() @@ -625,17 +625,17 @@ class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel): col.active = ipaint.use_stencil_layer stencil_text = mesh.uv_layer_stencil.name if mesh.uv_layer_stencil else "" - split = col.split(0.5) + split = col.split(factor=0.5) colsub = split.column() colsub.alignment = 'RIGHT' - colsub.label("UV Layer") + colsub.label(text="UV Layer") split.column().menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False) # todo this should be combinded into a single row - split = col.split(0.5) + split = col.split(factor=0.5) colsub = split.column() colsub.alignment = 'RIGHT' - colsub.label("Stencil Image") + colsub.label(text="Stencil Image") colsub = split.column() colsub.template_ID(ipaint, "stencil_image", new="image.new", open="image.open") @@ -672,11 +672,13 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel): col.label(text="Curve:") row = col.row(align=True) - if brush.use_cursor_overlay: - row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF') - else: - row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON') - + row.prop( + brush, + "use_cursor_overlay", + text="", + toggle=True, + icon='RESTRICT_VIEW_OFF' if brush.use_cursor_overlay else 'RESTRICT_VIEW_ON', + ) sub = row.row(align=True) sub.prop(brush, "cursor_overlay_alpha", text="Alpha") sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA') @@ -687,10 +689,13 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel): col.label(text="Texture:") row = col.row(align=True) if tex_slot.map_mode != 'STENCIL': - if brush.use_primary_overlay: - row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF') - else: - row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON') + row.prop( + brush, + "use_primary_overlay", + text="", + toggle=True, + icon='RESTRICT_VIEW_OFF' if brush.use_primary_overlay else 'RESTRICT_VIEW_ON', + ) sub = row.row(align=True) sub.prop(brush, "texture_overlay_alpha", text="Alpha") @@ -701,10 +706,13 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel): row = col.row(align=True) if tex_slot_mask.map_mode != 'STENCIL': - if brush.use_secondary_overlay: - row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF') - else: - row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON') + row.prop( + brush, + "use_secondary_overlay", + text="", + toggle=True, + icon='RESTRICT_VIEW_OFF' if brush.use_secondary_overlay else 'RESTRICT_VIEW_ON', + ) sub = row.row(align=True) sub.prop(brush, "mask_overlay_alpha", text="Alpha") @@ -788,7 +796,7 @@ class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel): if brush.use_anchor: col.separator() - col.prop(brush, "use_edge_to_edge", "Edge To Edge") + col.prop(brush, "use_edge_to_edge", text="Edge To Edge") if brush.use_airbrush: col.separator() @@ -814,10 +822,10 @@ class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel): if brush.sculpt_capabilities.has_jitter: col.separator() - colsub = col.split(0.5) + colsub = col.split(factor=0.5) row = colsub.row(align=True) row.alignment = 'RIGHT' - row.label("Jitter") + row.label(text="Jitter") row = colsub.row(align=True) row.prop(brush, "use_relative_jitter", icon_only=True) if brush.use_relative_jitter: @@ -1126,7 +1134,7 @@ class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel): row.active = mesh.use_mirror_x row.prop(mesh, "use_mirror_topology") - col.label("Show Zero Weights:") + col.label(text="Show Zero Weights:") sub = col.row() sub.prop(tool_settings, "vertex_group_user", expand=True) @@ -1180,7 +1188,7 @@ class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel): ipaint = toolsettings.image_paint col = layout.column() - row = col.split(align=True, percentage=0.55) + row = col.split(factor=0.55, align=True) row.operator("image.project_edit", text="Quick Edit") row.operator("image.project_apply", text="Apply") @@ -1607,13 +1615,13 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves(View3DPanel, Panel): gp_settings = brush.gpencil_settings # Brush - layout.label("Sensitivity") + layout.label(text="Sensitivity") layout.template_curve_mapping(gp_settings, "curve_sensitivity", brush=True) - layout.label("Strength") + layout.label(text="Strength") layout.template_curve_mapping(gp_settings, "curve_strength", brush=True) - layout.label("Jitter") + layout.label(text="Jitter") layout.template_curve_mapping(gp_settings, "curve_jitter", brush=True) @@ -1666,7 +1674,7 @@ class VIEW3D_PT_tools_grease_pencil_interpolate(Panel): settings = context.tool_settings.gpencil_interpolate col = layout.column(align=True) - col.label("Interpolate Strokes") + col.label(text="Interpolate Strokes") col.operator("gpencil.interpolate", text="Interpolate") col.operator("gpencil.interpolate_sequence", text="Sequence") col.operator("gpencil.interpolate_reverse", text="Remove Breakdowns") diff --git a/release/scripts/templates_py/addon_add_object.py b/release/scripts/templates_py/addon_add_object.py index d26f3d351bf..d7ee145175f 100644 --- a/release/scripts/templates_py/addon_add_object.py +++ b/release/scripts/templates_py/addon_add_object.py @@ -80,13 +80,13 @@ def add_object_manual_map(): def register(): bpy.utils.register_class(OBJECT_OT_add_object) bpy.utils.register_manual_map(add_object_manual_map) - bpy.types.INFO_MT_mesh_add.append(add_object_button) + bpy.types.VIEW3D_MT_mesh_add.append(add_object_button) def unregister(): bpy.utils.unregister_class(OBJECT_OT_add_object) bpy.utils.unregister_manual_map(add_object_manual_map) - bpy.types.INFO_MT_mesh_add.remove(add_object_button) + bpy.types.VIEW3D_MT_mesh_add.remove(add_object_button) if __name__ == "__main__": diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py index 7e4e89dafeb..a2701360c9b 100644 --- a/release/scripts/templates_py/custom_nodes.py +++ b/release/scripts/templates_py/custom_nodes.py @@ -103,7 +103,7 @@ class MyCustomNode(Node, MyCustomTreeNode): # Additional buttons displayed on the node. def draw_buttons(self, context, layout): - layout.label("Node settings") + layout.label(text="Node settings") layout.prop(self, "my_float_prop") # Detail buttons in the sidebar. diff --git a/release/scripts/templates_py/operator_file_export.py b/release/scripts/templates_py/operator_file_export.py index 4ea817d3507..45910772dc7 100644 --- a/release/scripts/templates_py/operator_file_export.py +++ b/release/scripts/templates_py/operator_file_export.py @@ -60,12 +60,12 @@ def menu_func_export(self, context): def register(): bpy.utils.register_class(ExportSomeData) - bpy.types.INFO_MT_file_export.append(menu_func_export) + bpy.types.TOPBAR_MT_file_export.append(menu_func_export) def unregister(): bpy.utils.unregister_class(ExportSomeData) - bpy.types.INFO_MT_file_export.remove(menu_func_export) + bpy.types.TOPBAR_MT_file_export.remove(menu_func_export) if __name__ == "__main__": diff --git a/release/scripts/templates_py/operator_file_import.py b/release/scripts/templates_py/operator_file_import.py index b932b008c49..5438a7a6f9d 100644 --- a/release/scripts/templates_py/operator_file_import.py +++ b/release/scripts/templates_py/operator_file_import.py @@ -63,12 +63,12 @@ def menu_func_import(self, context): def register(): bpy.utils.register_class(ImportSomeData) - bpy.types.INFO_MT_file_import.append(menu_func_import) + bpy.types.TOPBAR_MT_file_import.append(menu_func_import) def unregister(): bpy.utils.unregister_class(ImportSomeData) - bpy.types.INFO_MT_file_import.remove(menu_func_import) + bpy.types.TOPBAR_MT_file_import.remove(menu_func_import) if __name__ == "__main__": diff --git a/release/scripts/templates_py/operator_mesh_add.py b/release/scripts/templates_py/operator_mesh_add.py index 6b39ef7bbba..5a9acce3026 100644 --- a/release/scripts/templates_py/operator_mesh_add.py +++ b/release/scripts/templates_py/operator_mesh_add.py @@ -123,12 +123,12 @@ def menu_func(self, context): def register(): bpy.utils.register_class(AddBox) - bpy.types.INFO_MT_mesh_add.append(menu_func) + bpy.types.VIEW3D_MT_mesh_add.append(menu_func) def unregister(): bpy.utils.unregister_class(AddBox) - bpy.types.INFO_MT_mesh_add.remove(menu_func) + bpy.types.VIEW3D_MT_mesh_add.remove(menu_func) if __name__ == "__main__": diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index 2c9b1efe2f4..a4d8e21c349 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -33,6 +33,7 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_cachefile_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_camera_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_cloth_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_collection_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_color_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_constraint_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_curve_types.h @@ -46,9 +47,7 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_genfile.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_modifier_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_shader_fx_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpu_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_group_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_image_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_ipo_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_key_types.h @@ -58,16 +57,18 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lightprobe_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_listBase.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mask_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_material_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mesh_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meshdata_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mesh_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meta_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_modifier_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_movieclip_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_nla_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_node_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_enums.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_fluidsim_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_force_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_enums.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_outliner_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_packedFile_types.h @@ -77,12 +78,14 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_screen_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sdna_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sequence_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_shader_fx_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_smoke_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sound_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_space_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_speaker_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_text_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_texture_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_tracking_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_userdef_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_vec_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_vfont_types.h @@ -91,9 +94,6 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_windowmanager_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_workspace_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_world_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_movieclip_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_tracking_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mask_types.h ) add_subdirectory(datatoc) diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 4e1d8cb3bcf..3a1fd5c5ba6 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -37,6 +37,8 @@ struct Main; struct Scene; struct ToolSettings; struct UnifiedPaintSettings; +struct Material; + // enum eCurveMappingPreset; #include "DNA_object_enums.h" @@ -58,6 +60,7 @@ void BKE_brush_free(struct Brush *brush); void BKE_brush_sculpt_reset(struct Brush *brush); void BKE_brush_gpencil_presets(struct bContext *C); +void BKE_brush_update_material(struct Main *bmain, struct Material *ma, struct Brush *exclude_brush); struct Brush *BKE_brush_getactive_gpencil(struct ToolSettings *ts); struct Paint *BKE_brush_get_gpencil_paint(struct ToolSettings *ts); diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index 19535f23cf2..aad02c371db 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -26,10 +26,10 @@ #ifndef __BKE_GPENCIL_H__ #define __BKE_GPENCIL_H__ -/** \file BKE_gpencil.h - * \ingroup bke - * \author Joshua Leung - */ + /** \file BKE_gpencil.h + * \ingroup bke + * \author Joshua Leung + */ struct CurveMapping; struct Depsgraph; @@ -106,9 +106,9 @@ void BKE_gpencil_stats_update(struct bGPdata *gpd); #define GP_PRIM_DATABUF_SIZE 5 void BKE_gpencil_stroke_add_points( - struct bGPDstroke *gps, - const float *array, const int totpoints, - const float mat[4][4]); + struct bGPDstroke *gps, + const float *array, const int totpoints, + const float mat[4][4]); struct bGPDstroke *BKE_gpencil_add_stroke(struct bGPDframe *gpf, int mat_idx, int totpoints, short thickness); @@ -144,17 +144,15 @@ struct Material *BKE_gpencil_material_ensure(struct Main *bmain, struct Object * /* object boundbox */ bool BKE_gpencil_stroke_minmax( - const struct bGPDstroke *gps, const bool use_select, - float r_min[3], float r_max[3]); + const struct bGPDstroke *gps, const bool use_select, + float r_min[3], float r_max[3]); struct BoundBox *BKE_gpencil_boundbox_get(struct Object *ob); void BKE_gpencil_centroid_3D(struct bGPdata *gpd, float r_centroid[3]); /* vertex groups */ -float BKE_gpencil_vgroup_use_index(struct MDeformVert *dvert, int index); +void BKE_gpencil_dvert_ensure(struct bGPDstroke *gps); void BKE_gpencil_vgroup_remove(struct Object *ob, struct bDeformGroup *defgroup); -struct MDeformWeight *BKE_gpencil_vgroup_add_point_weight(struct MDeformVert *dvert, int index, float weight); -bool BKE_gpencil_vgroup_remove_point_weight(struct MDeformVert *dvert, int index); void BKE_gpencil_stroke_weights_duplicate(struct bGPDstroke *gps_src, struct bGPDstroke *gps_dst); /* GPencil geometry evaluation */ @@ -164,6 +162,7 @@ void BKE_gpencil_eval_geometry(struct Depsgraph *depsgraph, struct bGPdata *gpd) void BKE_gpencil_stroke_normal(const struct bGPDstroke *gps, float r_normal[3]); void BKE_gpencil_simplify_stroke(struct bGPDstroke *gps, float factor); void BKE_gpencil_simplify_fixed(struct bGPDstroke *gps); +void BKE_gpencil_subdivide(struct bGPDstroke *gps, int level, int flag); void BKE_gpencil_transform(struct bGPdata *gpd, float mat[4][4]); diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index e98839e3dbc..2ca6a35eec5 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -44,6 +44,7 @@ struct Scene; struct BPoint; struct MDeformVert; struct Depsgraph; +struct bGPDstroke; void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb); void BKE_lattice_init(struct Lattice *lt); @@ -73,7 +74,8 @@ void lattice_deform_verts(struct Object *laOb, struct Object *target, void armature_deform_verts(struct Object *armOb, struct Object *target, const struct Mesh *mesh, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts, int deformflag, - float (*prevCos)[3], const char *defgrp_name); + float (*prevCos)[3], const char *defgrp_name, + struct bGPDstroke *gps); float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3]; void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]); diff --git a/source/blender/blenkernel/BKE_mesh_tangent.h b/source/blender/blenkernel/BKE_mesh_tangent.h index 6d359a0653c..09575f39e98 100644 --- a/source/blender/blenkernel/BKE_mesh_tangent.h +++ b/source/blender/blenkernel/BKE_mesh_tangent.h @@ -20,6 +20,10 @@ #ifndef __BKE_MESH_TANGENT_H__ #define __BKE_MESH_TANGENT_H__ +/** \file BKE_mesh_tangent.h + * \ingroup bke + */ + void BKE_mesh_calc_loop_tangent_single_ex( const struct MVert *mverts, const int numVerts, const struct MLoop *mloops, float (*r_looptangent)[4], float (*loopnors)[3], const struct MLoopUV *loopuv, diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 095f442ca50..a0c8cab10fc 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -130,7 +130,7 @@ bool BKE_pbvh_node_find_nearest_to_ray( /* Drawing */ void BKE_pbvh_draw_cb( - PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, + PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, bool only_mask, void (*draw_fn)(void *user_data, struct GPUBatch *batch), void *user_data); /* PBVH Access */ diff --git a/source/blender/blenkernel/BKE_subdiv.h b/source/blender/blenkernel/BKE_subdiv.h index 76539383f16..aa14f9724fb 100644 --- a/source/blender/blenkernel/BKE_subdiv.h +++ b/source/blender/blenkernel/BKE_subdiv.h @@ -416,7 +416,7 @@ struct Mesh *BKE_subdiv_to_mesh( void BKE_subdiv_displacement_attach_from_multires( Subdiv *subdiv, - const struct Object *object, + const struct Mesh *mesh, const struct MultiresModifierData *mmd); void BKE_subdiv_displacement_detach(Subdiv *subdiv); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 9174038dfbb..a3f7dbe70be 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -27,7 +27,6 @@ * \ingroup bke */ - #include <ctype.h> #include <stdlib.h> #include <math.h> @@ -47,6 +46,7 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" +#include "DNA_gpencil_types.h" #include "DNA_mesh_types.h" #include "DNA_lattice_types.h" #include "DNA_listBase.h" @@ -971,7 +971,7 @@ static void armature_bbone_defmats_cb(void *userdata, Link *iter, int index) void armature_deform_verts(Object *armOb, Object *target, const Mesh * mesh, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts, int deformflag, - float (*prevCos)[3], const char *defgrp_name) + float (*prevCos)[3], const char *defgrp_name, bGPDstroke *gps) { bPoseChanDeform *pdef_info_array; bPoseChanDeform *pdef_info = NULL; @@ -1025,7 +1025,7 @@ void armature_deform_verts(Object *armOb, Object *target, const Mesh * mesh, flo /* get the def_nr for the overall armature vertex group if present */ armature_def_nr = defgroup_name_index(target, defgrp_name); - if (ELEM(target->type, OB_MESH, OB_LATTICE)) { + if (ELEM(target->type, OB_MESH, OB_LATTICE, OB_GPENCIL)) { defbase_tot = BLI_listbase_count(&target->defbase); if (target->type == OB_MESH) { @@ -1034,17 +1034,22 @@ void armature_deform_verts(Object *armOb, Object *target, const Mesh * mesh, flo if (dverts) target_totvert = me->totvert; } - else { + else if (target->type == OB_LATTICE) { Lattice *lt = target->data; dverts = lt->dvert; if (dverts) target_totvert = lt->pntsu * lt->pntsv * lt->pntsw; } + else if (target->type == OB_GPENCIL) { + dverts = gps->dvert; + if (dverts) + target_totvert = gps->totpoints; + } } /* get a vertex-deform-index to posechannel array */ if (deformflag & ARM_DEF_VGROUP) { - if (ELEM(target->type, OB_MESH, OB_LATTICE)) { + if (ELEM(target->type, OB_MESH, OB_LATTICE, OB_GPENCIL)) { /* if we have a Mesh, only use dverts if it has them */ if (mesh) { use_dverts = (mesh->dvert != NULL); diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index 2b3ec4aeaec..42a1a308de2 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -26,6 +26,10 @@ * Defines and code for core node types */ +/** \file blender/blenkernel/intern/armature_update.c + * \ingroup bke + */ + #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index e1cc3984601..84df994f051 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -525,6 +525,24 @@ void BKE_brush_gpencil_presets(bContext *C) } +void BKE_brush_update_material(Main *bmain, Material *ma, Brush *exclude_brush) +{ + for (Brush *brush = bmain->brush.first; brush; brush = brush->id.next) { + if ((exclude_brush != NULL) && (brush == exclude_brush)) { + continue; + } + + if (brush->gpencil_settings != NULL) { + BrushGpencilSettings *gpencil_settings = brush->gpencil_settings; + if (((gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) == 0) && + (gpencil_settings->material != ma)) + { + gpencil_settings->material = ma; + } + } + } +} + /* get the active gp-brush for editing */ Brush *BKE_brush_getactive_gpencil(ToolSettings *ts) { diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 04e09d06405..1537743fff4 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -44,8 +44,8 @@ #include "BKE_object.h" #include "BKE_scene.h" -#include "DNA_group_types.h" #include "DNA_ID.h" +#include "DNA_collection_types.h" #include "DNA_layer_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index a734e140932..0ba30fedc32 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -33,8 +33,8 @@ #include "MEM_guardedalloc.h" #include "DNA_cloth_types.h" +#include "DNA_collection_types.h" #include "DNA_effect_types.h" -#include "DNA_group_types.h" #include "DNA_object_types.h" #include "DNA_object_force_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 0684231480b..c090569421d 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -956,17 +956,15 @@ static void curvemapping_evaluateRGBF_filmlike(const CurveMapping *cumap, float static float curvemapping_weighted_standard_triangle(float a, float b, float a1) { - if (a != b) - { + if (a != b) { float b1; float a2 = a1 - a; - if (b < a) - { - b1 = b + a2 * b / a ; + if (b < a) { + b1 = b + a2 * b / a ; } else { - b1 = b + a2 * (65535.f - b) / (65535.f - a); + b1 = b + a2 * (65535.0f - b) / (65535.0f - a); } return b1; @@ -992,8 +990,7 @@ void curvemapping_evaluate_premulRGBF_ex( const float g = (vecin[1] - black[1]) * bwmul[1]; const float b = (vecin[2] - black[2]) * bwmul[2]; - switch (cumap->tone) - { + switch (cumap->tone) { default: case CURVE_TONE_STANDARD: { diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 84ca143dc55..2eb5b2f4f13 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -30,7 +30,7 @@ #include "MEM_guardedalloc.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index c1bdfc42a05..4b61d35cac8 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -41,9 +41,9 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" #include "DNA_dynamicpaint_types.h" -#include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 52ea4bf4a5e..a123b12d385 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -37,8 +37,8 @@ #include "MEM_guardedalloc.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" -#include "DNA_group_types.h" #include "DNA_listBase.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c index a9719a3611b..63e224fddd2 100644 --- a/source/blender/blenkernel/intern/fracture.c +++ b/source/blender/blenkernel/intern/fracture.c @@ -64,7 +64,7 @@ #include "DNA_scene_types.h" #include "DNA_fracture_types.h" #include "DNA_gpencil_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" diff --git a/source/blender/blenkernel/intern/fracture_automerge.c b/source/blender/blenkernel/intern/fracture_automerge.c index 24ee2beb6ea..3604bfa918d 100644 --- a/source/blender/blenkernel/intern/fracture_automerge.c +++ b/source/blender/blenkernel/intern/fracture_automerge.c @@ -39,7 +39,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_fracture_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_scene_types.h" #include "DNA_rigidbody_types.h" diff --git a/source/blender/blenkernel/intern/fracture_constraints.c b/source/blender/blenkernel/intern/fracture_constraints.c index 58eb07fdf21..18545e328a7 100644 --- a/source/blender/blenkernel/intern/fracture_constraints.c +++ b/source/blender/blenkernel/intern/fracture_constraints.c @@ -45,7 +45,7 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c index d439b5e7a6e..57a2d2d4134 100644 --- a/source/blender/blenkernel/intern/freestyle.c +++ b/source/blender/blenkernel/intern/freestyle.c @@ -31,8 +31,8 @@ #include "MEM_guardedalloc.h" +#include "DNA_collection_types.h" #include "DNA_freestyle_types.h" -#include "DNA_group_types.h" #include "BLI_blenlib.h" #include "BLI_math.h" diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 57494397f40..6d771148723 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -57,6 +57,7 @@ #include "BKE_context.h" #include "BKE_action.h" #include "BKE_animsys.h" +#include "BKE_deform.h" #include "BKE_global.h" #include "BKE_gpencil.h" #include "BKE_colortools.h" @@ -519,7 +520,6 @@ bGPDstroke *BKE_gpencil_add_stroke(bGPDframe *gpf, int mat_idx, int totpoints, s gps->totpoints = totpoints; gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); /* initialize triangle memory to dummy data */ gps->triangles = MEM_callocN(sizeof(bGPDtriangle), "GP Stroke triangulation"); @@ -546,21 +546,7 @@ void BKE_gpencil_stroke_weights_duplicate(bGPDstroke *gps_src, bGPDstroke *gps_d } BLI_assert(gps_src->totpoints == gps_dst->totpoints); - if ((gps_src->dvert == NULL) || (gps_dst->dvert == NULL)) { - return; - } - - for (int i = 0; i < gps_src->totpoints; i++) { - MDeformVert *dvert_src = &gps_src->dvert[i]; - MDeformVert *dvert_dst = &gps_dst->dvert[i]; - if (dvert_src->totweight > 0) { - dvert_dst->dw = MEM_dupallocN(dvert_src->dw); - } - else { - dvert_dst->dw = NULL; - } - - } + BKE_defvert_array_copy(gps_dst->dvert, gps_src->dvert, gps_src->totpoints); } /* make a copy of a given gpencil stroke */ @@ -573,8 +559,13 @@ bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src) gps_dst->points = MEM_dupallocN(gps_src->points); - gps_dst->dvert = MEM_dupallocN(gps_src->dvert); - BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst); + if (gps_src->dvert != NULL) { + gps_dst->dvert = MEM_dupallocN(gps_src->dvert); + BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst); + } + else { + gps_dst->dvert = NULL; + } /* Don't clear triangles, so that modifier evaluation can just use * this without extra work first. Most places that need to force @@ -1223,7 +1214,6 @@ void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup) { bGPdata *gpd = ob->data; MDeformVert *dvert = NULL; - MDeformWeight *gpw = NULL; const int def_nr = BLI_findindex(&ob->defbase, defgroup); /* Remove points data */ @@ -1233,15 +1223,9 @@ void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup) for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { for (int i = 0; i < gps->totpoints; i++) { dvert = &gps->dvert[i]; - for (int i2 = 0; i2 < dvert->totweight; i2++) { - gpw = &dvert->dw[i2]; - if (gpw->def_nr == def_nr) { - BKE_gpencil_vgroup_remove_point_weight(dvert, def_nr); - } - /* if index is greater, must be moved one back */ - if (gpw->def_nr > def_nr) { - gpw->def_nr--; - } + MDeformWeight *dw = defvert_find_index(dvert, def_nr); + if (dw != NULL) { + defvert_remove_group(dvert, dw); } } } @@ -1253,85 +1237,14 @@ void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup) BLI_freelinkN(&ob->defbase, defgroup); } -/* add a new weight */ -MDeformWeight *BKE_gpencil_vgroup_add_point_weight(MDeformVert *dvert, int index, float weight) -{ - MDeformWeight *new_gpw = NULL; - MDeformWeight *tmp_gpw; - - /* need to verify if was used before to update */ - for (int i = 0; i < dvert->totweight; i++) { - tmp_gpw = &dvert->dw[i]; - if (tmp_gpw->def_nr == index) { - tmp_gpw->weight = weight; - return tmp_gpw; - } - } - dvert->totweight++; - if (dvert->totweight == 1) { - dvert->dw = MEM_callocN(sizeof(MDeformWeight), "gp_weight"); - } - else { - dvert->dw = MEM_reallocN(dvert->dw, sizeof(MDeformWeight) * dvert->totweight); - } - new_gpw = &dvert->dw[dvert->totweight - 1]; - new_gpw->def_nr = index; - new_gpw->weight = weight; - - return new_gpw; -} - -/* return the weight if use index or -1*/ -float BKE_gpencil_vgroup_use_index(MDeformVert *dvert, int index) +void BKE_gpencil_dvert_ensure(bGPDstroke *gps) { - MDeformWeight *gpw; - for (int i = 0; i < dvert->totweight; i++) { - gpw = &dvert->dw[i]; - if (gpw->def_nr == index) { - return gpw->weight; - } - } - return -1.0f; -} - -/* add a new weight */ -bool BKE_gpencil_vgroup_remove_point_weight(MDeformVert *dvert, int index) -{ - int e = 0; - - if (BKE_gpencil_vgroup_use_index(dvert, index) < 0.0f) { - return false; - } - - /* if the array get empty, exit */ - if (dvert->totweight == 1) { - dvert->totweight = 0; - MEM_SAFE_FREE(dvert->dw); - return true; - } - - /* realloc weights */ - MDeformWeight *tmp = MEM_dupallocN(dvert->dw); - MEM_SAFE_FREE(dvert->dw); - dvert->dw = MEM_callocN(sizeof(MDeformWeight) * dvert->totweight - 1, "gp_weights"); - - for (int x = 0; x < dvert->totweight; x++) { - MDeformWeight *gpw = &tmp[e]; - MDeformWeight *final_gpw = &dvert->dw[e]; - if (gpw->def_nr != index) { - final_gpw->def_nr = gpw->def_nr; - final_gpw->weight = gpw->weight; - e++; - } + if (gps->dvert == NULL) { + gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); } - MEM_SAFE_FREE(tmp); - dvert->totweight--; - - return true; } - /* ************************************************** */ /** diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c index 3b0c86a1832..af82d8fa200 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier.c +++ b/source/blender/blenkernel/intern/gpencil_modifier.c @@ -23,9 +23,9 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/blenkernel/intern/gpencil_modifier.c - * \ingroup bke - */ + /** \file blender/blenkernel/intern/gpencil_modifier.c + * \ingroup bke + */ #include <stdio.h> @@ -220,8 +220,12 @@ static void gpencil_rdp_stroke(bGPDstroke *gps, vec2f *points2d, float epsilon) /* adding points marked */ bGPDspoint *old_points = MEM_dupallocN(gps->points); - MDeformVert *old_dvert = MEM_dupallocN(gps->dvert); + MDeformVert *old_dvert = NULL; + MDeformVert *dvert_src = NULL; + if (gps->dvert != NULL) { + old_dvert = MEM_dupallocN(gps->dvert); + } /* resize gps */ gps->flag |= GP_STROKE_RECALC_CACHES; gps->tot_triangles = 0; @@ -231,16 +235,23 @@ static void gpencil_rdp_stroke(bGPDstroke *gps, vec2f *points2d, float epsilon) bGPDspoint *pt_src = &old_points[i]; bGPDspoint *pt = &gps->points[j]; - MDeformVert *dvert_src = &old_dvert[i]; - MDeformVert *dvert = &gps->dvert[j]; - if ((marked[i]) || (i == 0) || (i == totpoints - 1)) { memcpy(pt, pt_src, sizeof(bGPDspoint)); - memcpy(dvert, dvert_src, sizeof(MDeformVert)); + if (gps->dvert != NULL) { + dvert_src = &old_dvert[i]; + MDeformVert *dvert = &gps->dvert[j]; + memcpy(dvert, dvert_src, sizeof(MDeformVert)); + if (dvert_src->dw) { + memcpy(dvert->dw, dvert_src->dw, sizeof(MDeformWeight)); + } + } j++; } else { - BKE_gpencil_free_point_weights(dvert_src); + if (gps->dvert != NULL) { + dvert_src = &old_dvert[i]; + BKE_gpencil_free_point_weights(dvert_src); + } } } @@ -257,11 +268,6 @@ void BKE_gpencil_simplify_stroke(bGPDstroke *gps, float factor) /* first create temp data and convert points to 2D */ vec2f *points2d = MEM_mallocN(sizeof(vec2f) * gps->totpoints, "GP Stroke temp 2d points"); - /* for some old files, the weights array could not be initializated */ - if (gps->dvert == NULL) { - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); - } - gpencil_stroke_project_2d(gps->points, gps->totpoints, points2d); gpencil_rdp_stroke(gps, points2d, factor); @@ -276,14 +282,14 @@ void BKE_gpencil_simplify_fixed(bGPDstroke *gps) return; } - /* for some old files, the weights array could not be initializated */ - if (gps->dvert == NULL) { - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); - } - /* save points */ bGPDspoint *old_points = MEM_dupallocN(gps->points); - MDeformVert *old_dvert = MEM_dupallocN(gps->dvert); + MDeformVert *old_dvert = NULL; + MDeformVert *dvert_src = NULL; + + if (gps->dvert != NULL) { + old_dvert = MEM_dupallocN(gps->dvert); + } /* resize gps */ int newtot = (gps->totpoints - 2) / 2; @@ -293,7 +299,9 @@ void BKE_gpencil_simplify_fixed(bGPDstroke *gps) newtot += 2; gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * newtot); - gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * newtot); + if (gps->dvert != NULL) { + gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * newtot); + } gps->flag |= GP_STROKE_RECALC_CACHES; gps->tot_triangles = 0; @@ -302,16 +310,24 @@ void BKE_gpencil_simplify_fixed(bGPDstroke *gps) bGPDspoint *pt_src = &old_points[i]; bGPDspoint *pt = &gps->points[j]; - MDeformVert *dvert_src = &old_dvert[i]; - MDeformVert *dvert = &gps->dvert[j]; if ((i == 0) || (i == gps->totpoints - 1) || ((i % 2) > 0.0)) { memcpy(pt, pt_src, sizeof(bGPDspoint)); - memcpy(dvert, dvert_src, sizeof(MDeformVert)); + if (gps->dvert != NULL) { + dvert_src = &old_dvert[i]; + MDeformVert *dvert = &gps->dvert[j]; + memcpy(dvert, dvert_src, sizeof(MDeformVert)); + if (dvert_src->dw) { + memcpy(dvert->dw, dvert_src->dw, sizeof(MDeformWeight)); + } + } j++; } else { - BKE_gpencil_free_point_weights(dvert_src); + if (gps->dvert != NULL) { + dvert_src = &old_dvert[i]; + BKE_gpencil_free_point_weights(dvert_src); + } } } @@ -331,7 +347,7 @@ void BKE_gpencil_simplify_fixed(bGPDstroke *gps) * each loop over all the geometry being evaluated. */ -/* init lattice deform data */ + /* init lattice deform data */ void BKE_gpencil_lattice_init(Object *ob) { GpencilModifierData *md; @@ -407,10 +423,12 @@ void BKE_gpencil_stroke_modifiers(Depsgraph *depsgraph, Object *ob, bGPDlayer *g /* some modifiers could require a recalc of fill triangulation data */ if (gpd->flag & GP_DATA_STROKE_FORCE_RECALC) { if (ELEM(md->type, - eGpencilModifierType_Hook, - eGpencilModifierType_Lattice, - eGpencilModifierType_Offset)) + eGpencilModifierType_Armature, + eGpencilModifierType_Hook, + eGpencilModifierType_Lattice, + eGpencilModifierType_Offset)) { + gps->flag |= GP_STROKE_RECALC_CACHES; } } @@ -444,7 +462,7 @@ void BKE_gpencil_geometry_modifiers(Depsgraph *depsgraph, Object *ob, bGPDlayer /* *************************************************** */ void BKE_gpencil_eval_geometry(Depsgraph *depsgraph, - bGPdata *gpd) + bGPdata *gpd) { DEG_debug_print_eval(depsgraph, __func__, gpd->id.name, gpd); int ctime = (int)DEG_get_ctime(depsgraph); @@ -458,10 +476,10 @@ void BKE_gpencil_eval_geometry(Depsgraph *depsgraph, * This would be better than inventing our own logic for this stuff... */ - /* TODO: Move the following code to "BKE_gpencil_eval_done()" (marked as an exit node) - * later when there's more happening here. For now, let's just keep this in here to avoid - * needing to have one more node slowing down evaluation... - */ + /* TODO: Move the following code to "BKE_gpencil_eval_done()" (marked as an exit node) + * later when there's more happening here. For now, let's just keep this in here to avoid + * needing to have one more node slowing down evaluation... + */ if (DEG_is_active(depsgraph)) { bGPdata *gpd_orig = (bGPdata *)DEG_get_original_id(&gpd->id); @@ -696,3 +714,108 @@ void BKE_gpencil_instance_modifier_instance_tfm(InstanceGpencilModifierData *mmd /* calculate matrix */ loc_eul_size_to_mat4(r_mat, offset, rot, scale); } + +void BKE_gpencil_subdivide(bGPDstroke *gps, int level, int flag) +{ + bGPDspoint *temp_points; + MDeformVert *temp_dverts = NULL; + MDeformVert *dvert = NULL; + MDeformVert *dvert_final = NULL; + MDeformVert *dvert_next = NULL; + int totnewpoints, oldtotpoints; + int i2; + + for (int s = 0; s < level; s++) { + totnewpoints = gps->totpoints - 1; + /* duplicate points in a temp area */ + temp_points = MEM_dupallocN(gps->points); + oldtotpoints = gps->totpoints; + + /* resize the points arrys */ + gps->totpoints += totnewpoints; + gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints); + if (gps->dvert != NULL) { + temp_dverts = MEM_dupallocN(gps->dvert); + gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints); + } + gps->flag |= GP_STROKE_RECALC_CACHES; + + /* move points from last to first to new place */ + i2 = gps->totpoints - 1; + for (int i = oldtotpoints - 1; i > 0; i--) { + bGPDspoint *pt = &temp_points[i]; + bGPDspoint *pt_final = &gps->points[i2]; + + copy_v3_v3(&pt_final->x, &pt->x); + pt_final->pressure = pt->pressure; + pt_final->strength = pt->strength; + pt_final->time = pt->time; + pt_final->flag = pt->flag; + + if (gps->dvert != NULL) { + dvert = &temp_dverts[i]; + dvert_final = &gps->dvert[i2]; + dvert_final->totweight = dvert->totweight; + dvert_final->dw = dvert->dw; + } + i2 -= 2; + } + /* interpolate mid points */ + i2 = 1; + for (int i = 0; i < oldtotpoints - 1; i++) { + bGPDspoint *pt = &temp_points[i]; + bGPDspoint *next = &temp_points[i + 1]; + bGPDspoint *pt_final = &gps->points[i2]; + + /* add a half way point */ + interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f); + pt_final->pressure = interpf(pt->pressure, next->pressure, 0.5f); + pt_final->strength = interpf(pt->strength, next->strength, 0.5f); + CLAMP(pt_final->strength, GPENCIL_STRENGTH_MIN, 1.0f); + pt_final->time = interpf(pt->time, next->time, 0.5f); + + if (gps->dvert != NULL) { + dvert = &temp_dverts[i]; + dvert_next = &temp_dverts[i + 1]; + dvert_final = &gps->dvert[i2]; + + dvert_final->totweight = dvert->totweight; + dvert_final->dw = MEM_dupallocN(dvert->dw); + + /* interpolate weight values */ + for (int d = 0; d < dvert->totweight; d++) { + MDeformWeight *dw_a = &dvert->dw[d]; + if (dvert_next->totweight > d) { + MDeformWeight *dw_b = &dvert_next->dw[d]; + MDeformWeight *dw_final = &dvert_final->dw[d]; + dw_final->weight = interpf(dw_a->weight, dw_b->weight, 0.5f); + } + } + } + + i2 += 2; + } + + MEM_SAFE_FREE(temp_points); + MEM_SAFE_FREE(temp_dverts); + + /* move points to smooth stroke (not simple flag )*/ + if ((flag & GP_SUBDIV_SIMPLE) == 0) { + /* duplicate points in a temp area with the new subdivide data */ + temp_points = MEM_dupallocN(gps->points); + + /* extreme points are not changed */ + for (int i = 0; i < gps->totpoints - 2; i++) { + bGPDspoint *pt = &temp_points[i]; + bGPDspoint *next = &temp_points[i + 1]; + bGPDspoint *pt_final = &gps->points[i + 1]; + + /* move point */ + interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f); + } + /* free temp memory */ + MEM_SAFE_FREE(temp_points); + } + + } +} diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 3a4bf53e22d..23cb6c71696 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -38,8 +38,8 @@ #include "MEM_guardedalloc.h" #include "DNA_brush_types.h" +#include "DNA_collection_types.h" #include "DNA_gpencil_types.h" -#include "DNA_group_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 1396ad1f97c..4df1b72d02a 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -44,8 +44,8 @@ #include "BKE_node.h" #include "BKE_object.h" -#include "DNA_group_types.h" #include "DNA_ID.h" +#include "DNA_collection_types.h" #include "DNA_layer_types.h" #include "DNA_object_types.h" #include "DNA_node_types.h" diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 06207eabe31..04ebaaf80b7 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -47,7 +47,7 @@ #include "DNA_brush_types.h" #include "DNA_cachefile_types.h" #include "DNA_camera_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_gpencil_types.h" #include "DNA_ipo_types.h" #include "DNA_key_types.h" diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index 0626e051e83..c569f43e7f4 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -35,8 +35,8 @@ #include "DNA_armature_types.h" #include "DNA_brush_types.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" -#include "DNA_group_types.h" #include "DNA_gpencil_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index 5d9445fa08d..cf4b6117599 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -39,7 +39,7 @@ #include "DNA_brush_types.h" #include "DNA_camera_types.h" #include "DNA_cachefile_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_gpencil_types.h" #include "DNA_ipo_types.h" #include "DNA_key_types.h" diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 662f1320b40..ccd88cffda6 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -37,8 +37,8 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" -#include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ec867546f3f..f0dcb333be0 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -39,10 +39,10 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" #include "DNA_gpencil_types.h" #include "DNA_gpencil_modifier_types.h" -#include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" @@ -1839,6 +1839,11 @@ static bool ob_parcurve(Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob, } BKE_displist_make_curveTypes(depsgraph, scene, par, 0); } +#else + /* See: T56619 */ + if (par->runtime.curve_cache == NULL) { + return false; + } #endif if (par->runtime.curve_cache->path == NULL) { diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index e288adaf9ad..9f6cdcd5179 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -42,7 +42,7 @@ #include "BLI_rand.h" #include "DNA_anim_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_mesh_types.h" #include "DNA_scene_types.h" #include "DNA_vfont_types.h" diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 54d21c261fc..8b82053868a 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -28,8 +28,8 @@ */ #include "DNA_anim_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" -#include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 4d4843928e2..da5efe3eeb8 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -36,8 +36,8 @@ #include "MEM_guardedalloc.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" -#include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 3e7a9b7ce24..00d6fa96856 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1107,7 +1107,6 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag) static int pbvh_get_buffers_update_flags(PBVH *bvh) { int update_flags = 0; - update_flags |= bvh->show_diffuse_color ? GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR : 0; update_flags |= bvh->show_mask ? GPU_PBVH_BUFFERS_SHOW_MASK : 0; return update_flags; } @@ -2053,33 +2052,11 @@ bool BKE_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data) return test_planes_aabb(bb_min, bb_max, data) != ISECT_INSIDE; } -static void pbvh_node_check_diffuse_changed(PBVH *bvh, PBVHNode *node) -{ - if (!node->draw_buffers) - return; - - if (GPU_pbvh_buffers_diffuse_changed(node->draw_buffers, node->bm_faces, bvh->show_diffuse_color)) - node->flag |= PBVH_UpdateDrawBuffers; -} - -/* TODO: not needed anymore in 2.8? */ -#if 0 -static void pbvh_node_check_mask_changed(PBVH *bvh, PBVHNode *node) -{ - if (!node->draw_buffers) { - return; - } - if (GPU_pbvh_buffers_mask_changed(node->draw_buffers, bvh->show_mask)) { - node->flag |= PBVH_UpdateDrawBuffers; - } -} -#endif - struct PBVHNodeDrawCallbackData { - void (*draw_fn)(void *user_data, GPUBatch *batch); void *user_data; bool fast; + bool only_mask; /* Only draw nodes that have mask data. */ }; static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) @@ -2088,8 +2065,11 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) if (!(node->flag & PBVH_FullyHidden)) { GPUBatch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast); - if (triangles != NULL) { - data->draw_fn(data->user_data, triangles); + bool show_mask = GPU_pbvh_buffers_has_mask(node->draw_buffers); + if (!data->only_mask || show_mask) { + if (triangles != NULL) { + data->draw_fn(data->user_data, triangles); + } } } } @@ -2098,10 +2078,11 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) * Version of #BKE_pbvh_draw that runs a callback. */ void BKE_pbvh_draw_cb( - PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, + PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, bool only_mask, void (*draw_fn)(void *user_data, GPUBatch *batch), void *user_data) { struct PBVHNodeDrawCallbackData draw_data = { + .only_mask = only_mask, .fast = fast, .draw_fn = draw_fn, .user_data = user_data, @@ -2109,9 +2090,6 @@ void BKE_pbvh_draw_cb( PBVHNode **nodes; int totnode; - for (int a = 0; a < bvh->totnode; a++) - pbvh_node_check_diffuse_changed(bvh, &bvh->nodes[a]); - BKE_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers), &nodes, &totnode); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 38f4eedcf66..e346fc1f33f 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -37,8 +37,8 @@ #include "MEM_guardedalloc.h" #include "DNA_ID.h" +#include "DNA_collection_types.h" #include "DNA_dynamicpaint_types.h" -#include "DNA_group_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_object_force_types.h" @@ -3163,117 +3163,116 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) /* clear all files in the temp dir with the prefix of the ID and the ".bphys" suffix */ switch (mode) { - case PTCACHE_CLEAR_ALL: - case PTCACHE_CLEAR_BEFORE: - case PTCACHE_CLEAR_AFTER: - if (pid->cache->flag & PTCACHE_DISK_CACHE) { - ptcache_path(pid, path); - - dir = opendir(path); - if (dir==NULL) - return; + case PTCACHE_CLEAR_ALL: + case PTCACHE_CLEAR_BEFORE: + case PTCACHE_CLEAR_AFTER: + if (pid->cache->flag & PTCACHE_DISK_CACHE) { + ptcache_path(pid, path); + + dir = opendir(path); + if (dir==NULL) + return; + + len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */ + /* append underscore terminator to ensure we don't match similar names + * from objects whose names start with the same prefix + */ + if (len < sizeof(filename) - 2) { + BLI_strncpy(filename + len, "_", sizeof(filename) - 2 - len); + len += 1; + } - len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */ - /* append underscore terminator to ensure we don't match similar names - * from objects whose names start with the same prefix - */ - if (len < sizeof(filename) - 2) { - BLI_strncpy(filename + len, "_", sizeof(filename) - 2 - len); - len += 1; - } + BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext); - BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext); - - while ((de = readdir(dir)) != NULL) { - if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ - if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ - if (mode == PTCACHE_CLEAR_ALL) { - pid->cache->last_exact = MIN2(pid->cache->startframe, 0); - BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); - BLI_delete(path_full, false, false); - } - else { - /* read the number of the file */ - const int frame = ptcache_frame_from_filename(de->d_name, ext); - - if (frame != -1) { - if ((mode == PTCACHE_CLEAR_BEFORE && frame < cfra) || - (mode == PTCACHE_CLEAR_AFTER && frame > cfra)) - { - - BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); - BLI_delete(path_full, false, false); - if (pid->cache->cached_frames && frame >=sta && frame <= end) - pid->cache->cached_frames[frame-sta] = 0; + while ((de = readdir(dir)) != NULL) { + if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ + if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ + if (mode == PTCACHE_CLEAR_ALL) { + pid->cache->last_exact = MIN2(pid->cache->startframe, 0); + BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); + BLI_delete(path_full, false, false); + } + else { + /* read the number of the file */ + const int frame = ptcache_frame_from_filename(de->d_name, ext); + + if (frame != -1) { + if ((mode == PTCACHE_CLEAR_BEFORE && frame < cfra) || + (mode == PTCACHE_CLEAR_AFTER && frame > cfra)) + { + BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); + BLI_delete(path_full, false, false); + if (pid->cache->cached_frames && frame >=sta && frame <= end) + pid->cache->cached_frames[frame-sta] = 0; + } } } } } } - } - closedir(dir); - - if (mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames) - memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames)); - } - else { - PTCacheMem *pm= pid->cache->mem_cache.first; - PTCacheMem *link= NULL; - - if (mode == PTCACHE_CLEAR_ALL) { - /*we want startframe if the cache starts before zero*/ - pid->cache->last_exact = MIN2(pid->cache->startframe, 0); - for (; pm; pm=pm->next) { - ptcache_data_free(pm); - ptcache_extra_free(pm); - } - BLI_freelistN(&pid->cache->mem_cache); + closedir(dir); - if (pid->cache->cached_frames) + if (mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames) memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames)); } else { - while (pm) { - if ((mode == PTCACHE_CLEAR_BEFORE && pm->frame < cfra) || - (mode == PTCACHE_CLEAR_AFTER && pm->frame > cfra)) - { - link = pm; - if (pid->cache->cached_frames && pm->frame >=sta && pm->frame <= end) - pid->cache->cached_frames[pm->frame-sta] = 0; + PTCacheMem *pm= pid->cache->mem_cache.first; + PTCacheMem *link= NULL; + + if (mode == PTCACHE_CLEAR_ALL) { + /*we want startframe if the cache starts before zero*/ + pid->cache->last_exact = MIN2(pid->cache->startframe, 0); + for (; pm; pm=pm->next) { ptcache_data_free(pm); ptcache_extra_free(pm); - pm = pm->next; - BLI_freelinkN(&pid->cache->mem_cache, link); } - else - pm = pm->next; + BLI_freelistN(&pid->cache->mem_cache); + + if (pid->cache->cached_frames) + memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames)); + } + else { + while (pm) { + if ((mode == PTCACHE_CLEAR_BEFORE && pm->frame < cfra) || + (mode == PTCACHE_CLEAR_AFTER && pm->frame > cfra)) + { + link = pm; + if (pid->cache->cached_frames && pm->frame >=sta && pm->frame <= end) + pid->cache->cached_frames[pm->frame-sta] = 0; + ptcache_data_free(pm); + ptcache_extra_free(pm); + pm = pm->next; + BLI_freelinkN(&pid->cache->mem_cache, link); + } + else + pm = pm->next; + } } } - } - break; + break; - case PTCACHE_CLEAR_FRAME: - if (pid->cache->flag & PTCACHE_DISK_CACHE) { - if (BKE_ptcache_id_exist(pid, cfra)) { - ptcache_filename(pid, filename, cfra, 1, 1); /* no path */ - BLI_delete(filename, false, false); + case PTCACHE_CLEAR_FRAME: + if (pid->cache->flag & PTCACHE_DISK_CACHE) { + if (BKE_ptcache_id_exist(pid, cfra)) { + ptcache_filename(pid, filename, cfra, 1, 1); /* no path */ + BLI_delete(filename, false, false); + } } - } - else { - PTCacheMem *pm = pid->cache->mem_cache.first; + else { + PTCacheMem *pm = pid->cache->mem_cache.first; - for (; pm; pm=pm->next) { - if (pm->frame == cfra) { - ptcache_data_free(pm); - ptcache_extra_free(pm); - BLI_freelinkN(&pid->cache->mem_cache, pm); - break; + for (; pm; pm=pm->next) { + if (pm->frame == cfra) { + ptcache_data_free(pm); + ptcache_extra_free(pm); + BLI_freelinkN(&pid->cache->mem_cache, pm); + break; + } } } - } - if (pid->cache->cached_frames && cfra >= sta && cfra <= end) - pid->cache->cached_frames[cfra-sta] = 0; - break; + if (pid->cache->cached_frames && cfra >= sta && cfra <= end) + pid->cache->cached_frames[cfra-sta] = 0; + break; } BKE_ptcache_update_info(pid); diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 0d1ac4c90d2..7d845b4b69c 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -54,7 +54,7 @@ #include "DNA_fracture_types.h" #include "DNA_ID.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 8522c7f4445..5f72036c3a8 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_linestyle_types.h" #include "DNA_mesh_types.h" #include "DNA_node_types.h" diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 9105961a3ae..65d023fb6f2 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1772,8 +1772,9 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f /* BOX WIPE IS NOT WORKING YET */ #if 0 case DO_BOX_WIPE: - if (!wipe->forward) + if (!wipe->forward) { facf0 = 1.0f - facf0; /* Go the other direction */ + } width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0)); hwidth = (float)width / 2.0; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index d3429622573..3ab55b3705a 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -57,13 +57,13 @@ variables on the UI for now #include "MEM_guardedalloc.h" /* types */ -#include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "DNA_lattice_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" -#include "DNA_mesh_types.h" +#include "DNA_lattice_types.h" #include "DNA_meshdata_types.h" -#include "DNA_group_types.h" +#include "DNA_mesh_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BLI_math.h" #include "BLI_utildefines.h" diff --git a/source/blender/blenkernel/intern/subdiv_converter.c b/source/blender/blenkernel/intern/subdiv_converter.c index 5cad2f3e4cd..47e87bfdd78 100644 --- a/source/blender/blenkernel/intern/subdiv_converter.c +++ b/source/blender/blenkernel/intern/subdiv_converter.c @@ -23,6 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/blenkernel/intern/subdiv_converter.c + * \ingroup bke + */ + #include "subdiv_converter.h" #include "BLI_utildefines.h" diff --git a/source/blender/blenkernel/intern/subdiv_converter.h b/source/blender/blenkernel/intern/subdiv_converter.h index 4c552a9164e..0326c9e504c 100644 --- a/source/blender/blenkernel/intern/subdiv_converter.h +++ b/source/blender/blenkernel/intern/subdiv_converter.h @@ -26,6 +26,10 @@ #ifndef __SUBDIV_CONVERTER_H__ #define __SUBDIV_CONVERTER_H__ +/** \file blender/blenkernel/intern/subdiv_converter.h + * \ingroup bke + */ + #include "BKE_subdiv.h" /* NOTE: Was initially used to get proper enumerator types, but this makes diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.c b/source/blender/blenkernel/intern/subdiv_converter_mesh.c index 32e829a9439..d17ee49ca0c 100644 --- a/source/blender/blenkernel/intern/subdiv_converter_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.c @@ -23,6 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/blenkernel/intern/subdiv_converter_mesh.c + * \ingroup bke + */ + #include "subdiv_converter.h" #include <string.h> diff --git a/source/blender/blenkernel/intern/subdiv_displacement_multires.c b/source/blender/blenkernel/intern/subdiv_displacement_multires.c index 7eb47a70588..1e0e2ae5152 100644 --- a/source/blender/blenkernel/intern/subdiv_displacement_multires.c +++ b/source/blender/blenkernel/intern/subdiv_displacement_multires.c @@ -369,10 +369,9 @@ static int count_num_ptex_faces(const Mesh *mesh) } static void displacement_data_init_mapping(SubdivDisplacement *displacement, - const Object *object) + const Mesh *mesh) { MultiresDisplacementData *data = displacement->user_data; - const Mesh *mesh = (Mesh *)object->data; const MPoly *mpoly = mesh->mpoly; const int num_ptex_faces = count_num_ptex_faces(mesh); /* Allocate memory. */ @@ -400,15 +399,14 @@ static void displacement_data_init_mapping(SubdivDisplacement *displacement, } static void displacement_init_data(SubdivDisplacement *displacement, - const Object *object, + const Mesh *mesh, const MultiresModifierData *mmd) { MultiresDisplacementData *data = displacement->user_data; - Mesh *mesh = (Mesh *)object->data; data->grid_size = (1 << (mmd->totlvl - 1)) + 1; data->mpoly = mesh->mpoly; data->mdisps = CustomData_get_layer(&mesh->ldata, CD_MDISPS); - displacement_data_init_mapping(displacement, object); + displacement_data_init_mapping(displacement, mesh); } static void displacement_init_functions(SubdivDisplacement *displacement) @@ -419,13 +417,9 @@ static void displacement_init_functions(SubdivDisplacement *displacement) void BKE_subdiv_displacement_attach_from_multires( Subdiv *subdiv, - const Object *object, + const Mesh *mesh, const MultiresModifierData *mmd) { - if (object->type != OB_MESH) { - BLI_assert(!"Should never be called for non-mesh objects"); - return; - } /* Make sure we dont' have previously assigned displacement. */ BKE_subdiv_displacement_detach(subdiv); /* Allocate all required memory. */ @@ -433,7 +427,7 @@ void BKE_subdiv_displacement_attach_from_multires( "multires displacement"); displacement->user_data = MEM_callocN(sizeof(MultiresDisplacementData), "multires displacement data"); - displacement_init_data(displacement, object, mmd); + displacement_init_data(displacement, mesh, mmd); displacement_init_functions(displacement); /* Finish. */ subdiv->displacement_evaluator = displacement; diff --git a/source/blender/blenlib/BLI_polyfill_2d.h b/source/blender/blenlib/BLI_polyfill_2d.h index 099f08d4663..0ede111fc42 100644 --- a/source/blender/blenlib/BLI_polyfill_2d.h +++ b/source/blender/blenlib/BLI_polyfill_2d.h @@ -21,6 +21,10 @@ #ifndef __BLI_POLYFILL_2D_H__ #define __BLI_POLYFILL_2D_H__ +/** \file BLI_polyfill_2d.h + * \ingroup bli + */ + struct MemArena; void BLI_polyfill_calc_arena( diff --git a/source/blender/blenlib/BLI_polyfill_2d_beautify.h b/source/blender/blenlib/BLI_polyfill_2d_beautify.h index 73b52125904..96b730bee68 100644 --- a/source/blender/blenlib/BLI_polyfill_2d_beautify.h +++ b/source/blender/blenlib/BLI_polyfill_2d_beautify.h @@ -21,6 +21,10 @@ #ifndef __BLI_POLYFILL_2D_BEAUTIFY_H__ #define __BLI_POLYFILL_2D_BEAUTIFY_H__ +/** \file BLI_polyfill_2d_beautify.h + * \ingroup bli + */ + struct Heap; struct MemArena; diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index f46676ac0cd..938728aa4bb 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -783,7 +783,7 @@ void BLI_str_toupper_ascii(char *str, const size_t len) */ void BLI_str_rstrip(char *str) { - for (int i = strlen(str) - 1; i > 0; i--) { + for (int i = (int)strlen(str) - 1; i > 0; i--) { if (isspace(str[i])) { str[i] = '\0'; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 792a561b91f..76afe05276f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -65,13 +65,13 @@ #include "DNA_camera_types.h" #include "DNA_cachefile_types.h" #include "DNA_cloth_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_effect_types.h" #include "DNA_fileglobal_types.h" #include "DNA_fracture_types.h" #include "DNA_genfile.h" -#include "DNA_group_types.h" #include "DNA_gpencil_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_shader_fx_types.h" @@ -6617,8 +6617,10 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd) gps->points = newdataadr(fd, gps->points); /* relink weight data */ - gps->dvert = newdataadr(fd, gps->dvert); - direct_link_dverts(fd, gps->totpoints, gps->dvert); + if (gps->dvert) { + gps->dvert = newdataadr(fd, gps->dvert); + direct_link_dverts(fd, gps->totpoints, gps->dvert); + } /* the triangulation is not saved, so need to be recalculated */ gps->triangles = NULL; @@ -8141,32 +8143,32 @@ static void lib_link_linestyle(FileData *fd, Main *main) for (m = linestyle->color_modifiers.first; m; m = m->next) { switch (m->type) { - case LS_MODIFIER_DISTANCE_FROM_OBJECT: - { - LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m; - cm->target = newlibadr(fd, linestyle->id.lib, cm->target); - } - break; + case LS_MODIFIER_DISTANCE_FROM_OBJECT: + { + LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m; + cm->target = newlibadr(fd, linestyle->id.lib, cm->target); + } + break; } } for (m = linestyle->alpha_modifiers.first; m; m = m->next) { switch (m->type) { - case LS_MODIFIER_DISTANCE_FROM_OBJECT: - { - LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m; - am->target = newlibadr(fd, linestyle->id.lib, am->target); - } - break; + case LS_MODIFIER_DISTANCE_FROM_OBJECT: + { + LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m; + am->target = newlibadr(fd, linestyle->id.lib, am->target); + } + break; } } for (m = linestyle->thickness_modifiers.first; m; m = m->next) { switch (m->type) { - case LS_MODIFIER_DISTANCE_FROM_OBJECT: - { - LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m; - tm->target = newlibadr(fd, linestyle->id.lib, tm->target); - } - break; + case LS_MODIFIER_DISTANCE_FROM_OBJECT: + { + LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m; + tm->target = newlibadr(fd, linestyle->id.lib, tm->target); + } + break; } } for (int a = 0; a < MAX_MTEX; a++) { @@ -8189,171 +8191,171 @@ static void lib_link_linestyle(FileData *fd, Main *main) static void direct_link_linestyle_color_modifier(FileData *fd, LineStyleModifier *modifier) { switch (modifier->type) { - case LS_MODIFIER_ALONG_STROKE: - { - LineStyleColorModifier_AlongStroke *m = (LineStyleColorModifier_AlongStroke *)modifier; - m->color_ramp = newdataadr(fd, m->color_ramp); - } - break; - case LS_MODIFIER_DISTANCE_FROM_CAMERA: - { - LineStyleColorModifier_DistanceFromCamera *m = (LineStyleColorModifier_DistanceFromCamera *)modifier; - m->color_ramp = newdataadr(fd, m->color_ramp); - } - break; - case LS_MODIFIER_DISTANCE_FROM_OBJECT: - { - LineStyleColorModifier_DistanceFromObject *m = (LineStyleColorModifier_DistanceFromObject *)modifier; - m->color_ramp = newdataadr(fd, m->color_ramp); - } - break; - case LS_MODIFIER_MATERIAL: - { - LineStyleColorModifier_Material *m = (LineStyleColorModifier_Material *)modifier; - m->color_ramp = newdataadr(fd, m->color_ramp); - } - break; - case LS_MODIFIER_TANGENT: - { - LineStyleColorModifier_Tangent *m = (LineStyleColorModifier_Tangent *)modifier; - m->color_ramp = newdataadr(fd, m->color_ramp); - } - break; - case LS_MODIFIER_NOISE: - { - LineStyleColorModifier_Noise *m = (LineStyleColorModifier_Noise *)modifier; - m->color_ramp = newdataadr(fd, m->color_ramp); - } - break; - case LS_MODIFIER_CREASE_ANGLE: - { - LineStyleColorModifier_CreaseAngle *m = (LineStyleColorModifier_CreaseAngle *)modifier; - m->color_ramp = newdataadr(fd, m->color_ramp); - } - break; - case LS_MODIFIER_CURVATURE_3D: - { - LineStyleColorModifier_Curvature_3D *m = (LineStyleColorModifier_Curvature_3D *)modifier; - m->color_ramp = newdataadr(fd, m->color_ramp); - } - break; + case LS_MODIFIER_ALONG_STROKE: + { + LineStyleColorModifier_AlongStroke *m = (LineStyleColorModifier_AlongStroke *)modifier; + m->color_ramp = newdataadr(fd, m->color_ramp); + } + break; + case LS_MODIFIER_DISTANCE_FROM_CAMERA: + { + LineStyleColorModifier_DistanceFromCamera *m = (LineStyleColorModifier_DistanceFromCamera *)modifier; + m->color_ramp = newdataadr(fd, m->color_ramp); + } + break; + case LS_MODIFIER_DISTANCE_FROM_OBJECT: + { + LineStyleColorModifier_DistanceFromObject *m = (LineStyleColorModifier_DistanceFromObject *)modifier; + m->color_ramp = newdataadr(fd, m->color_ramp); + } + break; + case LS_MODIFIER_MATERIAL: + { + LineStyleColorModifier_Material *m = (LineStyleColorModifier_Material *)modifier; + m->color_ramp = newdataadr(fd, m->color_ramp); + } + break; + case LS_MODIFIER_TANGENT: + { + LineStyleColorModifier_Tangent *m = (LineStyleColorModifier_Tangent *)modifier; + m->color_ramp = newdataadr(fd, m->color_ramp); + } + break; + case LS_MODIFIER_NOISE: + { + LineStyleColorModifier_Noise *m = (LineStyleColorModifier_Noise *)modifier; + m->color_ramp = newdataadr(fd, m->color_ramp); + } + break; + case LS_MODIFIER_CREASE_ANGLE: + { + LineStyleColorModifier_CreaseAngle *m = (LineStyleColorModifier_CreaseAngle *)modifier; + m->color_ramp = newdataadr(fd, m->color_ramp); + } + break; + case LS_MODIFIER_CURVATURE_3D: + { + LineStyleColorModifier_Curvature_3D *m = (LineStyleColorModifier_Curvature_3D *)modifier; + m->color_ramp = newdataadr(fd, m->color_ramp); + } + break; } } static void direct_link_linestyle_alpha_modifier(FileData *fd, LineStyleModifier *modifier) { switch (modifier->type) { - case LS_MODIFIER_ALONG_STROKE: - { - LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_DISTANCE_FROM_CAMERA: - { - LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_DISTANCE_FROM_OBJECT: - { - LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_MATERIAL: - { - LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_TANGENT: - { - LineStyleAlphaModifier_Tangent *m = (LineStyleAlphaModifier_Tangent *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_NOISE: - { - LineStyleAlphaModifier_Noise *m = (LineStyleAlphaModifier_Noise *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_CREASE_ANGLE: - { - LineStyleAlphaModifier_CreaseAngle *m = (LineStyleAlphaModifier_CreaseAngle *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_CURVATURE_3D: - { - LineStyleAlphaModifier_Curvature_3D *m = (LineStyleAlphaModifier_Curvature_3D *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; + case LS_MODIFIER_ALONG_STROKE: + { + LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_DISTANCE_FROM_CAMERA: + { + LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_DISTANCE_FROM_OBJECT: + { + LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_MATERIAL: + { + LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_TANGENT: + { + LineStyleAlphaModifier_Tangent *m = (LineStyleAlphaModifier_Tangent *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_NOISE: + { + LineStyleAlphaModifier_Noise *m = (LineStyleAlphaModifier_Noise *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_CREASE_ANGLE: + { + LineStyleAlphaModifier_CreaseAngle *m = (LineStyleAlphaModifier_CreaseAngle *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_CURVATURE_3D: + { + LineStyleAlphaModifier_Curvature_3D *m = (LineStyleAlphaModifier_Curvature_3D *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; } } static void direct_link_linestyle_thickness_modifier(FileData *fd, LineStyleModifier *modifier) { switch (modifier->type) { - case LS_MODIFIER_ALONG_STROKE: - { - LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_DISTANCE_FROM_CAMERA: - { - LineStyleThicknessModifier_DistanceFromCamera *m = (LineStyleThicknessModifier_DistanceFromCamera *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_DISTANCE_FROM_OBJECT: - { - LineStyleThicknessModifier_DistanceFromObject *m = (LineStyleThicknessModifier_DistanceFromObject *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_MATERIAL: - { - LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_TANGENT: - { - LineStyleThicknessModifier_Tangent *m = (LineStyleThicknessModifier_Tangent *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_CREASE_ANGLE: - { - LineStyleThicknessModifier_CreaseAngle *m = (LineStyleThicknessModifier_CreaseAngle *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; - case LS_MODIFIER_CURVATURE_3D: - { - LineStyleThicknessModifier_Curvature_3D *m = (LineStyleThicknessModifier_Curvature_3D *)modifier; - m->curve = newdataadr(fd, m->curve); - direct_link_curvemapping(fd, m->curve); - } - break; + case LS_MODIFIER_ALONG_STROKE: + { + LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_DISTANCE_FROM_CAMERA: + { + LineStyleThicknessModifier_DistanceFromCamera *m = (LineStyleThicknessModifier_DistanceFromCamera *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_DISTANCE_FROM_OBJECT: + { + LineStyleThicknessModifier_DistanceFromObject *m = (LineStyleThicknessModifier_DistanceFromObject *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_MATERIAL: + { + LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_TANGENT: + { + LineStyleThicknessModifier_Tangent *m = (LineStyleThicknessModifier_Tangent *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_CREASE_ANGLE: + { + LineStyleThicknessModifier_CreaseAngle *m = (LineStyleThicknessModifier_CreaseAngle *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; + case LS_MODIFIER_CURVATURE_3D: + { + LineStyleThicknessModifier_Curvature_3D *m = (LineStyleThicknessModifier_Curvature_3D *)modifier; + m->curve = newdataadr(fd, m->curve); + direct_link_curvemapping(fd, m->curve); + } + break; } } @@ -9007,49 +9009,49 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) while (bhead) { switch (bhead->code) { - case DATA: - case DNA1: - case TEST: /* used as preview since 2.5x */ - case REND: - bhead = blo_nextbhead(fd, bhead); - break; - case GLOB: - bhead = read_global(bfd, fd, bhead); - break; - case USER: - if (fd->skip_flags & BLO_READ_SKIP_USERDEF) { + case DATA: + case DNA1: + case TEST: /* used as preview since 2.5x */ + case REND: bhead = blo_nextbhead(fd, bhead); - } - else { - bhead = read_userdef(bfd, fd, bhead); - } - break; - case ENDB: - bhead = NULL; - break; + break; + case GLOB: + bhead = read_global(bfd, fd, bhead); + break; + case USER: + if (fd->skip_flags & BLO_READ_SKIP_USERDEF) { + bhead = blo_nextbhead(fd, bhead); + } + else { + bhead = read_userdef(bfd, fd, bhead); + } + break; + case ENDB: + bhead = NULL; + break; - case ID_ID: - /* Always adds to the most recently loaded ID_LI block, see direct_link_library. - * This is part of the file format definition. */ - if (fd->skip_flags & BLO_READ_SKIP_DATA) { - bhead = blo_nextbhead(fd, bhead); - } - else { - bhead = read_libblock(fd, mainlist.last, bhead, LIB_TAG_READ | LIB_TAG_EXTERN, NULL); - } - break; - /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */ - case ID_SCRN: - bhead->code = ID_SCR; - /* pass on to default */ - ATTR_FALLTHROUGH; - default: - if (fd->skip_flags & BLO_READ_SKIP_DATA) { - bhead = blo_nextbhead(fd, bhead); - } - else { - bhead = read_libblock(fd, bfd->main, bhead, LIB_TAG_LOCAL, NULL); - } + case ID_ID: + /* Always adds to the most recently loaded ID_LI block, see direct_link_library. + * This is part of the file format definition. */ + if (fd->skip_flags & BLO_READ_SKIP_DATA) { + bhead = blo_nextbhead(fd, bhead); + } + else { + bhead = read_libblock(fd, mainlist.last, bhead, LIB_TAG_READ | LIB_TAG_EXTERN, NULL); + } + break; + /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */ + case ID_SCRN: + bhead->code = ID_SCR; + /* pass on to default */ + ATTR_FALLTHROUGH; + default: + if (fd->skip_flags & BLO_READ_SKIP_DATA) { + bhead = blo_nextbhead(fd, bhead); + } + else { + bhead = read_libblock(fd, bfd->main, bhead, LIB_TAG_LOCAL, NULL); + } } } @@ -10154,91 +10156,91 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) expand_idprops(fd, mainvar, id->properties); switch (GS(id->name)) { - case ID_OB: - expand_object(fd, mainvar, (Object *)id); - break; - case ID_ME: - expand_mesh(fd, mainvar, (Mesh *)id); - break; - case ID_CU: - expand_curve(fd, mainvar, (Curve *)id); - break; - case ID_MB: - expand_mball(fd, mainvar, (MetaBall *)id); - break; - case ID_SCE: - expand_scene(fd, mainvar, (Scene *)id); - break; - case ID_MA: - expand_material(fd, mainvar, (Material *)id); - break; - case ID_TE: - expand_texture(fd, mainvar, (Tex *)id); - break; - case ID_WO: - expand_world(fd, mainvar, (World *)id); - break; - case ID_LT: - expand_lattice(fd, mainvar, (Lattice *)id); - break; - case ID_LA: - expand_lamp(fd, mainvar, (Lamp *)id); - break; - case ID_KE: - expand_key(fd, mainvar, (Key *)id); - break; - case ID_CA: - expand_camera(fd, mainvar, (Camera *)id); - break; - case ID_SPK: - expand_speaker(fd, mainvar, (Speaker *)id); - break; - case ID_SO: - expand_sound(fd, mainvar, (bSound *)id); - break; - case ID_LP: - expand_lightprobe(fd, mainvar, (LightProbe *)id); - break; - case ID_AR: - expand_armature(fd, mainvar, (bArmature *)id); - break; - case ID_AC: - expand_action(fd, mainvar, (bAction *)id); // XXX deprecated - old animation system - break; - case ID_GR: - expand_collection(fd, mainvar, (Collection *)id); - break; - case ID_NT: - expand_nodetree(fd, mainvar, (bNodeTree *)id); - break; - case ID_BR: - expand_brush(fd, mainvar, (Brush *)id); - break; - case ID_IP: - expand_ipo(fd, mainvar, (Ipo *)id); // XXX deprecated - old animation system - break; - case ID_PA: - expand_particlesettings(fd, mainvar, (ParticleSettings *)id); - break; - case ID_MC: - expand_movieclip(fd, mainvar, (MovieClip *)id); - break; - case ID_MSK: - expand_mask(fd, mainvar, (Mask *)id); - break; - case ID_LS: - expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id); - break; - case ID_GD: - expand_gpencil(fd, mainvar, (bGPdata *)id); - break; - case ID_CF: - expand_cachefile(fd, mainvar, (CacheFile *)id); - break; - case ID_WS: - expand_workspace(fd, mainvar, (WorkSpace *)id); - default: - break; + case ID_OB: + expand_object(fd, mainvar, (Object *)id); + break; + case ID_ME: + expand_mesh(fd, mainvar, (Mesh *)id); + break; + case ID_CU: + expand_curve(fd, mainvar, (Curve *)id); + break; + case ID_MB: + expand_mball(fd, mainvar, (MetaBall *)id); + break; + case ID_SCE: + expand_scene(fd, mainvar, (Scene *)id); + break; + case ID_MA: + expand_material(fd, mainvar, (Material *)id); + break; + case ID_TE: + expand_texture(fd, mainvar, (Tex *)id); + break; + case ID_WO: + expand_world(fd, mainvar, (World *)id); + break; + case ID_LT: + expand_lattice(fd, mainvar, (Lattice *)id); + break; + case ID_LA: + expand_lamp(fd, mainvar, (Lamp *)id); + break; + case ID_KE: + expand_key(fd, mainvar, (Key *)id); + break; + case ID_CA: + expand_camera(fd, mainvar, (Camera *)id); + break; + case ID_SPK: + expand_speaker(fd, mainvar, (Speaker *)id); + break; + case ID_SO: + expand_sound(fd, mainvar, (bSound *)id); + break; + case ID_LP: + expand_lightprobe(fd, mainvar, (LightProbe *)id); + break; + case ID_AR: + expand_armature(fd, mainvar, (bArmature *)id); + break; + case ID_AC: + expand_action(fd, mainvar, (bAction *)id); // XXX deprecated - old animation system + break; + case ID_GR: + expand_collection(fd, mainvar, (Collection *)id); + break; + case ID_NT: + expand_nodetree(fd, mainvar, (bNodeTree *)id); + break; + case ID_BR: + expand_brush(fd, mainvar, (Brush *)id); + break; + case ID_IP: + expand_ipo(fd, mainvar, (Ipo *)id); // XXX deprecated - old animation system + break; + case ID_PA: + expand_particlesettings(fd, mainvar, (ParticleSettings *)id); + break; + case ID_MC: + expand_movieclip(fd, mainvar, (MovieClip *)id); + break; + case ID_MSK: + expand_mask(fd, mainvar, (Mask *)id); + break; + case ID_LS: + expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id); + break; + case ID_GD: + expand_gpencil(fd, mainvar, (bGPdata *)id); + break; + case ID_CF: + expand_cachefile(fd, mainvar, (CacheFile *)id); + break; + case ID_WS: + expand_workspace(fd, mainvar, (WorkSpace *)id); + default: + break; } do_it = true; diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index fb579aff479..987e4bb3cfa 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -40,9 +40,9 @@ #include "DNA_object_types.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" #include "DNA_gpu_types.h" -#include "DNA_group_types.h" #include "DNA_lamp_types.h" #include "DNA_layer_types.h" #include "DNA_lightprobe_types.h" @@ -81,6 +81,8 @@ #include "BKE_paint.h" #include "BKE_object.h" +#include "BLT_translation.h" + #include "BLO_readfile.h" #include "readfile.h" @@ -408,7 +410,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) BLI_snprintf(name, sizeof(collection_master->id.name), - "Collection %d", + DATA_("Collection %d"), layer + 1); Collection *collection = BKE_collection_add(bmain, collection_master, name); @@ -564,6 +566,21 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) scene->basact = NULL; } +static void do_version_collection_propagate_lib_to_children(Collection *collection) +{ + if (collection->id.lib != NULL) { + for (CollectionChild *collection_child = collection->children.first; + collection_child != NULL; + collection_child = collection_child->next) + { + if (collection_child->collection->id.lib == NULL) { + collection_child->collection->id.lib = collection->id.lib; + } + do_version_collection_propagate_lib_to_children(collection_child->collection); + } + } +} + void do_versions_after_linking_280(Main *bmain) { bool use_collection_compat_28 = true; @@ -580,24 +597,43 @@ void do_versions_after_linking_280(Main *bmain) continue; } - Collection *collection_hidden = NULL; + Collection *hidden_collection_array[20] = {NULL}; for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) { cob_next = cob->next; Object *ob = cob->ob; if (!(ob->lay & collection->layer)) { - if (collection_hidden == NULL) { - collection_hidden = BKE_collection_add(bmain, collection, "Hidden"); - collection_hidden->id.lib = collection->id.lib; - collection_hidden->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; + /* Find or create hidden collection matching object's first layer. */ + Collection **collection_hidden = NULL; + int coll_idx = 0; + for (; coll_idx < 20; coll_idx++) { + if (ob->lay & (1 << coll_idx)) { + collection_hidden = &hidden_collection_array[coll_idx]; + break; + } + } + BLI_assert(collection_hidden != NULL); + + if (*collection_hidden == NULL) { + char name[MAX_ID_NAME]; + BLI_snprintf(name, sizeof(name), DATA_("Hidden %d"), coll_idx + 1); + *collection_hidden = BKE_collection_add(bmain, collection, name); + (*collection_hidden)->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; } - BKE_collection_object_add(bmain, collection_hidden, ob); + BKE_collection_object_add(bmain, *collection_hidden, ob); BKE_collection_object_remove(bmain, collection, ob, true); } } } + /* We need to assign lib pointer to generated hidden collections *after* all have been created, otherwise we'll + * end up with several datablocks sharing same name/library, which is FORBIDDEN! + * Note: we need this to be recursive, since a child collection may be sorted before its parent in bmain... */ + for (Collection *collection = bmain->collection.first; collection != NULL; collection = collection->id.next) { + do_version_collection_propagate_lib_to_children(collection); + } + /* Convert layers to collections. */ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { do_version_layers_to_collections(bmain, scene); diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index e6f8e70f70b..1fd82d01cf5 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -76,6 +76,26 @@ void BLO_update_defaults_userpref_blend(void) * This function can be emptied each time the startup.blend is updated. */ void BLO_update_defaults_startup_blend(Main *bmain) { + for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { + const char *name = workspace->id.name + 2; + + if (STREQ(name, "2D Animation")) { + workspace->object_mode = OB_MODE_GPENCIL_PAINT; + } + if (STREQ(name, "3D Animation")) { + workspace->object_mode = OB_MODE_POSE; + } + else if (STREQ(name, "Texture Paint")) { + workspace->object_mode = OB_MODE_TEXTURE_PAINT; + } + else if (STREQ(name, "Sculpting")) { + workspace->object_mode = OB_MODE_SCULPT; + } + else if (STREQ(name, "UV Editing")) { + workspace->object_mode = OB_MODE_EDIT; + } + } + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) { diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 30bbec1f482..61966ec49b7 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -46,9 +46,9 @@ #include "DNA_armature_types.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" #include "DNA_effect_types.h" -#include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" #include "DNA_lamp_types.h" diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index f5f16980a63..165658717df 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -113,10 +113,10 @@ #include "DNA_cachefile_types.h" #include "DNA_camera_types.h" #include "DNA_cloth_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_genfile.h" -#include "DNA_group_types.h" #include "DNA_gpencil_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_shader_fx_types.h" diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index a454fb7e948..0dcbc05b201 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -1549,14 +1549,17 @@ void bmesh_edit_end(BMesh *bm, BMOpTypeFlag type_flag) void BM_mesh_elem_index_ensure_ex(BMesh *bm, const char htype, int elem_offset[4]) { - const char htype_needed = bm->elem_index_dirty & htype; #ifdef DEBUG BM_ELEM_INDEX_VALIDATE(bm, "Should Never Fail!", __func__); #endif - if (0 && htype_needed == 0) { - goto finally; + if (elem_offset == NULL) { + /* Simple case. */ + const char htype_needed = bm->elem_index_dirty & htype; + if (htype_needed == 0) { + goto finally; + } } if (htype & BM_VERT) { diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index d5702f24383..46ea882c0a1 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -59,6 +59,8 @@ #include "bmesh.h" #include "intern/bmesh_operators_private.h" +#include "DNA_modifier_types.h" + /* The formatting of these bmesh operators is parsed by * 'doc/python_api/rst_from_bmesh_opdefines.py' * for use in python docs, so reStructuredText may be used @@ -95,6 +97,32 @@ * note that '//' comments are ignored. */ +/* enums shared between multiple operators */ + +static BMO_FlagSet bmo_enum_axis_xyz[] = { + {0, "X"}, + {1, "Y"}, + {2, "Z"}, + {0, NULL}, +}; + +static BMO_FlagSet bmo_enum_falloff_type[] = { + {SUBD_FALLOFF_SMOOTH, "SMOOTH"}, + {SUBD_FALLOFF_SPHERE, "SPHERE"}, + {SUBD_FALLOFF_ROOT, "ROOT"}, + {SUBD_FALLOFF_SHARP, "SHARP"}, + {SUBD_FALLOFF_LIN, "LINEAR"}, + {SUBD_FALLOFF_INVSQUARE, "INVERSE_SQUARE"}, + {0, NULL}, +}; + +static BMO_FlagSet bmo_enum_compare_types[] = { + {SIM_CMP_EQ, "EQUAL"}, + {SIM_CMP_GT, "GREATER_THAN"}, + {SIM_CMP_LT, "LESS_THAN"}, + {0, NULL}, +}; + /* * Vertex Smooth. * @@ -290,7 +318,7 @@ static BMOpDefine bmo_mirror_def = { {{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input geometry */ {"matrix", BMO_OP_SLOT_MAT}, /* matrix defining the mirror transformation */ {"merge_dist", BMO_OP_SLOT_FLT}, /* maximum distance for merging. does no merging if 0. */ - {"axis", BMO_OP_SLOT_INT}, /* the axis to use, 0, 1, or 2 for x, y, z */ + {"axis", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_axis_xyz}, /* the axis to use. */ {"mirror_u", BMO_OP_SLOT_BOOL}, /* mirror UVs across the u axis */ {"mirror_v", BMO_OP_SLOT_BOOL}, /* mirror UVs across the v axis */ {{'\0'}}, @@ -1153,6 +1181,15 @@ static BMOpDefine bmo_dissolve_faces_def = { BMO_OPTYPE_FLAG_SELECT_VALIDATE), }; +static BMO_FlagSet bmo_enum_dissolve_limit_flags[] = { + {BMO_DELIM_NORMAL, "NORMAL"}, + {BMO_DELIM_MATERIAL, "MATERIAL"}, + {BMO_DELIM_SEAM, "SEAM"}, + {BMO_DELIM_SHARP, "SHARP"}, + {BMO_DELIM_UV, "UV"}, + {0, NULL} +}; + /* * Limited Dissolve (Keep Normals). * @@ -1189,7 +1226,7 @@ static BMOpDefine bmo_dissolve_limit_def = { {"use_dissolve_boundaries", BMO_OP_SLOT_BOOL}, {"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, {"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, - {"delimit", BMO_OP_SLOT_INT}, + {"delimit", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_FLAG}, bmo_enum_dissolve_limit_flags}, {{'\0'}}, }, /* slots_out */ @@ -1223,6 +1260,20 @@ static BMOpDefine bmo_dissolve_degenerate_def = { BMO_OPTYPE_FLAG_SELECT_VALIDATE), }; +static BMO_FlagSet bmo_enum_triangulate_quad_method[] = { + {MOD_TRIANGULATE_QUAD_BEAUTY, "BEAUTY"}, + {MOD_TRIANGULATE_QUAD_FIXED, "FIXED"}, + {MOD_TRIANGULATE_QUAD_ALTERNATE, "ALTERNATE"}, + {MOD_TRIANGULATE_QUAD_SHORTEDGE, "SHORT_EDGE"}, + {0, NULL}, +}; + +static BMO_FlagSet bmo_enum_triangulate_ngon_method[] = { + {MOD_TRIANGULATE_NGON_BEAUTY, "BEAUTY"}, + {MOD_TRIANGULATE_NGON_EARCLIP, "EAR_CLIP"}, + {0, NULL}, +}; + /* * Triangulate. */ @@ -1230,8 +1281,8 @@ static BMOpDefine bmo_triangulate_def = { "triangulate", /* slots_in */ {{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, - {"quad_method", BMO_OP_SLOT_INT}, - {"ngon_method", BMO_OP_SLOT_INT}, + {"quad_method", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_triangulate_quad_method}, + {"ngon_method", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_triangulate_ngon_method}, {{'\0'}}, }, /* slots_out */ @@ -1267,6 +1318,14 @@ static BMOpDefine bmo_unsubdivide_def = { BMO_OPTYPE_FLAG_SELECT_VALIDATE), }; +static BMO_FlagSet bmo_enum_subdivide_edges_quad_corner_type[] = { + {SUBD_CORNER_STRAIGHT_CUT, "STRAIGHT_CUT"}, + {SUBD_CORNER_INNERVERT, "INNER_VERT"}, + {SUBD_CORNER_PATH, "PATH"}, + {SUBD_CORNER_FAN, "FAN"}, + {0, NULL}, +}; + /* * Subdivide Edges. * @@ -1278,15 +1337,14 @@ static BMOpDefine bmo_subdivide_edges_def = { /* slots_in */ {{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, {"smooth", BMO_OP_SLOT_FLT}, - {"smooth_falloff", BMO_OP_SLOT_INT}, /* SUBD_FALLOFF_ROOT and friends */ + {"smooth_falloff", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_falloff_type}, /* smooth falloff type */ {"fractal", BMO_OP_SLOT_FLT}, {"along_normal", BMO_OP_SLOT_FLT}, {"cuts", BMO_OP_SLOT_INT}, {"seed", BMO_OP_SLOT_INT}, {"custom_patterns", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL}}, /* uses custom pointers */ {"edge_percents", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_FLT}}, - - {"quad_corner_type", BMO_OP_SLOT_INT}, /* quad corner type, see bmesh_operators.h */ + {"quad_corner_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_subdivide_edges_quad_corner_type}, /* quad corner type */ {"use_grid_fill", BMO_OP_SLOT_BOOL}, /* fill in fully-selected faces with a grid */ {"use_single_edge", BMO_OP_SLOT_BOOL}, /* tessellate the case of one edge selected in a quad or triangle */ {"use_only_quads", BMO_OP_SLOT_BOOL}, /* only subdivide quads (for loopcut) */ @@ -1308,6 +1366,13 @@ static BMOpDefine bmo_subdivide_edges_def = { BMO_OPTYPE_FLAG_SELECT_VALIDATE), }; +static BMO_FlagSet bmo_enum_subdivide_edgering_interp_mode[] = { + {SUBD_RING_INTERP_LINEAR, "LINEAR"}, + {SUBD_RING_INTERP_PATH, "PATH"}, + {SUBD_RING_INTERP_SURF, "SURFACE"}, + {0, NULL}, +}; + /* * Subdivide Edge-Ring. * @@ -1317,10 +1382,10 @@ static BMOpDefine bmo_subdivide_edgering_def = { "subdivide_edgering", /* slots_in */ {{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* input vertices */ - {"interp_mode", BMO_OP_SLOT_INT}, + {"interp_mode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_subdivide_edgering_interp_mode}, /* interpolation method */ {"smooth", BMO_OP_SLOT_FLT}, {"cuts", BMO_OP_SLOT_INT}, - {"profile_shape", BMO_OP_SLOT_INT}, + {"profile_shape", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_falloff_type}, /* profile shape type */ {"profile_shape_factor", BMO_OP_SLOT_FLT}, {{'\0'}}, }, @@ -1360,6 +1425,17 @@ static BMOpDefine bmo_bisect_plane_def = { BMO_OPTYPE_FLAG_SELECT_VALIDATE), }; +static BMO_FlagSet bmo_enum_delete_context[] = { + {DEL_VERTS, "VERTS"}, + {DEL_EDGES, "EDGES"}, + {DEL_ONLYFACES, "FACES_ONLY"}, + {DEL_EDGESFACES, "EDGES_FACES"}, + {DEL_FACES, "FACES"}, + {DEL_FACES_KEEP_BOUNDARY, "FACES_KEEP_BOUNDARY"}, + {DEL_ONLYTAGGED, "TAGGED_ONLY"}, + {0, NULL}, +}; + /* * Delete Geometry. * @@ -1369,7 +1445,7 @@ static BMOpDefine bmo_delete_def = { "delete", /* slots_in */ {{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, - {"context", BMO_OP_SLOT_INT}, /* enum DEL_VERTS ... */ + {"context", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_delete_context}, /* geometry types to delete */ {{'\0'}}, }, {{{'\0'}}}, /* no output */ @@ -1483,6 +1559,20 @@ static BMOpDefine bmo_spin_def = { BMO_OPTYPE_FLAG_SELECT_FLUSH), }; +static BMO_FlagSet bmo_enum_similar_faces_types[] = { + {SIMFACE_MATERIAL, "MATERIAL"}, + {SIMFACE_AREA, "AREA"}, + {SIMFACE_SIDES, "SIDES"}, + {SIMFACE_PERIMETER, "PERIMETER"}, + {SIMFACE_NORMAL, "NORMAL"}, + {SIMFACE_COPLANAR, "COPLANAR"}, + {SIMFACE_SMOOTH, "SMOOTH"}, + {SIMFACE_FACEMAP, "FACE_MAP"}, +#ifdef WITH_FREESTYLE + {SIMFACE_FREESTYLE, "FREESTYLE"}, +#endif + {0, NULL}, +}; /* * Similar Faces Search. @@ -1493,9 +1583,9 @@ static BMOpDefine bmo_similar_faces_def = { "similar_faces", /* slots_in */ {{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */ - {"type", BMO_OP_SLOT_INT}, /* type of selection */ + {"type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_similar_faces_types}, /* type of selection */ {"thresh", BMO_OP_SLOT_FLT}, /* threshold of selection */ - {"compare", BMO_OP_SLOT_INT}, /* comparison method */ + {"compare", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_compare_types}, /* comparison method */ {{'\0'}}, }, /* slots_out */ @@ -1506,6 +1596,21 @@ static BMOpDefine bmo_similar_faces_def = { (BMO_OPTYPE_FLAG_SELECT_FLUSH), }; +static BMO_FlagSet bmo_enum_similar_edges_types[] = { + {SIMEDGE_LENGTH, "LENGTH"}, + {SIMEDGE_DIR, "DIRECTION"}, + {SIMEDGE_FACE, "FACE"}, + {SIMEDGE_FACE_ANGLE, "FACE_ANGLE"}, + {SIMEDGE_CREASE, "CREASE"}, + {SIMEDGE_BEVEL, "BEVEL"}, + {SIMEDGE_SEAM, "SEAM"}, + {SIMEDGE_SHARP, "SHARP"}, +#ifdef WITH_FREESTYLE + {SIMEDGE_FREESTYLE, "FREESTYLE"}, +#endif + {0, NULL}, +}; + /* * Similar Edges Search. * @@ -1515,9 +1620,9 @@ static BMOpDefine bmo_similar_edges_def = { "similar_edges", /* slots_in */ {{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* input edges */ - {"type", BMO_OP_SLOT_INT}, /* type of selection */ + {"type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_similar_edges_types}, /* type of selection */ {"thresh", BMO_OP_SLOT_FLT}, /* threshold of selection */ - {"compare", BMO_OP_SLOT_INT}, /* comparison method */ + {"compare", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_compare_types}, /* comparison method */ {{'\0'}}, }, /* slots_out */ @@ -1528,6 +1633,14 @@ static BMOpDefine bmo_similar_edges_def = { (BMO_OPTYPE_FLAG_SELECT_FLUSH), }; +static BMO_FlagSet bmo_enum_similar_verts_types[] = { + {SIMVERT_NORMAL, "NORMAL"}, + {SIMVERT_FACE, "FACE"}, + {SIMVERT_VGROUP, "VERTEX_GROUP"}, + {SIMVERT_EDGE, "EDGE"}, + {0, NULL}, +}; + /* * Similar Verts Search. * @@ -1537,9 +1650,9 @@ static BMOpDefine bmo_similar_verts_def = { "similar_verts", /* slots_in */ {{"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* input vertices */ - {"type", BMO_OP_SLOT_INT}, /* type of selection */ + {"type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_similar_verts_types}, /* type of selection */ {"thresh", BMO_OP_SLOT_FLT}, /* threshold of selection */ - {"compare", BMO_OP_SLOT_INT}, /* comparison method */ + {"compare", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_compare_types}, /* comparison method */ {{'\0'}}, }, /* slots_out */ @@ -1804,6 +1917,22 @@ static BMOpDefine bmo_create_cube_def = { BMO_OPTYPE_FLAG_SELECT_FLUSH), }; +static BMO_FlagSet bmo_enum_bevel_offset_type[] = { + {BEVEL_AMT_OFFSET, "OFFSET"}, + {BEVEL_AMT_WIDTH, "WIDTH"}, + {BEVEL_AMT_DEPTH, "DEPTH"}, + {BEVEL_AMT_PERCENT, "PERCENT"}, + {0, NULL}, +}; + +static BMO_FlagSet bmo_enum_bevel_harden_normal_type[] = { + {BEVEL_HN_NONE, "NONE"}, + {BEVEL_HN_FACE, "FACE"}, + {BEVEL_HN_ADJ, "ADJACENT"}, + {BEVEL_HN_FIX_SHA, "FIXED_NORMAL_SHADING"}, + {0, NULL}, +}; + /* * Bevel. * @@ -1814,7 +1943,7 @@ static BMOpDefine bmo_bevel_def = { /* slots_in */ {{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input edges and vertices */ {"offset", BMO_OP_SLOT_FLT}, /* amount to offset beveled edge */ - {"offset_type", BMO_OP_SLOT_INT}, /* how to measure offset (enum) */ + {"offset_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_bevel_offset_type}, /* how to measure the offset */ {"segments", BMO_OP_SLOT_INT}, /* number of segments in bevel */ {"profile", BMO_OP_SLOT_FLT}, /* profile shape, 0->1 (.5=>round) */ {"vertex_only", BMO_OP_SLOT_BOOL}, /* only bevel vertices, not edges */ @@ -1824,7 +1953,7 @@ static BMOpDefine bmo_bevel_def = { {"mark_seam", BMO_OP_SLOT_BOOL}, /* extend edge data to allow seams to run across bevels */ {"mark_sharp", BMO_OP_SLOT_BOOL}, /* extend edge data to allow sharp edges to run across bevels */ {"strength", BMO_OP_SLOT_FLT}, /* strength of calculated normal in range (0, 1) for custom clnors */ - {"hnmode", BMO_OP_SLOT_INT}, /* harden normals mode used in bevel if enabled */ + {"hnmode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_bevel_harden_normal_type}, /* harden normals mode used in bevel, if enabled */ {{'\0'}}, }, /* slots_out */ @@ -1842,6 +1971,13 @@ static BMOpDefine bmo_bevel_def = { BMO_OPTYPE_FLAG_SELECT_VALIDATE), }; +/* no enum is defined for this */ +static BMO_FlagSet bmo_enum_beautify_fill_method[] = { + {0, "AREA"}, + {1, "ANGLE"}, + {0, NULL}, +}; + /* * Beautify Fill. * @@ -1853,7 +1989,7 @@ static BMOpDefine bmo_beautify_fill_def = { {{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */ {"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* edges that can be flipped */ {"use_restrict_tag", BMO_OP_SLOT_BOOL}, /* restrict edge rotation to mixed tagged vertices */ - {"method", BMO_OP_SLOT_INT}, /* method to define what is beautiful */ + {"method", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_beautify_fill_method}, /* method to define what is beautiful */ {{'\0'}}, }, /* slots_out */ @@ -2018,6 +2154,13 @@ static BMOpDefine bmo_wireframe_def = { BMO_OPTYPE_FLAG_SELECT_VALIDATE), }; +static BMO_FlagSet bmo_enum_poke_center_mode[] = { + {BMOP_POKE_MEAN_WEIGHTED, "MEAN_WEIGHTED"}, + {BMOP_POKE_MEAN, "MEAN"}, + {BMOP_POKE_BOUNDS, "BOUNDS"}, + {0, NULL}, +}; + /* * Pokes a face. * @@ -2028,7 +2171,7 @@ static BMOpDefine bmo_poke_def = { /* slots_in */ {{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */ {"offset", BMO_OP_SLOT_FLT}, /* center vertex offset along normal */ - {"center_mode", BMO_OP_SLOT_INT}, /* calculation mode for center vertex */ + {"center_mode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_poke_center_mode}, /* calculation mode for center vertex */ {"use_relative_offset", BMO_OP_SLOT_BOOL}, /* apply offset */ {{'\0'}}, }, @@ -2094,7 +2237,7 @@ static BMOpDefine bmo_symmetrize_def = { "symmetrize", /* slots_in */ {{"input", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, - {"direction", BMO_OP_SLOT_INT}, + {"direction", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_axis_xyz}, /* axis to use */ {"dist", BMO_OP_SLOT_FLT}, /* minimum distance */ {{'\0'}}, }, diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index de87da71e8d..fd01bec9531 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -193,13 +193,23 @@ typedef enum eBMOpSlotSubType_Ptr { BMO_OP_SLOT_SUBTYPE_PTR_OBJECT = 102, BMO_OP_SLOT_SUBTYPE_PTR_MESH = 103, } eBMOpSlotSubType_Ptr; +typedef enum eBMOpSlotSubType_Int { + BMO_OP_SLOT_SUBTYPE_INT_ENUM = 200, + BMO_OP_SLOT_SUBTYPE_INT_FLAG = 201, +} eBMOpSlotSubType_Int; typedef union eBMOpSlotSubType_Union { eBMOpSlotSubType_Elem elem; eBMOpSlotSubType_Ptr ptr; eBMOpSlotSubType_Map map; + eBMOpSlotSubType_Int intg; } eBMOpSlotSubType_Union; +typedef struct BMO_FlagSet { + int value; + const char *identifier; +} BMO_FlagSet; + /* please ignore all these structures, don't touch them in tool code, except * for when your defining an operator with BMOpDefine.*/ @@ -218,6 +228,7 @@ typedef struct BMOpSlot { float vec[3]; void **buf; GHash *ghash; + BMO_FlagSet *enum_flags; } data; } BMOpSlot; @@ -269,6 +280,7 @@ typedef struct BMOSlotType { char name[MAX_SLOTNAME]; eBMOpSlotType type; eBMOpSlotSubType_Union subtype; + BMO_FlagSet *enum_flags; } BMOSlotType; typedef struct BMOpDefine { diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 62d892712fd..a8e1b1c3088 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -140,6 +140,10 @@ static void bmo_op_slots_init(const BMOSlotType *slot_types, BMOpSlot *slot_args case BMO_OP_SLOT_MAPPING: slot->data.ghash = BLI_ghash_ptr_new("bmesh slot map hash"); break; + case BMO_OP_SLOT_INT: + if (ELEM(slot->slot_subtype.intg, BMO_OP_SLOT_SUBTYPE_INT_ENUM, BMO_OP_SLOT_SUBTYPE_INT_FLAG)) { + slot->data.enum_flags = slot_types[i].enum_flags; + } default: break; } diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index ab53e282476..31d0dde567b 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -20,6 +20,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file AnimationExporter.cpp + * \ingroup collada + */ + #include "GeometryExporter.h" #include "AnimationExporter.h" #include "MaterialExporter.h" diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 04cd78af830..f5e96dbd813 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -20,6 +20,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file AnimationExporter.h + * \ingroup collada + */ + #include <stdlib.h> #include <stdio.h> #include <math.h> diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index cc4ecd5649b..8d9f67a8eab 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -66,7 +66,7 @@ extern "C" { #include "DNA_scene_types.h" #include "DNA_object_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_meshdata_types.h" #include "DNA_mesh_types.h" #include "DNA_image_types.h" diff --git a/source/blender/collada/SceneExporter.h b/source/blender/collada/SceneExporter.h index f7d56701961..593ed820563 100644 --- a/source/blender/collada/SceneExporter.h +++ b/source/blender/collada/SceneExporter.h @@ -34,7 +34,7 @@ extern "C" { #include "DNA_scene_types.h" #include "DNA_object_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_meshdata_types.h" #include "DNA_mesh_types.h" #include "DNA_image_types.h" diff --git a/source/blender/compositor/intern/COM_Debug.cpp b/source/blender/compositor/intern/COM_Debug.cpp index 6179bd26275..45c51bf1c98 100644 --- a/source/blender/compositor/intern/COM_Debug.cpp +++ b/source/blender/compositor/intern/COM_Debug.cpp @@ -274,7 +274,8 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma #if 0 for (ExecutionSystem::Operations::const_iterator it = system->m_operations.begin(); - it != system->m_operations.end(); ++it) { + it != system->m_operations.end(); ++it) + { NodeOperation *op = *it; len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %s\r\n", node->getbNode()->typeinfo->ui_name); } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 979f2197df0..95f07603592 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -47,11 +47,11 @@ extern "C" { #include "DNA_armature_types.h" #include "DNA_cachefile_types.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" #include "DNA_curve_types.h" #include "DNA_effect_types.h" #include "DNA_gpencil_types.h" -#include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" @@ -143,7 +143,7 @@ DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph) view_layer_(NULL), view_layer_index_(-1), collection_(NULL), - is_parent_collection_visible_(true), + is_parent_collection_visible_(true), cow_id_hash_(NULL) { } @@ -385,7 +385,8 @@ void DepsgraphNodeBuilder::end_build() } } -void DepsgraphNodeBuilder::build_id(ID *id) { +void DepsgraphNodeBuilder::build_id(ID *id) +{ if (id == NULL) { return; } @@ -495,9 +496,6 @@ void DepsgraphNodeBuilder::build_object(int base_index, eDepsNode_LinkedState_Type linked_state, bool is_visible) { - if (string(object->id.name) == "OBGEO-icicles_large_03") { - printf(">> %d\n", is_visible); - } const bool has_object = built_map_.checkIsBuiltAndTag(object); /* Skip rest of components if the ID node was already there. */ if (has_object) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index dbaa7738c33..af251849572 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -47,11 +47,11 @@ extern "C" { #include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_cachefile_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" #include "DNA_curve_types.h" #include "DNA_effect_types.h" #include "DNA_gpencil_types.h" -#include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" diff --git a/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc b/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc index bb79085ae51..47b4895942e 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc @@ -89,7 +89,7 @@ bool stat_entry_comparator(const StatsEntry& a, const StatsEntry& b) string gnuplotify_id_code(const string& name) { - return string("") + name[0] + name [1]; + return string("") + name[0] + name[1]; } string gnuplotify_name(const string& name) diff --git a/source/blender/depsgraph/intern/depsgraph_physics.cc b/source/blender/depsgraph/intern/depsgraph_physics.cc index e542e0c48ae..1868069f0ac 100644 --- a/source/blender/depsgraph/intern/depsgraph_physics.cc +++ b/source/blender/depsgraph/intern/depsgraph_physics.cc @@ -39,7 +39,7 @@ extern "C" { #include "BKE_modifier.h" } /* extern "C" */ -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_object_types.h" #include "DNA_object_force_types.h" diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index 7d1b4c56081..2524dbef367 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -163,6 +163,10 @@ void deg_iterator_objects_step(BLI_Iterator *iter, DEG::IDDepsNode *id_node) /* Set it early in case we need to exit and we are running from within a loop. */ iter->skip = true; + if (!id_node->is_visible) { + return; + } + DEGObjectIterData *data = (DEGObjectIterData *)iter->data; const ID_Type id_type = GS(id_node->id_orig->name); @@ -298,7 +302,11 @@ static void DEG_iterator_ids_step(BLI_Iterator *iter, DEG::IDDepsNode *id_node, { ID *id_cow = id_node->id_cow; - if (only_updated && !(id_cow->recalc & ID_RECALC_ALL)) { + if (!id_node->is_visible) { + iter->skip = true; + return; + } + else if (only_updated && !(id_cow->recalc & ID_RECALC_ALL)) { bNodeTree *ntree = ntreeFromID(id_cow); /* Nodetree is considered part of the datablock. */ diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 035a5b9295b..bac3a2f02fb 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -311,6 +311,7 @@ data_to_c_simple(modes/shaders/paint_wire_vert.glsl SRC) data_to_c_simple(modes/shaders/paint_vert_frag.glsl SRC) data_to_c_simple(modes/shaders/particle_strand_frag.glsl SRC) data_to_c_simple(modes/shaders/particle_strand_vert.glsl SRC) +data_to_c_simple(modes/shaders/sculpt_mask_vert.glsl SRC) data_to_c_simple(modes/shaders/volume_velocity_vert.glsl SRC) data_to_c_simple(engines/gpencil/shaders/gpencil_fill_vert.glsl SRC) diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index da55cbca2e0..ee962898a79 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -37,8 +37,8 @@ #include "BKE_object.h" +#include "DNA_collection_types.h" #include "DNA_lightprobe_types.h" -#include "DNA_group_types.h" #include "PIL_time.h" diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c index 2102f255f75..edb8f4433c9 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c @@ -35,8 +35,9 @@ #include "DNA_screen_types.h" #include "DNA_view3d_types.h" -#include "BKE_gpencil.h" #include "BKE_action.h" +#include "BKE_deform.h" +#include "BKE_gpencil.h" #include "DRW_render.h" @@ -499,11 +500,10 @@ GPUBatch *DRW_gpencil_get_edit_geom(bGPDstroke *gps, float alpha, short dflag) int idx = 0; float fcolor[4]; float fsize = 0; - for (int i = 0; i < gps->totpoints; i++, pt++, dvert++) { + for (int i = 0; i < gps->totpoints; i++, pt++) { /* weight paint */ if (is_weight_paint) { - float weight = BKE_gpencil_vgroup_use_index(dvert, vgindex); - CLAMP(weight, 0.0f, 1.0f); + float weight = gps->dvert ? defvert_find_weight(dvert, vgindex) : 0.0f; float hue = 2.0f * (1.0f - weight) / 3.0f; hsv_to_rgb(hue, 1.0f, 1.0f, &selectColor[0], &selectColor[1], &selectColor[2]); selectColor[3] = 1.0f; @@ -535,6 +535,9 @@ GPUBatch *DRW_gpencil_get_edit_geom(bGPDstroke *gps, float alpha, short dflag) GPU_vertbuf_attr_set(vbo, size_id, idx, &fsize); GPU_vertbuf_attr_set(vbo, pos_id, idx, &pt->x); idx++; + if (gps->dvert != NULL) { + dvert++; + } } return GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); @@ -571,23 +574,14 @@ GPUBatch *DRW_gpencil_get_edlin_geom(bGPDstroke *gps, float alpha, short UNUSED( /* Draw all the stroke lines (selected or not) */ bGPDspoint *pt = gps->points; - - /* GPXX: for some converted files, this struct could be null - * maybe we can remove this and move to versioning code after - * merge */ - if (gps->dvert == NULL) { - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); - } - MDeformVert *dvert = gps->dvert; int idx = 0; float fcolor[4]; - for (int i = 0; i < gps->totpoints; i++, pt++, dvert++) { + for (int i = 0; i < gps->totpoints; i++, pt++) { /* weight paint */ if (is_weight_paint) { - float weight = BKE_gpencil_vgroup_use_index(dvert, vgindex); - CLAMP(weight, 0.0f, 1.0f); + float weight = gps->dvert ? defvert_find_weight(dvert, vgindex) : 0.0f; float hue = 2.0f * (1.0f - weight) / 3.0f; hsv_to_rgb(hue, 1.0f, 1.0f, &selectColor[0], &selectColor[1], &selectColor[2]); selectColor[3] = 1.0f; @@ -605,6 +599,10 @@ GPUBatch *DRW_gpencil_get_edlin_geom(bGPDstroke *gps, float alpha, short UNUSED( GPU_vertbuf_attr_set(vbo, color_id, idx, fcolor); GPU_vertbuf_attr_set(vbo, pos_id, idx, &pt->x); idx++; + + if (gps->dvert != NULL) { + dvert++; + } } return GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index 858a20dbbc3..2dce51fc0ad 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -552,15 +552,15 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create( /* add fill shading group to pass */ static void gpencil_add_fill_shgroup( GpencilBatchCache *cache, DRWShadingGroup *fillgrp, - Object *ob, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, - const float tintcolor[4], const bool onion, const bool custonion) + Object *ob, bGPDlayer *UNUSED(gpl), bGPDframe *gpf, bGPDstroke *gps, + float opacity, const float tintcolor[4], const bool onion, const bool custonion) { MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1); if (gps->totpoints >= 3) { float tfill[4]; /* set color using material, tint color and opacity */ interp_v3_v3v3(tfill, gps->runtime.tmp_fill_rgba, tintcolor, tintcolor[3]); - tfill[3] = gps->runtime.tmp_fill_rgba[3] * gpl->opacity; + tfill[3] = gps->runtime.tmp_fill_rgba[3] * opacity; if ((tfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (gp_style->fill_style > 0)) { const float *color; if (!onion) { @@ -866,7 +866,7 @@ static void gpencil_draw_strokes( if ((fillgrp) && (!stl->storage->simplify_fill)) { gpencil_add_fill_shgroup( cache, fillgrp, ob, gpl, derived_gpf, gps, - tintcolor, false, custonion); + opacity, tintcolor, false, custonion); } /* stroke */ if (strokegrp) { @@ -1219,6 +1219,7 @@ void DRW_gpencil_populate_datablock( const bool main_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true; const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && main_onion; const bool overlay = v3d != NULL ? (bool)((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) : true; + float opacity; /* check if playing animation */ bool playing = stl->storage->is_playing; @@ -1242,6 +1243,16 @@ void DRW_gpencil_populate_datablock( if (gpf == NULL) continue; + /* if pose mode, maybe the overlay to fade geometry is enabled */ + if ((draw_ctx->obact) && (draw_ctx->object_mode == OB_MODE_POSE) && + (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT)) + { + opacity = gpl->opacity * v3d->overlay.bone_select_alpha; + } + else { + opacity = gpl->opacity; + } + /* create GHash if need */ if (gpl->runtime.derived_data == NULL) { gpl->runtime.derived_data = (GHash *)BLI_ghash_str_new(gpl->info); @@ -1308,7 +1319,7 @@ void DRW_gpencil_populate_datablock( gpencil_draw_strokes( cache, e_data, vedata, ts, ob, gpd, gpl, gpf, derived_gpf, - gpl->opacity, gpl->tintcolor, false, cache_ob); + opacity, gpl->tintcolor, false, cache_ob); } diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index bdca3a350cd..2e237ac7fe8 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -382,7 +382,8 @@ void GPENCIL_cache_init(void *vedata) (stl->storage->is_playing == false)) { if (((obact_gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) && - (obact_gpd->runtime.sbuffer_size > 0)) + (obact_gpd->runtime.sbuffer_size > 0) && + ((obact_gpd->flag & GP_DATA_STROKE_POLYGON) == 0)) { stl->g_data->session_flag |= GP_DRW_PAINT_PAINTING; } @@ -666,8 +667,7 @@ void GPENCIL_draw_scene(void *ved) /* paper pass to display a confortable area to draw over complex scenes with geometry */ if ((!is_render) && (obact) && (obact->type == OB_GPENCIL)) { if (((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && - (v3d->gp_flag & V3D_GP_SHOW_PAPER) && - (stl->g_data->gp_cache_used > 0)) + (v3d->gp_flag & V3D_GP_SHOW_PAPER)) { DRW_draw_pass(psl->paper_pass); } diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c index 0b90de88ec1..3aa94c346df 100644 --- a/source/blender/draw/engines/gpencil/gpencil_render.c +++ b/source/blender/draw/engines/gpencil/gpencil_render.c @@ -143,12 +143,12 @@ static void GPENCIL_render_cache( static void GPENCIL_render_update_viewvecs(float invproj[4][4], float winmat[4][4], float(*r_viewvecs)[4]) { /* view vectors for the corners of the view frustum. - * Can be used to recreate the world space position easily */ + * Can be used to recreate the world space position easily */ float view_vecs[4][4] = { - { -1.0f, -1.0f, -1.0f, 1.0f }, - { 1.0f, -1.0f, -1.0f, 1.0f }, - { -1.0f, 1.0f, -1.0f, 1.0f }, - { -1.0f, -1.0f, 1.0f, 1.0f } + {-1.0f, -1.0f, -1.0f, 1.0f}, + {1.0f, -1.0f, -1.0f, 1.0f}, + {-1.0f, 1.0f, -1.0f, 1.0f}, + {-1.0f, -1.0f, 1.0f, 1.0f} }; /* convert the view vectors to view space */ diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index f468288fefe..3fd8a970db9 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -458,12 +458,8 @@ static void curve_batch_cache_clear(Curve *cu) GPU_VERTBUF_DISCARD_SAFE(cache->surface.verts); GPU_INDEXBUF_DISCARD_SAFE(cache->surface.triangles_in_order); - if (cache->surface.shaded_triangles) { - for (int i = 0; i < cache->surface.mat_len; ++i) { - GPU_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); - } - } - MEM_SAFE_FREE(cache->surface.shaded_triangles); + + GPU_BATCH_DISCARD_ARRAY_SAFE(cache->surface.shaded_triangles, cache->surface.mat_len); GPU_BATCH_DISCARD_SAFE(cache->surface.batch); /* don't own vbo & elems */ @@ -1037,13 +1033,7 @@ GPUBatch **DRW_curve_batch_cache_get_surface_shaded( CurveBatchCache *cache = curve_batch_cache_get(cu); if (cache->surface.mat_len != gpumat_array_len) { - /* TODO: deduplicate code */ - if (cache->surface.shaded_triangles) { - for (int i = 0; i < cache->surface.mat_len; ++i) { - GPU_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); - } - } - MEM_SAFE_FREE(cache->surface.shaded_triangles); + GPU_BATCH_DISCARD_ARRAY_SAFE(cache->surface.shaded_triangles, cache->surface.mat_len); } if (cache->surface.shaded_triangles == NULL) { diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 30b1ebe07cd..691cd27051a 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -119,11 +119,10 @@ void DRW_globals_update(void) ts.sizeLampCircleShadow = ts.sizeLampCircle + U.pixelsize * 3.0f; /* M_SQRT2 to be at least the same size of the old square */ - ts.sizeVertex = max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f); - ts.sizeFaceDot = UI_GetThemeValuef(TH_FACEDOT_SIZE); - ts.sizeEdge = 1.0f / 2.0f; /* TODO Theme */ - ts.sizeEdgeFix = 0.5f + 2.0f * (2.0f * (MAX2(ts.sizeVertex, ts.sizeEdge)) * (float)M_SQRT1_2); - + ts.sizeVertex = U.pixelsize * (max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f)); + ts.sizeFaceDot = U.pixelsize * UI_GetThemeValuef(TH_FACEDOT_SIZE); + ts.sizeEdge = U.pixelsize * (1.0f / 2.0f); /* TODO Theme */ + ts.sizeEdgeFix = U.pixelsize * (0.5f + 2.0f * (2.0f * (MAX2(ts.sizeVertex, ts.sizeEdge)) * (float)M_SQRT1_2)); if (globals_ubo == NULL) { globals_ubo = DRW_uniformbuffer_create(sizeof(GlobalsUboStorage), &ts); diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 08045687795..96e862d2439 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -539,7 +539,7 @@ static void sculpt_draw_cb( if (pbvh) { BKE_pbvh_draw_cb( - pbvh, NULL, NULL, false, + pbvh, NULL, NULL, false, false, (void (*)(void *, GPUBatch *))draw_fn, shgroup); } } diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 95835a691a3..31a79bcda94 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -77,486 +77,6 @@ void DRW_draw_region_info(void) } } -/* ************************* Grid ************************** */ - -static void gridline_range(double x0, double dx, double max, int *r_first, int *r_len) -{ - /* determine range of gridlines that appear in this Area -- similar calc but separate ranges for x & y - * x0 is gridline 0, the axis in screen space - * Area covers [0 .. max) pixels */ - - int first = (int)ceil(-x0 / dx); - int last = (int)floor((max - x0) / dx); - - if (first <= last) { - *r_first = first; - *r_len = last - first + 1; - } - else { - *r_first = 0; - *r_len = 0; - } -} - -static int gridline_count(ARegion *ar, double x0, double y0, double dx) -{ - /* x0 & y0 establish the "phase" of the grid within this 2D region - * dx is the frequency, shared by x & y directions - * pass in dx of smallest (highest precision) grid we want to draw */ - - int first, x_len, y_len; - - gridline_range(x0, dx, ar->winx, &first, &x_len); - gridline_range(y0, dx, ar->winy, &first, &y_len); - - int total_len = x_len + y_len; - - return total_len; -} - -static bool drawgrid_draw( - ARegion *ar, double x0, double y0, double dx, int skip_mod, - uint pos, uint col, GLubyte col_value[3]) -{ - /* skip every skip_mod lines relative to each axis; they will be overlaid by another drawgrid_draw - * always skip exact x0 & y0 axes; they will be drawn later in color - * - * set grid color once, just before the first line is drawn - * it's harmless to set same color for every line, or every vertex - * but if no lines are drawn, color must not be set! */ - - const float x_max = (float)ar->winx; - const float y_max = (float)ar->winy; - - int first, ct; - int x_len = 0, y_len = 0; /* count of lines actually drawn */ - int lines_skipped_for_next_unit = 0; - - /* draw vertical lines */ - gridline_range(x0, dx, x_max, &first, &ct); - - for (int i = first; i < first + ct; ++i) { - if (i == 0) - continue; - else if (skip_mod && (i % skip_mod) == 0) { - ++lines_skipped_for_next_unit; - continue; - } - - if (x_len == 0) - immAttrib3ub(col, col_value[0], col_value[1], col_value[2]); - - float x = (float)(x0 + i * dx); - immVertex2f(pos, x, 0.0f); - immVertex2f(pos, x, y_max); - ++x_len; - } - - /* draw horizontal lines */ - gridline_range(y0, dx, y_max, &first, &ct); - - for (int i = first; i < first + ct; ++i) { - if (i == 0) - continue; - else if (skip_mod && (i % skip_mod) == 0) { - ++lines_skipped_for_next_unit; - continue; - } - - if (x_len + y_len == 0) - immAttrib3ub(col, col_value[0], col_value[1], col_value[2]); - - float y = (float)(y0 + i * dx); - immVertex2f(pos, 0.0f, y); - immVertex2f(pos, x_max, y); - ++y_len; - } - - return lines_skipped_for_next_unit > 0; -} - -#define GRID_MIN_PX_D 6.0 -#define GRID_MIN_PX_F 6.0f - -static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit) -{ - RegionView3D *rv3d = ar->regiondata; - - double fx = rv3d->persmat[3][0]; - double fy = rv3d->persmat[3][1]; - double fw = rv3d->persmat[3][3]; - - const double wx = 0.5 * ar->winx; /* use double precision to avoid rounding errors */ - const double wy = 0.5 * ar->winy; - - double x = wx * fx / fw; - double y = wy * fy / fw; - - double vec4[4] = { v3d->grid, v3d->grid, 0.0, 1.0 }; - mul_m4_v4d(rv3d->persmat, vec4); - fx = vec4[0]; - fy = vec4[1]; - fw = vec4[3]; - - double dx = fabs(x - wx * fx / fw); - if (dx == 0) dx = fabs(y - wy * fy / fw); - - x += wx; - y += wy; - - /* now x, y, and dx have their final values - * (x,y) is the world origin (0,0,0) mapped to Area-relative screen space - * dx is the distance in pixels between grid lines -- same for horiz or vert grid lines */ - - glLineWidth(1.0f); - -#if 0 /* TODO: write to UI/widget depth buffer, not scene depth */ - glDepthMask(GL_FALSE); /* disable write in zbuffer */ -#endif - - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - - uchar col[3], col2[3]; - UI_GetThemeColor3ubv(TH_GRID, col); - - if (unit->system) { - const void *usys; - int len; - - bUnit_GetSystem(unit->system, B_UNIT_LENGTH, &usys, &len); - - bool first = true; - - if (usys) { - int i = len; - while (i--) { - double scalar = bUnit_GetScaler(usys, i); - - double dx_scalar = dx * scalar / (double)unit->scale_length; - if (dx_scalar < (GRID_MIN_PX_D * 2.0)) { - /* very very small grid items are less useful when dealing with units */ - continue; - } - - if (first) { - first = false; - - /* Store the smallest drawn grid size units name so users know how big each grid cell is */ - *grid_unit = bUnit_GetNameDisplay(usys, i); - rv3d->gridview = (float)((scalar * (double)v3d->grid) / (double)unit->scale_length); - - int gridline_len = gridline_count(ar, x, y, dx_scalar); - if (gridline_len == 0) - goto drawgrid_cleanup; /* nothing to draw */ - - immBegin(GPU_PRIM_LINES, gridline_len * 2); - } - - float blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar); - /* tweak to have the fade a bit nicer */ - blend_fac = (blend_fac * blend_fac) * 2.0f; - CLAMP(blend_fac, 0.3f, 1.0f); - - UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, blend_fac, col2); - - const int skip_mod = (i == 0) ? 0 : (int)round(bUnit_GetScaler(usys, i - 1) / scalar); - if (!drawgrid_draw(ar, x, y, dx_scalar, skip_mod, pos, color, col2)) - break; - } - } - } - else { - const double sublines = v3d->gridsubdiv; - const float sublines_fl = v3d->gridsubdiv; - - int grids_to_draw = 2; /* first the faint fine grid, then the bold coarse grid */ - - if (dx < GRID_MIN_PX_D) { - rv3d->gridview *= sublines_fl; - dx *= sublines; - if (dx < GRID_MIN_PX_D) { - rv3d->gridview *= sublines_fl; - dx *= sublines; - if (dx < GRID_MIN_PX_D) { - rv3d->gridview *= sublines_fl; - dx *= sublines; - grids_to_draw = (dx < GRID_MIN_PX_D) ? 0 : 1; - } - } - } - else { - if (dx > (GRID_MIN_PX_D * 10.0)) { /* start blending in */ - rv3d->gridview /= sublines_fl; - dx /= sublines; - if (dx > (GRID_MIN_PX_D * 10.0)) { /* start blending in */ - rv3d->gridview /= sublines_fl; - dx /= sublines; - if (dx > (GRID_MIN_PX_D * 10.0)) { - grids_to_draw = 1; - } - } - } - } - - int gridline_len = gridline_count(ar, x, y, dx); - if (gridline_len == 0) - goto drawgrid_cleanup; /* nothing to draw */ - - immBegin(GPU_PRIM_LINES, gridline_len * 2); - - if (grids_to_draw == 2) { - UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2); - if (drawgrid_draw(ar, x, y, dx, v3d->gridsubdiv, pos, color, col2)) { - drawgrid_draw(ar, x, y, dx * sublines, 0, pos, color, col); - } - } - else if (grids_to_draw == 1) { - drawgrid_draw(ar, x, y, dx, 0, pos, color, col); - } - } - - /* draw visible axes */ - /* horizontal line */ - if (0 <= y && y < ar->winy) { - UI_make_axis_color(col, col2, ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT) ? 'Y' : 'X'); - immAttrib3ub(color, col2[0], col2[1], col2[2]); - immVertex2f(pos, 0.0f, y); - immVertex2f(pos, (float)ar->winx, y); - } - - /* vertical line */ - if (0 <= x && x < ar->winx) { - UI_make_axis_color(col, col2, ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM) ? 'Y' : 'Z'); - immAttrib3ub(color, col2[0], col2[1], col2[2]); - immVertex2f(pos, x, 0.0f); - immVertex2f(pos, x, (float)ar->winy); - } - - immEnd(); - -drawgrid_cleanup: - immUnbindProgram(); - -#if 0 /* depth write is left enabled above */ - glDepthMask(GL_TRUE); /* enable write in zbuffer */ -#endif -} - -#undef DEBUG_GRID -#undef GRID_MIN_PX_D -#undef GRID_MIN_PX_F - -static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) -{ - /* draw only if there is something to draw */ - if (v3d->gridflag & (V3D_SHOW_FLOOR | V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) { - /* draw how many lines? - * trunc(v3d->gridlines / 2) * 4 - * + 2 for xy axes (possibly with special colors) - * + 1 for z axis (the only line not in xy plane) - * even v3d->gridlines are honored, odd rounded down */ - const int gridlines = v3d->gridlines / 2; - const float grid_scale = ED_view3d_grid_scale(scene, v3d, grid_unit); - const float grid = gridlines * grid_scale; - - const bool show_floor = (v3d->gridflag & V3D_SHOW_FLOOR) && gridlines >= 1; - - bool show_axis_x = (v3d->gridflag & V3D_SHOW_X) != 0; - bool show_axis_y = (v3d->gridflag & V3D_SHOW_Y) != 0; - bool show_axis_z = (v3d->gridflag & V3D_SHOW_Z) != 0; - - uchar col_grid[3], col_axis[3]; - - glLineWidth(1.0f); - - UI_GetThemeColor3ubv(TH_GRID, col_grid); - - if (show_floor) { - const uint vertex_len = 2 * (gridlines * 4 + 2); - const int sublines = v3d->gridsubdiv; - - uchar col_bg[3], col_grid_emphasise[3], col_grid_light[3]; - - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - - immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - - immBegin(GPU_PRIM_LINES, vertex_len); - - /* draw normal grid lines */ - UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10); - - for (int a = 1; a <= gridlines; a++) { - /* skip emphasised divider lines */ - if (a % sublines != 0) { - const float line = a * grid_scale; - - immAttrib3ubv(color, col_grid_light); - - immVertex2f(pos, -grid, -line); - immVertex2f(pos, +grid, -line); - immVertex2f(pos, -grid, +line); - immVertex2f(pos, +grid, +line); - - immVertex2f(pos, -line, -grid); - immVertex2f(pos, -line, +grid); - immVertex2f(pos, +line, -grid); - immVertex2f(pos, +line, +grid); - } - } - - /* draw emphasised grid lines */ - UI_GetThemeColor3ubv(TH_BACK, col_bg); - /* emphasise division lines lighter instead of darker, if background is darker than grid */ - UI_GetColorPtrShade3ubv(col_grid, col_grid_emphasise, - (col_grid[0] + col_grid[1] + col_grid[2] + 30 > - col_bg[0] + col_bg[1] + col_bg[2]) ? 20 : -10); - - if (sublines <= gridlines) { - immAttrib3ubv(color, col_grid_emphasise); - - for (int a = sublines; a <= gridlines; a += sublines) { - const float line = a * grid_scale; - - immVertex2f(pos, -grid, -line); - immVertex2f(pos, +grid, -line); - immVertex2f(pos, -grid, +line); - immVertex2f(pos, +grid, +line); - - immVertex2f(pos, -line, -grid); - immVertex2f(pos, -line, +grid); - immVertex2f(pos, +line, -grid); - immVertex2f(pos, +line, +grid); - } - } - - /* draw X axis */ - if (show_axis_x) { - show_axis_x = false; /* drawing now, won't need to draw later */ - UI_make_axis_color(col_grid, col_axis, 'X'); - immAttrib3ubv(color, col_axis); - } - else - immAttrib3ubv(color, col_grid_emphasise); - - immVertex2f(pos, -grid, 0.0f); - immVertex2f(pos, +grid, 0.0f); - - /* draw Y axis */ - if (show_axis_y) { - show_axis_y = false; /* drawing now, won't need to draw later */ - UI_make_axis_color(col_grid, col_axis, 'Y'); - immAttrib3ubv(color, col_axis); - } - else - immAttrib3ubv(color, col_grid_emphasise); - - immVertex2f(pos, 0.0f, -grid); - immVertex2f(pos, 0.0f, +grid); - - immEnd(); - immUnbindProgram(); - - /* done with XY plane */ - } - - if (show_axis_x || show_axis_y || show_axis_z) { - /* draw axis lines -- sometimes grid floor is off, other times we still need to draw the Z axis */ - - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - - immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - immBegin(GPU_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2); - - if (show_axis_x) { - UI_make_axis_color(col_grid, col_axis, 'X'); - immAttrib3ubv(color, col_axis); - immVertex3f(pos, -grid, 0.0f, 0.0f); - immVertex3f(pos, +grid, 0.0f, 0.0f); - } - - if (show_axis_y) { - UI_make_axis_color(col_grid, col_axis, 'Y'); - immAttrib3ubv(color, col_axis); - immVertex3f(pos, 0.0f, -grid, 0.0f); - immVertex3f(pos, 0.0f, +grid, 0.0f); - } - - if (show_axis_z) { - UI_make_axis_color(col_grid, col_axis, 'Z'); - immAttrib3ubv(color, col_axis); - immVertex3f(pos, 0.0f, 0.0f, -grid); - immVertex3f(pos, 0.0f, 0.0f, +grid); - } - - immEnd(); - immUnbindProgram(); - } - } -} - -void DRW_draw_grid(void) -{ - /* TODO viewport - * Missing is the flags to check whether to draw it - * for now now we are using the flags in v3d itself. - * - * Also for now always assume depth is there, so we - * draw on top of it. - */ - /** - * Calculate pixel-size factor once, is used for lamps and object centers. - * Used by #ED_view3d_pixel_size and typically not accessed directly. - * - * \note #BKE_camera_params_compute_viewplane' also calculates a pixel-size value, - * passed to #RE_SetPixelSize, in ortho mode this is compatible with this value, - * but in perspective mode its offset by the near-clip. - * - * 'RegionView3D.pixsize' is used for viewport drawing, not rendering. - */ - const DRWContextState *draw_ctx = DRW_context_state_get(); - Scene *scene = draw_ctx->scene; - View3D *v3d = draw_ctx->v3d; - ARegion *ar = draw_ctx->ar; - RegionView3D *rv3d = draw_ctx->rv3d; - - const bool draw_floor = (rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO); - const char *grid_unit = NULL; - - /* ortho grid goes first, does not write to depth buffer and doesn't need depth test so it will override - * objects if done last - * needs to be done always, gridview is adjusted in drawgrid() now, but only for ortho views. - */ - rv3d->gridview = ED_view3d_grid_scale(scene, v3d, &grid_unit); - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - - if (!draw_floor) { - /* Do not get in front of overlays */ - glDepthMask(GL_FALSE); - - ED_region_pixelspace(ar); - *(&grid_unit) = NULL; /* drawgrid need this to detect/affect smallest valid unit... */ - drawgrid(&scene->unit, ar, v3d, &grid_unit); - - GPU_matrix_projection_set(rv3d->winmat); - GPU_matrix_set(rv3d->viewmat); - } - else { - glDepthMask(GL_TRUE); - drawfloor(scene, v3d, &grid_unit); - } -} - /* ************************* Background ************************** */ void DRW_draw_background(void) diff --git a/source/blender/draw/intern/draw_view.h b/source/blender/draw/intern/draw_view.h index 8f45a5fd786..01a342f0ae4 100644 --- a/source/blender/draw/intern/draw_view.h +++ b/source/blender/draw/intern/draw_view.h @@ -26,7 +26,6 @@ #ifndef __DRAW_VIEW_H__ #define __DRAW_VIEW_H__ -void DRW_draw_grid(void); void DRW_draw_region_info(void); void DRW_draw_background(void); void DRW_draw_cursor(void); diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 254afeb59ab..a79c0e2dc31 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -316,6 +316,8 @@ static DRWPass *edit_mesh_create_overlay_pass( DRWShadingGroup **r_face_shgrp, DRWShadingGroup **r_ledges_shgrp, DRWShadingGroup **r_lverts_shgrp, DRWShadingGroup **r_facedot_shgrp) { + static float edge_width_scale; + GPUShader *tri_sh, *ledge_sh; const DRWContextState *draw_ctx = DRW_context_state_get(); RegionView3D *rv3d = draw_ctx->rv3d; @@ -329,24 +331,32 @@ static DRWPass *edit_mesh_create_overlay_pass( "Edit Mesh Face Overlay Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_POINT | statemod); + + /* Applies on top of the theme edge width, so edge-mode can have thick edges. */ + edge_width_scale = (tsettings->selectmode & (SCE_SELECT_EDGE)) ? 1.75f : 1.0f; + *r_face_shgrp = DRW_shgroup_create(tri_sh, pass); DRW_shgroup_uniform_block(*r_face_shgrp, "globalsBlock", globals_ubo); DRW_shgroup_uniform_vec2(*r_face_shgrp, "viewportSize", DRW_viewport_size_get(), 1); DRW_shgroup_uniform_float(*r_face_shgrp, "faceAlphaMod", faceAlpha, 1); + DRW_shgroup_uniform_float(*r_face_shgrp, "edgeScale", &edge_width_scale, 1); *r_ledges_shgrp = DRW_shgroup_create(ledge_sh, pass); DRW_shgroup_uniform_block(*r_ledges_shgrp, "globalsBlock", globals_ubo); DRW_shgroup_uniform_vec2(*r_ledges_shgrp, "viewportSize", DRW_viewport_size_get(), 1); + DRW_shgroup_uniform_float(*r_ledges_shgrp, "edgeScale", &edge_width_scale, 1); if ((tsettings->selectmode & (SCE_SELECT_VERTEX)) != 0) { *r_lverts_shgrp = DRW_shgroup_create(e_data.overlay_vert_sh, pass); DRW_shgroup_uniform_block(*r_lverts_shgrp, "globalsBlock", globals_ubo); DRW_shgroup_uniform_vec2(*r_lverts_shgrp, "viewportSize", DRW_viewport_size_get(), 1); + DRW_shgroup_uniform_float(*r_lverts_shgrp, "edgeScale", &edge_width_scale, 1); } if ((tsettings->selectmode & (SCE_SELECT_FACE)) != 0) { *r_facedot_shgrp = DRW_shgroup_create(e_data.overlay_facedot_sh, pass); DRW_shgroup_uniform_block(*r_facedot_shgrp, "globalsBlock", globals_ubo); + DRW_shgroup_uniform_float(*r_facedot_shgrp, "edgeScale", &edge_width_scale, 1); } return pass; @@ -549,14 +559,21 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob) if (stl->g_data->do_zbufclip) { edit_mesh_add_ob_to_pass( - scene, ob, stl->g_data->face_occluded_shgrp, stl->g_data->ledges_occluded_shgrp, - stl->g_data->lverts_occluded_shgrp, stl->g_data->facedot_occluded_shgrp, + scene, ob, + stl->g_data->face_occluded_shgrp, + stl->g_data->ledges_occluded_shgrp, + stl->g_data->lverts_occluded_shgrp, + stl->g_data->facedot_occluded_shgrp, stl->g_data->facefill_occluded_shgrp); } else { edit_mesh_add_ob_to_pass( - scene, ob, stl->g_data->face_overlay_shgrp, stl->g_data->ledges_overlay_shgrp, - stl->g_data->lverts_overlay_shgrp, NULL, NULL); + scene, ob, + stl->g_data->face_overlay_shgrp, + stl->g_data->ledges_overlay_shgrp, + stl->g_data->lverts_overlay_shgrp, + (me->drawflag & ME_DRAW_FACE_DOT) ? stl->g_data->facedot_overlay_shgrp : NULL, + NULL); } stl->g_data->ghost_ob += (ob->dtx & OB_DRAWXRAY) ? 1 : 0; diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index 56b5898a6cf..c80fd40cf27 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -43,6 +43,10 @@ #include "draw_mode_engines.h" +extern char datatoc_sculpt_mask_vert_glsl[]; +extern char datatoc_gpu_shader_flat_color_frag_glsl[]; +extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[]; + /* *********** LISTS *********** */ /* All lists are per viewport specific datas. * They are all free when viewport changes engines @@ -121,26 +125,14 @@ static void SCULPT_engine_init(void *vedata) UNUSED_VARS(txl, fbl, stl); - /* Init Framebuffers like this: order is attachment order (for color texs) */ - /* - * DRWFboTexture tex[2] = {{&txl->depth, GPU_DEPTH_COMPONENT24, 0}, - * {&txl->color, GPU_RGBA8, DRW_TEX_FILTER}}; - */ - - /* DRW_framebuffer_init takes care of checking if - * the framebuffer is valid and has the right size*/ - /* - * float *viewport_size = DRW_viewport_size_get(); - * DRW_framebuffer_init(&fbl->occlude_wire_fb, - * (int)viewport_size[0], (int)viewport_size[1], - * tex, 2); - */ - if (!e_data.shader_flat) { - e_data.shader_flat = GPU_shader_get_builtin_shader(GPU_SHADER_3D_FLAT_COLOR); + e_data.shader_flat = DRW_shader_create(datatoc_sculpt_mask_vert_glsl, NULL, + datatoc_gpu_shader_flat_color_frag_glsl, + "#define SHADE_FLAT"); } if (!e_data.shader_smooth) { - e_data.shader_smooth = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SMOOTH_COLOR); + e_data.shader_smooth = DRW_shader_create(datatoc_sculpt_mask_vert_glsl, NULL, + datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL); } } @@ -183,6 +175,21 @@ static bool object_is_flat(const Object *ob) } } +static void sculpt_draw_mask_cb( + DRWShadingGroup *shgroup, + void (*draw_fn)(DRWShadingGroup *shgroup, struct GPUBatch *geom), + void *user_data) +{ + Object *ob = user_data; + PBVH *pbvh = ob->sculpt->pbvh; + + if (pbvh) { + BKE_pbvh_draw_cb( + pbvh, NULL, NULL, false, true, + (void (*)(void *, struct GPUBatch *))draw_fn, shgroup); + } +} + /* Add geometry to shadingGroups. Execute for each objects */ static void SCULPT_cache_populate(void *vedata, Object *ob) { @@ -210,8 +217,7 @@ static void SCULPT_cache_populate(void *vedata, Object *ob) /* Get geometry cache */ DRWShadingGroup *shgroup = object_is_flat(ob) ? stl->g_data->group_flat : stl->g_data->group_smooth; - /* Add geom to a shading group */ - DRW_shgroup_call_sculpt_add(shgroup, ob, ob->obmat); + DRW_shgroup_call_generate_add(shgroup, sculpt_draw_mask_cb, ob, ob->obmat); } } } @@ -260,7 +266,8 @@ static void SCULPT_draw_scene(void *vedata) * Mostly used for freeing shaders */ static void SCULPT_engine_free(void) { - // DRW_SHADER_FREE_SAFE(custom_shader); + DRW_SHADER_FREE_SAFE(e_data.shader_flat); + DRW_SHADER_FREE_SAFE(e_data.shader_smooth); } static const DrawEngineDataSize SCULPT_data_size = DRW_VIEWPORT_DATA_SIZE(SCULPT_Data); diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl index fe9062a8d50..6551fa81c21 100644 --- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl +++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl @@ -10,6 +10,7 @@ * TODO Refine the range to only affect GPUs. */ uniform float faceAlphaMod; +uniform float edgeScale; flat in vec3 edgesCrease; flat in vec3 edgesBweight; @@ -74,10 +75,12 @@ void main() FragColor.a *= faceAlphaMod; /* Edges */ + float sizeEdgeFinal = sizeEdge * edgeScale; + for (int v = 0; v < 3; ++v) { if ((flag[v] & EDGE_EXISTS) != 0) { /* Outer large edge */ - float largeEdge = e[v] - sizeEdge * LARGE_EDGE_SIZE; + float largeEdge = e[v] - sizeEdgeFinal * LARGE_EDGE_SIZE; vec4 large_edge_color = EDIT_MESH_edge_color_outer(flag[v], (flag[0]& FACE_ACTIVE) != 0, edgesCrease[v], edgesBweight[v]); @@ -86,7 +89,7 @@ void main() } /* Inner thin edge */ - float innerEdge = e[v] - sizeEdge; + float innerEdge = e[v] - sizeEdgeFinal; #ifdef ANTI_ALIASING innerEdge += 0.4; #endif diff --git a/source/blender/draw/modes/shaders/paint_vert_frag.glsl b/source/blender/draw/modes/shaders/paint_vert_frag.glsl index c22e1c04b96..5ea8c11ff9a 100644 --- a/source/blender/draw/modes/shaders/paint_vert_frag.glsl +++ b/source/blender/draw/modes/shaders/paint_vert_frag.glsl @@ -15,7 +15,7 @@ void main() float dist_squared = dot(centered, centered); const float rad_squared = 0.25; const vec4 colSel = vec4(1.0, 1.0, 1.0, 1.0); - const vec4 colUnsel = vec4(0.5, 0.5, 0.5, 1.0); + const vec4 colUnsel = vec4(0.0, 0.0, 0.0, 1.0); // round point with jaggy edges if (dist_squared > rad_squared) { diff --git a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl new file mode 100644 index 00000000000..e76d21eb43a --- /dev/null +++ b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl @@ -0,0 +1,19 @@ + +uniform mat4 ModelViewProjectionMatrix; + +in vec3 pos; +in float msk; + +#ifdef SHADE_FLAT +flat out vec4 finalColor; +#else +out vec4 finalColor; +#endif + +void main() +{ + gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); + + float mask = 1.0 - msk * 0.75; + finalColor = vec4(mask, mask, mask, 1.0); +} diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index a6eb9c5f3b5..6032b21ab88 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -3194,7 +3194,7 @@ void ED_operatortypes_animchannels(void) // TODO: check on a poll callback for this, to get hotkeys into menus void ED_keymap_animchannels(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation Channels", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Animation Channels", 0, 0); wmKeyMapItem *kmi; /* click-select */ diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index fe6c36d4cdb..2085ad869be 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1648,7 +1648,7 @@ void ED_operatortypes_marker(void) /* called in screen_ops.c:ED_keymap_screen() */ void ED_keymap_marker(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Markers", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Markers", 0, 0); wmKeyMapItem *kmi; WM_keymap_verify_item(keymap, "MARKER_OT_add", MKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 45fe7233f94..5ec38025ade 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -536,7 +536,7 @@ void ED_operatortypes_anim(void) void ED_keymap_anim(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Animation", 0, 0); wmKeyMapItem *kmi; /* frame management */ diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 350dee07a2c..20fccfda6b9 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -34,6 +34,8 @@ #include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_object_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_gpencil_modifier_types.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" @@ -51,6 +53,7 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_modifier.h" +#include "BKE_gpencil_modifier.h" #include "DEG_depsgraph.h" @@ -265,6 +268,46 @@ void ED_armature_bone_rename(Main *bmain, bArmature *arm, const char *oldnamep, break; } } + + /* fix grease pencil modifiers and vertex groups */ + if (ob->type == OB_GPENCIL) { + + bGPdata *gpd = (bGPdata *)ob->data; + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + if ((gpl->parent != NULL) && (gpl->parent->data == arm)) { + if (STREQ(gpl->parsubstr, oldname)) + BLI_strncpy(gpl->parsubstr, newname, MAXBONENAME); + } + } + + for (GpencilModifierData *gp_md = ob->greasepencil_modifiers.first; gp_md; gp_md = gp_md->next) { + switch (gp_md->type) { + case eGpencilModifierType_Armature: + { + ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)gp_md; + if (mmd->object && mmd->object->data == arm) { + bDeformGroup *dg = defgroup_find_name(ob, oldname); + if (dg) { + BLI_strncpy(dg->name, newname, MAXBONENAME); + } + } + break; + } + case eGpencilModifierType_Hook: + { + HookGpencilModifierData *hgp_md = (HookGpencilModifierData *)gp_md; + if (hgp_md->object && (hgp_md->object->data == arm)) { + if (STREQ(hgp_md->subtarget, oldname)) + BLI_strncpy(hgp_md->subtarget, newname, MAXBONENAME); + } + break; + } + default: + break; + } + } + } + DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); } /* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 366aafcfa07..323fa36832b 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -193,7 +193,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* Armature ------------------------ */ - keymap = WM_keymap_find(keyconf, "Armature", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Armature", 0, 0); keymap->poll = ED_operator_editarmature; /* only set in editmode armature, by space_view3d listener */ @@ -294,13 +294,13 @@ void ED_keymap_armature(wmKeyConfig *keyconf) /* Pose ------------------------ */ /* only set in posemode, by space_view3d listener */ - keymap = WM_keymap_find(keyconf, "Pose", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Pose", 0, 0); keymap->poll = ED_operator_posemode; /* set parent and add object are object-based operators, but we make them * available here because it's useful to do in pose mode too */ WM_keymap_add_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", false); diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 621b20c0ca7..eb178d422ae 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -95,6 +95,23 @@ static void pose_do_bone_select(bPoseChannel *pchan, const int select_mode) } } +void ED_pose_bone_select_tag_update(Object *ob) +{ + BLI_assert(ob->type == OB_ARMATURE); + bArmature *arm = ob->data; + WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, ob); + WM_main_add_notifier(NC_GEOM | ND_DATA, ob); + + if (arm->flag & ARM_HAS_VIZ_DEPS) { + /* mask modifier ('armature' mode), etc. */ + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + + /* copy on write tag is needed (for the armature), or else no refresh happens */ + DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); +} + + /* Utility method for changing the selection status of a bone */ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) { @@ -120,19 +137,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) } // TODO: select and activate corresponding vgroup? - - /* tag necessary depsgraph updates - * (see rna_Bone_select_update() in rna_armature.c for details) - */ - if (arm->flag & ARM_HAS_VIZ_DEPS) { - DEG_id_tag_update(&ob->id, OB_RECALC_DATA); - } - - /* send necessary notifiers */ - WM_main_add_notifier(NC_GEOM | ND_DATA, ob); - - /* tag armature for copy-on-write update (since act_bone is in armature not object) */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); + ED_pose_bone_select_tag_update(ob); } } @@ -235,14 +240,14 @@ bool ED_armature_pose_select_pick_with_buffer( /* 'select_mode' is usual SEL_SELECT/SEL_DESELECT/SEL_TOGGLE/SEL_INVERT. * When true, 'ignore_visibility' makes this func also affect invisible bones (hidden or on hidden layers). */ -void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibility) +bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibility) { bArmature *arm = ob->data; bPoseChannel *pchan; /* we call this from outliner too */ if (ob->pose == NULL) { - return; + return false; } /* Determine if we're selecting or deselecting */ @@ -259,12 +264,16 @@ void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil } /* Set the flags accordingly */ + bool changed = false; for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { /* ignore the pchan if it isn't visible or if its selection cannot be changed */ if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) { + int flag_prev = pchan->bone->flag; pose_do_bone_select(pchan, select_mode); + changed = (changed || flag_prev != pchan->bone->flag); } } + return changed; } static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility) @@ -300,22 +309,9 @@ void ED_pose_deselect_all_multi(Object **objects, uint objects_len, int select_m for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob_iter = objects[ob_index]; - bArmature *arm = ob_iter->data; - - ED_pose_deselect_all(ob_iter, select_mode, ignore_visibility); - - /* if there are some dependencies for visualizing armature state - * (e.g. Mask Modifier in 'Armature' mode), force update - */ - if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* NOTE: ob not ob_act here is intentional - it's the source of the - * bones being selected [T37247] - */ - DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA); + if (ED_pose_deselect_all(ob_iter, select_mode, ignore_visibility)) { + ED_pose_bone_select_tag_update(ob_iter); } - - /* need to tag armature for cow updates, or else selection doesn't update */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); } } @@ -353,8 +349,6 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve if (!bone) return OPERATOR_CANCELLED; - bArmature *arm = base->object->data; - /* Select parents */ for (curBone = bone; curBone; curBone = next) { /* ignore bone if cannot be selected */ @@ -377,16 +371,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve for (curBone = bone->childbase.first; curBone; curBone = next) selectconnected_posebonechildren(base->object, curBone, extend); - /* updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object); - - if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* mask modifier ('armature' mode), etc. */ - DEG_id_tag_update(&base->object->id, OB_RECALC_DATA); - } - - /* need to tag armature for cow updates, or else selection doesn't update */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); + ED_pose_bone_select_tag_update(base->object); return OPERATOR_FINISHED; } @@ -496,18 +481,7 @@ static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op)) else { continue; } - - /* updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - - if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* mask modifier ('armature' mode), etc. */ - DEG_id_tag_update(&ob->id, OB_RECALC_DATA); - } - - /* tag armature for copy-on-write update (since act_bone is in armature not object) */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); - + ED_pose_bone_select_tag_update(ob); } FOREACH_PCHAN_SELECTED_IN_OBJECT_END; } @@ -541,7 +515,6 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) { - bArmature *arm = ob->data; if (pchan->bone->flag & BONE_SELECTED) { for (con = pchan->constraints.first; con; con = con->next) { const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); @@ -559,14 +532,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op found = 1; if (ob != ob_prev) { - /* updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* mask modifier ('armature' mode), etc. */ - DEG_id_tag_update(&ob->id, OB_RECALC_DATA); - } - /* tag armature for copy on write, since selection status is armature data */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); + ED_pose_bone_select_tag_update(ob); ob_prev = ob; } } @@ -670,16 +636,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - /* updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - - if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* mask modifier ('armature' mode), etc. */ - DEG_id_tag_update(&ob->id, OB_RECALC_DATA); - } - - /* tag armature for copy-on-write update (since act_bone is in armature not object) */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); + ED_pose_bone_select_tag_update(ob); return OPERATOR_FINISHED; } @@ -890,7 +847,6 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object static int pose_select_grouped_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm = (bArmature *)ob->data; const ePose_SelectSame_Mode type = RNA_enum_get(op->ptr, "type"); const bool extend = RNA_boolean_get(op->ptr, "extend"); bool changed = false; @@ -919,16 +875,10 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op) } /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - - if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* mask modifier ('armature' mode), etc. */ - DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + if (changed) { + ED_pose_bone_select_tag_update(ob); } - /* need to tag armature for cow updates, or else selection doesn't update */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); - /* report done status */ if (changed) return OPERATOR_FINISHED; diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 2cfbc2f44c6..ae07196860b 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -170,7 +170,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap = WM_keymap_find(keyconf, "Font", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Font", 0, 0); keymap->poll = ED_operator_editfont; /* only set in editmode font, by space_view3d listener */ @@ -230,10 +230,10 @@ void ED_keymap_curve(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "accent", true); /* accented characters */ /* only set in editmode curve, by space_view3d listener */ - keymap = WM_keymap_find(keyconf, "Curve", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Curve", 0, 0); keymap->poll = ED_operator_editsurfcurve; - WM_keymap_add_menu(keymap, "INFO_MT_edit_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "CURVE_OT_handle_type_set", VKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 163248a84fa..6725817e35d 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -273,8 +273,7 @@ static void text_update_edited(bContext *C, Object *obedit, int mode) } } - BKE_curve_batch_cache_dirty_tag(cu, BKE_CURVE_BATCH_DIRTY_SELECT); - + DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); } diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index 52823fe731e..4c735634b3f 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -596,6 +596,8 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES ops.armature.bone.roll ops.armature.extrude.cursor ops.armature.extrude + ops.curve.draw + ops.curve.dupli_extrude_cursor ops.generic.cursor ops.generic.select_border ops.generic.select_circle @@ -623,17 +625,18 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES ops.mesh.dupli_extrude_cursor ops.mesh.extrude_faces_move ops.mesh.extrude_region_move + ops.mesh.extrude_region_shrink_fatten ops.mesh.inset ops.mesh.knife_tool ops.mesh.loopcut_slide ops.mesh.offset_edge_loops_slide ops.mesh.polybuild_hover - ops.mesh.primitive_cone_add_manipulator - ops.mesh.primitive_cube_add_manipulator - ops.mesh.primitive_cylinder_add_manipulator - ops.mesh.primitive_grid_add_manipulator - ops.mesh.primitive_sphere_add_manipulator - ops.mesh.primitive_torus_add_manipulator + ops.mesh.primitive_cone_add_gizmo + ops.mesh.primitive_cube_add_gizmo + ops.mesh.primitive_cylinder_add_gizmo + ops.mesh.primitive_grid_add_gizmo + ops.mesh.primitive_sphere_add_gizmo + ops.mesh.primitive_torus_add_gizmo ops.mesh.rip ops.mesh.rip_edge ops.mesh.spin @@ -649,7 +652,9 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES ops.transform.resize.cage ops.transform.resize ops.transform.rotate + ops.transform.shear ops.transform.shrink_fatten + ops.transform.tosphere ops.transform.transform ops.transform.translate ops.transform.vert_slide diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c index a53fb894a34..d20aa91d432 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_utils.c +++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c @@ -214,7 +214,7 @@ bool gizmo_window_project_2d( float co[3] = {mval[0], mval[1], 0.0f}; float imat[4][4]; invert_m4_m4(imat, mat); - mul_mat3_m4_v3(imat, co); + mul_m4_v3(imat, co); copy_v2_v2(r_co, co); return true; } diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt index 114e55c5704..cea2e5d4269 100644 --- a/source/blender/editors/gpencil/CMakeLists.txt +++ b/source/blender/editors/gpencil/CMakeLists.txt @@ -58,6 +58,7 @@ set(SRC gpencil_undo.c gpencil_utils.c gpencil_old.c + gpencil_armature.c gpencil_intern.h ) diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 4f3d487bcf7..4f25dc421e4 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -270,7 +270,8 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2]) } /* reproject the points of the stroke to a plane locked to axis to avoid stroke offset */ -static void gp_project_points_to_plane(RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis) +static void UNUSED_FUNCTION(gp_project_points_to_plane)( + RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis) { float plane_normal[3]; float vn[3]; diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index 88f935eb8bf..2c3159692bf 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -492,8 +492,10 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode) /* make a copy of stroke, then of its points array */ gpsn = MEM_dupallocN(gps); gpsn->points = MEM_dupallocN(gps->points); - gpsn->dvert = MEM_dupallocN(gps->dvert); - BKE_gpencil_stroke_weights_duplicate(gps, gpsn); + if (gps->dvert != NULL) { + gpsn->dvert = MEM_dupallocN(gps->dvert); + BKE_gpencil_stroke_weights_duplicate(gps, gpsn); + } /* duplicate triangle information */ gpsn->triangles = MEM_dupallocN(gps->triangles); /* append stroke to frame */ diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c new file mode 100644 index 00000000000..b55239deadc --- /dev/null +++ b/source/blender/editors/gpencil/gpencil_armature.c @@ -0,0 +1,671 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018, Blender Foundation + * This is a new part of Blender + * + * Contributor(s): Antonio Vazquez + * + * ***** END GPL LICENSE BLOCK ***** + * + * Operators for dealing with armatures and GP datablocks + */ + +/** \file blender/editors/gpencil/gpencil_armature.c + * \ingroup edgpencil + */ + + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stddef.h> +#include <math.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_ghash.h" +#include "BLI_math.h" +#include "BLI_string_utils.h" + +#include "BLT_translation.h" + +#include "DNA_armature_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_scene_types.h" + +#include "BKE_main.h" +#include "BKE_action.h" +#include "BKE_armature.h" +#include "BKE_context.h" +#include "BKE_deform.h" +#include "BKE_gpencil.h" +#include "BKE_gpencil_modifier.h" +#include "BKE_object_deform.h" +#include "BKE_report.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "ED_gpencil.h" +#include "ED_object.h" +#include "ED_mesh.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + +#include "gpencil_intern.h" + +enum { + GP_ARMATURE_NAME = 0, + GP_ARMATURE_AUTO = 1 +}; + +#define DEFAULT_RATIO 0.10f +#define DEFAULT_DECAY 0.8f + +static int gpencil_bone_looper( + Object *ob, Bone *bone, void *data, + int(*bone_func)(Object *, Bone *, void *)) +{ + /* We want to apply the function bone_func to every bone + * in an armature -- feed bone_looper the first bone and + * a pointer to the bone_func and watch it go!. The int count + * can be useful for counting bones with a certain property + * (e.g. skinnable) + */ + int count = 0; + + if (bone) { + /* only do bone_func if the bone is non null */ + count += bone_func(ob, bone, data); + + /* try to execute bone_func for the first child */ + count += gpencil_bone_looper(ob, bone->childbase.first, data, bone_func); + + /* try to execute bone_func for the next bone at this + * depth of the recursion. + */ + count += gpencil_bone_looper(ob, bone->next, data, bone_func); + } + + return count; +} + +static int gpencil_bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap) +{ + /* Bones that are deforming + * are regarded to be "skinnable" and are eligible for + * auto-skinning. + * + * This function performs 2 functions: + * + * a) It returns 1 if the bone is skinnable. + * If we loop over all bones with this + * function, we can count the number of + * skinnable bones. + * b) If the pointer data is non null, + * it is treated like a handle to a + * bone pointer -- the bone pointer + * is set to point at this bone, and + * the pointer the handle points to + * is incremented to point to the + * next member of an array of pointers + * to bones. This way we can loop using + * this function to construct an array of + * pointers to bones that point to all + * skinnable bones. + */ + Bone ***hbone; + int a, segments; + struct { Object *armob; void *list; int heat;} *data = datap; + + if (!(bone->flag & BONE_HIDDEN_P)) { + if (!(bone->flag & BONE_NO_DEFORM)) { + if (data->heat && data->armob->pose && + BKE_pose_channel_find_name(data->armob->pose, bone->name)) + { + segments = bone->segments; + } + else { + segments = 1; + } + + if (data->list != NULL) { + hbone = (Bone ***)&data->list; + + for (a = 0; a < segments; a++) { + **hbone = bone; + ++*hbone; + } + } + return segments; + } + } + return 0; +} + +static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) +{ + /* This group creates a vertex group to ob that has the + * same name as bone (provided the bone is skinnable). + * If such a vertex group already exist the routine exits. + */ + if (!(bone->flag & BONE_NO_DEFORM)) { + if (!defgroup_find_name(ob, bone->name)) { + BKE_object_defgroup_add_name(ob, bone->name); + return 1; + } + } + return 0; +} + +static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) +{ + /* Bones that are deforming + * are regarded to be "skinnable" and are eligible for + * auto-skinning. + * + * This function performs 2 functions: + * + * a) If the bone is skinnable, it creates + * a vertex group for ob that has + * the name of the skinnable bone + * (if one doesn't exist already). + * b) If the pointer data is non null, + * it is treated like a handle to a + * bDeformGroup pointer -- the + * bDeformGroup pointer is set to point + * to the deform group with the bone's + * name, and the pointer the handle + * points to is incremented to point to the + * next member of an array of pointers + * to bDeformGroups. This way we can loop using + * this function to construct an array of + * pointers to bDeformGroups, all with names + * of skinnable bones. + */ + bDeformGroup ***hgroup, *defgroup = NULL; + int a, segments; + struct { Object *armob; void *list; int heat; } *data = datap; + bArmature *arm = data->armob->data; + + if (!(bone->flag & BONE_HIDDEN_P)) { + if (!(bone->flag & BONE_NO_DEFORM)) { + if (data->heat && data->armob->pose && + BKE_pose_channel_find_name(data->armob->pose, bone->name)) + { + segments = bone->segments; + } + else { + segments = 1; + } + + if (arm->layer & bone->layer) { + if (!(defgroup = defgroup_find_name(ob, bone->name))) { + defgroup = BKE_object_defgroup_add_name(ob, bone->name); + } + else if (defgroup->flag & DG_LOCK_WEIGHT) { + /* In case vgroup already exists and is locked, do not modify it here. See T43814. */ + defgroup = NULL; + } + } + + if (data->list != NULL) { + hgroup = (bDeformGroup ***)&data->list; + + for (a = 0; a < segments; a++) { + **hgroup = defgroup; + ++*hgroup; + } + } + return segments; + } + } + return 0; +} + +/* get weight value depending of distance and decay value */ +static float get_weight(float dist, float decay_rad, float dif_rad) +{ + float weight = 1.0f; + if (dist < decay_rad) { + weight = 1.0f; + } + else { + weight = interpf(0.0f, 0.9f, (dist - decay_rad) / dif_rad); + } + + return weight; +} + +/* This functions implements the automatic computation of vertex group weights */ +static void gpencil_add_verts_to_dgroups( + const bContext *C, Object *ob, Object *ob_arm, const float ratio, const float decay) +{ + bArmature *arm = ob_arm->data; + Bone **bonelist, *bone; + bDeformGroup **dgrouplist; + bPoseChannel *pchan; + bGPdata *gpd = (bGPdata *)ob->data; + bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); + + Mat4 bbone_array[MAX_BBONE_SUBDIV], *bbone = NULL; + float(*root)[3], (*tip)[3], (*verts)[3]; + float *radsqr; + int *selected; + float weight; + int numbones, i, j, segments = 0; + struct { Object *armob; void *list; int heat; } looper_data; + + looper_data.armob = ob_arm; + looper_data.heat = true; + looper_data.list = NULL; + + /* count the number of skinnable bones */ + numbones = gpencil_bone_looper(ob, arm->bonebase.first, &looper_data, gpencil_bone_skinnable_cb); + + if (numbones == 0) + return; + + /* create an array of pointer to bones that are skinnable + * and fill it with all of the skinnable bones */ + bonelist = MEM_callocN(numbones * sizeof(Bone *), "bonelist"); + looper_data.list = bonelist; + gpencil_bone_looper(ob, arm->bonebase.first, &looper_data, gpencil_bone_skinnable_cb); + + /* create an array of pointers to the deform groups that + * correspond to the skinnable bones (creating them + * as necessary. */ + dgrouplist = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgrouplist"); + + looper_data.list = dgrouplist; + gpencil_bone_looper(ob, arm->bonebase.first, &looper_data, dgroup_skinnable_cb); + + /* create an array of root and tip positions transformed into + * global coords */ + root = MEM_callocN(numbones * sizeof(float) * 3, "root"); + tip = MEM_callocN(numbones * sizeof(float) * 3, "tip"); + selected = MEM_callocN(numbones * sizeof(int), "selected"); + radsqr = MEM_callocN(numbones * sizeof(float), "radsqr"); + + for (j = 0; j < numbones; j++) { + bone = bonelist[j]; + + /* handle bbone */ + if (segments == 0) { + segments = 1; + bbone = NULL; + + if ((ob_arm->pose) && + (pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name))) + { + if (bone->segments > 1) { + segments = bone->segments; + b_bone_spline_setup(pchan, 1, bbone_array); + bbone = bbone_array; + } + } + } + + segments--; + + /* compute root and tip */ + if (bbone) { + mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]); + if ((segments + 1) < bone->segments) { + mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments + 1].mat[3]); + } + else { + copy_v3_v3(tip[j], bone->arm_tail); + } + } + else { + copy_v3_v3(root[j], bone->arm_head); + copy_v3_v3(tip[j], bone->arm_tail); + } + + mul_m4_v3(ob_arm->obmat, root[j]); + mul_m4_v3(ob_arm->obmat, tip[j]); + + selected[j] = 1; + + /* calculate radius squared */ + radsqr[j] = len_squared_v3v3(root[j], tip[j]) * ratio; + } + + /* loop all strokes */ + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + bGPDframe *init_gpf = gpl->actframe; + bGPDspoint *pt = NULL; + + if (is_multiedit) { + init_gpf = gpl->frames.first; + } + + for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { + if ((gpf == gpl->actframe) || + ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) + { + + if (gpf == NULL) + continue; + + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { + /* skip strokes that are invalid for current view */ + if (ED_gpencil_stroke_can_use(C, gps) == false) + continue; + + BKE_gpencil_dvert_ensure(gps); + + /* create verts array */ + verts = MEM_callocN(gps->totpoints * sizeof(*verts), __func__); + + /* 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->obmat, verts[i]); + } + + /* loop groups and assign weight */ + for (j = 0; j < numbones; j++) { + int def_nr = BLI_findindex(&ob->defbase, dgrouplist[j]); + if (def_nr < 0) { + continue; + } + + float decay_rad = radsqr[j] - (radsqr[j] * decay); + float dif_rad = radsqr[j] - decay_rad; + + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { + MDeformVert *dvert = &gps->dvert[i]; + float dist = dist_squared_to_line_segment_v3(verts[i], root[j], tip[j]); + if (dist > radsqr[j]) { + /* if not in cylinder, check if inside extreme spheres */ + weight = 0.0f; + dist = len_squared_v3v3(root[j], verts[i]); + if (dist < radsqr[j]) { + weight = get_weight(dist, decay_rad, dif_rad); + } + else { + dist = len_squared_v3v3(tip[j], verts[i]); + if (dist < radsqr[j]) { + weight = get_weight(dist, decay_rad, dif_rad); + } + } + } + else { + /* inside bone cylinder */ + weight = get_weight(dist, decay_rad, dif_rad); + } + + /* assign weight */ + MDeformWeight *dw = defvert_verify_index(dvert, def_nr); + if (dw) { + dw->weight = weight; + } + } + } + MEM_SAFE_FREE(verts); + } + } + + /* if not multiedit, exit loop*/ + if (!is_multiedit) { + break; + } + } + } + + /* free the memory allocated */ + MEM_SAFE_FREE(bonelist); + MEM_SAFE_FREE(dgrouplist); + MEM_SAFE_FREE(root); + MEM_SAFE_FREE(tip); + MEM_SAFE_FREE(radsqr); + MEM_SAFE_FREE(selected); +} + +static void gpencil_object_vgroup_calc_from_armature( + const bContext *C, + Object *ob, Object *ob_arm, + const int mode, const float ratio, const float decay) +{ + /* Lets try to create some vertex groups + * based on the bones of the parent armature. + */ + bArmature *arm = ob_arm->data; + + /* always create groups */ + const int defbase_tot = BLI_listbase_count(&ob->defbase); + int defbase_add; + /* Traverse the bone list, trying to create empty vertex + * groups corresponding to the bone. + */ + defbase_add = gpencil_bone_looper(ob, arm->bonebase.first, NULL, + vgroup_add_unique_bone_cb); + + if (defbase_add) { + /* its possible there are DWeight's outside the range of the current + * objects deform groups, in this case the new groups wont be empty */ + ED_vgroup_data_clamp_range(ob->data, defbase_tot); + } + + if (mode == GP_ARMATURE_AUTO) { + /* Traverse the bone list, trying to fill vertex groups + * with the corresponding vertice weights for which the + * bone is closest. + */ + gpencil_add_verts_to_dgroups( + C, ob, ob_arm, + ratio, decay); + } +} + +bool ED_gpencil_add_armature_weights( + const bContext *C, ReportList *reports, + Object *ob, Object *ob_arm, int mode) +{ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + + /* if no armature modifier, add a new one */ + GpencilModifierData *md = BKE_gpencil_modifiers_findByType(ob, eGpencilModifierType_Armature); + if (md == NULL) { + md = ED_object_gpencil_modifier_add(reports, bmain, scene, + ob, "Armature", eGpencilModifierType_Armature); + if (md == NULL) { + BKE_report(reports, RPT_ERROR, + "Unable to add a new Armature modifier to object"); + return false; + } + DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA); + } + + /* verify armature */ + ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md; + if (mmd->object == NULL) { + mmd->object = ob_arm; + } + else { + if (ob_arm != mmd->object) { + BKE_report(reports, RPT_ERROR, + "The existing Armature modifier is already using a different Armature object"); + return false; + } + } + + /* add weights */ + gpencil_object_vgroup_calc_from_armature(C, ob, ob_arm, mode, DEFAULT_RATIO, DEFAULT_DECAY); + + return true; +} +/* ***************** Generate armature weights ************************** */ +static bool gpencil_generate_weights_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + bGPdata *gpd = (bGPdata *)ob->data; + + if (BLI_listbase_count(&gpd->layers) == 0) { + return false; + } + + /* need some armature in the view layer */ + for (Base *base = view_layer->object_bases.first; base; base = base->next) { + if (base->object->type == OB_ARMATURE) { + return true; + } + } + + return false; +} + +static int gpencil_generate_weights_exec(bContext *C, wmOperator *op) +{ + Depsgraph *depsgraph = CTX_data_depsgraph(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = CTX_data_active_object(C); + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); + bGPdata *gpd = (bGPdata *)ob->data; + Object *ob_arm = NULL; + + const int mode = RNA_enum_get(op->ptr, "mode"); + const float ratio = RNA_float_get(op->ptr, "ratio"); + const float decay = RNA_float_get(op->ptr, "decay"); + + /* sanity checks */ + if (ELEM(NULL, ob, gpd)) + return OPERATOR_CANCELLED; + + /* get armature */ + const int arm_idx = RNA_enum_get(op->ptr, "armature"); + if (arm_idx > 0) { + Base *base = BLI_findlink(&view_layer->object_bases, arm_idx - 1); + ob_arm = base->object; + } + else { + /* get armature from modifier */ + GpencilModifierData *md = BKE_gpencil_modifiers_findByType(ob_eval, eGpencilModifierType_Armature); + if (md == NULL) { + BKE_report(op->reports, RPT_ERROR, + "The grease pencil object need an Armature modifier"); + return OPERATOR_CANCELLED; + } + + ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md; + if (mmd->object == NULL) { + BKE_report(op->reports, RPT_ERROR, + "Armature modifier is not valid or wrong defined"); + return OPERATOR_CANCELLED; + } + + ob_arm = mmd->object; + } + + if (ob_arm == NULL) { + BKE_report(op->reports, RPT_ERROR, + "No Armature object in the view layer"); + return OPERATOR_CANCELLED; + } + + gpencil_object_vgroup_calc_from_armature(C, ob, ob_arm, mode, ratio, decay); + + /* notifiers */ + DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + + return OPERATOR_FINISHED; +} + +/* Dynamically populate an enum of Armatures */ +static const EnumPropertyItem *gpencil_armatures_enum_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + EnumPropertyItem *item = NULL, item_tmp = { 0 }; + int totitem = 0; + int i = 0; + + if (C == NULL) { + return DummyRNA_DEFAULT_items; + } + + /* add default */ + item_tmp.identifier = "DEFAULT"; + item_tmp.name = "Default"; + item_tmp.value = 0; + RNA_enum_item_add(&item, &totitem, &item_tmp); + i++; + + for (Base *base = view_layer->object_bases.first; base; base = base->next) { + Object *ob = base->object; + if (ob->type == OB_ARMATURE) { + item_tmp.identifier = item_tmp.name = ob->id.name + 2; + item_tmp.value = i; + RNA_enum_item_add(&item, &totitem, &item_tmp); + } + i++; + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + +void GPENCIL_OT_generate_weights(wmOperatorType *ot) +{ + static const EnumPropertyItem mode_type[] = { + {GP_ARMATURE_NAME, "NAME", 0, "Empty Groups", ""}, + {GP_ARMATURE_AUTO, "AUTO", 0, "Automatic Weights", ""}, + {0, NULL, 0, NULL, NULL} + }; + + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Generate Automatic Weights"; + ot->idname = "GPENCIL_OT_generate_weights"; + ot->description = "Generate automatic weights for armatures (requires armature modifier)"; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* callbacks */ + ot->exec = gpencil_generate_weights_exec; + ot->poll = gpencil_generate_weights_poll; + + ot->prop = RNA_def_enum(ot->srna, "mode", mode_type, 0, "Mode", ""); + + prop = RNA_def_enum(ot->srna, "armature", DummyRNA_DEFAULT_items, 0, "Armature", "Armature to use"); + RNA_def_enum_funcs(prop, gpencil_armatures_enum_itemf); + + RNA_def_float( + ot->srna, "ratio", DEFAULT_RATIO, 0.0f, 2.0f, "Ratio", + "Ratio between bone length and influence radius", 0.001f, 1.0f); + + RNA_def_float( + ot->srna, "decay", DEFAULT_DECAY, 0.0f, 1.0f, "Decay", + "Factor to reduce influence depending of distance to bone axis", 0.0f, 1.0f); +} diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index ddce148a3a3..6eff4d3687f 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -57,6 +57,7 @@ #include "DNA_object_types.h" #include "BKE_context.h" +#include "BKE_deform.h" #include "BKE_gpencil.h" #include "BKE_library.h" #include "BKE_report.h" @@ -876,6 +877,9 @@ static bool gp_brush_weight_apply( tGP_BrushEditData *gso, bGPDstroke *gps, int pt_index, const int radius, const int co[2]) { + /* create dvert */ + BKE_gpencil_dvert_ensure(gps); + bGPDspoint *pt = gps->points + pt_index; MDeformVert *dvert = gps->dvert + pt_index; float inf; @@ -894,14 +898,8 @@ static bool gp_brush_weight_apply( } } /* get current weight */ - float curweight = 0.0f; - for (int i = 0; i < dvert->totweight; i++) { - MDeformWeight *gpw = &dvert->dw[i]; - if (gpw->def_nr == gso->vrgroup) { - curweight = gpw->weight; - break; - } - } + MDeformWeight *dw = defvert_verify_index(dvert, gso->vrgroup); + float curweight = dw ? dw->weight : 0.0f; if (gp_brush_invert_check(gso)) { /* reduce weight */ @@ -913,7 +911,9 @@ static bool gp_brush_weight_apply( } CLAMP(curweight, 0.0f, 1.0f); - BKE_gpencil_vgroup_add_point_weight(dvert, gso->vrgroup, curweight); + if (dw) { + dw->weight = curweight; + } /* weight should stay within [0.0, 1.0] */ if (pt->pressure < 0.0f) @@ -1055,8 +1055,10 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) new_stroke = MEM_dupallocN(gps); new_stroke->points = MEM_dupallocN(gps->points); - new_stroke->dvert = MEM_dupallocN(gps->dvert); - BKE_gpencil_stroke_weights_duplicate(gps, new_stroke); + if (gps->dvert != NULL) { + new_stroke->dvert = MEM_dupallocN(gps->dvert); + BKE_gpencil_stroke_weights_duplicate(gps, new_stroke); + } new_stroke->triangles = MEM_dupallocN(gps->triangles); new_stroke->next = new_stroke->prev = NULL; diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index f662e9b42be..afce0fb7a43 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -47,8 +47,8 @@ #include "BLT_translation.h" #include "DNA_anim_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" -#include "DNA_group_types.h" #include "DNA_object_types.h" #include "DNA_node_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 4084ed1c7ac..818a694a899 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -418,6 +418,144 @@ void GPENCIL_OT_layer_duplicate(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/* ********************* Duplicate Layer in a new object ************************** */ +enum { + GP_LAYER_COPY_OBJECT_ALL_FRAME = 0, + GP_LAYER_COPY_OBJECT_ACT_FRAME = 1 +}; + +static bool gp_layer_duplicate_object_poll(bContext *C) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = CTX_data_active_object(C); + if ((ob == NULL) || (ob->type != OB_GPENCIL)) + return false; + + bGPdata *gpd = (bGPdata *)ob->data; + bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); + + if (gpl == NULL) + return false; + + /* check there are more grease pencil objects */ + for (Base *base = view_layer->object_bases.first; base; base = base->next) { + if ((base->object != ob) && (base->object->type == OB_GPENCIL)) + return true; + } + + return false; +} + +static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op) +{ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + char name[MAX_ID_NAME - 2]; + RNA_string_get(op->ptr, "object", name); + + if (name[0] == '\0') { + return OPERATOR_CANCELLED; + } + + Object *ob_dst = (Object *)BKE_scene_object_find_by_name(scene, name); + + int mode = RNA_enum_get(op->ptr, "mode"); + + Object *ob_src = CTX_data_active_object(C); + bGPdata *gpd_src = (bGPdata *)ob_src->data; + bGPDlayer *gpl_src = BKE_gpencil_layer_getactive(gpd_src); + + /* sanity checks */ + if (ELEM(NULL, gpd_src, gpl_src, ob_dst)) { + return OPERATOR_CANCELLED; + } + /* cannot copy itself and check destination type */ + if ((ob_src == ob_dst) || (ob_dst->type != OB_GPENCIL)) { + return OPERATOR_CANCELLED; + } + + bGPdata *gpd_dst = (bGPdata *)ob_dst->data; + + /* make copy of layer */ + bGPDlayer *gpl_dst = MEM_dupallocN(gpl_src); + gpl_dst->prev = gpl_dst->next = NULL; + gpl_dst->runtime.derived_data = NULL; + BLI_addtail(&gpd_dst->layers, gpl_dst); + BLI_uniquename(&gpd_dst->layers, gpl_dst, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl_dst->info)); + + /* copy frames */ + BLI_listbase_clear(&gpl_dst->frames); + for (bGPDframe *gpf_src = gpl_src->frames.first; gpf_src; gpf_src = gpf_src->next) { + + if ((mode == GP_LAYER_COPY_OBJECT_ACT_FRAME) && (gpf_src != gpl_src->actframe)) { + continue; + } + + /* make a copy of source frame */ + bGPDframe *gpf_dst = MEM_dupallocN(gpf_src); + gpf_dst->prev = gpf_dst->next = NULL; + BLI_addtail(&gpl_dst->frames, gpf_dst); + + /* copy strokes */ + BLI_listbase_clear(&gpf_dst->strokes); + for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) { + + /* make copy of source stroke */ + bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src); + + /* check if material is in destination object, + * otherwise add the slot with the material + */ + Material *ma_src = give_current_material(ob_src, gps_src->mat_nr + 1); + int idx = BKE_gpencil_get_material_index(ob_dst, ma_src); + if (idx == 0) { + BKE_object_material_slot_add(bmain, ob_dst); + assign_material(bmain, ob_dst, ma_src, ob_dst->totcol, BKE_MAT_ASSIGN_USERPREF); + idx = ob_dst->totcol; + } + + /* reasign the stroke material to the right slot in destination object */ + gps_dst->mat_nr = idx - 1; + + /* add new stroke to frame */ + BLI_addtail(&gpf_dst->strokes, gps_dst); + } + } + + /* notifiers */ + DEG_id_tag_update(&gpd_dst->id, OB_RECALC_OB | OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE); + DEG_id_tag_update(&ob_dst->id, DEG_TAG_COPY_ON_WRITE); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + + return OPERATOR_FINISHED; +} + +void GPENCIL_OT_layer_duplicate_object(wmOperatorType *ot) +{ + static const EnumPropertyItem copy_mode[] = { + {GP_LAYER_COPY_OBJECT_ALL_FRAME, "ALL", 0, "All Frames", ""}, + {GP_LAYER_COPY_OBJECT_ACT_FRAME, "ACTIVE", 0, "Active Frame", ""}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name = "Duplicate Layer to new Object"; + ot->idname = "GPENCIL_OT_layer_duplicate_object"; + ot->description = "Make a copy of the active Grease Pencil layer to new object"; + + /* callbacks */ + ot->exec = gp_layer_duplicate_object_exec; + ot->poll = gp_layer_duplicate_object_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + ot->prop = RNA_def_string(ot->srna, "object", NULL, MAX_ID_NAME - 2, "Object", "Name of the destination object"); + RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE); + + RNA_def_enum(ot->srna, "mode", copy_mode, GP_LAYER_COPY_OBJECT_ALL_FRAME, "Mode", ""); +} + /* ********************* Duplicate Frame ************************** */ enum { GP_FRAME_DUP_ACTIVE = 0, @@ -545,9 +683,9 @@ static int gp_frame_clean_fill_exec(bContext *C, wmOperator *op) void GPENCIL_OT_frame_clean_fill(wmOperatorType *ot) { static const EnumPropertyItem duplicate_mode[] = { - { GP_FRAME_CLEAN_FILL_ACTIVE, "ACTIVE", 0, "Active Frame Only", "Clean active frame only" }, - { GP_FRAME_CLEAN_FILL_ALL, "ALL", 0, "All Frames", "Clean all frames in all layers" }, - { 0, NULL, 0, NULL, NULL } + {GP_FRAME_CLEAN_FILL_ACTIVE, "ACTIVE", 0, "Active Frame Only", "Clean active frame only"}, + {GP_FRAME_CLEAN_FILL_ALL, "ALL", 0, "All Frames", "Clean all frames in all layers"}, + {0, NULL, 0, NULL, NULL} }; /* identifiers */ @@ -587,9 +725,6 @@ static int gp_frame_clean_loose_exec(bContext *C, wmOperator *op) if (gpf == NULL) continue; - if (gpf == NULL) - continue; - /* simply delete strokes which are no loose */ for (gps = gpf->strokes.first; gps; gps = gpsn) { gpsn = gps->next; @@ -1683,14 +1818,15 @@ static int gpencil_vertex_group_invert_exec(bContext *C, wmOperator *UNUSED(op)) { for (int i = 0; i < gps->totpoints; i++) { dvert = &gps->dvert[i]; - if (dvert->dw == NULL) { - BKE_gpencil_vgroup_add_point_weight(dvert, def_nr, 1.0f); + MDeformWeight *dw = defvert_find_index(dvert, def_nr); + if (dw == NULL) { + defvert_add_index_notest(dvert, def_nr, 1.0f); } - else if (dvert->dw->weight == 1.0f) { - BKE_gpencil_vgroup_remove_point_weight(dvert, def_nr); + else if (dw->weight == 1.0f) { + defvert_remove_group(dvert, dw); } else { - dvert->dw->weight = 1.0f - dvert->dw->weight; + dw->weight = 1.0f - dw->weight; } } } @@ -1763,10 +1899,8 @@ static int gpencil_vertex_group_smooth_exec(bContext *C, wmOperator *op) ptc = &gps->points[i]; } - float wa = BKE_gpencil_vgroup_use_index(dverta, def_nr); - float wb = BKE_gpencil_vgroup_use_index(dvertb, def_nr); - CLAMP_MIN(wa, 0.0f); - CLAMP_MIN(wb, 0.0f); + float wa = defvert_find_weight(dverta, def_nr); + float wb = defvert_find_weight(dvertb, def_nr); /* the optimal value is the corresponding to the interpolation of the weight * at the distance of point b @@ -1774,8 +1908,10 @@ static int gpencil_vertex_group_smooth_exec(bContext *C, wmOperator *op) const float opfac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x); const float optimal = interpf(wa, wb, opfac); /* Based on influence factor, blend between original and optimal */ - wb = interpf(wb, optimal, fac); - BKE_gpencil_vgroup_add_point_weight(dvertb, def_nr, wb); + MDeformWeight *dw = defvert_verify_index(dvertb, def_nr); + if (dw) { + dw->weight = interpf(wb, optimal, fac); + } } } } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 81a5fbdf069..171c52470c0 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -25,9 +25,9 @@ * Operators for editing Grease Pencil strokes */ -/** \file blender/editors/gpencil/gpencil_edit.c - * \ingroup edgpencil - */ + /** \file blender/editors/gpencil/gpencil_edit.c + * \ingroup edgpencil + */ #include <stdio.h> @@ -92,8 +92,8 @@ #include "gpencil_intern.h" -/* ************************************************ */ -/* Stroke Edit Mode Management */ + /* ************************************************ */ + /* Stroke Edit Mode Management */ static bool gpencil_editmode_toggle_poll(bContext *C) { /* if using gpencil object, use this gpd */ @@ -108,7 +108,7 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op) { const int back = RNA_boolean_get(op->ptr, "back"); Depsgraph *depsgraph = CTX_data_depsgraph(C); \ - bGPdata *gpd = ED_gpencil_data_get_active(C); + bGPdata *gpd = ED_gpencil_data_get_active(C); bool is_object = false; short mode; /* if using a gpencil object, use this datablock */ @@ -672,8 +672,8 @@ void GPENCIL_OT_duplicate(wmOperatorType *ot) * from several different layers into a single layer. */ -/* list of bGPDstroke instances */ -/* NOTE: is exposed within the editors/gpencil module so that other tools can use it too */ + /* list of bGPDstroke instances */ + /* NOTE: is exposed within the editors/gpencil module so that other tools can use it too */ ListBase gp_strokes_copypastebuf = {NULL, NULL}; /* Hash for hanging on to all the colors used by strokes in the buffer @@ -1252,7 +1252,7 @@ void GPENCIL_OT_blank_frame_add(wmOperatorType *ot) ot->name = "Insert Blank Frame"; ot->idname = "GPENCIL_OT_blank_frame_add"; ot->description = "Insert a blank frame on the current frame " - "(all subsequently existing frames, if any, are shifted right by one frame)"; + "(all subsequently existing frames, if any, are shifted right by one frame)"; /* callbacks */ ot->exec = gp_blank_frame_add_exec; @@ -1774,7 +1774,7 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke /* Create each new stroke... */ for (idx = 0; idx < num_islands; idx++) { tGPDeleteIsland *island = &islands[idx]; - bGPDstroke *new_stroke = MEM_dupallocN(gps); + bGPDstroke *new_stroke = MEM_dupallocN(gps); /* initialize triangle memory - to be calculated on next redraw */ new_stroke->triangles = NULL; @@ -1785,13 +1785,13 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke new_stroke->totpoints = island->end_idx - island->start_idx + 1; /* Copy over the relevant point data */ - new_stroke->points = MEM_callocN(sizeof(bGPDspoint) * new_stroke->totpoints, "gp delete stroke fragment"); + new_stroke->points = MEM_callocN(sizeof(bGPDspoint) * new_stroke->totpoints, "gp delete stroke fragment"); memcpy(new_stroke->points, gps->points + island->start_idx, sizeof(bGPDspoint) * new_stroke->totpoints); /* Copy over vertex weight data (if available) */ if (new_stroke->dvert != NULL) { /* Copy over the relevant vertex-weight points */ - new_stroke->dvert = MEM_callocN(sizeof(MDeformVert) * new_stroke->totpoints, "gp delete stroke fragment weight"); + new_stroke->dvert = MEM_callocN(sizeof(MDeformVert) * new_stroke->totpoints, "gp delete stroke fragment weight"); memcpy(new_stroke->dvert, gps->dvert + island->start_idx, sizeof(MDeformVert) * new_stroke->totpoints); /* Copy weights */ @@ -2024,10 +2024,11 @@ static bool gp_snap_poll(bContext *C) static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op)) { bGPdata *gpd = ED_gpencil_data_get_active(C); - RegionView3D *rv3d = CTX_wm_region_data(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); \ + View3D *v3d = CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *obact = CTX_data_active_object(C); - const float gridf = rv3d->gridview; + const float gridf = ED_view3d_grid_scale(scene, v3d, NULL); for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only editable and visible layers are considered */ @@ -2100,9 +2101,9 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); \ - Object *obact = CTX_data_active_object(C); \ + Object *obact = CTX_data_active_object(C); \ - const bool use_offset = RNA_boolean_get(op->ptr, "use_offset"); + const bool use_offset = RNA_boolean_get(op->ptr, "use_offset"); const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d)->location; for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { @@ -2176,7 +2177,7 @@ void GPENCIL_OT_snap_to_cursor(wmOperatorType *ot) /* props */ ot->prop = RNA_def_boolean(ot->srna, "use_offset", true, "With Offset", - "Offset the entire stroke instead of selected points only"); + "Offset the entire stroke instead of selected points only"); } /* ------------------------------- */ @@ -2188,9 +2189,9 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); \ - Object *obact = CTX_data_active_object(C); \ + Object *obact = CTX_data_active_object(C); \ - float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location; + float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location; float centroid[3] = {0.0f}; float min[3], max[3]; size_t count = 0; @@ -2227,7 +2228,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) float fpt[3]; mul_v3_m4v3(fpt, diff_mat, &pt->x); - add_v3_v3(centroid, fpt); + add_v3_v3(centroid, fpt); minmax_v3v3_v3(min, max, fpt); count++; @@ -2453,7 +2454,7 @@ static void gpencil_flip_stroke(bGPDstroke *gps) /* Helper: copy point between strokes */ static void gpencil_stroke_copy_point(bGPDstroke *gps, bGPDspoint *point, int idx, float delta[3], - float pressure, float strength, float deltatime) + float pressure, float strength, float deltatime) { bGPDspoint *newpoint; @@ -2880,8 +2881,8 @@ void GPENCIL_OT_reproject(wmOperatorType *ot) ot->name = "Reproject Strokes"; ot->idname = "GPENCIL_OT_reproject"; ot->description = "Reproject the selected strokes from the current viewpoint as if they had been newly drawn " - "(e.g. to fix problems from accidental 3D cursor movement or accidental viewport changes, " - "or for matching deforming geometry)"; + "(e.g. to fix problems from accidental 3D cursor movement or accidental viewport changes, " + "or for matching deforming geometry)"; /* callbacks */ ot->invoke = WM_menu_invoke; @@ -2943,6 +2944,14 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) temp_points = MEM_dupallocN(gps->points); oldtotpoints = gps->totpoints; + MDeformVert *temp_dverts = NULL; + MDeformVert *dvert_final = NULL; + MDeformVert *dvert = NULL; + MDeformVert *dvert_next = NULL; + if (gps->dvert != NULL) { + temp_dverts = MEM_dupallocN(gps->dvert); + } + /* resize the points arrys */ gps->totpoints += totnewpoints; gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints); @@ -2957,8 +2966,6 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) bGPDspoint *pt = &temp_points[i]; bGPDspoint *pt_final = &gps->points[i2]; - MDeformVert *dvert_final = &gps->dvert[i2]; - /* copy current point */ copy_v3_v3(&pt_final->x, &pt->x); pt_final->pressure = pt->pressure; @@ -2966,8 +2973,12 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) pt_final->time = pt->time; pt_final->flag = pt->flag; - dvert_final->totweight = 0; - dvert_final->dw = NULL; + if (gps->dvert != NULL) { + dvert = &temp_dverts[i]; + dvert_final = &gps->dvert[i2]; + dvert_final->totweight = dvert->totweight; + dvert_final->dw = dvert->dw; + } i2++; /* if next point is selected add a half way point */ @@ -2987,16 +2998,34 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) pt_final->time = interpf(pt->time, next->time, 0.5f); pt_final->flag |= GP_SPOINT_SELECT; - dvert_final->totweight = 0; - dvert_final->dw = NULL; + /* interpolate weights */ + if (gps->dvert != NULL) { + dvert = &temp_dverts[i]; + dvert_next = &temp_dverts[i + 1]; + dvert_final = &gps->dvert[i2]; + + dvert_final->totweight = dvert->totweight; + dvert_final->dw = MEM_dupallocN(dvert->dw); - i2++; + /* interpolate weight values */ + for (int d = 0; d < dvert->totweight; d++) { + MDeformWeight *dw_a = &dvert->dw[d]; + if (dvert_next->totweight > d) { + MDeformWeight *dw_b = &dvert_next->dw[d]; + MDeformWeight *dw_final = &dvert_final->dw[d]; + dw_final->weight = interpf(dw_a->weight, dw_b->weight, 0.5f); + } + } + } + + i2++; } } } } /* free temp memory */ - MEM_freeN(temp_points); + MEM_SAFE_FREE(temp_points); + MEM_SAFE_FREE(temp_dverts); } } } @@ -3317,10 +3346,10 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op) void GPENCIL_OT_stroke_separate(wmOperatorType *ot) { static const EnumPropertyItem separate_type[] = { - {GP_SEPARATE_POINT, "POINT", 0, "Selected Points", "Separate the selected points" }, - {GP_SEPARATE_STROKE, "STROKE", 0, "Selected Strokes", "Separate the selected strokes"}, - {GP_SEPARATE_LAYER, "LAYER", 0, "Active Layer", "Separate the strokes of the current layer" }, - { 0, NULL, 0, NULL, NULL } + {GP_SEPARATE_POINT, "POINT", 0, "Selected Points", "Separate the selected points"}, + {GP_SEPARATE_STROKE, "STROKE", 0, "Selected Strokes", "Separate the selected strokes"}, + {GP_SEPARATE_LAYER, "LAYER", 0, "Active Layer", "Separate the strokes of the current layer"}, + {0, NULL, 0, NULL, NULL} }; /* identifiers */ diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index c6df07ae83e..2ff7e45d7a2 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -23,9 +23,9 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/gpencil/gpencil_fill.c - * \ingroup edgpencil - */ + /** \file blender/editors/gpencil/gpencil_fill.c + * \ingroup edgpencil + */ #include <stdio.h> @@ -47,6 +47,7 @@ #include "BKE_main.h" #include "BKE_brush.h" +#include "BKE_deform.h" #include "BKE_image.h" #include "BKE_gpencil.h" #include "BKE_material.h" @@ -84,7 +85,7 @@ #define LEAK_VERT 1 -/* Temporary fill operation data (op->customdata) */ + /* Temporary fill operation data (op->customdata) */ typedef struct tGPDfill { struct Main *bmain; struct Depsgraph *depsgraph; @@ -124,10 +125,10 @@ typedef struct tGPDfill { } tGPDfill; - /* draw a given stroke using same thickness and color for all points */ +/* draw a given stroke using same thickness and color for all points */ static void gp_draw_basic_stroke( - tGPDfill *tgpf, bGPDstroke *gps, const float diff_mat[4][4], - bool cyclic, float ink[4], int flag, float thershold) + tGPDfill *tgpf, bGPDstroke *gps, const float diff_mat[4][4], + bool cyclic, float ink[4], int flag, float thershold) { bGPDspoint *points = gps->points; @@ -247,7 +248,7 @@ static void gp_draw_datablock(tGPDfill *tgpf, float ink[4]) /* normal strokes */ if ((tgpf->fill_draw_mode == GP_FILL_DMODE_STROKE) || - (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) + (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) { ED_gp_draw_fill(&tgpw); @@ -255,7 +256,7 @@ static void gp_draw_datablock(tGPDfill *tgpf, float ink[4]) /* 3D Lines with basic shapes and invisible lines */ if ((tgpf->fill_draw_mode == GP_FILL_DMODE_CONTROL) || - (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) + (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) { gp_draw_basic_stroke(tgpf, gps, tgpw.diff_mat, gps->flag & GP_STROKE_CYCLIC, ink, tgpf->flag, tgpf->fill_threshold); @@ -266,7 +267,7 @@ static void gp_draw_datablock(tGPDfill *tgpf, float ink[4]) glDisable(GL_BLEND); } - /* draw strokes in offscreen buffer */ +/* draw strokes in offscreen buffer */ static void gp_render_offscreen(tGPDfill *tgpf) { bool is_ortho = false; @@ -298,8 +299,8 @@ static void gp_render_offscreen(tGPDfill *tgpf) int bwiny = tgpf->ar->winy; rcti brect = tgpf->ar->winrct; - tgpf->ar->winx = (short) tgpf->sizex; - tgpf->ar->winy = (short) tgpf->sizey; + tgpf->ar->winx = (short)tgpf->sizex; + tgpf->ar->winy = (short)tgpf->sizey; tgpf->ar->winrct.xmin = 0; tgpf->ar->winrct.ymin = 0; tgpf->ar->winrct.xmax = tgpf->sizex; @@ -314,8 +315,8 @@ static void gp_render_offscreen(tGPDfill *tgpf) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ED_view3d_update_viewmat( - tgpf->depsgraph, tgpf->scene, tgpf->v3d, tgpf->ar, - NULL, winmat, NULL); + tgpf->depsgraph, tgpf->scene, tgpf->v3d, tgpf->ar, + NULL, winmat, NULL); /* set for opengl */ GPU_matrix_projection_set(tgpf->rv3d->winmat); GPU_matrix_set(tgpf->rv3d->viewmat); @@ -419,7 +420,7 @@ static bool is_leak_narrow(ImBuf *ibuf, const int maxpixel, int limit, int index if (pt <= maxpixel) { get_pixel(ibuf, pt, rgba); if (rgba[0] == 1.0f) { - t_a = true; + t_a = true; break; } } @@ -675,7 +676,7 @@ static void gpencil_get_outline_points(tGPDfill *tgpf) int cur_back_offset = -1; for (int i = 0; i < NEIGHBOR_COUNT; i++) { if (backtracked_offset[0][0] == offset[i][0] && - backtracked_offset[0][1] == offset[i][1]) + backtracked_offset[0][1] == offset[i][1]) { /* Finding the bracktracked pixel offset index */ cur_back_offset = i; @@ -709,7 +710,7 @@ static void gpencil_get_outline_points(tGPDfill *tgpf) } /* current pixel is equal to starting pixel */ if (boundary_co[0] == start_co[0] && - boundary_co[1] == start_co[1]) + boundary_co[1] == start_co[1]) { BLI_stack_pop(tgpf->stack, &v); // boundary_found = true; @@ -757,9 +758,9 @@ static void gpencil_get_depth_array(tGPDfill *tgpf) copy_v2_v2_int(mval, &ptc->x); if ((ED_view3d_autodist_depth( - tgpf->ar, mval, depth_margin, tgpf->depth_arr + i) == 0) && - (i && (ED_view3d_autodist_depth_seg( - tgpf->ar, mval, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0))) + tgpf->ar, mval, depth_margin, tgpf->depth_arr + i) == 0) && + (i && (ED_view3d_autodist_depth_seg( + tgpf->ar, mval, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0))) { interp_depth = true; } @@ -803,7 +804,7 @@ static void gpencil_points_from_stack(tGPDfill *tgpf) point2D->y = v[1]; point2D->pressure = 1.0f; - point2D->strength = 1.0f;; + point2D->strength = 1.0f; point2D->time = 0.0f; point2D++; } @@ -822,7 +823,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) } bGPDspoint *pt; - MDeformVert *dvert; + MDeformVert *dvert = NULL; tGPspoint *point2D; if (tgpf->sbuffer_size == 0) { @@ -842,11 +843,15 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) gps->flag |= GP_STROKE_3DSPACE; gps->mat_nr = BKE_gpencil_get_material_index(tgpf->ob, tgpf->mat) - 1; + if (gps->mat_nr < 0) { + BKE_object_material_slot_add(tgpf->bmain, tgpf->ob); + assign_material(tgpf->bmain, tgpf->ob, tgpf->mat, tgpf->ob->totcol, BKE_MAT_ASSIGN_USERPREF); + gps->mat_nr = tgpf->ob->totcol - 1; + } /* allocate memory for storage points */ gps->totpoints = tgpf->sbuffer_size; gps->points = MEM_callocN(sizeof(bGPDspoint) * tgpf->sbuffer_size, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * tgpf->sbuffer_size, "gp_stroke_weights"); /* initialize triangle memory to dummy data */ gps->tot_triangles = 0; @@ -863,22 +868,43 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) /* add points */ pt = gps->points; - dvert = gps->dvert; point2D = (tGPspoint *)tgpf->sbuffer; - for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++, dvert++) { + + const int def_nr = tgpf->ob->actdef - 1; + const bool have_weight = (bool)BLI_findlink(&tgpf->ob->defbase, def_nr); + + if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) { + BKE_gpencil_dvert_ensure(gps); + dvert = gps->dvert; + } + + for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++) { /* convert screen-coordinates to 3D coordinates */ gp_stroke_convertcoords_tpoint( - tgpf->scene, tgpf->ar, tgpf->v3d, tgpf->ob, - tgpf->gpl, point2D, - tgpf->depth_arr ? tgpf->depth_arr + i : NULL, - &pt->x); + tgpf->scene, tgpf->ar, tgpf->v3d, tgpf->ob, + tgpf->gpl, point2D, + tgpf->depth_arr ? tgpf->depth_arr + i : NULL, + &pt->x); pt->pressure = 1.0f; - pt->strength = 1.0f;; + pt->strength = 1.0f; pt->time = 0.0f; - dvert->totweight = 0; - dvert->dw = NULL; + if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) { + MDeformWeight *dw = defvert_verify_index(dvert, def_nr); + if (dw) { + dw->weight = ts->vgroup_weight; + } + + dvert++; + } + else { + if (dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + dvert++; + } + } } /* smooth stroke */ diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index 9d9fede91af..975b09ed5c8 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -335,6 +335,7 @@ void GPENCIL_OT_layer_add(struct wmOperatorType *ot); void GPENCIL_OT_layer_remove(struct wmOperatorType *ot); void GPENCIL_OT_layer_move(struct wmOperatorType *ot); void GPENCIL_OT_layer_duplicate(struct wmOperatorType *ot); +void GPENCIL_OT_layer_duplicate_object(struct wmOperatorType *ot); void GPENCIL_OT_hide(struct wmOperatorType *ot); void GPENCIL_OT_reveal(struct wmOperatorType *ot); @@ -421,6 +422,9 @@ void GPENCIL_OT_color_select(struct wmOperatorType *ot); /* convert old 2.7 files to 2.8 */ void GPENCIL_OT_convert_old_files(struct wmOperatorType *ot); +/* armatures */ +void GPENCIL_OT_generate_weights(struct wmOperatorType *ot); + /* ****************************************************** */ /* FILTERED ACTION DATA - TYPES ---> XXX DEPRECEATED OLD ANIM SYSTEM CODE! */ diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 6541e9f012a..1b7acbd4132 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -1,4 +1,4 @@ -/* +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -110,17 +110,14 @@ static bool gpencil_view3d_poll(bContext *C) } /* Perform interpolation */ -static void gp_interpolate_update_points(bGPDstroke *gps_from, bGPDstroke *gps_to, bGPDstroke *new_stroke, float factor) +static void gp_interpolate_update_points( + const bGPDstroke *gps_from, const bGPDstroke *gps_to, bGPDstroke *new_stroke, float factor) { - bGPDspoint *prev, *pt, *next; - MDeformVert *dvert; - /* update points */ for (int i = 0; i < new_stroke->totpoints; i++) { - prev = &gps_from->points[i]; - pt = &new_stroke->points[i]; - dvert = &new_stroke->dvert[i]; - next = &gps_to->points[i]; + const bGPDspoint *prev = &gps_from->points[i]; + const bGPDspoint *next = &gps_to->points[i]; + bGPDspoint *pt = &new_stroke->points[i]; /* Interpolate all values */ interp_v3_v3v3(&pt->x, &prev->x, &next->x, factor); @@ -128,8 +125,12 @@ static void gp_interpolate_update_points(bGPDstroke *gps_from, bGPDstroke *gps_t pt->strength = interpf(prev->strength, next->strength, 1.0f - factor); CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); + /* GPXX interpolate dverts */ +#if 0 + MDeformVert *dvert = &new_stroke->dvert[i]; dvert->totweight = 0; dvert->dw = NULL; +#endif } } @@ -301,7 +302,9 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) /* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */ if (gps_from->totpoints > gps_to->totpoints) { new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points) * gps_to->totpoints); - new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert) * gps_to->totpoints); + if (new_stroke->dvert != NULL) { + new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert) * gps_to->totpoints); + } new_stroke->totpoints = gps_to->totpoints; new_stroke->tot_triangles = 0; new_stroke->flag |= GP_STROKE_RECALC_CACHES; @@ -313,7 +316,9 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) /* need an empty stroke to keep index correct for lookup, but resize to smallest size */ new_stroke->totpoints = 0; new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points)); - new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert)); + if (new_stroke->dvert != NULL) { + new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert)); + } new_stroke->tot_triangles = 0; new_stroke->triangles = MEM_recallocN(new_stroke->triangles, sizeof(*new_stroke->triangles)); new_stroke->flag |= GP_STROKE_RECALC_CACHES; @@ -587,8 +592,10 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent /* make copy of source stroke, then adjust pointer to points too */ gps_dst = MEM_dupallocN(gps_src); gps_dst->points = MEM_dupallocN(gps_src->points); - gps_dst->dvert = MEM_dupallocN(gps_src->dvert); - BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst); + if (gps_src->dvert != NULL) { + gps_dst->dvert = MEM_dupallocN(gps_src->dvert); + BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst); + } gps_dst->triangles = MEM_dupallocN(gps_src->triangles); gps_dst->flag |= GP_STROKE_RECALC_CACHES; BLI_addtail(&gpf_dst->strokes, gps_dst); @@ -1016,10 +1023,15 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) /* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */ if (gps_from->totpoints > gps_to->totpoints) { /* free weights of removed points */ - BKE_defvert_array_free_elems(gps_from->dvert + gps_to->totpoints, gps_from->totpoints - gps_to->totpoints); + if (gps_from->dvert != NULL) { + BKE_defvert_array_free_elems(gps_from->dvert + gps_to->totpoints, gps_from->totpoints - gps_to->totpoints); + } new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points) * gps_to->totpoints); - new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert) * gps_to->totpoints); + + if (new_stroke->dvert != NULL) { + new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert) * gps_to->totpoints); + } new_stroke->totpoints = gps_to->totpoints; new_stroke->tot_triangles = 0; new_stroke->flag |= GP_STROKE_RECALC_CACHES; diff --git a/source/blender/editors/gpencil/gpencil_old.c b/source/blender/editors/gpencil/gpencil_old.c index a384d6d7ae8..5c01de55885 100644 --- a/source/blender/editors/gpencil/gpencil_old.c +++ b/source/blender/editors/gpencil/gpencil_old.c @@ -146,8 +146,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *UNUSED(op)) { gps->mat_nr = ob->totcol - 1; gps->colorname[0] = '\0'; - /* create weights array */ - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); + /* weights array */ + gps->dvert = NULL; } } } diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index d39dd085add..b14f18714a5 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -62,7 +62,7 @@ /* Generic Drawing Keymap - Annotations */ static void ed_keymap_gpencil_general(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil", 0, 0); wmKeyMapItem *kmi; /* Draw --------------------------------------- */ @@ -335,7 +335,7 @@ static void ed_keymap_gpencil_weight(wmKeyMap *keymap) /* Stroke Editing Keymap - Only when editmode is enabled */ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Edit Mode", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Edit Mode", 0, 0); wmKeyMapItem *kmi; /* set poll callback - so that this keymap only gets enabled when stroke editmode is enabled */ @@ -463,7 +463,7 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) /* keys for draw with a drawing brush (no fill) */ static void ed_keymap_gpencil_painting_draw(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Paint (Draw brush)", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Paint (Draw brush)", 0, 0); wmKeyMapItem *kmi; /* set poll callback */ @@ -518,7 +518,7 @@ static void ed_keymap_gpencil_painting_draw(wmKeyConfig *keyconf) /* keys for draw with a eraser brush (erase) */ static void ed_keymap_gpencil_painting_erase(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Paint (Erase)", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Paint (Erase)", 0, 0); wmKeyMapItem *kmi; /* set poll callback */ @@ -545,7 +545,7 @@ static void ed_keymap_gpencil_painting_erase(wmKeyConfig *keyconf) /* keys for draw with a fill brush */ static void ed_keymap_gpencil_painting_fill(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Paint (Fill)", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Paint (Fill)", 0, 0); wmKeyMapItem *kmi; /* set poll callback */ @@ -577,7 +577,7 @@ static void ed_keymap_gpencil_painting_fill(wmKeyConfig *keyconf) /* Stroke Painting Keymap - Only when paintmode is enabled */ static void ed_keymap_gpencil_painting(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Paint Mode", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Paint Mode", 0, 0); wmKeyMapItem *kmi; /* set poll callback - so that this keymap only gets enabled when stroke paintmode is enabled */ @@ -602,7 +602,7 @@ static void ed_keymap_gpencil_painting(wmKeyConfig *keyconf) /* Stroke Sculpting Keymap - Only when sculptmode is enabled */ static void ed_keymap_gpencil_sculpting(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Sculpt Mode", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Sculpt Mode", 0, 0); /* set poll callback - so that this keymap only gets enabled when stroke sculptmode is enabled */ keymap->poll = gp_stroke_sculptmode_poll; @@ -620,7 +620,7 @@ static void ed_keymap_gpencil_sculpting(wmKeyConfig *keyconf) /* Stroke Weight Paint Keymap - Only when weight is enabled */ static void ed_keymap_gpencil_weightpainting(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Weight Mode", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Weight Mode", 0, 0); wmKeyMapItem *kmi; /* set poll callback - so that this keymap only gets enabled when stroke sculptmode is enabled */ @@ -718,6 +718,7 @@ void ED_operatortypes_gpencil(void) WM_operatortype_append(GPENCIL_OT_layer_remove); WM_operatortype_append(GPENCIL_OT_layer_move); WM_operatortype_append(GPENCIL_OT_layer_duplicate); + WM_operatortype_append(GPENCIL_OT_layer_duplicate_object); WM_operatortype_append(GPENCIL_OT_hide); WM_operatortype_append(GPENCIL_OT_reveal); @@ -784,6 +785,8 @@ void ED_operatortypes_gpencil(void) /* convert old 2.7 files to 2.8 */ WM_operatortype_append(GPENCIL_OT_convert_old_files); + /* armatures */ + WM_operatortype_append(GPENCIL_OT_generate_weights); } void ED_operatormacros_gpencil(void) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index d4371926eb4..f000eac5f94 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -23,9 +23,9 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/gpencil/gpencil_paint.c - * \ingroup edgpencil - */ + /** \file blender/editors/gpencil/gpencil_paint.c + * \ingroup edgpencil + */ #include <stdio.h> @@ -59,6 +59,7 @@ #include "BKE_brush.h" #include "BKE_paint.h" #include "BKE_context.h" +#include "BKE_deform.h" #include "BKE_global.h" #include "BKE_gpencil.h" #include "BKE_report.h" @@ -92,10 +93,10 @@ #include "gpencil_intern.h" -/* ******************************************* */ -/* 'Globals' and Defines */ + /* ******************************************* */ + /* 'Globals' and Defines */ -/* values for tGPsdata->status */ + /* values for tGPsdata->status */ typedef enum eGPencil_PaintStatus { GP_STATUS_IDLING = 0, /* stroke isn't in progress yet */ GP_STATUS_PAINTING, /* a stroke is in progress */ @@ -170,7 +171,7 @@ typedef struct tGPsdata { double ocurtime; /* Used when converting to path */ float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space - * to region space */ + * to region space */ float mat[4][4]; float custom_color[4]; /* custom color - hack for enforcing a particular color for track/mask editing */ @@ -369,38 +370,52 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] /* in 3d-space - pt->x/y/z are 3 side-by-side floats */ if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) { + + /* add small offset to keep stroke over the surface. + * This could be a UI parameter, but the value is too sensitive for + * the user to use it and don't improve the result. + */ + if (depth) { + *depth *= 0.99998f; + } + if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ + + /* verify valid zdepth, if it's wrong, the default darwing mode is used + * and the function doesn't return now */ + if (*depth <= 1.0f) { + return; + } } - else { - float mval_prj[2]; - float rvec[3], dvec[3]; - float mval_f[2]; - copy_v2fl_v2i(mval_f, mval); - float zfac; - - /* Current method just converts each point in screen-coordinates to - * 3D-coordinates using the 3D-cursor as reference. In general, this - * works OK, but it could of course be improved. - * - * TODO: - * - investigate using nearest point(s) on a previous stroke as - * reference point instead or as offset, for easier stroke matching - */ - gp_get_3d_reference(p, rvec); - zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL); + float mval_prj[2]; + float rvec[3], dvec[3]; + float mval_f[2]; + copy_v2fl_v2i(mval_f, mval); + float zfac; - if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { - sub_v2_v2v2(mval_f, mval_prj, mval_f); - ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac); - sub_v3_v3v3(out, rvec, dvec); - } - else { - zero_v3(out); - } + /* Current method just converts each point in screen-coordinates to + * 3D-coordinates using the 3D-cursor as reference. In general, this + * works OK, but it could of course be improved. + * + * TODO: + * - investigate using nearest point(s) on a previous stroke as + * reference point instead or as offset, for easier stroke matching + */ + + gp_get_3d_reference(p, rvec); + zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL); + + if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + sub_v2_v2v2(mval_f, mval_prj, mval_f); + ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac); + sub_v3_v3v3(out, rvec, dvec); + } + else { + zero_v3(out); } } } @@ -543,7 +558,7 @@ static void gp_smooth_buffer(tGPsdata *p, float inf, int idx) /* add current stroke-point to buffer (returns whether point was successfully added) */ static short gp_stroke_addpoint( - tGPsdata *p, const int mval[2], float pressure, double curtime) + tGPsdata *p, const int mval[2], float pressure, double curtime) { bGPdata *gpd = p->gpd; Brush *brush = p->brush; @@ -551,9 +566,11 @@ static short gp_stroke_addpoint( ToolSettings *ts = p->scene->toolsettings; Object *obact = (Object *)p->ownerPtr.data; Depsgraph *depsgraph = p->depsgraph; \ - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->ar->regiondata; View3D *v3d = p->sa->spacedata.first; MaterialGPencilStyle *gp_style = p->material->gp_style; + const int def_nr = obact->actdef - 1; + const bool have_weight = (bool)BLI_findlink(&obact->defbase, def_nr); /* check painting mode */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { @@ -622,7 +639,7 @@ static short gp_stroke_addpoint( } /* apply randomness to pressure */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && - (brush->gpencil_settings->draw_random_press > 0.0f)) + (brush->gpencil_settings->draw_random_press > 0.0f)) { float curvef = curvemapping_evaluateF(brush->gpencil_settings->curve_sensitivity, 0, pressure); float tmp_pressure = curvef * brush->gpencil_settings->draw_sensitivity; @@ -651,7 +668,7 @@ static short gp_stroke_addpoint( /* apply angle of stroke to brush size */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && - (brush->gpencil_settings->draw_angle_factor > 0.0f)) + (brush->gpencil_settings->draw_angle_factor > 0.0f)) { gp_brush_angle(gpd, brush, pt, mval); } @@ -670,7 +687,7 @@ static short gp_stroke_addpoint( /* apply randomness to color strength */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && - (brush->gpencil_settings->draw_random_strength > 0.0f)) + (brush->gpencil_settings->draw_random_strength > 0.0f)) { if (BLI_rng_get_float(p->rng) > 0.5f) { pt->strength -= pt->strength * brush->gpencil_settings->draw_random_strength * BLI_rng_get_float(p->rng); @@ -733,6 +750,9 @@ static short gp_stroke_addpoint( } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { + /* enable special flag for drawing engine */ + gpd->flag |= GP_DATA_STROKE_POLYGON; + bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); /* get pointer to destination point */ pt = (tGPspoint *)(gpd->runtime.sbuffer); @@ -750,18 +770,21 @@ static short gp_stroke_addpoint( if (gp_stroke_added_check(p)) { bGPDstroke *gps = p->gpf->strokes.last; bGPDspoint *pts; - MDeformVert *dvert; + MDeformVert *dvert = NULL; /* first time point is adding to temporary buffer -- need to allocate new point in stroke */ if (gpd->runtime.sbuffer_size == 0) { gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); - gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * (gps->totpoints + 1)); + if (gps->dvert != NULL) { + gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * (gps->totpoints + 1)); + } gps->totpoints++; } pts = &gps->points[gps->totpoints - 1]; - dvert = &gps->dvert[gps->totpoints - 1]; - + if (gps->dvert != NULL) { + dvert = &gps->dvert[gps->totpoints - 1]; + } /* special case for poly lines: normally, * depth is needed only when creating new stroke from buffer, * but poly lines are converting to stroke instantly, @@ -770,7 +793,7 @@ static short gp_stroke_addpoint( if (gpencil_project_check(p)) { view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init( - p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); + p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } /* convert screen-coordinates to appropriate coordinates (and store them) */ @@ -786,8 +809,19 @@ static short gp_stroke_addpoint( pts->uv_fac = pt->uv_fac; pts->uv_rot = pt->uv_rot; - dvert->totweight = 0; - dvert->dw = NULL; + if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) { + BKE_gpencil_dvert_ensure(gps); + MDeformWeight *dw = defvert_verify_index(dvert, def_nr); + if (dw) { + dw->weight = ts->vgroup_weight; + } + } + else { + if (dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + } + } /* force fill recalc */ gps->flag |= GP_STROKE_RECALC_CACHES; @@ -837,9 +871,9 @@ static void gp_stroke_simplify(tGPsdata *p) gp_session_validatebuffer(p); gpd->runtime.sbuffer_sflag = flag; -/* macro used in loop to get position of new point - * - used due to the mixture of datatypes in use here - */ + /* macro used in loop to get position of new point + * - used due to the mixture of datatypes in use here + */ #define GP_SIMPLIFY_AVPOINT(offs, sfac) \ { \ co[0] += (float)(old_points[offs].x * sfac); \ @@ -848,7 +882,7 @@ static void gp_stroke_simplify(tGPsdata *p) time += old_points[offs].time * sfac; \ } (void)0 - /* XXX Here too, do not lose start and end points! */ + /* XXX Here too, do not lose start and end points! */ gp_stroke_addpoint(p, &old_points->x, old_points->pressure, p->inittime + (double)old_points->time); for (i = 0, j = 0; i < num_points; i++) { if (i - j == 3) { @@ -878,7 +912,7 @@ static void gp_stroke_simplify(tGPsdata *p) } } gp_stroke_addpoint(p, &old_points[num_points - 1].x, old_points[num_points - 1].pressure, - p->inittime + (double)old_points[num_points - 1].time); + p->inittime + (double)old_points[num_points - 1].time); /* free old buffer */ MEM_freeN(old_points); @@ -892,11 +926,13 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) bGPDstroke *gps; bGPDspoint *pt; tGPspoint *ptc; - MDeformVert *dvert; + MDeformVert *dvert = NULL; Brush *brush = p->brush; ToolSettings *ts = p->scene->toolsettings; Depsgraph *depsgraph = p->depsgraph; Object *obact = (Object *)p->ownerPtr.data; + const int def_nr = obact->actdef - 1; + const bool have_weight = (bool)BLI_findlink(&obact->defbase, def_nr); int i, totelem; /* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */ @@ -946,7 +982,6 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) const int subdivide = brush->gpencil_settings->draw_subdivide; gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); /* initialize triangle memory to dummy data */ gps->triangles = MEM_callocN(sizeof(bGPDtriangle), "GP Stroke triangulation"); @@ -956,7 +991,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) gp_update_cache(p->gpd); /* set pointer to first non-initialized point */ pt = gps->points + (gps->totpoints - totelem); - dvert = gps->dvert + (gps->totpoints - totelem); + if (gps->dvert != NULL) { + dvert = gps->dvert + (gps->totpoints - totelem); + } /* copy points from the buffer to the stroke */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { @@ -972,12 +1009,23 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) pt->strength = ptc->strength; CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; - - dvert->totweight = 0; - dvert->dw = NULL; - pt++; - dvert++; + + if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) { + BKE_gpencil_dvert_ensure(gps); + MDeformWeight *dw = defvert_verify_index(dvert, def_nr); + if (dw) { + dw->weight = ts->vgroup_weight; + } + dvert++; + } + else { + if (dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + dvert++; + } + } } if (totelem == 2) { @@ -992,8 +1040,19 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; - dvert->totweight = 0; - dvert->dw = NULL; + if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) { + BKE_gpencil_dvert_ensure(gps); + MDeformWeight *dw = defvert_verify_index(dvert, def_nr); + if (dw) { + dw->weight = ts->vgroup_weight; + } + } + else { + if (dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + } + } } /* reproject to plane (only in 3d space) */ @@ -1020,8 +1079,19 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; - dvert->totweight = 0; - dvert->dw = NULL; + if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) { + BKE_gpencil_dvert_ensure(gps); + MDeformWeight *dw = defvert_verify_index(dvert, def_nr); + if (dw) { + dw->weight = ts->vgroup_weight; + } + } + else { + if (dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + } + } } else { @@ -1039,7 +1109,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) copy_v2_v2_int(mval, &ptc->x); if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) && - (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0))) + (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { interp_depth = true; } @@ -1087,6 +1157,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) } pt = gps->points; + dvert = gps->dvert; /* convert all points (normal behavior) */ for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_size && ptc; i++, ptc++, pt++) { @@ -1100,6 +1171,12 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) pt->time = ptc->time; pt->uv_fac = ptc->uv_fac; pt->uv_rot = ptc->uv_rot; + + if (dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + dvert++; + } } /* subdivide and smooth the stroke */ @@ -1108,7 +1185,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) } /* apply randomness to stroke */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && - (brush->gpencil_settings->draw_random_sub > 0.0f)) + (brush->gpencil_settings->draw_random_sub > 0.0f)) { gp_randomize_stroke(gps, brush, p->rng); } @@ -1118,7 +1195,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) * the original stroke */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && - (brush->gpencil_settings->draw_smoothfac > 0.0f)) + (brush->gpencil_settings->draw_smoothfac > 0.0f)) { float reduce = 0.0f; for (int r = 0; r < brush->gpencil_settings->draw_smoothlvl; r++) { @@ -1131,7 +1208,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) } /* smooth thickness */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && - (brush->gpencil_settings->thick_smoothfac > 0.0f)) + (brush->gpencil_settings->thick_smoothfac > 0.0f)) { for (int r = 0; r < brush->gpencil_settings->thick_smoothlvl * 2; r++) { for (i = 0; i < gps->totpoints; i++) { @@ -1165,6 +1242,18 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) else { BLI_addtail(&p->gpf->strokes, gps); } + /* add weights */ + if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) { + BKE_gpencil_dvert_ensure(gps); + for (i = 0; i < gps->totpoints; i++) { + MDeformVert *ve = &gps->dvert[i]; + MDeformWeight *dw = defvert_verify_index(ve, def_nr); + if (dw) { + dw->weight = ts->vgroup_weight; + } + } + } + gp_stroke_added_enable(p); } @@ -1187,7 +1276,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons Object *obact = (Object *)p->ownerPtr.data; if ((p->sa->spacetype == SPACE_VIEW3D) && - (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) + (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) { RegionView3D *rv3d = p->ar->regiondata; bGPDlayer *gpl = p->gpl; @@ -1204,7 +1293,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons const float depth_mval = view3d_point_depth(rv3d, mval_3d); mul_v3_m4v3(fpt, diff_mat, &pt->x); - const float depth_pt = view3d_point_depth(rv3d, fpt); + const float depth_pt = view3d_point_depth(rv3d, fpt); if (depth_pt > depth_mval) { return true; @@ -1252,9 +1341,9 @@ static void gp_free_stroke(bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps) /* eraser tool - evaluation per stroke */ /* TODO: this could really do with some optimization (KD-Tree/BVH?) */ static void gp_stroke_eraser_dostroke(tGPsdata *p, - bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, - const int mval[2], const int mvalo[2], - const int radius, const rcti *rect) + bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, + const int mval[2], const int mvalo[2], + const int radius, const rcti *rect) { Depsgraph *depsgraph = p->depsgraph; Object *obact = (Object *)p->ownerPtr.data; @@ -1316,7 +1405,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, /* Pressure threshold at which stroke should be culled: Calculated as pressure value * below which we would have invisible strokes */ - const float cull_thresh = (gps->thickness) ? 1.0f / ((float)gps->thickness) : 1.0f; + const float cull_thresh = (gps->thickness) ? 1.0f / ((float)gps->thickness) : 1.0f; /* Amount to decrease the pressure of each point with each stroke */ // TODO: Fetch from toolsettings, or compute based on thickness instead? @@ -1359,7 +1448,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, /* Check that point segment of the boundbox of the eraser stroke */ if (((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || - ((!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1])) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) + ((!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1])) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { /* Check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) @@ -1367,7 +1456,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, */ if (gp_stroke_inside_circle(mval, mvalo, radius, pc1[0], pc1[1], pc2[0], pc2[1])) { if ((gp_stroke_eraser_is_occluded(p, pt1, pc1[0], pc1[1]) == false) || - (gp_stroke_eraser_is_occluded(p, pt2, pc2[0], pc2[1]) == false)) + (gp_stroke_eraser_is_occluded(p, pt2, pc2[0], pc2[1]) == false)) { /* Point is affected: */ /* 1) Adjust thickness @@ -1379,13 +1468,13 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, /* 2) Tag any point with overly low influence for removal in the next pass */ if ((pt1->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || - (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)) + (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)) { pt1->flag |= GP_SPOINT_TAG; do_cull = true; } if ((pt2->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || - (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)) + (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD)) { pt2->flag |= GP_SPOINT_TAG; do_cull = true; @@ -1498,7 +1587,7 @@ static Brush *gp_get_default_eraser(Main *bmain, ToolSettings *ts) Brush *brush_old = paint->brush; for (Brush *brush = bmain->brush.first; brush; brush = brush->id.next) { if ((brush->ob_mode == OB_MODE_GPENCIL_PAINT) && - (brush->gpencil_settings->brush_type == GP_BRUSH_TYPE_ERASE)) + (brush->gpencil_settings->brush_type == GP_BRUSH_TYPE_ERASE)) { /* save first eraser to use later if no default */ if (brush_dft == NULL) { @@ -1870,7 +1959,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps if (has_layer_to_erase == false) { p->status = GP_STATUS_ERROR; //if (G.debug & G_DEBUG) - printf("Error: Eraser will not be affecting anything (gpencil_paint_init)\n"); + printf("Error: Eraser will not be affecting anything (gpencil_paint_init)\n"); return; } } @@ -2049,9 +2138,9 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) immUniform1f("dash_factor", 0.5f); imm_draw_circle_wire_2d(shdr_pos, x, y, p->radius, - /* XXX Dashed shader gives bad results with sets of small segments currently, - * temp hack around the issue. :( */ - max_ii(8, p->radius / 2)); /* was fixed 40 */ + /* XXX Dashed shader gives bad results with sets of small segments currently, + * temp hack around the issue. :( */ + max_ii(8, p->radius / 2)); /* was fixed 40 */ immUnbindProgram(); @@ -2072,9 +2161,9 @@ static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short en ED_gpencil_toggle_brush_cursor(p->C, false, NULL); /* enable cursor */ p->erasercursor = WM_paint_cursor_activate( - CTX_wm_manager(C), - NULL, /* XXX */ - gpencil_draw_eraser, p); + CTX_wm_manager(C), + NULL, /* XXX */ + gpencil_draw_eraser, p); } } @@ -2124,6 +2213,7 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op) /* drawing batch cache is dirty now */ bGPdata *gpd = CTX_data_gpencil_data(C); if (gpd) { + gpd->flag &= ~GP_DATA_STROKE_POLYGON; gp_update_cache(gpd); } } @@ -2203,7 +2293,7 @@ static void gpencil_draw_cursor_set(tGPsdata *p) { Brush *brush = p->brush; if ((p->paintmode == GP_PAINTMODE_ERASER) || - (brush->gpencil_settings->brush_type == GP_BRUSH_TYPE_ERASE)) + (brush->gpencil_settings->brush_type == GP_BRUSH_TYPE_ERASE)) { WM_cursor_modal_set(p->win, BC_CROSSCURSOR); /* XXX need a better cursor */ } @@ -2223,10 +2313,10 @@ static void gpencil_draw_status_indicators(bContext *C, tGPsdata *p) case GP_PAINTMODE_DRAW_POLY: /* Provide usage tips, since this is modal, and unintuitive without hints */ ED_workspace_status_text( - C, IFACE_( - "Annotation Create Poly: LMB click to place next stroke vertex | " - "ESC/Enter to end (or click outside this area)" - )); + C, IFACE_( + "Annotation Create Poly: LMB click to place next stroke vertex | " + "ESC/Enter to end (or click outside this area)" + )); break; default: /* Do nothing - the others are self explanatory, exit quickly once the mouse is released @@ -2241,18 +2331,18 @@ static void gpencil_draw_status_indicators(bContext *C, tGPsdata *p) switch (p->paintmode) { case GP_PAINTMODE_ERASER: ED_workspace_status_text(C, IFACE_("Grease Pencil Erase Session: Hold and drag LMB or RMB to erase | " - "ESC/Enter to end (or click outside this area)")); + "ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW_STRAIGHT: ED_workspace_status_text(C, IFACE_("Grease Pencil Line Session: Hold and drag LMB to draw | " - "ESC/Enter to end (or click outside this area)")); + "ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW: ED_workspace_status_text(C, IFACE_("Grease Pencil Freehand Session: Hold and drag LMB to draw")); break; case GP_PAINTMODE_DRAW_POLY: ED_workspace_status_text(C, IFACE_("Grease Pencil Poly Session: LMB click to place next stroke vertex | " - "Release Shift/ESC/Enter to end (or click outside this area)")); + "Release Shift/ESC/Enter to end (or click outside this area)")); break; default: /* unhandled future cases */ @@ -2346,7 +2436,7 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra } } else if ((p->brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) && - (gpd->runtime.sbuffer_size > 0)) + (gpd->runtime.sbuffer_size > 0)) { pt = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_size - 1; if (p->paintmode != GP_PAINTMODE_ERASER) { @@ -2509,7 +2599,7 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op) /* loop over the stroke RNA elements recorded (i.e. progress of mouse movement), * setting the relevant values in context at each step, then applying */ - RNA_BEGIN (op->ptr, itemptr, "stroke") + RNA_BEGIN(op->ptr, itemptr, "stroke") { float mousef[2]; @@ -2589,9 +2679,9 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event /* TODO: set any additional settings that we can take from the events? * TODO? if tablet is erasing, force eraser to be on? */ - /* TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... */ + /* TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... */ - /* if eraser is on, draw radial aid */ + /* if eraser is on, draw radial aid */ if (p->paintmode == GP_PAINTMODE_ERASER) { gpencil_draw_toggle_eraser_cursor(C, p, true); } @@ -2777,7 +2867,7 @@ static void gpencil_add_missing_events(bContext *C, wmOperator *op, const wmEven sub_v2_v2v2(pt, b, pt); /* create fake event */ gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), - (int)pt[0], (int)pt[1]); + (int)pt[0], (int)pt[1]); } else if (dist >= factor) { int slices = 2 + (int)((dist - 1.0) / factor); @@ -2787,7 +2877,7 @@ static void gpencil_add_missing_events(bContext *C, wmOperator *op, const wmEven sub_v2_v2v2(pt, b, pt); /* create fake event */ gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), - (int)pt[0], (int)pt[1]); + (int)pt[0], (int)pt[1]); } } } @@ -2835,7 +2925,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) else if ((event->type == BKEY) && (event->val == KM_RELEASE)) { /* Add Blank Frame * - Since this operator is non-modal, we can just call it here, and keep going... - * - This operator is especially useful when animating + * - This operator is especially useful when animating */ WM_operator_name_call(C, "GPENCIL_OT_blank_frame_add", WM_OP_EXEC_DEFAULT, NULL); estate = OPERATOR_RUNNING_MODAL; @@ -2850,9 +2940,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* exit painting mode (and/or end current stroke) * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647] */ - /* if polyline and release shift must cancel */ + /* if polyline and release shift must cancel */ if ((ELEM(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY, EKEY)) || - ((p->paintmode == GP_PAINTMODE_DRAW_POLY) && (event->shift == 0))) + ((p->paintmode == GP_PAINTMODE_DRAW_POLY) && (event->shift == 0))) { /* exit() ends the current stroke before cleaning up */ /* printf("\t\tGP - end of paint op + end of stroke\n"); */ @@ -3009,7 +3099,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) * NOTE: Don't enter this case if an error occurred while finding the * region (as above) */ - /* if drawing polygon and enable on back, must move stroke */ + /* if drawing polygon and enable on back, must move stroke */ if (ts) { if ((ts->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK) && (p->paintmode == GP_PAINTMODE_DRAW_POLY)) { if (p->flags & GP_PAINTFLAG_STROKEADDED) { @@ -3050,12 +3140,12 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* eraser size */ else if ((p->paintmode == GP_PAINTMODE_ERASER) && - ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, PADPLUSKEY, PADMINUS)) + ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, PADPLUSKEY, PADMINUS)) { /* just resize the brush (local version) * TODO: fix the hardcoded size jumps (set to make a visible difference) and hardcoded keys */ - /* printf("\t\tGP - resize eraser\n"); */ + /* printf("\t\tGP - resize eraser\n"); */ switch (event->type) { case WHEELDOWNMOUSE: /* larger */ case PADPLUSKEY: @@ -3111,7 +3201,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* event doesn't need to be handled */ #if 0 printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", - event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE); + event->type, event->type == MIDDLEMOUSE, event->type == MOUSEMOVE); #endif break; } diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 2dfdeeba0b6..570825d0106 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -25,9 +25,9 @@ * Operators for creating new Grease Pencil primitives (boxes, circles, ...) */ -/** \file blender/editors/gpencil/gpencil_primitive.c - * \ingroup edgpencil - */ + /** \file blender/editors/gpencil/gpencil_primitive.c + * \ingroup edgpencil + */ #include <stdio.h> @@ -56,6 +56,7 @@ #include "BKE_main.h" #include "BKE_brush.h" #include "BKE_context.h" +#include "BKE_deform.h" #include "BKE_global.h" #include "BKE_gpencil.h" #include "BKE_library.h" @@ -89,10 +90,10 @@ #define IDLE 0 #define IN_PROGRESS 1 -/* ************************************************ */ -/* Core/Shared Utilities */ + /* ************************************************ */ + /* Core/Shared Utilities */ -/* Poll callback for primitive operators */ + /* Poll callback for primitive operators */ static bool gpencil_primitive_add_poll(bContext *C) { /* only 3D view */ @@ -182,7 +183,6 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi) /* allocate memory for storage points, but keep empty */ gps->totpoints = 0; gps->points = MEM_callocN(sizeof(bGPDspoint), "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert), "gp_stroke_weights"); /* initialize triangle memory to dummy data */ gps->tot_triangles = 0; gps->triangles = NULL; @@ -231,26 +231,26 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi else { if (tgpi->flag == IN_PROGRESS) { BLI_snprintf( - status_str, sizeof(status_str), "%s: %d (%d, %d) (%d, %d)", msg_str, (int)tgpi->tot_edges, - tgpi->top[0], tgpi->top[1], tgpi->bottom[0], tgpi->bottom[1]); + status_str, sizeof(status_str), "%s: %d (%d, %d) (%d, %d)", msg_str, (int)tgpi->tot_edges, + tgpi->top[0], tgpi->top[1], tgpi->bottom[0], tgpi->bottom[1]); } else { BLI_snprintf( - status_str, sizeof(status_str), "%s: %d (%d, %d)", msg_str, (int)tgpi->tot_edges, - tgpi->bottom[0], tgpi->bottom[1]); + status_str, sizeof(status_str), "%s: %d (%d, %d)", msg_str, (int)tgpi->tot_edges, + tgpi->bottom[0], tgpi->bottom[1]); } } } else { if (tgpi->flag == IN_PROGRESS) { BLI_snprintf( - status_str, sizeof(status_str), "%s: (%d, %d) (%d, %d)", msg_str, - tgpi->top[0], tgpi->top[1], tgpi->bottom[0], tgpi->bottom[1]); + status_str, sizeof(status_str), "%s: (%d, %d) (%d, %d)", msg_str, + tgpi->top[0], tgpi->top[1], tgpi->bottom[0], tgpi->bottom[1]); } else { BLI_snprintf( - status_str, sizeof(status_str), "%s: (%d, %d)", msg_str, - tgpi->bottom[0], tgpi->bottom[1]); + status_str, sizeof(status_str), "%s: (%d, %d)", msg_str, + tgpi->bottom[0], tgpi->bottom[1]); } } ED_workspace_status_text(C, status_str); @@ -322,7 +322,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* realloc points to new size */ /* TODO: only do this if the size has changed? */ gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * tgpi->tot_edges); - gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * tgpi->tot_edges); + if (gps->dvert != NULL) { + gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * tgpi->tot_edges); + } gps->totpoints = tgpi->tot_edges; /* compute screen-space coordinates for points */ @@ -344,7 +346,6 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* convert screen-coordinates to 3D coordinates */ for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; - MDeformVert *dvert = &gps->dvert[i]; tGPspoint *p2d = &points2D[i]; @@ -355,8 +356,11 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) pt->strength = tgpi->brush->gpencil_settings->draw_strength; pt->time = 0.0f; - dvert->totweight = 0; - dvert->dw = NULL; + if (gps->dvert != NULL) { + MDeformVert *dvert = &gps->dvert[i]; + dvert->totweight = 0; + dvert->dw = NULL; + } } /* if axis locked, reproject to plane locked */ @@ -364,12 +368,12 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) bGPDspoint *tpt = gps->points; float origin[3]; ED_gp_get_drawing_reference(tgpi->v3d, tgpi->scene, tgpi->ob, tgpi->gpl, - ts->gpencil_v3d_align, origin); + ts->gpencil_v3d_align, origin); for (int i = 0; i < gps->totpoints; i++, tpt++) { ED_gp_project_point_to_plane(tgpi->ob, tgpi->rv3d, origin, - ts->gp_sculpt.lock_axis - 1, - tpt); + ts->gp_sculpt.lock_axis - 1, + tpt); } } @@ -528,6 +532,11 @@ static void gpencil_primitive_done(bContext *C, wmOperator *op, wmWindow *win, t bGPDframe *gpf; bGPDstroke *gps; + ToolSettings *ts = tgpi->scene->toolsettings; + + const int def_nr = tgpi->ob->actdef - 1; + const bool have_weight = (bool)BLI_findlink(&tgpi->ob->defbase, def_nr); + /* return to normal cursor and header status */ ED_workspace_status_text(C, NULL); WM_cursor_modal_restore(win); @@ -546,6 +555,19 @@ static void gpencil_primitive_done(bContext *C, wmOperator *op, wmWindow *win, t BLI_movelisttolist(&gpf->strokes, &tgpi->gpf->strokes); BLI_assert(BLI_listbase_is_empty(&tgpi->gpf->strokes)); + /* add weights if required */ + if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) { + BKE_gpencil_dvert_ensure(gps); + for (int i = 0; i < gps->totpoints; i++) { + MDeformVert *ve = &gps->dvert[i]; + MDeformWeight *dw = defvert_verify_index(ve, def_nr); + if (dw) { + dw->weight = ts->vgroup_weight; + } + + } + } + /* clean up temp data */ gpencil_primitive_exit(C, op); } diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index cd352579b4a..06747798ec7 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -50,6 +50,7 @@ #include "DNA_view3d_types.h" #include "BKE_action.h" +#include "BKE_deform.h" #include "BKE_main.h" #include "BKE_brush.h" #include "BKE_context.h" @@ -946,7 +947,9 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) /* resize the points arrys */ gps->totpoints += totnewpoints; gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints); - gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints); + if (gps->dvert != NULL) { + gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints); + } gps->flag |= GP_STROKE_RECALC_CACHES; /* move points from last to first to new place */ @@ -954,8 +957,6 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) for (int i = oldtotpoints - 1; i > 0; i--) { bGPDspoint *pt = &temp_points[i]; bGPDspoint *pt_final = &gps->points[i2]; - MDeformVert *dvert = &gps->dvert[i]; - MDeformVert *dvert_final = &gps->dvert[i2]; copy_v3_v3(&pt_final->x, &pt->x); pt_final->pressure = pt->pressure; @@ -965,8 +966,13 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) pt_final->uv_fac = pt->uv_fac; pt_final->uv_rot = pt->uv_rot; - dvert_final->totweight = dvert->totweight; - dvert_final->dw = dvert->dw; + if (gps->dvert != NULL) { + MDeformVert *dvert = &gps->dvert[i]; + MDeformVert *dvert_final = &gps->dvert[i2]; + + dvert_final->totweight = dvert->totweight; + dvert_final->dw = dvert->dw; + } i2 -= 2; } @@ -976,7 +982,6 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) bGPDspoint *pt = &temp_points[i]; bGPDspoint *next = &temp_points[i + 1]; bGPDspoint *pt_final = &gps->points[i2]; - MDeformVert *dvert_final = &gps->dvert[i2]; /* add a half way point */ interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f); @@ -987,8 +992,11 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) pt_final->uv_fac = interpf(pt->uv_fac, next->uv_fac, 0.5f); pt_final->uv_rot = interpf(pt->uv_rot, next->uv_rot, 0.5f); - dvert_final->totweight = 0; - dvert_final->dw = NULL; + if (gps->dvert != NULL) { + MDeformVert *dvert_final = &gps->dvert[i2]; + dvert_final->totweight = 0; + dvert_final->dw = NULL; + } i2 += 2; } @@ -1211,11 +1219,17 @@ void ED_gpencil_vgroup_assign(bContext *C, Object *ob, float weight) CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { if (gps->flag & GP_STROKE_SELECT) { + /* verify the weight array is created */ + BKE_gpencil_dvert_ensure(gps); + for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; MDeformVert *dvert = &gps->dvert[i]; if (pt->flag & GP_SPOINT_SELECT) { - BKE_gpencil_vgroup_add_point_weight(dvert, def_nr, weight); + MDeformWeight *dw = defvert_verify_index(dvert, def_nr); + if (dw) { + dw->weight = weight; + } } } } @@ -1234,10 +1248,16 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob) { for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; + if (gps->dvert == NULL) { + continue; + } MDeformVert *dvert = &gps->dvert[i]; if ((pt->flag & GP_SPOINT_SELECT) && (dvert->totweight > 0)) { - BKE_gpencil_vgroup_remove_point_weight(dvert, def_nr); + MDeformWeight *dw = defvert_find_index(dvert, def_nr); + if (dw != NULL) { + defvert_remove_group(dvert, dw); + } } } } @@ -1255,9 +1275,12 @@ void ED_gpencil_vgroup_select(bContext *C, Object *ob) { for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; + if (gps->dvert == NULL) { + continue; + } MDeformVert *dvert = &gps->dvert[i]; - if (BKE_gpencil_vgroup_use_index(dvert, def_nr) > -1.0f) { + if (defvert_find_index(dvert, def_nr) != NULL) { pt->flag |= GP_SPOINT_SELECT; gps->flag |= GP_STROKE_SELECT; } @@ -1277,9 +1300,12 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob) { for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; + if (gps->dvert == NULL) { + continue; + } MDeformVert *dvert = &gps->dvert[i]; - if (BKE_gpencil_vgroup_use_index(dvert, def_nr) > -1.0f) { + if (defvert_find_index(dvert, def_nr) != NULL) { pt->flag &= ~GP_SPOINT_SELECT; gps->flag |= GP_STROKE_SELECT; } diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index cb422c2fb95..5c193392052 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -221,8 +221,9 @@ bool ED_object_posemode_exit_ex(struct Main *bmain, struct Object *ob); bool ED_object_posemode_exit(struct bContext *C, struct Object *ob); bool ED_object_posemode_enter_ex(struct Main *bmain, struct Object *ob); bool ED_object_posemode_enter(struct bContext *C, struct Object *ob); -void ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility); +bool ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility); void ED_pose_deselect_all_multi(struct Object **objects, uint objects_len, int select_mode, const bool ignore_visibility); +void ED_pose_bone_select_tag_update(struct Object *ob); void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select); void ED_pose_recalculate_paths(struct bContext *C, struct Scene *scene, struct Object *ob); struct Object *ED_pose_object_from_context(struct bContext *C); diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 13f8233079b..25dc6743a33 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -49,6 +49,7 @@ struct Depsgraph; struct ScrArea; struct ARegion; struct RegionView3D; +struct ReportList; struct Scene; struct ToolSettings; struct ViewLayer; @@ -193,6 +194,14 @@ bool ED_gpencil_anim_copybuf_paste(struct bAnimContext *ac, const short copy_mod int ED_gpencil_session_active(void); int ED_undo_gpencil_step(struct bContext *C, int step, const char *name); +/* ------------ Grease-Pencil Armature weights ------------------ */ +bool ED_gpencil_add_armature_weights(const struct bContext *C, struct ReportList *reports, + struct Object *ob, struct Object *ob_arm, int mode); + +/* keep this aligned with gpencil_armature enum */ +#define GP_PAR_ARMATURE_NAME 0 +#define GP_PAR_ARMATURE_AUTO 1 + /* ------------ Transformation Utilities ------------ */ /* get difference matrix */ diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index dec02faf85c..5601beb9228 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -113,7 +113,9 @@ DEF_ICON(FILE_TICK) DEF_ICON(QUIT) DEF_ICON(URL) DEF_ICON(RECOVER_LAST) -DEF_ICON(PRESET) +#ifndef DEF_ICON_BLANK_SKIP + DEF_ICON(BLANK030) +#endif DEF_ICON(FULLSCREEN_ENTER) DEF_ICON(FULLSCREEN_EXIT) DEF_ICON(BLANK1) // Not actually blank - this is used all over the place @@ -133,9 +135,9 @@ DEF_ICON(PARTICLES) DEF_ICON(PHYSICS) DEF_ICON(SPEAKER) DEF_ICON(TEXTURE_SHADED) +DEF_ICON(TOOL_SETTINGS) +DEF_ICON(SHADERFX) #ifndef DEF_ICON_BLANK_SKIP - DEF_ICON(BLANK042) - DEF_ICON(BLANK043) DEF_ICON(BLANK044) DEF_ICON(BLANK045) DEF_ICON(BLANK046) @@ -275,19 +277,22 @@ DEF_ICON(MOUSE_MOVE) DEF_ICON(MOUSE_LMB_DRAG) DEF_ICON(MOUSE_MMB_DRAG) DEF_ICON(MOUSE_RMB_DRAG) - #ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK099) - DEF_ICON(BLANK100) +#endif +DEF_ICON(PRESET) +#ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK101) - DEF_ICON(BLANK102) - DEF_ICON(BLANK103) - DEF_ICON(BLANK104) - DEF_ICON(BLANK105) - DEF_ICON(BLANK106) - DEF_ICON(BLANK107) - DEF_ICON(BLANK108) - DEF_ICON(BLANK109) +#endif +DEF_ICON(DECORATE) +DEF_ICON(DECORATE_KEYFRAME) +DEF_ICON(DECORATE_ANIMATE) +DEF_ICON(DECORATE_DRIVER) +DEF_ICON(DECORATE_LINKED) +DEF_ICON(DECORATE_OVERRIDE) +DEF_ICON(DECORATE_UNLOCKED) +DEF_ICON(DECORATE_LOCKED) +#ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK110) DEF_ICON(BLANK111) DEF_ICON(BLANK112) @@ -759,9 +764,7 @@ DEF_ICON(WIRE) DEF_ICON(SOLID) DEF_ICON(SMOOTH) DEF_ICON(POTATO) -#ifndef DEF_ICON_BLANK_SKIP - DEF_ICON(BLANK248) -#endif +DEF_ICON(OVERLAY) DEF_ICON(ORTHO) #ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK249) diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index cda70d405ad..d2a5ab80148 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -108,19 +108,19 @@ void ui_but_anim_decorate_update_from_flag(uiBut *but) BLI_assert(UI_but_is_decorator(but) && but->prev); int flag = but->prev->flag; if (flag & UI_BUT_DRIVEN) { - but->icon = ICON_AUTO; + but->icon = ICON_DECORATE_DRIVER; } else if (flag & UI_BUT_ANIMATED_KEY) { - but->icon = ICON_SPACE2; + but->icon = ICON_DECORATE_KEYFRAME; } else if (flag & UI_BUT_ANIMATED) { - but->icon = ICON_SPACE3; + but->icon = ICON_DECORATE_ANIMATE; } else if (flag & UI_BUT_OVERRIDEN) { - but->icon = ICON_LIBRARY_DATA_OVERRIDE; + but->icon = ICON_DECORATE_OVERRIDE; } else { - but->icon = ICON_DOT; + but->icon = ICON_DECORATE; } const int flag_copy = (UI_BUT_DISABLED | UI_BUT_INACTIVE); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 1972cc745ca..58e1545b336 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -143,6 +143,7 @@ enum { /* Show an icon button next to each property (to set keyframes, show status). * Enabled by default, depends on 'UI_ITEM_PROP_SEP'. */ UI_ITEM_PROP_DECORATE = 1 << 4, + UI_ITEM_PROP_DECORATE_NO_PAD = 1 << 5, }; typedef struct uiButtonItem { @@ -810,10 +811,16 @@ static uiBut *ui_item_with_label( x, y, prop_but_width, h); } +#ifdef UI_PROP_DECORATE /* Only for alignment. */ - if ((layout->item.flag & UI_ITEM_PROP_DECORATE) != 0) { - uiItemL(sub, NULL, ICON_BLANK1); + if (layout->item.flag & UI_ITEM_PROP_SEP) { + if ((layout->item.flag & UI_ITEM_PROP_DECORATE) && + (layout->item.flag & UI_ITEM_PROP_DECORATE_NO_PAD) == 0) + { + uiItemL(sub, NULL, ICON_BLANK1); + } } +#endif /* UI_PROP_DECORATE */ UI_block_layout_set_current(block, layout); return but; @@ -1515,8 +1522,6 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index #ifdef UI_PROP_DECORATE struct { bool use_prop_decorate; - /* For button types that handle own decorations (or add own padding for alignment). */ - bool use_prop_decorate_done; int len; uiLayout *layout; uiBut *but; @@ -1705,6 +1710,9 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index ui_decorate.layout->space = 0; UI_block_layout_set_current(block, layout); ui_decorate.but = block->buttons.last; + + /* Clear after. */ + layout->item.flag |= UI_ITEM_PROP_DECORATE_NO_PAD; } #endif /* UI_PROP_DECORATE */ } @@ -1736,11 +1744,6 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index if (layout->redalert) UI_but_flag_enable(but, UI_BUT_REDALERT); - -#ifdef UI_PROP_DECORATE - /* ui_item_with_label handles this. */ - ui_decorate.use_prop_decorate_done = true; -#endif } /* single button */ else { @@ -1762,10 +1765,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index } #ifdef UI_PROP_DECORATE - if (ui_decorate.use_prop_decorate_done) { - /* pass */ - } - else if (ui_decorate.use_prop_decorate) { + if (ui_decorate.use_prop_decorate) { const bool is_anim = RNA_property_animateable(ptr, prop); uiBut *but_decorate = ui_decorate.but ? ui_decorate.but->next : block->buttons.first; uiLayout *layout_col = uiLayoutColumn(ui_decorate.layout, false); @@ -1795,6 +1795,8 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index but_decorate = but->next; } BLI_assert(ELEM(i, 1, ui_decorate.len)); + + layout->item.flag &= ~UI_ITEM_PROP_DECORATE_NO_PAD; } #endif /* UI_PROP_DECORATE */ diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index ae0fe912f95..19b6ab91877 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1372,7 +1372,7 @@ void ED_operatortypes_ui(void) */ void ED_keymap_ui(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "User Interface", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "User Interface", 0, 0); wmKeyMapItem *kmi; /* eyedroppers - notice they all have the same shortcut, but pass the event diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index aa67d58fd57..cb5c104e638 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -134,7 +134,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar) return BUT_VERTICAL; else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) return BUT_VERTICAL; - else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) + else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS, RGN_TYPE_HUD)) return BUT_VERTICAL; return 0; @@ -1563,10 +1563,15 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in } } - if (align) + if (align) { panel_activate_state(C, block->panel, PANEL_STATE_ANIMATION); - else + } + else { + /* FIXME: this doesn't update the panel drawing, assert to avoid debugging why this is. + * We could fix this in the future if it's ever needed. */ + BLI_assert(0); ED_region_tag_redraw(ar); + } } else if (show_drag && BLI_rctf_isect_x(&rect_drag, mx)) { /* XXX, for now don't allow dragging in floating windows yet. */ diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 97f501b7448..ae6ab09a62a 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -67,6 +67,10 @@ #include "BLF_api.h" #include "BLT_translation.h" +#ifdef WITH_PYTHON +# include "BPY_extern.h" +#endif + #include "ED_screen.h" #include "interface_intern.h" @@ -306,13 +310,13 @@ static void ui_tooltip_region_free_cb(ARegion *ar) /** \name ToolTip Creation * \{ */ -static uiTooltipData *ui_tooltip_data_from_keymap(bContext *C, wmKeyMap *keymap) +static bool ui_tooltip_data_append_from_keymap( + bContext *C, uiTooltipData *data, + wmKeyMap *keymap) { + const int fields_len_init = data->fields_len; char buf[512]; - /* create tooltip data */ - uiTooltipData *data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { wmOperatorType *ot = WM_operatortype_find(kmi->idname, true); if (ot != NULL) { @@ -341,7 +345,7 @@ static uiTooltipData *ui_tooltip_data_from_keymap(bContext *C, wmKeyMap *keymap) } /* Python */ - { + if (U.flag & USER_TOOLTIPS_PYTHON) { uiTooltipField *field = text_field_add( data, &(uiTooltipFormat){ .style = UI_TIP_STYLE_NORMAL, @@ -354,6 +358,88 @@ static uiTooltipData *ui_tooltip_data_from_keymap(bContext *C, wmKeyMap *keymap) } } } + + return (fields_len_init != data->fields_len); +} + + +/** + * Special tool-system exception. + */ +static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but) +{ + if (but->optype == NULL) { + return NULL; + } + + if (!STREQ(but->optype->idname, "WM_OT_tool_set_by_name")) { + return NULL; + } + + char tool_name[MAX_NAME]; + RNA_string_get(but->opptr, "name", tool_name); + BLI_assert(tool_name[0] != '\0'); + + /* We have a tool, now extract the info. */ + uiTooltipData *data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); + +#ifdef WITH_PYTHON + /* it turns out to be most simple to do this via Python since C + * doesn't have access to information about non-active tools. + */ + char expr[256]; + + /* Tip */ + { + SNPRINTF( + expr, + "__import__('bl_ui').space_toolsystem_common.description_from_name(" + "__import__('bpy').context, " + "__import__('bpy').context.space_data.type, " + "'%s') + '.'", + tool_name); + + char *expr_result = NULL; + if (BPY_execute_string_as_string(C, expr, true, &expr_result)) { + if (!STREQ(expr_result, ".")) { + uiTooltipField *field = text_field_add( + data, &(uiTooltipFormat){ + .style = UI_TIP_STYLE_NORMAL, + .color_id = UI_TIP_LC_MAIN, + .is_pad = true, + }); + field->text = expr_result; + } + else { + MEM_freeN(expr_result); + } + } + } + + /* Keymap */ + + /* This is too handy not to expose somehow, let's be sneaky for now. */ + if (CTX_wm_window(C)->eventstate->shift) { + SNPRINTF( + expr, + "getattr(" + "__import__('bl_ui').space_toolsystem_common.keymap_from_name(" + "__import__('bpy').context, " + "__import__('bpy').context.space_data.type, " + "'%s'), " + "'as_pointer', lambda: 0)()", + tool_name); + + intptr_t expr_result = 0; + if (BPY_execute_string_as_intptr(C, expr, true, &expr_result)) { + if (expr_result != 0) { + wmKeyMap *keymap = (wmKeyMap *)expr_result; + ui_tooltip_data_append_from_keymap(C, data, keymap); + } + } + } +#endif /* WITH_PYTHON */ + if (data->fields_len == 0) { MEM_freeN(data); return NULL; @@ -894,31 +980,14 @@ ARegion *UI_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *b } uiTooltipData *data = NULL; - /* custom tips for pre-defined operators */ - if (but->optype) { - /* TODO(campbell): we now use 'WM_OT_tool_set_by_name', this logic will be moved into the status bar. */ - if (false && STREQ(but->optype->idname, "WM_OT_tool_set")) { - char keymap[64] = ""; - RNA_string_get(but->opptr, "keymap", keymap); - if (keymap[0]) { - ScrArea *sa = CTX_wm_area(C); - /* It happens in rare cases, for tooltips originated from the toolbar. - * It is hard to reproduce, but it happens when the mouse is nowhere near the actual tool. */ - if (sa == NULL) { - return NULL; - } - wmKeyMap *km = WM_keymap_find_all(C, keymap, sa->spacetype, RGN_TYPE_WINDOW); - if (km != NULL) { - data = ui_tooltip_data_from_keymap(C, km); - } - } - } + if (data == NULL) { + data = ui_tooltip_data_from_tool(C, but); } - /* toolsystem exception */ if (data == NULL) { data = ui_tooltip_data_from_button(C, but); } + if (data == NULL) { return NULL; } diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 1c56dabb396..f2411c1861a 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -2130,7 +2130,7 @@ void ED_operatortypes_view2d(void) void ED_keymap_view2d(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "View2D", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "View2D", 0, 0); wmKeyMapItem *kmi; /* scrollers */ @@ -2190,7 +2190,7 @@ void ED_keymap_view2d(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0); /* Alternative keymap for buttons listview */ - keymap = WM_keymap_find(keyconf, "View2D Buttons List", 0, 0); + keymap = WM_keymap_ensure(keyconf, "View2D Buttons List", 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", MIDDLEMOUSE, KM_PRESS, 0, 0); diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index 91fc1e9fe6a..8e446c73eab 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -22,6 +22,10 @@ * */ +/** \file blender/editors/io/io_alembic.c + * \ingroup editor/io + */ + #ifdef WITH_ALEMBIC /* needed for directory lookup */ diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c index 221142a6cf8..953dc24f6a5 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.c @@ -22,6 +22,10 @@ * */ +/** \file blender/editors/io/io_cache.c + * \ingroup editor/io + */ + #include "MEM_guardedalloc.h" #include "DNA_cachefile_types.h" diff --git a/source/blender/editors/lattice/lattice_ops.c b/source/blender/editors/lattice/lattice_ops.c index 593b880e501..2e6eafb0886 100644 --- a/source/blender/editors/lattice/lattice_ops.c +++ b/source/blender/editors/lattice/lattice_ops.c @@ -59,7 +59,7 @@ void ED_keymap_lattice(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap = WM_keymap_find(keyconf, "Lattice", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Lattice", 0, 0); keymap->poll = ED_operator_editlattice; kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 060778cefc9..d734f4fbb93 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -526,7 +526,7 @@ void ED_keymap_mask(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap = WM_keymap_find(keyconf, "Mask Editing", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Mask Editing", 0, 0); keymap->poll = ED_maskedit_poll; WM_keymap_add_item(keymap, "MASK_OT_new", NKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index bbdb0a904a9..280b8f91151 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -59,6 +59,7 @@ #include "ED_mesh.h" #include "ED_screen.h" +#include "ED_transform.h" #include "ED_select_utils.h" #include "ED_view3d.h" @@ -1753,9 +1754,13 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de ED_view3d_viewcontext_init_object(&vc, basact->object); em = vc.em; } + else { + em = NULL; + } + em_original->selectmode = selectmode; - if (eed == NULL) { + if (em == NULL || eed == NULL) { return false; } @@ -4330,70 +4335,112 @@ void MESH_OT_select_ungrouped(wmOperatorType *ot) /** \name Select Axis Operator * \{ */ -/* BMESH_TODO - some way to select on an arbitrary axis */ +enum { + SELECT_AXIS_POS = 0, + SELECT_AXIS_NEG = 1, + SELECT_AXIS_ALIGN = 2, +}; + static int edbm_select_axis_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); - BMesh *bm = em->bm; - BMVert *v_act = BM_mesh_active_vert_get(bm); + BMVert *v_act = BM_mesh_active_vert_get(em->bm); + const int orientation = RNA_enum_get(op->ptr, "orientation"); const int axis = RNA_enum_get(op->ptr, "axis"); - const int mode = RNA_enum_get(op->ptr, "mode"); /* -1 == aligned, 0 == neg, 1 == pos */ + const int sign = RNA_enum_get(op->ptr, "sign"); if (v_act == NULL) { BKE_report(op->reports, RPT_WARNING, "This operator requires an active vertex (last selected)"); return OPERATOR_CANCELLED; } - else { - BMVert *v; - BMIter iter; - const float limit = RNA_float_get(op->ptr, "threshold"); - float value = v_act->co[axis]; - if (mode == 0) - value -= limit; - else if (mode == 1) - value += limit; + const float limit = RNA_float_get(op->ptr, "threshold"); + + float value; + float axis_mat[3][3]; + + /* 3D view variables may be NULL, (no need to check in poll function). */ + ED_transform_calc_orientation_from_type_ex( + C, axis_mat, + scene, CTX_wm_view3d(C), CTX_wm_region_view3d(C), obedit, obedit, + orientation, V3D_AROUND_ACTIVE); + + const float *axis_vector = axis_mat[axis]; + + { + float vertex_world[3]; + mul_v3_m4v3(vertex_world, obedit->obmat, v_act->co); + value = dot_v3v3(axis_vector, vertex_world); + } + + if (sign == SELECT_AXIS_NEG) { + value += limit; + } + else if (sign == SELECT_AXIS_POS) { + value -= limit; + } + + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, &objects_len); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit_iter = objects[ob_index]; + BMEditMesh *em_iter = BKE_editmesh_from_object(obedit_iter); + BMesh *bm = em_iter->bm; + + if (bm->totvert == bm->totvertsel) { + continue; + } + + BMIter iter; + BMVert *v; + bool changed = false; BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) { - switch (mode) { - case -1: /* aligned */ - if (fabsf(v->co[axis] - value) < limit) + 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->obmat, v->co); + const float value_iter = dot_v3v3(axis_vector, v_iter_world); + switch (sign) { + case SELECT_AXIS_ALIGN: + if (fabsf(value_iter - value) < limit) { BM_vert_select_set(bm, v, true); + changed = true; + } break; - case 0: /* neg */ - if (v->co[axis] > value) + case SELECT_AXIS_NEG: + if (value_iter < value) { BM_vert_select_set(bm, v, true); + changed = true; + } break; - case 1: /* pos */ - if (v->co[axis] < value) + case SELECT_AXIS_POS: + if (value_iter > value) { BM_vert_select_set(bm, v, true); + changed = true; + } break; } } } + if (changed) { + EDBM_selectmode_flush(em_iter); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit_iter->data); + DEG_id_tag_update(obedit_iter->data, DEG_TAG_SELECT_UPDATE); + } } - - EDBM_selectmode_flush(em); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - + MEM_freeN(objects); return OPERATOR_FINISHED; } void MESH_OT_select_axis(wmOperatorType *ot) { - static const EnumPropertyItem axis_mode_items[] = { - {0, "POSITIVE", 0, "Positive Axis", ""}, - {1, "NEGATIVE", 0, "Negative Axis", ""}, - {-1, "ALIGNED", 0, "Aligned Axis", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem axis_items_xyz[] = { - {0, "X_AXIS", 0, "X Axis", ""}, - {1, "Y_AXIS", 0, "Y Axis", ""}, - {2, "Z_AXIS", 0, "Z Axis", ""}, + static const EnumPropertyItem axis_sign_items[] = { + {SELECT_AXIS_POS, "POS", 0, "Positive Axis", ""}, + {SELECT_AXIS_NEG, "NEG", 0, "Negative Axis", ""}, + {SELECT_AXIS_ALIGN, "ALIGN", 0, "Aligned Axis", ""}, {0, NULL, 0, NULL, NULL} }; @@ -4410,8 +4457,9 @@ void MESH_OT_select_axis(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "mode", axis_mode_items, 0, "Axis Mode", "Axis side to use when selecting"); - RNA_def_enum(ot->srna, "axis", axis_items_xyz, 0, "Axis", "Select the axis to compare each vertex on"); + RNA_def_enum(ot->srna, "orientation", rna_enum_transform_orientation_items, V3D_MANIP_LOCAL, "Axis Mode", "Axis orientation"); + RNA_def_enum(ot->srna, "sign", axis_sign_items, SELECT_AXIS_POS, "Axis Sign", "Side to select"); + RNA_def_enum(ot->srna, "axis", rna_enum_axis_xyz_items, 0, "Axis", "Select the axis to compare each vertex on"); RNA_def_float(ot->srna, "threshold", 0.0001f, 0.000001f, 50.0f, "Threshold", "", 0.00001f, 10.0f); } diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 07390cc4017..a318b3b78e5 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -328,7 +328,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap = WM_keymap_find(keyconf, "Mesh", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Mesh", 0, 0); keymap->poll = ED_operator_editmesh; kmi = WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0); @@ -475,7 +475,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) // WM_keymap_add_item(keymap, "MESH_OT_skin", FKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); /* python, removed */ WM_keymap_add_item(keymap, "MESH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_menu(keymap, "INFO_MT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_split", YKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 09d1b3a3ed8..97636b59143 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -73,7 +73,7 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap = WM_keymap_find(keyconf, "Metaball", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Metaball", 0, 0); keymap->poll = ED_operator_editmball; WM_keymap_add_item(keymap, "OBJECT_OT_metaball_add", AKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 41ff724275e..2e0a3ed62ce 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -48,11 +48,11 @@ set(SRC object_add.c object_bake.c object_bake_api.c + object_collection.c object_constraint.c object_data_transfer.c object_edit.c object_facemap_ops.c - object_group.c object_hook.c object_modes.c object_modifier.c diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index a03b167ef85..36944a53877 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -35,8 +35,8 @@ #include "DNA_anim_types.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" -#include "DNA_group_types.h" #include "DNA_lamp_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_collection.c index 72c5fde2955..8386b1fc520 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_collection.c @@ -25,7 +25,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_group.c +/** \file blender/editors/object/object_collection.c * \ingroup edobj */ @@ -35,7 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 5d0d715ea15..58ecd7fb472 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -46,9 +46,9 @@ #include "BLT_translation.h" #include "DNA_armature_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" #include "DNA_gpencil_types.h" -#include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_meta_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c index a561556bba0..25fe52ba279 100644 --- a/source/blender/editors/object/object_facemap_ops.c +++ b/source/blender/editors/object/object_facemap_ops.c @@ -24,6 +24,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/object/object_facemap_ops.c + * \ingroup edobj + */ + #include <string.h> #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index ad90b11a700..71cd7661d85 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -44,7 +44,7 @@ #include "DNA_scene_types.h" #include "DNA_rigidbody_types.h" #include "DNA_fracture_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "BLI_bitmap.h" #include "BLI_math.h" diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index a2c8b84dc0d..e4b63718846 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -315,7 +315,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* Objects, Regardless of Mode -------------------------------------------------- */ - keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Object Non-modal", 0, 0); /* modes */ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0); @@ -334,7 +334,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) /* Object Mode ---------------------------------------------------------------- */ /* Note: this keymap gets disabled in non-objectmode, */ - keymap = WM_keymap_find(keyconf, "Object Mode", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Object Mode", 0, 0); keymap->poll = object_mode_poll; /* object mode supports PET now */ @@ -409,7 +409,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "use_global", true); - WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); #ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "OBJECT_OT_duplicates_make_real", AKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 1f1aa301a63..0df08ae8192 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -37,8 +37,8 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_mesh_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" -#include "DNA_group_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" #include "DNA_material_types.h" @@ -110,6 +110,7 @@ #include "ED_armature.h" #include "ED_curve.h" +#include "ED_gpencil.h" #include "ED_keyframing.h" #include "ED_object.h" #include "ED_mesh.h" @@ -798,6 +799,23 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene, invert_m4_m4(ob->parentinv, workob.obmat); } + else if (pararm && (ob->type == OB_GPENCIL) && (par->type == OB_ARMATURE)) { + if (partype == PAR_ARMATURE_NAME) { + ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_NAME); + } + else if ((partype == PAR_ARMATURE_AUTO) || + (partype == PAR_ARMATURE_ENVELOPE)) + { + WM_cursor_wait(1); + ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_AUTO); + WM_cursor_wait(0); + } + /* get corrected inverse */ + ob->partype = PAROBJECT; + BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); + + invert_m4_m4(ob->parentinv, workob.obmat); + } else { /* calculate inverse parent matrix */ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 3ebec65da69..fc4934fe4b3 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -34,7 +34,7 @@ #include <string.h> #include "DNA_anim_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_material_types.h" #include "DNA_modifier_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index e516036d898..08b5d6adca2 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -39,7 +39,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_gpencil_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_lattice_types.h" #include "DNA_modifier_types.h" #include "DNA_fracture_types.h" diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index f73cdc30292..9c7c9fde066 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3764,7 +3764,8 @@ static void brush_add_count_iter( &min_d, &add_pars[iter].num_dmcache, add_pars[iter].fuv, - 0, 0, 0, 0)) { + 0, 0, 0, 0)) + { if (psys->part->use_modifier_stack && !psmd_eval->mesh_final->runtime.deformed_only) { add_pars[iter].num = add_pars[iter].num_dmcache; add_pars[iter].num_dmcache = DMCACHE_ISCHILD; @@ -4645,7 +4646,8 @@ int PE_minmax(Scene *scene, ViewLayer *view_layer, float min[3], float max[3]) static struct ParticleSystem *psys_eval_get( Depsgraph *depsgraph, Object *object, - ParticleSystem *psys){ + ParticleSystem *psys) +{ Object *object_eval = DEG_get_evaluated_object(depsgraph, object); if (object_eval == object) { return psys; diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 52358c1b528..736f7c48a10 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -115,7 +115,7 @@ static void keymap_particle(wmKeyConfig *keyconf) wmKeyMapItem *kmi; wmKeyMap *keymap; - keymap = WM_keymap_find(keyconf, "Particle", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Particle", 0, 0); keymap->poll = PE_poll; kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, 0, 0); @@ -209,7 +209,7 @@ static void operatortypes_dynamicpaint(void) //static void keymap_pointcache(wmWindowManager *wm) //{ -// wmKeyMap *keymap = WM_keymap_find(wm, "Pointcache", 0, 0); +// wmKeyMap *keymap = WM_keymap_ensure(wm, "Pointcache", 0, 0); // // WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0); // WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 8bb60b19dcf..0059d782eaf 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -51,7 +51,7 @@ #include "DNA_world_types.h" #include "DNA_camera_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index a031b9f50c7..4ad40807c8b 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1441,7 +1441,7 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand /* XXX it would be good to have boundbox checks for some of these... */ if (flag & ED_KEYMAP_UI) { - wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "User Interface", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "User Interface", 0, 0); WM_event_add_keymap_handler(handlers, keymap); /* user interface widgets */ @@ -1449,12 +1449,12 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand } if (flag & ED_KEYMAP_VIEW2D) { /* 2d-viewport handling+manipulation */ - wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "View2D", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "View2D", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } if (flag & ED_KEYMAP_MARKERS) { /* time-markers */ - wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Markers", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Markers", 0, 0); /* use a boundbox restricted map */ ARegion *ar; @@ -1468,12 +1468,12 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand } if (flag & ED_KEYMAP_ANIMATION) { /* frame changing and timeline operators (for time spaces) */ - wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Animation", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Animation", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } if (flag & ED_KEYMAP_FRAMES) { /* frame changing/jumping (for all spaces) */ - wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Frames", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Frames", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } if (flag & ED_KEYMAP_GPENCIL) { @@ -1484,30 +1484,30 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand * For now, it's easier to just include all, * since you hardly want one without the others. */ - wmKeyMap *keymap_general = WM_keymap_find(wm->defaultconf, "Grease Pencil", 0, 0); + wmKeyMap *keymap_general = WM_keymap_ensure(wm->defaultconf, "Grease Pencil", 0, 0); WM_event_add_keymap_handler(handlers, keymap_general); - wmKeyMap *keymap_edit = WM_keymap_find(wm->defaultconf, "Grease Pencil Stroke Edit Mode", 0, 0); + wmKeyMap *keymap_edit = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Edit Mode", 0, 0); WM_event_add_keymap_handler(handlers, keymap_edit); - wmKeyMap *keymap_paint = WM_keymap_find(wm->defaultconf, "Grease Pencil Stroke Paint Mode", 0, 0); + wmKeyMap *keymap_paint = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Paint Mode", 0, 0); WM_event_add_keymap_handler(handlers, keymap_paint); - wmKeyMap *keymap_paint_draw = WM_keymap_find(wm->defaultconf, "Grease Pencil Stroke Paint (Draw brush)", 0, 0); + wmKeyMap *keymap_paint_draw = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Paint (Draw brush)", 0, 0); WM_event_add_keymap_handler(handlers, keymap_paint_draw); - wmKeyMap *keymap_paint_erase = WM_keymap_find(wm->defaultconf, "Grease Pencil Stroke Paint (Erase)", 0, 0); + wmKeyMap *keymap_paint_erase = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Paint (Erase)", 0, 0); WM_event_add_keymap_handler(handlers, keymap_paint_erase); - wmKeyMap *keymap_paint_fill = WM_keymap_find(wm->defaultconf, "Grease Pencil Stroke Paint (Fill)", 0, 0); + wmKeyMap *keymap_paint_fill = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Paint (Fill)", 0, 0); WM_event_add_keymap_handler(handlers, keymap_paint_fill); - wmKeyMap *keymap_sculpt = WM_keymap_find(wm->defaultconf, "Grease Pencil Stroke Sculpt Mode", 0, 0); + wmKeyMap *keymap_sculpt = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Sculpt Mode", 0, 0); WM_event_add_keymap_handler(handlers, keymap_sculpt); } if (flag & ED_KEYMAP_HEADER) { /* standard keymap for headers regions */ - wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Header", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Header", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } } @@ -2307,7 +2307,7 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy); - keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 0550afda342..4acffb6eca7 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4861,7 +4861,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* Screen Editing ------------------------------------------------ */ - keymap = WM_keymap_find(keyconf, "Screen Editing", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Screen Editing", 0, 0); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "modifier", 0); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "modifier", 1); @@ -4886,12 +4886,12 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* Header Editing ------------------------------------------------ */ /* note: this is only used when the cursor is inside the header */ - keymap = WM_keymap_find(keyconf, "Header", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Header", 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_header_context_menu", RIGHTMOUSE, KM_PRESS, 0, 0); /* Screen General ------------------------------------------------ */ - keymap = WM_keymap_find(keyconf, "Screen", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Screen", 0, 0); /* standard timers */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0); @@ -4970,7 +4970,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* Anim Playback ------------------------------------------------ */ - keymap = WM_keymap_find(keyconf, "Frames", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Frames", 0, 0); /* frame offsets */ #ifdef USE_WM_KEYMAP_27X @@ -5023,7 +5023,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* Alternative keys for animation and sequencer playing */ #if 0 /* XXX: disabled for restoring later... bad implementation */ - keymap = WM_keymap_find(keyconf, "Frames", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Frames", 0, 0); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "cycle_speed", true); diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 246d2fed1a1..77fc20a98a5 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -172,24 +172,29 @@ bool ED_workspace_change( screen_new = screen_change_prepare(screen_old, screen_new, bmain, C, win); BLI_assert(BKE_workspace_layout_screen_get(layout_new) == screen_new); - if (screen_new) { - BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace_new, layout_new); - BKE_workspace_active_set(win->workspace_hook, workspace_new); + if (screen_new == NULL) { + return false; + } - /* update screen *after* changing workspace - which also causes the - * actual screen change and updates context (including CTX_wm_workspace) */ - screen_change_update(C, win, screen_new); - workspace_change_update(workspace_new, workspace_old, C, wm); + BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace_new, layout_new); + BKE_workspace_active_set(win->workspace_hook, workspace_new); - BLI_assert(CTX_wm_workspace(C) == workspace_new); + /* update screen *after* changing workspace - which also causes the + * actual screen change and updates context (including CTX_wm_workspace) */ + screen_change_update(C, win, screen_new); + workspace_change_update(workspace_new, workspace_old, C, wm); - WM_toolsystem_unlink_all(C, workspace_old); - WM_toolsystem_reinit_all(C, win); + BLI_assert(CTX_wm_workspace(C) == workspace_new); - return true; + WM_toolsystem_unlink_all(C, workspace_old); + WM_toolsystem_reinit_all(C, win); + + /* Automatic mode switching. */ + if (workspace_new->object_mode != workspace_old->object_mode) { + ED_object_mode_generic_enter(C, workspace_new->object_mode); } - return false; + return true; } /** diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 359c93175b4..05be3db635f 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -1297,13 +1297,13 @@ void ED_keymap_paint(wmKeyConfig *keyconf) wmKeyMapItem *kmi; int i; - keymap = WM_keymap_find(keyconf, "Paint Curve", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Paint Curve", 0, 0); keymap->poll = paint_curve_poll; paint_keymap_curve(keymap); /* Sculpt mode */ - keymap = WM_keymap_find(keyconf, "Sculpt", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Sculpt", 0, 0); keymap->poll = sculpt_mode_poll; RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); @@ -1378,7 +1378,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_angle_control", RKEY, KM_PRESS, 0, 0); /* Vertex Paint mode */ - keymap = WM_keymap_find(keyconf, "Vertex Paint", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Vertex Paint", 0, 0); keymap->poll = vertex_paint_mode_poll; WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0); @@ -1404,7 +1404,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "tool_settings.vertex_paint.brush.stroke_method"); /* Weight Paint mode */ - keymap = WM_keymap_find(keyconf, "Weight Paint", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Weight Paint", 0, 0); keymap->poll = weight_paint_mode_poll; WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0); @@ -1435,7 +1435,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "tool_settings.weight_paint.brush.use_smooth_stroke"); /*Weight paint's Vertex Selection Mode */ - keymap = WM_keymap_find(keyconf, "Weight Paint Vertex Selection", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Weight Paint Vertex Selection", 0, 0); keymap->poll = vert_paint_poll; kmi = WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_SELECT); @@ -1451,7 +1451,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0); /* Image/Texture Paint mode */ - keymap = WM_keymap_find(keyconf, "Image Paint", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Image Paint", 0, 0); keymap->poll = image_texture_paint_poll; RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); @@ -1479,7 +1479,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "tool_settings.image_paint.brush.stroke_method"); /* face-mask mode */ - keymap = WM_keymap_find(keyconf, "Face Mask", 0, 0); + keymap = WM_keymap_ensure(keyconf, "Face Mask", 0, 0); keymap->poll = facemask_paint_poll; kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, 0, 0); @@ -1500,7 +1500,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "deselect", true); - keymap = WM_keymap_find(keyconf, "UV Sculpt", 0, 0); + keymap = WM_keymap_ensure(keyconf, "UV Sculpt", 0, 0); keymap->poll = uv_sculpt_keymap_poll; kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index a53561f814d..4976ffa3fc3 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -281,7 +281,7 @@ void action_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap; /* keymap for all regions */ - keymap = WM_keymap_find(keyconf, "Dopesheet Generic", SPACE_ACTION, 0); + keymap = WM_keymap_ensure(keyconf, "Dopesheet Generic", SPACE_ACTION, 0); /* region management... */ WM_keymap_add_item(keymap, "ACTION_OT_properties", NKEY, KM_PRESS, 0, 0); @@ -294,6 +294,6 @@ void action_keymap(wmKeyConfig *keyconf) */ /* keyframes */ - keymap = WM_keymap_find(keyconf, "Dopesheet", SPACE_ACTION, 0); + keymap = WM_keymap_ensure(keyconf, "Dopesheet", SPACE_ACTION, 0); action_keymap_keyframes(keyconf, keymap); } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 363c30427db..3e8e92d814d 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -33,7 +33,7 @@ #include <stdio.h> #include "DNA_action_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -205,9 +205,9 @@ static void action_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -296,12 +296,12 @@ static void action_channel_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); WM_keymap_add_menu(keymap, "DOPESHEET_MT_specials_channels", WKEY, KM_PRESS, 0, 0); - keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -749,7 +749,7 @@ static void action_buttons_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 986a1fc7bf2..bbd36ce6d7d 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -39,7 +39,7 @@ #include "BLT_translation.h" #include "DNA_armature_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" @@ -59,7 +59,6 @@ #include "BKE_screen.h" #include "BKE_texture.h" #include "BKE_linestyle.h" -#include "BKE_workspace.h" #include "RNA_access.h" @@ -188,14 +187,6 @@ static int buttons_context_path_linestyle(ButsContextPath *path, wmWindow *windo return 0; } -static int buttons_context_path_workspace(ButsContextPath *path) -{ - PointerRNA *ptr = &path->ptr[path->len - 1]; - - /* This one just verifies. */ - return RNA_struct_is_a(ptr->type, &RNA_WorkSpace); -} - static int buttons_context_path_object(ButsContextPath *path) { PointerRNA *ptr = &path->ptr[path->len - 1]; @@ -497,7 +488,6 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); wmWindow *window = CTX_wm_window(C); - WorkSpace *workspace = CTX_wm_workspace(C); ID *id; int found; Object *ob = CTX_data_active_object(C); @@ -513,19 +503,13 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma path->len++; } /* No pinned root, use scene as initial root. */ - else { - if (ELEM(mainb, BCONTEXT_WORKSPACE, BCONTEXT_TOOL)) { - RNA_id_pointer_create(&workspace->id, &path->ptr[0]); - path->len++; - } - else { - RNA_id_pointer_create(&scene->id, &path->ptr[0]); - path->len++; + else if (mainb != BCONTEXT_TOOL) { + RNA_id_pointer_create(&scene->id, &path->ptr[0]); + path->len++; - if (!ELEM(mainb, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD)) { - RNA_pointer_create(NULL, &RNA_ViewLayer, view_layer, &path->ptr[path->len]); - path->len++; - } + if (!ELEM(mainb, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD)) { + RNA_pointer_create(NULL, &RNA_ViewLayer, view_layer, &path->ptr[path->len]); + path->len++; } } @@ -551,8 +535,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found = buttons_context_path_world(path); break; case BCONTEXT_TOOL: - case BCONTEXT_WORKSPACE: - found = buttons_context_path_workspace(path); + found = true; break; case BCONTEXT_OBJECT: case BCONTEXT_PHYSICS: @@ -1075,7 +1058,13 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) } } -static void buttons_panel_context(const bContext *C, Panel *pa) +static bool buttons_panel_context_poll(const bContext *C, PanelType *UNUSED(pt)) +{ + SpaceButs *sbuts = CTX_wm_space_buts(C); + return (sbuts->mainb != BCONTEXT_TOOL); +} + +static void buttons_panel_context_draw(const bContext *C, Panel *pa) { buttons_context_draw(C, pa->layout); } @@ -1088,7 +1077,8 @@ void buttons_context_register(ARegionType *art) strcpy(pt->idname, "BUTTONS_PT_context"); strcpy(pt->label, N_("Context")); /* XXX C panels are not available through RNA (bpy.types)! */ strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); - pt->draw = buttons_panel_context; + pt->poll = buttons_panel_context_poll; + pt->draw = buttons_panel_context_draw; pt->flag = PNL_NO_HEADER; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 0350e3fcd14..56d70d10a96 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -130,7 +130,7 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "Property Editor", SPACE_BUTS, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Property Editor", SPACE_BUTS, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -153,9 +153,6 @@ static void buttons_main_region_layout_properties(const bContext *C, SpaceButs * case BCONTEXT_WORLD: contexts[0] = "world"; break; - case BCONTEXT_WORKSPACE: - contexts[0] = "workspace"; - break; case BCONTEXT_OBJECT: contexts[0] = "object"; break; @@ -200,11 +197,13 @@ static void buttons_main_region_layout_properties(const bContext *C, SpaceButs * static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar) { - const char *contexts[3] = {NULL}; - const WorkSpace *workspace = CTX_wm_workspace(C); const int mode = CTX_data_mode_enum(C); + const char *contexts_base[5] = {NULL}; + contexts_base[0] = ".active_tool"; + const char **contexts = &contexts_base[1]; + if (workspace->tools_space_type == SPACE_VIEW3D) { switch (mode) { case CTX_MODE_EDIT_MESH: @@ -282,8 +281,15 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar) break; } + int i = 0; + while (contexts_base[i]) { + i++; + } + BLI_assert(i < ARRAY_SIZE(contexts_base)); + contexts_base[i] = ".workspace"; + const bool vertical = true; - ED_region_panels_layout_ex(C, ar, contexts, -1, vertical); + ED_region_panels_layout_ex(C, ar, contexts_base, -1, vertical); } static void buttons_main_region_layout(const bContext *C, ARegion *ar) @@ -324,7 +330,7 @@ static void buttons_operatortypes(void) static void buttons_keymap(struct wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Property Editor", SPACE_BUTS, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Property Editor", SPACE_BUTS, 0); WM_keymap_add_item(keymap, "BUTTONS_OT_context_menu", RIGHTMOUSE, KM_PRESS, 0, 0); } @@ -365,6 +371,10 @@ static void buttons_header_region_message_subscribe( if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_WORLD)) { WM_msg_subscribe_rna_anon_prop(mbus, ViewLayer, name, &msg_sub_value_region_tag_redraw); } + + if (sbuts->mainb == BCONTEXT_TOOL) { + WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw); + } } /* draw a certain button set only if properties area is currently diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 79e1dc35245..bee266285d3 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -543,7 +543,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) /* ******** Global hotkeys avalaible for all regions ******** */ - keymap = WM_keymap_find(keyconf, "Clip", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(keyconf, "Clip", SPACE_CLIP, 0); WM_keymap_add_item(keymap, "CLIP_OT_open", OKEY, KM_PRESS, KM_ALT, 0); @@ -583,7 +583,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) /* ******** Hotkeys avalaible for main region only ******** */ - keymap = WM_keymap_find(keyconf, "Clip Editor", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(keyconf, "Clip Editor", SPACE_CLIP, 0); // keymap->poll = ED_space_clip_tracking_poll; /* ** View/navigation ** */ @@ -754,7 +754,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) /* ******** Hotkeys avalaible for preview region only ******** */ - keymap = WM_keymap_find(keyconf, "Clip Graph Editor", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(keyconf, "Clip Graph Editor", SPACE_CLIP, 0); /* "timeline" */ WM_keymap_add_item(keymap, "CLIP_OT_change_frame", ACTIONMOUSE, KM_PRESS, 0, 0); @@ -810,7 +810,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) /* ******** Hotkeys avalaible for channels region only ******** */ - keymap = WM_keymap_find(keyconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(keyconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); kmi = WM_keymap_add_item(keymap, "CLIP_OT_dopesheet_select_channel", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", true); /* toggle */ @@ -1109,14 +1109,14 @@ static void clip_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); /* mask polls mode */ - keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "Clip Editor", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Clip Editor", SPACE_CLIP, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -1235,13 +1235,13 @@ static void clip_preview_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "Clip Graph Editor", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Clip Graph Editor", SPACE_CLIP, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -1359,7 +1359,7 @@ static void clip_channels_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - keymap = WM_keymap_find(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -1435,7 +1435,7 @@ static void clip_tools_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -1480,7 +1480,7 @@ static void clip_properties_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 3429d726349..a5e9f6cf641 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -146,7 +146,7 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *ar) } /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Console", SPACE_CONSOLE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* add drop boxes */ @@ -265,7 +265,7 @@ static void console_operatortypes(void) static void console_keymap(struct wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Console", SPACE_CONSOLE, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Console", SPACE_CONSOLE, 0); wmKeyMapItem *kmi; #ifdef __APPLE__ diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index cb21659dbb8..d1847956c13 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -330,10 +330,10 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymaps */ - keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "File Browser Main", SPACE_FILE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Main", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -491,7 +491,7 @@ static void file_keymap(struct wmKeyConfig *keyconf) { wmKeyMapItem *kmi; /* keys for all regions */ - wmKeyMap *keymap = WM_keymap_find(keyconf, "File Browser", SPACE_FILE, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "File Browser", SPACE_FILE, 0); /* More common 'fliebrowser-like navigation' shortcuts. */ WM_keymap_add_item(keymap, "FILE_OT_parent", UPARROWKEY, KM_PRESS, KM_ALT, 0); @@ -515,7 +515,7 @@ static void file_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "FILE_OT_bookmark_add", BKEY, KM_PRESS, KM_CTRL, 0); /* keys for main region */ - keymap = WM_keymap_find(keyconf, "File Browser Main", SPACE_FILE, 0); + keymap = WM_keymap_ensure(keyconf, "File Browser Main", SPACE_FILE, 0); kmi = WM_keymap_add_item(keymap, "FILE_OT_execute", LEFTMOUSE, KM_DBL_CLICK, 0, 0); RNA_boolean_set(kmi->ptr, "need_active", true); @@ -607,7 +607,7 @@ static void file_keymap(struct wmKeyConfig *keyconf) /* keys for button region (top) */ - keymap = WM_keymap_find(keyconf, "File Browser Buttons", SPACE_FILE, 0); + keymap = WM_keymap_ensure(keyconf, "File Browser Buttons", SPACE_FILE, 0); kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); RNA_int_set(kmi->ptr, "increment", 1); kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0); @@ -631,7 +631,7 @@ static void file_tools_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); /* own keymaps */ - keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -659,7 +659,7 @@ static void file_header_region_init(wmWindowManager *wm, ARegion *ar) ED_region_header_init(ar); - keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -676,10 +676,10 @@ static void file_ui_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "File Browser Buttons", SPACE_FILE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Buttons", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index d796c9be3b6..8699bb595fa 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -693,7 +693,7 @@ void graphedit_keymap(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* keymap for all regions */ - keymap = WM_keymap_find(keyconf, "Graph Editor Generic", SPACE_IPO, 0); + keymap = WM_keymap_ensure(keyconf, "Graph Editor Generic", SPACE_IPO, 0); WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0); /* extrapolation works on channels, not keys */ @@ -719,6 +719,6 @@ void graphedit_keymap(wmKeyConfig *keyconf) */ /* keyframes */ - keymap = WM_keymap_find(keyconf, "Graph Editor", SPACE_IPO, 0); + keymap = WM_keymap_ensure(keyconf, "Graph Editor", SPACE_IPO, 0); graphedit_keymap_keyframes(keyconf, keymap); } diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index fa57df0393a..6a921eede4a 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -33,7 +33,7 @@ #include <stdio.h> #include "DNA_anim_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -222,9 +222,9 @@ static void graph_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Graph Editor", SPACE_IPO, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor", SPACE_IPO, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -368,9 +368,9 @@ static void graph_channel_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -420,7 +420,7 @@ static void graph_buttons_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index f46b5893dde..1b7851eede7 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -293,7 +293,7 @@ static void image_operatortypes(void) static void image_keymap(struct wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Image Generic", SPACE_IMAGE, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Image Generic", SPACE_IMAGE, 0); wmKeyMapItem *kmi; int i; @@ -311,7 +311,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, KM_ALT, 0)->ptr, "reverse", true); - keymap = WM_keymap_find(keyconf, "Image", SPACE_IMAGE, 0); + keymap = WM_keymap_ensure(keyconf, "Image", SPACE_IMAGE, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); @@ -678,29 +678,29 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar) WM_gizmomap_add_handlers(ar, ar->gizmo_map); /* mask polls mode */ - keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* image paint polls for mode */ - keymap = WM_keymap_find(wm->defaultconf, "Curve", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Curve", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "Paint Curve", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Image Paint", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "UV Editor", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "UV Editor", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "UV Sculpt", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "UV Sculpt", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); /* own keymaps */ - keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Image", SPACE_IMAGE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Image", SPACE_IMAGE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -868,7 +868,7 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *ar) ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -922,7 +922,7 @@ static void image_tools_region_init(wmWindowManager *wm, ARegion *ar) ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index fdf9d6df374..b9814e97dfc 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -31,9 +31,9 @@ #include "MEM_guardedalloc.h" #include "DNA_armature_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" #include "DNA_gpencil_types.h" -#include "DNA_group_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 7f4d2a7f6c7..abc953507e0 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -137,7 +137,7 @@ static void info_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Info", SPACE_INFO, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Info", SPACE_INFO, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -207,12 +207,12 @@ static void info_operatortypes(void) static void info_keymap(struct wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Window", 0, 0); WM_keymap_verify_item(keymap, "INFO_OT_reports_display_update", TIMERREPORT, KM_ANY, KM_ANY, 0); /* info space */ - keymap = WM_keymap_find(keyconf, "Info", SPACE_INFO, 0); + keymap = WM_keymap_ensure(keyconf, "Info", SPACE_INFO, 0); /* report selection */ @@ -306,35 +306,6 @@ static void info_header_region_message_subscribe( WM_msg_subscribe_rna_anon_prop(mbus, ViewLayer, name, &msg_sub_value_region_tag_redraw); } -static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu) -{ - struct RecentFile *recent; - uiLayout *layout = menu->layout; - uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); - if (!BLI_listbase_is_empty(&G.recent_files)) { - for (recent = G.recent_files.first; (recent); recent = recent->next) { - const char *file = BLI_path_basename(recent->filepath); - const int icon = BLO_has_bfile_extension(file) ? ICON_FILE_BLEND : ICON_FILE_BACKUP; - uiItemStringO(layout, file, icon, "WM_OT_open_mainfile", "filepath", recent->filepath); - } - } - else { - uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE); - } -} - -static void recent_files_menu_register(void) -{ - MenuType *mt; - - mt = MEM_callocN(sizeof(MenuType), "spacetype info menu recent files"); - strcpy(mt->idname, "INFO_MT_file_open_recent"); - strcpy(mt->label, N_("Open Recent...")); - strcpy(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); - mt->draw = recent_files_menu_draw; - WM_menutype_add(mt); -} - /* only called once, from space/spacetypes.c */ void ED_spacetype_info(void) { @@ -375,7 +346,5 @@ void ED_spacetype_info(void) BLI_addhead(&st->regiontypes, art); - recent_files_menu_register(); - BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c new file mode 100644 index 00000000000..6d484b4cb4c --- /dev/null +++ b/source/blender/editors/space_logic/space_logic.c @@ -0,0 +1,373 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_logic/space_logic.c + * \ingroup splogic + */ + + +#include <string.h> +#include <stdio.h> + + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "DNA_gpencil_types.h" + +#include "BKE_context.h" +#include "BKE_library.h" +#include "BKE_screen.h" + +#include "ED_space_api.h" +#include "ED_screen.h" + +#include "BIF_gl.h" + + +#include "WM_api.h" +#include "WM_types.h" + +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "logic_intern.h" + +/* ******************** manage regions ********************* */ + +ARegion *logic_has_buttons_region(ScrArea *sa) +{ + ARegion *ar, *arnew; + + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); + if (ar) return ar; + + /* add subdiv level; after header */ + ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + + /* is error! */ + if (ar == NULL) return NULL; + + arnew= MEM_callocN(sizeof(ARegion), "buttons for image"); + + BLI_insertlinkafter(&sa->regionbase, ar, arnew); + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; + + arnew->flag = RGN_FLAG_HIDDEN; + + return arnew; +} + +/* ******************** default callbacks for image space ***************** */ + +static SpaceLink *logic_new(const bContext *C) +{ + ScrArea *sa= CTX_wm_area(C); + ARegion *ar; + SpaceLogic *slogic; + + slogic= MEM_callocN(sizeof(SpaceLogic), "initlogic"); + slogic->spacetype= SPACE_LOGIC; + + /* default options */ + slogic->scaflag = ((BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_SENS_LINK) | + (BUTS_CONT_SEL|BUTS_CONT_ACT|BUTS_CONT_LINK) | + (BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_ACT_LINK) | + (BUTS_SENS_STATE|BUTS_ACT_STATE)); + + + /* header */ + ar= MEM_callocN(sizeof(ARegion), "header for logic"); + + BLI_addtail(&slogic->regionbase, ar); + ar->regiontype= RGN_TYPE_HEADER; + ar->alignment= RGN_ALIGN_BOTTOM; + + /* buttons/list view */ + ar= MEM_callocN(sizeof(ARegion), "buttons for logic"); + + BLI_addtail(&slogic->regionbase, ar); + ar->regiontype= RGN_TYPE_UI; + ar->alignment= RGN_ALIGN_RIGHT; + + /* main region */ + ar= MEM_callocN(sizeof(ARegion), "main region for logic"); + + BLI_addtail(&slogic->regionbase, ar); + ar->regiontype= RGN_TYPE_WINDOW; + + ar->v2d.tot.xmin = 0.0f; + ar->v2d.tot.ymax = 0.0f; + ar->v2d.tot.xmax = 1150.0f; + ar->v2d.tot.ymin = ( 1150.0f/(float)sa->winx ) * (float)-sa->winy; + + ar->v2d.cur = ar->v2d.tot; + + ar->v2d.min[0] = 1.0f; + ar->v2d.min[1] = 1.0f; + + ar->v2d.max[0] = 32000.0f; + ar->v2d.max[1] = 32000.0f; + + ar->v2d.minzoom = 0.5f; + ar->v2d.maxzoom = 1.5f; + + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom = V2D_KEEPZOOM | V2D_LIMITZOOM | V2D_KEEPASPECT; + ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS; + ar->v2d.align = V2D_ALIGN_NO_POS_Y | V2D_ALIGN_NO_NEG_X; + ar->v2d.keepofs = V2D_KEEPOFS_Y; + + return (SpaceLink *)slogic; +} + +/* not spacelink itself */ +static void logic_free(SpaceLink *UNUSED(sl)) +{ +// Spacelogic *slogic= (SpaceLogic *) sl; + +// if (slogic->gpd) +// XXX BKE_gpencil_free(slogic->gpd); + +} + + +/* spacetype; init callback */ +static void logic_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +{ + +} + +static SpaceLink *logic_duplicate(SpaceLink *sl) +{ + SpaceLogic *slogicn= MEM_dupallocN(sl); + + return (SpaceLink *)slogicn; +} + +static void logic_operatortypes(void) +{ + WM_operatortype_append(LOGIC_OT_properties); + WM_operatortype_append(LOGIC_OT_links_cut); +} + +static void logic_keymap(struct wmKeyConfig *keyconf) +{ + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Logic Editor", SPACE_LOGIC, 0); + + WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "LOGIC_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0); + + WM_keymap_add_item(keymap, "LOGIC_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF + WM_keymap_add_item(keymap, "LOGIC_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif +} + +static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa)) +{ +// SpaceLogic *slogic= CTX_wm_space_logic(C); +// Object *obedit= CTX_data_edit_object(C); + +} + +static void logic_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch (wmn->category) { + case NC_LOGIC: + ED_region_tag_redraw(ar); + break; + case NC_SCENE: + switch (wmn->data) { + case ND_FRAME: + ED_region_tag_redraw(ar); + break; + + case ND_OB_ACTIVE: + ED_region_tag_redraw(ar); + break; + } + break; + case NC_OBJECT: + break; + case NC_ID: + if (wmn->action == NA_RENAME) + ED_region_tag_redraw(ar); + break; + } +} + +static int logic_context(const bContext *UNUSED(C), const char *UNUSED(member), bContextDataResult *UNUSED(result)) +{ +// SpaceLogic *slogic= CTX_wm_space_logic(C); + return 0; +} + +/************************** main region ***************************/ + + +/* add handlers, stuff you only do once or on area/region changes */ +static void logic_main_region_init(wmWindowManager *wm, ARegion *ar) +{ + wmKeyMap *keymap; + + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); + + /* own keymaps */ + keymap = WM_keymap_ensure(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); +} + +static void logic_main_region_draw(const bContext *C, ARegion *ar) +{ + /* draw entirely, view changes should be handled here */ +// SpaceLogic *slogic= CTX_wm_space_logic(C); + View2D *v2d= &ar->v2d; + View2DScrollers *scrollers; + + /* clear and setup matrix */ + UI_ThemeClearColor(TH_BACK); + glClear(GL_COLOR_BUFFER_BIT); + + UI_view2d_view_ortho(v2d); + + logic_buttons((bContext *)C, ar); + + /* reset view matrix */ + UI_view2d_view_restore(C); + + /* scrollers */ + scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + UI_view2d_scrollers_draw(C, v2d, scrollers); + UI_view2d_scrollers_free(scrollers); + +} + + +/* *********************** buttons region ************************ */ + +/* add handlers, stuff you only do once or on area/region changes */ +static void logic_buttons_region_init(wmWindowManager *wm, ARegion *ar) +{ + wmKeyMap *keymap; + + ED_region_panels_init(wm, ar); + + keymap = WM_keymap_ensure(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); +} + +static void logic_buttons_region_draw(const bContext *C, ARegion *ar) +{ + ED_region_panels(C, ar, NULL, -1, true); +} + +/************************* header region **************************/ + +/* add handlers, stuff you only do once or on area/region changes */ +static void logic_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar) +{ + ED_region_header_init(ar); +} + +static void logic_header_region_draw(const bContext *C, ARegion *ar) +{ + ED_region_header(C, ar); +} + +/**************************** spacetype *****************************/ + +static void logic_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) +{ + SpaceLogic *slog = (SpaceLogic *)slink; + + if (!ELEM(GS(old_id->name), ID_GD)) { + return; + } + + if ((ID *)slog->gpd == old_id) { + slog->gpd = (bGPdata *)new_id; + id_us_min(old_id); + id_us_plus(new_id); + } +} + +/* only called once, from space/spacetypes.c */ +void ED_spacetype_logic(void) +{ + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype logic"); + ARegionType *art; + + st->spaceid = SPACE_LOGIC; + strncpy(st->name, "Logic", BKE_ST_MAXNAME); + + st->new = logic_new; + st->free = logic_free; + st->init = logic_init; + st->duplicate = logic_duplicate; + st->operatortypes = logic_operatortypes; + st->keymap = logic_keymap; + st->refresh = logic_refresh; + st->context = logic_context; + st->id_remap = logic_id_remap; + + /* regions: main window */ + art = MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art->regionid = RGN_TYPE_WINDOW; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES | ED_KEYMAP_VIEW2D; + art->init = logic_main_region_init; + art->draw = logic_main_region_draw; + art->listener = logic_listener; + + BLI_addhead(&st->regiontypes, art); + + /* regions: listview/buttons */ + art = MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art->regionid = RGN_TYPE_UI; + art->prefsizex= 220; // XXX + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; + art->listener = logic_listener; + art->init = logic_buttons_region_init; + art->draw = logic_buttons_region_draw; + BLI_addhead(&st->regiontypes, art); + + /* regions: header */ + art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art->regionid = RGN_TYPE_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; + art->init = logic_header_region_init; + art->draw = logic_header_region_draw; + + BLI_addhead(&st->regiontypes, art); + + BKE_spacetype_register(st); +} diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 53a9c8a0dd2..53e9321b2e8 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -314,7 +314,7 @@ void nla_keymap(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* keymap for all regions ------------------------------------------- */ - keymap = WM_keymap_find(keyconf, "NLA Generic", SPACE_NLA, 0); + keymap = WM_keymap_ensure(keyconf, "NLA Generic", SPACE_NLA, 0); /* region management */ WM_keymap_add_item(keymap, "NLA_OT_properties", NKEY, KM_PRESS, 0, 0); @@ -346,10 +346,10 @@ void nla_keymap(wmKeyConfig *keyconf) * * However, those operations which involve clicking on channels and/or the placement of them in the view are implemented here instead */ - keymap = WM_keymap_find(keyconf, "NLA Channels", SPACE_NLA, 0); + keymap = WM_keymap_ensure(keyconf, "NLA Channels", SPACE_NLA, 0); nla_keymap_channels(keymap); /* data ------------------------------------------------------------- */ - keymap = WM_keymap_find(keyconf, "NLA Editor", SPACE_NLA, 0); + keymap = WM_keymap_ensure(keyconf, "NLA Editor", SPACE_NLA, 0); nla_keymap_main(keyconf, keymap); } diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 6633dbdf08e..bf9aa090b94 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -33,7 +33,7 @@ #include <stdio.h> #include "DNA_anim_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -214,13 +214,13 @@ static void nla_channel_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ /* own channels map first to override some channel keymaps */ - keymap = WM_keymap_find(wm->defaultconf, "NLA Channels", SPACE_NLA, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "NLA Channels", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* now generic channels map for everything else that can apply */ - keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -260,9 +260,9 @@ static void nla_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "NLA Editor", SPACE_NLA, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "NLA Editor", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -355,7 +355,7 @@ static void nla_buttons_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 142d6fdc237..759b157b3f8 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -231,13 +231,13 @@ void node_keymap(struct wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* Entire Editor only ----------------- */ - keymap = WM_keymap_find(keyconf, "Node Generic", SPACE_NODE, 0); + keymap = WM_keymap_ensure(keyconf, "Node Generic", SPACE_NODE, 0); WM_keymap_add_item(keymap, "NODE_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_toolbar", TKEY, KM_PRESS, 0, 0); /* Main Region only ----------------- */ - keymap = WM_keymap_find(keyconf, "Node Editor", SPACE_NODE, 0); + keymap = WM_keymap_ensure(keyconf, "Node Editor", SPACE_NODE, 0); /* mouse select in nodes used to be both keys, but perhaps this should be reduced? * NOTE: mouse-clicks on left-mouse will fall through to allow transform-tweak, but also link/resize diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 51ba3a62d1b..38bc1b6da8d 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -596,7 +596,7 @@ static void node_buttons_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Node Generic", SPACE_NODE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -612,7 +612,7 @@ static void node_toolbar_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Node Generic", SPACE_NODE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -655,10 +655,10 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *ar) WM_gizmomap_add_handlers(ar, ar->gizmo_map); /* own keymaps */ - keymap = WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Node Generic", SPACE_NODE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Node Editor", SPACE_NODE, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Node Editor", SPACE_NODE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* add drop boxes */ diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index d4c85ce28bd..34128942382 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -29,7 +29,7 @@ #include "BLI_utildefines.h" #include "BLI_listbase.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_object_types.h" #include "BKE_context.h" @@ -99,9 +99,26 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te) return NULL; } +TreeTraversalAction outliner_find_selected_collections(TreeElement *te, void *customdata) +{ + struct IDsSelectedData *data = customdata; + TreeStoreElem *tselem = TREESTORE(te); + + if (outliner_is_collection_tree_element(te)) { + BLI_addtail(&data->selected_array, BLI_genericNodeN(te)); + return TRAVERSE_CONTINUE; + } + + if (tselem->type || (tselem->id && GS(tselem->id->name) != ID_GR)) { + return TRAVERSE_SKIP_CHILDS; + } + + return TRAVERSE_CONTINUE; +} + TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *customdata) { - struct ObjectsSelectedData *data = customdata; + struct IDsSelectedData *data = customdata; TreeStoreElem *tselem = TREESTORE(te); if (outliner_is_collection_tree_element(te)) { @@ -112,7 +129,7 @@ TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *custom return TRAVERSE_SKIP_CHILDS; } - BLI_addtail(&data->objects_selected_array, BLI_genericNodeN(te)); + BLI_addtail(&data->selected_array, BLI_genericNodeN(te)); return TRAVERSE_CONTINUE; } @@ -811,12 +828,12 @@ void OUTLINER_OT_collection_indirect_only_clear(wmOperatorType *ot) void ED_outliner_selected_objects_get(const bContext *C, ListBase *objects) { SpaceOops *soops = CTX_wm_space_outliner(C); - struct ObjectsSelectedData data = {{NULL}}; + struct IDsSelectedData data = {{NULL}}; outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_objects, &data); - LISTBASE_FOREACH (LinkData *, link, &data.objects_selected_array) { + LISTBASE_FOREACH (LinkData *, link, &data.selected_array) { TreeElement *ten_selected = (TreeElement *)link->data; Object *ob = (Object *)TREESTORE(ten_selected)->id; BLI_addtail(objects, BLI_genericNodeN(ob)); } - BLI_freelistN(&data.objects_selected_array); + BLI_freelistN(&data.selected_array); } diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index e3c089a813f..60f02dd9529 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -33,7 +33,7 @@ #include "MEM_guardedalloc.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_space_types.h" @@ -883,26 +883,55 @@ static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *UNUSED(op), c wmDrag *drag = WM_event_start_drag(C, data.icon, WM_DRAG_ID, NULL, 0.0, WM_DRAG_NOP); - if (GS(data.drag_id->name) == ID_OB) { - /* For objects we cheat and drag all selected objects. */ + if (ELEM(GS(data.drag_id->name), ID_OB, ID_GR)) { + /* For collections and objects we cheat and drag all selected. */ TREESTORE(te)->flag |= TSE_SELECTED; - struct ObjectsSelectedData selected = { - .objects_selected_array = {NULL, NULL}, + /* Gather all selected elements. */ + struct IDsSelectedData selected = { + .selected_array = {NULL, NULL}, }; - outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_objects, &selected); - LISTBASE_FOREACH (LinkData *, link, &selected.objects_selected_array) { - TreeElement *ten_selected = (TreeElement *)link->data; - Object *ob = (Object *)TREESTORE(ten_selected)->id; + if (GS(data.drag_id->name) == ID_OB) { + outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_objects, &selected); + } + else { + outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_collections, &selected); + } + + LISTBASE_FOREACH (LinkData *, link, &selected.selected_array) { + TreeElement *te_selected = (TreeElement *)link->data; + ID *id; + + if (GS(data.drag_id->name) == ID_OB) { + id = TREESTORE(te_selected)->id; + } + else { + /* Keep collection hierarchies intact when dragging. */ + bool parent_selected = false; + for (TreeElement *te_parent = te_selected->parent; te_parent; te_parent = te_parent->parent) { + if (outliner_is_collection_tree_element(te_parent)) { + if (TREESTORE(te_parent)->flag & TSE_SELECTED) { + parent_selected = true; + break; + } + } + } + + if (parent_selected) { + continue; + } + + id = &outliner_collection_from_tree_element(te_selected)->id; + } - /* Find parent collection of object. */ + /* Find parent collection. */ Collection *parent = NULL; - if (ten_selected->parent) { - for (TreeElement *te_ob_parent = ten_selected->parent; te_ob_parent; te_ob_parent = te_ob_parent->parent) { - if (outliner_is_collection_tree_element(te_ob_parent)) { - parent = outliner_collection_from_tree_element(te_ob_parent); + if (te_selected->parent) { + for (TreeElement *te_parent = te_selected->parent; te_parent; te_parent = te_parent->parent) { + if (outliner_is_collection_tree_element(te_parent)) { + parent = outliner_collection_from_tree_element(te_parent); break; } } @@ -912,10 +941,10 @@ static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *UNUSED(op), c parent = BKE_collection_master(scene); } - WM_drag_add_ID(drag, &ob->id, &parent->id); + WM_drag_add_ID(drag, id, &parent->id); } - BLI_freelistN(&selected.objects_selected_array); + BLI_freelistN(&selected.selected_array); } else { /* Add single ID. */ diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 211c9e1a392..2f7d8b7523c 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -31,9 +31,9 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" +#include "DNA_collection_types.h" #include "DNA_gpencil_types.h" #include "DNA_gpencil_modifier_types.h" -#include "DNA_group_types.h" #include "DNA_lamp_types.h" #include "DNA_lightprobe_types.h" #include "DNA_object_types.h" @@ -1094,6 +1094,9 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) case eGpencilModifierType_Offset: data.icon = ICON_MOD_DISPLACE; break; + case eGpencilModifierType_Armature: + data.icon = ICON_MOD_ARMATURE; + break; /* Default */ default: diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index ec267d333a7..b845e5c4d40 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -34,7 +34,7 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_ID.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index f8dc41b8d37..99411df3fda 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -176,10 +176,11 @@ void outliner_build_tree( struct Scene *scene, struct ViewLayer *view_layer, struct SpaceOops *soops, struct ARegion *ar); -typedef struct ObjectsSelectedData { - struct ListBase objects_selected_array; -} ObjectsSelectedData; +typedef struct IDsSelectedData { + struct ListBase selected_array; +} IDsSelectedData; +TreeTraversalAction outliner_find_selected_collections(struct TreeElement *te, void *customdata); TreeTraversalAction outliner_find_selected_objects(struct TreeElement *te, void *customdata); /* outliner_draw.c ---------------------------------------------- */ diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 39d77f75c0e..66fd680a1e0 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -33,7 +33,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "BLT_translation.h" @@ -120,7 +120,7 @@ void outliner_operatortypes(void) void outliner_keymap(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Outliner", SPACE_OUTLINER, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Outliner", SPACE_OUTLINER, 0); wmKeyMapItem *kmi; WM_keymap_add_item(keymap, "OUTLINER_OT_highlight_update", MOUSEMOVE, KM_ANY, KM_ANY, 0); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 05cc1790a83..e713a0a2797 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -32,7 +32,7 @@ #include <stdlib.h> #include "DNA_armature_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 190ef9fa229..84af223733d 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -33,8 +33,8 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" +#include "DNA_collection_types.h" #include "DNA_gpencil_types.h" -#include "DNA_group_types.h" #include "DNA_lamp_types.h" #include "DNA_linestyle_types.h" #include "DNA_material_types.h" diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 91033189035..170a54cd404 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -39,8 +39,8 @@ #include "DNA_constraint_types.h" #include "DNA_camera_types.h" #include "DNA_cachefile_types.h" +#include "DNA_collection_types.h" #include "DNA_gpencil_types.h" -#include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index b0d63aee7c0..37fa44f7386 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -84,7 +84,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0); /* don't pass on view2d mask, it's always set with scrollbar space, hide fails */ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, &ar->winrct); diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index fe7261f7bbd..65c489e8409 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -133,7 +133,7 @@ static void script_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Script", SPACE_SCRIPT, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Script", SPACE_SCRIPT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 14e181f2a25..bf1804955d7 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -138,7 +138,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* Common items ------------------------------------------------------------------ */ - keymap = WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0); + keymap = WM_keymap_ensure(keyconf, "SequencerCommon", SPACE_SEQ, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0); @@ -149,7 +149,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_view_toggle", TABKEY, KM_PRESS, KM_CTRL, 0); /* Strips Region --------------------------------------------------------------- */ - keymap = WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0); + keymap = WM_keymap_ensure(keyconf, "Sequencer", SPACE_SEQ, 0); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_SELECT); @@ -343,7 +343,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) /* Preview Region ----------------------------------------------------------- */ - keymap = WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0); + keymap = WM_keymap_ensure(keyconf, "SequencerPreview", SPACE_SEQ, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0); #ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 11517d64d7a..c5d5a9695f8 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -471,15 +471,15 @@ static void sequencer_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); #if 0 - keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); #endif - keymap = WM_keymap_find(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Sequencer", SPACE_SEQ, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer", SPACE_SEQ, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* add drop boxes */ @@ -594,15 +594,15 @@ static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); #if 0 - keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); #endif - keymap = WM_keymap_find(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -699,7 +699,7 @@ static void sequencer_buttons_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - keymap = WM_keymap_find(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); ED_region_panels_init(wm, ar); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index f3c55aa3474..7f2ce59361e 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -244,7 +244,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap = WM_keymap_find(keyconf, "Text Generic", SPACE_TEXT, 0); + keymap = WM_keymap_ensure(keyconf, "Text Generic", SPACE_TEXT, 0); WM_keymap_add_item(keymap, "TEXT_OT_start_find", FKEY, KM_PRESS, KM_CTRL, 0); #ifdef __APPLE__ WM_keymap_add_item(keymap, "TEXT_OT_start_find", FKEY, KM_PRESS, KM_OSKEY, 0); @@ -254,7 +254,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_replace", HKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_properties", TKEY, KM_PRESS, KM_CTRL, 0); - keymap = WM_keymap_find(keyconf, "Text", SPACE_TEXT, 0); + keymap = WM_keymap_ensure(keyconf, "Text", SPACE_TEXT, 0); #ifdef __APPLE__ RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN); @@ -426,9 +426,9 @@ static void text_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); /* own keymap */ - keymap = WM_keymap_find(wm->defaultconf, "Text Generic", SPACE_TEXT, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - keymap = WM_keymap_find(wm->defaultconf, "Text", SPACE_TEXT, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* add drop boxes */ @@ -543,7 +543,7 @@ static void text_properties_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); /* own keymaps */ - keymap = WM_keymap_find(wm->defaultconf, "Text Generic", SPACE_TEXT, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c new file mode 100644 index 00000000000..e3fe124a5c4 --- /dev/null +++ b/source/blender/editors/space_time/space_time.c @@ -0,0 +1,834 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_time/space_time.c + * \ingroup sptime + */ + + +#include <string.h> +#include <stdio.h> + +#include "DNA_cachefile_types.h" +#include "DNA_constraint_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" + +#include "BKE_constraint.h" +#include "BKE_context.h" +#include "BKE_main.h" +#include "BKE_modifier.h" +#include "BKE_screen.h" +#include "BKE_pointcache.h" + +#include "ED_anim_api.h" +#include "ED_keyframes_draw.h" +#include "ED_screen.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "UI_resources.h" +#include "UI_view2d.h" +#include "UI_interface.h" + +#include "ED_space_api.h" +#include "ED_markers.h" + +#include "time_intern.h" + +/* ************************ main time area region *********************** */ + +static void time_draw_sfra_efra(Scene *scene, View2D *v2d) +{ + /* draw darkened area outside of active timeline + * frame range used is preview range or scene range + */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glColor4f(0.0f, 0.0f, 0.0f, 0.4f); + + if (PSFRA < PEFRA) { + glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); + glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + } + else { + glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + } + glDisable(GL_BLEND); + + UI_ThemeColorShade(TH_BACK, -60); + /* thin lines where the actual frames are */ + fdrawline((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); + fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax); +} + +static void time_draw_cache(Main *bmain, SpaceTime *stime, Object *ob, Scene *scene) +{ + PTCacheID *pid; + ListBase pidlist; + SpaceTimeCache *stc = stime->caches.first; + const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize); + float yoffs = 0.f; + + if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob)) + return; + + BKE_ptcache_ids_from_object(bmain, &pidlist, ob, scene, 0); + + /* iterate over pointcaches on the active object, + * add spacetimecache and vertex array for each */ + for (pid = pidlist.first; pid; pid = pid->next) { + float col[4], *fp; + int i, sta = pid->cache->startframe, end = pid->cache->endframe; + int len = (end - sta + 1) * 4; + + switch (pid->type) { + case PTCACHE_TYPE_SOFTBODY: + if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue; + break; + case PTCACHE_TYPE_PARTICLES: + if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue; + break; + case PTCACHE_TYPE_CLOTH: + if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue; + break; + case PTCACHE_TYPE_SMOKE_DOMAIN: + case PTCACHE_TYPE_SMOKE_HIGHRES: + if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; + break; + case PTCACHE_TYPE_DYNAMICPAINT: + if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue; + break; + case PTCACHE_TYPE_RIGIDBODY: + if (!(stime->cache_display & TIME_CACHE_RIGIDBODY)) continue; + break; + } + + if (pid->cache->cached_frames == NULL) + continue; + + /* make sure we have stc with correct array length */ + if (stc == NULL || MEM_allocN_len(stc->array) != len * 2 * sizeof(float)) { + if (stc) { + MEM_freeN(stc->array); + } + else { + stc = MEM_callocN(sizeof(SpaceTimeCache), "spacetimecache"); + BLI_addtail(&stime->caches, stc); + } + + stc->array = MEM_callocN(len * 2 * sizeof(float), "SpaceTimeCache array"); + } + + /* fill the vertex array with a quad for each cached frame */ + for (i = sta, fp = stc->array; i <= end; i++) { + if (pid->cache->cached_frames[i - sta]) { + fp[0] = (float)i - 0.5f; + fp[1] = 0.0; + fp += 2; + + fp[0] = (float)i - 0.5f; + fp[1] = 1.0; + fp += 2; + + fp[0] = (float)i + 0.5f; + fp[1] = 1.0; + fp += 2; + + fp[0] = (float)i + 0.5f; + fp[1] = 0.0; + fp += 2; + } + } + + glPushMatrix(); + glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0); + glScalef(1.0, cache_draw_height, 0.0); + + switch (pid->type) { + case PTCACHE_TYPE_SOFTBODY: + col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; + col[3] = 0.1; + break; + case PTCACHE_TYPE_PARTICLES: + col[0] = 1.0; col[1] = 0.1; col[2] = 0.02; + col[3] = 0.1; + break; + case PTCACHE_TYPE_CLOTH: + col[0] = 0.1; col[1] = 0.1; col[2] = 0.75; + col[3] = 0.1; + break; + case PTCACHE_TYPE_SMOKE_DOMAIN: + case PTCACHE_TYPE_SMOKE_HIGHRES: + col[0] = 0.2; col[1] = 0.2; col[2] = 0.2; + col[3] = 0.1; + break; + case PTCACHE_TYPE_DYNAMICPAINT: + col[0] = 1.0; col[1] = 0.1; col[2] = 0.75; + col[3] = 0.1; + break; + case PTCACHE_TYPE_RIGIDBODY: + col[0] = 1.0; col[1] = 0.6; col[2] = 0.0; + col[3] = 0.1; + break; + default: + col[0] = 1.0; col[1] = 0.0; col[2] = 1.0; + col[3] = 0.1; + BLI_assert(0); + break; + } + glColor4fv(col); + + glEnable(GL_BLEND); + + glRectf((float)sta, 0.0, (float)end, 1.0); + + col[3] = 0.4f; + if (pid->cache->flag & PTCACHE_BAKED) { + col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; + } + else if (pid->cache->flag & PTCACHE_OUTDATED) { + col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f; + } + glColor4fv(col); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, stc->array); + glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2); + glDisableClientState(GL_VERTEX_ARRAY); + + glDisable(GL_BLEND); + + glPopMatrix(); + + yoffs += cache_draw_height; + + stc = stc->next; + } + + BLI_freelistN(&pidlist); + + /* free excessive caches */ + while (stc) { + SpaceTimeCache *tmp = stc->next; + BLI_remlink(&stime->caches, stc); + MEM_freeN(stc->array); + MEM_freeN(stc); + stc = tmp; + } +} + +static void time_cache_free(SpaceTime *stime) +{ + SpaceTimeCache *stc; + + for (stc = stime->caches.first; stc; stc = stc->next) { + if (stc->array) { + MEM_freeN(stc->array); + stc->array = NULL; + } + } + + BLI_freelistN(&stime->caches); +} + +static void time_cache_refresh(SpaceTime *stime) +{ + /* Free previous caches to indicate full refresh */ + time_cache_free(stime); +} + +/* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */ +static ActKeyColumn *time_cfra_find_ak(ActKeyColumn *ak, float cframe) +{ + ActKeyColumn *akn = NULL; + + /* sanity checks */ + if (ak == NULL) + return NULL; + + /* check if this is a match, or whether it is in some subtree */ + if (cframe < ak->cfra) + akn = time_cfra_find_ak(ak->left, cframe); + else if (cframe > ak->cfra) + akn = time_cfra_find_ak(ak->right, cframe); + + /* if no match found (or found match), just use the current one */ + if (akn == NULL) + return ak; + else + return akn; +} + +/* helper for time_draw_keyframes() */ +static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) +{ + bDopeSheet ads = {NULL}; + DLRBT_Tree keys; + ActKeyColumn *ak; + + float fac1 = (GS(id->name) == ID_GD) ? 0.8f : 0.6f; /* draw GPencil keys taller, to help distinguish them */ + float fac2 = 1.0f - fac1; + + float ymin = v2d->tot.ymin; + float ymax = v2d->tot.ymax * fac1 + ymin * fac2; + + /* init binarytree-list for getting keyframes */ + BLI_dlrbTree_init(&keys); + + /* init dopesheet settings */ + if (onlysel) + ads.filterflag |= ADS_FILTER_ONLYSEL; + + /* populate tree with keyframe nodes */ + switch (GS(id->name)) { + case ID_SCE: + scene_to_keylist(&ads, (Scene *)id, &keys, NULL); + break; + case ID_OB: + ob_to_keylist(&ads, (Object *)id, &keys, NULL); + break; + case ID_GD: + gpencil_to_keylist(&ads, (bGPdata *)id, &keys); + break; + case ID_CF: + cachefile_to_keylist(&ads, (CacheFile *)id, &keys, NULL); + break; + default: + break; + } + + /* build linked-list for searching */ + BLI_dlrbTree_linkedlist_sync(&keys); + + /* start drawing keyframes + * - we use the binary-search capabilities of the tree to only start from + * the first visible keyframe (last one can then be easily checked) + * - draw within a single GL block to be faster + */ + glBegin(GL_LINES); + for (ak = time_cfra_find_ak(keys.root, v2d->cur.xmin); + (ak) && (ak->cfra <= v2d->cur.xmax); + ak = ak->next) + { + glVertex2f(ak->cfra, ymin); + glVertex2f(ak->cfra, ymax); + } + glEnd(); // GL_LINES + + /* free temp stuff */ + BLI_dlrbTree_free(&keys); +} + +static void time_draw_caches_keyframes(Main *bmain, Scene *scene, View2D *v2d, bool onlysel) +{ + CacheFile *cache_file; + + for (cache_file = bmain->cachefiles.first; + cache_file; + cache_file = cache_file->id.next) + { + cache_file->draw_flag &= ~CACHEFILE_KEYFRAME_DRAWN; + } + + for (Base *base = scene->base.first; base; base = base->next) { + Object *ob = base->object; + + ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache); + + if (md) { + MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md; + + cache_file = mcmd->cache_file; + + if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) { + continue; + } + + cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN; + + time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel); + } + + for (bConstraint *con = ob->constraints.first; con; con = con->next) { + if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) { + continue; + } + + bTransformCacheConstraint *data = con->data; + + cache_file = data->cache_file; + + if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) { + continue; + } + + cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN; + + time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel); + } + } +} + +/* draw keyframe lines for timeline */ +static void time_draw_keyframes(const bContext *C, ARegion *ar) +{ + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + View2D *v2d = &ar->v2d; + bool onlysel = ((scene->flag & SCE_KEYS_NO_SELONLY) == 0); + + /* set this for all keyframe lines once and for all */ + glLineWidth(1.0); + + /* draw cache files keyframes (if available) */ + UI_ThemeColor(TH_TIME_KEYFRAME); + time_draw_caches_keyframes(CTX_data_main(C), scene, v2d, onlysel); + + /* draw grease pencil keyframes (if available) */ + UI_ThemeColor(TH_TIME_GP_KEYFRAME); + if (scene->gpd) { + time_draw_idblock_keyframes(v2d, (ID *)scene->gpd, onlysel); + } + if (ob && ob->gpd) { + time_draw_idblock_keyframes(v2d, (ID *)ob->gpd, onlysel); + } + + /* draw scene keyframes first + * - don't try to do this when only drawing active/selected data keyframes, + * since this can become quite slow + */ + if (onlysel == 0) { + /* set draw color */ + UI_ThemeColorShade(TH_TIME_KEYFRAME, -50); + time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel); + } + + /* draw keyframes from selected objects + * - only do the active object if in posemode (i.e. showing only keyframes for the bones) + * OR the onlysel flag was set, which means that only active object's keyframes should + * be considered + */ + UI_ThemeColor(TH_TIME_KEYFRAME); + + if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) { + /* draw keyframes for active object only */ + time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel); + } + else { + bool active_done = false; + + /* draw keyframes from all selected objects */ + CTX_DATA_BEGIN (C, Object *, obsel, selected_objects) + { + /* last arg is 0, since onlysel doesn't apply here... */ + time_draw_idblock_keyframes(v2d, (ID *)obsel, 0); + + /* if this object is the active one, set flag so that we don't draw again */ + if (obsel == ob) + active_done = true; + } + CTX_DATA_END; + + /* if active object hasn't been done yet, draw it... */ + if (ob && (active_done == 0)) + time_draw_idblock_keyframes(v2d, (ID *)ob, 0); + } +} + +/* ---------------- */ + +static void time_refresh(const bContext *UNUSED(C), ScrArea *sa) +{ + /* find the main timeline region and refresh cache display*/ + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (ar) { + SpaceTime *stime = (SpaceTime *)sa->spacedata.first; + time_cache_refresh(stime); + } +} + +/* editor level listener */ +static void time_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) +{ + + /* mainly for updating cache display */ + switch (wmn->category) { + case NC_OBJECT: + { + switch (wmn->data) { + case ND_BONE_SELECT: + case ND_BONE_ACTIVE: + case ND_POINTCACHE: + case ND_MODIFIER: + case ND_PARTICLE: + case ND_KEYS: + ED_area_tag_refresh(sa); + ED_area_tag_redraw(sa); + break; + } + break; + } + case NC_SCENE: + { + switch (wmn->data) { + case ND_RENDER_RESULT: + ED_area_tag_redraw(sa); + break; + case ND_OB_ACTIVE: + case ND_FRAME: + ED_area_tag_refresh(sa); + break; + case ND_FRAME_RANGE: + { + ARegion *ar; + Scene *scene = wmn->reference; + + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + ar->v2d.tot.xmin = (float)(SFRA - 4); + ar->v2d.tot.xmax = (float)(EFRA + 4); + break; + } + } + break; + } + } + break; + } + case NC_SPACE: + { + switch (wmn->data) { + case ND_SPACE_CHANGED: + ED_area_tag_refresh(sa); + break; + } + break; + } + case NC_WM: + { + switch (wmn->data) { + case ND_FILEREAD: + ED_area_tag_refresh(sa); + break; + } + break; + } + } +} + +/* ---------------- */ + +/* add handlers, stuff you only do once or on area/region changes */ +static void time_main_region_init(wmWindowManager *wm, ARegion *ar) +{ + wmKeyMap *keymap; + + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); + + /* own keymap */ + keymap = WM_keymap_ensure(wm->defaultconf, "Timeline", SPACE_TIME, 0); + WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); +} + +static void time_main_region_draw(const bContext *C, ARegion *ar) +{ + /* draw entirely, view changes should be handled here */ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceTime *stime = CTX_wm_space_time(C); + Object *obact = CTX_data_active_object(C); + View2D *v2d = &ar->v2d; + View2DGrid *grid; + View2DScrollers *scrollers; + int unit, flag = 0; + + /* clear and setup matrix */ + UI_ThemeClearColor(TH_BACK); + glClear(GL_COLOR_BUFFER_BIT); + + UI_view2d_view_ortho(v2d); + + /* grid */ + unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS; + grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS)); + UI_view2d_grid_free(grid); + + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); + + /* start and end frame */ + time_draw_sfra_efra(scene, v2d); + + /* current frame */ + flag = DRAWCFRA_WIDE; /* this is only really needed on frames where there's a keyframe, but this will do... */ + if ((stime->flag & TIME_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS; + if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX; + ANIM_draw_cfra(C, v2d, flag); + + UI_view2d_view_ortho(v2d); + + /* keyframes */ + time_draw_keyframes(C, ar); + + /* markers */ + UI_view2d_view_orthoSpecial(ar, v2d, 1); + ED_markers_draw(C, 0); + + /* caches */ + time_draw_cache(bmain, stime, obact, scene); + + /* callback */ + UI_view2d_view_ortho(v2d); + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); + + /* reset view matrix */ + UI_view2d_view_restore(C); + + /* scrollers */ + scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + UI_view2d_scrollers_draw(C, v2d, scrollers); + UI_view2d_scrollers_free(scrollers); +} + +static void time_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch (wmn->category) { + case NC_SPACE: + if (wmn->data == ND_SPACE_TIME) + ED_region_tag_redraw(ar); + break; + + case NC_ANIMATION: + ED_region_tag_redraw(ar); + break; + + case NC_SCENE: + switch (wmn->data) { + case ND_OB_SELECT: + case ND_OB_ACTIVE: + case ND_FRAME: + case ND_FRAME_RANGE: + case ND_KEYINGSET: + case ND_RENDER_OPTIONS: + ED_region_tag_redraw(ar); + break; + } + break; + case NC_GPENCIL: + if (wmn->data == ND_DATA) + ED_region_tag_redraw(ar); + break; + } +} + +/* ************************ header time area region *********************** */ + +/* add handlers, stuff you only do once or on area/region changes */ +static void time_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar) +{ + ED_region_header_init(ar); +} + +static void time_header_region_draw(const bContext *C, ARegion *ar) +{ + ED_region_header(C, ar); +} + +static void time_header_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch (wmn->category) { + case NC_SCREEN: + { + if (wmn->data == ND_ANIMPLAY) + ED_region_tag_redraw(ar); + break; + } + case NC_SCENE: + { + switch (wmn->data) { + case ND_RENDER_RESULT: + case ND_OB_SELECT: + case ND_FRAME: + case ND_FRAME_RANGE: + case ND_KEYINGSET: + case ND_RENDER_OPTIONS: + ED_region_tag_redraw(ar); + break; + } + break; + } + case NC_SPACE: + { + if (wmn->data == ND_SPACE_TIME) + ED_region_tag_redraw(ar); + break; + } + } +} + +/* ******************** default callbacks for time space ***************** */ + +static SpaceLink *time_new(const bContext *C) +{ + Scene *scene = CTX_data_scene(C); + ARegion *ar; + SpaceTime *stime; + + stime = MEM_callocN(sizeof(SpaceTime), "inittime"); + + stime->spacetype = SPACE_TIME; + stime->flag |= TIME_DRAWFRAMES; + + /* header */ + ar = MEM_callocN(sizeof(ARegion), "header for time"); + + BLI_addtail(&stime->regionbase, ar); + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; + + /* main region */ + ar = MEM_callocN(sizeof(ARegion), "main region for time"); + + BLI_addtail(&stime->regionbase, ar); + ar->regiontype = RGN_TYPE_WINDOW; + + ar->v2d.tot.xmin = (float)(SFRA - 4); + ar->v2d.tot.ymin = 0.0f; + ar->v2d.tot.xmax = (float)(EFRA + 4); + ar->v2d.tot.ymax = 50.0f; + + ar->v2d.cur = ar->v2d.tot; + + ar->v2d.min[0] = 1.0f; + ar->v2d.min[1] = 50.0f; + + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = 50.0; + + ar->v2d.minzoom = 0.1f; + ar->v2d.maxzoom = 10.0; + + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; + ar->v2d.keepofs |= V2D_LOCKOFS_Y; + ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; + + + return (SpaceLink *)stime; +} + +/* not spacelink itself */ +static void time_free(SpaceLink *sl) +{ + SpaceTime *stime = (SpaceTime *)sl; + + time_cache_free(stime); +} +/* spacetype; init callback in ED_area_initialize() */ +/* init is called to (re)initialize an existing editor (file read, screen changes) */ +/* validate spacedata, add own area level handlers */ +static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa) +{ + SpaceTime *stime = (SpaceTime *)sa->spacedata.first; + + time_cache_free(stime); + + /* enable all cache display */ + stime->cache_display |= TIME_CACHE_DISPLAY; + stime->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES); + stime->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT); + stime->cache_display |= TIME_CACHE_RIGIDBODY; +} + +static SpaceLink *time_duplicate(SpaceLink *sl) +{ + SpaceTime *stime = (SpaceTime *)sl; + SpaceTime *stimen = MEM_dupallocN(stime); + + BLI_listbase_clear(&stimen->caches); + + return (SpaceLink *)stimen; +} + +/* only called once, from space_api/spacetypes.c */ +/* it defines all callbacks to maintain spaces */ +void ED_spacetype_time(void) +{ + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); + ARegionType *art; + + st->spaceid = SPACE_TIME; + strncpy(st->name, "Timeline", BKE_ST_MAXNAME); + + st->new = time_new; + st->free = time_free; + st->init = time_init; + st->duplicate = time_duplicate; + st->operatortypes = time_operatortypes; + st->keymap = NULL; + st->listener = time_listener; + st->refresh = time_refresh; + + /* regions: main window */ + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art->regionid = RGN_TYPE_WINDOW; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; + + art->init = time_main_region_init; + art->draw = time_main_region_draw; + art->listener = time_main_region_listener; + art->keymap = time_keymap; + art->lock = 1; /* Due to pointcache, see T4960. */ + BLI_addhead(&st->regiontypes, art); + + /* regions: header */ + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art->regionid = RGN_TYPE_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; + + art->init = time_header_region_init; + art->draw = time_header_region_draw; + art->listener = time_header_region_listener; + BLI_addhead(&st->regiontypes, art); + + BKE_spacetype_register(st); +} diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c new file mode 100644 index 00000000000..a68bd2a9fbb --- /dev/null +++ b/source/blender/editors/space_time/time_ops.c @@ -0,0 +1,226 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_time/time_ops.c + * \ingroup sptime + */ + + +#include <stdlib.h> +#include <math.h> + +#include "DNA_scene_types.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "BKE_context.h" + +#include "ED_anim_api.h" +#include "ED_screen.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "time_intern.h" + +/* ****************** Start/End Frame Operators *******************************/ +static int time_set_sfra_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + int frame; + + if (scene == NULL) + return OPERATOR_CANCELLED; + + frame = CFRA; + + /* if Preview Range is defined, set the 'start' frame for that */ + if (PRVRANGEON) + scene->r.psfra = frame; + else + scene->r.sfra = frame; + + if (PEFRA < frame) { + if (PRVRANGEON) + scene->r.pefra = frame; + else + scene->r.efra = frame; + } + + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + + return OPERATOR_FINISHED; +} + +static void TIME_OT_start_frame_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Set Start Frame"; + ot->idname = "TIME_OT_start_frame_set"; + ot->description = "Set the start frame"; + + /* api callbacks */ + ot->exec = time_set_sfra_exec; + ot->poll = ED_operator_timeline_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + + +static int time_set_efra_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + int frame; + + if (scene == NULL) + return OPERATOR_CANCELLED; + + frame = CFRA; + + /* if Preview Range is defined, set the 'end' frame for that */ + if (PRVRANGEON) + scene->r.pefra = frame; + else + scene->r.efra = frame; + + if (PSFRA > frame) { + if (PRVRANGEON) + scene->r.psfra = frame; + else + scene->r.sfra = frame; + } + + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + + return OPERATOR_FINISHED; +} + +static void TIME_OT_end_frame_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Set End Frame"; + ot->idname = "TIME_OT_end_frame_set"; + ot->description = "Set the end frame"; + + /* api callbacks */ + ot->exec = time_set_efra_exec; + ot->poll = ED_operator_timeline_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/* ************************ View All Operator *******************************/ + +static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + + if (ELEM(NULL, scene, ar)) + return OPERATOR_CANCELLED; + + View2D *v2d = &ar->v2d; + + /* set extents of view to start/end frames (Preview Range too) */ + v2d->cur.xmin = (float)PSFRA; + v2d->cur.xmax = (float)PEFRA; + + /* we need an extra "buffer" factor on either side so that the endpoints are visible */ + const float extra = 0.01f * BLI_rctf_size_x(&v2d->cur); + v2d->cur.xmin -= extra; + v2d->cur.xmax += extra; + + /* this only affects this TimeLine instance, so just force redraw of this region */ + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +static void TIME_OT_view_all(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "View All"; + ot->idname = "TIME_OT_view_all"; + ot->description = "Show the entire playable frame range"; + + /* api callbacks */ + ot->exec = time_view_all_exec; + ot->poll = ED_operator_timeline_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/* ************************ View Frame Operator *******************************/ + +static int time_view_frame_exec(bContext *C, wmOperator *op) +{ + const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); + ANIM_center_frame(C, smooth_viewtx); + + return OPERATOR_FINISHED; +} + +static void TIME_OT_view_frame(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "View Frame"; + ot->idname = "TIME_OT_view_frame"; + ot->description = "Reset viewable area to show range around current frame"; + + /* api callbacks */ + ot->exec = time_view_frame_exec; + ot->poll = ED_operator_timeline_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/* ************************** registration **********************************/ + +void time_operatortypes(void) +{ + WM_operatortype_append(TIME_OT_start_frame_set); + WM_operatortype_append(TIME_OT_end_frame_set); + WM_operatortype_append(TIME_OT_view_all); + WM_operatortype_append(TIME_OT_view_frame); +} + +void time_keymap(wmKeyConfig *keyconf) +{ + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Timeline", SPACE_TIME, 0); + + WM_keymap_add_item(keymap, "TIME_OT_start_frame_set", SKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "TIME_OT_end_frame_set", EKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "TIME_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF + WM_keymap_add_item(keymap, "TIME_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); +#endif + WM_keymap_add_item(keymap, "TIME_OT_view_frame", PAD0, KM_PRESS, 0, 0); +} diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c index 6113922c02e..db75545fbd6 100644 --- a/source/blender/editors/space_topbar/space_topbar.c +++ b/source/blender/editors/space_topbar/space_topbar.c @@ -128,7 +128,7 @@ static void topbar_main_region_init(wmWindowManager *wm, ARegion *region) } UI_view2d_region_reinit(®ion->v2d, V2D_COMMONVIEW_HEADER, region->winx, region->winy); - keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0); WM_event_add_keymap_handler(®ion->handlers, keymap); } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 434cb108ef4..674f4e1f778 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -465,74 +465,74 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) /* object ops. */ /* important to be before Pose keymap since they can both be enabled at once */ - keymap = WM_keymap_find(wm->defaultconf, "Face Mask", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Face Mask", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Weight Paint Vertex Selection", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Weight Paint Vertex Selection", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); /* pose is not modal, operator poll checks for this */ - keymap = WM_keymap_find(wm->defaultconf, "Pose", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Pose", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Object Mode", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Object Mode", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Paint Curve", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Curve", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Curve", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Image Paint", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Vertex Paint", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Vertex Paint", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Weight Paint", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Weight Paint", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Sculpt", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Sculpt", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Mesh", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Mesh", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Curve", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Curve", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Armature", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Armature", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Pose", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Pose", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Metaball", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Metaball", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Lattice", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Lattice", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Particle", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Particle", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); /* editfont keymap swallows all... */ - keymap = WM_keymap_find(wm->defaultconf, "Font", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Font", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Object Non-modal", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Object Non-modal", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Frames", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Frames", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); /* own keymap, last so modes can override it */ - keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "3D View", SPACE_VIEW3D, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "3D View", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); /* add drop boxes */ @@ -1150,7 +1150,7 @@ static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void view3d_header_region_init(wmWindowManager *wm, ARegion *ar) { - wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); + wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -1231,7 +1231,7 @@ static void view3d_buttons_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -1360,7 +1360,7 @@ static void view3d_tools_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); - keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 38fac7cb37d..43b7b940b4f 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -938,6 +938,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, true); uiItemR(colsub, ptr, "location", 0, NULL, ICON_NONE); colsub = uiLayoutColumn(split, true); + uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_location", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -948,6 +949,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, true); uiItemR(colsub, ptr, "rotation_quaternion", 0, IFACE_("Rotation"), ICON_NONE); colsub = uiLayoutColumn(split, true); + uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); if (RNA_boolean_get(ptr, "lock_rotations_4d")) uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE + UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -959,6 +961,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, true); uiItemR(colsub, ptr, "rotation_axis_angle", 0, IFACE_("Rotation"), ICON_NONE); colsub = uiLayoutColumn(split, true); + uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); if (RNA_boolean_get(ptr, "lock_rotations_4d")) uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -970,6 +973,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, true); uiItemR(colsub, ptr, "rotation_euler", 0, IFACE_("Rotation"), ICON_NONE); colsub = uiLayoutColumn(split, true); + uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; @@ -980,6 +984,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, true); uiItemR(colsub, ptr, "scale", 0, NULL, ICON_NONE); colsub = uiLayoutColumn(split, true); + uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_scale", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index d0fc36a8a1e..612be3ad6aa 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -34,9 +34,9 @@ #include "DNA_armature_types.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_customdata_types.h" #include "DNA_object_types.h" -#include "DNA_group_types.h" #include "DNA_mesh_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index 5853fa6e3b3..938b4c45181 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -422,7 +422,6 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup) if (ruler_item->flag & RULERITEM_USE_ANGLE) { gps->totpoints = 3; pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); for (j = 0; j < 3; j++) { copy_v3_v3(&pt->x, ruler_item->co[j]); pt->pressure = 1.0f; @@ -433,7 +432,6 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup) else { gps->totpoints = 2; pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); for (j = 0; j < 3; j += 2) { copy_v3_v3(&pt->x, ruler_item->co[j]); pt->pressure = 1.0f; diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index c1f5f33b38c..c53382a60ad 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -33,8 +33,8 @@ #include <math.h> +#include "DNA_collection_types.h" #include "DNA_object_types.h" -#include "DNA_group_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -237,13 +237,13 @@ void view3d_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap = WM_keymap_find(keyconf, "3D View Generic", SPACE_VIEW3D, 0); + keymap = WM_keymap_ensure(keyconf, "3D View Generic", SPACE_VIEW3D, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_toolshelf", TKEY, KM_PRESS, 0, 0); /* only for region 3D window */ - keymap = WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0); + keymap = WM_keymap_ensure(keyconf, "3D View", SPACE_VIEW3D, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_CLICK, 0, 0); diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 0475159712b..df8d65449e9 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -338,7 +338,6 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) if (ruler_item->flag & RULERITEM_USE_ANGLE) { gps->totpoints = 3; pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); for (j = 0; j < 3; j++) { copy_v3_v3(&pt->x, ruler_item->co[j]); pt->pressure = 1.0f; @@ -349,7 +348,6 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) else { gps->totpoints = 2; pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); for (j = 0; j < 3; j += 2) { copy_v3_v3(&pt->x, ruler_item->co[j]); pt->pressure = 1.0f; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b72017b2207..d32176ab20a 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -342,7 +342,7 @@ static bool edge_inside_rect(const rctf *rect, const float v1[2], const float v2 return 1; } -static void do_lasso_select_pose__doSelectBone( +static void do_lasso_select_pose__do_tag( void *userData, struct bPoseChannel *pchan, const float screen_co_a[2], const float screen_co_b[2]) { LassoSelectUserData *data = userData; @@ -352,26 +352,21 @@ static void do_lasso_select_pose__doSelectBone( bool is_point_done = false; int points_proj_tot = 0; - const int x0 = screen_co_a[0]; - const int y0 = screen_co_a[1]; - const int x1 = screen_co_b[0]; - const int y1 = screen_co_b[1]; - /* project head location to screenspace */ - if (x0 != IS_CLIPPED) { + if (screen_co_a[0] != IS_CLIPPED) { points_proj_tot++; - if (BLI_rcti_isect_pt(data->rect, x0, y0) && - BLI_lasso_is_point_inside(data->mcords, data->moves, x0, y0, INT_MAX)) + if (BLI_rcti_isect_pt(data->rect, UNPACK2(screen_co_a)) && + BLI_lasso_is_point_inside(data->mcords, data->moves, UNPACK2(screen_co_a), INT_MAX)) { is_point_done = true; } } /* project tail location to screenspace */ - if (x1 != IS_CLIPPED) { + if (screen_co_b[0] != IS_CLIPPED) { points_proj_tot++; - if (BLI_rcti_isect_pt(data->rect, x1, y1) && - BLI_lasso_is_point_inside(data->mcords, data->moves, x1, y1, INT_MAX)) + if (BLI_rcti_isect_pt(data->rect, UNPACK2(screen_co_b)) && + BLI_lasso_is_point_inside(data->mcords, data->moves, UNPACK2(screen_co_b), INT_MAX)) { is_point_done = true; } @@ -379,22 +374,15 @@ static void do_lasso_select_pose__doSelectBone( /* if one of points selected, we skip the bone itself */ if ((is_point_done == true) || - ((is_point_done == false) && (points_proj_tot == 2))) + ((is_point_done == false) && (points_proj_tot == 2) && + BLI_lasso_is_edge_inside(data->mcords, data->moves, UNPACK2(screen_co_a), UNPACK2(screen_co_b), INT_MAX))) { - const bool is_select = pchan->bone->flag & BONE_SELECTED; - const bool is_inside = BLI_lasso_is_edge_inside(data->mcords, data->moves, x0, y0, x1, y1, INT_MAX); - const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside); - if (sel_op_result != -1) { - SET_FLAG_FROM_TEST(pchan->bone->flag, sel_op_result, BONE_SELECTED); - data->is_changed = true; - } + pchan->bone->flag |= BONE_DONE; } data->is_changed |= is_point_done; } } -static void do_lasso_select_pose( - ViewContext *vc, Object *ob, const int mcords[][2], short moves, - const eSelectOp sel_op) +static void do_lasso_tag_pose(ViewContext *vc, Object *ob, const int mcords[][2], short moves) { ViewContext vc_tmp; LassoSelectUserData data; @@ -409,21 +397,11 @@ static void do_lasso_select_pose( BLI_lasso_boundbox(&rect, mcords, moves); - view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, sel_op); + view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, 0); - ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); + ED_view3d_init_mats_rv3d(vc_tmp.obact, vc->rv3d); - pose_foreachScreenBone(&vc_tmp, do_lasso_select_pose__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT); - - if (data.is_changed) { - bArmature *arm = ob->data; - if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* mask modifier ('armature' mode), etc. */ - DEG_id_tag_update(&ob->id, OB_RECALC_DATA); - } - /* bone selection status is on armature not object */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); - } + pose_foreachScreenBone(&vc_tmp, do_lasso_select_pose__do_tag, &data, V3D_PROJ_TEST_CLIP_DEFAULT); } static void object_deselect_all_visible(ViewLayer *view_layer) @@ -441,31 +419,133 @@ static void do_lasso_select_objects( ViewContext *vc, const int mcords[][2], const short moves, const eSelectOp sel_op) { - bool is_pose_mode = vc->obact ? (vc->obact->mode & OB_MODE_POSE) : false; Base *base; if (SEL_OP_USE_PRE_DESELECT(sel_op)) { object_deselect_all_visible(vc->view_layer); } + bool changed = false; for (base = vc->view_layer->object_bases.first; base; base = base->next) { if (BASE_SELECTABLE(base)) { /* use this to avoid un-needed lasso lookups */ - if (((vc->scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) ? - (is_pose_mode == false) : true) && - ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) - { - const bool is_select = base->flag & BASE_SELECTED; - const bool is_inside = BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED); + const bool is_select = base->flag & BASE_SELECTED; + const bool is_inside = ( + (ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) && + BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED)); + const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); + if (sel_op_result != -1) { + ED_object_base_select(base, sel_op_result ? BA_SELECT : BA_DESELECT); + changed = true; + } + } + } + + if (changed) { + DEG_id_tag_update(&vc->scene->id, DEG_TAG_SELECT_UPDATE); + WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, vc->scene); + } +} + + +/** + * Use for lasso & border select. + */ +static Base **do_pose_tag_select_op_prepare(ViewContext *vc, uint *r_bases_len) +{ + Base **bases = NULL; + BLI_array_declare(bases); + FOREACH_BASE_IN_MODE_BEGIN (vc->view_layer, OB_MODE_POSE, base_iter) { + Object *ob_iter = base_iter->object; + bArmature *arm = ob_iter->data; + for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { + Bone *bone = pchan->bone; + bone->flag &= ~BONE_DONE; + } + arm->id.tag |= LIB_TAG_DOIT; + ob_iter->id.tag &= ~LIB_TAG_DOIT; + BLI_array_append(bases, base_iter); + } + FOREACH_BASE_IN_MODE_END; + *r_bases_len = BLI_array_len(bases); + return bases; +} + +static bool do_pose_tag_select_op_exec(Base **bases, const uint bases_len, const eSelectOp sel_op) +{ + bool changed_multi = false; + + if (SEL_OP_USE_PRE_DESELECT(sel_op)) { + for (int i = 0; i < bases_len; i++) { + Base *base_iter = bases[i]; + Object *ob_iter = base_iter->object; + if (ED_pose_deselect_all(ob_iter, SEL_DESELECT, false)) { + ED_pose_bone_select_tag_update(ob_iter); + changed_multi = true; + } + } + } + + for (int i = 0; i < bases_len; i++) { + Base *base_iter = bases[i]; + Object *ob_iter = base_iter->object; + bArmature *arm = ob_iter->data; + + /* Don't handle twice. */ + if (arm->id.tag & LIB_TAG_DOIT) { + arm->id.tag &= ~LIB_TAG_DOIT; + } + else { + continue; + } + + bool changed = true; + for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { + Bone *bone = pchan->bone; + if ((bone->flag & BONE_UNSELECTABLE) == 0) { + const bool is_select = bone->flag & BONE_SELECTED; + const bool is_inside = bone->flag & BONE_DONE; const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); if (sel_op_result != -1) { - ED_object_base_select(base, sel_op_result ? BA_SELECT : BA_DESELECT); + SET_FLAG_FROM_TEST(bone->flag, sel_op_result, BONE_SELECTED); + if (sel_op_result == 0) { + if (arm->act_bone == bone) { + arm->act_bone = NULL; + } + } + changed = true; } } - if (is_pose_mode && (base->object->mode & OB_MODE_POSE)) { - do_lasso_select_pose(vc, base->object, mcords, moves, sel_op); - } + } + if (changed) { + ED_pose_bone_select_tag_update(ob_iter); + changed_multi = true; } } + return changed_multi; +} + +static void do_lasso_select_pose( + ViewContext *vc, const int mcords[][2], const short moves, + const eSelectOp sel_op) +{ + uint bases_len; + Base **bases = do_pose_tag_select_op_prepare(vc, &bases_len); + + for (int i = 0; i < bases_len; i++) { + Base *base_iter = bases[i]; + Object *ob_iter = base_iter->object; + do_lasso_tag_pose(vc, ob_iter, mcords, moves); + } + + const bool changed_multi = do_pose_tag_select_op_exec(bases, bases_len, sel_op); + if (changed_multi) { + DEG_id_tag_update(&vc->scene->id, DEG_TAG_SELECT_UPDATE); + WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, vc->scene); + } + + if (bases != NULL) { + MEM_freeN(bases); + } } static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, const float screen_co[2], int UNUSED(index)) @@ -910,10 +990,11 @@ static void view3d_lasso_select( else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { PE_lasso_select(C, mcords, moves, sel_op); } + else if (ob && (ob->mode & OB_MODE_POSE)) { + do_lasso_select_pose(vc, mcords, moves, sel_op); + } else { do_lasso_select_objects(vc, mcords, moves, sel_op); - DEG_id_tag_update(&vc->scene->id, DEG_TAG_SELECT_UPDATE); - WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene); } } else { /* Edit Mode */ @@ -2253,43 +2334,83 @@ static int opengl_bone_select_buffer_cmp(const void *sel_a_p, const void *sel_b_ } } -static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const eSelectOp sel_op) +static int do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const eSelectOp sel_op) { - unsigned int *vbuffer = NULL; /* selection buffer */ - int bone_only; int totobj = MAXPICKBUF; /* XXX solve later */ - int hits; - if (vc->obact && (vc->obact->mode & OB_MODE_POSE)) - bone_only = 1; - else - bone_only = 0; + /* selection buffer now has bones potentially too, so we add MAXPICKBUF */ + uint *vbuffer = MEM_mallocN(4 * (totobj + MAXPICKELEMS) * sizeof(uint[4]), "selection buffer"); + const eV3DSelectObjectFilter select_filter = ( + (vc->scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) ? + VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK : VIEW3D_SELECT_FILTER_NOP); + const int hits = view3d_opengl_select( + vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, + VIEW3D_SELECT_ALL, select_filter); - if (SEL_OP_USE_PRE_DESELECT(sel_op)) { - if (bone_only) { - FOREACH_OBJECT_IN_MODE_BEGIN (vc->view_layer, OB_MODE_POSE, ob_iter) { - bArmature *arm = ob_iter->data; - for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { - if (PBONE_VISIBLE(arm, pchan->bone)) { - if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) { - pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - } - } + for (Base *base = vc->view_layer->object_bases.first; base; base = base->next) { + base->object->id.tag &= ~LIB_TAG_DOIT; + } + + Base **bases = NULL; + BLI_array_declare(bases); + + /* The draw order doesn't always match the order we populate the engine, see: T51695. */ + if (hits > 0) { + qsort(vbuffer, hits, sizeof(uint[4]), opengl_bone_select_buffer_cmp); + + for (Base *base = vc->view_layer->object_bases.first; base; base = base->next) { + if (BASE_SELECTABLE(base)) { + if ((base->object->select_color & 0x0000FFFF) != 0) { + BLI_array_append(bases, base); } } - FOREACH_OBJECT_IN_MODE_END; } - else { - object_deselect_all_visible(vc->view_layer); + } + + for (const uint *col = vbuffer + 3, *col_end = col + (hits * 4); col < col_end; col += 4) { + Bone *bone; + Base *base = ED_armature_base_and_bone_from_select_buffer(bases, BLI_array_len(bases), *col, &bone); + base->object->id.tag |= LIB_TAG_DOIT; + } + + if (SEL_OP_USE_PRE_DESELECT(sel_op)) { + object_deselect_all_visible(vc->view_layer); + } + + for (Base *base = vc->view_layer->object_bases.first; base && hits; base = base->next) { + if (BASE_SELECTABLE(base)) { + const bool is_select = base->flag & BASE_SELECTED; + const bool is_inside = base->object->id.tag & LIB_TAG_DOIT; + const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); + if (sel_op_result != -1) { + ED_object_base_select(base, sel_op_result ? BA_SELECT : BA_DESELECT); + } } + DEG_id_tag_update(&vc->scene->id, DEG_TAG_SELECT_UPDATE); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene); } + if (bases != NULL) { + MEM_freeN(bases); + } + MEM_freeN(vbuffer); + + return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED; +} + +static int do_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const eSelectOp sel_op) +{ + uint bases_len; + Base **bases = do_pose_tag_select_op_prepare(vc, &bases_len); + + int totobj = MAXPICKBUF; /* XXX solve later */ + /* selection buffer now has bones potentially too, so we add MAXPICKBUF */ - vbuffer = MEM_mallocN(4 * (totobj + MAXPICKELEMS) * sizeof(unsigned int), "selection buffer"); + uint *vbuffer = MEM_mallocN((totobj + MAXPICKELEMS) * sizeof(uint[4]), "selection buffer"); const eV3DSelectObjectFilter select_filter = ( (vc->scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) ? VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK : VIEW3D_SELECT_FILTER_NOP); - hits = view3d_opengl_select( + const int hits = view3d_opengl_select( vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL, select_filter); /* @@ -2301,81 +2422,26 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, c * keeping the same color until we have a hit. */ - if (hits <= 0) { - if (SEL_OP_USE_OUTSIDE(sel_op)) { - for (Base *base = vc->view_layer->object_bases.first; base && hits; base = base->next) { - if (BASE_SELECTABLE(base)) { - const bool is_select = base->flag & BASE_SELECTED; - const bool is_inside = false; /* we know there are no hits. */ - const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); - if (sel_op_result != -1) { - ED_object_base_select(base, sel_op_result ? BA_SELECT : BA_DESELECT); - } - } - } - } - } - else { + if (hits > 0) { /* no need to loop if there's no hit */ /* The draw order doesn't always match the order we populate the engine, see: T51695. */ qsort(vbuffer, hits, sizeof(uint[4]), opengl_bone_select_buffer_cmp); - Base **bases = NULL; - BLI_array_declare(bases); - - for (Base *base = vc->view_layer->object_bases.first; base && hits; base = base->next) { - if (BASE_SELECTABLE(base)) { - if ((base->object->select_color & 0x0000FFFF) != 0) { - BLI_array_append(bases, base); - base->object->id.tag &= ~LIB_TAG_DOIT; - } - } - } - for (const uint *col = vbuffer + 3, *col_end = col + (hits * 4); col < col_end; col += 4) { Bone *bone; - Base *base = ED_armature_base_and_bone_from_select_buffer(bases, BLI_array_len(bases), *col, &bone); + Base *base = ED_armature_base_and_bone_from_select_buffer(bases, bases_len, *col, &bone); if (base == NULL) { continue; } + /* Loop over contiguous bone hits for 'base'. */ - bool changed = false; for (; col != col_end; col += 4) { /* should never fail */ if (bone != NULL) { - const bool is_select = (bone->flag & BONE_SELECTED) != 0; - const bool is_inside = true; - const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); - - if (sel_op_result != -1) { - if (sel_op_result) { - if ((bone->flag & BONE_UNSELECTABLE) == 0) { - bone->flag |= BONE_SELECTED; - } - } - else { - bArmature *arm = base->object->data; - if ((bone->flag & BONE_UNSELECTABLE) == 0) { - bone->flag &= ~BONE_SELECTED; - if (arm->act_bone == bone) - arm->act_bone = NULL; - } - } - } - changed = true; - } - else if (!bone_only) { - if ((base->object->id.tag & LIB_TAG_DOIT) == 0) { - base->object->id.tag |= LIB_TAG_DOIT; - const bool is_select = base->flag & BASE_SELECTED; - const bool is_inside = true; - const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); - if (sel_op_result != -1) { - ED_object_base_select(base, sel_op_result ? BA_SELECT : BA_DESELECT); - } - } + base->object->id.tag |= LIB_TAG_DOIT; + bone->flag |= BONE_DONE; } /* Select the next bone if we're not switching bases. */ @@ -2383,8 +2449,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, c if ((base->object->select_color & 0x0000FFFF) != (col[4] & 0x0000FFFF)) { break; } - - if ((base->object->pose != NULL) && bone_only) { + if (base->object->pose != NULL) { const uint hit_bone = (col[4] & ~BONESEL_ANY) >> 16; bPoseChannel *pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone); bone = pchan ? pchan->bone : NULL; @@ -2394,43 +2459,18 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, c } } } - - if (changed) { - if (base->object && (base->object->type == OB_ARMATURE)) { - bArmature *arm = base->object->data; - - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object); - - if (vc->obact && arm && (arm->flag & ARM_HAS_VIZ_DEPS)) { - /* mask modifier ('armature' mode), etc. */ - DEG_id_tag_update(&vc->obact->id, OB_RECALC_DATA); - } - - /* copy on write tag is needed (for the armature), or else no refresh happens */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); - } - } - } - - if (SEL_OP_USE_OUTSIDE(sel_op)) { - for (int i = 0; i < BLI_array_len(bases); i++) { - Base *base = bases[i]; - if ((base->object->id.tag & LIB_TAG_DOIT) == 0) { - const bool is_select = base->flag & BASE_SELECTED; - const bool is_inside = false; /* we know there are no hits. */ - const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); - if (sel_op_result != -1) { - ED_object_base_select(base, sel_op_result ? BA_SELECT : BA_DESELECT); - } - } - } } + } - MEM_freeN(bases); - + const bool changed_multi = do_pose_tag_select_op_exec(bases, bases_len, sel_op); + if (changed_multi) { DEG_id_tag_update(&vc->scene->id, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene); } + + if (bases != NULL) { + MEM_freeN(bases); + } MEM_freeN(vbuffer); return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED; @@ -2514,8 +2554,11 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) { ret |= PE_border_select(C, &rect, sel_op); } + else if (vc.obact && vc.obact->mode & OB_MODE_POSE) { + ret |= do_pose_box_select(C, &vc, &rect, sel_op); + } else { /* object mode with none active */ - ret |= do_object_pose_box_select(C, &vc, &rect, sel_op); + ret |= do_object_box_select(C, &vc, &rect, sel_op); } } @@ -2995,17 +3038,7 @@ static void pose_circle_select(ViewContext *vc, const bool select, const int mva pose_foreachScreenBone(vc, do_circle_select_pose__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT); if (data.is_changed) { - bArmature *arm = vc->obact->data; - - WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obact); - - if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* mask modifier ('armature' mode), etc. */ - DEG_id_tag_update(&vc->obact->id, OB_RECALC_DATA); - } - - /* copy on write tag is needed (for the armature), or else no refresh happens */ - DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); + ED_pose_bone_select_tag_update(vc->obact); } } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 15be77ff6ab..37f096c3e49 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -79,13 +79,13 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); - RegionView3D *rv3d = CTX_wm_region_data(C); + View3D *v3d = CTX_wm_view3d(C); TransVertStore tvs = {NULL}; TransVert *tv; float gridf, imat[3][3], bmat[3][3], vec[3]; int a; - gridf = rv3d->gridview; + gridf = ED_view3d_grid_scale(scene, v3d, NULL); if (obedit) { ViewLayer *view_layer = CTX_data_view_layer(C); @@ -493,11 +493,10 @@ void VIEW3D_OT_snap_selected_to_active(wmOperatorType *ot) static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - RegionView3D *rv3d = CTX_wm_region_data(C); View3D *v3d = CTX_wm_view3d(C); float gridf, *curs; - gridf = rv3d->gridview; + gridf = ED_view3d_grid_scale(scene, v3d, NULL); curs = ED_view3d_cursor3d_get(scene, v3d)->location; curs[0] = gridf * floorf(0.5f + curs[0] / gridf); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 294eebab68f..5816815f5bc 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4578,8 +4578,9 @@ static void initSnapSpatial(TransInfo *t, float r_snap[3]) RegionView3D *rv3d = t->ar->regiondata; if (rv3d) { + View3D *v3d = t->sa->spacedata.first; r_snap[0] = 0.0f; - r_snap[1] = rv3d->gridview * 1.0f; + r_snap[1] = ED_view3d_grid_scale(t->scene, v3d, NULL) * 1.0f; r_snap[2] = r_snap[1] * 0.1f; } } diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 03ed75d46a2..845f361a869 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -670,9 +670,11 @@ void ED_transform_calc_orientation_from_type_ex( } case V3D_MANIP_VIEW: { - copy_m3_m4(r_mat, rv3d->viewinv); - normalize_m3(r_mat); - ok = true; + if (rv3d != NULL) { + copy_m3_m4(r_mat, rv3d->viewinv); + normalize_m3(r_mat); + ok = true; + } break; } case V3D_MANIP_CURSOR: @@ -1457,8 +1459,10 @@ static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *gzgroup) if (ptr) { PropertyRNA *prop; - if ((prop = RNA_struct_find_property(ptr, "constraint_axis"))) { - RNA_property_boolean_set_array(ptr, prop, constraint_axis); + if (ELEM(true, UNPACK3(constraint_axis))) { + if ((prop = RNA_struct_find_property(ptr, "constraint_axis"))) { + RNA_property_boolean_set_array(ptr, prop, constraint_axis); + } } RNA_boolean_set(ptr, "release_confirm", 1); diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 6dfcfe11af2..33eb481e528 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -2655,6 +2655,9 @@ static short transform_snap_context_project_view3d_mixed_impl( negate_v4(new_clipplane); } + /* Small offset to simulate a kind of volume for edges and vertices. */ + new_clipplane[3] += 0.01f; + /* Try to snap only to the polygon. */ elem = snap_mesh_polygon( sctx, &snapdata, ob, obmat, diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 616f4eac2ad..446e8d66fd0 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -166,6 +166,10 @@ static void draw_uvs_shadow(Object *obedit) BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; + if (bm->totloop == 0) { + return; + } + const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -634,6 +638,10 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } } + if (bm->totloop == 0) { + return; + } + /* 2. draw colored faces */ if (sima->flag & SI_DRAW_STRETCH) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 3c5ba6a721f..80c443ab1eb 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -4397,7 +4397,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap = WM_keymap_find(keyconf, "UV Editor", 0, 0); + keymap = WM_keymap_ensure(keyconf, "UV Editor", 0, 0); keymap->poll = ED_operator_uvedit_can_uv_sculpt; #ifdef USE_WM_KEYMAP_27X diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index e57d004e503..a0b97b817fd 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -164,24 +164,24 @@ int BlenderFileLoader::countClippedFaces(float v1[3], float v2[3], float v3[3], sum += clip[i]; } switch (numClipped) { - case 0: - numTris = 1; // triangle - break; - case 1: - numTris = 2; // tetragon - break; - case 2: - if (sum == 0) - numTris = 3; // pentagon - else + case 0: numTris = 1; // triangle - break; - case 3: - if (sum == 3 || sum == -3) - numTris = 0; - else + break; + case 1: numTris = 2; // tetragon - break; + break; + case 2: + if (sum == 0) + numTris = 3; // pentagon + else + numTris = 1; // triangle + break; + case 3: + if (sum == 3 || sum == -3) + numTris = 0; + else + numTris = 2; // tetragon + break; } return numTris; } diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index d3f3b71c940..07776bfc1b7 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -34,7 +34,7 @@ extern "C" { #include "RNA_types.h" #include "DNA_camera_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_listBase.h" #include "DNA_linestyle_types.h" #include "DNA_material_types.h" @@ -193,17 +193,17 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer() } #endif switch (ob->type) { - case OB_MESH: - BKE_libblock_free(freestyle_bmain, ob); - BKE_libblock_free(freestyle_bmain, data); - break; - case OB_CAMERA: - BKE_libblock_free(freestyle_bmain, ob); - BKE_libblock_free(freestyle_bmain, data); - freestyle_scene->camera = NULL; - break; - default: - cerr << "Warning: unexpected object in the scene: " << name[0] << name[1] << ":" << (name + 2) << endl; + case OB_MESH: + BKE_libblock_free(freestyle_bmain, ob); + BKE_libblock_free(freestyle_bmain, data); + break; + case OB_CAMERA: + BKE_libblock_free(freestyle_bmain, ob); + BKE_libblock_free(freestyle_bmain, data); + freestyle_scene->camera = NULL; + break; + default: + cerr << "Warning: unexpected object in the scene: " << name[0] << name[1] << ":" << (name + 2) << endl; } } diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index b1c5de9d621..6d911ea04d2 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -41,8 +41,8 @@ extern "C" { #include "MEM_guardedalloc.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_freestyle_types.h" -#include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_text_types.h" @@ -147,12 +147,12 @@ static void init_view(Render *re) float thickness = 1.0f; switch (re->r.line_thickness_mode) { - case R_LINE_THICKNESS_ABSOLUTE: - thickness = re->r.unit_line_thickness * (re->r.size / 100.f); - break; - case R_LINE_THICKNESS_RELATIVE: - thickness = height / 480.f; - break; + case R_LINE_THICKNESS_ABSOLUTE: + thickness = re->r.unit_line_thickness * (re->r.size / 100.f); + break; + case R_LINE_THICKNESS_RELATIVE: + thickness = height / 480.f; + break; } g_freestyle.viewport[0] = g_freestyle.viewport[1] = 0; @@ -303,115 +303,115 @@ static void prepare(Render *re, ViewLayer *view_layer) int layer_count = 0; switch (config->mode) { - case FREESTYLE_CONTROL_SCRIPT_MODE: - if (G.debug & G_DEBUG_FREESTYLE) { - cout << "Modules :" << endl; - } - for (FreestyleModuleConfig *module_conf = (FreestyleModuleConfig *)config->modules.first; - module_conf; - module_conf = module_conf->next) - { - if (module_conf->script && module_conf->is_displayed) { - const char *id_name = module_conf->script->id.name + 2; - if (G.debug & G_DEBUG_FREESTYLE) { - cout << " " << layer_count + 1 << ": " << id_name; - if (module_conf->script->name) - cout << " (" << module_conf->script->name << ")"; - cout << endl; - } - controller->InsertStyleModule(layer_count, id_name, module_conf->script); - controller->toggleLayer(layer_count, true); - layer_count++; + case FREESTYLE_CONTROL_SCRIPT_MODE: + if (G.debug & G_DEBUG_FREESTYLE) { + cout << "Modules :" << endl; } - } - if (G.debug & G_DEBUG_FREESTYLE) { - cout << endl; - } - controller->setComputeRidgesAndValleysFlag((config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false); - controller->setComputeSuggestiveContoursFlag((config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false); - controller->setComputeMaterialBoundariesFlag((config->flags & FREESTYLE_MATERIAL_BOUNDARIES_FLAG) ? true : false); - break; - case FREESTYLE_CONTROL_EDITOR_MODE: - int use_ridges_and_valleys = 0; - int use_suggestive_contours = 0; - int use_material_boundaries = 0; - struct edge_type_condition conditions[] = { - {FREESTYLE_FE_SILHOUETTE, 0}, - {FREESTYLE_FE_BORDER, 0}, - {FREESTYLE_FE_CREASE, 0}, - {FREESTYLE_FE_RIDGE_VALLEY, 0}, - {FREESTYLE_FE_SUGGESTIVE_CONTOUR, 0}, - {FREESTYLE_FE_MATERIAL_BOUNDARY, 0}, - {FREESTYLE_FE_CONTOUR, 0}, - {FREESTYLE_FE_EXTERNAL_CONTOUR, 0}, - {FREESTYLE_FE_EDGE_MARK, 0} - }; - int num_edge_types = sizeof(conditions) / sizeof(struct edge_type_condition); - if (G.debug & G_DEBUG_FREESTYLE) { - cout << "Linesets:" << endl; - } - for (FreestyleLineSet *lineset = (FreestyleLineSet *)config->linesets.first; - lineset; - lineset = lineset->next) - { - if (lineset->flags & FREESTYLE_LINESET_ENABLED) { - if (G.debug & G_DEBUG_FREESTYLE) { - cout << " " << layer_count+1 << ": " << lineset->name << " - " << - (lineset->linestyle ? (lineset->linestyle->id.name + 2) : "<NULL>") << endl; - } - char *buffer = create_lineset_handler(view_layer->name, lineset->name); - controller->InsertStyleModule(layer_count, lineset->name, buffer); - controller->toggleLayer(layer_count, true); - MEM_freeN(buffer); - if (!(lineset->selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset->edge_types) { - ++use_ridges_and_valleys; - ++use_suggestive_contours; - ++use_material_boundaries; - } - else { - // conditions for feature edge selection by edge types - for (int i = 0; i < num_edge_types; i++) { - if (!(lineset->edge_types & conditions[i].edge_type)) - conditions[i].value = 0; // no condition specified - else if (!(lineset->exclude_edge_types & conditions[i].edge_type)) - conditions[i].value = 1; // condition: X - else - conditions[i].value = -1; // condition: NOT X + for (FreestyleModuleConfig *module_conf = (FreestyleModuleConfig *)config->modules.first; + module_conf; + module_conf = module_conf->next) + { + if (module_conf->script && module_conf->is_displayed) { + const char *id_name = module_conf->script->id.name + 2; + if (G.debug & G_DEBUG_FREESTYLE) { + cout << " " << layer_count + 1 << ": " << id_name; + if (module_conf->script->name) + cout << " (" << module_conf->script->name << ")"; + cout << endl; } - // logical operator for the selection conditions - bool logical_and = ((lineset->flags & FREESTYLE_LINESET_FE_AND) != 0); - // negation operator - if (lineset->flags & FREESTYLE_LINESET_FE_NOT) { - // convert an Exclusive condition into an Inclusive equivalent using De Morgan's laws: - // NOT (X OR Y) --> (NOT X) AND (NOT Y) - // NOT (X AND Y) --> (NOT X) OR (NOT Y) - for (int i = 0; i < num_edge_types; i++) - conditions[i].value *= -1; - logical_and = !logical_and; + controller->InsertStyleModule(layer_count, id_name, module_conf->script); + controller->toggleLayer(layer_count, true); + layer_count++; + } + } + if (G.debug & G_DEBUG_FREESTYLE) { + cout << endl; + } + controller->setComputeRidgesAndValleysFlag((config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false); + controller->setComputeSuggestiveContoursFlag((config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false); + controller->setComputeMaterialBoundariesFlag((config->flags & FREESTYLE_MATERIAL_BOUNDARIES_FLAG) ? true : false); + break; + case FREESTYLE_CONTROL_EDITOR_MODE: + int use_ridges_and_valleys = 0; + int use_suggestive_contours = 0; + int use_material_boundaries = 0; + struct edge_type_condition conditions[] = { + {FREESTYLE_FE_SILHOUETTE, 0}, + {FREESTYLE_FE_BORDER, 0}, + {FREESTYLE_FE_CREASE, 0}, + {FREESTYLE_FE_RIDGE_VALLEY, 0}, + {FREESTYLE_FE_SUGGESTIVE_CONTOUR, 0}, + {FREESTYLE_FE_MATERIAL_BOUNDARY, 0}, + {FREESTYLE_FE_CONTOUR, 0}, + {FREESTYLE_FE_EXTERNAL_CONTOUR, 0}, + {FREESTYLE_FE_EDGE_MARK, 0} + }; + int num_edge_types = sizeof(conditions) / sizeof(struct edge_type_condition); + if (G.debug & G_DEBUG_FREESTYLE) { + cout << "Linesets:" << endl; + } + for (FreestyleLineSet *lineset = (FreestyleLineSet *)config->linesets.first; + lineset; + lineset = lineset->next) + { + if (lineset->flags & FREESTYLE_LINESET_ENABLED) { + if (G.debug & G_DEBUG_FREESTYLE) { + cout << " " << layer_count+1 << ": " << lineset->name << " - " << + (lineset->linestyle ? (lineset->linestyle->id.name + 2) : "<NULL>") << endl; } - if (test_edge_type_conditions(conditions, num_edge_types, logical_and, - FREESTYLE_FE_RIDGE_VALLEY, true)) - { + char *buffer = create_lineset_handler(view_layer->name, lineset->name); + controller->InsertStyleModule(layer_count, lineset->name, buffer); + controller->toggleLayer(layer_count, true); + MEM_freeN(buffer); + if (!(lineset->selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset->edge_types) { ++use_ridges_and_valleys; - } - if (test_edge_type_conditions(conditions, num_edge_types, logical_and, - FREESTYLE_FE_SUGGESTIVE_CONTOUR, true)) - { ++use_suggestive_contours; - } - if (test_edge_type_conditions(conditions, num_edge_types, logical_and, - FREESTYLE_FE_MATERIAL_BOUNDARY, true)) - { ++use_material_boundaries; } + else { + // conditions for feature edge selection by edge types + for (int i = 0; i < num_edge_types; i++) { + if (!(lineset->edge_types & conditions[i].edge_type)) + conditions[i].value = 0; // no condition specified + else if (!(lineset->exclude_edge_types & conditions[i].edge_type)) + conditions[i].value = 1; // condition: X + else + conditions[i].value = -1; // condition: NOT X + } + // logical operator for the selection conditions + bool logical_and = ((lineset->flags & FREESTYLE_LINESET_FE_AND) != 0); + // negation operator + if (lineset->flags & FREESTYLE_LINESET_FE_NOT) { + // convert an Exclusive condition into an Inclusive equivalent using De Morgan's laws: + // NOT (X OR Y) --> (NOT X) AND (NOT Y) + // NOT (X AND Y) --> (NOT X) OR (NOT Y) + for (int i = 0; i < num_edge_types; i++) + conditions[i].value *= -1; + logical_and = !logical_and; + } + if (test_edge_type_conditions(conditions, num_edge_types, logical_and, + FREESTYLE_FE_RIDGE_VALLEY, true)) + { + ++use_ridges_and_valleys; + } + if (test_edge_type_conditions(conditions, num_edge_types, logical_and, + FREESTYLE_FE_SUGGESTIVE_CONTOUR, true)) + { + ++use_suggestive_contours; + } + if (test_edge_type_conditions(conditions, num_edge_types, logical_and, + FREESTYLE_FE_MATERIAL_BOUNDARY, true)) + { + ++use_material_boundaries; + } + } + layer_count++; } - layer_count++; } - } - controller->setComputeRidgesAndValleysFlag(use_ridges_and_valleys > 0); - controller->setComputeSuggestiveContoursFlag(use_suggestive_contours > 0); - controller->setComputeMaterialBoundariesFlag(use_material_boundaries > 0); - break; + controller->setComputeRidgesAndValleysFlag(use_ridges_and_valleys > 0); + controller->setComputeSuggestiveContoursFlag(use_suggestive_contours > 0); + controller->setComputeMaterialBoundariesFlag(use_material_boundaries > 0); + break; } // set parameters @@ -541,24 +541,24 @@ static int displayed_layer_count(ViewLayer *view_layer) int count = 0; switch (view_layer->freestyle_config.mode) { - case FREESTYLE_CONTROL_SCRIPT_MODE: - for (FreestyleModuleConfig *module = (FreestyleModuleConfig *)view_layer->freestyle_config.modules.first; - module; - module = module->next) - { - if (module->script && module->is_displayed) - count++; - } - break; - case FREESTYLE_CONTROL_EDITOR_MODE: - for (FreestyleLineSet *lineset = (FreestyleLineSet *)view_layer->freestyle_config.linesets.first; - lineset; - lineset = lineset->next) - { - if (lineset->flags & FREESTYLE_LINESET_ENABLED) - count++; - } - break; + case FREESTYLE_CONTROL_SCRIPT_MODE: + for (FreestyleModuleConfig *module = (FreestyleModuleConfig *)view_layer->freestyle_config.modules.first; + module; + module = module->next) + { + if (module->script && module->is_displayed) + count++; + } + break; + case FREESTYLE_CONTROL_EDITOR_MODE: + for (FreestyleLineSet *lineset = (FreestyleLineSet *)view_layer->freestyle_config.linesets.first; + lineset; + lineset = lineset->next) + { + if (lineset->flags & FREESTYLE_LINESET_ENABLED) + count++; + } + break; } return count; } diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp index 1866058a151..3695e85cd15 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp @@ -157,38 +157,38 @@ static int FrsMaterial_mathutils_get(BaseMathObject *bmo, int subtype) { BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_LINE: - bmo->data[0] = self->m->lineR(); - bmo->data[1] = self->m->lineG(); - bmo->data[2] = self->m->lineB(); - bmo->data[3] = self->m->lineA(); - break; - case MATHUTILS_SUBTYPE_DIFFUSE: - bmo->data[0] = self->m->diffuseR(); - bmo->data[1] = self->m->diffuseG(); - bmo->data[2] = self->m->diffuseB(); - bmo->data[3] = self->m->diffuseA(); - break; - case MATHUTILS_SUBTYPE_SPECULAR: - bmo->data[0] = self->m->specularR(); - bmo->data[1] = self->m->specularG(); - bmo->data[2] = self->m->specularB(); - bmo->data[3] = self->m->specularA(); - break; - case MATHUTILS_SUBTYPE_AMBIENT: - bmo->data[0] = self->m->ambientR(); - bmo->data[1] = self->m->ambientG(); - bmo->data[2] = self->m->ambientB(); - bmo->data[3] = self->m->ambientA(); - break; - case MATHUTILS_SUBTYPE_EMISSION: - bmo->data[0] = self->m->emissionR(); - bmo->data[1] = self->m->emissionG(); - bmo->data[2] = self->m->emissionB(); - bmo->data[3] = self->m->emissionA(); - break; - default: - return -1; + case MATHUTILS_SUBTYPE_LINE: + bmo->data[0] = self->m->lineR(); + bmo->data[1] = self->m->lineG(); + bmo->data[2] = self->m->lineB(); + bmo->data[3] = self->m->lineA(); + break; + case MATHUTILS_SUBTYPE_DIFFUSE: + bmo->data[0] = self->m->diffuseR(); + bmo->data[1] = self->m->diffuseG(); + bmo->data[2] = self->m->diffuseB(); + bmo->data[3] = self->m->diffuseA(); + break; + case MATHUTILS_SUBTYPE_SPECULAR: + bmo->data[0] = self->m->specularR(); + bmo->data[1] = self->m->specularG(); + bmo->data[2] = self->m->specularB(); + bmo->data[3] = self->m->specularA(); + break; + case MATHUTILS_SUBTYPE_AMBIENT: + bmo->data[0] = self->m->ambientR(); + bmo->data[1] = self->m->ambientG(); + bmo->data[2] = self->m->ambientB(); + bmo->data[3] = self->m->ambientA(); + break; + case MATHUTILS_SUBTYPE_EMISSION: + bmo->data[0] = self->m->emissionR(); + bmo->data[1] = self->m->emissionG(); + bmo->data[2] = self->m->emissionB(); + bmo->data[3] = self->m->emissionA(); + break; + default: + return -1; } return 0; } @@ -197,23 +197,23 @@ static int FrsMaterial_mathutils_set(BaseMathObject *bmo, int subtype) { BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_LINE: - self->m->setLine(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); - break; - case MATHUTILS_SUBTYPE_DIFFUSE: - self->m->setDiffuse(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); - break; - case MATHUTILS_SUBTYPE_SPECULAR: - self->m->setSpecular(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); - break; - case MATHUTILS_SUBTYPE_AMBIENT: - self->m->setAmbient(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); - break; - case MATHUTILS_SUBTYPE_EMISSION: - self->m->setEmission(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); - break; - default: - return -1; + case MATHUTILS_SUBTYPE_LINE: + self->m->setLine(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); + break; + case MATHUTILS_SUBTYPE_DIFFUSE: + self->m->setDiffuse(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); + break; + case MATHUTILS_SUBTYPE_SPECULAR: + self->m->setSpecular(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); + break; + case MATHUTILS_SUBTYPE_AMBIENT: + self->m->setAmbient(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); + break; + case MATHUTILS_SUBTYPE_EMISSION: + self->m->setEmission(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); + break; + default: + return -1; } return 0; } @@ -222,38 +222,38 @@ static int FrsMaterial_mathutils_get_index(BaseMathObject *bmo, int subtype, int { BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_LINE: - { - const float *color = self->m->line(); - bmo->data[index] = color[index]; - } - break; - case MATHUTILS_SUBTYPE_DIFFUSE: - { - const float *color = self->m->diffuse(); - bmo->data[index] = color[index]; - } - break; - case MATHUTILS_SUBTYPE_SPECULAR: - { - const float *color = self->m->specular(); - bmo->data[index] = color[index]; - } - break; - case MATHUTILS_SUBTYPE_AMBIENT: - { - const float *color = self->m->ambient(); - bmo->data[index] = color[index]; - } - break; - case MATHUTILS_SUBTYPE_EMISSION: - { - const float *color = self->m->emission(); - bmo->data[index] = color[index]; - } - break; - default: - return -1; + case MATHUTILS_SUBTYPE_LINE: + { + const float *color = self->m->line(); + bmo->data[index] = color[index]; + } + break; + case MATHUTILS_SUBTYPE_DIFFUSE: + { + const float *color = self->m->diffuse(); + bmo->data[index] = color[index]; + } + break; + case MATHUTILS_SUBTYPE_SPECULAR: + { + const float *color = self->m->specular(); + bmo->data[index] = color[index]; + } + break; + case MATHUTILS_SUBTYPE_AMBIENT: + { + const float *color = self->m->ambient(); + bmo->data[index] = color[index]; + } + break; + case MATHUTILS_SUBTYPE_EMISSION: + { + const float *color = self->m->emission(); + bmo->data[index] = color[index]; + } + break; + default: + return -1; } return 0; } @@ -263,33 +263,33 @@ static int FrsMaterial_mathutils_set_index(BaseMathObject *bmo, int subtype, int BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user; float color[4]; switch (subtype) { - case MATHUTILS_SUBTYPE_LINE: - copy_v4_v4(color, self->m->line()); - color[index] = bmo->data[index]; - self->m->setLine(color[0], color[1], color[2], color[3]); - break; - case MATHUTILS_SUBTYPE_DIFFUSE: - copy_v4_v4(color, self->m->diffuse()); - color[index] = bmo->data[index]; - self->m->setDiffuse(color[0], color[1], color[2], color[3]); - break; - case MATHUTILS_SUBTYPE_SPECULAR: - copy_v4_v4(color, self->m->specular()); - color[index] = bmo->data[index]; - self->m->setSpecular(color[0], color[1], color[2], color[3]); - break; - case MATHUTILS_SUBTYPE_AMBIENT: - copy_v4_v4(color, self->m->ambient()); - color[index] = bmo->data[index]; - self->m->setAmbient(color[0], color[1], color[2], color[3]); - break; - case MATHUTILS_SUBTYPE_EMISSION: - copy_v4_v4(color, self->m->emission()); - color[index] = bmo->data[index]; - self->m->setEmission(color[0], color[1], color[2], color[3]); - break; - default: - return -1; + case MATHUTILS_SUBTYPE_LINE: + copy_v4_v4(color, self->m->line()); + color[index] = bmo->data[index]; + self->m->setLine(color[0], color[1], color[2], color[3]); + break; + case MATHUTILS_SUBTYPE_DIFFUSE: + copy_v4_v4(color, self->m->diffuse()); + color[index] = bmo->data[index]; + self->m->setDiffuse(color[0], color[1], color[2], color[3]); + break; + case MATHUTILS_SUBTYPE_SPECULAR: + copy_v4_v4(color, self->m->specular()); + color[index] = bmo->data[index]; + self->m->setSpecular(color[0], color[1], color[2], color[3]); + break; + case MATHUTILS_SUBTYPE_AMBIENT: + copy_v4_v4(color, self->m->ambient()); + color[index] = bmo->data[index]; + self->m->setAmbient(color[0], color[1], color[2], color[3]); + break; + case MATHUTILS_SUBTYPE_EMISSION: + copy_v4_v4(color, self->m->emission()); + color[index] = bmo->data[index]; + self->m->setEmission(color[0], color[1], color[2], color[3]); + break; + default: + return -1; } return 0; } diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp index 43313ef5213..fb7eb49127c 100644 --- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp +++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp @@ -391,17 +391,17 @@ static int StrokeAttribute_mathutils_get(BaseMathObject *bmo, int subtype) { BPy_StrokeAttribute *self = (BPy_StrokeAttribute *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_COLOR: - bmo->data[0] = self->sa->getColorR(); - bmo->data[1] = self->sa->getColorG(); - bmo->data[2] = self->sa->getColorB(); - break; - case MATHUTILS_SUBTYPE_THICKNESS: - bmo->data[0] = self->sa->getThicknessR(); - bmo->data[1] = self->sa->getThicknessL(); - break; - default: - return -1; + case MATHUTILS_SUBTYPE_COLOR: + bmo->data[0] = self->sa->getColorR(); + bmo->data[1] = self->sa->getColorG(); + bmo->data[2] = self->sa->getColorB(); + break; + case MATHUTILS_SUBTYPE_THICKNESS: + bmo->data[0] = self->sa->getThicknessR(); + bmo->data[1] = self->sa->getThicknessL(); + break; + default: + return -1; } return 0; } @@ -410,14 +410,14 @@ static int StrokeAttribute_mathutils_set(BaseMathObject *bmo, int subtype) { BPy_StrokeAttribute *self = (BPy_StrokeAttribute *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_COLOR: - self->sa->setColor(bmo->data[0], bmo->data[1], bmo->data[2]); - break; - case MATHUTILS_SUBTYPE_THICKNESS: - self->sa->setThickness(bmo->data[0], bmo->data[1]); - break; - default: - return -1; + case MATHUTILS_SUBTYPE_COLOR: + self->sa->setColor(bmo->data[0], bmo->data[1], bmo->data[2]); + break; + case MATHUTILS_SUBTYPE_THICKNESS: + self->sa->setThickness(bmo->data[0], bmo->data[1]); + break; + default: + return -1; } return 0; } @@ -426,25 +426,25 @@ static int StrokeAttribute_mathutils_get_index(BaseMathObject *bmo, int subtype, { BPy_StrokeAttribute *self = (BPy_StrokeAttribute *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_COLOR: - switch (index) { - case 0: bmo->data[0] = self->sa->getColorR(); break; - case 1: bmo->data[1] = self->sa->getColorG(); break; - case 2: bmo->data[2] = self->sa->getColorB(); break; + case MATHUTILS_SUBTYPE_COLOR: + switch (index) { + case 0: bmo->data[0] = self->sa->getColorR(); break; + case 1: bmo->data[1] = self->sa->getColorG(); break; + case 2: bmo->data[2] = self->sa->getColorB(); break; + default: + return -1; + } + break; + case MATHUTILS_SUBTYPE_THICKNESS: + switch (index) { + case 0: bmo->data[0] = self->sa->getThicknessR(); break; + case 1: bmo->data[1] = self->sa->getThicknessL(); break; + default: + return -1; + } + break; default: return -1; - } - break; - case MATHUTILS_SUBTYPE_THICKNESS: - switch (index) { - case 0: bmo->data[0] = self->sa->getThicknessR(); break; - case 1: bmo->data[1] = self->sa->getThicknessL(); break; - default: - return -1; - } - break; - default: - return -1; } return 0; } @@ -453,23 +453,23 @@ static int StrokeAttribute_mathutils_set_index(BaseMathObject *bmo, int subtype, { BPy_StrokeAttribute *self = (BPy_StrokeAttribute *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_COLOR: - { - float r = (index == 0) ? bmo->data[0] : self->sa->getColorR(); - float g = (index == 1) ? bmo->data[1] : self->sa->getColorG(); - float b = (index == 2) ? bmo->data[2] : self->sa->getColorB(); - self->sa->setColor(r, g, b); - } - break; - case MATHUTILS_SUBTYPE_THICKNESS: - { - float tr = (index == 0) ? bmo->data[0] : self->sa->getThicknessR(); - float tl = (index == 1) ? bmo->data[1] : self->sa->getThicknessL(); - self->sa->setThickness(tr, tl); - } - break; - default: - return -1; + case MATHUTILS_SUBTYPE_COLOR: + { + float r = (index == 0) ? bmo->data[0] : self->sa->getColorR(); + float g = (index == 1) ? bmo->data[1] : self->sa->getColorG(); + float b = (index == 2) ? bmo->data[2] : self->sa->getColorB(); + self->sa->setColor(r, g, b); + } + break; + case MATHUTILS_SUBTYPE_THICKNESS: + { + float tr = (index == 0) ? bmo->data[0] : self->sa->getThicknessR(); + float tl = (index == 1) ? bmo->data[1] : self->sa->getThicknessL(); + self->sa->setThickness(tr, tl); + } + break; + default: + return -1; } return 0; } diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp index 33300ea70b5..d83a5a5174c 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp @@ -158,18 +158,18 @@ static int SVertex_mathutils_get(BaseMathObject *bmo, int subtype) { BPy_SVertex *self = (BPy_SVertex *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_POINT3D: - bmo->data[0] = self->sv->getX(); - bmo->data[1] = self->sv->getY(); - bmo->data[2] = self->sv->getZ(); - break; - case MATHUTILS_SUBTYPE_POINT2D: - bmo->data[0] = self->sv->getProjectedX(); - bmo->data[1] = self->sv->getProjectedY(); - bmo->data[2] = self->sv->getProjectedZ(); - break; - default: - return -1; + case MATHUTILS_SUBTYPE_POINT3D: + bmo->data[0] = self->sv->getX(); + bmo->data[1] = self->sv->getY(); + bmo->data[2] = self->sv->getZ(); + break; + case MATHUTILS_SUBTYPE_POINT2D: + bmo->data[0] = self->sv->getProjectedX(); + bmo->data[1] = self->sv->getProjectedY(); + bmo->data[2] = self->sv->getProjectedZ(); + break; + default: + return -1; } return 0; } @@ -178,20 +178,20 @@ static int SVertex_mathutils_set(BaseMathObject *bmo, int subtype) { BPy_SVertex *self = (BPy_SVertex *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_POINT3D: - { - Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); - self->sv->setPoint3D(p); - } - break; - case MATHUTILS_SUBTYPE_POINT2D: - { - Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); - self->sv->setPoint2D(p); - } - break; - default: - return -1; + case MATHUTILS_SUBTYPE_POINT3D: + { + Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); + self->sv->setPoint3D(p); + } + break; + case MATHUTILS_SUBTYPE_POINT2D: + { + Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); + self->sv->setPoint2D(p); + } + break; + default: + return -1; } return 0; } @@ -200,26 +200,26 @@ static int SVertex_mathutils_get_index(BaseMathObject *bmo, int subtype, int ind { BPy_SVertex *self = (BPy_SVertex *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_POINT3D: - switch (index) { - case 0: bmo->data[0] = self->sv->getX(); break; - case 1: bmo->data[1] = self->sv->getY(); break; - case 2: bmo->data[2] = self->sv->getZ(); break; + case MATHUTILS_SUBTYPE_POINT3D: + switch (index) { + case 0: bmo->data[0] = self->sv->getX(); break; + case 1: bmo->data[1] = self->sv->getY(); break; + case 2: bmo->data[2] = self->sv->getZ(); break; + default: + return -1; + } + break; + case MATHUTILS_SUBTYPE_POINT2D: + switch (index) { + case 0: bmo->data[0] = self->sv->getProjectedX(); break; + case 1: bmo->data[1] = self->sv->getProjectedY(); break; + case 2: bmo->data[2] = self->sv->getProjectedZ(); break; + default: + return -1; + } + break; default: return -1; - } - break; - case MATHUTILS_SUBTYPE_POINT2D: - switch (index) { - case 0: bmo->data[0] = self->sv->getProjectedX(); break; - case 1: bmo->data[1] = self->sv->getProjectedY(); break; - case 2: bmo->data[2] = self->sv->getProjectedZ(); break; - default: - return -1; - } - break; - default: - return -1; } return 0; } @@ -228,22 +228,22 @@ static int SVertex_mathutils_set_index(BaseMathObject *bmo, int subtype, int ind { BPy_SVertex *self = (BPy_SVertex *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_POINT3D: - { - Vec3r p(self->sv->point3D()); - p[index] = bmo->data[index]; - self->sv->setPoint3D(p); - } - break; - case MATHUTILS_SUBTYPE_POINT2D: - { - Vec3r p(self->sv->point2D()); - p[index] = bmo->data[index]; - self->sv->setPoint2D(p); - } - break; - default: - return -1; + case MATHUTILS_SUBTYPE_POINT3D: + { + Vec3r p(self->sv->point3D()); + p[index] = bmo->data[index]; + self->sv->setPoint3D(p); + } + break; + case MATHUTILS_SUBTYPE_POINT2D: + { + Vec3r p(self->sv->point2D()); + p[index] = bmo->data[index]; + self->sv->setPoint2D(p); + } + break; + default: + return -1; } return 0; } diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp index ba773d4f4cf..09e33db529d 100644 --- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp @@ -186,10 +186,10 @@ static int StrokeVertex_mathutils_get_index(BaseMathObject *bmo, int /*subtype*/ { BPy_StrokeVertex *self = (BPy_StrokeVertex *)bmo->cb_user; switch (index) { - case 0: bmo->data[0] = (float)self->sv->x(); break; - case 1: bmo->data[1] = (float)self->sv->y(); break; - default: - return -1; + case 0: bmo->data[0] = (float)self->sv->x(); break; + case 1: bmo->data[1] = (float)self->sv->y(); break; + default: + return -1; } return 0; } @@ -198,10 +198,10 @@ static int StrokeVertex_mathutils_set_index(BaseMathObject *bmo, int /*subtype*/ { BPy_StrokeVertex *self = (BPy_StrokeVertex *)bmo->cb_user; switch (index) { - case 0: self->sv->setX((real)bmo->data[0]); break; - case 1: self->sv->setY((real)bmo->data[1]); break; - default: - return -1; + case 0: self->sv->setX((real)bmo->data[0]); break; + case 1: self->sv->setY((real)bmo->data[1]); break; + default: + return -1; } return 0; } diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp index acdd5989511..319eee2945e 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp @@ -110,24 +110,24 @@ static int FEdgeSharp_mathutils_get(BaseMathObject *bmo, int subtype) { BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_NORMAL_A: - { - Vec3r p(self->fes->normalA()); - bmo->data[0] = p[0]; - bmo->data[1] = p[1]; - bmo->data[2] = p[2]; - } - break; - case MATHUTILS_SUBTYPE_NORMAL_B: - { - Vec3r p(self->fes->normalB()); - bmo->data[0] = p[0]; - bmo->data[1] = p[1]; - bmo->data[2] = p[2]; - } - break; - default: - return -1; + case MATHUTILS_SUBTYPE_NORMAL_A: + { + Vec3r p(self->fes->normalA()); + bmo->data[0] = p[0]; + bmo->data[1] = p[1]; + bmo->data[2] = p[2]; + } + break; + case MATHUTILS_SUBTYPE_NORMAL_B: + { + Vec3r p(self->fes->normalB()); + bmo->data[0] = p[0]; + bmo->data[1] = p[1]; + bmo->data[2] = p[2]; + } + break; + default: + return -1; } return 0; } @@ -136,20 +136,20 @@ static int FEdgeSharp_mathutils_set(BaseMathObject *bmo, int subtype) { BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_NORMAL_A: - { - Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); - self->fes->setNormalA(p); - } - break; - case MATHUTILS_SUBTYPE_NORMAL_B: - { - Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); - self->fes->setNormalB(p); - } - break; - default: - return -1; + case MATHUTILS_SUBTYPE_NORMAL_A: + { + Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); + self->fes->setNormalA(p); + } + break; + case MATHUTILS_SUBTYPE_NORMAL_B: + { + Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); + self->fes->setNormalB(p); + } + break; + default: + return -1; } return 0; } @@ -158,20 +158,20 @@ static int FEdgeSharp_mathutils_get_index(BaseMathObject *bmo, int subtype, int { BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_NORMAL_A: - { - Vec3r p(self->fes->normalA()); - bmo->data[index] = p[index]; - } - break; - case MATHUTILS_SUBTYPE_NORMAL_B: - { - Vec3r p(self->fes->normalB()); - bmo->data[index] = p[index]; - } - break; - default: - return -1; + case MATHUTILS_SUBTYPE_NORMAL_A: + { + Vec3r p(self->fes->normalA()); + bmo->data[index] = p[index]; + } + break; + case MATHUTILS_SUBTYPE_NORMAL_B: + { + Vec3r p(self->fes->normalB()); + bmo->data[index] = p[index]; + } + break; + default: + return -1; } return 0; } @@ -180,22 +180,22 @@ static int FEdgeSharp_mathutils_set_index(BaseMathObject *bmo, int subtype, int { BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; switch (subtype) { - case MATHUTILS_SUBTYPE_NORMAL_A: - { - Vec3r p(self->fes->normalA()); - p[index] = bmo->data[index]; - self->fes->setNormalA(p); - } - break; - case MATHUTILS_SUBTYPE_NORMAL_B: - { - Vec3r p(self->fes->normalB()); - p[index] = bmo->data[index]; - self->fes->setNormalB(p); - } - break; - default: - return -1; + case MATHUTILS_SUBTYPE_NORMAL_A: + { + Vec3r p(self->fes->normalA()); + p[index] = bmo->data[index]; + self->fes->setNormalA(p); + } + break; + case MATHUTILS_SUBTYPE_NORMAL_B: + { + Vec3r p(self->fes->normalB()); + p[index] = bmo->data[index]; + self->fes->setNormalB(p); + } + break; + default: + return -1; } return 0; } diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp index 1eeb6805e7d..d179e8b7f18 100644 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp @@ -573,7 +573,8 @@ void FEdgeXDetector::ProcessSuggestiveContourFace(WXFace *iFace) real threshold = _meanKr; if (faceLayer->nPosDotP()!=numVertices) { if ((fabs(faceLayer->dotP(0)) < threshold) && (fabs(faceLayer->dotP(1)) < threshold) && - (fabs(faceLayer->dotP(2)) < threshold)) { + (fabs(faceLayer->dotP(2)) < threshold)) + { faceLayer->ReplaceDotP(0, 0); faceLayer->ReplaceDotP(1, 0); faceLayer->ReplaceDotP(2, 0); diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h index 06ab3183027..16c9699dcef 100644 --- a/source/blender/freestyle/intern/view_map/ViewMap.h +++ b/source/blender/freestyle/intern/view_map/ViewMap.h @@ -1660,7 +1660,7 @@ void ViewShape::SplitEdge(FEdge *fe, const vector<TVertex*>& iViewVertices, vect sv = sv2; } else { - // if the shape is the same we can safely differ the two vertices using their ids: + // if the shape is the same we can safely differ the two vertices using their ids: if (sv->getId() != fe->vertexA()->getId()) sv = sv2; } diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index 5b7576ccd3d..f5239b970f5 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -1947,7 +1947,8 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, Grid *iGrid, real eps int viewport[4]; SilhouetteGeomEngine::retrieveViewport(viewport); if ((A.x() < viewport[0]) || (A.x() > viewport[2]) || (A.y() < viewport[1]) || (A.y() > viewport[3]) || - (B.x() < viewport[0]) || (B.x() > viewport[2]) || (B.y() < viewport[1]) || (B.y() > viewport[3])) { + (B.x() < viewport[0]) || (B.x() > viewport[2]) || (B.y() < viewport[1]) || (B.y() > viewport[3])) + { cerr << "Warning: point is out of the grid for fedge " << fe->getId() << endl; //return 0; } diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 5ad91d4e01b..44689a1d091 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -43,6 +43,7 @@ set(SRC intern/MOD_gpencil_util.h intern/MOD_gpencil_util.c + intern/MOD_gpencilarmature.c intern/MOD_gpencilnoise.c intern/MOD_gpencilsubdiv.c intern/MOD_gpencilsimplify.c diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h index 73386601d10..968f7e73544 100644 --- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h +++ b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h @@ -44,6 +44,7 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Mirror; extern GpencilModifierTypeInfo modifierType_Gpencil_Smooth; extern GpencilModifierTypeInfo modifierType_Gpencil_Hook; extern GpencilModifierTypeInfo modifierType_Gpencil_Offset; +extern GpencilModifierTypeInfo modifierType_Gpencil_Armature; /* MOD_gpencil_util.c */ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c index 151218c06e4..5aa9073eacb 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c @@ -45,6 +45,7 @@ #include "DNA_gpencil_types.h" #include "DNA_gpencil_modifier_types.h" +#include "BKE_deform.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_object.h" @@ -76,6 +77,7 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]) INIT_GP_TYPE(Smooth); INIT_GP_TYPE(Hook); INIT_GP_TYPE(Offset); + INIT_GP_TYPE(Armature); #undef INIT_GP_TYPE } @@ -121,12 +123,13 @@ bool is_stroke_affected_by_modifier( } /* verify if valid vertex group *and return weight */ -float get_modifier_point_weight(MDeformVert *dvert, int inverse, int vindex) +float get_modifier_point_weight(MDeformVert *dvert, bool inverse, int def_nr) { float weight = 1.0f; - if (vindex >= 0) { - weight = BKE_gpencil_vgroup_use_index(dvert, vindex); + if (def_nr != -1) { + MDeformWeight *dw = defvert_find_index(dvert, def_nr); + weight = dw ? dw->weight : -1.0f; if ((weight >= 0.0f) && (inverse == 1)) { return -1.0f; } @@ -147,8 +150,8 @@ float get_modifier_point_weight(MDeformVert *dvert, int inverse, int vindex) /* set material when apply modifiers (used in tint and color modifier) */ void gpencil_apply_modifier_material( - Main *bmain, Object *ob, Material *mat, - GHash *gh_color, bGPDstroke *gps, bool crt_material) + Main *bmain, Object *ob, Material *mat, + GHash *gh_color, bGPDstroke *gps, bool crt_material) { MaterialGPencilStyle *gp_style = mat->gp_style; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h index 1ca9febbdca..95772d141f1 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h @@ -45,10 +45,10 @@ bool is_stroke_affected_by_modifier( struct Object *ob, char *mlayername, int mpassindex, int minpoints, bGPDlayer *gpl, bGPDstroke *gps, bool inv1, bool inv2); -float get_modifier_point_weight(struct MDeformVert *dvert, int inverse, int vindex); +float get_modifier_point_weight(struct MDeformVert *dvert, bool inverse, int def_nr); void gpencil_apply_modifier_material( - struct Main *bmain, struct Object *ob, struct Material *mat, - struct GHash *gh_color, struct bGPDstroke *gps, bool crt_material); + struct Main *bmain, struct Object *ob, struct Material *mat, + struct GHash *gh_color, struct bGPDstroke *gps, bool crt_material); #endif /* __MOD_GPENCIL_UTIL_H__ */ diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c new file mode 100644 index 00000000000..4ae48e73d0f --- /dev/null +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c @@ -0,0 +1,205 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018, Blender Foundation + * This is a new part of Blender + * + * Contributor(s): Antonio Vazquez + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/gpencil_modifiers/intern/MOD_gpencilarmature.c + * \ingroup modifiers + */ + +#include <stdio.h> + +#include "DNA_armature_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_scene_types.h" +#include "DNA_object_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_gpencil_modifier_types.h" +#include "DNA_modifier_types.h" +#include "BLI_math.h" + +#include "BLI_listbase.h" +#include "BLI_task.h" +#include "BLI_utildefines.h" + +#include "BKE_lattice.h" +#include "BKE_context.h" +#include "BKE_gpencil.h" +#include "BKE_gpencil_modifier.h" +#include "BKE_modifier.h" +#include "BKE_library_query.h" +#include "BKE_scene.h" +#include "BKE_main.h" + +#include "MEM_guardedalloc.h" + +#include "MOD_gpencil_util.h" +#include "MOD_gpencil_modifiertypes.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" + +static void initData(GpencilModifierData *md) +{ + ArmatureGpencilModifierData *gpmd = (ArmatureGpencilModifierData *)md; + gpmd->object = NULL; + gpmd->deformflag = ARM_DEF_VGROUP; +} + +static void copyData(const GpencilModifierData *md, GpencilModifierData *target) +{ + BKE_gpencil_modifier_copyData_generic(md, target); +} + +static void gpencil_deform_verts( + ArmatureGpencilModifierData *mmd, Object *target, + bGPDstroke *gps) +{ + bGPDspoint *pt = gps->points; + float *all_vert_coords = MEM_callocN(sizeof(float) * 3 * gps->totpoints, __func__); + int i; + + BKE_gpencil_dvert_ensure(gps); + + /* prepare array of points */ + for (i = 0; i < gps->totpoints; i++, pt++) { + float *pt_coords = &all_vert_coords[3 * i]; + float co[3]; + copy_v3_v3(co, &pt->x); + copy_v3_v3(pt_coords, co); + } + + /* deform verts */ + armature_deform_verts(mmd->object, target, NULL, + (float(*)[3])all_vert_coords, + NULL, gps->totpoints, + mmd->deformflag, + (float(*)[3])mmd->prevCos, + mmd->vgname, gps); + + /* Apply deformed coordinates */ + pt = gps->points; + for (i = 0; i < gps->totpoints; i++, pt++) { + float *pt_coords = &all_vert_coords[3 * i]; + copy_v3_v3(&pt->x, pt_coords); + } + + MEM_SAFE_FREE(all_vert_coords); + +} + +/* deform stroke */ +static void deformStroke( + GpencilModifierData *md, Depsgraph *UNUSED(depsgraph), + Object *ob, bGPDlayer *UNUSED(gpl), bGPDstroke *gps) +{ + ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md; + if (!mmd->object) { + return; + } + + gpencil_deform_verts(mmd, ob, gps); +} + +static void bakeModifier( + Main *bmain, Depsgraph *depsgraph, + GpencilModifierData *md, Object *ob) +{ + ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md; + Scene *scene = DEG_get_evaluated_scene(depsgraph); + bGPdata *gpd = ob->data; + int oldframe = (int)DEG_get_ctime(depsgraph); + + if (mmd->object == NULL) + return; + + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { + /* apply armature effects on this frame + * NOTE: this assumes that we don't want armature animation on non-keyframed frames + */ + CFRA = gpf->framenum; + BKE_scene_graph_update_for_newframe(depsgraph, bmain); + + /* compute armature effects on this frame */ + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { + deformStroke(md, depsgraph, ob, gpl, gps); + } + } + } + + /* return frame state and DB to original state */ + CFRA = oldframe; + BKE_scene_graph_update_for_newframe(depsgraph, bmain); +} + +static bool isDisabled(GpencilModifierData *md, int UNUSED(userRenderParams)) +{ + ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md; + + return !mmd->object; +} + +static void updateDepsgraph(GpencilModifierData *md, const ModifierUpdateDepsgraphContext *ctx) +{ + ArmatureGpencilModifierData *lmd = (ArmatureGpencilModifierData *)md; + if (lmd->object != NULL) { + DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier"); + DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_TRANSFORM, "Armature Modifier"); + } + DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Armature Modifier"); +} + +static void foreachObjectLink( + GpencilModifierData *md, Object *ob, + ObjectWalkFunc walk, void *userData) +{ + ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md; + + walk(userData, ob, &mmd->object, IDWALK_CB_NOP); +} + +GpencilModifierTypeInfo modifierType_Gpencil_Armature = { + /* name */ "Armature", + /* structName */ "ArmatureGpencilModifierData", + /* structSize */ sizeof(ArmatureGpencilModifierData), + /* type */ eGpencilModifierTypeType_Gpencil, + /* flags */ 0, + + /* copyData */ copyData, + + /* deformStroke */ deformStroke, + /* generateStrokes */ NULL, + /* bakeModifier */ bakeModifier, + + /* initData */ initData, + /* freeData */ NULL, + /* isDisabled */ isDisabled, + /* updateDepsgraph */ updateDepsgraph, + /* dependsOnTime */ NULL, + /* foreachObjectLink */ foreachObjectLink, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, +}; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c index 945afec002d..6435ca1ce70 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c @@ -118,7 +118,10 @@ static void gpf_clear_all_strokes(bGPDframe *gpf) static void reduce_stroke_points(bGPDstroke *gps, const int num_points, const eBuildGpencil_Transition transition) { bGPDspoint *new_points = MEM_callocN(sizeof(bGPDspoint) * num_points, __func__); - MDeformVert *new_dvert = MEM_callocN(sizeof(MDeformVert) * num_points, __func__); + MDeformVert *new_dvert = NULL; + if (gps->dvert != NULL) { + new_dvert = MEM_callocN(sizeof(MDeformVert) * num_points, __func__); + } /* Which end should points be removed from */ // TODO: free stroke weights @@ -128,14 +131,15 @@ static void reduce_stroke_points(bGPDstroke *gps, const int num_points, const eB { /* copy over point data */ memcpy(new_points, gps->points, sizeof(bGPDspoint) * num_points); - memcpy(new_dvert, gps->dvert, sizeof(MDeformVert) * num_points); + if (gps->dvert != NULL) { + memcpy(new_dvert, gps->dvert, sizeof(MDeformVert) * num_points); - /* free unused point weights */ - for (int i = num_points; i < gps->totpoints; i++) { - MDeformVert *dvert = &gps->dvert[i]; - BKE_gpencil_free_point_weights(dvert); + /* free unused point weights */ + for (int i = num_points; i < gps->totpoints; i++) { + MDeformVert *dvert = &gps->dvert[i]; + BKE_gpencil_free_point_weights(dvert); + } } - break; } @@ -149,14 +153,15 @@ static void reduce_stroke_points(bGPDstroke *gps, const int num_points, const eB /* copy over point data */ memcpy(new_points, gps->points + offset, sizeof(bGPDspoint) * num_points); - memcpy(new_dvert, gps->dvert + offset, sizeof(MDeformVert) * num_points); + if (gps->dvert != NULL) { + memcpy(new_dvert, gps->dvert + offset, sizeof(MDeformVert) * num_points); - /* free unused weights */ - for (int i = 0; i < offset; i++) { - MDeformVert *dvert = &gps->dvert[i]; - BKE_gpencil_free_point_weights(dvert); + /* free unused weights */ + for (int i = 0; i < offset; i++) { + MDeformVert *dvert = &gps->dvert[i]; + BKE_gpencil_free_point_weights(dvert); + } } - break; } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c index 46d452545e2..1ba2a08acdb 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c @@ -203,8 +203,7 @@ static void deformStroke( return; } - int vindex = defgroup_name_index(ob, mmd->vgname); - float weight = 1.0f; + const int def_nr = defgroup_name_index(ob, mmd->vgname); bPoseChannel *pchan = BKE_pose_channel_find_name(mmd->object->pose, mmd->subtarget); float dmat[4][4]; @@ -253,8 +252,8 @@ static void deformStroke( MDeformVert *dvert = &gps->dvert[i]; /* verify vertex group */ - weight = get_modifier_point_weight(dvert, (int)((mmd->flag & GP_HOOK_INVERT_VGROUP) != 0), vindex); - if (weight < 0) { + const float weight = get_modifier_point_weight(dvert, (mmd->flag & GP_HOOK_INVERT_VGROUP) != 0, def_nr); + if (weight < 0.0f) { continue; } gp_hook_co_apply(&tData, weight, pt); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c index 33bdb9c861d..55836dce1cd 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c @@ -79,8 +79,7 @@ static void deformStroke( Object *ob, bGPDlayer *gpl, bGPDstroke *gps) { LatticeGpencilModifierData *mmd = (LatticeGpencilModifierData *)md; - int vindex = defgroup_name_index(ob, mmd->vgname); - float weight = 1.0f; + const int def_nr = defgroup_name_index(ob, mmd->vgname); if (!is_stroke_affected_by_modifier(ob, mmd->layername, mmd->pass_index, 3, gpl, gps, @@ -98,11 +97,10 @@ static void deformStroke( MDeformVert *dvert = &gps->dvert[i]; /* verify vertex group */ - weight = get_modifier_point_weight(dvert, (int)((mmd->flag & GP_LATTICE_INVERT_VGROUP) != 0), vindex); - if (weight < 0) { + const float weight = get_modifier_point_weight(dvert, (mmd->flag & GP_LATTICE_INVERT_VGROUP) != 0, def_nr); + if (weight < 0.0f) { continue; } - calc_latt_deform((struct LatticeDeformData *)mmd->cache_data, &pt->x, mmd->strength * weight); } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c index be361498578..d2e74a1de66 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c @@ -110,8 +110,7 @@ static void deformStroke( #endif int sc_frame = 0; int sc_diff = 0; - int vindex = defgroup_name_index(ob, mmd->vgname); - float weight = 1.0f; + const int def_nr = defgroup_name_index(ob, mmd->vgname); /* Random generator, only init once. */ if (mmd->rng == NULL) { @@ -154,8 +153,8 @@ static void deformStroke( } /* verify vertex group */ - weight = get_modifier_point_weight(dvert, (int)((mmd->flag & GP_NOISE_INVERT_VGROUP) != 0), vindex); - if (weight < 0) { + const float weight = get_modifier_point_weight(dvert, (mmd->flag & GP_NOISE_INVERT_VGROUP) != 0, def_nr); + if (weight < 0.0f) { continue; } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c index a31f889c48a..f59056b2845 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c @@ -72,7 +72,7 @@ static void deformStroke( Object *ob, bGPDlayer *gpl, bGPDstroke *gps) { OffsetGpencilModifierData *mmd = (OffsetGpencilModifierData *)md; - int vindex = defgroup_name_index(ob, mmd->vgname); + const int def_nr = defgroup_name_index(ob, mmd->vgname); float mat[4][4]; float loc[3], rot[3], scale[3]; @@ -89,8 +89,8 @@ static void deformStroke( MDeformVert *dvert = &gps->dvert[i]; /* verify vertex group */ - float weight = get_modifier_point_weight(dvert, (int)((mmd->flag & GP_OFFSET_INVERT_VGROUP) != 0), vindex); - if (weight < 0) { + const float weight = get_modifier_point_weight(dvert, (mmd->flag & GP_OFFSET_INVERT_VGROUP) != 0, def_nr); + if (weight < 0.0f) { continue; } /* calculate matrix */ diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c index e0484e19959..19e3b1bb384 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c @@ -75,7 +75,7 @@ static void deformStroke( Object *ob, bGPDlayer *gpl, bGPDstroke *gps) { OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md; - int vindex = defgroup_name_index(ob, mmd->vgname); + const int def_nr = defgroup_name_index(ob, mmd->vgname); if (!is_stroke_affected_by_modifier( ob, @@ -110,8 +110,8 @@ static void deformStroke( MDeformVert *dvert = &gps->dvert[i]; /* verify vertex group */ - float weight = get_modifier_point_weight(dvert, ((mmd->flag & GP_OPACITY_INVERT_VGROUP) != 0), vindex); - if (weight < 0) { + const float weight = get_modifier_point_weight(dvert, (mmd->flag & GP_OPACITY_INVERT_VGROUP) != 0, def_nr); + if (weight < 0.0f) { pt->strength += mmd->factor - 1.0f; } else { @@ -147,8 +147,9 @@ static void bakeModifier( deformStroke(md, depsgraph, ob, gpl, gps); - gpencil_apply_modifier_material(bmain, ob, mat, gh_color, gps, - (bool)(mmd->flag & GP_OPACITY_CREATE_COLORS)); + gpencil_apply_modifier_material( + bmain, ob, mat, gh_color, gps, + (bool)(mmd->flag & GP_OPACITY_CREATE_COLORS)); } } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c index b5f2f0349af..d6a0721129d 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c @@ -67,9 +67,7 @@ static void deformStroke( Object *ob, bGPDlayer *gpl, bGPDstroke *gps) { SmoothGpencilModifierData *mmd = (SmoothGpencilModifierData *)md; - int vindex = defgroup_name_index(ob, mmd->vgname); - float weight = 1.0f; - float val; + const int def_nr = defgroup_name_index(ob, mmd->vgname); if (!is_stroke_affected_by_modifier(ob, mmd->layername, mmd->pass_index, 3, gpl, gps, @@ -86,12 +84,13 @@ static void deformStroke( MDeformVert *dvert = &gps->dvert[i]; /* verify vertex group */ - weight = get_modifier_point_weight(dvert, (int)((mmd->flag & GP_SMOOTH_INVERT_VGROUP) != 0), vindex); - if (weight < 0) { + const float weight = get_modifier_point_weight( + dvert, (mmd->flag & GP_SMOOTH_INVERT_VGROUP) != 0, def_nr); + if (weight < 0.0f) { continue; } - val = mmd->factor * weight; + const float val = mmd->factor * weight; /* perform smoothing */ if (mmd->flag & GP_SMOOTH_MOD_LOCATION) { BKE_gpencil_smooth_stroke(gps, i, val); @@ -99,7 +98,7 @@ static void deformStroke( if (mmd->flag & GP_SMOOTH_MOD_STRENGTH) { BKE_gpencil_smooth_stroke_strength(gps, i, val); } - if ((mmd->flag & GP_SMOOTH_MOD_THICKNESS) && (val > 0)) { + if ((mmd->flag & GP_SMOOTH_MOD_THICKNESS) && (val > 0.0f)) { /* thickness need to repeat process several times */ for (int r2 = 0; r2 < r * 10; r2++) { BKE_gpencil_smooth_stroke_thickness(gps, i, val); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c index dba3e028904..3ba53250abd 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c @@ -24,9 +24,9 @@ * */ -/** \file blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c - * \ingroup modifiers - */ + /** \file blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c + * \ingroup modifiers + */ #include <stdio.h> @@ -65,98 +65,24 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) /* subdivide stroke to get more control points */ static void deformStroke( - GpencilModifierData *md, Depsgraph *UNUSED(depsgraph), - Object *ob, bGPDlayer *gpl, bGPDstroke *gps) + GpencilModifierData *md, Depsgraph *UNUSED(depsgraph), + Object *ob, bGPDlayer *gpl, bGPDstroke *gps) { SubdivGpencilModifierData *mmd = (SubdivGpencilModifierData *)md; - bGPDspoint *temp_points; - int totnewpoints, oldtotpoints; - int i2; if (!is_stroke_affected_by_modifier(ob, - mmd->layername, mmd->pass_index, 3, gpl, gps, - mmd->flag & GP_SUBDIV_INVERT_LAYER, mmd->flag & GP_SUBDIV_INVERT_PASS)) + mmd->layername, mmd->pass_index, 3, gpl, gps, + mmd->flag & GP_SUBDIV_INVERT_LAYER, mmd->flag & GP_SUBDIV_INVERT_PASS)) { return; } - /* loop as many times as levels */ - for (int s = 0; s < mmd->level; s++) { - totnewpoints = gps->totpoints - 1; - /* duplicate points in a temp area */ - temp_points = MEM_dupallocN(gps->points); - oldtotpoints = gps->totpoints; - - /* resize the points arrys */ - gps->totpoints += totnewpoints; - gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints); - gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints); - gps->flag |= GP_STROKE_RECALC_CACHES; - - /* move points from last to first to new place */ - i2 = gps->totpoints - 1; - for (int i = oldtotpoints - 1; i > 0; i--) { - bGPDspoint *pt = &temp_points[i]; - bGPDspoint *pt_final = &gps->points[i2]; - - MDeformVert *dvert = &gps->dvert[i]; - MDeformVert *dvert_final = &gps->dvert[i2]; - - copy_v3_v3(&pt_final->x, &pt->x); - pt_final->pressure = pt->pressure; - pt_final->strength = pt->strength; - pt_final->time = pt->time; - pt_final->flag = pt->flag; - - dvert_final->totweight = dvert->totweight; - dvert_final->dw = dvert->dw; - i2 -= 2; - } - /* interpolate mid points */ - i2 = 1; - for (int i = 0; i < oldtotpoints - 1; i++) { - bGPDspoint *pt = &temp_points[i]; - bGPDspoint *next = &temp_points[i + 1]; - bGPDspoint *pt_final = &gps->points[i2]; - MDeformVert *dvert_final = &gps->dvert[i2]; - - /* add a half way point */ - interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f); - pt_final->pressure = interpf(pt->pressure, next->pressure, 0.5f); - pt_final->strength = interpf(pt->strength, next->strength, 0.5f); - CLAMP(pt_final->strength, GPENCIL_STRENGTH_MIN, 1.0f); - pt_final->time = interpf(pt->time, next->time, 0.5f); - - dvert_final->totweight = 0; - dvert_final->dw = NULL; - i2 += 2; - } - - MEM_SAFE_FREE(temp_points); - - /* move points to smooth stroke (not simple flag )*/ - if ((mmd->flag & GP_SUBDIV_SIMPLE) == 0) { - /* duplicate points in a temp area with the new subdivide data */ - temp_points = MEM_dupallocN(gps->points); - - /* extreme points are not changed */ - for (int i = 0; i < gps->totpoints - 2; i++) { - bGPDspoint *pt = &temp_points[i]; - bGPDspoint *next = &temp_points[i + 1]; - bGPDspoint *pt_final = &gps->points[i + 1]; - - /* move point */ - interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f); - } - /* free temp memory */ - MEM_SAFE_FREE(temp_points); - } - } + BKE_gpencil_subdivide(gps, mmd->level, mmd->flag); } static void bakeModifier( - struct Main *UNUSED(bmain), Depsgraph *depsgraph, - GpencilModifierData *md, Object *ob) + struct Main *UNUSED(bmain), Depsgraph *depsgraph, + GpencilModifierData *md, Object *ob) { bGPdata *gpd = ob->data; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c index 2c01fec1357..3b5f4dbf7c7 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c @@ -92,7 +92,7 @@ static void deformStroke( Object *ob, bGPDlayer *gpl, bGPDstroke *gps) { ThickGpencilModifierData *mmd = (ThickGpencilModifierData *)md; - int vindex = defgroup_name_index(ob, mmd->vgname); + const int def_nr = defgroup_name_index(ob, mmd->vgname); if (!is_stroke_affected_by_modifier(ob, mmd->layername, mmd->pass_index, 3, gpl, gps, @@ -111,8 +111,8 @@ static void deformStroke( MDeformVert *dvert = &gps->dvert[i]; float curvef = 1.0f; /* verify vertex group */ - float weight = get_modifier_point_weight(dvert, (int)((mmd->flag & GP_THICK_INVERT_VGROUP) != 0), vindex); - if (weight < 0) { + const float weight = get_modifier_point_weight(dvert, (mmd->flag & GP_THICK_INVERT_VGROUP) != 0, def_nr); + if (weight < 0.0f) { continue; } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c index 8af9ff6eec8..98cf3ae16e7 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c @@ -135,8 +135,9 @@ static void bakeModifier( deformStroke(md, depsgraph, ob, gpl, gps); - gpencil_apply_modifier_material(bmain, ob, mat, gh_color, gps, - (bool)(mmd->flag & GP_TINT_CREATE_COLORS)); + gpencil_apply_modifier_material( + bmain, ob, mat, gh_color, gps, + (bool)(mmd->flag & GP_TINT_CREATE_COLORS)); } } } diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h index bb67a90d619..cf69af11aa6 100644 --- a/source/blender/gpu/GPU_batch.h +++ b/source/blender/gpu/GPU_batch.h @@ -196,4 +196,14 @@ void gpu_batch_exit(void); } \ } while (0) +#define GPU_BATCH_DISCARD_ARRAY_SAFE(_batch_array, _len) do { \ + if (_batch_array != NULL) { \ + BLI_assert(_len > 0); \ + for (int _i = 0; _i < _len; _i++) { \ + GPU_BATCH_DISCARD_SAFE(_batch_array[_i]); \ + } \ + MEM_freeN(_batch_array); \ + } \ +} while (0) + #endif /* __GPU_BATCH_H__ */ diff --git a/source/blender/gpu/GPU_batch_presets.h b/source/blender/gpu/GPU_batch_presets.h index a33b864c5b9..6b010396a9b 100644 --- a/source/blender/gpu/GPU_batch_presets.h +++ b/source/blender/gpu/GPU_batch_presets.h @@ -24,7 +24,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/* Batched geometry rendering is powered by the GPU library. +/** \file blender/gpu/GPU_batch_presets.h + * \ingroup gpu + * + * Batched geometry rendering is powered by the GPU library. * This file contains any additions or modifications specific to Blender. */ diff --git a/source/blender/gpu/GPU_batch_utils.h b/source/blender/gpu/GPU_batch_utils.h index d558b7a1097..05bbb6542ff 100644 --- a/source/blender/gpu/GPU_batch_utils.h +++ b/source/blender/gpu/GPU_batch_utils.h @@ -18,6 +18,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/gpu/GPU_batch_utils.h + * \ingroup gpu + */ + #ifndef __GPU_BATCH_UTILS_H__ #define __GPU_BATCH_UTILS_H__ diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index 77801256463..e60b5d60c30 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -66,7 +66,6 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading); /* update */ enum { - GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR = (1 << 0), GPU_PBVH_BUFFERS_SHOW_MASK = (1 << 1), }; @@ -93,12 +92,11 @@ void GPU_pbvh_grid_buffers_update( /* draw */ struct GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast); +bool GPU_pbvh_buffers_has_mask(GPU_PBVH_Buffers *buffers); + /* debug PBVH draw */ void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos); -bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, struct GSet *bm_faces, bool show_diffuse_color); -bool GPU_pbvh_buffers_mask_changed(GPU_PBVH_Buffers *buffers, bool show_mask); - void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers); void GPU_pbvh_multires_buffers_free(struct GridCommonGPUBuffer **grid_common_gpu_buffer); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 16590785af6..cea2de77848 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -85,7 +85,6 @@ struct GPU_PBVH_Buffers { const int *face_indices; int face_indices_len; - const float *vmask; /* grid pointers */ CCGKey gridkey; @@ -105,25 +104,13 @@ struct GPU_PBVH_Buffers { * smooth-shaded or all faces are flat-shaded */ bool smooth; - bool show_diffuse_color; bool show_mask; - - float diffuse_color[4]; }; static struct { - uint pos, nor, col; + uint pos, nor, msk; } g_vbo_id = {0}; -static void gpu_material_diffuse_get(int UNUSED(nr), float diff[4]) -{ - /* TODO: sculpt diffuse color option not supported in 2.8 yet. */ - diff[0] = 0.8f; - diff[1] = 0.8f; - diff[2] = 0.8f; - diff[3] = 1.0f; -} - /* Allocates a non-initialized buffer to be sent to GPU. * Return is false it indicates that the memory map failed. */ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int vert_len) @@ -136,7 +123,7 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int v if (format.attr_len == 0) { g_vbo_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); g_vbo_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - g_vbo_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); + g_vbo_id.msk = GPU_vertformat_attr_add(&format, "msk", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } #if 0 buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_DYNAMIC); @@ -175,67 +162,17 @@ static void gpu_pbvh_batch_init(GPU_PBVH_Buffers *buffers) } } -static float gpu_color_from_mask(float mask) -{ - return 1.0f - mask * 0.75f; -} - -static void gpu_color_from_mask_copy(float mask, const float diffuse_color[4], unsigned char out[3]) -{ - float mask_color; - - mask_color = gpu_color_from_mask(mask) * 255.0f; - - out[0] = diffuse_color[0] * mask_color; - out[1] = diffuse_color[1] * mask_color; - out[2] = diffuse_color[2] * mask_color; -} - -static void gpu_color_from_mask_quad_copy(const CCGKey *key, - CCGElem *a, CCGElem *b, - CCGElem *c, CCGElem *d, - const float *diffuse_color, - unsigned char out[3]) -{ - float mask_color = - gpu_color_from_mask((*CCG_elem_mask(key, a) + - *CCG_elem_mask(key, b) + - *CCG_elem_mask(key, c) + - *CCG_elem_mask(key, d)) * 0.25f) * 255.0f; - - out[0] = diffuse_color[0] * mask_color; - out[1] = diffuse_color[1] * mask_color; - out[2] = diffuse_color[2] * mask_color; -} - void GPU_pbvh_mesh_buffers_update( GPU_PBVH_Buffers *buffers, const MVert *mvert, const int *vert_indices, int totvert, const float *vmask, const int (*face_vert_indices)[3], const int update_flags) { - const bool show_diffuse_color = (update_flags & GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR) != 0; const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0; - - buffers->vmask = vmask; - buffers->show_diffuse_color = show_diffuse_color; - buffers->show_mask = show_mask; + bool empty_mask = true; { int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3)); - float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 0.8f}; - - if (show_diffuse_color) { - const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]]; - const MPoly *mp = &buffers->mpoly[lt->poly]; - - gpu_material_diffuse_get(mp->mat_nr + 1, diffuse_color); - } - - copy_v4_v4(buffers->diffuse_color, diffuse_color); - - uchar diffuse_color_ub[4]; - rgba_float_to_uchar(diffuse_color_ub, diffuse_color); /* Build VBO */ if (gpu_pbvh_vert_buf_data_set(buffers, totelem)) { @@ -249,18 +186,15 @@ void GPU_pbvh_mesh_buffers_update( GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, i, v->no); } - for (uint i = 0; i < buffers->face_indices_len; i++) { - const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]]; - for (uint j = 0; j < 3; j++) { - int vidx = face_vert_indices[i][j]; - if (vmask && show_mask) { + if (vmask && show_mask) { + for (uint i = 0; i < buffers->face_indices_len; i++) { + const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]]; + for (uint j = 0; j < 3; j++) { + int vidx = face_vert_indices[i][j]; int v_index = buffers->mloop[lt->tri[j]].v; - uchar color_ub[3]; - gpu_color_from_mask_copy(vmask[v_index], diffuse_color, color_ub); - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, color_ub); - } - else { - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, diffuse_color_ub); + float fmask = vmask[v_index]; + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vidx, &fmask); + empty_mask = empty_mask && (fmask == 0.0f); } } } @@ -291,13 +225,9 @@ void GPU_pbvh_mesh_buffers_update( mpoly_prev = lt->poly; } - uchar color_ub[3]; + float fmask = 0.0f; if (vmask && show_mask) { - float fmask = (vmask[vtri[0]] + vmask[vtri[1]] + vmask[vtri[2]]) / 3.0f; - gpu_color_from_mask_copy(fmask, diffuse_color, color_ub); - } - else { - copy_v3_v3_uchar(color_ub, diffuse_color_ub); + fmask = (vmask[vtri[0]] + vmask[vtri[1]] + vmask[vtri[2]]) / 3.0f; } for (uint j = 0; j < 3; j++) { @@ -305,10 +235,12 @@ void GPU_pbvh_mesh_buffers_update( GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, v->co); GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no); - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index, &fmask); vbo_index++; } + + empty_mask = empty_mask && (fmask == 0.0f); } } @@ -316,6 +248,7 @@ void GPU_pbvh_mesh_buffers_update( } } + buffers->show_mask = !empty_mask; buffers->mvert = mvert; } @@ -339,8 +272,7 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build( buffers->smooth = (mpoly[0].flag & ME_SMOOTH) != 0; #endif - buffers->show_diffuse_color = false; - buffers->show_mask = true; + buffers->show_mask = false; /* Count the number of visible triangles */ for (i = 0, tottri = 0; i < face_indices_len; ++i) { @@ -407,26 +339,15 @@ void GPU_pbvh_grid_buffers_update( int totgrid, const CCGKey *key, const int update_flags) { - const bool show_diffuse_color = (update_flags & GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR) != 0; const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0; + bool empty_mask = true; int i, j, k, x, y; - buffers->show_diffuse_color = show_diffuse_color; - buffers->show_mask = show_mask; buffers->smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; /* Build VBO */ if (buffers->index_buf) { const int has_mask = key->has_mask; - float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; - - if (show_diffuse_color) { - const DMFlagMat *flags = &grid_flag_mats[grid_indices[0]]; - - gpu_material_diffuse_get(flags->mat_nr + 1, diffuse_color); - } - - copy_v4_v4(buffers->diffuse_color, diffuse_color); uint vbo_index_offset = 0; /* Build VBO */ @@ -445,16 +366,10 @@ void GPU_pbvh_grid_buffers_update( normal_float_to_short_v3(no_short, CCG_elem_no(key, elem)); GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); - if (has_mask) { - uchar color_ub[3]; - if (show_mask) { - gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), - diffuse_color, color_ub); - } - else { - unit_float_to_uchar_clamp_v3(color_ub, diffuse_color); - } - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); + if (has_mask && show_mask) { + float fmask = *CCG_elem_mask(key, elem); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index, &fmask); + empty_mask = empty_mask && (fmask == 0.0f); } } vbo_index += 1; @@ -483,21 +398,13 @@ void GPU_pbvh_grid_buffers_update( normal_float_to_short_v3(no_short, fno); GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); - if (has_mask) { - uchar color_ub[3]; - if (show_mask) { - gpu_color_from_mask_quad_copy(key, - elems[0], - elems[1], - elems[2], - elems[3], - diffuse_color, - color_ub); - } - else { - unit_float_to_uchar_clamp_v3(color_ub, diffuse_color); - } - GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); + if (has_mask && show_mask) { + float fmask = (*CCG_elem_mask(key, elems[0]) + + *CCG_elem_mask(key, elems[1]) + + *CCG_elem_mask(key, elems[2]) + + *CCG_elem_mask(key, elems[3])) * 0.25f; + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index, &fmask); + empty_mask = empty_mask && (fmask == 0.0f); } } } @@ -515,6 +422,7 @@ void GPU_pbvh_grid_buffers_update( buffers->totgrid = totgrid; buffers->grid_flag_mats = grid_flag_mats; buffers->gridkey = *key; + buffers->show_mask = !empty_mask; //printf("node updated %p\n", buffers); } @@ -628,8 +536,7 @@ GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build( buffers->grid_hidden = grid_hidden; buffers->totgrid = totgrid; - buffers->show_diffuse_color = false; - buffers->show_mask = true; + buffers->show_mask = false; /* Count the number of quads */ totquad = BKE_pbvh_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize); @@ -689,36 +596,23 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn( const float fno[3], const float *fmask, const int cd_vert_mask_offset, - const float diffuse_color[4], - const bool show_mask) + const bool show_mask, + bool *empty_mask) { if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) { /* Set coord, normal, and mask */ GPU_vertbuf_attr_set(vert_buf, g_vbo_id.pos, *v_index, v->co); - { - short no_short[3]; - normal_float_to_short_v3(no_short, fno ? fno : v->no); - GPU_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short); - } - - { - uchar color_ub[3]; - float effective_mask; - if (show_mask) { - effective_mask = fmask ? *fmask - : BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset); - } - else { - effective_mask = 0.0f; - } + short no_short[3]; + normal_float_to_short_v3(no_short, fno ? fno : v->no); + GPU_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short); - gpu_color_from_mask_copy( - effective_mask, - diffuse_color, - color_ub); - GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col, *v_index, color_ub); + if (show_mask) { + float effective_mask = fmask ? *fmask + : BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset); + GPU_vertbuf_attr_set(vert_buf, g_vbo_id.msk, *v_index, &effective_mask); + *empty_mask = *empty_mask && (effective_mask == 0.0f); } /* Assign index for use in the triangle index buffer */ @@ -776,17 +670,13 @@ void GPU_pbvh_bmesh_buffers_update( GSet *bm_other_verts, const int update_flags) { - const bool show_diffuse_color = (update_flags & GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR) != 0; const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0; int tottri, totvert, maxvert = 0; - float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; + bool empty_mask = true; /* TODO, make mask layer optional for bmesh buffer */ const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK); - buffers->show_diffuse_color = show_diffuse_color; - buffers->show_mask = show_mask; - /* Count visible triangles */ tottri = gpu_bmesh_face_visible_count(bm_faces); @@ -805,17 +695,6 @@ void GPU_pbvh_bmesh_buffers_update( return; } - if (show_diffuse_color) { - /* due to dynamic nature of dyntopo, only get first material */ - GSetIterator gs_iter; - BMFace *f; - BLI_gsetIterator_init(&gs_iter, bm_faces); - f = BLI_gsetIterator_getKey(&gs_iter); - gpu_material_diffuse_get(f->mat_nr + 1, diffuse_color); - } - - copy_v4_v4(buffers->diffuse_color, diffuse_color); - /* Fill vertex buffer */ if (gpu_pbvh_vert_buf_data_set(buffers, totvert)) { int v_index = 0; @@ -831,16 +710,16 @@ void GPU_pbvh_bmesh_buffers_update( gpu_bmesh_vert_to_buffer_copy__gwn( BLI_gsetIterator_getKey(&gs_iter), buffers->vert_buf, &v_index, NULL, NULL, - cd_vert_mask_offset, diffuse_color, - show_mask); + cd_vert_mask_offset, + show_mask, &empty_mask); } GSET_ITER (gs_iter, bm_other_verts) { gpu_bmesh_vert_to_buffer_copy__gwn( BLI_gsetIterator_getKey(&gs_iter), buffers->vert_buf, &v_index, NULL, NULL, - cd_vert_mask_offset, diffuse_color, - show_mask); + cd_vert_mask_offset, + show_mask, &empty_mask); } maxvert = v_index; @@ -855,7 +734,7 @@ void GPU_pbvh_bmesh_buffers_update( if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { BMVert *v[3]; - float fmask = 0; + float fmask = 0.0f; int i; #if 0 @@ -873,8 +752,8 @@ void GPU_pbvh_bmesh_buffers_update( gpu_bmesh_vert_to_buffer_copy__gwn( v[i], buffers->vert_buf, &v_index, f->no, &fmask, - cd_vert_mask_offset, diffuse_color, - show_mask); + cd_vert_mask_offset, + show_mask, &empty_mask); } } } @@ -934,6 +813,8 @@ void GPU_pbvh_bmesh_buffers_update( buffers->is_index_buf_global = false; } + buffers->show_mask = !empty_mask; + gpu_pbvh_batch_init(buffers); } @@ -944,7 +825,6 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading) buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers"); buffers->use_bmesh = true; buffers->smooth = smooth_shading; - buffers->show_diffuse_color = false; buffers->show_mask = true; return buffers; @@ -956,48 +836,9 @@ GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast) buffers->triangles_fast : buffers->triangles; } -bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GSet *bm_faces, bool show_diffuse_color) -{ - float diffuse_color[4]; - - if (buffers->show_diffuse_color != show_diffuse_color) - return true; - - if (buffers->show_diffuse_color == false) - return false; - - if (buffers->looptri) { - const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]]; - const MPoly *mp = &buffers->mpoly[lt->poly]; - - gpu_material_diffuse_get(mp->mat_nr + 1, diffuse_color); - } - else if (buffers->use_bmesh) { - /* due to dynamic nature of dyntopo, only get first material */ - if (BLI_gset_len(bm_faces) > 0) { - GSetIterator gs_iter; - BMFace *f; - - BLI_gsetIterator_init(&gs_iter, bm_faces); - f = BLI_gsetIterator_getKey(&gs_iter); - gpu_material_diffuse_get(f->mat_nr + 1, diffuse_color); - } - else { - return false; - } - } - else { - const DMFlagMat *flags = &buffers->grid_flag_mats[buffers->grid_indices[0]]; - - gpu_material_diffuse_get(flags->mat_nr + 1, diffuse_color); - } - - return !equals_v3v3(diffuse_color, buffers->diffuse_color); -} - -bool GPU_pbvh_buffers_mask_changed(GPU_PBVH_Buffers *buffers, bool show_mask) +bool GPU_pbvh_buffers_has_mask(GPU_PBVH_Buffers *buffers) { - return (buffers->show_mask != show_mask); + return buffers->show_mask; } void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers) diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index daea96df008..1bfa0788f00 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -25,6 +25,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/gpu/intern/gpu_shader.c + * \ingroup gpu + */ + #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index dcb7fbd344b..09d5ec92859 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -117,7 +117,9 @@ typedef enum eGPDbrush_Flag { /* settings group */ GP_BRUSH_GROUP_SETTINGS = (1 << 11), /* Random settings group */ - GP_BRUSH_GROUP_RANDOM = (1 << 12) + GP_BRUSH_GROUP_RANDOM = (1 << 12), + /* Keep material assigned to brush */ + GP_BRUSH_MATERIAL_PINNED = (1 << 13) } eGPDbrush_Flag; /* BrushGpencilSettings->gp_fill_draw_mode */ diff --git a/source/blender/makesdna/DNA_group_types.h b/source/blender/makesdna/DNA_collection_types.h index b5208a81510..f08725e9fe0 100644 --- a/source/blender/makesdna/DNA_group_types.h +++ b/source/blender/makesdna/DNA_collection_types.h @@ -25,14 +25,14 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file DNA_group_types.h +/** \file DNA_collection_types.h * \ingroup DNA * * \brief Object groups, one object can be in many groups at once. */ -#ifndef __DNA_GROUP_TYPES_H__ -#define __DNA_GROUP_TYPES_H__ +#ifndef __DNA_COLLECTION_TYPES_H__ +#define __DNA_COLLECTION_TYPES_H__ #include "DNA_defs.h" #include "DNA_listBase.h" @@ -91,4 +91,4 @@ enum { COLLECTION_IS_MASTER = (1 << 5), /* Is master collection embedded in the scene. */ }; -#endif /* __DNA_GROUP_TYPES_H__ */ +#endif /* __DNA_COLLECTION_TYPES_H__ */ diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index 3727ca9a3f3..ae341b24e41 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -50,6 +50,7 @@ typedef enum GpencilModifierType { eGpencilModifierType_Hook = 12, eGpencilModifierType_Offset = 13, eGpencilModifierType_Mirror = 14, + eGpencilModifierType_Armature = 15, NUM_GREASEPENCIL_MODIFIER_TYPES } GpencilModifierType; @@ -408,4 +409,14 @@ typedef enum eSmoothGpencil_Flag { GP_SMOOTH_MOD_UV = (1 << 6), } eSmoothGpencil_Flag; +typedef struct ArmatureGpencilModifierData { + GpencilModifierData modifier; + short deformflag, multi; /* deformflag replaces armature->deformflag */ + int pad2; + struct Object *object; + float *prevCos; /* stored input of previous modifier, for vertexgroup blending */ + char vgname[64]; /* MAX_VGROUP_NAME */ + +} ArmatureGpencilModifierData; + #endif /* __DNA_GPENCIL_MODIFIER_TYPES_H__ */ diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index f4a13801949..8462b615d2c 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -427,6 +427,8 @@ typedef enum eGPdata_Flag { * not valid. */ GP_DATA_STROKE_FORCE_RECALC = (1 << 17), + /* Special mode drawing polygons */ + GP_DATA_STROKE_POLYGON = (1 << 18), } eGPdata_Flag; /* gpd->onion_flag */ diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 9e15bd32b3b..a91f2f05c1a 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -243,7 +243,7 @@ enum { ME_DRAW_VNORMALS = 1 << 3, ME_DRAWEIGHT = 1 << 4, - /* ME_HIDDENEDGES = 1 << 5, */ /* DEPRECATED */ + ME_DRAW_FACE_DOT = 1 << 5, ME_DRAWCREASES = 1 << 6, ME_DRAWSEAMS = 1 << 7, diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 6425871b7dd..1429e7ce238 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -47,7 +47,7 @@ extern "C" { #include "DNA_ID.h" #include "DNA_freestyle_types.h" #include "DNA_gpu_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_layer_types.h" #include "DNA_material_types.h" #include "DNA_userdef_types.h" @@ -2068,7 +2068,9 @@ typedef enum eGPencil_Flags { /* Add the strokes below all strokes in the layer */ GP_TOOL_FLAG_PAINT_ONBACK = (1 << 2), /* Show compact list of colors */ - GP_TOOL_FLAG_THUMBNAIL_LIST = (1 << 3), + GP_TOOL_FLAG_THUMBNAIL_LIST = (1 << 3), + /* Generate wheight data for new strokes */ + GP_TOOL_FLAG_CREATE_WEIGHTS = (1 << 4), } eGPencil_Flags; /* scene->r.simplify_gpencil */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 5404f4160fd..f38669a757a 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -197,8 +197,7 @@ typedef enum eSpaceButtons_Context { BCONTEXT_BONE_CONSTRAINT = 12, BCONTEXT_VIEW_LAYER = 13, BCONTEXT_TOOL = 14, - BCONTEXT_WORKSPACE = 15, - BCONTEXT_SHADERFX = 16, + BCONTEXT_SHADERFX = 15, /* always as last... */ BCONTEXT_TOT diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 317cde9009d..65b6192b9c8 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -96,7 +96,7 @@ typedef struct RegionView3D { float tw_axis_min[3], tw_axis_max[3]; float tw_axis_matrix[3][3]; - float gridview; + float gridview DNA_DEPRECATED; float viewquat[4]; /* view rotation, must be kept normalized */ float dist; /* distance from 'ofs' along -viewinv[2] vector, where result is negative as is 'ofs' */ diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h index 3eb40bfa523..fd56c246c96 100644 --- a/source/blender/makesdna/DNA_workspace_types.h +++ b/source/blender/makesdna/DNA_workspace_types.h @@ -144,8 +144,10 @@ typedef struct WorkSpace { char tools_space_type; /** Type is different for each space-type. */ char tools_mode; + char _pad[6]; + + int object_mode; - char _pad[2]; int flags DNA_PRIVATE_WORKSPACE; /* enum eWorkSpaceFlags */ /* Info text from modal operators (runtime). */ diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index d628444a1e8..e4f825e31dd 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -101,7 +101,7 @@ static const char *includefiles[] = { "DNA_effect_types.h", "DNA_outliner_types.h", "DNA_sound_types.h", - "DNA_group_types.h", + "DNA_collection_types.h", "DNA_armature_types.h", "DNA_action_types.h", "DNA_constraint_types.h", @@ -1328,7 +1328,7 @@ int main(int argc, char **argv) #include "DNA_effect_types.h" #include "DNA_outliner_types.h" #include "DNA_sound_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_armature_types.h" #include "DNA_action_types.h" #include "DNA_constraint_types.h" diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index d4d753e27cf..d1be0243338 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -614,6 +614,7 @@ extern StructRNA RNA_MirrorGpencilModifier; extern StructRNA RNA_SmoothGpencilModifier; extern StructRNA RNA_HookGpencilModifier; extern StructRNA RNA_OffsetGpencilModifier; +extern StructRNA RNA_ArmatureGpencilModifier; extern StructRNA RNA_ShaderFx; extern StructRNA RNA_ShaderFxBlur; extern StructRNA RNA_ShaderFxColorize; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 9efa8475f8e..613454e2f33 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -43,6 +43,7 @@ extern const EnumPropertyItem DummyRNA_DEFAULT_items[]; extern const EnumPropertyItem rna_enum_id_type_items[]; extern const EnumPropertyItem rna_enum_object_mode_items[]; +extern const EnumPropertyItem rna_enum_workspace_object_mode_items[]; extern const EnumPropertyItem rna_enum_object_empty_drawtype_items[]; extern const EnumPropertyItem rna_enum_object_gpencil_type_items[]; extern const EnumPropertyItem rna_enum_metaelem_type_items[]; @@ -164,6 +165,7 @@ extern const EnumPropertyItem rna_enum_operator_context_items[]; extern const EnumPropertyItem rna_enum_wm_report_items[]; extern const EnumPropertyItem rna_enum_transform_pivot_items_full[]; +extern const EnumPropertyItem rna_enum_transform_orientation_items[]; extern const EnumPropertyItem rna_enum_transform_mode_types[]; extern const EnumPropertyItem rna_enum_posebone_rotmode_items[]; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 9eba2e9d36f..1b06077b1ea 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -40,6 +40,7 @@ set(DEFSRC rna_cachefile.c rna_camera.c rna_cloth.c + rna_collection.c rna_color.c rna_constraint.c rna_context.c @@ -51,13 +52,12 @@ set(DEFSRC rna_fluidsim.c rna_gpencil.c rna_gpencil_modifier.c - rna_shader_fx.c - rna_group.c rna_image.c rna_key.c rna_lamp.c rna_lattice.c rna_layer.c + rna_lightprobe.c rna_linestyle.c rna_main.c rna_mask.c @@ -74,7 +74,6 @@ set(DEFSRC rna_palette.c rna_particle.c rna_pose.c - rna_lightprobe.c rna_render.c rna_rigidbody.c rna_rna.c @@ -82,6 +81,7 @@ set(DEFSRC rna_screen.c rna_sculpt_paint.c rna_sequencer.c + rna_shader_fx.c rna_smoke.c rna_sound.c rna_space.c diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 0c5a433ed9c..f9e65811ca8 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3396,6 +3396,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_cachefile.c", NULL, RNA_def_cachefile}, {"rna_camera.c", "rna_camera_api.c", RNA_def_camera}, {"rna_cloth.c", NULL, RNA_def_cloth}, + {"rna_collection.c", NULL, RNA_def_collections}, {"rna_color.c", NULL, RNA_def_color}, {"rna_constraint.c", NULL, RNA_def_constraint}, {"rna_context.c", NULL, RNA_def_context}, @@ -3404,7 +3405,6 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve}, {"rna_fluidsim.c", NULL, RNA_def_fluidsim}, {"rna_gpencil.c", NULL, RNA_def_gpencil}, - {"rna_group.c", NULL, RNA_def_collections}, {"rna_image.c", "rna_image_api.c", RNA_def_image}, {"rna_key.c", NULL, RNA_def_key}, {"rna_lamp.c", NULL, RNA_def_light}, diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 8ad77b88702..680ed346b54 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -171,6 +171,7 @@ static EnumPropertyItem rna_enum_gpencil_brush_icons_items[] = { #include "BKE_colorband.h" #include "BKE_brush.h" #include "BKE_icons.h" +#include "BKE_gpencil.h" #include "BKE_paint.h" #include "WM_api.h" @@ -411,6 +412,31 @@ static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR /*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */ } +static void rna_Brush_material_update(bContext *C, PointerRNA *ptr) +{ + Main *bmain = CTX_data_main(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + Brush *br = (Brush *)ptr->id.data; + int index; + + /* set material slot to same material */ + if ((ob) && (ob->type == OB_GPENCIL) && (br->gpencil_settings != NULL)) { + BrushGpencilSettings *gpencil_settings = br->gpencil_settings; + if (gpencil_settings->material != NULL) { + + index = BKE_gpencil_get_material_index(ob, gpencil_settings->material); + if ((index > 0) && (ob->actcol != index)) { + ob->actcol = index; + /* update other brushes to keep all synchro */ + BKE_brush_update_material(bmain, gpencil_settings->material, br); + } + + } + WM_main_add_notifier(NC_SPACE | ND_SPACE_PROPERTIES, NULL); + } +} + static void rna_Brush_main_tex_update(bContext *C, PointerRNA *ptr) { Main *bmain = CTX_data_main(C); @@ -563,8 +589,8 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA /* sculpt mode */ static const EnumPropertyItem prop_flatten_contrast_items[] = { - {0, "FLATTEN", 0, "Flatten", "Add effect of brush"}, - {BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"}, + {BRUSH_DIR_IN, "CONTRAST", ICON_ZOOMIN, "Contrast", "Subtract effect of brush"}, + {0, "FLATTEN", ICON_ZOOMOUT, "Flatten", "Add effect of brush"}, {0, NULL, 0, NULL, NULL} }; @@ -575,27 +601,27 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA }; static const EnumPropertyItem prop_scrape_peaks_items[] = { - {0, "SCRAPE", 0, "Scrape", "Add effect of brush"}, - {BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"}, + {0, "SCRAPE", ICON_ZOOMIN, "Scrape", "Add effect of brush"}, + {BRUSH_DIR_IN, "PEAKS", ICON_ZOOMOUT, "Peaks", "Subtract effect of brush"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem prop_pinch_magnify_items[] = { - {0, "PINCH", 0, "Pinch", "Add effect of brush"}, - {BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"}, + {BRUSH_DIR_IN, "MAGNIFY", ICON_ZOOMIN, "Magnify", "Subtract effect of brush"}, + {0, "PINCH", ICON_ZOOMOUT, "Pinch", "Add effect of brush"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem prop_inflate_deflate_items[] = { - {0, "INFLATE", 0, "Inflate", "Add effect of brush"}, - {BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"}, + {0, "INFLATE", ICON_ZOOMIN, "Inflate", "Add effect of brush"}, + {BRUSH_DIR_IN, "DEFLATE", ICON_ZOOMOUT, "Deflate", "Subtract effect of brush"}, {0, NULL, 0, NULL, NULL} }; /* texture paint mode */ static const EnumPropertyItem prop_soften_sharpen_items[] = { - {0, "SOFTEN", 0, "Soften", "Blur effect of brush"}, - {BRUSH_DIR_IN, "SHARPEN", 0, "Sharpen", "Sharpen effect of brush"}, + {BRUSH_DIR_IN, "SHARPEN", ICON_ZOOMIN, "Sharpen", "Sharpen effect of brush"}, + {0, "SOFTEN", ICON_ZOOMOUT, "Soften", "Blur effect of brush"}, {0, NULL, 0, NULL, NULL} }; @@ -935,8 +961,8 @@ static void rna_def_gpencil_options(BlenderRNA *brna) /* Grease Pencil Drawing - generated dynamically */ static const EnumPropertyItem prop_dynamic_gpencil_type[] = { - { 1, "DRAW", 0, "Draw", "" }, - { 0, NULL, 0, NULL, NULL } + {1, "DRAW", 0, "Draw", ""}, + {0, NULL, 0, NULL, NULL} }; srna = RNA_def_struct(brna, "BrushGpencilSettings", NULL); @@ -1202,10 +1228,10 @@ static void rna_def_gpencil_options(BlenderRNA *brna) prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Material"); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_BrushGpencilSettings_material_poll"); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Material", "Material used for strokes drawn using this brush"); RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_Brush_material_update"); prop = RNA_def_property(srna, "gpencil_fill_show_boundary", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_FILL_SHOW_HELPLINES); @@ -1236,6 +1262,12 @@ static void rna_def_gpencil_options(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_GROUP_RANDOM); RNA_def_property_ui_text(prop, "Random Settings", "Enable random settings for brush"); RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "pin_material", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_MATERIAL_PINNED); + RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); + RNA_def_property_ui_text(prop, "Pin Material", "Keep material assigned to brush"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); } static void rna_def_brush(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c index c0aa1f2a9f4..dd76e2409db 100644 --- a/source/blender/makesrna/intern/rna_cachefile.c +++ b/source/blender/makesrna/intern/rna_cachefile.c @@ -23,6 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/makesrna/intern/rna_cachefile.c + * \ingroup RNA + */ + #include "DNA_cachefile_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_collection.c index 7797de9ad4b..1262ae05390 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_collection.c @@ -20,13 +20,13 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/makesrna/intern/rna_group.c +/** \file blender/makesrna/intern/rna_collection.c * \ingroup RNA */ #include <stdlib.h> -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "BLI_utildefines.h" diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 6f7580a3944..52c6bc105fd 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -528,6 +528,7 @@ static void rna_def_constraint_target_common(StructRNA *srna) RNA_def_property_pointer_sdna(prop, NULL, "tar"); RNA_def_property_ui_text(prop, "Target", "Target object"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); @@ -680,6 +681,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "poletar"); RNA_def_property_ui_text(prop, "Pole Target", "Object for pole rotation"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "pole_subtarget", PROP_STRING, PROP_NONE); @@ -1093,6 +1095,7 @@ static void rna_def_constraint_action(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Action_id_poll"); RNA_def_property_ui_text(prop, "Action", "The constraining action"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); prop = RNA_def_property(srna, "use_bone_object_action", PROP_BOOLEAN, PROP_NONE); @@ -1205,6 +1208,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll"); RNA_def_property_ui_text(prop, "Target", "Target Curve object"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TIME); @@ -1349,6 +1353,7 @@ static void rna_def_constraint_clamp_to(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll"); RNA_def_property_ui_text(prop, "Target", "Target Object (Curves only)"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "main_axis", PROP_ENUM, PROP_NONE); @@ -1920,6 +1925,7 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll"); RNA_def_property_ui_text(prop, "Target", "Target Mesh object"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "shrinkwrap_type", PROP_ENUM, PROP_NONE); @@ -2013,6 +2019,7 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll"); RNA_def_property_ui_text(prop, "Target", "Curve that controls this relationship"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "chain_count", PROP_INT, PROP_NONE); @@ -2131,6 +2138,7 @@ static void rna_def_constraint_pivot(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "tar"); RNA_def_property_ui_text(prop, "Target", "Target Object, defining the position of the pivot when defined"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); @@ -2181,6 +2189,7 @@ static void rna_def_constraint_follow_track(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "clip"); RNA_def_property_ui_text(prop, "Movie Clip", "Movie Clip to get tracking data from"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); /* track */ @@ -2213,6 +2222,7 @@ static void rna_def_constraint_follow_track(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Camera", "Camera to which motion is parented (if empty active scene camera is used)"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_followTrack_camera_set", NULL, "rna_Constraint_cameraObject_poll"); @@ -2223,6 +2233,7 @@ static void rna_def_constraint_follow_track(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Depth Object", "Object used to define depth in camera space by projecting onto surface of this object"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_followTrack_depthObject_set", NULL, "rna_Constraint_followTrack_depthObject_poll"); @@ -2255,6 +2266,7 @@ static void rna_def_constraint_camera_solver(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "clip"); RNA_def_property_ui_text(prop, "Movie Clip", "Movie Clip to get tracking data from"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); /* use default clip */ @@ -2278,6 +2290,7 @@ static void rna_def_constraint_object_solver(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "clip"); RNA_def_property_ui_text(prop, "Movie Clip", "Movie Clip to get tracking data from"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); /* use default clip */ @@ -2298,6 +2311,7 @@ static void rna_def_constraint_object_solver(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Camera", "Camera to which motion is parented (if empty active scene camera is used)"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_objectSolver_camera_set", NULL, "rna_Constraint_cameraObject_poll"); @@ -2317,6 +2331,7 @@ static void rna_def_constraint_transform_cache(BlenderRNA *brna) RNA_def_property_struct_type(prop, "CacheFile"); RNA_def_property_ui_text(prop, "Cache File", ""); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, 0, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "object_path", PROP_STRING, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_fracture.c b/source/blender/makesrna/intern/rna_fracture.c index 4b10cc06b8b..7ba0f68b1a2 100644 --- a/source/blender/makesrna/intern/rna_fracture.c +++ b/source/blender/makesrna/intern/rna_fracture.c @@ -36,7 +36,7 @@ #include "DNA_fracture_types.h" #include "DNA_modifier_types.h" #include "DNA_rigidbody_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "BLI_math.h" #include "BLI_utildefines.h" diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 6beb8c5313e..6bb93e9e313 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -494,7 +494,9 @@ static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports stroke->totpoints--; stroke->points = MEM_callocN(sizeof(bGPDspoint) * stroke->totpoints, "gp_stroke_points"); - stroke->dvert = MEM_callocN(sizeof(MDeformVert) * stroke->totpoints, "gp_stroke_weights"); + if (pt_dvert != NULL) { + stroke->dvert = MEM_callocN(sizeof(MDeformVert) * stroke->totpoints, "gp_stroke_weights"); + } if (index > 0) { memcpy(stroke->points, pt_tmp, sizeof(bGPDspoint) * index); diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index c4d1e93a2ef..ec8adeaddda 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -67,6 +67,7 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = { {eGpencilModifierType_Simplify, "GP_SIMPLIFY", ICON_MOD_DECIM, "Simplify", "Simplify stroke reducing number of points"}, {eGpencilModifierType_Subdiv, "GP_SUBDIV", ICON_MOD_SUBSURF, "Subdivide", "Subdivide stroke adding more control points"}, {0, "", 0, N_("Deform"), "" }, + {eGpencilModifierType_Armature, "GP_ARMATURE", ICON_MOD_ARMATURE, "Armature", "Deform stroke points using armature object"}, {eGpencilModifierType_Hook, "GP_HOOK", ICON_HOOK, "Hook", "Deform stroke points using objects"}, {eGpencilModifierType_Lattice, "GP_LATTICE", ICON_MOD_LATTICE, "Lattice", "Deform strokes using lattice"}, {eGpencilModifierType_Mirror, "GP_MIRROR", ICON_MOD_MIRROR, "Mirror", "Duplicate strokes like a mirror"}, @@ -160,6 +161,8 @@ static StructRNA *rna_GpencilModifier_refine(struct PointerRNA *ptr) return &RNA_HookGpencilModifier; case eGpencilModifierType_Offset: return &RNA_OffsetGpencilModifier; + case eGpencilModifierType_Armature: + return &RNA_ArmatureGpencilModifier; /* Default */ case eGpencilModifierType_None: case NUM_GREASEPENCIL_MODIFIER_TYPES: @@ -227,6 +230,7 @@ RNA_GP_MOD_VGROUP_NAME_SET(Lattice, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Smooth, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Hook, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Offset, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Armature, vgname); #undef RNA_GP_MOD_VGROUP_NAME_SET @@ -251,6 +255,7 @@ static void rna_##_type##GpencilModifier_##_prop##_set(PointerRNA *ptr, PointerR greasepencil_modifier_object_set(ptr->id.data, &tmd->_prop, _obtype, value); \ } +RNA_GP_MOD_OBJECT_SET(Armature, object, OB_ARMATURE); RNA_GP_MOD_OBJECT_SET(Lattice, object, OB_LATTICE); RNA_GP_MOD_OBJECT_SET(Mirror, object, OB_EMPTY); @@ -1261,6 +1266,60 @@ static void rna_def_modifier_gpencilhook(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Uniform Falloff", "Compensate for non-uniform object scale"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); } + +static void rna_def_modifier_gpencilarmature(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ArmatureGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Armature Modifier", "Change stroke using armature to deform modifier"); + RNA_def_struct_sdna(srna, "ArmatureGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_ARMATURE); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Armature object to deform with"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureGpencilModifier_object_set", NULL, "rna_Armature_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE); + RNA_def_property_ui_text(prop, "Use Bone Envelopes", "Bind Bone envelopes to armature modifier"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "use_vertex_groups", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP); + RNA_def_property_ui_text(prop, "Use Vertex Groups", "Bind vertex groups to armature modifier"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION); + RNA_def_property_ui_text(prop, "Preserve Volume", "Deform rotation interpolation with quaternions"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + +#if 0 /* GPXX keep disabled now */ + prop = RNA_def_property(srna, "use_multi_modifier", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "multi", 0); + RNA_def_property_ui_text(prop, "Multi Modifier", + "Use same input as previous modifier, and mix results using overall vgroup"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); +#endif + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", + "Name of Vertex Group which determines influence of modifier per point"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ArmatureGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); +} + void RNA_def_greasepencil_modifier(BlenderRNA *brna) { StructRNA *srna; @@ -1330,6 +1389,7 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna) rna_def_modifier_gpencillattice(brna); rna_def_modifier_gpencilmirror(brna); rna_def_modifier_gpencilhook(brna); + rna_def_modifier_gpencilarmature(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index c7a3e103281..d6b7cabc335 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -144,7 +144,7 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); } - BKE_image_release_ibuf(image, ibuf, &lock); + BKE_image_release_ibuf(image, ibuf, lock); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, image); } diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index d425534fe53..df86a45b1a9 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -53,7 +53,7 @@ # include "BPY_extern.h" #endif -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_object_types.h" #include "RNA_access.h" diff --git a/source/blender/makesrna/intern/rna_lightprobe.c b/source/blender/makesrna/intern/rna_lightprobe.c index f54c01fab8e..cae06b5aa89 100644 --- a/source/blender/makesrna/intern/rna_lightprobe.c +++ b/source/blender/makesrna/intern/rna_lightprobe.c @@ -42,8 +42,8 @@ #include "BKE_main.h" #include "DEG_depsgraph.h" +#include "DNA_collection_types.h" #include "DNA_object_types.h" -#include "DNA_group_types.h" #include "WM_api.h" diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 9fd9a04ae25..6e68eb51ff8 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -99,7 +99,7 @@ #include "DNA_lightprobe_types.h" #include "DNA_text_types.h" #include "DNA_texture_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_brush_types.h" #include "DNA_lattice_types.h" #include "DNA_meta_types.h" diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index a1551ea2317..53c5da243fe 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -2704,7 +2704,7 @@ static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop) /* PropertyRNA *prop; */ FunctionRNA *func; -/* PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshVertices"); srna = RNA_def_struct(brna, "MeshVertices", NULL); @@ -2713,7 +2713,8 @@ static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "ED_mesh_vertices_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX); + parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); #if 0 /* BMESH_TODO Remove until BMesh merge */ func = RNA_def_function(srna, "remove", "ED_mesh_vertices_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); @@ -2728,7 +2729,7 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop) /* PropertyRNA *prop; */ FunctionRNA *func; -/* PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshEdges"); srna = RNA_def_struct(brna, "MeshEdges", NULL); @@ -2737,7 +2738,8 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "ED_mesh_edges_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to add", 0, INT_MAX); + parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to add", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); #if 0 /* BMESH_TODO Remove until BMesh merge */ func = RNA_def_function(srna, "remove", "ED_mesh_edges_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); @@ -2752,7 +2754,7 @@ static void rna_def_mesh_tessfaces(BlenderRNA *brna, PropertyRNA *cprop) PropertyRNA *prop; FunctionRNA *func; -/* PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshTessFaces"); srna = RNA_def_struct(brna, "MeshTessFaces", NULL); @@ -2765,7 +2767,8 @@ static void rna_def_mesh_tessfaces(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "ED_mesh_tessfaces_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to add", 0, INT_MAX); + parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to add", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); #if 0 /* BMESH_TODO Remove until BMesh merge */ func = RNA_def_function(srna, "remove", "ED_mesh_faces_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); @@ -2781,7 +2784,7 @@ static void rna_def_mesh_loops(BlenderRNA *brna, PropertyRNA *cprop) /*PropertyRNA *prop;*/ FunctionRNA *func; - /*PropertyRNA *parm;*/ + PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshLoops"); srna = RNA_def_struct(brna, "MeshLoops", NULL); @@ -2790,7 +2793,8 @@ static void rna_def_mesh_loops(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "ED_mesh_loops_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of loops to add", 0, INT_MAX); + parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of loops to add", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } /* mesh.polygons */ @@ -2801,7 +2805,7 @@ static void rna_def_mesh_polygons(BlenderRNA *brna, PropertyRNA *cprop) PropertyRNA *prop; FunctionRNA *func; - /* PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshPolygons"); srna = RNA_def_struct(brna, "MeshPolygons", NULL); @@ -2814,7 +2818,8 @@ static void rna_def_mesh_polygons(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "ED_mesh_polys_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of polygons to add", 0, INT_MAX); + parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of polygons to add", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } @@ -3518,6 +3523,11 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Draw Faces", "Display all faces as shades in the 3D view and UV editor"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + prop = RNA_def_property(srna, "show_face_center", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FACE_DOT); + RNA_def_property_ui_text(prop, "Draw Face Center", "Display face center"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + prop = RNA_def_property(srna, "show_edge_crease", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWCREASES); RNA_def_property_ui_text(prop, "Draw Creases", "Display creases created for Subdivision Surface modifier"); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index a6172bd9cc2..0bb222b2dff 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -6976,9 +6976,8 @@ static void def_cmp_cryptomatte(StructRNA *srna) RNA_def_struct_sdna_from(srna, "NodeCryptomatte", "storage"); prop = RNA_def_property(srna, "matte_id", PROP_STRING, PROP_NONE); - RNA_def_property_string_funcs( - prop, "rna_NodeCryptomatte_matte_get", "rna_NodeCryptomatte_matte_length", - "rna_NodeCryptomatte_matte_set"); + RNA_def_property_string_funcs(prop, "rna_NodeCryptomatte_matte_get", "rna_NodeCryptomatte_matte_length", + "rna_NodeCryptomatte_matte_set"); RNA_def_property_ui_text(prop, "Matte Objects", "List of object and material crypto IDs to include in matte"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 9cb5c7333c8..dc0e1b23098 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -28,8 +28,9 @@ #include <stdlib.h> #include "DNA_action_types.h" +#include "DNA_brush_types.h" +#include "DNA_collection_types.h" #include "DNA_customdata_types.h" -#include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_object_force_types.h" @@ -80,6 +81,23 @@ const EnumPropertyItem rna_enum_object_mode_items[] = { {0, NULL, 0, NULL, NULL} }; +/* Same as above, but with names that distinguish grease pencil. */ +const EnumPropertyItem rna_enum_workspace_object_mode_items[] = { + {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""}, + {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""}, + {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""}, + {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""}, + {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, + {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, + {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, + {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""}, + {OB_MODE_GPENCIL_EDIT, "GPENCIL_EDIT", ICON_EDITMODE_HLT, "Grease Pencil Edit Mode", "Edit Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_SCULPT, "GPENCIL_SCULPT", ICON_SCULPTMODE_HLT, "Grease Pencil Sculpt Mode", "Sculpt Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_PAINT, "GPENCIL_PAINT", ICON_GREASEPENCIL, "Grease Pencil Draw", "Paint Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_WEIGHT, "GPENCIL_WEIGHT", ICON_WPAINT_HLT, "Grease Pencil Weight Paint", "Grease Pencil Weight Paint Strokes" }, + {0, NULL, 0, NULL, NULL} +}; + const EnumPropertyItem rna_enum_object_empty_drawtype_items[] = { {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""}, {OB_ARROWS, "ARROWS", 0, "Arrows", ""}, @@ -194,6 +212,7 @@ const EnumPropertyItem rna_enum_object_axis_items[] = { #include "DNA_node_types.h" #include "BKE_armature.h" +#include "BKE_brush.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" @@ -243,6 +262,20 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id); } +static void rna_MaterialIndex_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + /* update the material of all brushes not pinned */ + Object *ob = (Object *)ptr->id.data; + if (ob && ob->type == OB_GPENCIL) { + Material *ma = give_current_material(ob, ob->actcol); + if (ma != NULL) { + BKE_brush_update_material(bmain, ma, NULL); + WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL); + } + } +} + + static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) { Object *ob = ptr->id.data; @@ -2216,7 +2249,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range"); RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot"); - RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, NULL); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_MaterialIndex_update"); /* transform */ prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c index 46124a43799..3ade431bbbb 100644 --- a/source/blender/makesrna/intern/rna_rigidbody.c +++ b/source/blender/makesrna/intern/rna_rigidbody.c @@ -33,7 +33,7 @@ #include "rna_internal.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_object_types.h" #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index fe32566028d..84910b6b1b3 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -27,7 +27,7 @@ #include <stdlib.h> #include "DNA_brush_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" #include "DNA_rigidbody_types.h" @@ -469,7 +469,7 @@ const EnumPropertyItem rna_enum_transform_pivot_items_full[] = { }; /* Icons could be made a consistent set of images. */ -static const EnumPropertyItem transform_orientation_items[] = { +const EnumPropertyItem rna_enum_transform_orientation_items[] = { {V3D_MANIP_GLOBAL, "GLOBAL", ICON_SCENE_DATA, "Global", "Align the transformation axes to world space"}, {V3D_MANIP_LOCAL, "LOCAL", ICON_MANIPUL, "Local", "Align the transformation axes to the selected objects' local space"}, {V3D_MANIP_NORMAL, "NORMAL", ICON_SNAP_NORMAL, "Normal", @@ -2012,7 +2012,7 @@ const EnumPropertyItem *rna_TransformOrientation_itemf( EnumPropertyItem *item = NULL; int i = V3D_MANIP_CUSTOM, totitem = 0; - RNA_enum_items_add(&item, &totitem, transform_orientation_items); + RNA_enum_items_add(&item, &totitem, rna_enum_transform_orientation_items); Scene *scene; if (ptr->type == &RNA_Scene) { @@ -2451,6 +2451,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) "Show compact list of color instead of thumbnails"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + prop = RNA_def_property(srna, "add_gpencil_weight_data", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_CREATE_WEIGHTS); + RNA_def_property_ui_text(prop, "Add weight data for new strokes", + "When creating new strokes, the weight data is added according to the current vertex group and weight, " + "if no vertex group selected, weight is not added"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + prop = RNA_def_property(srna, "gpencil_sculpt", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gp_sculpt"); RNA_def_property_struct_type(prop, "GPencilSculptSettings"); @@ -6256,7 +6263,7 @@ void RNA_def_scene(BlenderRNA *brna) /* Orientations */ prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "orientation_type"); - RNA_def_property_enum_items(prop, transform_orientation_items); + RNA_def_property_enum_items(prop, rna_enum_transform_orientation_items); RNA_def_property_enum_funcs(prop, "rna_Scene_transform_orientation_get", "rna_Scene_transform_orientation_set", "rna_TransformOrientation_itemf"); RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation"); diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c index da4470ccff7..4b77e504a38 100644 --- a/source/blender/makesrna/intern/rna_shader_fx.c +++ b/source/blender/makesrna/intern/rna_shader_fx.c @@ -49,14 +49,14 @@ #include "WM_types.h" const EnumPropertyItem rna_enum_object_shaderfx_type_items[] = { - {eShaderFxType_Blur, "FX_BLUR", ICON_SOLO_ON, "Blur", "Apply Gaussian Blur to object" }, - {eShaderFxType_Colorize, "FX_COLORIZE", ICON_SOLO_ON, "Colorize", "Apply different tint effects" }, - {eShaderFxType_Flip, "FX_FLIP", ICON_SOLO_ON, "Flip", "Flip image" }, - {eShaderFxType_Light, "FX_LIGHT", ICON_SOLO_ON, "Light", "Simulate ilumination" }, - {eShaderFxType_Pixel, "FX_PIXEL", ICON_SOLO_ON, "Pixelate", "Pixelate image"}, - {eShaderFxType_Rim, "FX_RIM", ICON_SOLO_ON, "Rim", "Add a rim to the image" }, - {eShaderFxType_Swirl, "FX_SWIRL", ICON_SOLO_ON, "Swirl", "Create a rotation distortion"}, - {eShaderFxType_Wave, "FX_WAVE", ICON_SOLO_ON, "Wave Distortion", "Apply sinusoidal deformation"}, + {eShaderFxType_Blur, "FX_BLUR", ICON_SHADERFX, "Blur", "Apply Gaussian Blur to object" }, + {eShaderFxType_Colorize, "FX_COLORIZE", ICON_SHADERFX, "Colorize", "Apply different tint effects" }, + {eShaderFxType_Flip, "FX_FLIP", ICON_SHADERFX, "Flip", "Flip image" }, + {eShaderFxType_Light, "FX_LIGHT", ICON_SHADERFX, "Light", "Simulate ilumination" }, + {eShaderFxType_Pixel, "FX_PIXEL", ICON_SHADERFX, "Pixelate", "Pixelate image"}, + {eShaderFxType_Rim, "FX_RIM", ICON_SHADERFX, "Rim", "Add a rim to the image" }, + {eShaderFxType_Swirl, "FX_SWIRL", ICON_SHADERFX, "Swirl", "Create a rotation distortion"}, + {eShaderFxType_Wave, "FX_WAVE", ICON_SHADERFX, "Wave Distortion", "Apply sinusoidal deformation"}, {0, NULL, 0, NULL, NULL} }; @@ -194,7 +194,7 @@ static void rna_def_shader_fx_blur(BlenderRNA *brna) srna = RNA_def_struct(brna, "ShaderFxBlur", "ShaderFx"); RNA_def_struct_ui_text(srna, "Gaussian Blur Effect", "Gaussian Blur effect"); RNA_def_struct_sdna(srna, "BlurShaderFxData"); - RNA_def_struct_ui_icon(srna, ICON_SOLO_ON); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); prop = RNA_def_property(srna, "factor", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "radius"); @@ -231,7 +231,7 @@ static void rna_def_shader_fx_colorize(BlenderRNA *brna) srna = RNA_def_struct(brna, "ShaderFxColorize", "ShaderFx"); RNA_def_struct_ui_text(srna, "Colorize Effect", "Colorize effect"); RNA_def_struct_sdna(srna, "ColorizeShaderFxData"); - RNA_def_struct_ui_icon(srna, ICON_SOLO_ON); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "factor"); @@ -274,7 +274,7 @@ static void rna_def_shader_fx_wave(BlenderRNA *brna) srna = RNA_def_struct(brna, "ShaderFxWave", "ShaderFx"); RNA_def_struct_ui_text(srna, "Wave Deformation Effect", "Wave Deformation effect"); RNA_def_struct_sdna(srna, "WaveShaderFxData"); - RNA_def_struct_ui_icon(srna, ICON_SOLO_ON); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); prop = RNA_def_property(srna, "orientation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "orientation"); @@ -309,7 +309,7 @@ static void rna_def_shader_fx_pixel(BlenderRNA *brna) srna = RNA_def_struct(brna, "ShaderFxPixel", "ShaderFx"); RNA_def_struct_ui_text(srna, "Pixelate Effect", "Pixelate effect"); RNA_def_struct_sdna(srna, "PixelShaderFxData"); - RNA_def_struct_ui_icon(srna, ICON_SOLO_ON); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "size"); @@ -339,7 +339,7 @@ static void rna_def_shader_fx_rim(BlenderRNA *brna) srna = RNA_def_struct(brna, "ShaderFxRim", "ShaderFx"); RNA_def_struct_ui_text(srna, "Rim Effect", "Rim effect"); RNA_def_struct_sdna(srna, "RimShaderFxData"); - RNA_def_struct_ui_icon(srna, ICON_SOLO_ON); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); prop = RNA_def_property(srna, "offset", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "offset"); @@ -390,7 +390,7 @@ static void rna_def_shader_fx_swirl(BlenderRNA *brna) srna = RNA_def_struct(brna, "ShaderFxSwirl", "ShaderFx"); RNA_def_struct_ui_text(srna, "Swirl Effect", "Swirl effect"); RNA_def_struct_sdna(srna, "SwirlShaderFxData"); - RNA_def_struct_ui_icon(srna, ICON_SOLO_ON); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); prop = RNA_def_property(srna, "radius", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "radius"); @@ -425,7 +425,7 @@ static void rna_def_shader_fx_flip(BlenderRNA *brna) srna = RNA_def_struct(brna, "ShaderFxFlip", "ShaderFx"); RNA_def_struct_ui_text(srna, "Flip Effect", "Flip effect"); RNA_def_struct_sdna(srna, "FlipShaderFxData"); - RNA_def_struct_ui_icon(srna, ICON_SOLO_ON); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); prop = RNA_def_property(srna, "flip_horizontal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_FLIP_HORIZONTAL); @@ -446,7 +446,7 @@ static void rna_def_shader_fx_light(BlenderRNA *brna) srna = RNA_def_struct(brna, "ShaderFxLight", "ShaderFx"); RNA_def_struct_ui_text(srna, "Light Effect", "Light effect"); RNA_def_struct_sdna(srna, "LightShaderFxData"); - RNA_def_struct_ui_icon(srna, ICON_SOLO_ON); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "energy"); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d7563f13dc2..2e50111b01b 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -273,7 +273,7 @@ const EnumPropertyItem rna_enum_clip_editor_mode_items[] = { /* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */ static const EnumPropertyItem buttons_context_items[] = { - {BCONTEXT_TOOL, "TOOL", ICON_PREFERENCES, "Tool", "Tool settings"}, + {BCONTEXT_TOOL, "TOOL", ICON_TOOL_SETTINGS, "Tool", "Tool settings"}, {BCONTEXT_SCENE, "SCENE", ICON_SCENE_DATA, "Scene", "Scene"}, {BCONTEXT_RENDER, "RENDER", ICON_SCENE, "Render", "Render"}, {BCONTEXT_VIEW_LAYER, "VIEW_LAYER", ICON_RENDER_RESULT, "View Layer", "View layer"}, @@ -288,8 +288,7 @@ static const EnumPropertyItem buttons_context_items[] = { {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"}, {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"}, {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"}, - {BCONTEXT_WORKSPACE, "WORKSPACE", ICON_SPLITSCREEN, "Workspace", "Workspace"}, - {BCONTEXT_SHADERFX, "SHADERFX", ICON_SOLO_ON, "Effects", "Object visual effects" }, + {BCONTEXT_SHADERFX, "SHADERFX", ICON_SHADERFX, "Effects", "Object visual effects" }, {0, NULL, 0, NULL, NULL} }; @@ -1319,10 +1318,6 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf( RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_TOOL); } - if (sbuts->pathflag & (1 << BCONTEXT_WORKSPACE)) { - RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORKSPACE); - } - if (totitem) { RNA_enum_item_add_separator(&item, &totitem); } @@ -2746,7 +2741,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_BONE_SELECT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Bone Selection", "Show the Bone Selection Overlay"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); prop = RNA_def_property(srna, "bone_select_alpha", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "overlay.bone_select_alpha"); @@ -2754,7 +2749,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Opacity", "Opacity to use for bone selection"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); prop = RNA_def_property(srna, "show_motion_paths", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_MOTION_PATHS); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 5001f633727..bafc7dc69c1 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -543,7 +543,10 @@ void RNA_api_ui_layout(StructRNA *srna) func = RNA_def_function(srna, "split", "uiLayoutSplit"); parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in"); RNA_def_function_return(func, parm); - RNA_def_float(func, "percentage", 0.0f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at", 0.0f, 1.0f); + RNA_def_float( + func, "factor", 0.0f, 0.0f, 1.0f, "Percentage", + "Percentage of width to split at (leave unset for automatic calculation)", + 0.0f, 1.0f); RNA_def_boolean(func, "align", false, "", "Align buttons to each other"); /* radial/pie layout */ @@ -1003,10 +1006,11 @@ void RNA_api_ui_layout(StructRNA *srna) parm = RNA_def_string(func, "list_id", NULL, 0, "", "Identifier of this list widget (mandatory when using default \"" UI_UL_DEFAULT_CLASS_NAME "\" class). " - "If this is set, the uilist gets a custom ID, otherwise it takes the " + "If this not an empty string, the uilist gets a custom ID, otherwise it takes the " "name of the class used to define the uilist (for example, if the " "class name is \"OBJECT_UL_vgroups\", and list_id is not set by the " "script, then bl_idname = \"OBJECT_UL_vgroups\")"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_pointer(func, "dataptr", "AnyType", "", "Data from which to take the Collection property"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR); parm = RNA_def_string(func, "propname", NULL, 0, "", "Identifier of the Collection property in data"); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index a1780b45aed..f8a9b00c724 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -286,7 +286,7 @@ static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, bool modal) { if (modal == 0) { - return WM_keymap_find(keyconf, idname, spaceid, regionid); + return WM_keymap_ensure(keyconf, idname, spaceid, regionid); } else { return WM_modalkeymap_add(keyconf, idname, NULL); /* items will be lazy init */ @@ -596,8 +596,7 @@ void RNA_api_wm(StructRNA *srna) func = RNA_def_function(srna, "popmenu_end__internal", "rna_PopMenuEnd"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); - + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED); /* wrap UI_popover_begin */ func = RNA_def_function(srna, "popover_begin__internal", "rna_PopoverBegin"); @@ -612,7 +611,7 @@ void RNA_api_wm(StructRNA *srna) func = RNA_def_function(srna, "popover_end__internal", "rna_PopoverEnd"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "menu", "UIPopover", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED); RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map"); @@ -634,7 +633,7 @@ void RNA_api_wm(StructRNA *srna) func = RNA_def_function(srna, "piemenu_end__internal", "rna_PieMenuEnd"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "menu", "UIPieMenu", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED); /* access last operator options (optionally create). */ func = RNA_def_function(srna, "operator_properties_last", "rna_WindoManager_operator_properties_last"); diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c index 88b79e8ee32..b9ca6412f7a 100644 --- a/source/blender/makesrna/intern/rna_workspace.c +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -152,6 +152,12 @@ static int rna_WorkspaceTool_index_get(PointerRNA *ptr) return (tref->runtime) ? tref->runtime->index : 0; } +static int rna_WorkspaceTool_has_datablock_get(PointerRNA *ptr) +{ + bToolRef *tref = ptr->data; + return (tref->runtime) ? (tref->runtime->data_block[0] != '\0') : false; +} + #else /* RNA_RUNTIME */ static void rna_def_workspace_owner(BlenderRNA *brna) @@ -230,6 +236,13 @@ static void rna_def_workspace_tool(BlenderRNA *brna) RNA_def_property_enum_items(prop, rna_enum_space_type_items); RNA_def_property_ui_text(prop, "Space Type", ""); + RNA_define_verify_sdna(0); + prop = RNA_def_property(srna, "has_datablock", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Has Datablock", ""); + RNA_def_property_boolean_funcs(prop, "rna_WorkspaceTool_has_datablock_get", NULL); + RNA_define_verify_sdna(1); + RNA_api_workspace_tool(srna); } @@ -307,11 +320,9 @@ static void rna_def_workspace(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Active Tool Space", "Tool mode"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); -#if 0 prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, rna_enum_object_mode_items); - RNA_def_property_ui_text(prop, "Mode", "Object interaction mode used in this window"); -#endif + RNA_def_property_enum_items(prop, rna_enum_workspace_object_mode_items); + RNA_def_property_ui_text(prop, "Object Mode", "Switch to this object mode when activating the workspace"); /* Flags */ prop = RNA_def_property(srna, "use_filter_by_owner", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index c44b65dffec..7fa1705249c 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -122,7 +122,7 @@ static void deformVerts( MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ armature_deform_verts(amd->object, ctx->object, mesh, vertexCos, NULL, - numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); + numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name, NULL); /* free cache */ if (amd->prevCos) { @@ -141,7 +141,7 @@ static void deformVertsEM( MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, NULL, - numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); + numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name, NULL); /* free cache */ if (amd->prevCos) { @@ -163,7 +163,7 @@ static void deformMatricesEM( Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, em, mesh, NULL, false, false); armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts, - amd->deformflag, NULL, amd->defgrp_name); + amd->deformflag, NULL, amd->defgrp_name, NULL); if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); @@ -178,7 +178,7 @@ static void deformMatrices( Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false); armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts, - amd->deformflag, NULL, amd->defgrp_name); + amd->deformflag, NULL, amd->defgrp_name, NULL); if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index ef447ff30ec..a961208755d 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -283,8 +283,8 @@ static void bevel_fix_normal_shading_continuity(BevelModifierData *bmd, BMesh *b if (f_b) has_f_b = BLI_ghash_haskey(faceHash, f_b); if (has_f_a ^ has_f_b) { - /* If one of both faces is present in faceHash then we are at a border - * between new vmesh created and reconstructed face */ + /* If one of both faces is present in faceHash then we are at a border + * between new vmesh created and reconstructed face */ for (int i = 0; i < 2; i++) { BMVert *v = (i == 0) ? e->v1 : e->v2; @@ -316,8 +316,8 @@ static void bevel_fix_normal_shading_continuity(BevelModifierData *bmd, BMesh *b } } else if (has_f_a == true && has_f_b == true) { - /* Else if both faces are present we assign clnor corresponding - * to vert normal and face normal */ + /* Else if both faces are present we assign clnor corresponding + * to vert normal and face normal */ for (int i = 0; i < 2; i++) { BMVert *v = (i == 0) ? e->v1 : e->v2; BM_ITER_ELEM(l, &liter, v, BM_LOOPS_OF_VERT) { diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c index 8bed99bd21c..fd6f8a0df4d 100644 --- a/source/blender/modifiers/intern/MOD_fracture.c +++ b/source/blender/modifiers/intern/MOD_fracture.c @@ -40,7 +40,7 @@ #include "BLI_ghash.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_fracture_types.h" #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 1298ad63604..24495efa08d 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -169,7 +169,7 @@ static Mesh *applyModifier_subdiv(ModifierData *md, /* Happens on bad topology, ut also on empty input mesh. */ return result; } - BKE_subdiv_displacement_attach_from_multires(subdiv, object, mmd); + BKE_subdiv_displacement_attach_from_multires(subdiv, mesh, mmd); result = BKE_subdiv_to_mesh(subdiv, &mesh_settings, mesh); /* TODO(sergey): Cache subdiv somehow. */ // BKE_subdiv_stats_print(&subdiv->stats); diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 9a27f31adaa..a15c4169df3 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -37,7 +37,7 @@ #include "MEM_guardedalloc.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_smoke_types.h" diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.c b/source/blender/nodes/shader/nodes/node_shader_emission.c index 7a7c89be3a0..25194c23d0a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_emission.c +++ b/source/blender/nodes/shader/nodes/node_shader_emission.c @@ -30,7 +30,7 @@ /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_emission_in[] = { - { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f}, { -1, 0, "" } }; diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c index 5fd9c6b50de..ddd71eb93e3 100644 --- a/source/blender/physics/intern/implicit_blender.c +++ b/source/blender/physics/intern/implicit_blender.c @@ -456,6 +456,13 @@ DO_INLINE void muladd_fmatrix_fvector(float to[3], float matrix[3][3], float fro to[2] += dot_v3v3(matrix[2], from); } +DO_INLINE void muladd_fmatrixT_fvector(float to[3], float matrix[3][3], float from[3]) +{ + to[0] += matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2]; + to[1] += matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2]; + to[2] += matrix[0][2] * from[0] + matrix[1][2] * from[1] + matrix[2][2] * from[2]; +} + BLI_INLINE void outerproduct(float r[3][3], const float a[3], const float b[3]) { mul_v3_v3fl(r[0], a, b[0]); @@ -599,7 +606,9 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector #pragma omp section { for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) { - muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]); + /* This is the lower triangle of the sparse matrix, + * therefore multiplication occurs with transposed submatrices. */ + muladd_fmatrixT_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]); } } #pragma omp section @@ -612,8 +621,6 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector add_lfvector_lfvector(to, to, temp, from[0].vcount); del_lfvector(temp); - - } /* SPARSE SYMMETRIC sub big matrix with big matrix*/ diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index da1b031f1c0..24d2ef0463d 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -76,6 +76,7 @@ void BPY_thread_restore(BPy_ThreadStatePtr tstate); bool BPY_execute_filepath(struct bContext *C, const char *filepath, struct ReportList *reports); bool BPY_execute_text(struct bContext *C, struct Text *text, struct ReportList *reports, const bool do_jump); bool BPY_execute_string_as_number(struct bContext *C, const char *expr, const bool verbose, double *r_value); +bool BPY_execute_string_as_intptr(struct bContext *C, const char *expr, const bool verbose, intptr_t *r_value); bool BPY_execute_string_as_string(struct bContext *C, const char *expr, const bool verbose, char **r_value); bool BPY_execute_string_ex(struct bContext *C, const char *expr, bool use_eval); bool BPY_execute_string(struct bContext *C, const char *expr); diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c index ee96c859858..49e71da3bc3 100644 --- a/source/blender/python/bmesh/bmesh_py_ops.c +++ b/source/blender/python/bmesh/bmesh_py_ops.c @@ -75,10 +75,14 @@ static char *bmp_slots_as_args(const BMOSlotType slot_types[BMO_OP_MAX_SLOTS], c { DynStr *dyn_str = BLI_dynstr_new(); char *ret; + bool quoted; + bool set; int i = 0; while (*slot_types[i].name) { + quoted = false; + set = false; /* cut off '.out' by using a string size arg */ const int name_len = is_out ? (strchr(slot_types[i].name, '.') - slot_types[i].name) : @@ -86,7 +90,19 @@ static char *bmp_slots_as_args(const BMOSlotType slot_types[BMO_OP_MAX_SLOTS], c const char *value = "<Unknown>"; switch (slot_types[i].type) { case BMO_OP_SLOT_BOOL: value = "False"; break; - case BMO_OP_SLOT_INT: value = "0"; break; + case BMO_OP_SLOT_INT: + if (slot_types[i].subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_ENUM) { + value = slot_types[i].enum_flags[0].identifier; + quoted = true; + } + else if (slot_types[i].subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_FLAG) { + value = ""; + set = true; + } + else { + value = "0"; + } + break; case BMO_OP_SLOT_FLT: value = "0.0"; break; case BMO_OP_SLOT_PTR: value = "None"; break; case BMO_OP_SLOT_MAT: value = "Matrix()"; break; @@ -95,7 +111,12 @@ static char *bmp_slots_as_args(const BMOSlotType slot_types[BMO_OP_MAX_SLOTS], c (slot_types[i].subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) ? "None" : "[]"; break; case BMO_OP_SLOT_MAPPING: value = "{}"; break; } - BLI_dynstr_appendf(dyn_str, i ? ", %.*s=%s" : "%.*s=%s", name_len, slot_types[i].name, value); + BLI_dynstr_appendf( + dyn_str, i ? ", %.*s=%s%s%s%s%s" : "%.*s=%s%s%s%s%s", + name_len, slot_types[i].name, + set ? "{" : "", quoted ? "'" : "", + value, + quoted ? "'" : "", set ? "}" : ""); i++; } diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c index 4dce0dc2a22..74d899ba3f8 100644 --- a/source/blender/python/bmesh/bmesh_py_ops_call.c +++ b/source/blender/python/bmesh/bmesh_py_ops_call.c @@ -46,6 +46,8 @@ #include "../generic/python_utildefines.h" #include "../generic/py_capi_utils.h" +BLI_STATIC_ASSERT(sizeof(PyC_FlagSet) == sizeof(BMO_FlagSet), "size mismatch"); + static int bpy_bm_op_as_py_error(BMesh *bm) { if (BMO_error_occurred(bm)) { @@ -169,16 +171,46 @@ static int bpy_slot_from_py( } case BMO_OP_SLOT_INT: { - const int param = PyC_Long_AsI32(value); + if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_ENUM) { + int enum_val = -1; + PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_flags; + const char *enum_str = _PyUnicode_AsString(value); - if (param == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, - "%.200s: keyword \"%.200s\" expected an int, not %.200s", - opname, slot_name, Py_TYPE(value)->tp_name); - return -1; + if (enum_str == NULL) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected a string, not %.200s", + opname, slot_name, Py_TYPE(value)->tp_name); + return -1; + } + + if (PyC_FlagSet_ValueFromID(items, enum_str, &enum_val, slot_name) == -1) { + return -1; + } + + BMO_SLOT_AS_INT(slot) = enum_val; + } + else if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_FLAG) { + int flag = 0; + PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_flags; + + if (PyC_FlagSet_ToBitfield(items, value, &flag, slot_name) == -1) { + return -1; + } + + BMO_SLOT_AS_INT(slot) = flag; } else { - BMO_SLOT_AS_INT(slot) = param; + const int param = PyC_Long_AsI32(value); + + if (param == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected an int, not %.200s", + opname, slot_name, Py_TYPE(value)->tp_name); + return -1; + } + else { + BMO_SLOT_AS_INT(slot) = param; + } } break; } diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 6517cc271cc..d8d6b5c7ce7 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -1140,6 +1140,40 @@ bool PyC_RunString_AsNumber(const char *expr, const char *filename, double *r_va return ok; } +bool PyC_RunString_AsIntPtr(const char *expr, const char *filename, intptr_t *r_value) +{ + PyObject *py_dict, *retval; + bool ok = true; + PyObject *main_mod = NULL; + + PyC_MainModule_Backup(&main_mod); + + py_dict = PyC_DefaultNameSpace(filename); + + retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict); + + if (retval == NULL) { + ok = false; + } + else { + intptr_t val; + + val = (intptr_t)PyLong_AsVoidPtr(retval); + if (val == 0 && PyErr_Occurred()) { + ok = false; + } + else { + *r_value = val; + } + + Py_DECREF(retval); + } + + PyC_MainModule_Restore(main_mod); + + return ok; +} + bool PyC_RunString_AsString(const char *expr, const char *filename, char **r_value) { PyObject *py_dict, *retval; diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index fef9171b4d4..b962f40c180 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -102,6 +102,7 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_val PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag); bool PyC_RunString_AsNumber(const char *expr, const char *filename, double *r_value); +bool PyC_RunString_AsIntPtr(const char *expr, const char *filename, intptr_t *r_value); bool PyC_RunString_AsString(const char *expr, const char *filename, char **r_value); int PyC_ParseBool(PyObject *o, void *p); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 64bc54c6221..5a908f866a0 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -628,13 +628,10 @@ bool BPY_execute_string_as_number(bContext *C, const char *expr, const bool verb */ bool BPY_execute_string_as_string(bContext *C, const char *expr, const bool verbose, char **r_value) { + BLI_assert(r_value && expr); PyGILState_STATE gilstate; bool ok = true; - if (!r_value || !expr) { - return -1; - } - if (expr[0] == '\0') { *r_value = NULL; return ok; @@ -658,17 +655,49 @@ bool BPY_execute_string_as_string(bContext *C, const char *expr, const bool verb return ok; } +/** + * Support both int and pointers. + * + * \return success + */ +bool BPY_execute_string_as_intptr(bContext *C, const char *expr, const bool verbose, intptr_t *r_value) +{ + BLI_assert(r_value && expr); + PyGILState_STATE gilstate; + bool ok = true; + + if (expr[0] == '\0') { + *r_value = 0; + return ok; + } + + bpy_context_set(C, &gilstate); + + ok = PyC_RunString_AsIntPtr(expr, "<blender button>", r_value); + + if (ok == false) { + if (verbose) { + BPy_errors_to_report_ex(CTX_wm_reports(C), false, false); + } + else { + PyErr_Clear(); + } + } + + bpy_context_clear(C, &gilstate); + + return ok; +} bool BPY_execute_string_ex(bContext *C, const char *expr, bool use_eval) { + BLI_assert(expr); PyGILState_STATE gilstate; PyObject *main_mod = NULL; PyObject *py_dict, *retval; bool ok = true; Main *bmain_back; /* XXX, quick fix for release (Copy Settings crash), needs further investigation */ - if (!expr) return -1; - if (expr[0] == '\0') { return ok; } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 30bd3bc5ca3..9de9f6179d6 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -5654,6 +5654,17 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject item = NULL; if (i < pyargs_len) { + /* New in 2.8x, optional arguments must be keywords. */ + if (UNLIKELY((flag_parameter & PARM_REQUIRED) == 0)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s(): required parameter \"%.200s\" to be a keyword argument!", + RNA_struct_identifier(self_ptr->type), + RNA_function_identifier(self_func), + RNA_property_identifier(parm)); + err = -1; + break; + } + item = PyTuple_GET_ITEM(args, i); kw_arg = false; } diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c index 5155a214aab..3aa8f586329 100644 --- a/source/blender/render/intern/source/bake_api.c +++ b/source/blender/render/intern/source/bake_api.c @@ -590,7 +590,8 @@ bool RE_bake_pixels_populate_from_objects( /* cast ray */ if (!cast_ray_highpoly(treeData, tri_low, tris_high, pixel_array_from, pixel_array_to, mat_low, - highpoly, co, dir, i, tot_highpoly)) { + highpoly, co, dir, i, tot_highpoly)) + { /* if it fails mask out the original pixel array */ pixel_array_from[i].primitive_id = -1; } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 47548c15b9c..c6b372a53e5 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -37,7 +37,7 @@ #include <errno.h> #include "DNA_anim_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_image_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index c259a60cda0..60e0a3d3843 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -882,7 +882,8 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil /* Skip non-RGBA and Z passes if not using multi layer. */ if (!multi_layer && !(STREQ(rp->name, RE_PASSNAME_COMBINED) || STREQ(rp->name, "") || - (STREQ(rp->name, RE_PASSNAME_Z) && write_z))) { + (STREQ(rp->name, RE_PASSNAME_Z) && write_z))) + { continue; } diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 2841d96025e..e24e14058ed 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1246,127 +1246,127 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa float facm; switch (blendtype) { - case MTEX_BLEND: - fact*= facg; - facm= 1.0f-fact; - - in[0]= (fact*tex[0] + facm*out[0]); - in[1]= (fact*tex[1] + facm*out[1]); - in[2]= (fact*tex[2] + facm*out[2]); - break; - - case MTEX_MUL: - fact*= facg; - facm= 1.0f-fact; - in[0]= (facm+fact*tex[0])*out[0]; - in[1]= (facm+fact*tex[1])*out[1]; - in[2]= (facm+fact*tex[2])*out[2]; - break; - - case MTEX_SCREEN: - fact*= facg; - facm= 1.0f-fact; - in[0]= 1.0f - (facm+fact*(1.0f-tex[0])) * (1.0f-out[0]); - in[1]= 1.0f - (facm+fact*(1.0f-tex[1])) * (1.0f-out[1]); - in[2]= 1.0f - (facm+fact*(1.0f-tex[2])) * (1.0f-out[2]); - break; - - case MTEX_OVERLAY: - fact*= facg; - facm= 1.0f-fact; - - if (out[0] < 0.5f) - in[0] = out[0] * (facm + 2.0f*fact*tex[0]); - else - in[0] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[0])) * (1.0f - out[0]); - if (out[1] < 0.5f) - in[1] = out[1] * (facm + 2.0f*fact*tex[1]); - else - in[1] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[1])) * (1.0f - out[1]); - if (out[2] < 0.5f) - in[2] = out[2] * (facm + 2.0f*fact*tex[2]); - else - in[2] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[2])) * (1.0f - out[2]); - break; - - case MTEX_SUB: - fact= -fact; - ATTR_FALLTHROUGH; - case MTEX_ADD: - fact*= facg; - in[0]= (fact*tex[0] + out[0]); - in[1]= (fact*tex[1] + out[1]); - in[2]= (fact*tex[2] + out[2]); - break; - - case MTEX_DIV: - fact*= facg; - facm= 1.0f-fact; - - if (tex[0]!=0.0f) - in[0]= facm*out[0] + fact*out[0]/tex[0]; - if (tex[1]!=0.0f) - in[1]= facm*out[1] + fact*out[1]/tex[1]; - if (tex[2]!=0.0f) - in[2]= facm*out[2] + fact*out[2]/tex[2]; - - break; - - case MTEX_DIFF: - fact*= facg; - facm= 1.0f-fact; - in[0]= facm*out[0] + fact*fabsf(tex[0]-out[0]); - in[1]= facm*out[1] + fact*fabsf(tex[1]-out[1]); - in[2]= facm*out[2] + fact*fabsf(tex[2]-out[2]); - break; - - case MTEX_DARK: - fact*= facg; - facm= 1.0f-fact; - - in[0] = min_ff(out[0], tex[0])*fact + out[0]*facm; - in[1] = min_ff(out[1], tex[1])*fact + out[1]*facm; - in[2] = min_ff(out[2], tex[2])*fact + out[2]*facm; - break; - - case MTEX_LIGHT: - fact*= facg; - - in[0] = max_ff(fact * tex[0], out[0]); - in[1] = max_ff(fact * tex[1], out[1]); - in[2] = max_ff(fact * tex[2], out[2]); - break; - - case MTEX_BLEND_HUE: - fact*= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_HUE, in, fact, tex); - break; - case MTEX_BLEND_SAT: - fact*= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_SAT, in, fact, tex); - break; - case MTEX_BLEND_VAL: - fact*= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_VAL, in, fact, tex); - break; - case MTEX_BLEND_COLOR: - fact*= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_COLOR, in, fact, tex); - break; - case MTEX_SOFT_LIGHT: - fact*= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_SOFT, in, fact, tex); - break; - case MTEX_LIN_LIGHT: - fact*= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_LINEAR, in, fact, tex); - break; + case MTEX_BLEND: + fact*= facg; + facm= 1.0f-fact; + + in[0]= (fact*tex[0] + facm*out[0]); + in[1]= (fact*tex[1] + facm*out[1]); + in[2]= (fact*tex[2] + facm*out[2]); + break; + + case MTEX_MUL: + fact*= facg; + facm= 1.0f-fact; + in[0]= (facm+fact*tex[0])*out[0]; + in[1]= (facm+fact*tex[1])*out[1]; + in[2]= (facm+fact*tex[2])*out[2]; + break; + + case MTEX_SCREEN: + fact*= facg; + facm= 1.0f-fact; + in[0]= 1.0f - (facm+fact*(1.0f-tex[0])) * (1.0f-out[0]); + in[1]= 1.0f - (facm+fact*(1.0f-tex[1])) * (1.0f-out[1]); + in[2]= 1.0f - (facm+fact*(1.0f-tex[2])) * (1.0f-out[2]); + break; + + case MTEX_OVERLAY: + fact*= facg; + facm= 1.0f-fact; + + if (out[0] < 0.5f) + in[0] = out[0] * (facm + 2.0f*fact*tex[0]); + else + in[0] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[0])) * (1.0f - out[0]); + if (out[1] < 0.5f) + in[1] = out[1] * (facm + 2.0f*fact*tex[1]); + else + in[1] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[1])) * (1.0f - out[1]); + if (out[2] < 0.5f) + in[2] = out[2] * (facm + 2.0f*fact*tex[2]); + else + in[2] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[2])) * (1.0f - out[2]); + break; + + case MTEX_SUB: + fact= -fact; + ATTR_FALLTHROUGH; + case MTEX_ADD: + fact*= facg; + in[0]= (fact*tex[0] + out[0]); + in[1]= (fact*tex[1] + out[1]); + in[2]= (fact*tex[2] + out[2]); + break; + + case MTEX_DIV: + fact*= facg; + facm= 1.0f-fact; + + if (tex[0]!=0.0f) + in[0]= facm*out[0] + fact*out[0]/tex[0]; + if (tex[1]!=0.0f) + in[1]= facm*out[1] + fact*out[1]/tex[1]; + if (tex[2]!=0.0f) + in[2]= facm*out[2] + fact*out[2]/tex[2]; + + break; + + case MTEX_DIFF: + fact*= facg; + facm= 1.0f-fact; + in[0]= facm*out[0] + fact*fabsf(tex[0]-out[0]); + in[1]= facm*out[1] + fact*fabsf(tex[1]-out[1]); + in[2]= facm*out[2] + fact*fabsf(tex[2]-out[2]); + break; + + case MTEX_DARK: + fact*= facg; + facm= 1.0f-fact; + + in[0] = min_ff(out[0], tex[0])*fact + out[0]*facm; + in[1] = min_ff(out[1], tex[1])*fact + out[1]*facm; + in[2] = min_ff(out[2], tex[2])*fact + out[2]*facm; + break; + + case MTEX_LIGHT: + fact*= facg; + + in[0] = max_ff(fact * tex[0], out[0]); + in[1] = max_ff(fact * tex[1], out[1]); + in[2] = max_ff(fact * tex[2], out[2]); + break; + + case MTEX_BLEND_HUE: + fact*= facg; + copy_v3_v3(in, out); + ramp_blend(MA_RAMP_HUE, in, fact, tex); + break; + case MTEX_BLEND_SAT: + fact*= facg; + copy_v3_v3(in, out); + ramp_blend(MA_RAMP_SAT, in, fact, tex); + break; + case MTEX_BLEND_VAL: + fact*= facg; + copy_v3_v3(in, out); + ramp_blend(MA_RAMP_VAL, in, fact, tex); + break; + case MTEX_BLEND_COLOR: + fact*= facg; + copy_v3_v3(in, out); + ramp_blend(MA_RAMP_COLOR, in, fact, tex); + break; + case MTEX_SOFT_LIGHT: + fact*= facg; + copy_v3_v3(in, out); + ramp_blend(MA_RAMP_SOFT, in, fact, tex); + break; + case MTEX_LIN_LIGHT: + fact*= facg; + copy_v3_v3(in, out); + ramp_blend(MA_RAMP_LINEAR, in, fact, tex); + break; } } @@ -1382,64 +1382,64 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen if (flip) SWAP(float, fact, facm); switch (blendtype) { - case MTEX_BLEND: - in= fact*tex + facm*out; - break; - - case MTEX_MUL: - facm= 1.0f-facg; - in= (facm+fact*tex)*out; - break; - - case MTEX_SCREEN: - facm= 1.0f-facg; - in= 1.0f-(facm+fact*(1.0f-tex))*(1.0f-out); - break; - - case MTEX_OVERLAY: - facm= 1.0f-facg; - if (out < 0.5f) - in = out * (facm + 2.0f*fact*tex); - else - in = 1.0f - (facm + 2.0f*fact*(1.0f - tex)) * (1.0f - out); - break; - - case MTEX_SUB: - fact= -fact; - ATTR_FALLTHROUGH; - case MTEX_ADD: - in= fact*tex + out; - break; - - case MTEX_DIV: - if (tex!=0.0f) - in= facm*out + fact*out/tex; - break; - - case MTEX_DIFF: - in= facm*out + fact*fabsf(tex-out); - break; - - case MTEX_DARK: - in = min_ff(out, tex)*fact + out*facm; - break; - - case MTEX_LIGHT: - col= fact*tex; - if (col > out) in= col; else in= out; - break; - - case MTEX_SOFT_LIGHT: - scf=1.0f - (1.0f - tex) * (1.0f - out); - in= facm*out + fact * ((1.0f - out) * tex * out) + (out * scf); - break; - - case MTEX_LIN_LIGHT: - if (tex > 0.5f) - in = out + fact*(2.0f*(tex - 0.5f)); - else - in = out + fact*(2.0f*tex - 1.0f); - break; + case MTEX_BLEND: + in= fact*tex + facm*out; + break; + + case MTEX_MUL: + facm= 1.0f-facg; + in= (facm+fact*tex)*out; + break; + + case MTEX_SCREEN: + facm= 1.0f-facg; + in= 1.0f-(facm+fact*(1.0f-tex))*(1.0f-out); + break; + + case MTEX_OVERLAY: + facm= 1.0f-facg; + if (out < 0.5f) + in = out * (facm + 2.0f*fact*tex); + else + in = 1.0f - (facm + 2.0f*fact*(1.0f - tex)) * (1.0f - out); + break; + + case MTEX_SUB: + fact= -fact; + ATTR_FALLTHROUGH; + case MTEX_ADD: + in= fact*tex + out; + break; + + case MTEX_DIV: + if (tex!=0.0f) + in= facm*out + fact*out/tex; + break; + + case MTEX_DIFF: + in= facm*out + fact*fabsf(tex-out); + break; + + case MTEX_DARK: + in = min_ff(out, tex)*fact + out*facm; + break; + + case MTEX_LIGHT: + col= fact*tex; + if (col > out) in= col; else in= out; + break; + + case MTEX_SOFT_LIGHT: + scf=1.0f - (1.0f - tex) * (1.0f - out); + in= facm*out + fact * ((1.0f - out) * tex * out) + (out * scf); + break; + + case MTEX_LIN_LIGHT: + if (tex > 0.5f) + in = out + fact*(2.0f*(tex - 0.5f)); + else + in = out + fact*(2.0f*tex - 1.0f); + break; } return in; diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index 2e84140707d..e184cfe9aa3 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -78,7 +78,7 @@ bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem * int WM_keymap_item_to_string(wmKeyMapItem *kmi, const bool compact, char *result, const int result_len); wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid); -wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid); +wmKeyMap *WM_keymap_ensure(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid); wmKeyMap *WM_keymap_find_all(const struct bContext *C, const char *idname, int spaceid, int regionid); wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap); wmKeyMap *WM_keymap_guess_opname(const struct bContext *C, const char *opname); diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 3ba9fa71601..e46cd9049a5 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -656,7 +656,7 @@ wmKeyMap *WM_gizmogroup_keymap_common( const wmGizmoGroupType *gzgt, wmKeyConfig *config) { /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */ - wmKeyMap *km = WM_keymap_find(config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid); + wmKeyMap *km = WM_keymap_ensure(config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid); WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0); gizmogroup_tweak_modal_keymap(config, gzgt->name); @@ -671,7 +671,7 @@ wmKeyMap *WM_gizmogroup_keymap_common_select( const wmGizmoGroupType *gzgt, wmKeyConfig *config) { /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */ - wmKeyMap *km = WM_keymap_find(config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid); + wmKeyMap *km = WM_keymap_ensure(config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid); WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0); WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", EVT_TWEAK_S, KM_ANY, 0, 0); diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index d0f6ab9f451..2c0d0ff34a7 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -1131,7 +1131,7 @@ void wm_gizmomaptypes_free(void) void wm_gizmos_keymap(wmKeyConfig *keyconf) { /* we add this item-less keymap once and use it to group gizmo-group keymaps into it */ - WM_keymap_find(keyconf, "Gizmos", 0, 0); + WM_keymap_ensure(keyconf, "Gizmos", 0, 0); for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type; gzmap_type = gzmap_type->next) { for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref; gzgt_ref = gzgt_ref->next) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 1c709dcb83c..cd1357e85b1 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1871,13 +1871,15 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve for (kmi = keymap->items.first; kmi; kmi = kmi->next) { if (wm_eventmatch(event, kmi)) { - - event->prevtype = event->type; - event->prevval = event->val; - event->type = EVT_MODAL_MAP; - event->val = kmi->propvalue; - - break; + if ((keymap->poll_modal_item == NULL) || + (keymap->poll_modal_item(op, kmi->propvalue))) + { + event->prevtype = event->type; + event->prevval = event->val; + event->type = EVT_MODAL_MAP; + event->val = kmi->propvalue; + break; + } } } } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 6815ff4413a..55b00b2ef61 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -824,7 +824,7 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int return NULL; } -wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) +wmKeyMap *WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) { wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); @@ -851,7 +851,7 @@ wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items) { - wmKeyMap *km = WM_keymap_find(keyconf, idname, 0, 0); + wmKeyMap *km = WM_keymap_ensure(keyconf, idname, 0, 0); km->flag |= KEYMAP_MODAL; km->modal_items = items; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index bbc99a87d6f..28a2f5398fb 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3436,7 +3436,7 @@ static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf) /* default keymap for windows and screens, only call once per WM */ void wm_window_keymap(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Window", 0, 0); wmKeyMapItem *kmi; /* note, this doesn't replace existing keymap items */ @@ -3446,7 +3446,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) #ifdef __APPLE__ WM_keymap_add_item(keymap, "WM_OT_read_homefile", NKEY, KM_PRESS, KM_OSKEY, 0); - WM_keymap_add_menu(keymap, "INFO_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); + WM_keymap_add_menu(keymap, "TOPBAR_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "WM_OT_save_mainfile", SKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); @@ -3456,7 +3456,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) #ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0); #endif - WM_keymap_add_menu(keymap, "INFO_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + WM_keymap_add_menu(keymap, "TOPBAR_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_CTRL, 0); #ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 398ed7f1b70..568dfacd41c 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -767,13 +767,13 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm) wm_window_ensure_eventstate(win); /* add keymap handlers (1 handler for all keys in map!) */ - keymap = WM_keymap_find(wm->defaultconf, "Window", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Window", 0, 0); WM_event_add_keymap_handler(&win->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Screen", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Screen", 0, 0); WM_event_add_keymap_handler(&win->handlers, keymap); - keymap = WM_keymap_find(wm->defaultconf, "Screen Editing", 0, 0); + keymap = WM_keymap_ensure(wm->defaultconf, "Screen Editing", 0, 0); WM_event_add_keymap_handler(&win->modalhandlers, keymap); /* add drop boxes */ diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c new file mode 100644 index 00000000000..9f34729cd2f --- /dev/null +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -0,0 +1,772 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * BKE_bad_level_calls function stubs + */ + +/** \file blenderplayer/bad_level_call_stubs/stubs.c + * \ingroup blc + */ + +#ifdef WITH_GAMEENGINE + +#define ASSERT_STUBS 0 +#if ASSERT_STUBS +# include <assert.h> +# define STUB_ASSERT(x) (assert(x)) +#else +# define STUB_ASSERT(x) +#endif + + +struct ARegion; +struct ARegionType; +struct BMEditMesh; +struct Base; +struct bContext; +struct BoundBox; +struct Brush; +struct CSG_FaceIteratorDescriptor; +struct CSG_VertexIteratorDescriptor; +struct ChannelDriver; +struct ColorBand; +struct Context; +struct Curve; +struct CurveMapping; +struct DerivedMesh; +struct EditBone; +struct EnvMap; +struct FCurve; +struct Heap; +struct HeapNode; +struct ID; +struct ImBuf; +struct Image; +struct ImageUser; +struct KeyingSet; +struct KeyingSetInfo; +struct MCol; +struct MTex; +struct Main; +struct Mask; +struct Material; +struct MenuType; +struct Mesh; +struct MetaBall; +struct Lattice; +struct ModifierData; +struct MovieClip; +struct MultiresModifierData; +struct HookModifierData; +struct NodeBlurData; +struct Nurb; +struct Object; +struct PBVHNode; +struct PyObject; +struct Render; +struct RenderEngine; +struct RenderEngineType; +struct RenderLayer; +struct RenderResult; +struct Scene; +struct Scene; +struct ScrArea; +struct SculptSession; +struct ShadeInput; +struct ShadeResult; +struct SpaceButs; +struct SpaceClip; +struct SpaceImage; +struct SpaceNode; +struct Tex; +struct TexResult; +struct Text; +struct ToolSettings; +struct View2D; +struct View3D; +struct bAction; +struct bArmature; +struct bConstraint; +struct bConstraintOb; +struct bConstraintTarget; +struct bContextDataResult; +struct bGPDlayer; +struct bNode; +struct bNodeType; +struct bNodeSocket; +struct bNodeSocketType; +struct bNodeTree; +struct bNodeTreeType; +struct bPoseChannel; +struct bPythonConstraint; +struct bTheme; +struct uiLayout; +struct wmEvent; +struct wmKeyConfig; +struct wmKeyMap; +struct wmOperator; +struct wmOperatorType; +struct wmWindow; +struct wmWindowManager; + + +/* -------------------------------------------------------------------- */ +/* Declarations */ + +/* may cause troubles... enable for now so args match for certain */ +#if 1 +#if defined(__GNUC__) +# pragma GCC diagnostic error "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +#include "../../intern/dualcon/dualcon.h" +#include "../../intern/elbeem/extern/elbeem.h" +#include "../blender/blenkernel/BKE_modifier.h" +#include "../blender/blenkernel/BKE_paint.h" +#include "../blender/compositor/COM_compositor.h" +#include "../blender/editors/include/ED_armature.h" +#include "../blender/editors/include/ED_anim_api.h" +#include "../blender/editors/include/ED_buttons.h" +#include "../blender/editors/include/ED_clip.h" +#include "../blender/editors/include/ED_curve.h" +#include "../blender/editors/include/ED_fileselect.h" +#include "../blender/editors/include/ED_gpencil.h" +#include "../blender/editors/include/ED_image.h" +#include "../blender/editors/include/ED_info.h" +#include "../blender/editors/include/ED_keyframes_edit.h" +#include "../blender/editors/include/ED_keyframing.h" +#include "../blender/editors/include/ED_lattice.h" +#include "../blender/editors/include/ED_mball.h" +#include "../blender/editors/include/ED_mesh.h" +#include "../blender/editors/include/ED_node.h" +#include "../blender/editors/include/ED_object.h" +#include "../blender/editors/include/ED_particle.h" +#include "../blender/editors/include/ED_render.h" +#include "../blender/editors/include/ED_screen.h" +#include "../blender/editors/include/ED_space_api.h" +#include "../blender/editors/include/ED_text.h" +#include "../blender/editors/include/ED_transform.h" +#include "../blender/editors/include/ED_transform_snap_object_context.h" +#include "../blender/editors/include/ED_uvedit.h" +#include "../blender/editors/include/ED_view3d.h" +#include "../blender/editors/include/UI_interface.h" +#include "../blender/editors/include/UI_interface_icons.h" +#include "../blender/editors/include/UI_resources.h" +#include "../blender/editors/include/UI_view2d.h" +#include "../blender/freestyle/FRS_freestyle.h" +#include "../blender/python/BPY_extern.h" +#include "../blender/render/extern/include/RE_engine.h" +#include "../blender/render/extern/include/RE_pipeline.h" +#include "../blender/render/extern/include/RE_render_ext.h" +#include "../blender/render/extern/include/RE_shader_ext.h" +#include "../blender/windowmanager/WM_api.h" + + +/* -------------------------------------------------------------------- */ +/* Externs + * (ideally we wouldn't have _any_ but we can't include all directly) + */ + +/* bpy_operator_wrap.h */ +extern void macro_wrapper(struct wmOperatorType *ot, void *userdata); +extern void operator_wrapper(struct wmOperatorType *ot, void *userdata); +/* bpy_rna.h */ +extern bool pyrna_id_FromPyObject(struct PyObject *obj, struct ID **id); +extern const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid); +extern const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid); +extern struct PyObject *pyrna_id_CreatePyObject(struct ID *id); +extern bool pyrna_id_CheckPyObject(struct PyObject *obj); +/* bpy_interface.c */ +bool BPY_string_is_keyword(const char *str) { return false; } + +#endif +/* end declarations */ + + +/* -------------------------------------------------------------------- */ +/* Return Macro's */ + +#include <string.h> /* memset */ +#define RET_NULL {STUB_ASSERT(0); return (void *) NULL;} +#define RET_ZERO {STUB_ASSERT(0); return 0;} +#define RET_MINUSONE {STUB_ASSERT(0); return -1;} +#define RET_STRUCT(t) {struct t v; STUB_ASSERT(0); memset(&v, 0, sizeof(v)); return v;} +#define RET_ARG(arg) {STUB_ASSERT(0); return arg; } +#define RET_NONE {STUB_ASSERT(0);} + + +/* -------------------------------------------------------------------- */ +/* Stubs */ + +/*new render funcs */ +void EDBM_selectmode_set(struct BMEditMesh *em) RET_NONE +void EDBM_mesh_load(struct Main *bmain, struct Object *ob) RET_NONE +void EDBM_mesh_make(struct Object *ob, const int select_mode, const bool use_key_index) RET_NONE +void EDBM_mesh_normals_update(struct BMEditMesh *em) RET_NONE +void *g_system; +bool EDBM_uv_check(struct BMEditMesh *em) RET_ZERO + +float *RE_RenderLayerGetPass(volatile struct RenderLayer *rl, const char *name, const char *viewname) RET_NULL +float RE_filter_value(int type, float x) RET_ZERO +struct RenderLayer *RE_GetRenderLayer(struct RenderResult *rr, const char *name) RET_NULL +void RE_texture_rng_init() RET_NONE +void RE_texture_rng_exit() RET_NONE + +bool RE_layers_have_name(struct RenderResult *result) RET_ZERO +const char *RE_engine_active_view_get(struct RenderEngine *engine) RET_NULL +void RE_engine_active_view_set(struct RenderEngine *engine, const char *viewname) RET_NONE +void RE_engine_get_camera_model_matrix(struct RenderEngine *engine, struct Object *camera, bool use_spherical_stereo, float *r_modelmat) RET_NONE +float RE_engine_get_camera_shift_x(struct RenderEngine *engine, struct Object *camera, bool use_spherical_stereo) RET_ZERO +bool RE_engine_get_spherical_stereo(struct RenderEngine *engine, struct Object *camera) RET_ZERO +void RE_SetActiveRenderView(struct Render *re, const char *viewname) RET_NONE + +struct RenderPass *RE_pass_find_by_name(volatile struct RenderLayer *rl, const char *name, const char *viewname) RET_NULL +struct RenderPass *RE_pass_find_by_type(volatile struct RenderLayer *rl, int passtype, const char *viewname) RET_NULL +bool RE_HasCombinedLayer(RenderResult *res) RET_ZERO + +/* imagetexture.c stub */ +void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float *result) RET_NONE + +/* Freestyle */ +bool ED_texture_context_check_linestyle(const struct bContext *C) RET_ZERO +void FRS_free_view_map_cache(void) RET_NONE + +/* texture.c */ +int multitex_ext(struct Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres, short thread, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image) RET_ZERO +int multitex_ext_safe(struct Tex *tex, float texvec[3], struct TexResult *texres, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image) RET_ZERO +int multitex_nodes(struct Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres, const short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex, struct ImagePool *pool) RET_ZERO + +struct Material *RE_sample_material_init(struct Material *orig_mat, struct Scene *scene) RET_NULL +void RE_sample_material_free(struct Material *mat) RET_NONE +void RE_sample_material_color( + struct Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3], + int tri_index, struct DerivedMesh *orcoDm, struct Object *ob) RET_NONE +/* nodes */ +struct Render *RE_GetRender(const char *name) RET_NULL +struct Render *RE_GetSceneRender(const struct Scene *scene) RET_NULL +struct Object *RE_GetCamera(struct Render *re) RET_NULL +float RE_lamp_get_data(struct ShadeInput *shi, struct Object *lamp_obj, float col[4], float lv[3], float *dist, float shadow[4]) RET_ZERO +const float (*RE_object_instance_get_matrix(struct ObjectInstanceRen *obi, int matrix_id))[4] RET_NULL +const float (*RE_render_current_get_matrix(int matrix_id))[4] RET_NULL +float RE_object_instance_get_object_pass_index(struct ObjectInstanceRen *obi) RET_ZERO +float RE_object_instance_get_random_id(struct ObjectInstanceRen *obi) RET_ZERO + +/* blenkernel */ +bool BKE_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool *uvs, bool *mat, bool *tex, bool *stencil) RET_ZERO + +/* render */ +void RE_FreeRenderResult(struct RenderResult *res) RET_NONE +void RE_FreeAllRenderResults(void) RET_NONE +struct RenderResult *RE_MultilayerConvert(void *exrhandle, const char *colorspace, bool predivide, int rectx, int recty) RET_NULL +struct Scene *RE_GetScene(struct Render *re) RET_NULL +void RE_Database_Free(struct Render *re) RET_NONE +void RE_FreeRender(struct Render *re) RET_NONE +void RE_DataBase_GetView(struct Render *re, float mat[4][4]) RET_NONE +int externtex( + const struct MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, float *tb, float *ta, + const int thread, struct ImagePool *pool, const bool skip_load_image, const bool texnode_preview) RET_ZERO +float texture_value_blend(float tex, float out, float fact, float facg, int blendtype) RET_ZERO +void texture_rgb_blend(float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype) RET_NONE +double elbeemEstimateMemreq(int res, float sx, float sy, float sz, int refine, char *retstr) RET_ZERO +struct Render *RE_NewRender(const char *name) RET_NULL +struct Render *RE_NewSceneRender(const struct Scene *scene) RET_NULL +void RE_SwapResult(struct Render *re, struct RenderResult **rr) RET_NONE +void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct SceneRenderLayer *srl, struct Object *camera_override, unsigned int lay_override, int frame, const bool write_still) RET_NONE +bool RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]) RET_ZERO + +/* rna */ +float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d) RET_NULL +void WM_menutype_free(void) RET_NONE +void WM_menutype_freelink(struct MenuType *mt) RET_NONE +bool WM_menutype_add(struct MenuType *mt) RET_ZERO +int WM_operator_props_dialog_popup(struct bContext *C, struct wmOperator *op, int width, int height) RET_ZERO +int WM_operator_confirm(struct bContext *C, struct wmOperator *op, const struct wmEvent *event) RET_ZERO +struct MenuType *WM_menutype_find(const char *idname, bool quiet) RET_NULL +void WM_operator_stack_clear(struct wmWindowManager *wm) RET_NONE +void WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot) RET_NONE +bool WM_operator_is_repeat(const struct bContext *C, const struct wmOperator *op) RET_ZERO; + +void WM_autosave_init(wmWindowManager *wm) RET_NONE +void WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner) RET_NONE + +void WM_lib_reload(struct Library *lib, struct bContext *C, struct ReportList *reports) RET_NONE + +char *WM_clipboard_text_get(bool selection, int *r_len) RET_NULL +char *WM_clipboard_text_get_firstline(bool selection, int *r_len) RET_NULL +void WM_clipboard_text_set(const char *buf, bool selection) RET_NONE + +void WM_cursor_set(struct wmWindow *win, int curor) RET_NONE +void WM_cursor_modal_set(struct wmWindow *win, int curor) RET_NONE +void WM_cursor_modal_restore(struct wmWindow *win) RET_NONE +void WM_cursor_time(struct wmWindow *win, int nr) RET_NONE +void WM_cursor_warp(struct wmWindow *win, int x, int y) RET_NONE + +struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner, const char *name, int flag, int job_type) RET_NULL +void WM_jobs_customdata_set(struct wmJob *job, void *customdata, void (*free)(void *)) RET_NONE +void WM_jobs_timer(struct wmJob *job, double timestep, unsigned int note, unsigned int endnote) RET_NONE + +void WM_jobs_callbacks(struct wmJob *job, + void (*startjob)(void *, short *, short *, float *), + void (*initjob)(void *), + void (*update)(void *), + void (*endjob)(void *)) RET_NONE + +void WM_jobs_start(struct wmWindowManager *wm, struct wmJob *job) RET_NONE +void WM_report(ReportType type, const char *message) RET_NONE + +#ifdef WITH_INPUT_NDOF + void WM_ndof_deadzone_set(float deadzone) RET_NONE +#endif + +void WM_uilisttype_init(void) RET_NONE +struct uiListType *WM_uilisttype_find(const char *idname, bool quiet) RET_NULL +bool WM_uilisttype_add(struct uiListType *ult) RET_ZERO +void WM_uilisttype_freelink(struct uiListType *ult) RET_NONE +void WM_uilisttype_free(void) RET_NONE + +struct wmKeyMapItem *WM_keymap_item_find_id(struct wmKeyMap *keymap, int id) RET_NULL +struct wmKeyMapItem *WM_key_event_operator( + const struct bContext *C, const char *opname, int opcontext, + struct IDProperty *properties, const bool is_hotkey, + struct wmKeyMap **r_keymap) RET_NULL +void WM_keyconfig_update(struct wmWindowManager *wm) RET_NONE + +int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event) RET_ZERO +void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference) RET_NONE +void WM_main_add_notifier(unsigned int type, void *reference) RET_NONE +void ED_armature_bone_rename(struct Main *bmain, struct bArmature *arm, const char *oldnamep, const char *newnamep) RET_NONE +void ED_armature_transform(struct Main *bmain, struct bArmature *arm, float mat[4][4], const bool do_props) RET_NONE +struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op) RET_NULL +struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep) RET_NULL +void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer) RET_NONE +float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]) RET_ZERO +bool WM_event_is_tablet(const struct wmEvent *event) RET_ZERO +void ED_armature_ebone_remove(struct bArmature *arm, struct EditBone *exBone) RET_NONE +void object_test_constraints(struct Main *bmain, struct Object *owner) RET_NONE +void ED_armature_ebone_to_mat4(struct EditBone *ebone, float mat[4][4]) RET_NONE +void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]) RET_NONE +void ED_object_parent(struct Object *ob, struct Object *par, int type, const char *substr) RET_NONE +void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con) RET_NONE +void ED_node_composit_default(const struct bContext *C, struct Scene *scene) RET_NONE +void *ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *custumdata, int type) RET_ZERO /* XXX this one looks weird */ +void *ED_region_draw_cb_customdata(void *handle) RET_ZERO /* XXX This one looks wrong also */ +void ED_region_draw_cb_exit(struct ARegionType *art, void *handle) RET_NONE +void ED_area_headerprint(struct ScrArea *sa, const char *str) RET_NONE +void ED_gpencil_parent_location(struct bGPDlayer *gpl, float diff_mat[4][4]) RET_NONE +void UI_view2d_region_to_view(struct View2D *v2d, float x, float y, float *viewx, float *viewy) RET_NONE +bool UI_view2d_view_to_region_clip(struct View2D *v2d, float x, float y, int *regionx, int *regiony) RET_ZERO +void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *region_y) RET_NONE +void UI_view2d_sync(struct bScreen *screen, struct ScrArea *sa, struct View2D *v2dcur, int flag) RET_NONE + +struct EditBone *ED_armature_ebone_get_mirrored(const struct ListBase *edbo, EditBone *ebo) RET_NULL +struct EditBone *ED_armature_ebone_add(struct bArmature *arm, const char *name) RET_NULL +struct ListBase *get_active_constraints (struct Object *ob) RET_NULL +struct ListBase *get_constraint_lb(struct Object *ob, struct bConstraint *con, struct bPoseChannel **r_pchan) RET_NULL + +bool ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit) RET_ZERO +bool ED_space_image_show_render(struct SpaceImage *sima) RET_ZERO +bool ED_space_image_show_paint(struct SpaceImage *sima) RET_ZERO +void ED_space_image_paint_update(struct Main *bmain, struct wmWindowManager *wm, struct Scene *scene) RET_NONE +void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima) RET_NONE +void ED_space_image_uv_sculpt_update(struct Main *bmain, struct wmWindowManager *wm, struct Scene *scene) RET_NONE +void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *sima, struct ImBuf *ibuf, bool use_view_settings) RET_NONE + +void ED_uvedit_get_aspect(struct Scene *scene, struct Object *ob, struct BMesh *em, float *aspx, float *aspy) RET_NONE + +void ED_screen_set_scene(struct bContext *C, struct bScreen *screen, struct Scene *scene) RET_NONE +struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc) RET_NULL +void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip) RET_NONE +void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask) RET_NONE +void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask) RET_NONE + +void ED_area_tag_redraw_regiontype(struct ScrArea *sa, int regiontype) RET_NONE +void ED_render_engine_changed(struct Main *bmain) RET_NONE + +void ED_file_read_bookmarks(void) RET_NONE +void ED_file_change_dir(struct bContext *C) RET_NONE +void ED_preview_kill_jobs(struct wmWindowManager *wm, struct Main *bmain) RET_NONE +struct FSMenu *ED_fsmenu_get(void) RET_NULL +struct FSMenuEntry *ED_fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory category) RET_NULL +int ED_fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category) RET_ZERO +struct FSMenuEntry *ED_fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index) RET_NULL +char *ED_fsmenu_entry_get_path(struct FSMenuEntry *fsentry) RET_NULL +void ED_fsmenu_entry_set_path(struct FSMenuEntry *fsentry, const char *name) RET_NONE +char *ED_fsmenu_entry_get_name(struct FSMenuEntry *fsentry) RET_NULL +void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name) RET_NONE + +struct PTCacheEdit *PE_get_current(struct Main *bmain, struct Scene *scene, struct Object *ob) RET_NULL +void PE_current_changed(struct Main *bmain, struct Scene *scene, struct Object *ob) RET_NONE + +/* rna keymap */ +struct wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap) RET_NULL +struct wmKeyMap *WM_keymap_ensure(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) RET_NULL +struct wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) RET_NULL +struct wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid) RET_NULL +struct wmKeyConfig *WM_keyconfig_new(struct wmWindowManager *wm, const char *idname) RET_NULL +struct wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, const char *idname) RET_NULL +bool WM_keyconfig_remove(struct wmWindowManager *wm, struct wmKeyConfig *keyconf) RET_ZERO +bool WM_keymap_remove(struct wmKeyConfig *keyconfig, struct wmKeyMap *keymap) RET_ZERO +void WM_keyconfig_set_active(struct wmWindowManager *wm, const char *idname) RET_NONE +bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi) RET_ZERO +void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C) RET_NONE +void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi) RET_NONE +void WM_keymap_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties) RET_NONE +void WM_keyconfig_update_tag(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi) RET_NONE +bool WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2) RET_ZERO +int WM_keymap_map_type_get(struct wmKeyMapItem *kmi) RET_ZERO + + +/* rna editors */ + +struct FCurve *verify_fcurve(struct bAction *act, const char group[], struct PointerRNA *ptr, const char rna_path[], const int array_index, short add) RET_NULL +int insert_vert_fcurve(struct FCurve *fcu, float x, float y, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag) RET_ZERO +void delete_fcurve_key(struct FCurve *fcu, int index, bool do_recalc) RET_NONE +struct KeyingSetInfo *ANIM_keyingset_info_find_name (const char name[]) RET_NULL +struct KeyingSet *ANIM_scene_get_active_keyingset (struct Scene *scene) RET_NULL +int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks) RET_ZERO +void ANIM_id_update(struct Scene *scene, struct ID *id) RET_NONE +struct ListBase builtin_keyingsets; +void ANIM_keyingset_info_register(struct KeyingSetInfo *ksi) RET_NONE +void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi) RET_NONE +short ANIM_validate_keyingset(struct bContext *C, struct ListBase *dsources, struct KeyingSet *ks) RET_ZERO +int ANIM_add_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag, int type) RET_ZERO +bool ANIM_remove_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag) RET_ZERO +void ED_space_image_release_buffer(struct SpaceImage *sima, struct ImBuf *ibuf, void *lock) RET_NONE +struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **r_lock) RET_NULL +void ED_space_image_get_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy) RET_NONE +const char *ED_info_stats_string(struct Scene *scene) RET_NULL +void ED_area_tag_redraw(struct ScrArea *sa) RET_NONE +void ED_area_tag_refresh(struct ScrArea *sa) RET_NONE +void ED_area_newspace(struct bContext *C, struct ScrArea *sa, int type, const bool skip_ar_exit) RET_NONE +void ED_region_tag_redraw(struct ARegion *ar) RET_NONE +void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op) RET_NONE +void WM_cursor_wait(bool val) RET_NONE +void ED_node_texture_default(const struct bContext *C, struct Tex *tex) RET_NONE +void ED_node_tag_update_id(struct ID *id) RET_NONE +void ED_node_tag_update_nodetree(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node) RET_NONE +void ED_node_tree_update(const struct bContext *C) RET_NONE +void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typeinfo) RET_NONE +void ED_init_custom_node_type(struct bNodeType *ntype) RET_NONE +void ED_init_custom_node_socket_type(struct bNodeSocketType *stype) RET_NONE +void ED_init_standard_node_socket_type(struct bNodeSocketType *stype) RET_NONE +void ED_init_node_socket_type_virtual(struct bNodeSocketType *stype) RET_NONE +int ED_node_tree_path_length(struct SpaceNode *snode) RET_ZERO +void ED_node_tree_path_get(struct SpaceNode *snode, char *value) RET_NONE +void ED_node_tree_path_get_fixedbuf(struct SpaceNode *snode, char *value, int max_length) RET_NONE +void ED_node_tree_start(struct SpaceNode *snode, struct bNodeTree *ntree, struct ID *id, struct ID *from) RET_NONE +void ED_node_tree_push(struct SpaceNode *snode, struct bNodeTree *ntree, struct bNode *gnode) RET_NONE +void ED_node_tree_pop(struct SpaceNode *snode) RET_NONE +int ED_view3d_scene_layer_set(int lay, const bool *values, int *active) RET_ZERO +void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, bool do_clip) RET_NONE +void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist) RET_NONE +struct BGpic *ED_view3d_background_image_new(struct View3D *v3d) RET_NULL +void ED_view3d_background_image_remove(struct View3D *v3d, struct BGpic *bgpic) RET_NONE +void ED_view3d_background_image_clear(struct View3D *v3d) RET_NONE +void ED_view3d_update_viewmat(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, float viewmat[4][4], float winmat[4][4], const struct rcti *rect) RET_NONE +float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit) RET_ZERO +void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa) RET_NONE +void ED_node_shader_default(const struct bContext *C, struct ID *id) RET_NONE +void ED_screen_animation_timer_update(struct bScreen *screen, int redraws, int refresh) RET_NONE +struct bScreen *ED_screen_animation_playing(const struct wmWindowManager *wm) RET_NULL +void ED_base_object_select(struct Base *base, short mode) RET_NONE +bool ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain, struct Object *ob, struct ModifierData *md) RET_ZERO +struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name, int type) RET_ZERO +void ED_object_modifier_clear(struct Main *bmain, struct Object *ob) RET_NONE +bool ED_object_editmode_enter(struct bContext *C, int flag) RET_ZERO +bool ED_object_editmode_exit(struct bContext *C, int flag) RET_ZERO +bool ED_object_editmode_load(struct Main *bmain, struct Object *obedit) RET_ZERO +void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object) RET_NONE +bool uiLayoutGetActive(struct uiLayout *layout) RET_ZERO +int uiLayoutGetOperatorContext(struct uiLayout *layout) RET_ZERO +int uiLayoutGetAlignment(struct uiLayout *layout) RET_ZERO +bool uiLayoutGetEnabled(struct uiLayout *layout) RET_ZERO +float uiLayoutGetScaleX(struct uiLayout *layout) RET_ZERO +float uiLayoutGetScaleY(struct uiLayout *layout) RET_ZERO +void uiLayoutSetActive(struct uiLayout *layout, bool active) RET_NONE +void uiLayoutSetOperatorContext(struct uiLayout *layout, int opcontext) RET_NONE +void uiLayoutSetEnabled(uiLayout *layout, bool enabled) RET_NONE +void uiLayoutSetAlignment(uiLayout *layout, char alignment) RET_NONE +void uiLayoutSetScaleX(struct uiLayout *layout, float scale) RET_NONE +void uiLayoutSetScaleY(struct uiLayout *layout, float scale) RET_NONE +void uiTemplateIconView(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool show_labels, float icon_scale) RET_NONE +void ED_base_object_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Base *base) RET_NONE +void ED_mesh_update(struct Mesh *mesh, struct bContext *C, bool calc_edges, bool calc_tessface) RET_NONE +void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE +void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE +void ED_mesh_tessfaces_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE +void ED_mesh_loops_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE +void ED_mesh_polys_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE +void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE +void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE +void ED_mesh_faces_remove(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE +int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set) RET_MINUSONE +int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set) RET_MINUSONE +bool ED_mesh_color_remove_named(struct Mesh *me, const char *name) RET_ZERO +bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name) RET_ZERO +void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *ob) RET_NONE +void ED_object_constraint_dependency_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con) RET_NONE +void ED_object_constraint_update(struct Main *bmain, struct Object *ob) RET_NONE +void ED_object_constraint_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con) RET_NONE +void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode) RET_NONE +void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum) RET_NONE +float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum) RET_ZERO +int ED_mesh_mirror_topo_table(struct Object *ob, struct DerivedMesh *dm, char mode) RET_ZERO +int ED_mesh_mirror_spatial_table(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, const float co[3], char mode) RET_ZERO + +float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float new_up_axis[3], const bool axis_only) RET_ZERO +void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height) RET_NONE +bool ED_space_image_check_show_maskedit(struct Scene *scene, struct SpaceImage *sima) RET_ZERO + +bool ED_texture_context_check_world(const struct bContext *C) RET_ZERO +bool ED_texture_context_check_material(const struct bContext *C) RET_ZERO +bool ED_texture_context_check_lamp(const struct bContext *C) RET_ZERO +bool ED_texture_context_check_particles(const struct bContext *C) RET_ZERO +bool ED_texture_context_check_others(const struct bContext *C) RET_ZERO + +bool ED_text_region_location_from_cursor(SpaceText *st, ARegion *ar, const int cursor_co[2], int r_pixel_co[2]) RET_ZERO + +SnapObjectContext *ED_transform_snap_object_context_create( + struct Main *bmain, struct Scene *scene, int flag) RET_NULL +SnapObjectContext *ED_transform_snap_object_context_create_view3d( + struct Main *bmain, struct Scene *scene, int flag, + const struct ARegion *ar, const struct View3D *v3d) RET_NULL +void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx) RET_NONE +bool ED_transform_snap_object_project_ray_ex( + struct SnapObjectContext *sctx, + const struct SnapObjectParams *params, + const float ray_start[3], const float ray_normal[3], float *ray_depth, + /* return args */ + float r_loc[3], float r_no[3], int *r_index, + struct Object **r_ob, float r_obmat[4][4]) RET_ZERO + +void ED_curve_editnurb_load(struct Main *bmain, struct Object *obedit) RET_NONE +void ED_curve_editnurb_make(struct Object *obedit) RET_NONE + +void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon) RET_NONE + +void uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag, struct PointerRNA *r_opptr) RET_NONE +void uiItemFullO_ptr(struct uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, struct IDProperty *properties, int context, int flag, struct PointerRNA *r_opptr) RET_NONE +void uiItemFullOMenuHold_ptr( uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, struct IDProperty *properties, int context, int flag, const char *menu_id, /* extra menu arg. */ PointerRNA *r_opptr) RET_NONE +struct uiLayout *uiLayoutRow(uiLayout *layout, bool align) RET_NULL +struct uiLayout *uiLayoutColumn(uiLayout *layout, bool align) RET_NULL +struct uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, bool align) RET_NULL +struct uiLayout *uiLayoutBox(struct uiLayout *layout) RET_NULL +struct uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, bool align) RET_NULL +bool uiLayoutGetRedAlert(struct uiLayout *layout) RET_ZERO +void uiLayoutSetRedAlert(uiLayout *layout, bool redalert) RET_NONE +void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE +void uiItemMenuEnumR_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon) RET_NONE +void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon) RET_NONE +void uiItemEnumR_string_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *value, const char *name, int icon) RET_NONE +void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon) RET_NONE +void uiItemPointerR_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, struct PointerRNA *searchptr, PropertyRNA *searchprop, const char *name, int icon) RET_NONE +void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon) RET_NONE +void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) RET_NONE +void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value) RET_NONE +void uiItemMenuEnumO(uiLayout *layout, struct bContext *C, const char *opname, const char *propname, const char *name, int icon) RET_NONE +void uiItemMenuEnumO_ptr(uiLayout *layout, struct bContext *C, struct wmOperatorType *ot, const char *propname, const char *name, int icon) RET_NONE +void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) RET_NONE +void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) RET_NONE +void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value) RET_NONE +void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value) RET_NONE +void uiItemL(struct uiLayout *layout, const char *name, int icon) RET_NONE +void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon) RET_NONE +void uiItemS(struct uiLayout *layout) RET_NONE +void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon) RET_NONE +void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr) RET_NONE +void UI_reinit_font(void) RET_NONE +int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon, const bool big) RET_ZERO +struct bTheme *UI_GetTheme(void) RET_NULL + +/* rna template */ +void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *proptypename, const char *text) RET_NONE +void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *root_ptr, const char *text) RET_NONE +void uiTemplateHeader(struct uiLayout *layout, struct bContext *C) RET_NONE +void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter) RET_NONE +struct uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr) RET_NULL +struct uiLayout *uiTemplateConstraint(struct uiLayout *layout, struct PointerRNA *ptr) RET_NULL +void uiTemplatePreview(struct uiLayout *layout, struct bContext *C, struct ID *id, bool show_buttons, struct ID *parent, + struct MTex *slot, const char *preview_id) RET_NONE +void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int rows, int cols, int filter) RET_NONE +void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, bool levels, bool brush, bool neg_slope) RET_NONE +void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool expand) RET_NONE +void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer) RET_NONE +void uiTemplateImageLayers(struct uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser) RET_NONE +void uiTemplateList(struct uiLayout *layout, struct bContext *C, const char *listtype_name, const char *list_id, + PointerRNA *dataptr, const char *propname, PointerRNA *active_dataptr, const char *active_propname, + const char *item_dyntip_propname, int rows, int maxrows, int layout_type, int columns) RET_NONE +void uiTemplateRunningJobs(struct uiLayout *layout, struct bContext *C) RET_NONE +void uiTemplateOperatorSearch(struct uiLayout *layout) RET_NONE +void uiTemplateHeader3D(struct uiLayout *layout, struct bContext *C) RET_NONE +void uiTemplateEditModeSelection(struct uiLayout *layout, struct bContext *C) RET_NONE +void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, bool compact, bool multiview) RET_NONE +void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic) RET_NONE +void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE +void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C) RET_NONE +void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE +void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE +void uiTemplateNodeLink(struct uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) RET_NONE +void uiTemplateNodeView(struct uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) RET_NONE +void uiTemplateTextureUser(struct uiLayout *layout, struct bContext *C) RET_NONE +void uiTemplateTextureShow(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop) RET_NONE +void uiTemplateKeymapItemProperties(struct uiLayout *layout, struct PointerRNA *ptr) RET_NONE +void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, bool compact) RET_NONE +void uiTemplateMovieclipInformation(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr) RET_NONE +void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE +void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, bool compact) RET_NONE +void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, bool color_management) RET_NONE +void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE +void uiTemplateColormanagedViewSettings(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname) RET_NONE +void uiTemplateComponentMenu(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name) RET_NONE +void uiTemplateNodeSocket(struct uiLayout *layout, struct bContext *C, float *color) RET_NONE +void uiTemplatePalette(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool color) RET_NONE +void uiTemplateImageStereo3d(struct uiLayout *layout, struct PointerRNA *stereo3d_format_ptr) RET_NONE +void uiTemplateCacheFile(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname) RET_NONE + +/* rna render */ +struct RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h, const char *layername, const char *viewname) RET_NULL +struct RenderResult *RE_AcquireResultRead(struct Render *re) RET_NULL +struct RenderResult *RE_AcquireResultWrite(struct Render *re) RET_NULL +struct RenderResult *RE_engine_get_result(struct RenderEngine *re) RET_NULL +struct RenderStats *RE_GetStats(struct Render *re) RET_NULL +struct RenderData *RE_engine_get_render_data(struct Render *re) RET_NULL +void RE_engine_update_result(struct RenderEngine *engine, struct RenderResult *result) RET_NONE +void RE_engine_update_progress(struct RenderEngine *engine, float progress) RET_NONE +void RE_engine_set_error_message(RenderEngine *engine, const char *msg) RET_NONE +void RE_engine_add_pass(RenderEngine *engine, const char *name, int channels, const char *chan_id, const char *layername) RET_NONE +void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result, bool cancel, bool highlight, bool merge_results) RET_NONE +void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info) RET_NONE +void RE_layer_load_from_file(struct RenderLayer *layer, struct ReportList *reports, const char *filename, int x, int y) RET_NONE +void RE_result_load_from_file(struct RenderResult *result, struct ReportList *reports, const char *filename) RET_NONE +void RE_AcquireResultImage(struct Render *re, struct RenderResult *rr, const int view_id) RET_NONE +void RE_ReleaseResult(struct Render *re) RET_NONE +void RE_ReleaseResultImage(struct Render *re) RET_NONE +bool RE_engine_test_break(struct RenderEngine *engine) RET_ZERO +void RE_engines_init() RET_NONE +void RE_engines_exit() RET_NONE +void RE_engine_report(struct RenderEngine *engine, int type, const char *msg) RET_NONE +ListBase R_engines = {NULL, NULL}; +void RE_engine_free(struct RenderEngine *engine) RET_NONE +struct RenderEngineType *RE_engines_find(const char *idname) RET_NULL +void RE_engine_update_memory_stats(struct RenderEngine *engine, float mem_used, float mem_peak) RET_NONE +struct RenderEngine *RE_engine_create(struct RenderEngineType *type) RET_NULL +void RE_engine_frame_set(struct RenderEngine *engine, int frame, float subframe) RET_NONE +void RE_FreePersistentData(void) RET_NONE +void RE_point_density_cache(struct Scene *scene, struct PointDensity *pd, const bool use_render_params) RET_NONE +void RE_point_density_minmax(struct Scene *scene, struct PointDensity *pd, const bool use_render_params, float r_min[3], float r_max[3]) RET_NONE +void RE_point_density_sample(struct Scene *scene, struct PointDensity *pd, int resolution, const bool use_render_params, float *values) RET_NONE +void RE_point_density_free(struct PointDensity *pd) RET_NONE +void RE_instance_get_particle_info(struct ObjectInstanceRen *obi, float *index, float *random, float *age, float *lifetime, float co[3], float *size, float vel[3], float angvel[3]) RET_NONE +void RE_FreeAllPersistentData(void) RET_NONE +float RE_fresnel_dielectric(float incoming[3], float normal[3], float eta) RET_ZERO +void RE_engine_register_pass(struct RenderEngine *engine, struct Scene *scene, struct SceneRenderLayer *srl, const char *name, int channels, const char *chanid, int type) RET_NONE + +/* python */ +struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet) RET_NULL +void WM_operatortype_iter(struct GHashIterator *ghi) RET_NONE +struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname) RET_NULL +int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short context, struct PointerRNA *properties, struct ReportList *reports, const bool is_undo) RET_ZERO +void WM_operatortype_remove_ptr(struct wmOperatorType *ot) RET_NONE +bool WM_operatortype_remove(const char *idname) RET_ZERO +bool WM_operator_poll(struct bContext *C, struct wmOperatorType *ot) RET_ZERO +bool WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, short context) RET_ZERO +int WM_operator_props_popup(struct bContext *C, struct wmOperator *op, const struct wmEvent *event) RET_ZERO +void WM_operator_properties_free(struct PointerRNA *ptr) RET_NONE +void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring) RET_NONE +void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot) RET_NONE +void WM_operator_properties_sanitize(struct PointerRNA *ptr, const bool no_context) RET_NONE +void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata) RET_NONE +void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata) RET_NONE +void WM_operator_bl_idname(char *to, const char *from) RET_NONE +void WM_operator_py_idname(char *to, const char *from) RET_NONE +bool WM_operator_py_idname_ok_or_report(struct ReportList *reports, const char *classname, const char *idname) RET_ZERO +int WM_operator_ui_popup(struct bContext *C, struct wmOperator *op, int width, int height) RET_ZERO +void update_autoflags_fcurve(struct FCurve *fcu, struct bContext *C, struct ReportList *reports, struct PointerRNA *ptr) RET_NONE +short insert_keyframe(struct Main *bmain, struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag) RET_ZERO +short delete_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eInsertKeyFlags flag) RET_ZERO +struct bAction *verify_adt_action(struct Main *bmain, struct ID *id, short add) RET_NULL +char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, const bool all_args, const bool macro_args, struct wmOperatorType *ot, struct PointerRNA *opptr) RET_NULL +char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, const bool all_args, const bool macro_args) RET_NULL +struct wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value) RET_NULL +struct wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value) RET_NULL +struct wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, const struct EnumPropertyItem *items) RET_NULL +struct uiPopupMenu *UI_popup_menu_begin(struct bContext *C, const char *title, int icon) RET_NULL +void UI_popup_menu_end(struct bContext *C, struct uiPopupMenu *head) RET_NONE +struct uiLayout *UI_popup_menu_layout(struct uiPopupMenu *head) RET_NULL +struct uiLayout *UI_pie_menu_layout(struct uiPieMenu *pie) RET_NULL +int UI_pie_menu_invoke(struct bContext *C, const char *idname, const struct wmEvent *event) RET_ZERO +struct uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, const struct wmEvent *event) RET_NULL +void UI_pie_menu_end(struct bContext *C, uiPieMenu *pie) RET_NONE +struct uiLayout *uiLayoutRadial(struct uiLayout *layout) RET_NULL +int UI_pie_menu_invoke_from_operator_enum(struct bContext *C, const char *title, const char *opname, + const char *propname, const struct wmEvent *event) RET_ZERO + +void ED_mesh_calc_tessface(struct Mesh *mesh, bool free_mpoly) RET_NONE + +/* bpy/python internal api */ +extern void BPY_RNA_operator_wrapper(struct wmOperatorType *ot, void *userdata); +extern void BPY_RNA_operator_macro_wrapper(struct wmOperatorType *ot, void *userdata); +void BPY_RNA_operator_wrapper(struct wmOperatorType *ot, void *userdata) RET_NONE +void BPY_RNA_operator_macro_wrapper(struct wmOperatorType *ot, void *userdata) RET_NONE +void BPY_text_free_code(struct Text *text) RET_NONE +void BPY_id_release(struct ID *id) RET_NONE +int BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result) RET_ZERO +void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct) RET_NONE +float BPY_driver_exec(PathResolvedRNA *anim_rna, struct ChannelDriver *driver, const float evaltime) RET_ZERO /* might need this one! */ +void BPY_DECREF(void *pyob_ptr) RET_NONE +void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr) RET_NONE; +void BPY_pyconstraint_exec(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets) RET_NONE +bool pyrna_id_FromPyObject(struct PyObject *obj, struct ID **id) RET_ZERO +struct PyObject *pyrna_id_CreatePyObject(struct ID *id) RET_NULL +bool pyrna_id_CheckPyObject(struct PyObject *obj) RET_ZERO +void BPY_context_update(struct bContext *C) RET_NONE +const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid) RET_ARG(msgid) + +/* intern/dualcon */ + +void *dualcon(const DualConInput *input_mesh, + /* callbacks for output */ + DualConAllocOutput alloc_output, + DualConAddVert add_vert, + DualConAddQuad add_quad, + + DualConFlags flags, + DualConMode mode, + float threshold, + float hermite_num, + float scale, + int depth) RET_ZERO + +/* compositor */ +void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rendering, + const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings, + const char *viewName) RET_NONE + +/*multiview*/ +bool RE_RenderResult_is_stereo(RenderResult *res) RET_ZERO +void uiTemplateImageViews(uiLayout *layout, struct PointerRNA *imfptr) RET_NONE + +#endif // WITH_GAMEENGINE diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 72411bcbbc6..18a8ebeac37 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -711,7 +711,7 @@ elseif(WIN32) ) if(WITH_PYTHON_INSTALL_NUMPY) - set(PYTHON_NUMPY_VERSION 1.13) + set(PYTHON_NUMPY_VERSION 1.15) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages) @@ -774,12 +774,12 @@ elseif(WIN32) if(WITH_CODEC_FFMPEG) install( FILES - ${LIBDIR}/ffmpeg/lib/avcodec-57.dll - ${LIBDIR}/ffmpeg/lib/avformat-57.dll - ${LIBDIR}/ffmpeg/lib/avdevice-57.dll - ${LIBDIR}/ffmpeg/lib/avutil-55.dll - ${LIBDIR}/ffmpeg/lib/swscale-4.dll - ${LIBDIR}/ffmpeg/lib/swresample-2.dll + ${LIBDIR}/ffmpeg/lib/avcodec-58.dll + ${LIBDIR}/ffmpeg/lib/avformat-58.dll + ${LIBDIR}/ffmpeg/lib/avdevice-58.dll + ${LIBDIR}/ffmpeg/lib/avutil-56.dll + ${LIBDIR}/ffmpeg/lib/swscale-5.dll + ${LIBDIR}/ffmpeg/lib/swresample-3.dll DESTINATION "." ) endif() @@ -828,15 +828,6 @@ elseif(WIN32) DESTINATION "." ) - if(WITH_OPENCOLORIO) - set(OCIOBIN ${LIBDIR}/opencolorio/bin) - install( - FILES - ${OCIOBIN}/OpenColorIO.dll - DESTINATION "." - ) - endif() - elseif(APPLE) # handy install macro to exclude files, we use \$ escape for the "to" diff --git a/source/tools b/source/tools -Subproject ca3e38d89666c422d6681bb06967a59ef1a4a7d +Subproject 11656ebaf7f912cdb1b5eb39c5d0a3b5d492c1a |