Geometry Nodes: Sample Volume node #107656

Closed
Erik Abrahamsson wants to merge 17 commits from erik85:volume-sample into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
549 changed files with 5526 additions and 8195 deletions
Showing only changes of commit b28d0fd6c3 - Show all commits

View File

@ -122,5 +122,6 @@ if(BUILD_MODE STREQUAL Release AND WIN32)
COMMAND ${CMAKE_COMMAND} -E rm -f ${HARVEST_TARGET}/dpcpp/bin/lld.exe
COMMAND ${CMAKE_COMMAND} -E rm -f ${HARVEST_TARGET}/dpcpp/bin/lld-link.exe
COMMAND ${CMAKE_COMMAND} -E rm -f ${HARVEST_TARGET}/dpcpp/bin/wasm-ld.exe
DEPENDEES install
)
endif()

View File

@ -46,7 +46,7 @@ ${temp_LIBDIR}/vpx/lib/pkgconfig:\
${temp_LIBDIR}/theora/lib/pkgconfig:\
${temp_LIBDIR}/openjpeg/lib/pkgconfig:\
${temp_LIBDIR}/opus/lib/pkgconfig:\
${temp_LIBDIR}/aom/lib/pkgconfig"
${temp_LIBDIR}/aom/lib/pkgconfig:"
)
unset(temp_LIBDIR)

View File

@ -2,35 +2,45 @@
set(FFTW_EXTRA_ARGS)
if(WIN32)
set(FFTW3_PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/fftw3/src/external_fftw3 < ${PATCH_DIR}/fftw3.diff)
set(FFTW_EXTRA_ARGS --disable-static --enable-shared)
set(FFTW_INSTALL install-strip)
else()
set(FFTW_EXTRA_ARGS --enable-static)
set(FFTW_INSTALL install)
endif()
macro(fftw_build FFTW_POSTFIX)
if(WIN32)
set(FFTW3_PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX} < ${PATCH_DIR}/fftw3.diff)
set(FFTW_EXTRA_ARGS --disable-static --enable-shared)
set(FFTW_INSTALL install-strip)
else()
set(FFTW_EXTRA_ARGS --enable-static)
set(FFTW_INSTALL install)
endif()
ExternalProject_Add(external_fftw3_${FFTW_POSTFIX}
URL file://${PACKAGE_DIR}/${FFTW_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${FFTW_HASH_TYPE}=${FFTW_HASH}
PREFIX ${BUILD_DIR}/fftw3
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX}/ && ${CONFIGURE_COMMAND} ${FFTW_EXTRA_ARGS} ${ARGN} --prefix=${mingw_LIBDIR}/fftw3
PATCH_COMMAND ${FFTW3_PATCH_COMMAND}
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX}/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX}/ && make ${FFTW_INSTALL}
INSTALL_DIR ${LIBDIR}/fftw3
)
endmacro()
ExternalProject_Add(external_fftw3
URL file://${PACKAGE_DIR}/${FFTW_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${FFTW_HASH_TYPE}=${FFTW_HASH}
PREFIX ${BUILD_DIR}/fftw3
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && ${CONFIGURE_COMMAND} ${FFTW_EXTRA_ARGS} --prefix=${mingw_LIBDIR}/fftw3
PATCH_COMMAND ${FFTW3_PATCH_COMMAND}
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && make ${FFTW_INSTALL}
INSTALL_DIR ${LIBDIR}/fftw3
)
fftw_build(double)
fftw_build(float --enable-float)
if(MSVC)
set_target_properties(external_fftw3 PROPERTIES FOLDER Mingw)
set_target_properties(external_fftw3_double PROPERTIES FOLDER Mingw)
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_fftw3 after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/lib/libfftw3.dll.a ${HARVEST_TARGET}/fftw3/lib/libfftw.lib
ExternalProject_Add_Step(external_fftw3_double after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/lib/libfftw3.dll.a ${HARVEST_TARGET}/fftw3/lib/libfftw3-3.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/bin/libfftw3-3.dll ${HARVEST_TARGET}/fftw3/lib/libfftw3-3.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/include/fftw3.h ${HARVEST_TARGET}/fftw3/include/fftw3.h
DEPENDEES install
)
ExternalProject_Add_Step(external_fftw3_float after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/lib/libfftw3f.dll.a ${HARVEST_TARGET}/fftw3/lib/libfftw3f.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/bin/libfftw3f-3.dll ${HARVEST_TARGET}/fftw3/lib/libfftw3f-3.dll
DEPENDEES install
)
endif()
endif()

View File

@ -218,7 +218,7 @@ else()
harvest(openimagedenoise/lib openimagedenoise/lib "*.a")
harvest(embree/include embree/include "*.h")
harvest(embree/lib embree/lib "*.a")
harvest(embree/lib embree/lib "*${SHAREDLIBEXT}*")
harvest_rpath_lib(embree/lib embree/lib "*${SHAREDLIBEXT}*")
harvest(openpgl/include openpgl/include "*.h")
harvest(openpgl/lib openpgl/lib "*.a")
harvest(openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION} openpgl/lib/cmake/openpgl "*.cmake")

View File

@ -11,7 +11,7 @@ if(WIN32)
elseif(APPLE)
# Use bison and flex installed via Homebrew.
# The ones that come with Xcode toolset are too old.
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
if(BLENDER_PLATFORM_ARM)
set(ISPC_EXTRA_ARGS_APPLE
-DBISON_EXECUTABLE=/opt/homebrew/opt/bison/bin/bison
-DFLEX_EXECUTABLE=/opt/homebrew/opt/flex/bin/flex

View File

@ -2,11 +2,12 @@
set(MATERIALX_EXTRA_ARGS
-DMATERIALX_BUILD_PYTHON=ON
-DMATERIALX_BUILD_RENDER=OFF
-DMATERIALX_BUILD_RENDER=ON
-DMATERIALX_INSTALL_PYTHON=OFF
-DMATERIALX_PYTHON_EXECUTABLE=${PYTHON_BINARY}
-DMATERIALX_PYTHON_VERSION=${PYTHON_SHORT_VERSION}
-DMATERIALX_BUILD_SHARED_LIBS=ON
-DMATERIALX_BUILD_TESTS=OFF
-DCMAKE_DEBUG_POSTFIX=_d
-Dpybind11_ROOT=${LIBDIR}/pybind11
-DPython_EXECUTABLE=${PYTHON_BINARY}

View File

@ -27,6 +27,7 @@ ExternalProject_Add(external_openexr
URL file://${PACKAGE_DIR}/${OPENEXR_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${OPENEXR_HASH_TYPE}=${OPENEXR_HASH}
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openexr/src/external_openexr < ${PATCH_DIR}/openexr_b18905772e.diff
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PREFIX ${BUILD_DIR}/openexr
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openexr ${DEFAULT_CMAKE_FLAGS} ${OPENEXR_EXTRA_ARGS}

View File

@ -54,7 +54,7 @@ set(OPENIMAGEIO_EXTRA_ARGS
-DUSE_DCMTK=OFF
-DUSE_LIBHEIF=OFF
-DUSE_OPENGL=OFF
-DUSE_TBB=OFF
-DUSE_TBB=ON
-DUSE_QT=OFF
-DUSE_PYTHON=ON
-DUSE_GIF=OFF
@ -96,6 +96,7 @@ set(OPENIMAGEIO_EXTRA_ARGS
-DImath_ROOT=${LIBDIR}/imath
-Dpybind11_ROOT=${LIBDIR}/pybind11
-DPython_EXECUTABLE=${PYTHON_BINARY}
-DTBB_ROOT=${LIBDIR}/tbb
)
ExternalProject_Add(external_openimageio
@ -104,7 +105,8 @@ ExternalProject_Add(external_openimageio
URL_HASH ${OPENIMAGEIO_HASH_TYPE}=${OPENIMAGEIO_HASH}
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PREFIX ${BUILD_DIR}/openimageio
PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/openimageio.diff
PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/openimageio.diff &&
${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_3832.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimageio ${DEFAULT_CMAKE_FLAGS} ${OPENIMAGEIO_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/openimageio
)
@ -125,6 +127,7 @@ add_dependencies(
external_webp
external_python
external_pybind11
external_tbb
)
if(WIN32)

View File

@ -35,7 +35,7 @@ if(WIN32)
# regardless of the version actually in there.
PATCH_COMMAND mkdir ${PYTHON_EXTERNALS_FOLDER_DOS} &&
mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\zlib-1.2.13 ${ZLIB_SOURCE_FOLDER_DOS} &&
mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\openssl-1.1.1q ${SSL_SOURCE_FOLDER_DOS} &&
mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\openssl-1.1.1t ${SSL_SOURCE_FOLDER_DOS} &&
${CMAKE_COMMAND} -E copy ${ZLIB_SOURCE_FOLDER}/../external_zlib-build/zconf.h ${PYTHON_EXTERNALS_FOLDER}/zlib-1.2.13/zconf.h &&
${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_windows.diff
CONFIGURE_COMMAND echo "."

View File

@ -1,7 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-or-later
set(SSL_CONFIGURE_COMMAND ./Configure)
set(SSL_PATCH_CMD echo .)
if(WIN32)
# Python will build this with its preferred build options and patches. We only need to unpack openssl
@ -18,7 +17,6 @@ if(WIN32)
else()
if(APPLE)
set(SSL_OS_COMPILER "blender-darwin-${CMAKE_OSX_ARCHITECTURES}")
set(SSL_PATCH_CMD ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/ssl/src/external_ssl < ${PATCH_DIR}/ssl.diff)
else()
if(BLENDER_PLATFORM_ARM)
set(SSL_OS_COMPILER "blender-linux-aarch64")
@ -35,7 +33,6 @@ else()
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${SSL_HASH_TYPE}=${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

View File

@ -15,8 +15,7 @@ if(WIN32)
-D_PXR_CXX_DEFINITIONS=/DBOOST_ALL_NO_LIB
-DCMAKE_SHARED_LINKER_FLAGS_INIT=/LIBPATH:${LIBDIR}/tbb/lib
-DPython_FIND_REGISTRY=NEVER
-DPYTHON_INCLUDE_DIRS=${LIBDIR}/python/include
-DPYTHON_LIBRARY=${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}${LIBEXT}
-DPython3_EXECUTABLE=${PYTHON_BINARY}
)
if(BUILD_MODE STREQUAL Debug)
list(APPEND USD_PLATFORM_FLAGS -DPXR_USE_DEBUG_PYTHON=ON)
@ -27,6 +26,12 @@ elseif(UNIX)
# part of the interpret in the USD library. Allow undefined Python symbols and replace
# Python library with TBB so it doesn't complain about missing library.
set(USD_PLATFORM_FLAGS
# NOTE(@ideasman42): Setting the root is needed, without this an older version of Python
# is detected from the system. Referencing the root-directory may remove the need
# to explicitly set the `PYTHON_INCLUDE_DIR` & `PYTHON_LIBRARY`.
# Keep them as it's known these are the libraries to use and it avoids any ambiguity.
-DPython3_ROOT_DIR=${LIBDIR}/python/
-DPYTHON_INCLUDE_DIR=${LIBDIR}/python/include/python${PYTHON_SHORT_VERSION}/
-DPYTHON_LIBRARY=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${SHAREDLIBEXT}
)
@ -44,6 +49,7 @@ set(USD_EXTRA_ARGS
${USD_PLATFORM_FLAGS}
-DOPENSUBDIV_ROOT_DIR=${LIBDIR}/opensubdiv
-DOpenImageIO_ROOT=${LIBDIR}/openimageio
-DMaterialX_ROOT=${LIBDIR}/materialx
-DOPENEXR_LIBRARIES=${LIBDIR}/imath/lib/${LIBPREFIX}Imath${OPENEXR_VERSION_POSTFIX}${SHAREDLIBEXT}
-DOPENEXR_INCLUDE_DIR=${LIBDIR}/imath/include
-DImath_DIR=${LIBDIR}/imath
@ -56,9 +62,10 @@ set(USD_EXTRA_ARGS
-DPXR_BUILD_TUTORIALS=OFF
-DPXR_BUILD_USDVIEW=OFF
-DPXR_ENABLE_HDF5_SUPPORT=OFF
-DPXR_ENABLE_MATERIALX_SUPPORT=OFF
-DPXR_ENABLE_MATERIALX_SUPPORT=ON
-DPXR_ENABLE_OPENVDB_SUPPORT=ON
-DPYTHON_EXECUTABLE=${PYTHON_BINARY}
-DPython3_EXECUTABLE=${PYTHON_BINARY}
-DPXR_BUILD_MONOLITHIC=ON
# OSL is an optional dependency of the Imaging module. However, since that
# module was included for its support for converting primitive shapes (sphere,
@ -95,7 +102,12 @@ ExternalProject_Add(external_usd
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PREFIX ${BUILD_DIR}/usd
LIST_SEPARATOR ^^
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd.diff
# usd_pull_1965.diff https://github.com/PixarAnimationStudios/USD/pull/1965
# usd_hydra.diff - https://github.com/bnagirniak/RPRHydraRenderBlenderAddon/blob/master/usd.diff
# usd_hydra.diff also included the blender changes and usd_pull_1965 and has been edited to remove those sections.
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd.diff &&
${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd_pull_1965.diff &&
${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd_hydra.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/usd -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${USD_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/usd
)
@ -107,6 +119,7 @@ add_dependencies(
external_opensubdiv
external_python
external_openimageio
external_materialx
openvdb
)

View File

@ -58,16 +58,16 @@ set(PTHREADS_HASH f3bf81bb395840b3446197bcf4ecd653)
set(PTHREADS_HASH_TYPE MD5)
set(PTHREADS_FILE pthreads4w-code-${PTHREADS_VERSION}.zip)
set(OPENEXR_VERSION 3.1.5)
set(OPENEXR_VERSION 3.1.7)
set(OPENEXR_URI https://github.com/AcademySoftwareFoundation/openexr/archive/v${OPENEXR_VERSION}.tar.gz)
set(OPENEXR_HASH a92f38eedd43e56c0af56d4852506886)
set(OPENEXR_HASH ae68f0cb8b30a49c961fa87d31c60394)
set(OPENEXR_HASH_TYPE MD5)
set(OPENEXR_FILE openexr-${OPENEXR_VERSION}.tar.gz)
set(OPENEXR_CPE "cpe:2.3:a:openexr:openexr:${OPENEXR_VERSION}:*:*:*:*:*:*:*")
set(IMATH_VERSION 3.1.5)
set(IMATH_VERSION 3.1.7)
set(IMATH_URI https://github.com/AcademySoftwareFoundation/Imath/archive/v${OPENEXR_VERSION}.tar.gz)
set(IMATH_HASH dd375574276c54872b7b3d54053baff0)
set(IMATH_HASH 5cedab446ab296c080957c3037c6d097)
set(IMATH_HASH_TYPE MD5)
set(IMATH_FILE imath-${IMATH_VERSION}.tar.gz)
@ -88,9 +88,9 @@ else()
set(OPENEXR_VERSION_POSTFIX)
endif()
set(FREETYPE_VERSION 2.12.1)
set(FREETYPE_VERSION 2.13.0)
set(FREETYPE_URI http://prdownloads.sourceforge.net/freetype/freetype-${FREETYPE_VERSION}.tar.gz)
set(FREETYPE_HASH 8bc5c9c9df7ac12c504f8918552a7cf2)
set(FREETYPE_HASH 98bc3cf234fe88ef3cf24569251fe0a4)
set(FREETYPE_HASH_TYPE MD5)
set(FREETYPE_FILE freetype-${FREETYPE_VERSION}.tar.gz)
SET(FREETYPE_CPE "cpe:2.3:a:freetype:freetype:${FREETYPE_VERSION}:*:*:*:*:*:*:*")
@ -112,7 +112,6 @@ set(ALEMBIC_URI https://github.com/alembic/alembic/archive/${ALEMBIC_VERSION}.ta
set(ALEMBIC_HASH 2cd8d6e5a3ac4a014e24a4b04f4fadf9)
set(ALEMBIC_HASH_TYPE MD5)
set(ALEMBIC_FILE alembic-${ALEMBIC_VERSION}.tar.gz)
SET(FREETYPE_CPE "cpe:2.3:a:freetype:freetype:${FREETYPE_VERSION}:*:*:*:*:*:*:*")
set(OPENSUBDIV_VERSION v3_5_0)
set(OPENSUBDIV_URI https://github.com/PixarAnimationStudios/OpenSubdiv/archive/${OPENSUBDIV_VERSION}.tar.gz)
@ -165,17 +164,17 @@ set(OPENMP_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${
set(OPENMP_HASH_TYPE MD5)
set(OPENMP_FILE openmp-${OPENMP_VERSION}.src.tar.xz)
set(OPENIMAGEIO_VERSION v2.4.9.0)
set(OPENIMAGEIO_VERSION v2.4.11.0)
set(OPENIMAGEIO_URI https://github.com/OpenImageIO/oiio/archive/refs/tags/${OPENIMAGEIO_VERSION}.tar.gz)
set(OPENIMAGEIO_HASH 7da92a7d6029921a8599a977ff1efa2a)
set(OPENIMAGEIO_HASH 7eb997479ecfe7d9fa59cc8ddd35d0ae)
set(OPENIMAGEIO_HASH_TYPE MD5)
set(OPENIMAGEIO_FILE OpenImageIO-${OPENIMAGEIO_VERSION}.tar.gz)
# 8.0.0 is currently oiio's preferred version although never versions may be available.
# 9.1.0 is currently oiio's preferred version although never versions may be available.
# the preferred version can be found in oiio's externalpackages.cmake
set(FMT_VERSION 8.0.0)
set(FMT_VERSION 9.1.0)
set(FMT_URI https://github.com/fmtlib/fmt/archive/refs/tags/${FMT_VERSION}.tar.gz)
set(FMT_HASH 7bce0e9e022e586b178b150002e7c2339994e3c2bbe44027e9abb0d60f9cce83)
set(FMT_HASH 5dea48d1fcddc3ec571ce2058e13910a0d4a6bab4cc09a809d8b1dd1c88ae6f2)
set(FMT_HASH_TYPE SHA256)
set(FMT_FILE fmt-${FMT_VERSION}.tar.gz)
set(FMT_CPE "cpe:2.3:a:fmt:fmt:${FMT_VERSION}:*:*:*:*:*:*:*")
@ -209,11 +208,11 @@ set(OSL_FILE OpenShadingLanguage-${OSL_VERSION}.tar.gz)
# BZIP2, FFI, SQLITE and change the versions in this file as well. For compliance
# reasons there can be no exceptions to this.
set(PYTHON_VERSION 3.10.9)
set(PYTHON_VERSION 3.10.11)
set(PYTHON_SHORT_VERSION 3.10)
set(PYTHON_SHORT_VERSION_NO_DOTS 310)
set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
set(PYTHON_HASH dc8c0f274b28ee9e95923d20cfc364c9)
set(PYTHON_HASH 1bf8481a683e0881e14d52e0f23633a6)
set(PYTHON_HASH_TYPE MD5)
set(PYTHON_FILE Python-${PYTHON_VERSION}.tar.xz)
set(PYTHON_CPE "cpe:2.3:a:python:python:${PYTHON_VERSION}:-:*:*:*:*:*:*")
@ -296,9 +295,9 @@ set(THEORA_HASH b6ae1ee2fa3d42ac489287d3ec34c5885730b1296f0801ae577a35193d3affbc
set(THEORA_HASH_TYPE SHA256)
set(THEORA_FILE libtheora-${THEORA_VERSION}.tar.bz2)
set(FLAC_VERSION 1.3.4)
set(FLAC_VERSION 1.4.2)
set(FLAC_URI http://downloads.xiph.org/releases/flac/flac-${FLAC_VERSION}.tar.xz)
set(FLAC_HASH 8ff0607e75a322dd7cd6ec48f4f225471404ae2730d0ea945127b1355155e737 )
set(FLAC_HASH e322d58a1f48d23d9dd38f432672865f6f79e73a6f9cc5a5f57fcaa83eb5a8e4 )
set(FLAC_HASH_TYPE SHA256)
set(FLAC_FILE flac-${FLAC_VERSION}.tar.xz)
set(FLAC_CPE "cpe:2.3:a:flac_project:flac:${FLAC_VERSION}:*:*:*:*:*:*:*")
@ -336,9 +335,9 @@ set(OPENJPEG_HASH_TYPE SHA256)
set(OPENJPEG_FILE openjpeg-v${OPENJPEG_VERSION}.tar.gz)
set(OPENJPEG_CPE "cpe:2.3:a:uclouvain:openjpeg:${OPENJPEG_VERSION}:*:*:*:*:*:*:*")
set(FFMPEG_VERSION 5.1.2)
set(FFMPEG_VERSION 6.0)
set(FFMPEG_URI http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2)
set(FFMPEG_HASH 39a0bcc8d98549f16c570624678246a6ac736c066cebdb409f9502e915b22f2b)
set(FFMPEG_HASH 47d062731c9f66a78380e35a19aac77cebceccd1c7cc309b9c82343ffc430c3d)
set(FFMPEG_HASH_TYPE SHA256)
set(FFMPEG_FILE ffmpeg-${FFMPEG_VERSION}.tar.bz2)
set(FFMPEG_CPE "cpe:2.3:a:ffmpeg:ffmpeg:${FFMPEG_VERSION}:*:*:*:*:*:*:*")
@ -460,9 +459,9 @@ set(LZMA_HASH_TYPE SHA256)
set(LZMA_FILE xz-${LZMA_VERSION}.tar.bz2)
# NOTE: Python's build has been modified to use our ssl version.
set(SSL_VERSION 1.1.1q)
set(SSL_VERSION 1.1.1t)
set(SSL_URI https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz)
set(SSL_HASH d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca)
set(SSL_HASH 8dee9b24bdb1dcbf0c3d1e9b02fb8f6bf22165e807f45adeb7c9677536859d3b)
set(SSL_HASH_TYPE SHA256)
set(SSL_FILE openssl-${SSL_VERSION}.tar.gz)
set(SSL_CPE "cpe:2.3:a:openssl:openssl:${SSL_VERSION}:*:*:*:*:*:*:*")
@ -470,10 +469,10 @@ set(SSL_CPE "cpe:2.3:a:openssl:openssl:${SSL_VERSION}:*:*:*:*:*:*:*")
# Note: This will *HAVE* to match the version python ships on windows which
# is hardcoded in pythons PCbuild/get_externals.bat for compliance reasons there
# can be no exceptions to this.
set(SQLITE_VERSION 3.39.4)
set(SQLLITE_LONG_VERSION 3390400)
set(SQLITE_VERSION 3.40.1)
set(SQLLITE_LONG_VERSION 3400100)
set(SQLITE_URI https://www.sqlite.org/2022/sqlite-autoconf-${SQLLITE_LONG_VERSION}.tar.gz)
set(SQLITE_HASH c4c5c39269d1b9bb1487cff580c1f583608229b2)
set(SQLITE_HASH b8c2d4bc0094f5c0ce985dc0e237dfcbaa1f6275)
set(SQLITE_HASH_TYPE SHA1)
set(SQLITE_FILE sqlite-autoconf-${SQLLITE_LONG_VERSION}.tar.gz)
set(SQLITE_CPE "cpe:2.3:a:sqlite:sqlite:${SQLITE_VERSION}:*:*:*:*:*:*:*")
@ -484,9 +483,9 @@ set(EMBREE_HASH dd26617719a587e126b341d1b32f7fd0)
set(EMBREE_HASH_TYPE MD5)
set(EMBREE_FILE embree-v${EMBREE_VERSION}.zip)
set(USD_VERSION 22.11)
set(USD_VERSION 23.05)
set(USD_URI https://github.com/PixarAnimationStudios/USD/archive/v${USD_VERSION}.tar.gz)
set(USD_HASH 8c89459e48a2ef0e7ae9e7e490377507)
set(USD_HASH 56684f4fdd1a9209dabf03856be5eca6)
set(USD_HASH_TYPE MD5)
set(USD_FILE usd-v${USD_VERSION}.tar.gz)

View File

@ -9,77 +9,3 @@
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 && {
--- a/libavcodec/cfhddata.c
+++ b/libavcodec/cfhddata.c
@@ -276,10 +276,10 @@
av_cold int ff_cfhd_init_vlcs(CFHDContext *s)
{
int i, j, ret = 0;
- uint32_t new_cfhd_vlc_bits[NB_VLC_TABLE_18 * 2];
- uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2];
- uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2];
- int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2];
+ uint32_t *new_cfhd_vlc_bits = av_calloc(sizeof(uint32_t), NB_VLC_TABLE_18 * 2);
+ uint8_t *new_cfhd_vlc_len = av_calloc(sizeof(uint8_t), NB_VLC_TABLE_18 * 2);
+ uint16_t *new_cfhd_vlc_run = av_calloc(sizeof(uint16_t), NB_VLC_TABLE_18 * 2);
+ int16_t *new_cfhd_vlc_level = av_calloc(sizeof(int16_t), NB_VLC_TABLE_18 * 2);
/** Similar to dv.c, generate signed VLC tables **/
@@ -305,8 +305,13 @@
ret = init_vlc(&s->vlc_9, VLC_BITS, j, new_cfhd_vlc_len,
1, 1, new_cfhd_vlc_bits, 4, 4, 0);
- if (ret < 0)
+ if (ret < 0) {
+ av_free(new_cfhd_vlc_bits);
+ av_free(new_cfhd_vlc_len);
+ av_free(new_cfhd_vlc_run);
+ av_free(new_cfhd_vlc_level);
return ret;
+ }
for (i = 0; i < s->vlc_9.table_size; i++) {
int code = s->vlc_9.table[i][0];
int len = s->vlc_9.table[i][1];
@@ -346,8 +351,14 @@
ret = init_vlc(&s->vlc_18, VLC_BITS, j, new_cfhd_vlc_len,
1, 1, new_cfhd_vlc_bits, 4, 4, 0);
- if (ret < 0)
+ if (ret < 0) {
+ av_free(new_cfhd_vlc_bits);
+ av_free(new_cfhd_vlc_len);
+ av_free(new_cfhd_vlc_run);
+ av_free(new_cfhd_vlc_level);
return ret;
+ }
+
av_assert0(s->vlc_18.table_size == 4572);
for (i = 0; i < s->vlc_18.table_size; i++) {
@@ -367,5 +378,10 @@
s->table_18_rl_vlc[i].run = run;
}
+ av_free(new_cfhd_vlc_bits);
+ av_free(new_cfhd_vlc_len);
+ av_free(new_cfhd_vlc_run);
+ av_free(new_cfhd_vlc_level);
+
return ret;
}
diff --git a/libavcodec/x86/simple_idct.asm b/libavcodec/x86/simple_idct.asm
index dcf0da6df121..982b2f0bbba1 100644
--- a/libavcodec/x86/simple_idct.asm
+++ b/libavcodec/x86/simple_idct.asm
@@ -25,9 +25,9 @@
%include "libavutil/x86/x86util.asm"
-%if ARCH_X86_32
SECTION_RODATA
+%if ARCH_X86_32
cextern pb_80
wm1010: dw 0, 0xffff, 0, 0xffff

View File

@ -0,0 +1,13 @@
diff --git a/src/python/py_oiio.cpp b/src/python/py_oiio.cpp
index 6031d2c23..e71105da5 100644
--- a/src/python/py_oiio.cpp
+++ b/src/python/py_oiio.cpp
@@ -153,7 +153,7 @@ oiio_bufinfo::oiio_bufinfo(const py::buffer_info& pybuf, int nchans, int width,
format = TypeUnknown; // No idea what's going on -- error
error = Strutil::fmt::format(
"Python array shape is [{:,}] but expecting h={}, w={}, ch={}",
- cspan<ssize_t>(pybuf.shape), height, width, nchans);
+ cspan<py::ssize_t>(pybuf.shape), height, width, nchans);
}
} else if (pixeldims == 1) {
// Reading a 1D scanline span

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
diff --git a/pxr/usd/usdMtlx/reader.cpp b/pxr/usd/usdMtlx/reader.cpp
index 29e901816..e6fc68b20 100644
--- a/pxr/usd/usdMtlx/reader.cpp
+++ b/pxr/usd/usdMtlx/reader.cpp
@@ -797,6 +797,15 @@ _NodeGraphBuilder::_CreateInterfaceInputs(
// We deliberately ignore tokens here.
}
+mx::StringSet _GetStdlibIncludes() {
+ mx::StringSet stdlibIncludes = UsdMtlxGetDocument("")->getReferencedSourceUris();
+ mx::StringSet normStdlibIncludes;
+ for (std::string const& entry : stdlibIncludes) {
+ normStdlibIncludes.insert(TfNormPath(entry));
+ }
+ return normStdlibIncludes;
+}
+
// Returns True if the mtlxNodeDef corresponds to a locally defined custom node
// with an associated nodegraph.
// XXX Locally defined custom nodes without nodegraphs are not supported
@@ -818,13 +827,14 @@ _NodeGraphBuilder::_IsLocalCustomNode(const mx::ConstNodeDefPtr &mtlxNodeDef)
}
// Combine with the nodeDef relative path
nodeDefUri = TfNormPath(fullMtlxPath + nodeDefUri);
+ } else {
+ nodeDefUri = TfNormPath(nodeDefUri);
}
// This is a locally defined custom node if the absolute path to the
// nodedef is not included in the stdlibDoc.
static mx::StringSet customNodeDefNames;
- static const mx::StringSet stdlibIncludes =
- UsdMtlxGetDocument("")->getReferencedSourceUris();
+ static const mx::StringSet stdlibIncludes = _GetStdlibIncludes();
if (stdlibIncludes.find(nodeDefUri) == stdlibIncludes.end()) {
// Check if we already used this custom node
if (std::find(customNodeDefNames.begin(), customNodeDefNames.end(),

View File

@ -0,0 +1,106 @@
diff --git a/build_scripts/build_usd.py b/build_scripts/build_usd.py
index cfe243effb..a4bb94eee1 100644
--- a/build_scripts/build_usd.py
+++ b/build_scripts/build_usd.py
@@ -1415,7 +1415,7 @@ def InstallDraco(context, force, buildArgs):
############################################################
# MaterialX
-MATERIALX_URL = "https://github.com/materialx/MaterialX/archive/v1.38.4.zip"
+MATERIALX_URL = "https://github.com/materialx/MaterialX/archive/v1.38.5.zip"
def InstallMaterialX(context, force, buildArgs):
with CurrentWorkingDirectory(DownloadURL(MATERIALX_URL, context, force)):
diff --git a/pxr/imaging/hdSt/materialXShaderGen.cpp b/pxr/imaging/hdSt/materialXShaderGen.cpp
index df80ff119f..e4b5f04a73 100644
--- a/pxr/imaging/hdSt/materialXShaderGen.cpp
+++ b/pxr/imaging/hdSt/materialXShaderGen.cpp
@@ -136,8 +136,7 @@ HdStMaterialXShaderGen::HdStMaterialXShaderGen(
"st" : mxHdInfo.defaultTexcoordName;
// Register the customized version of the Surface node generator
- registerImplementation("IM_surface_" + GlslShaderGenerator::TARGET,
- HdStMaterialXSurfaceNodeGen::create);
+ registerImplementation("IM_surface_genglsl", HdStMaterialXSurfaceNodeGen::create);
}
// Based on GlslShaderGenerator::generate()
@@ -273,8 +272,7 @@ HdStMaterialXShaderGen::_EmitMxFunctions(
mx::ShaderStage& mxStage) const
{
// Add global constants and type definitions
- emitLibraryInclude("stdlib/" + mx::GlslShaderGenerator::TARGET
- + "/lib/mx_math.glsl", mxContext, mxStage);
+ emitLibraryInclude("stdlib/genglsl/lib/mx_math.glsl", mxContext, mxStage);
emitLine("#if NUM_LIGHTS > 0", mxStage, false);
emitLine("#define MAX_LIGHT_SOURCES NUM_LIGHTS", mxStage, false);
emitLine("#else", mxStage, false);
@@ -394,16 +392,24 @@ HdStMaterialXShaderGen::_EmitMxFunctions(
emitSpecularEnvironment(mxContext, mxStage);
}
if (shadowing) {
- emitLibraryInclude("pbrlib/" + mx::GlslShaderGenerator::TARGET
- + "/lib/mx_shadow.glsl", mxContext, mxStage);
+ emitLibraryInclude("pbrlib/genglsl/lib/mx_shadow.glsl", mxContext, mxStage);
}
+#if MATERIALX_MAJOR_VERSION > 1 || \
+ (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION > 38) || \
+ (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION == 38 && MATERIALX_BUILD_VERSION > 4)
+ // MaterialX 1.38.5 changes the default transmission method to "refraction".
+ mxContext.getOptions().hwTransmissionRenderMethod = mx::TRANSMISSION_OPACITY;
+
+ // Emit transmission code
+ emitTransmissionRender(mxContext, mxStage);
+#endif
+
// Emit directional albedo table code.
if (mxContext.getOptions().hwDirectionalAlbedoMethod ==
mx::HwDirectionalAlbedoMethod::DIRECTIONAL_ALBEDO_TABLE ||
mxContext.getOptions().hwWriteAlbedoTable) {
- emitLibraryInclude("pbrlib/" + mx::GlslShaderGenerator::TARGET
- + "/lib/mx_table.glsl", mxContext, mxStage);
+ emitLibraryInclude("pbrlib/genglsl/lib/mx_table.glsl", mxContext, mxStage);
emitLineBreak(mxStage);
}
@@ -421,7 +427,7 @@ HdStMaterialXShaderGen::_EmitMxFunctions(
// Emit uv transform code globally if needed.
if (mxContext.getOptions().hwAmbientOcclusion) {
emitLibraryInclude(
- "stdlib/" + mx::GlslShaderGenerator::TARGET + "/lib/" +
+ "stdlib/genglsl/lib/" +
_tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV],
mxContext, mxStage);
}
@@ -490,10 +496,30 @@ HdStMaterialXShaderGen::_EmitMxSurfaceShader(
// closure/shader nodes and need to be emitted first.
emitFunctionCalls(mxGraph, mxContext, mxStage, mx::ShaderNode::Classification::TEXTURE);
+#if MATERIALX_MAJOR_VERSION == 1 && \
+ MATERIALX_MINOR_VERSION == 38 && \
+ MATERIALX_BUILD_VERSION <= 4
// Emit function calls for all surface shader nodes.
// These will internally emit their closure function calls.
emitFunctionCalls(mxGraph, mxContext, mxStage, mx::ShaderNode::Classification::SHADER |
mx::ShaderNode::Classification::SURFACE);
+#else
+ // Emit function calls for "root" closure/shader nodes.
+ // These will internally emit function calls for any dependent closure nodes upstream.
+ for (mx::ShaderGraphOutputSocket* socket : mxGraph.getOutputSockets())
+ {
+ if (socket->getConnection())
+ {
+ const mx::ShaderNode* upstream = socket->getConnection()->getNode();
+ if (upstream->getParent() == &mxGraph &&
+ (upstream->hasClassification(mx::ShaderNode::Classification::CLOSURE) ||
+ upstream->hasClassification(mx::ShaderNode::Classification::SHADER)))
+ {
+ emitFunctionCall(*upstream, mxContext, mxStage);
+ }
+ }
+ }
+#endif
}
else
{

View File

@ -108,7 +108,8 @@ set oiio_paths=%Staging%\%BuildDir%%ARCH%R\Release\openimageio\bin;%Staging%\%Bu
set boost_paths=%Staging%\%BuildDir%%ARCH%R\Release\boost\lib;%Staging%\%BuildDir%%ARCH%D\Debug\boost\lib
set openexr_paths=%Staging%\%BuildDir%%ARCH%R\Release\openexr\bin;%Staging%\%BuildDir%%ARCH%D\Debug\openexr\bin
set imath_paths=%Staging%\%BuildDir%%ARCH%R\Release\imath\bin;%Staging%\%BuildDir%%ARCH%D\Debug\imath\bin
set path=%BUILD_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%BUILD_DIR%\downloads\nasm-2.12.01\;%path%;%boost_paths%;%oiio_paths%;%openexr_paths%;%imath_paths%
set tbb_paths=%Staging%\%BuildDir%%ARCH%R\Release\tbb\bin;%Staging%\%BuildDir%%ARCH%D\Debug\tbb\bin
set path=%BUILD_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%BUILD_DIR%\downloads\nasm-2.12.01\;%path%;%boost_paths%;%oiio_paths%;%openexr_paths%;%imath_paths%;%tbb_paths%
mkdir %STAGING%\%BuildDir%%ARCH%R
cd %Staging%\%BuildDir%%ARCH%R
echo %DATE% %TIME% : Start > %StatusFile%

View File

@ -314,7 +314,7 @@ if(WITH_CYCLES AND WITH_CYCLES_OSL)
endif()
endif()
if(WITH_CYCLES AND (WITH_CYCLES_DEVICE_ONEAPI OR (WITH_CYCLES_EMBREE AND EMBREE_SYCL_SUPPORT)))
if(WITH_CYCLES AND WITH_CYCLES_DEVICE_ONEAPI)
set(CYCLES_LEVEL_ZERO ${LIBDIR}/level-zero CACHE PATH "Path to Level Zero installation")
if(EXISTS ${CYCLES_LEVEL_ZERO} AND NOT LEVEL_ZERO_ROOT_DIR)
set(LEVEL_ZERO_ROOT_DIR ${CYCLES_LEVEL_ZERO})
@ -324,6 +324,13 @@ if(WITH_CYCLES AND (WITH_CYCLES_DEVICE_ONEAPI OR (WITH_CYCLES_EMBREE AND EMBREE_
if(EXISTS ${CYCLES_SYCL} AND NOT SYCL_ROOT_DIR)
set(SYCL_ROOT_DIR ${CYCLES_SYCL})
endif()
endif()
# add_bundled_libraries for SYCL, but custom since we need to filter the files.
if(DEFINED LIBDIR)
if(NOT DEFINED SYCL_ROOT_DIR)
set(SYCL_ROOT_DIR ${LIBDIR}/dpcpp)
endif()
file(GLOB _sycl_runtime_libraries
${SYCL_ROOT_DIR}/lib/libsycl.so
${SYCL_ROOT_DIR}/lib/libsycl.so.*
@ -1005,7 +1012,7 @@ if(PLATFORM_BUNDLED_LIBRARIES)
# Environment variables to run precompiled executables that needed libraries.
list(JOIN PLATFORM_BUNDLED_LIBRARY_DIRS ":" _library_paths)
set(PLATFORM_ENV_BUILD "LD_LIBRARY_PATH=\"${_library_paths};${LD_LIBRARY_PATH}\"")
set(PLATFORM_ENV_BUILD "LD_LIBRARY_PATH=\"${_library_paths}:${LD_LIBRARY_PATH}\"")
set(PLATFORM_ENV_INSTALL "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/lib/;$LD_LIBRARY_PATH")
unset(_library_paths)
endif()

View File

@ -21,7 +21,7 @@
#define __WCWIDTH_H__
#ifndef __cplusplus
# if defined(__APPLE__) || defined(__NetBSD__)
# if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
/* The <uchar.h> standard header is missing on macOS. */
#include <stddef.h>
typedef unsigned int char32_t;

View File

@ -14,7 +14,6 @@ PassAccessorGPU::PassAccessorGPU(DeviceQueue *queue,
float exposure,
int num_samples)
: PassAccessor(pass_access_info, exposure, num_samples), queue_(queue)
{
}

View File

@ -118,7 +118,9 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
{
/* For curves use the smooth normal, particularly for ribbons the geometric
* normal gives too much darkening otherwise. */
int label;
*eval = zero_spectrum();
*pdf = 0.f;
int label = LABEL_NONE;
const float3 Ng = (sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng;
switch (sc->type) {
@ -536,6 +538,7 @@ ccl_device_inline
ccl_private float *pdf)
{
Spectrum eval = zero_spectrum();
*pdf = 0.f;
switch (sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:

View File

@ -8,7 +8,7 @@
/* Adopted from Libmv. */
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
/* Needed for memalign on Linux and _aligned_alloc on Windows. */
# ifdef FREE_WINDOWS
/* Make sure _aligned_malloc is included. */
@ -33,7 +33,7 @@ void *util_aligned_malloc(size_t size, int alignment)
return MEM_mallocN_aligned(size, alignment, "Cycles Aligned Alloc");
#elif defined(_WIN32)
return _aligned_malloc(size, alignment);
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
void *result;
if (posix_memalign(&result, alignment, size)) {
/* Non-zero means allocation error

View File

@ -59,7 +59,7 @@ void *aligned_malloc(size_t size, size_t alignment)
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
void *result;
if (posix_memalign(&result, alignment, size)) {

View File

@ -52,7 +52,7 @@ size_t malloc_usable_size(void *ptr);
# define UNLIKELY(x) (x)
#endif
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
// Needed for memalign on Linux and _aligned_alloc on Windows.
# include <malloc.h>

View File

@ -21,7 +21,8 @@
#include "libmv/base/aligned_malloc.h"
#include "libmv/logging/logging.h"
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
!defined(__OpenBSD__)
// Needed for memalign on Linux and _aligned_alloc on Windows.
# ifdef FREE_WINDOWS
/* make sure _aligned_malloc is included */
@ -44,7 +45,8 @@ namespace libmv {
void* aligned_malloc(int size, int alignment) {
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
void* result;
if (posix_memalign(&result, alignment, size)) {

View File

@ -567,6 +567,7 @@ const bTheme U_theme_default = {
.handle_vertex_size = 4,
.anim_active = RGBA(0x4d272766),
.anim_preview_range = RGBA(0xa14d0066),
.simulated_frames = RGBA(0x721e65ff),
},
.space_nla = {
.back = RGBA(0x30303000),

View File

@ -39,6 +39,11 @@ class PHYSICS_PT_geometry_nodes(Panel):
row.operator("object.simulation_nodes_cache_bake", text=bake_text).selected = True
row.operator("object.simulation_nodes_cache_delete", text="", icon='TRASH').selected = True
layout.use_property_split = True
layout.use_property_decorate = False
ob = context.object
layout.prop(ob, "use_simulation_cache", text="Cache")
classes = (
PHYSICS_PT_geometry_nodes,

View File

@ -62,6 +62,7 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_pointcloud_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_rigidbody_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_scene_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_scene_enums.h
${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

View File

@ -123,7 +123,7 @@ TEST_F(AssetLibraryServiceTest, library_from_reference)
Main dummy_main{};
std::string dummy_filepath = asset_library_root_ + SEP + "dummy.blend";
BLI_strncpy(dummy_main.filepath, dummy_filepath.c_str(), sizeof(dummy_main.filepath));
STRNCPY(dummy_main.filepath, dummy_filepath.c_str());
EXPECT_EQ(lib, service->get_asset_library(&dummy_main, ref))
<< "Getting the local (current file) reference with a main saved on disk should return "
"the an asset library for this directory";

View File

@ -25,13 +25,13 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 7
#define BLENDER_FILE_SUBVERSION 8
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file
* was written with too new a version. */
#define BLENDER_FILE_MIN_VERSION 305
#define BLENDER_FILE_MIN_SUBVERSION 8
#define BLENDER_FILE_MIN_SUBVERSION 9
/** User readable version string. */
const char *BKE_blender_version_string(void);

View File

@ -82,7 +82,7 @@ class CurvesGeometryRuntime {
mutable SharedCache<Vector<float3>> evaluated_position_cache;
/**
* A cache of bounds shared between data-blocks with unchanged positions and radii.
* A cache of bounds shared between data-blocks with unchanged positions.
* When data changes affect the bounds, the cache is "un-shared" with other geometries.
* See #SharedCache comments.
*/

View File

@ -252,25 +252,15 @@ void IDP_Reset(struct IDProperty *prop, const struct IDProperty *reference);
/* C11 const correctness for casts */
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
# define IDP_Float(prop) \
_Generic((prop), \
struct IDProperty *: (*(float *)&(prop)->data.val), \
const struct IDProperty *: (*(const float *)&(prop)->data.val))
_Generic((prop), struct IDProperty * : (*(float *)&(prop)->data.val), const struct IDProperty * : (*(const float *)&(prop)->data.val))
# define IDP_Double(prop) \
_Generic((prop), \
struct IDProperty *: (*(double *)&(prop)->data.val), \
const struct IDProperty *: (*(const double *)&(prop)->data.val))
_Generic((prop), struct IDProperty * : (*(double *)&(prop)->data.val), const struct IDProperty * : (*(const double *)&(prop)->data.val))
# define IDP_String(prop) \
_Generic((prop), \
struct IDProperty *: ((char *) (prop)->data.pointer), \
const struct IDProperty *: ((const char *) (prop)->data.pointer))
_Generic((prop), struct IDProperty * : ((char *)(prop)->data.pointer), const struct IDProperty * : ((const char *)(prop)->data.pointer))
# define IDP_IDPArray(prop) \
_Generic((prop), \
struct IDProperty *: ((struct IDProperty *) (prop)->data.pointer), \
const struct IDProperty *: ((const struct IDProperty *) (prop)->data.pointer))
_Generic((prop), struct IDProperty * : ((struct IDProperty *)(prop)->data.pointer), const struct IDProperty * : ((const struct IDProperty *)(prop)->data.pointer))
# define IDP_Id(prop) \
_Generic((prop), \
struct IDProperty *: ((ID *) (prop)->data.pointer), \
const struct IDProperty *: ((const ID *) (prop)->data.pointer))
_Generic((prop), struct IDProperty * : ((ID *)(prop)->data.pointer), const struct IDProperty * : ((const ID *)(prop)->data.pointer))
#else
# define IDP_Float(prop) (*(float *)&(prop)->data.val)
# define IDP_Double(prop) (*(double *)&(prop)->data.val)

View File

@ -308,6 +308,15 @@ void BKE_id_free_us(struct Main *bmain, void *idv) ATTR_NONNULL();
* Properly delete a single ID from given \a bmain database.
*/
void BKE_id_delete(struct Main *bmain, void *idv) ATTR_NONNULL();
/**
* Like BKE_id_delete, but with extra corner-case options.
*
* \param extra_remapping_flags Additional `ID_REMAP_` flags to pass to remapping code when
* ensuring that deleted IDs are not used by any other ID in given `bmain`. Typical example would
* be e.g. `ID_REMAP_FORCE_UI_POINTERS`, required when default UI-handling callbacks of remapping
* code won't be working (e.g. from readfile code). */
void BKE_id_delete_ex(struct Main *bmain, void *idv, const int extra_remapping_flags)
ATTR_NONNULL(1, 2);
/**
* Properly delete all IDs tagged with \a LIB_TAG_DOIT, in given \a bmain database.
*

View File

@ -269,7 +269,7 @@ bool BKE_library_id_can_use_idtype(struct ID *id_owner, short id_type_used);
/**
* Given the id_owner return the type of id_types it can use as a filter_id.
*/
uint64_t BKE_library_id_can_use_filter_id(const struct ID *id_owner);
uint64_t BKE_library_id_can_use_filter_id(const struct ID *id_owner, const bool include_ui);
/**
* Check whether given ID is used locally (i.e. by another non-linked ID).

View File

@ -79,6 +79,52 @@ void normals_calc_poly_vert(Span<float3> vert_positions,
MutableSpan<float3> poly_normals,
MutableSpan<float3> vert_normals);
/** \} */
/* -------------------------------------------------------------------- */
/** \name Face Corner Normal Calculation
* \{ */
/**
* Combined with the automatically calculated face corner normal, this gives a dimentional
* coordinate space used to convert normals between the "custom normal" #short2 representation and
* a regular #float3 format.
*/
struct CornerNormalSpace {
/** Reference vector, orthogonal to corner normal. */
float3 vec_ref;
/** Third vector, orthogonal to corner normal and #vec_ref. */
float3 vec_ortho;
/** Reference angle around #vec_ortho, in [0, pi] range (0.0 marks space as invalid). */
float ref_alpha;
/** Reference angle around corner normal, in [0, 2pi] range (0.0 marks space as invalid). */
float ref_beta;
};
/**
* Storage for corner fan coordinate spaces for an entire mesh.
*/
struct CornerNormalSpaceArray {
/**
* The normal coordinate spaces, potentially shared between multiple face corners in a smooth fan
* connected to a vertex (and not per face corner). Depending on the mesh (the amount of sharing
* / number of sharp edges / size of each fan), there may be many fewer spaces than face corners,
* so they are stored in a separate array.
*/
Array<CornerNormalSpace> spaces;
/**
* The index of the data in the #spaces array for each face corner (the array size is the
* same as #Mesh::totloop). Rare -1 values define face corners without a coordinate space.
*/
Array<int> corner_space_indices;
};
void lnor_space_custom_normal_to_data(const CornerNormalSpace *lnor_space,
float3 lnor_no_custom,
const float custom_lnor[3],
short r_clnor_data[2]);
/**
* Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals').
* Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry
@ -87,6 +133,8 @@ void normals_calc_poly_vert(Span<float3> vert_positions,
* \param loop_to_poly_map: Optional pre-created map from corners to their polygon.
* \param sharp_edges: Optional array of sharp edge tags, used to split the evaluated normals on
* each side of the edge.
* \param r_lnors_spacearr: Optional return data filled with information about the custom
* normals spaces for each grouped fan of face corners.
*/
void normals_calc_loop(Span<float3> vert_positions,
Span<int2> edges,
@ -101,7 +149,7 @@ void normals_calc_loop(Span<float3> vert_positions,
bool use_split_normals,
float split_angle,
short2 *clnors_data,
MLoopNorSpaceArray *r_lnors_spacearr,
CornerNormalSpaceArray *r_lnors_spacearr,
MutableSpan<float3> r_loop_normals);
void normals_loop_custom_set(Span<float3> vert_positions,

View File

@ -8,6 +8,8 @@
* used by painting and tools.
*/
#include "DNA_scene_enums.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -92,7 +94,6 @@ void BKE_object_defgroup_index_map_apply(struct MDeformVert *dvert,
/* Select helpers. */
enum eVGroupSelect;
/**
* Return the subset type of the Vertex Group Selection.
*/

View File

@ -720,7 +720,7 @@ typedef struct PBVHFaceIter {
const struct BMesh *bm;
CCGKey subdiv_key_;
int last_face_index_;
int last_poly_index_;
} PBVHFaceIter;
void BKE_pbvh_face_iter_init(PBVH *pbvh, PBVHNode *node, PBVHFaceIter *fd);

View File

@ -181,6 +181,7 @@ class ModifierSimulationCache {
}
void reset();
void clear_prev_states();
};
} // namespace blender::bke::sim

View File

@ -776,11 +776,11 @@ struct MovieTrackingObject *BKE_tracking_find_object_for_plane_track(
void BKE_tracking_get_rna_path_for_track(const struct MovieTracking *tracking,
const struct MovieTrackingTrack *track,
char *rna_path,
size_t rna_path_len);
size_t rna_path_maxncpy);
void BKE_tracking_get_rna_path_prefix_for_track(const struct MovieTracking *tracking,
const struct MovieTrackingTrack *track,
char *rna_path,
size_t rna_path_len);
size_t rna_path_maxncpy);
void BKE_tracking_get_rna_path_for_plane_track(const struct MovieTracking *tracking,
const struct MovieTrackingPlaneTrack *plane_track,
char *rna_path,
@ -789,7 +789,7 @@ void BKE_tracking_get_rna_path_prefix_for_plane_track(
const struct MovieTracking *tracking,
const struct MovieTrackingPlaneTrack *plane_track,
char *rna_path,
size_t rna_path_len);
size_t rna_path_maxncpy);
/* --------------------------------------------------------------------
* Utility macros.

View File

@ -500,7 +500,7 @@ static void mesh_calc_finalize(const Mesh *mesh_input, Mesh *mesh_eval)
{
/* Make sure the name is the same. This is because mesh allocation from template does not
* take care of naming. */
BLI_strncpy(mesh_eval->id.name, mesh_input->id.name, sizeof(mesh_eval->id.name));
STRNCPY(mesh_eval->id.name, mesh_input->id.name);
/* Make evaluated mesh to share same edit mesh pointer as original and copied meshes. */
mesh_eval->edit_mesh = mesh_input->edit_mesh;
}

View File

@ -422,7 +422,7 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[])
/* make it selected, with default name */
agrp->flag = AGRP_SELECTED;
BLI_strncpy(agrp->name, name[0] ? name : DATA_("Group"), sizeof(agrp->name));
STRNCPY(agrp->name, name[0] ? name : DATA_("Group"));
/* add to action, and validate */
BLI_addtail(&act->groups, agrp);
@ -645,7 +645,7 @@ bPoseChannel *BKE_pose_channel_ensure(bPose *pose, const char *name)
BKE_pose_channel_session_uuid_generate(chan);
BLI_strncpy(chan->name, name, sizeof(chan->name));
STRNCPY(chan->name, name);
copy_v3_fl(chan->custom_scale_xyz, 1.0f);
zero_v3(chan->custom_translation);
@ -1273,7 +1273,7 @@ bActionGroup *BKE_pose_add_group(bPose *pose, const char *name)
}
grp = MEM_callocN(sizeof(bActionGroup), "PoseGroup");
BLI_strncpy(grp->name, name, sizeof(grp->name));
STRNCPY(grp->name, name);
BLI_addtail(&pose->agroups, grp);
BLI_uniquename(&pose->agroups, grp, name, '.', offsetof(bActionGroup, name), sizeof(grp->name));
@ -1772,10 +1772,10 @@ void what_does_obaction(Object *ob,
}
}
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
STRNCPY(workob->parsubstr, ob->parsubstr);
/* we don't use real object name, otherwise RNA screws with the real thing */
BLI_strncpy(workob->id.name, "OB<ConstrWorkOb>", sizeof(workob->id.name));
STRNCPY(workob->id.name, "OB<ConstrWorkOb>");
/* If we're given a group to use, it's likely to be more efficient
* (though a bit more dangerous). */

View File

@ -46,7 +46,7 @@ bAddon *BKE_addon_ensure(ListBase *addon_list, const char *module)
bAddon *addon = BKE_addon_find(addon_list, module);
if (addon == NULL) {
addon = BKE_addon_new();
BLI_strncpy(addon->module, module, sizeof(addon->module));
STRNCPY(addon->module, module);
BLI_addtail(addon_list, addon);
}
return addon;

View File

@ -767,7 +767,7 @@ static bool fcurves_path_rename_fix(ID *owner_id,
bActionGroup *agrp = fcu->grp;
is_changed = true;
if (oldName != NULL && (agrp != NULL) && STREQ(oldName, agrp->name)) {
BLI_strncpy(agrp->name, newName, sizeof(agrp->name));
STRNCPY(agrp->name, newName);
}
}
}
@ -819,7 +819,7 @@ static bool drivers_path_rename_fix(ID *owner_id,
(dtar->pchan_name[0]) && STREQ(oldName, dtar->pchan_name))
{
is_changed = true;
BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name));
STRNCPY(dtar->pchan_name, newName);
}
}
}

View File

@ -131,12 +131,8 @@ KeyingSet *BKE_keyingset_add(
/* allocate new KeyingSet */
ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet");
BLI_strncpy(ks->idname,
(idname) ? idname :
(name) ? name :
DATA_("KeyingSet"),
sizeof(ks->idname));
BLI_strncpy(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set"), sizeof(ks->name));
STRNCPY(ks->idname, (idname) ? idname : (name) ? name : DATA_("KeyingSet"));
STRNCPY(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set"));
ks->flag = flag;
ks->keyingflag = keyingflag;
@ -193,7 +189,7 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks,
/* just store absolute info */
ksp->id = id;
if (group_name) {
BLI_strncpy(ksp->group, group_name, sizeof(ksp->group));
STRNCPY(ksp->group, group_name);
}
else {
ksp->group[0] = '\0';
@ -608,13 +604,18 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr,
}
}
/* This function assumes that the quaternion is keyed in array index order.
* If the quaternion is only partially keyed, the result is normalized.
* If it is fully keyed, the result is returned as-is. */
static void animsys_quaternion_evaluate_fcurves(PathResolvedRNA quat_rna,
FCurve *first_fcurve,
const AnimationEvalContext *anim_eval_context,
float r_quaternion[4])
/**
* This function assumes that the quaternion keys are sequential. They do not
* have to be in array_index order. If the quaternion is only partially keyed,
* the result is normalized. If it is fully keyed, the result is returned as-is.
*
* \return the number of FCurves used to construct this quaternion. This is so
* that the caller knows how many FCurves can be skipped while iterating over
* them. */
static int animsys_quaternion_evaluate_fcurves(PathResolvedRNA quat_rna,
FCurve *first_fcurve,
const AnimationEvalContext *anim_eval_context,
float r_quaternion[4])
{
FCurve *quat_curve_fcu = first_fcurve;
@ -625,46 +626,54 @@ static void animsys_quaternion_evaluate_fcurves(PathResolvedRNA quat_rna,
r_quaternion[2] = 0.0f;
r_quaternion[3] = 0.0f;
/* This should start at 0, but in the case of semi-keyed quaternions, the first FCurve may
* actually have a different array index. */
const int start_index = first_fcurve->array_index;
int prop_index = start_index;
for (; prop_index < 4 && quat_curve_fcu; ++prop_index, quat_curve_fcu = quat_curve_fcu->next) {
if (quat_curve_fcu->array_index != prop_index ||
!STREQ(quat_curve_fcu->rna_path, first_fcurve->rna_path))
{
/* This should never happen when the quaternion is fully keyed and stored in order. People
* do use half-keyed quaternions, though, so better to check anyway. */
int fcurve_offset = 0;
for (; fcurve_offset < 4 && quat_curve_fcu;
++fcurve_offset, quat_curve_fcu = quat_curve_fcu->next) {
if (!STREQ(quat_curve_fcu->rna_path, first_fcurve->rna_path)) {
/* This should never happen when the quaternion is fully keyed. Some
* people do use half-keyed quaternions, though, so better to check. */
break;
}
quat_rna.prop_index = prop_index;
r_quaternion[prop_index] = calculate_fcurve(&quat_rna, quat_curve_fcu, anim_eval_context);
const int array_index = quat_curve_fcu->array_index;
quat_rna.prop_index = array_index;
r_quaternion[array_index] = calculate_fcurve(&quat_rna, quat_curve_fcu, anim_eval_context);
}
if (start_index != 0 || prop_index < 4) {
if (fcurve_offset < 4) {
/* This quaternion was incompletely keyed, so the result is a mixture of the unit quaterion and
* values from FCurves. This means that it's almost certainly no longer of unit length. */
normalize_qt(r_quaternion);
}
return fcurve_offset;
}
/* This function assumes that the quaternion is fully keyed, and is stored in array index order. */
static void animsys_blend_fcurves_quaternion(PathResolvedRNA *anim_rna,
FCurve *first_fcurve,
const AnimationEvalContext *anim_eval_context,
const float blend_factor)
/**
* This function assumes that the quaternion keys are sequential. They do not
* have to be in array_index order.
*
* \return the number of FCurves used to construct the quaternion, counting from
* `first_fcurve`. This is so that the caller knows how many FCurves can be
* skipped while iterating over them. */
static int animsys_blend_fcurves_quaternion(PathResolvedRNA *anim_rna,
FCurve *first_fcurve,
const AnimationEvalContext *anim_eval_context,
const float blend_factor)
{
float current_quat[4];
RNA_property_float_get_array(&anim_rna->ptr, anim_rna->prop, current_quat);
float target_quat[4];
animsys_quaternion_evaluate_fcurves(*anim_rna, first_fcurve, anim_eval_context, target_quat);
const int num_fcurves_read = animsys_quaternion_evaluate_fcurves(
*anim_rna, first_fcurve, anim_eval_context, target_quat);
float blended_quat[4];
interp_qt_qtqt(blended_quat, current_quat, target_quat, blend_factor);
RNA_property_float_set_array(&anim_rna->ptr, anim_rna->prop, blended_quat);
return num_fcurves_read;
}
/* LERP between current value (blend_factor=0.0) and the value from the FCurve (blend_factor=1.0)
@ -699,12 +708,13 @@ static void animsys_blend_in_fcurves(PointerRNA *ptr,
}
if (STREQ(RNA_property_identifier(anim_rna.prop), "rotation_quaternion")) {
animsys_blend_fcurves_quaternion(&anim_rna, fcu, anim_eval_context, blend_factor);
const int num_fcurves_read = animsys_blend_fcurves_quaternion(
&anim_rna, fcu, anim_eval_context, blend_factor);
/* Skip the next three channels, because those have already been handled here. */
MEM_SAFE_FREE(channel_to_skip);
channel_to_skip = BLI_strdup(fcu->rna_path);
num_channels_to_skip = 3;
num_channels_to_skip = num_fcurves_read - 1;
continue;
}
/* TODO(Sybren): do something similar as above for Euler and Axis/Angle representations. */

View File

@ -115,7 +115,7 @@ static char *blender_version_decimal(const int version)
{
static char version_str[5];
BLI_assert(version < 1000);
BLI_snprintf(version_str, sizeof(version_str), "%d.%d", version / 100, version % 100);
SNPRINTF(version_str, "%d.%d", version / 100, version % 100);
return version_str;
}
@ -480,7 +480,7 @@ static bool get_path_user_ex(char *targetpath,
const char *user_base_path = GHOST_getUserDir(version, blender_version_decimal(version));
if (user_base_path) {
BLI_strncpy(user_path, user_base_path, FILE_MAX);
STRNCPY(user_path, user_base_path);
}
}
@ -546,7 +546,7 @@ static bool get_path_system_ex(char *targetpath,
system_path[0] = '\0';
const char *system_base_path = GHOST_getSystemDir(version, blender_version_decimal(version));
if (system_base_path) {
BLI_strncpy(system_path, system_base_path, FILE_MAX);
STRNCPY(system_path, system_base_path);
}
}

View File

@ -708,7 +708,7 @@ bool bone_autoside_name(
if (len == 0) {
return false;
}
BLI_strncpy(basename, name, sizeof(basename));
STRNCPY(basename, name);
/* Figure out extension to append:
* - The extension to append is based upon the axis that we are working on.

View File

@ -52,7 +52,7 @@ AssetMetaData::~AssetMetaData()
static AssetTag *asset_metadata_tag_add(AssetMetaData *asset_data, const char *const name)
{
AssetTag *tag = (AssetTag *)MEM_callocN(sizeof(*tag), __func__);
BLI_strncpy(tag->name, name, sizeof(tag->name));
STRNCPY(tag->name, name);
BLI_addtail(&asset_data->tags, tag);
asset_data->tot_tags++;

View File

@ -217,7 +217,7 @@ bool BKE_id_attribute_rename(ID *id,
BKE_id_attributes_default_color_set(id, result_name);
}
BLI_strncpy_utf8(layer->name, result_name, sizeof(layer->name));
STRNCPY_UTF8(layer->name, result_name);
return true;
}

View File

@ -111,13 +111,12 @@ static void blender_version_init(void)
BLI_assert_msg(0, "Invalid Blender version cycle");
}
BLI_snprintf(blender_version_string,
ARRAY_SIZE(blender_version_string),
"%d.%01d.%d%s",
BLENDER_VERSION / 100,
BLENDER_VERSION % 100,
BLENDER_VERSION_PATCH,
version_cycle);
SNPRINTF(blender_version_string,
"%d.%01d.%d%s",
BLENDER_VERSION / 100,
BLENDER_VERSION % 100,
BLENDER_VERSION_PATCH,
version_cycle);
}
const char *BKE_blender_version_string(void)

View File

@ -57,7 +57,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
char mainstr[sizeof(bmain->filepath)];
int success = 0, fileflags;
BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */
STRNCPY(mainstr, BKE_main_blendfile_path(bmain)); /* temporal store */
fileflags = G.fileflags;
G.fileflags |= G_FILE_NO_UI;
@ -116,14 +116,14 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev)
counter++;
counter = counter % U.undosteps;
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
SNPRINTF(numstr, "%d.blend", counter);
BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_session(), numstr);
const BlendFileWriteParams blend_file_write_params{};
/* success = */ /* UNUSED */ BLO_write_file(
bmain, filepath, fileflags, &blend_file_write_params, nullptr);
BLI_strncpy(mfu->filepath, filepath, sizeof(mfu->filepath));
STRNCPY(mfu->filepath, filepath);
}
else {
MemFile *prevfile = (mfu_prev) ? &(mfu_prev->memfile) : nullptr;

View File

@ -1116,9 +1116,9 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *
ID *local_appended_new_id = NULL;
char lib_filepath[FILE_MAX];
BLI_strncpy(lib_filepath, id->lib->filepath, sizeof(lib_filepath));
STRNCPY(lib_filepath, id->lib->filepath);
char lib_id_name[MAX_ID_NAME];
BLI_strncpy(lib_id_name, id->name, sizeof(lib_id_name));
STRNCPY(lib_id_name, id->name);
switch (item->action) {
case LINK_APPEND_ACT_COPY_LOCAL:

View File

@ -1617,7 +1617,7 @@ BoidRule *boid_new_rule(int type)
rule->type = type;
rule->flag |= BOIDRULE_IN_AIR | BOIDRULE_ON_LAND;
BLI_strncpy(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name), sizeof(rule->name));
STRNCPY(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name));
return rule;
}
@ -1653,7 +1653,7 @@ BoidState *boid_new_state(BoidSettings *boids)
state->id = boids->last_state_id++;
if (state->id) {
BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id);
SNPRINTF(state->name, "State %i", state->id);
}
else {
strcpy(state->name, "State");

View File

@ -135,7 +135,7 @@ bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char
char path_dst[FILE_MAX];
if (absolute_base_path) {
BLI_strncpy(path_src_buf, path, sizeof(path_src_buf));
STRNCPY(path_src_buf, path);
BLI_path_abs(path_src_buf, absolute_base_path);
path_src = path_src_buf;
}
@ -144,7 +144,7 @@ bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char
}
/* so functions can check old value */
BLI_strncpy(path_dst, path, FILE_MAX);
STRNCPY(path_dst, path);
if (bpath_data->callback_function(bpath_data, path_dst, path_src)) {
BLI_strncpy(path, path_dst, FILE_MAX);
@ -167,7 +167,7 @@ bool BKE_bpath_foreach_path_dirfile_fixed_process(BPathForeachPathData *bpath_da
BLI_path_join(path_src, sizeof(path_src), path_dir, path_file);
/* So that functions can access the old value. */
BLI_strncpy(path_dst, path_src, FILE_MAX);
STRNCPY(path_dst, path_src);
if (absolute_base_path) {
BLI_path_abs(path_src, absolute_base_path);
@ -191,7 +191,7 @@ bool BKE_bpath_foreach_path_allocated_process(BPathForeachPathData *bpath_data,
char path_dst[FILE_MAX];
if (absolute_base_path) {
BLI_strncpy(path_src_buf, *path, sizeof(path_src_buf));
STRNCPY(path_src_buf, *path);
BLI_path_abs(path_src_buf, absolute_base_path);
path_src = path_src_buf;
}

View File

@ -82,7 +82,7 @@ TEST_F(BPathTest, rebase_on_relative)
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE);
BKE_bpath_relative_rebase(bmain, BASE_DIR, REBASE_DIR, nullptr);
@ -97,7 +97,7 @@ TEST_F(BPathTest, rebase_on_absolute)
text->filepath = BLI_strdup(TEXT_PATH_ABSOLUTE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
BKE_bpath_relative_rebase(bmain, BASE_DIR, REBASE_DIR, nullptr);
@ -111,7 +111,7 @@ TEST_F(BPathTest, convert_to_relative)
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
BKE_bpath_relative_convert(bmain, BASE_DIR, nullptr);
@ -127,7 +127,7 @@ TEST_F(BPathTest, convert_to_absolute)
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
BKE_bpath_absolute_convert(bmain, BASE_DIR, nullptr);
@ -143,7 +143,7 @@ TEST_F(BPathTest, list_backup_restore)
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
void *path_list_handle = BKE_bpath_list_backup(bmain, static_cast<eBPathForeachFlag>(0));
@ -152,7 +152,7 @@ TEST_F(BPathTest, list_backup_restore)
MEM_freeN(text->filepath);
text->filepath = BLI_strdup(TEXT_PATH_ABSOLUTE);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE);
BKE_bpath_list_restore(bmain, static_cast<eBPathForeachFlag>(0), path_list_handle);

View File

@ -58,7 +58,7 @@ static void cache_file_init_data(ID *id)
cache_file->scale = 1.0f;
cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND;
BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name));
STRNCPY(cache_file->velocity_name, ".velocities");
}
static void cache_file_copy_data(Main *UNUSED(bmain),
@ -362,7 +362,7 @@ void BKE_cachefile_eval(Main *bmain, Depsgraph *depsgraph, CacheFile *cache_file
cache_file->type = CACHEFILE_TYPE_ALEMBIC;
cache_file->handle = ABC_create_handle(
bmain, filepath, cache_file->layers.first, &cache_file->object_paths);
BLI_strncpy(cache_file->handle_filepath, filepath, FILE_MAX);
STRNCPY(cache_file->handle_filepath, filepath);
}
#endif
#ifdef WITH_USD
@ -441,7 +441,7 @@ CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filepa
const int num_layers = BLI_listbase_count(&cache_file->layers);
CacheFileLayer *layer = MEM_callocN(sizeof(CacheFileLayer), "CacheFileLayer");
BLI_strncpy(layer->filepath, filepath, sizeof(layer->filepath));
STRNCPY(layer->filepath, filepath);
BLI_addtail(&cache_file->layers, layer);

View File

@ -1034,7 +1034,7 @@ static Object *camera_multiview_advanced(const Scene *scene, Object *camera, con
}
if (STREQ(camera_name + (len_name - len_suffix), srv->suffix)) {
BLI_snprintf(name, sizeof(name), "%.*s%s", (len_name - len_suffix), camera_name, suffix);
SNPRINTF(name, "%.*s%s", (len_name - len_suffix), camera_name, suffix);
len_suffix_max = len_suffix;
}
}

View File

@ -1790,15 +1790,13 @@ void BKE_color_managed_display_settings_init(ColorManagedDisplaySettings *settin
{
const char *display_name = IMB_colormanagement_display_get_default_name();
BLI_strncpy(settings->display_device, display_name, sizeof(settings->display_device));
STRNCPY(settings->display_device, display_name);
}
void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_settings,
const ColorManagedDisplaySettings *settings)
{
BLI_strncpy(new_settings->display_device,
settings->display_device,
sizeof(new_settings->display_device));
STRNCPY(new_settings->display_device, settings->display_device);
}
void BKE_color_managed_view_settings_init_render(
@ -1836,10 +1834,8 @@ void BKE_color_managed_view_settings_init_default(
void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings,
const ColorManagedViewSettings *settings)
{
BLI_strncpy(new_settings->look, settings->look, sizeof(new_settings->look));
BLI_strncpy(new_settings->view_transform,
settings->view_transform,
sizeof(new_settings->view_transform));
STRNCPY(new_settings->look, settings->look);
STRNCPY(new_settings->view_transform, settings->view_transform);
new_settings->flag = settings->flag;
new_settings->exposure = settings->exposure;
@ -1882,14 +1878,14 @@ void BKE_color_managed_view_settings_blend_read_data(BlendDataReader *reader,
void BKE_color_managed_colorspace_settings_init(
ColorManagedColorspaceSettings *colorspace_settings)
{
BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name));
STRNCPY(colorspace_settings->name, "");
}
void BKE_color_managed_colorspace_settings_copy(
ColorManagedColorspaceSettings *colorspace_settings,
const ColorManagedColorspaceSettings *settings)
{
BLI_strncpy(colorspace_settings->name, settings->name, sizeof(colorspace_settings->name));
STRNCPY(colorspace_settings->name, settings->name);
}
bool BKE_color_managed_colorspace_settings_equals(const ColorManagedColorspaceSettings *settings1,

View File

@ -859,7 +859,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
\
ct->tar = datatar; \
BLI_strncpy(ct->subtarget, datasubtarget, sizeof(ct->subtarget)); \
STRNCPY(ct->subtarget, datasubtarget); \
ct->space = con->tarspace; \
ct->flag = CONSTRAINT_TAR_TEMP; \
\
@ -916,7 +916,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
bConstraintTarget *ctn = ct->next; \
if (no_copy == 0) { \
datatar = ct->tar; \
BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \
STRNCPY(datasubtarget, ct->subtarget); \
con->tarspace = (char)ct->space; \
} \
\
@ -5403,7 +5403,7 @@ static void transformcache_copy(bConstraint *con, bConstraint *srccon)
bTransformCacheConstraint *src = srccon->data;
bTransformCacheConstraint *dst = con->data;
BLI_strncpy(dst->object_path, src->object_path, sizeof(dst->object_path));
STRNCPY(dst->object_path, src->object_path);
dst->cache_file = src->cache_file;
dst->reader = NULL;
dst->reader_object_path[0] = '\0';
@ -5779,7 +5779,7 @@ static bConstraint *add_new_constraint_internal(const char *name, short type)
}
/* copy the name */
BLI_strncpy(con->name, newName, sizeof(con->name));
STRNCPY(con->name, newName);
/* return the new constraint */
return con;
@ -6201,7 +6201,7 @@ void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targ
if (!no_copy) {
con->space_object = ct->tar;
BLI_strncpy(con->space_subtarget, ct->subtarget, sizeof(con->space_subtarget));
STRNCPY(con->space_subtarget, ct->subtarget);
}
BLI_freelinkN(targets, ct);

View File

@ -146,7 +146,7 @@ TEST(cryptomatte, session_from_stamp_data)
/* Create StampData from CryptomatteSession. */
ViewLayer view_layer;
BLI_strncpy(view_layer.name, "viewlayername", sizeof(view_layer.name));
STRNCPY(view_layer.name, "viewlayername");
RenderResult *render_result2 = static_cast<RenderResult *>(
MEM_callocN(sizeof(RenderResult), __func__));
BKE_cryptomatte_store_metadata(session.get(), render_result2, &view_layer);

View File

@ -2955,7 +2955,7 @@ static CustomDataLayer *customData_add_layer__internal(
}
if (name) {
BLI_strncpy(new_layer.name, name, sizeof(new_layer.name));
STRNCPY(new_layer.name, name);
CustomData_set_layer_unique_name(data, index);
}
else {
@ -3669,7 +3669,7 @@ bool CustomData_set_layer_name(CustomData *data,
return false;
}
BLI_strncpy(data->layers[layer_index].name, name, sizeof(data->layers[layer_index].name));
STRNCPY(data->layers[layer_index].name, name);
return true;
}
@ -4781,7 +4781,7 @@ void CustomData_external_add(CustomData *data,
external = MEM_cnew<CustomDataExternal>(__func__);
data->external = external;
}
BLI_strncpy(external->filepath, filepath, sizeof(external->filepath));
STRNCPY(external->filepath, filepath);
layer->flag |= CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY;
}

View File

@ -444,7 +444,7 @@ CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t
layer->datatype = CDF_DATA_FLOAT;
layer->datasize = datasize;
layer->type = type;
BLI_strncpy(layer->name, name, CDF_LAYER_NAME_MAX);
STRNCPY(layer->name, name);
return layer;
}

View File

@ -48,7 +48,7 @@ bDeformGroup *BKE_object_defgroup_new(Object *ob, const char *name)
defgroup = MEM_cnew<bDeformGroup>(__func__);
BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
STRNCPY(defgroup->name, name);
ListBase *defbase = BKE_object_defgroup_list_mutable(ob);

View File

@ -761,7 +761,7 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph,
BKE_mesh_ensure_normals_for_display(final_mesh);
BLI_strncpy(final_mesh->id.name, cu->id.name, sizeof(final_mesh->id.name));
STRNCPY(final_mesh->id.name, cu->id.name);
*((short *)final_mesh->id.name) = ID_ME;
}

View File

@ -295,7 +295,7 @@ static Mesh *dynamicPaint_brush_mesh_get(DynamicPaintBrushSettings *brush)
static bool setError(DynamicPaintCanvasSettings *canvas, const char *string)
{
/* Add error to canvas ui info label */
BLI_strncpy(canvas->error, string, sizeof(canvas->error));
STRNCPY(canvas->error, string);
CLOG_STR_ERROR(&LOG, string);
return false;
}
@ -369,7 +369,7 @@ static bool surface_duplicateOutputExists(void *arg, const char *name)
static void surface_setUniqueOutputName(DynamicPaintSurface *surface, char *basename, int output)
{
char name[64];
BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */
STRNCPY(name, basename); /* in case basename is surface->name use a copy */
if (output == 0) {
BLI_uniquename_cb(surface_duplicateOutputExists,
surface,
@ -405,7 +405,7 @@ static bool surface_duplicateNameExists(void *arg, const char *name)
void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, const char *basename)
{
char name[64];
BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */
STRNCPY(name, basename); /* in case basename is surface->name use a copy */
BLI_uniquename_cb(
surface_duplicateNameExists, surface, name, '.', surface->name, sizeof(surface->name));
}
@ -420,7 +420,7 @@ void dynamicPaintSurface_updateType(DynamicPaintSurface *surface)
}
else {
strcpy(surface->output_name, "dp_");
BLI_strncpy(surface->output_name2, surface->output_name, sizeof(surface->output_name2));
STRNCPY(surface->output_name2, surface->output_name);
surface->flags &= ~MOD_DPAINT_ANTIALIAS;
surface->depth_clamp = 0.0f;
}
@ -1233,7 +1233,7 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd,
t_surface->effector_weights = static_cast<EffectorWeights *>(
MEM_dupallocN(surface->effector_weights));
BLI_strncpy(t_surface->name, surface->name, sizeof(t_surface->name));
STRNCPY(t_surface->name, surface->name);
t_surface->format = surface->format;
t_surface->type = surface->type;
t_surface->disp_type = surface->disp_type;
@ -1250,8 +1250,7 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd,
copy_v4_v4(t_surface->init_color, surface->init_color);
t_surface->init_texture = surface->init_texture;
BLI_strncpy(
t_surface->init_layername, surface->init_layername, sizeof(t_surface->init_layername));
STRNCPY(t_surface->init_layername, surface->init_layername);
t_surface->dry_speed = surface->dry_speed;
t_surface->diss_speed = surface->diss_speed;
@ -1274,12 +1273,10 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd,
t_surface->wave_spring = surface->wave_spring;
t_surface->wave_smoothness = surface->wave_smoothness;
BLI_strncpy(t_surface->uvlayer_name, surface->uvlayer_name, sizeof(t_surface->uvlayer_name));
BLI_strncpy(t_surface->image_output_path,
surface->image_output_path,
sizeof(t_surface->image_output_path));
BLI_strncpy(t_surface->output_name, surface->output_name, sizeof(t_surface->output_name));
BLI_strncpy(t_surface->output_name2, surface->output_name2, sizeof(t_surface->output_name2));
STRNCPY(t_surface->uvlayer_name, surface->uvlayer_name);
STRNCPY(t_surface->image_output_path, surface->image_output_path);
STRNCPY(t_surface->output_name, surface->output_name);
STRNCPY(t_surface->output_name2, surface->output_name2);
}
}
if (tpmd->brush) {
@ -3314,7 +3311,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
format = R_IMF_IMTYPE_PNG;
}
#endif
BLI_strncpy(output_file, filepath, sizeof(output_file));
STRNCPY(output_file, filepath);
BKE_image_path_ext_from_imtype_ensure(output_file, sizeof(output_file), format);
/* Validate output file path */

View File

@ -1351,7 +1351,7 @@ void BKE_sim_debug_data_add_element(int type,
zero_v3(elem->v2);
}
if (str) {
BLI_strncpy(elem->str, str, sizeof(elem->str));
STRNCPY(elem->str, str);
}
else {
elem->str[0] = '\0';

View File

@ -161,7 +161,7 @@ void BKE_fcurves_copy(ListBase *dst, ListBase *src)
void BKE_fmodifier_name_set(FModifier *fcm, const char *name)
{
/* Copy new Modifier name. */
BLI_strncpy(fcm->name, name, sizeof(fcm->name));
STRNCPY(fcm->name, name);
/* Set default modifier name when name parameter is an empty string.
* Ensure the name is unique. */
@ -1305,7 +1305,7 @@ void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
if (a == 1) {
next = cycle_offset_triple(cycle, &tmp, &fcu->bezt[1], first, last);
}
else {
else if (next != NULL) {
next++;
}

View File

@ -4455,12 +4455,12 @@ void BKE_fluid_particle_system_create(Main *bmain,
part->phystype = PART_PHYS_NO; /* No physics needed, part system only used to display data. */
psys->part = part;
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
BLI_strncpy(psys->name, parts_name, sizeof(psys->name));
STRNCPY(psys->name, parts_name);
BLI_addtail(&ob->particlesystem, psys);
/* add modifier */
pfmd = (ParticleSystemModifierData *)BKE_modifier_new(eModifierType_ParticleSystem);
BLI_strncpy(pfmd->modifier.name, psys_name, sizeof(pfmd->modifier.name));
STRNCPY(pfmd->modifier.name, psys_name);
pfmd->psys = psys;
BLI_addtail(&ob->modifiers, pfmd);
BKE_modifier_unique_name(&ob->modifiers, (ModifierData *)pfmd);
@ -4968,7 +4968,7 @@ void BKE_fluid_modifier_copy(const FluidModifierData *fmd, FluidModifierData *tf
tfds->cache_data_format = fds->cache_data_format;
tfds->cache_particle_format = fds->cache_particle_format;
tfds->cache_noise_format = fds->cache_noise_format;
BLI_strncpy(tfds->cache_directory, fds->cache_directory, sizeof(tfds->cache_directory));
STRNCPY(tfds->cache_directory, fds->cache_directory);
/* time options */
tfds->time_scale = fds->time_scale;
@ -5056,7 +5056,7 @@ void BKE_fluid_modifier_copy(const FluidModifierData *fmd, FluidModifierData *tf
/* texture control */
tffs->texture_size = ffs->texture_size;
tffs->texture_offset = ffs->texture_offset;
BLI_strncpy(tffs->uvlayer_name, ffs->uvlayer_name, sizeof(tffs->uvlayer_name));
STRNCPY(tffs->uvlayer_name, ffs->uvlayer_name);
tffs->vgroup_density = ffs->vgroup_density;
tffs->type = ffs->type;

View File

@ -180,10 +180,10 @@ FreestyleLineSet *BKE_freestyle_lineset_add(struct Main *bmain,
lineset->exclude_edge_types = 0;
lineset->group = NULL;
if (name) {
BLI_strncpy(lineset->name, name, sizeof(lineset->name));
STRNCPY(lineset->name, name);
}
else if (lineset_index > 0) {
BLI_snprintf(lineset->name, sizeof(lineset->name), "LineSet %i", lineset_index + 1);
SNPRINTF(lineset->name, "LineSet %i", lineset_index + 1);
}
else {
strcpy(lineset->name, "LineSet");

View File

@ -675,7 +675,7 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd,
}
/* auto-name */
BLI_strncpy(gpl->info, DATA_(name), sizeof(gpl->info));
STRNCPY(gpl->info, DATA_(name));
BLI_uniquename(&gpd->layers,
gpl,
(gpd->flag & GP_DATA_ANNOTATIONS) ? DATA_("Note") : DATA_("GP_Layer"),
@ -1018,9 +1018,9 @@ void BKE_gpencil_layer_copy_settings(const bGPDlayer *gpl_src, bGPDlayer *gpl_ds
gpl_dst->pass_index = gpl_src->pass_index;
gpl_dst->parent = gpl_src->parent;
copy_m4_m4(gpl_dst->inverse, gpl_src->inverse);
BLI_strncpy(gpl_dst->parsubstr, gpl_src->parsubstr, 64);
STRNCPY(gpl_dst->parsubstr, gpl_src->parsubstr);
gpl_dst->partype = gpl_src->partype;
BLI_strncpy(gpl_dst->viewlayername, gpl_src->viewlayername, 64);
STRNCPY(gpl_dst->viewlayername, gpl_src->viewlayername);
copy_v3_v3(gpl_dst->location, gpl_src->location);
copy_v3_v3(gpl_dst->rotation, gpl_src->rotation);
copy_v3_v3(gpl_dst->scale, gpl_src->scale);
@ -1436,7 +1436,7 @@ bGPDlayer_Mask *BKE_gpencil_layer_mask_add(bGPDlayer *gpl, const char *name)
bGPDlayer_Mask *mask = MEM_callocN(sizeof(bGPDlayer_Mask), "bGPDlayer_Mask");
BLI_addtail(&gpl->mask_layers, mask);
BLI_strncpy(mask->name, name, sizeof(mask->name));
STRNCPY(mask->name, name);
gpl->act_mask++;
return mask;

View File

@ -356,7 +356,7 @@ GpencilModifierData *BKE_gpencil_modifier_new(int type)
GpencilModifierData *md = MEM_callocN(mti->struct_size, mti->struct_name);
/* NOTE: this name must be made unique later. */
BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
STRNCPY(md->name, DATA_(mti->name));
md->type = type;
md->mode = eGpencilModifierMode_Realtime | eGpencilModifierMode_Render;

View File

@ -65,7 +65,7 @@ IDProperty *IDP_NewIDPArray(const char *name)
IDProperty *prop = MEM_callocN(sizeof(IDProperty), "IDProperty prop array");
prop->type = IDP_IDPARRAY;
prop->len = 0;
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
STRNCPY(prop->name, name);
return prop;
}
@ -300,7 +300,7 @@ static IDProperty *idp_generic_copy(const IDProperty *prop, const int UNUSED(fla
{
IDProperty *newp = MEM_callocN(sizeof(IDProperty), __func__);
BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
STRNCPY(newp->name, prop->name);
newp->type = prop->type;
newp->flag = prop->flag;
newp->data.val = prop->data.val;
@ -369,7 +369,7 @@ IDProperty *IDP_NewStringMaxSize(const char *st, const char *name, int maxncpy)
}
prop->type = IDP_STRING;
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
STRNCPY(prop->name, name);
return prop;
}
@ -1005,7 +1005,7 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char *
}
prop->type = type;
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
STRNCPY(prop->name, name);
return prop;
}

View File

@ -67,7 +67,7 @@ static void idp_str_append_escape(struct ReprState *state,
state->str_append_fn(state->user_data, str + i_prev, i - i_prev);
}
char buf[5];
uint len = (uint)BLI_snprintf_rlen(buf, sizeof(buf), "\\x%02x", c);
uint len = (uint)SNPRINTF_RLEN(buf, "\\x%02x", c);
BLI_assert(len == 4);
state->str_append_fn(state->user_data, buf, len);
i_prev = i + 1;
@ -90,9 +90,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro
#define STR_APPEND_FMT(format, ...) \
state->str_append_fn( \
state->user_data, \
state->buf, \
(uint)BLI_snprintf_rlen(state->buf, sizeof(state->buf), format, __VA_ARGS__))
state->user_data, state->buf, (uint)SNPRINTF_RLEN(state->buf, format, __VA_ARGS__))
switch (prop->type) {
case IDP_STRING: {

View File

@ -290,7 +290,7 @@ static void image_foreach_path(ID *id, BPathForeachPathData *bpath_data)
bool result = false;
if (ima->source == IMA_SRC_TILED && (flag & BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN) != 0) {
char temp_path[FILE_MAX], orig_file[FILE_MAXFILE];
BLI_strncpy(temp_path, ima->filepath, sizeof(temp_path));
STRNCPY(temp_path, ima->filepath);
BLI_path_split_file_part(temp_path, orig_file, sizeof(orig_file));
eUDIM_TILE_FORMAT tile_format;
@ -3195,7 +3195,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
int new_start, new_range;
char filepath[FILE_MAX];
BLI_strncpy(filepath, ima->filepath, sizeof(filepath));
STRNCPY(filepath, ima->filepath);
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
bool result = BKE_image_get_tile_info(filepath, &new_tiles, &new_start, &new_range);
if (result) {
@ -3407,7 +3407,7 @@ ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *la
}
if (label) {
BLI_strncpy(tile->label, label, sizeof(tile->label));
STRNCPY(tile->label, label);
}
for (int eye = 0; eye < 2; eye++) {
@ -5561,11 +5561,11 @@ RenderSlot *BKE_image_add_renderslot(Image *ima, const char *name)
{
RenderSlot *slot = MEM_cnew<RenderSlot>("Image new Render Slot");
if (name && name[0]) {
BLI_strncpy(slot->name, name, sizeof(slot->name));
STRNCPY(slot->name, name);
}
else {
int n = BLI_listbase_count(&ima->renderslots) + 1;
BLI_snprintf(slot->name, sizeof(slot->name), DATA_("Slot %d"), n);
SNPRINTF(slot->name, DATA_("Slot %d"), n);
}
BLI_addtail(&ima->renderslots, slot);
return slot;

View File

@ -167,7 +167,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
const bool is_prev_save = !STREQ(G.ima, "//");
if (opts->save_as_render) {
if (is_prev_save) {
BLI_strncpy(opts->filepath, G.ima, sizeof(opts->filepath));
STRNCPY(opts->filepath, G.ima);
}
else {
BLI_path_join(opts->filepath, sizeof(opts->filepath), "//", DATA_("untitled"));
@ -252,7 +252,7 @@ static void image_save_update_filepath(Image *ima,
const ImageSaveOptions *opts)
{
if (opts->do_newpath) {
BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath));
STRNCPY(ima->filepath, filepath);
/* only image path, never ibuf */
if (opts->relative) {
@ -281,7 +281,7 @@ static void image_save_post(ReportList *reports,
}
if (opts->do_newpath) {
BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath));
STRNCPY(ibuf->filepath, filepath);
}
/* The tiled image code-path must call this on its own. */
@ -776,7 +776,7 @@ bool BKE_image_render_write_exr(ReportList *reports,
if (multi_layer) {
RE_render_result_full_channel_name(passname, nullptr, "Combined", nullptr, chan_id, a);
BLI_strncpy(layname, "Composite", sizeof(layname));
STRNCPY(layname, "Composite");
}
else {
passname[0] = chan_id[a];
@ -842,7 +842,7 @@ bool BKE_image_render_write_exr(ReportList *reports,
if (multi_layer) {
RE_render_result_full_channel_name(passname, nullptr, rp->name, nullptr, rp->chan_id, a);
BLI_strncpy(layname, rl->name, sizeof(layname));
STRNCPY(layname, rl->name);
}
else {
passname[0] = rp->chan_id[a];

View File

@ -17,7 +17,7 @@ TEST(udim, image_ensure_tile_token)
auto verify = [](const char *original, const char *expected) {
char result[FILE_MAX];
BLI_strncpy(result, original, sizeof(result));
STRNCPY(result, original);
BKE_image_ensure_tile_token_filename_only(result, sizeof(result));
EXPECT_STREQ(result, expected);
};
@ -172,7 +172,7 @@ TEST(udim, image_set_filepath_from_tile_number)
char filepath[FILE_MAX];
/* Parameter validation. */
BLI_strncpy(filepath, "xxxx", FILE_MAX);
STRNCPY(filepath, "xxxx");
BKE_image_set_filepath_from_tile_number(nullptr, udim_pattern, tile_format, 1028);
BKE_image_set_filepath_from_tile_number(filepath, nullptr, tile_format, 1028);

View File

@ -445,7 +445,7 @@ static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int *UNUSED(array_i
/* block will be attached to ID_KE block... */
if (adrcode == 0) {
/* adrcode=0 was the misnamed "speed" curve (now "evaluation time") */
BLI_strncpy(buf, "eval_time", sizeof(buf));
STRNCPY(buf, "eval_time");
}
else {
/* Find the name of the ShapeKey (i.e. KeyBlock) to look for */
@ -457,11 +457,11 @@ static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int *UNUSED(array_i
/* Use the keyblock name, escaped, so that path lookups for this will work */
char kb_name_esc[sizeof(kb->name) * 2];
BLI_str_escape(kb_name_esc, kb->name, sizeof(kb_name_esc));
BLI_snprintf(buf, sizeof(buf), "key_blocks[\"%s\"].value", kb_name_esc);
SNPRINTF(buf, "key_blocks[\"%s\"].value", kb_name_esc);
}
else {
/* Fallback - Use the adrcode as index directly, so that this can be manually fixed */
BLI_snprintf(buf, sizeof(buf), "key_blocks[%d].value", adrcode);
SNPRINTF(buf, "key_blocks[%d].value", adrcode);
}
}
return buf;
@ -580,7 +580,7 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
/* only build and return path if there's a property */
if (prop) {
BLI_snprintf(buf, 128, "%s.%s", base, prop);
SNPRINTF(buf, "%s.%s", base, prop);
return buf;
}
@ -1154,8 +1154,7 @@ static char *get_rna_access(ID *id,
char constname_esc[sizeof(((bConstraint *)NULL)->name) * 2];
BLI_str_escape(actname_esc, actname, sizeof(actname_esc));
BLI_str_escape(constname_esc, constname, sizeof(constname_esc));
BLI_snprintf(
buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname_esc, constname_esc);
SNPRINTF(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname_esc, constname_esc);
}
else if (actname && actname[0]) {
if ((blocktype == ID_OB) && STREQ(actname, "Object")) {
@ -1171,20 +1170,20 @@ static char *get_rna_access(ID *id,
/* Pose-Channel */
char actname_esc[sizeof(((bActionChannel *)NULL)->name) * 2];
BLI_str_escape(actname_esc, actname, sizeof(actname_esc));
BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"]", actname_esc);
SNPRINTF(buf, "pose.bones[\"%s\"]", actname_esc);
}
}
else if (constname && constname[0]) {
/* Constraint in Object */
char constname_esc[sizeof(((bConstraint *)NULL)->name) * 2];
BLI_str_escape(constname_esc, constname, sizeof(constname_esc));
BLI_snprintf(buf, sizeof(buf), "constraints[\"%s\"]", constname_esc);
SNPRINTF(buf, "constraints[\"%s\"]", constname_esc);
}
else if (seq) {
/* Sequence names in Scene */
char seq_name_esc[(sizeof(seq->name) - 2) * 2];
BLI_str_escape(seq_name_esc, seq->name + 2, sizeof(seq_name_esc));
BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq_name_esc);
SNPRINTF(buf, "sequence_editor.sequences_all[\"%s\"]", seq_name_esc);
}
else {
buf[0] = '\0'; /* empty string */
@ -1202,7 +1201,7 @@ static char *get_rna_access(ID *id,
/* if there was no array index pointer provided, add it to the path */
if (array_index == NULL) {
BLI_snprintf(buf, sizeof(buf), "[\"%d\"]", dummy_index);
SNPRINTF(buf, "[\"%d\"]", dummy_index);
BLI_dynstr_append(path, buf);
}
@ -1261,7 +1260,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
/* FIXME: expression will be useless due to API changes, but at least not totally lost */
cdriver->type = DRIVER_TYPE_PYTHON;
if (idriver->name[0]) {
BLI_strncpy(cdriver->expression, idriver->name, sizeof(cdriver->expression));
STRNCPY(cdriver->expression, idriver->name);
}
}
else {
@ -1283,7 +1282,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
if (idriver->name[0]) {
BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
STRNCPY(dtar->pchan_name, idriver->name);
}
/* second bone target (name was stored in same var as the first one) */
@ -1291,8 +1290,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
if (idriver->name[0]) { /* XXX: for safety. */
BLI_strncpy(
dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS, sizeof(dtar->pchan_name));
STRNCPY(dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS);
}
}
else {
@ -1305,7 +1303,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
if (idriver->name[0]) {
BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
STRNCPY(dtar->pchan_name, idriver->name);
}
dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode);
dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */
@ -1362,7 +1360,7 @@ static void fcurve_add_to_list(
agrp->flag |= AGRP_MUTED;
}
BLI_strncpy(agrp->name, grpname, sizeof(agrp->name));
STRNCPY(agrp->name, grpname);
BLI_addtail(&tmp_act.groups, agrp);
BLI_uniquename(&tmp_act.groups,
@ -1876,7 +1874,7 @@ static void ipo_to_animdata(
if (adt->action == NULL) {
char nameBuf[MAX_ID_NAME];
BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2);
SNPRINTF(nameBuf, "CDA:%s", ipo->id.name + 2);
adt->action = BKE_action_add(bmain, nameBuf);
if (G.debug & G_DEBUG) {

View File

@ -1841,14 +1841,14 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name)
tot = BLI_listbase_count(&key->block);
if (name) {
BLI_strncpy(kb->name, name, sizeof(kb->name));
STRNCPY(kb->name, name);
}
else {
if (tot == 1) {
BLI_strncpy(kb->name, DATA_("Basis"), sizeof(kb->name));
STRNCPY(kb->name, DATA_("Basis"));
}
else {
BLI_snprintf(kb->name, sizeof(kb->name), DATA_("Key %d"), tot - 1);
SNPRINTF(kb->name, DATA_("Key %d"), tot - 1);
}
}
@ -1961,7 +1961,7 @@ void BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src)
kb_dst->curval = kb_src->curval;
kb_dst->type = kb_src->type;
kb_dst->relative = kb_src->relative;
BLI_strncpy(kb_dst->vgroup, kb_src->vgroup, sizeof(kb_dst->vgroup));
STRNCPY(kb_dst->vgroup, kb_src->vgroup);
kb_dst->slidermin = kb_src->slidermin;
kb_dst->slidermax = kb_src->slidermax;
}

View File

@ -161,7 +161,7 @@ static ViewLayer *view_layer_add(const char *name)
ViewLayer *view_layer = MEM_cnew<ViewLayer>("View Layer");
view_layer->flag = VIEW_LAYER_RENDER | VIEW_LAYER_FREESTYLE;
BLI_strncpy_utf8(view_layer->name, name, sizeof(view_layer->name));
STRNCPY_UTF8(view_layer->name, name);
/* Pure rendering pipeline settings. */
view_layer->layflag = SCE_LAY_FLAG_DEFAULT;
@ -210,7 +210,7 @@ ViewLayer *BKE_view_layer_add(Scene *scene,
BKE_view_layer_copy_data(scene, scene, view_layer_new, view_layer_source, 0);
BLI_addtail(&scene->view_layers, view_layer_new);
BLI_strncpy_utf8(view_layer_new->name, name, sizeof(view_layer_new->name));
STRNCPY_UTF8(view_layer_new->name, name);
break;
}
case VIEWLAYER_ADD_EMPTY: {
@ -553,9 +553,9 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
{
char oldname[sizeof(view_layer->name)];
BLI_strncpy(oldname, view_layer->name, sizeof(view_layer->name));
STRNCPY(oldname, view_layer->name);
BLI_strncpy_utf8(view_layer->name, newname, sizeof(view_layer->name));
STRNCPY_UTF8(view_layer->name, newname);
BLI_uniquename(&scene->view_layers,
view_layer,
DATA_("ViewLayer"),
@ -570,7 +570,7 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
for (node = static_cast<bNode *>(scene->nodetree->nodes.first); node; node = node->next) {
if (node->type == CMP_NODE_R_LAYERS && node->id == nullptr) {
if (node->custom1 == index) {
BLI_strncpy(node->name, view_layer->name, NODE_MAXSTR);
STRNCPY(node->name, view_layer->name);
}
}
}
@ -2522,7 +2522,7 @@ ViewLayerAOV *BKE_view_layer_add_aov(ViewLayer *view_layer)
ViewLayerAOV *aov;
aov = MEM_cnew<ViewLayerAOV>(__func__);
aov->type = AOV_TYPE_COLOR;
BLI_strncpy(aov->name, DATA_("AOV"), sizeof(aov->name));
STRNCPY(aov->name, DATA_("AOV"));
BLI_addtail(&view_layer->aovs, aov);
viewlayer_aov_active_set(view_layer, aov);
viewlayer_aov_make_name_unique(view_layer);
@ -2643,10 +2643,10 @@ ViewLayerLightgroup *BKE_view_layer_add_lightgroup(ViewLayer *view_layer, const
ViewLayerLightgroup *lightgroup;
lightgroup = MEM_cnew<ViewLayerLightgroup>(__func__);
if (name && name[0]) {
BLI_strncpy(lightgroup->name, name, sizeof(lightgroup->name));
STRNCPY(lightgroup->name, name);
}
else {
BLI_strncpy(lightgroup->name, DATA_("Lightgroup"), sizeof(lightgroup->name));
STRNCPY(lightgroup->name, DATA_("Lightgroup"));
}
BLI_addtail(&view_layer->lightgroups, lightgroup);
viewlayer_lightgroup_active_set(view_layer, lightgroup);
@ -2690,8 +2690,8 @@ void BKE_view_layer_rename_lightgroup(Scene *scene,
const char *name)
{
char old_name[64];
BLI_strncpy_utf8(old_name, lightgroup->name, sizeof(old_name));
BLI_strncpy_utf8(lightgroup->name, name, sizeof(lightgroup->name));
STRNCPY_UTF8(old_name, lightgroup->name);
STRNCPY_UTF8(lightgroup->name, name);
viewlayer_lightgroup_make_name_unique(view_layer, lightgroup);
if (scene != nullptr) {
@ -2700,7 +2700,7 @@ void BKE_view_layer_rename_lightgroup(Scene *scene,
if (!ID_IS_LINKED(ob) && ob->lightgroup != nullptr) {
LightgroupMembership *lgm = ob->lightgroup;
if (STREQ(lgm->name, old_name)) {
BLI_strncpy_utf8(lgm->name, lightgroup->name, sizeof(lgm->name));
STRNCPY_UTF8(lgm->name, lightgroup->name);
}
}
}
@ -2711,7 +2711,7 @@ void BKE_view_layer_rename_lightgroup(Scene *scene,
scene->world->lightgroup != nullptr) {
LightgroupMembership *lgm = scene->world->lightgroup;
if (STREQ(lgm->name, old_name)) {
BLI_strncpy_utf8(lgm->name, lightgroup->name, sizeof(lgm->name));
STRNCPY_UTF8(lgm->name, lightgroup->name);
}
}
}

View File

@ -60,7 +60,7 @@ TEST(view_layer, aov_unique_names)
EXPECT_TRUE(STREQ(aov2->name, "AOV_001"));
/* Revert previous resolution */
BLI_strncpy(aov2->name, "AOV", MAX_NAME);
STRNCPY(aov2->name, "AOV");
BKE_view_layer_verify_aov(engine, &scene, view_layer);
EXPECT_TRUE(BKE_view_layer_has_valid_aov(view_layer));
EXPECT_FALSE((aov1->flag & AOV_CONFLICT) != 0);
@ -97,7 +97,7 @@ static void test_render_pass_conflict(Scene *scene,
RNA_boolean_set(&ptr, rna_prop_name, false);
/* Rename to Conflicting name */
BLI_strncpy(aov->name, render_pass_name, MAX_NAME);
STRNCPY(aov->name, render_pass_name);
BKE_view_layer_verify_aov(engine, scene, view_layer);
EXPECT_TRUE(BKE_view_layer_has_valid_aov(view_layer));
EXPECT_FALSE((aov->flag & AOV_CONFLICT) != 0);

View File

@ -1361,7 +1361,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
if ((flag & LIB_ID_CREATE_NO_ALLOCATE) != 0) {
/* r_newid already contains pointer to allocated memory. */
/* TODO: do we want to memset(0) whole mem before filling it? */
BLI_strncpy(new_id->name, id->name, sizeof(new_id->name));
STRNCPY(new_id->name, id->name);
new_id->us = 0;
new_id->tag |= LIB_TAG_NOT_ALLOCATED | LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT;
/* TODO: Do we want/need to copy more from ID struct itself? */
@ -1597,11 +1597,11 @@ bool BKE_id_new_name_validate(
tname = id->name + 2;
}
/* Make a copy of given name (tname args can be const). */
BLI_strncpy(name, tname, sizeof(name));
STRNCPY(name, tname);
if (name[0] == '\0') {
/* Disallow empty names. */
BLI_strncpy(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name))), sizeof(name));
STRNCPY(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name))));
}
else {
/* disallow non utf8 chars,

View File

@ -199,7 +199,9 @@ void BKE_id_free_us(Main *bmain, void *idv) /* test users */
}
}
static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
static size_t id_delete(Main *bmain,
const bool do_tagged_deletion,
const int extra_remapping_flags)
{
const int tag = LIB_TAG_DOIT;
ListBase *lbarray[INDEX_ID_MAX];
@ -211,6 +213,8 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
const int free_flag = LIB_ID_FREE_NO_UI_USER |
(do_tagged_deletion ? LIB_ID_FREE_NO_MAIN | LIB_ID_FREE_NO_USER_REFCOUNT :
0);
const int remapping_flags = (ID_REMAP_FLAG_NEVER_NULL_USAGE | ID_REMAP_FORCE_NEVER_NULL_USAGE |
ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS | extra_remapping_flags);
ListBase tagged_deleted_ids = {NULL};
base_count = set_listbasepointers(bmain, lbarray);
@ -261,11 +265,7 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
* links, this can lead to nasty crashing here in second, actual deleting loop.
* Also, this will also flag users of deleted data that cannot be unlinked
* (object using deleted obdata, etc.), so that they also get deleted. */
BKE_libblock_remap_multiple_locked(bmain,
id_remapper,
ID_REMAP_FLAG_NEVER_NULL_USAGE |
ID_REMAP_FORCE_NEVER_NULL_USAGE |
ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS);
BKE_libblock_remap_multiple_locked(bmain, id_remapper, remapping_flags);
BKE_id_remapper_clear(id_remapper);
}
@ -329,11 +329,7 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
* links, this can lead to nasty crashing here in second, actual deleting loop.
* Also, this will also flag users of deleted data that cannot be unlinked
* (object using deleted obdata, etc.), so that they also get deleted. */
BKE_libblock_remap_multiple_locked(bmain,
remapper,
(ID_REMAP_FLAG_NEVER_NULL_USAGE |
ID_REMAP_FORCE_NEVER_NULL_USAGE |
ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS));
BKE_libblock_remap_multiple_locked(bmain, remapper, remapping_flags);
}
BKE_id_remapper_free(remapper);
}
@ -371,7 +367,7 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
return num_datablocks_deleted;
}
void BKE_id_delete(Main *bmain, void *idv)
void BKE_id_delete_ex(Main *bmain, void *idv, const int extra_remapping_flags)
{
BLI_assert_msg((((ID *)idv)->tag & LIB_TAG_NO_MAIN) == 0,
"Cannot be used with IDs outside of Main");
@ -379,12 +375,17 @@ void BKE_id_delete(Main *bmain, void *idv)
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
((ID *)idv)->tag |= LIB_TAG_DOIT;
id_delete(bmain, false);
id_delete(bmain, false, extra_remapping_flags);
}
void BKE_id_delete(Main *bmain, void *idv)
{
BKE_id_delete_ex(bmain, idv, 0);
}
size_t BKE_id_multi_tagged_delete(Main *bmain)
{
return id_delete(bmain, true);
return id_delete(bmain, true, 0);
}
/* -------------------------------------------------------------------- */

View File

@ -39,8 +39,8 @@ TEST(lib_id_remapper, mapped)
ID id1;
ID id2;
ID *idp = &id1;
BLI_strncpy(id1.name, "OB1", sizeof(id1.name));
BLI_strncpy(id2.name, "OB2", sizeof(id2.name));
STRNCPY(id1.name, "OB1");
STRNCPY(id2.name, "OB2");
IDRemapper *remapper = BKE_id_remapper_create();
BKE_id_remapper_add(remapper, &id1, &id2);
@ -55,7 +55,7 @@ TEST(lib_id_remapper, unassigned)
{
ID id1;
ID *idp = &id1;
BLI_strncpy(id1.name, "OB2", sizeof(id1.name));
STRNCPY(id1.name, "OB2");
IDRemapper *remapper = BKE_id_remapper_create();
BKE_id_remapper_add(remapper, &id1, nullptr);
@ -73,9 +73,9 @@ TEST(lib_id_remapper, unassign_when_mapped_to_self)
ID id2;
ID *idp;
BLI_strncpy(id_self.name, "OBSelf", sizeof(id1.name));
BLI_strncpy(id1.name, "OB1", sizeof(id1.name));
BLI_strncpy(id2.name, "OB2", sizeof(id2.name));
STRNCPY(id_self.name, "OBSelf");
STRNCPY(id1.name, "OB1");
STRNCPY(id2.name, "OB2");
/* Default mapping behavior. Should just remap to id2. */
idp = &id1;

View File

@ -4323,7 +4323,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
* different from reference linked ID. But local ID names need to be unique in a given type
* list of Main, so we cannot always keep it identical, which is why we need this special
* manual handling here. */
BLI_strncpy(tmp_id->name, local->name, sizeof(tmp_id->name));
STRNCPY(tmp_id->name, local->name);
/* Those ugly loop-back pointers again. Luckily we only need to deal with the shape keys here,
* collections' parents are fully runtime and reconstructed later. */
@ -4333,7 +4333,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
tmp_key->id.flag |= (local_key->id.flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE);
BKE_main_namemap_remove_name(bmain, &tmp_key->id, tmp_key->id.name + 2);
tmp_key->id.lib = local_key->id.lib;
BLI_strncpy(tmp_key->id.name, local_key->id.name, sizeof(tmp_key->id.name));
STRNCPY(tmp_key->id.name, local_key->id.name);
}
PointerRNA rnaptr_src, rnaptr_dst, rnaptr_storage_stack, *rnaptr_storage = nullptr;

View File

@ -374,7 +374,7 @@ void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cb_flag)
}
}
uint64_t BKE_library_id_can_use_filter_id(const ID *id_owner)
uint64_t BKE_library_id_can_use_filter_id(const ID *id_owner, const bool include_ui)
{
/* any type of ID can be used in custom props. */
if (id_owner->properties) {
@ -387,6 +387,11 @@ uint64_t BKE_library_id_can_use_filter_id(const ID *id_owner)
return FILTER_ID_ALL;
}
/* Screen UI IDs can also link to virtually any ID (through e.g. the Outliner). */
if (include_ui && id_type_owner == ID_SCR) {
return FILTER_ID_ALL;
}
/* Casting to non const.
* TODO(jbakker): We should introduce a ntree_id_has_tree function as we are actually not
* interested in the result. */
@ -510,7 +515,7 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
}
const uint64_t filter_id_type_used = BKE_idtype_idcode_to_idfilter(id_type_used);
const uint64_t can_be_used = BKE_library_id_can_use_filter_id(id_owner);
const uint64_t can_be_used = BKE_library_id_can_use_filter_id(id_owner, false);
return (can_be_used & filter_id_type_used) != 0;
}

View File

@ -482,13 +482,14 @@ static void libblock_remap_data(Main *bmain,
const int remap_flags)
{
IDRemap id_remap_data = {0};
const int foreach_id_flags =
(((remap_flags & ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS) != 0 ?
IDWALK_DO_INTERNAL_RUNTIME_POINTERS :
IDWALK_NOP) |
((remap_flags & ID_REMAP_FORCE_UI_POINTERS) != 0 ? IDWALK_INCLUDE_UI : IDWALK_NOP) |
((remap_flags & ID_REMAP_NO_ORIG_POINTERS_ACCESS) != 0 ? IDWALK_NO_ORIG_POINTERS_ACCESS :
IDWALK_NOP));
const bool include_ui = (remap_flags & ID_REMAP_FORCE_UI_POINTERS) != 0;
const int foreach_id_flags = (((remap_flags & ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS) != 0 ?
IDWALK_DO_INTERNAL_RUNTIME_POINTERS :
IDWALK_NOP) |
(include_ui ? IDWALK_INCLUDE_UI : IDWALK_NOP) |
((remap_flags & ID_REMAP_NO_ORIG_POINTERS_ACCESS) != 0 ?
IDWALK_NO_ORIG_POINTERS_ACCESS :
IDWALK_NOP));
id_remap_data.id_remapper = id_remapper;
id_remap_data.type = remap_type;
@ -514,7 +515,7 @@ static void libblock_remap_data(Main *bmain,
ID *id_curr;
FOREACH_MAIN_ID_BEGIN (bmain, id_curr) {
const uint64_t can_use_filter_id = BKE_library_id_can_use_filter_id(id_curr);
const uint64_t can_use_filter_id = BKE_library_id_can_use_filter_id(id_curr, include_ui);
const bool has_mapping = BKE_id_remapper_has_mapping_for(id_remapper, can_use_filter_id);
/* Continue when id_remapper doesn't have any mappings that can be used by id_curr. */

View File

@ -113,10 +113,10 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
/* in some cases this is used to update the absolute path from the
* relative */
if (lib->filepath != filepath) {
BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath));
STRNCPY(lib->filepath, filepath);
}
BLI_strncpy(lib->filepath_abs, filepath, sizeof(lib->filepath_abs));
STRNCPY(lib->filepath_abs, filepath);
/* Not essential but set `filepath_abs` is an absolute copy of value which
* is more useful if its kept in sync. */

View File

@ -815,7 +815,7 @@ static LineStyleModifier *new_modifier(const char *name, int type, size_t size)
}
m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
m->type = type;
BLI_strncpy(m->name, name, sizeof(m->name));
STRNCPY(m->name, name);
m->influence = 1.0f;
m->flags = LS_MODIFIER_ENABLED | LS_MODIFIER_EXPANDED;

View File

@ -377,8 +377,8 @@ static LibWeakRefKey *lib_weak_key_create(LibWeakRefKey *key,
if (key == NULL) {
key = MEM_mallocN(sizeof(*key), __func__);
}
BLI_strncpy(key->filepath, lib_path, sizeof(key->filepath));
BLI_strncpy(key->id_name, id_name, sizeof(key->id_name));
STRNCPY(key->filepath, lib_path);
STRNCPY(key->id_name, id_name);
return key;
}
@ -463,12 +463,8 @@ void BKE_main_library_weak_reference_add_item(GHash *library_weak_reference_mapp
BLI_assert(!already_exist_in_mapping);
UNUSED_VARS_NDEBUG(already_exist_in_mapping);
BLI_strncpy(new_id->library_weak_reference->library_filepath,
library_filepath,
sizeof(new_id->library_weak_reference->library_filepath));
BLI_strncpy(new_id->library_weak_reference->library_id_name,
library_id_name,
sizeof(new_id->library_weak_reference->library_id_name));
STRNCPY(new_id->library_weak_reference->library_filepath, library_filepath);
STRNCPY(new_id->library_weak_reference->library_id_name, library_id_name);
*id_p = new_id;
}

View File

@ -47,7 +47,7 @@ using namespace blender;
static bool id_name_final_build(char *name, char *base_name, size_t base_name_len, int number)
{
char number_str[11]; /* Dot + nine digits + NULL terminator. */
size_t number_str_len = BLI_snprintf_rlen(number_str, ARRAY_SIZE(number_str), ".%.3d", number);
size_t number_str_len = SNPRINTF_RLEN(number_str, ".%.3d", number);
/* If the number would lead to an overflow of the maximum ID name length, we need to truncate
* the base name part and do all the number checks again. */
@ -229,7 +229,7 @@ static void main_namemap_populate(UniqueName_Map *name_map, struct Main *bmain,
/* Insert the full name into the set. */
UniqueName_Key key;
BLI_strncpy(key.name, id->name + 2, MAX_NAME);
STRNCPY(key.name, id->name + 2);
type_map->full_names.add(key);
/* Get the name and number parts ("name.number"). */
@ -279,7 +279,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
UniqueName_Key key;
while (true) {
/* Check if the full original name has a duplicate. */
BLI_strncpy(key.name, name, MAX_NAME);
STRNCPY(key.name, name);
const bool has_dup = type_map->full_names.contains(key);
/* Get the name and number parts ("name.number"). */
@ -299,7 +299,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
val.mark_used(number);
if (!has_dup) {
BLI_strncpy(key.name, name, MAX_NAME);
STRNCPY(key.name, name);
type_map->full_names.add(key);
}
return is_name_changed;
@ -334,7 +334,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
BLI_assert(number_to_use >= MIN_NUMBER);
if (id_name_final_build(name, key.name, base_name_len, number_to_use)) {
/* All good, add final name to the set. */
BLI_strncpy(key.name, name, MAX_NAME);
STRNCPY(key.name, name);
type_map->full_names.add(key);
break;
}
@ -369,7 +369,7 @@ void BKE_main_namemap_remove_name(struct Main *bmain, struct ID *id, const char
UniqueName_Key key;
/* Remove full name from the set. */
BLI_strncpy(key.name, name, MAX_NAME);
STRNCPY(key.name, name);
type_map->full_names.remove(key);
int number = MIN_NUMBER;
@ -408,7 +408,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb_iter) {
LISTBASE_FOREACH_MUTABLE (ID *, id_iter, lb_iter) {
Uniqueness_Key key;
BLI_strncpy(key.name, id_iter->name, MAX_ID_NAME);
STRNCPY(key.name, id_iter->name);
key.lib = id_iter->lib;
if (!id_names_libs.add(key)) {
is_valid = false;
@ -421,7 +421,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
* not really an issue. */
BKE_id_new_name_validate(
bmain, which_libbase(bmain, GS(id_iter->name)), id_iter, nullptr, true);
BLI_strncpy(key.name, id_iter->name, MAX_ID_NAME);
STRNCPY(key.name, id_iter->name);
if (!id_names_libs.add(key)) {
CLOG_ERROR(&LOG,
"\tID has been renamed to '%s', but it still seems to be already in use",
@ -442,7 +442,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
UniqueName_Key key_namemap;
/* Remove full name from the set. */
BLI_strncpy(key_namemap.name, id_iter->name + 2, MAX_NAME);
STRNCPY(key_namemap.name, id_iter->name + 2);
if (!type_map->full_names.contains(key_namemap)) {
is_valid = false;
CLOG_ERROR(&LOG,

View File

@ -336,7 +336,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
MaskLayer *masklay = MEM_cnew<MaskLayer>(__func__);
if (name && name[0]) {
BLI_strncpy(masklay->name, name, sizeof(masklay->name));
STRNCPY(masklay->name, name);
}
else {
strcpy(masklay->name, DATA_("MaskLayer"));
@ -389,7 +389,7 @@ void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay)
void BKE_mask_layer_rename(Mask *mask, MaskLayer *masklay, char *oldname, char *newname)
{
BLI_strncpy(masklay->name, newname, sizeof(masklay->name));
STRNCPY(masklay->name, newname);
BKE_mask_layer_unique_name(mask, masklay);
@ -401,7 +401,7 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay)
{
MaskLayer *masklay_new = MEM_cnew<MaskLayer>("new mask layer");
BLI_strncpy(masklay_new->name, masklay->name, sizeof(masklay_new->name));
STRNCPY(masklay_new->name, masklay->name);
masklay_new->alpha = masklay->alpha;
masklay_new->blend = masklay->blend;
@ -1011,7 +1011,7 @@ Mask *BKE_mask_new(Main *bmain, const char *name)
char mask_name[MAX_ID_NAME - 2];
if (name && name[0]) {
BLI_strncpy(mask_name, name, sizeof(mask_name));
STRNCPY(mask_name, name);
}
else {
strcpy(mask_name, "Mask");

View File

@ -770,7 +770,7 @@ static Mesh *mesh_new_from_mesh(Object *object, Mesh *mesh)
nullptr, &mesh->id, nullptr, LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT);
/* NOTE: Materials should already be copied. */
/* Copy original mesh name. This is because edit meshes might not have one properly set name. */
BLI_strncpy(mesh_result->id.name, ((ID *)object->data)->name, sizeof(mesh_result->id.name));
STRNCPY(mesh_result->id.name, ((ID *)object->data)->name);
return mesh_result;
}

View File

@ -390,7 +390,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
CustomData *ldata = &result->ldata;
blender::short2 *clnors = static_cast<blender::short2 *>(
CustomData_get_layer_for_write(ldata, CD_CUSTOMLOOPNORMAL, result->totloop));
MLoopNorSpaceArray lnors_spacearr = {nullptr};
blender::bke::mesh::CornerNormalSpaceArray lnors_spacearr;
/* The transform matrix of a normal must be
* the transpose of inverse of transform matrix of the geometry... */
@ -432,12 +432,14 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
}
copy_v3_v3(loop_normals[mirrorj], loop_normals[j]);
mul_m4_v3(mtx_nor, loop_normals[mirrorj]);
BKE_lnor_space_custom_normal_to_data(
lnors_spacearr.lspacearr[mirrorj], loop_normals[mirrorj], clnors[mirrorj]);
const int space_index = lnors_spacearr.corner_space_indices[mirrorj];
blender::bke::mesh::lnor_space_custom_normal_to_data(&lnors_spacearr.spaces[space_index],
loop_normals[mirrorj],
loop_normals[mirrorj],
clnors[mirrorj]);
}
}
BKE_lnor_spacearr_free(&lnors_spacearr);
}
/* handle vgroup stuff */

View File

@ -467,11 +467,12 @@ MLoopNorSpace *BKE_lnor_space_create(MLoopNorSpaceArray *lnors_spacearr)
/* This threshold is a bit touchy (usual float precision issue), this value seems OK. */
#define LNOR_SPACE_TRIGO_THRESHOLD (1.0f - 1e-4f)
void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
const float lnor[3],
float vec_ref[3],
float vec_other[3],
const blender::Span<blender::float3> edge_vectors)
namespace blender::bke::mesh {
static void lnor_space_define(CornerNormalSpace *lnor_space,
const float lnor[3],
float vec_ref[3],
float vec_other[3],
const blender::Span<blender::float3> edge_vectors)
{
const float pi2 = float(M_PI) * 2.0f;
float tvec[3], dtp;
@ -487,8 +488,6 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
return;
}
copy_v3_v3(lnor_space->vec_lnor, lnor);
/* Compute ref alpha, average angle of all available edge vectors to lnor. */
if (!edge_vectors.is_empty()) {
float alpha = 0.0f;
@ -532,6 +531,23 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
lnor_space->ref_beta = pi2;
}
}
} // namespace blender::bke::mesh
void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
const float lnor[3],
float vec_ref[3],
float vec_other[3],
const blender::Span<blender::float3> edge_vectors)
{
using namespace blender::bke::mesh;
CornerNormalSpace space{};
lnor_space_define(&space, lnor, vec_ref, vec_other, edge_vectors);
copy_v3_v3(lnor_space->vec_lnor, lnor);
copy_v3_v3(lnor_space->vec_ref, space.vec_ref);
copy_v3_v3(lnor_space->vec_ortho, space.vec_ortho);
lnor_space->ref_alpha = space.ref_alpha;
lnor_space->ref_beta = space.ref_beta;
}
void BKE_lnor_space_add_loop(MLoopNorSpaceArray *lnors_spacearr,
MLoopNorSpace *lnor_space,
@ -568,13 +584,15 @@ MINLINE short unit_float_to_short(const float val)
return short(floorf(val * float(SHRT_MAX) + 0.5f));
}
void BKE_lnor_space_custom_data_to_normal(const MLoopNorSpace *lnor_space,
const short clnor_data[2],
float r_custom_lnor[3])
namespace blender::bke::mesh {
static void lnor_space_custom_data_to_normal(const CornerNormalSpace *lnor_space,
const float3 lnor_no_custom,
const short clnor_data[2],
float r_custom_lnor[3])
{
/* NOP custom normal data or invalid lnor space, return. */
if (clnor_data[0] == 0 || lnor_space->ref_alpha == 0.0f || lnor_space->ref_beta == 0.0f) {
copy_v3_v3(r_custom_lnor, lnor_space->vec_lnor);
copy_v3_v3(r_custom_lnor, lnor_no_custom);
return;
}
@ -587,7 +605,7 @@ void BKE_lnor_space_custom_data_to_normal(const MLoopNorSpace *lnor_space,
alphafac;
const float betafac = unit_short_to_float(clnor_data[1]);
mul_v3_v3fl(r_custom_lnor, lnor_space->vec_lnor, cosf(alpha));
mul_v3_v3fl(r_custom_lnor, lnor_no_custom, cosf(alpha));
if (betafac == 0.0f) {
madd_v3_v3fl(r_custom_lnor, lnor_space->vec_ref, sinf(alpha));
@ -601,21 +619,37 @@ void BKE_lnor_space_custom_data_to_normal(const MLoopNorSpace *lnor_space,
}
}
}
} // namespace blender::bke::mesh
void BKE_lnor_space_custom_normal_to_data(const MLoopNorSpace *lnor_space,
const float custom_lnor[3],
short r_clnor_data[2])
void BKE_lnor_space_custom_data_to_normal(const MLoopNorSpace *lnor_space,
const short clnor_data[2],
float r_custom_lnor[3])
{
using namespace blender::bke::mesh;
CornerNormalSpace space;
space.vec_ref = lnor_space->vec_ref;
space.vec_ortho = lnor_space->vec_ortho;
space.ref_alpha = lnor_space->ref_alpha;
space.ref_beta = lnor_space->ref_beta;
lnor_space_custom_data_to_normal(&space, lnor_space->vec_lnor, clnor_data, r_custom_lnor);
}
namespace blender::bke::mesh {
void lnor_space_custom_normal_to_data(const CornerNormalSpace *lnor_space,
const float3 lnor_no_custom,
const float custom_lnor[3],
short r_clnor_data[2])
{
/* We use nullptr vector as NOP custom normal (can be simpler than giving auto-computed `lnor`).
*/
if (is_zero_v3(custom_lnor) || compare_v3v3(lnor_space->vec_lnor, custom_lnor, 1e-4f)) {
if (is_zero_v3(custom_lnor) || compare_v3v3(lnor_no_custom, custom_lnor, 1e-4f)) {
r_clnor_data[0] = r_clnor_data[1] = 0;
return;
}
{
const float pi2 = float(M_PI * 2.0);
const float cos_alpha = dot_v3v3(lnor_space->vec_lnor, custom_lnor);
const float cos_alpha = dot_v3v3(lnor_no_custom, custom_lnor);
float vec[3], cos_beta;
float alpha;
@ -630,7 +664,7 @@ void BKE_lnor_space_custom_normal_to_data(const MLoopNorSpace *lnor_space,
}
/* Project custom lnor on (vec_ref, vec_ortho) plane. */
mul_v3_v3fl(vec, lnor_space->vec_lnor, -cos_alpha);
mul_v3_v3fl(vec, lnor_no_custom, -cos_alpha);
add_v3_v3(vec, custom_lnor);
normalize_v3(vec);
@ -654,6 +688,20 @@ void BKE_lnor_space_custom_normal_to_data(const MLoopNorSpace *lnor_space,
}
}
}
} // namespace blender::bke::mesh
void BKE_lnor_space_custom_normal_to_data(const MLoopNorSpace *lnor_space,
const float custom_lnor[3],
short r_clnor_data[2])
{
using namespace blender::bke::mesh;
CornerNormalSpace space;
space.vec_ref = lnor_space->vec_ref;
space.vec_ortho = lnor_space->vec_ortho;
space.ref_alpha = lnor_space->ref_alpha;
space.ref_beta = lnor_space->ref_beta;
lnor_space_custom_normal_to_data(&space, lnor_space->vec_lnor, custom_lnor, r_clnor_data);
}
namespace blender::bke::mesh {
@ -661,7 +709,7 @@ struct LoopSplitTaskDataCommon {
/* Read/write.
* Note we do not need to protect it, though, since two different tasks will *always* affect
* different elements in the arrays. */
MLoopNorSpaceArray *lnors_spacearr;
CornerNormalSpaceArray *lnors_spacearr;
MutableSpan<float3> loop_normals;
MutableSpan<short2> clnors_data;
@ -833,7 +881,7 @@ static void loop_manifold_fan_around_vert_next(const Span<int> corner_verts,
static void lnor_space_for_single_fan(LoopSplitTaskDataCommon *common_data,
const int ml_curr_index,
MLoopNorSpace *lnor_space)
const int space_index)
{
const Span<int> loop_to_poly = common_data->loop_to_poly;
const Span<float3> poly_normals = common_data->poly_normals;
@ -841,7 +889,7 @@ static void lnor_space_for_single_fan(LoopSplitTaskDataCommon *common_data,
loop_normals[ml_curr_index] = poly_normals[loop_to_poly[ml_curr_index]];
if (MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr) {
if (CornerNormalSpaceArray *lnors_spacearr = common_data->lnors_spacearr) {
const Span<float3> positions = common_data->positions;
const Span<int2> edges = common_data->edges;
const OffsetIndices polys = common_data->polys;
@ -864,23 +912,25 @@ static void lnor_space_for_single_fan(LoopSplitTaskDataCommon *common_data,
sub_v3_v3v3(vec_prev, positions[vert_3], positions[vert_pivot]);
normalize_v3(vec_prev);
BKE_lnor_space_define(lnor_space, loop_normals[ml_curr_index], vec_curr, vec_prev, {});
/* We know there is only one loop in this space, no need to create a link-list in this case. */
BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, ml_curr_index, nullptr, true);
CornerNormalSpace *lnor_space = &lnors_spacearr->spaces[space_index];
lnor_space_define(lnor_space, loop_normals[ml_curr_index], vec_curr, vec_prev, {});
lnors_spacearr->corner_space_indices[ml_curr_index] = space_index;
if (!clnors_data.is_empty()) {
BKE_lnor_space_custom_data_to_normal(
lnor_space, clnors_data[ml_curr_index], loop_normals[ml_curr_index]);
lnor_space_custom_data_to_normal(lnor_space,
loop_normals[ml_curr_index],
clnors_data[ml_curr_index],
loop_normals[ml_curr_index]);
}
}
}
static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data,
const int ml_curr_index,
MLoopNorSpace *lnor_space,
const int space_index,
Vector<float3> *edge_vectors)
{
MLoopNorSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
CornerNormalSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
MutableSpan<float3> loop_normals = common_data->loop_normals;
MutableSpan<short2> clnors_data = common_data->clnors_data;
@ -984,8 +1034,6 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data,
processed_corners.append(mlfan_vert_index);
if (lnors_spacearr) {
/* Assign current lnor space to current 'vertex' loop. */
BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, mlfan_vert_index, nullptr, false);
if (edge != edge_orig) {
/* We store here all edges-normalized vectors processed. */
edge_vectors->append(vec_curr);
@ -1024,7 +1072,10 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data,
length = 1.0f;
}
BKE_lnor_space_define(lnor_space, lnor, vec_org, vec_curr, *edge_vectors);
CornerNormalSpace *lnor_space = &lnors_spacearr->spaces[space_index];
lnor_space_define(lnor_space, lnor, vec_org, vec_curr, *edge_vectors);
lnors_spacearr->corner_space_indices.as_mutable_span().fill_indices(
processed_corners.as_span(), space_index);
edge_vectors->clear();
if (!clnors_data.is_empty()) {
@ -1042,7 +1093,7 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data,
/* Extra bonus: since small-stack is local to this function,
* no more need to empty it at all cost! */
BKE_lnor_space_custom_data_to_normal(lnor_space, *clnor_ref, lnor);
lnor_space_custom_data_to_normal(lnor_space, lnor, *clnor_ref, lnor);
}
}
@ -1219,7 +1270,7 @@ void normals_calc_loop(const Span<float3> vert_positions,
bool use_split_normals,
float split_angle,
short2 *clnors_data,
MLoopNorSpaceArray *r_lnors_spacearr,
CornerNormalSpaceArray *r_lnors_spacearr,
MutableSpan<float3> r_loop_normals)
{
/* For now this is not supported.
@ -1277,7 +1328,7 @@ void normals_calc_loop(const Span<float3> vert_positions,
/* When using custom loop normals, disable the angle feature! */
const bool check_angle = (split_angle < float(M_PI)) && (clnors_data == nullptr);
MLoopNorSpaceArray _lnors_spacearr = {nullptr};
CornerNormalSpaceArray _lnors_spacearr;
#ifdef DEBUG_TIME
SCOPED_TIMER_AVERAGED(__func__);
@ -1287,9 +1338,6 @@ void normals_calc_loop(const Span<float3> vert_positions,
/* We need to compute lnor spacearr if some custom lnor data are given to us! */
r_lnors_spacearr = &_lnors_spacearr;
}
if (r_lnors_spacearr) {
BKE_lnor_spacearr_init(r_lnors_spacearr, corner_verts.size(), MLNOR_SPACEARR_LOOP_INDEX);
}
/* Init data common to all tasks. */
LoopSplitTaskDataCommon common_data;
@ -1328,17 +1376,15 @@ void normals_calc_loop(const Span<float3> vert_positions,
Vector<int> fan_corners;
loop_split_generator(&common_data, single_corners, fan_corners);
MLoopNorSpace *lnor_spaces = nullptr;
if (r_lnors_spacearr) {
r_lnors_spacearr->spaces_num = single_corners.size() + fan_corners.size();
lnor_spaces = static_cast<MLoopNorSpace *>(BLI_memarena_calloc(
r_lnors_spacearr->mem, sizeof(MLoopNorSpace) * r_lnors_spacearr->spaces_num));
r_lnors_spacearr->spaces.reinitialize(single_corners.size() + fan_corners.size());
r_lnors_spacearr->corner_space_indices = Array<int>(corner_verts.size(), -1);
}
threading::parallel_for(single_corners.index_range(), 1024, [&](const IndexRange range) {
for (const int i : range) {
const int corner = single_corners[i];
lnor_space_for_single_fan(&common_data, corner, lnor_spaces ? &lnor_spaces[i] : nullptr);
lnor_space_for_single_fan(&common_data, corner, i);
}
});
@ -1346,24 +1392,48 @@ void normals_calc_loop(const Span<float3> vert_positions,
Vector<float3> edge_vectors;
for (const int i : range) {
const int corner = fan_corners[i];
split_loop_nor_fan_do(&common_data,
corner,
lnor_spaces ? &lnor_spaces[single_corners.size() + i] : nullptr,
&edge_vectors);
const int space_index = single_corners.size() + i;
split_loop_nor_fan_do(&common_data, corner, space_index, &edge_vectors);
}
});
if (r_lnors_spacearr) {
if (r_lnors_spacearr == &_lnors_spacearr) {
BKE_lnor_spacearr_free(r_lnors_spacearr);
}
}
}
#undef INDEX_UNSET
#undef INDEX_INVALID
#undef IS_EDGE_SHARP
/**
* Take an array of N indices that points to \a items_num items, where multiple indices map to the
* same item, and reverse the indices to create an array of all the indices that reference each
* item. Group each item's indices together consecutively, encoding the grouping in #r_offsets,
* which is meant to be used by #OffsetIndices.
*
* \param r_offsets: An array to be filled with the first index of each item in
* \a r_reverse_indices, used to split the indices into chunks by item. (See #OffsetIndices).
* \param r_reverse_indices: The indices into \a item_indices that point to each item, split by \a
* r_offsets.
*/
static void reverse_index_array(const Span<int> item_indices,
const int items_num,
Array<int> &r_offsets,
Array<int> &r_reverse_indices)
{
r_offsets = Array<int>(items_num + 1, 0);
for (const int index : item_indices) {
r_offsets[index]++;
}
offset_indices::accumulate_counts_to_offsets(r_offsets);
r_reverse_indices.reinitialize(r_offsets.last());
Array<int> count_per_item(items_num, 0);
for (const int corner : item_indices.index_range()) {
const int space = item_indices[corner];
r_reverse_indices[r_offsets[space] + count_per_item[space]] = corner;
count_per_item[space]++;
}
}
/**
* Compute internal representation of given custom normals (as an array of float[2]).
* It also makes sure the mesh matches those custom normals, by setting sharp edges flag as needed
@ -1392,7 +1462,7 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
* function *is not* performance-critical, since it is mostly expected to be called by io add-ons
* when importing custom normals, and modifier (and perhaps from some editing tools later?). So
* better to keep some simplicity here, and just call #bke::mesh::normals_calc_loop() twice! */
MLoopNorSpaceArray lnors_spacearr = {nullptr};
CornerNormalSpaceArray lnors_spacearr;
BitVector<> done_loops(corner_verts.size(), false);
Array<float3> loop_normals(corner_verts.size());
const Array<int> loop_to_poly = mesh_topology::build_loop_to_poly_map(polys);
@ -1434,8 +1504,6 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
}
}
BLI_assert(lnors_spacearr.data_type == MLNOR_SPACEARR_LOOP_INDEX);
/* Now, check each current smooth fan (one lnor space per smooth fan!),
* and if all its matching custom loop_normals are not (enough) equal, add sharp edges as needed.
* This way, next time we run bke::mesh::normals_calc_loop(), we'll get lnor spacearr/smooth fans
@ -1446,10 +1514,18 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
done_loops.fill(true);
}
else {
Array<int> fan_corners_from_space_offset_indices;
Array<int> fan_corners_from_space_data;
reverse_index_array(lnors_spacearr.corner_space_indices,
lnors_spacearr.spaces.size(),
fan_corners_from_space_offset_indices,
fan_corners_from_space_data);
const OffsetIndices<int> fan_corner_offsets(fan_corners_from_space_offset_indices);
for (const int i : corner_verts.index_range()) {
if (!lnors_spacearr.lspacearr[i]) {
if (lnors_spacearr.corner_space_indices[i] == -1) {
/* This should not happen in theory, but in some rare case (probably ugly geometry)
* we can get some nullptr loopspacearr at this point. :/
* we can get some missing loopspacearr at this point. :/
* Maybe we should set those loops' edges as sharp? */
done_loops[i].set();
if (G.debug & G_DEBUG) {
@ -1461,6 +1537,10 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
continue;
}
const int space_index = lnors_spacearr.corner_space_indices[i];
const Span<int> fan_corners = fan_corners_from_space_data.as_span().slice(
fan_corner_offsets[space_index]);
/* Notes:
* - In case of mono-loop smooth fan, we have nothing to do.
* - Loops in this linklist are ordered (in reversed order compared to how they were
@ -1470,17 +1550,15 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
* - In smooth fan case, we compare each clnor against a ref one,
* to avoid small differences adding up into a real big one in the end!
*/
if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
if (fan_corners.is_empty()) {
done_loops[i].set();
continue;
}
LinkNode *loop_link = lnors_spacearr.lspacearr[i]->loops;
int prev_corner = -1;
const float *org_nor = nullptr;
while (loop_link) {
const int lidx = POINTER_AS_INT(loop_link->link);
for (const int lidx : fan_corners) {
float *nor = r_custom_loop_normals[lidx];
if (!org_nor) {
@ -1502,7 +1580,6 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
}
prev_corner = lidx;
loop_link = loop_link->next;
done_loops[lidx].set();
}
@ -1510,9 +1587,8 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
* otherwise we may miss some sharp edges here!
* This is just a simplified version of above while loop.
* See #45984. */
loop_link = lnors_spacearr.lspacearr[i]->loops;
if (loop_link && org_nor) {
const int lidx = POINTER_AS_INT(loop_link->link);
if (fan_corners.size() > 1 && org_nor) {
const int lidx = fan_corners.last();
float *nor = r_custom_loop_normals[lidx];
if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
@ -1527,7 +1603,7 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
}
/* And now, recompute our new auto `loop_normals` and lnor spacearr! */
BKE_lnor_spacearr_clear(&lnors_spacearr);
lnors_spacearr = {};
normals_calc_loop(positions,
edges,
polys,
@ -1545,12 +1621,18 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
loop_normals);
}
Vector<int> processed_corners;
Array<int> fan_corners_from_space_offset_indices;
Array<int> fan_corners_from_space_data;
reverse_index_array(lnors_spacearr.corner_space_indices,
lnors_spacearr.spaces.size(),
fan_corners_from_space_offset_indices,
fan_corners_from_space_data);
const OffsetIndices<int> fan_corner_offsets(fan_corners_from_space_offset_indices);
/* And we just have to convert plain object-space custom normals to our
* lnor space-encoded ones. */
for (const int i : corner_verts.index_range()) {
if (!lnors_spacearr.lspacearr[i]) {
if (lnors_spacearr.corner_space_indices[i] == -1) {
done_loops[i].reset();
if (G.debug & G_DEBUG) {
printf("WARNING! Still getting invalid nullptr loop space in second loop for loop %d!\n",
@ -1562,44 +1644,41 @@ static void mesh_normals_loop_custom_set(Span<float3> positions,
continue;
}
const int space_index = lnors_spacearr.corner_space_indices[i];
const Span<int> fan_corners = fan_corners_from_space_data.as_span().slice(
fan_corner_offsets[space_index]);
/* Note we accumulate and average all custom normals in current smooth fan,
* to avoid getting different clnors data (tiny differences in plain custom normals can
* give rather huge differences in computed 2D factors). */
LinkNode *loop_link = lnors_spacearr.lspacearr[i]->loops;
if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
BLI_assert(POINTER_AS_INT(loop_link) == i);
if (fan_corners.size() < 2) {
const int nidx = use_vertices ? corner_verts[i] : i;
float *nor = r_custom_loop_normals[nidx];
BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], nor, r_clnors_data[i]);
const int space_index = lnors_spacearr.corner_space_indices[i];
lnor_space_custom_normal_to_data(
&lnors_spacearr.spaces[space_index], loop_normals[i], nor, r_clnors_data[i]);
done_loops[i].reset();
}
else {
int avg_nor_count = 0;
float3 avg_nor(0.0f);
while (loop_link) {
const int lidx = POINTER_AS_INT(loop_link->link);
for (const int lidx : fan_corners) {
const int nidx = use_vertices ? corner_verts[lidx] : lidx;
float *nor = r_custom_loop_normals[nidx];
avg_nor_count++;
add_v3_v3(avg_nor, nor);
processed_corners.append(lidx);
loop_link = loop_link->next;
done_loops[lidx].reset();
}
mul_v3_fl(avg_nor, 1.0f / float(avg_nor_count));
mul_v3_fl(avg_nor, 1.0f / float(fan_corners.size()));
short2 clnor_data_tmp;
BKE_lnor_space_custom_normal_to_data(lnors_spacearr.lspacearr[i], avg_nor, clnor_data_tmp);
lnor_space_custom_normal_to_data(
&lnors_spacearr.spaces[space_index], loop_normals[i], avg_nor, clnor_data_tmp);
r_clnors_data.fill_indices(processed_corners.as_span(), clnor_data_tmp);
processed_corners.clear();
r_clnors_data.fill_indices(fan_corners, clnor_data_tmp);
}
}
BKE_lnor_spacearr_free(&lnors_spacearr);
}
void normals_loop_custom_set(const Span<float3> vert_positions,

View File

@ -162,7 +162,7 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
const float (*poly_normals)[3])
{
MemArena *pf_arena = nullptr;
uint tri_index = 0;
uint looptri_i = 0;
if (poly_normals != nullptr) {
for (const int64_t i : polys.index_range()) {
@ -170,17 +170,17 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
polys,
positions,
uint(i),
&mlooptri[tri_index],
&mlooptri[looptri_i],
&pf_arena,
poly_normals[i]);
tri_index += uint(polys[i].size() - 2);
looptri_i += uint(polys[i].size() - 2);
}
}
else {
for (const int64_t i : polys.index_range()) {
mesh_calc_tessellation_for_face(
corner_verts, polys, positions, uint(i), &mlooptri[tri_index], &pf_arena);
tri_index += uint(polys[i].size() - 2);
corner_verts, polys, positions, uint(i), &mlooptri[looptri_i], &pf_arena);
looptri_i += uint(polys[i].size() - 2);
}
}
@ -188,7 +188,7 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
BLI_memarena_free(pf_arena);
pf_arena = nullptr;
}
BLI_assert(tri_index == uint(poly_to_tri_count(int(polys.size()), int(corner_verts.size()))));
BLI_assert(looptri_i == uint(poly_to_tri_count(int(polys.size()), int(corner_verts.size()))));
}
struct TessellationUserData {
@ -213,12 +213,12 @@ static void mesh_calc_tessellation_for_face_fn(void *__restrict userdata,
{
const TessellationUserData *data = static_cast<const TessellationUserData *>(userdata);
TessellationUserTLS *tls_data = static_cast<TessellationUserTLS *>(tls->userdata_chunk);
const int tri_index = poly_to_tri_count(index, int(data->polys[index].start()));
const int looptri_i = poly_to_tri_count(index, int(data->polys[index].start()));
mesh_calc_tessellation_for_face_impl(data->corner_verts,
data->polys,
data->positions,
uint(index),
&data->mlooptri[tri_index],
&data->mlooptri[looptri_i],
&tls_data->pf_arena,
false,
nullptr);
@ -230,12 +230,12 @@ static void mesh_calc_tessellation_for_face_with_normal_fn(void *__restrict user
{
const TessellationUserData *data = static_cast<const TessellationUserData *>(userdata);
TessellationUserTLS *tls_data = static_cast<TessellationUserTLS *>(tls->userdata_chunk);
const int tri_index = poly_to_tri_count(index, int(data->polys[index].start()));
const int looptri_i = poly_to_tri_count(index, int(data->polys[index].start()));
mesh_calc_tessellation_for_face_impl(data->corner_verts,
data->polys,
data->positions,
uint(index),
&data->mlooptri[tri_index],
&data->mlooptri[looptri_i],
&tls_data->pf_arena,
true,
data->poly_normals[index]);

View File

@ -137,7 +137,7 @@ static ModifierData *modifier_allocate_and_init(ModifierType type)
ModifierData *md = static_cast<ModifierData *>(MEM_callocN(mti->structSize, mti->structName));
/* NOTE: this name must be made unique later. */
BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
STRNCPY(md->name, DATA_(mti->name));
md->type = type;
md->mode = eModifierMode_Realtime | eModifierMode_Render;
@ -329,7 +329,7 @@ ModifierData *BKE_modifier_copy_ex(const ModifierData *md, int flag)
{
ModifierData *md_dst = modifier_allocate_and_init(ModifierType(md->type));
BLI_strncpy(md_dst->name, md->name, sizeof(md_dst->name));
STRNCPY(md_dst->name, md->name);
BKE_modifier_copydata_ex(md, md_dst, flag);
return md_dst;

View File

@ -518,10 +518,10 @@ static void get_proxy_filepath(const MovieClip *clip,
BLI_path_split_dir_file(clip->filepath, clipdir, FILE_MAX, clipfile, FILE_MAX);
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
STRNCPY(dir, clip->proxy.dir);
}
else {
BLI_snprintf(dir, sizeof(dir), "%s" SEP_STR "BL_proxy", clipdir);
SNPRINTF(dir, "%s" SEP_STR "BL_proxy", clipdir);
}
if (undistorted) {
@ -671,7 +671,7 @@ static void movieclip_open_anim_file(MovieClip *clip)
char str[FILE_MAX];
if (!clip->anim) {
BLI_strncpy(str, clip->filepath, FILE_MAX);
STRNCPY(str, clip->filepath);
BLI_path_abs(str, ID_BLEND_PATH_FROM_GLOBAL(&clip->id));
/* FIXME: make several stream accessible in image editor, too */
@ -680,7 +680,7 @@ static void movieclip_open_anim_file(MovieClip *clip)
if (clip->anim) {
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
char dir[FILE_MAX];
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
STRNCPY(dir, clip->proxy.dir);
BLI_path_abs(dir, BKE_main_blendfile_path_from_global());
IMB_anim_set_index_dir(clip->anim, dir);
}
@ -935,7 +935,7 @@ static bool put_imbuf_cache(
struct MovieCache *moviecache;
// char cache_name[64];
// BLI_snprintf(cache_name, sizeof(cache_name), "movie %s", clip->id.name);
// SNPRINTF(cache_name, "movie %s", clip->id.name);
clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
@ -1018,7 +1018,7 @@ static void detect_clip_source(Main *bmain, MovieClip *clip)
ImBuf *ibuf;
char filepath[FILE_MAX];
BLI_strncpy(filepath, clip->filepath, sizeof(filepath));
STRNCPY(filepath, clip->filepath);
BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));
ibuf = IMB_testiffname(filepath, IB_rect | IB_multilayer);
@ -1037,7 +1037,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath)
int file;
char str[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* exists? */
@ -1051,7 +1051,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath)
/* create a short library name */
clip = movieclip_alloc(bmain, BLI_path_basename(filepath));
BLI_strncpy(clip->filepath, filepath, sizeof(clip->filepath));
STRNCPY(clip->filepath, filepath);
detect_clip_source(bmain, clip);
@ -1072,12 +1072,12 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b
MovieClip *clip;
char str[FILE_MAX], strtest[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
BLI_strncpy(strtest, clip->filepath, sizeof(clip->filepath));
STRNCPY(strtest, clip->filepath);
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &clip->id));
if (BLI_path_cmp(strtest, str) == 0) {

View File

@ -517,7 +517,7 @@ NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act, const bool is_libo
nlt = BKE_nlatrack_new_tail(&adt->nla_tracks, is_liboverride);
BKE_nlatrack_set_active(&adt->nla_tracks, nlt);
BKE_nlatrack_add_strip(nlt, strip, is_liboverride);
BLI_strncpy(nlt->name, act->id.name + 2, sizeof(nlt->name));
STRNCPY(nlt->name, act->id.name + 2);
}
/* automatically name it too */
@ -1798,18 +1798,16 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
if (strip->name[0] == 0) {
switch (strip->type) {
case NLASTRIP_TYPE_CLIP: /* act-clip */
BLI_strncpy(strip->name,
(strip->act) ? (strip->act->id.name + 2) : ("<No Action>"),
sizeof(strip->name));
STRNCPY(strip->name, (strip->act) ? (strip->act->id.name + 2) : ("<No Action>"));
break;
case NLASTRIP_TYPE_TRANSITION: /* transition */
BLI_strncpy(strip->name, "Transition", sizeof(strip->name));
STRNCPY(strip->name, "Transition");
break;
case NLASTRIP_TYPE_META: /* meta */
BLI_strncpy(strip->name, "Meta", sizeof(strip->name));
STRNCPY(strip->name, "Meta");
break;
default:
BLI_strncpy(strip->name, "NLA Strip", sizeof(strip->name));
STRNCPY(strip->name, "NLA Strip");
break;
}
}
@ -2066,7 +2064,7 @@ bool BKE_nla_action_stash(AnimData *adt, const bool is_liboverride)
BLI_addhead(&adt->nla_tracks, nlt);
}
BLI_strncpy(nlt->name, STASH_TRACK_NAME, sizeof(nlt->name));
STRNCPY(nlt->name, STASH_TRACK_NAME);
BLI_uniquename(
&adt->nla_tracks, nlt, STASH_TRACK_NAME, '.', offsetof(NlaTrack, name), sizeof(nlt->name));

View File

@ -1159,7 +1159,7 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node)
* Data have their own translation option!
* This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler
* than adding "do_translate" flags to this func (and labelfunc() as well). */
BLI_strncpy(node->name, DATA_(ntype->ui_name), NODE_MAXSTR);
STRNCPY(node->name, DATA_(ntype->ui_name));
nodeUniqueName(ntree, node);
/* Generally sockets should be added after the initialization, because the set of sockets might
@ -1596,11 +1596,11 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
if (identifier && identifier[0] != '\0') {
/* use explicit identifier */
BLI_strncpy(auto_identifier, identifier, sizeof(auto_identifier));
STRNCPY(auto_identifier, identifier);
}
else {
/* if no explicit identifier is given, assign a unique identifier based on the name */
BLI_strncpy(auto_identifier, name, sizeof(auto_identifier));
STRNCPY(auto_identifier, name);
}
/* Make the identifier unique. */
BLI_uniquename_cb(
@ -1610,15 +1610,15 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
sock->in_out = in_out;
BLI_strncpy(sock->identifier, auto_identifier, NODE_MAXSTR);
STRNCPY(sock->identifier, auto_identifier);
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
BLI_strncpy(sock->name, name, NODE_MAXSTR);
STRNCPY(sock->name, name);
sock->storage = nullptr;
sock->flag |= SOCK_COLLAPSED;
sock->type = SOCK_CUSTOM; /* int type undefined by default */
BLI_strncpy(sock->idname, idname, sizeof(sock->idname));
STRNCPY(sock->idname, idname);
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(idname));
return sock;
@ -1772,7 +1772,7 @@ void nodeModifySocketType(bNodeTree *ntree,
}
}
BLI_strncpy(sock->idname, idname, sizeof(sock->idname));
STRNCPY(sock->idname, idname);
node_socket_set_typeinfo(ntree, sock, socktype);
}
@ -2327,7 +2327,7 @@ bNode *nodeAddNode(const bContext *C, bNodeTree *ntree, const char *idname)
BLI_addtail(&ntree->nodes, node);
nodeUniqueID(ntree, node);
BLI_strncpy(node->idname, idname, sizeof(node->idname));
STRNCPY(node->idname, idname);
node_set_typeinfo(C, ntree, node, nodeTypeFind(idname));
BKE_ntree_update_tag_node_new(ntree, node);
@ -2898,7 +2898,7 @@ static bNodeTree *ntreeAddTree_do(
BLI_assert(owner_id == nullptr);
}
BLI_strncpy(ntree->idname, idname, sizeof(ntree->idname));
STRNCPY(ntree->idname, idname);
ntree_set_typeinfo(ntree, ntreeTypeFind(idname));
return ntree;
@ -3283,7 +3283,7 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, const bool do_id
char prefix[MAX_IDPROP_NAME * 2];
BLI_str_escape(propname_esc, node->name, sizeof(propname_esc));
BLI_snprintf(prefix, sizeof(prefix), "nodes[\"%s\"]", propname_esc);
SNPRINTF(prefix, "nodes[\"%s\"]", propname_esc);
if (BKE_animdata_fix_paths_remove(&ntree->id, prefix)) {
if (bmain != nullptr) {
@ -3538,7 +3538,7 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
bNodeSocket *sock = MEM_cnew<bNodeSocket>("socket template");
sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname));
STRNCPY(sock->idname, stype->idname);
sock->in_out = int(in_out);
sock->type = int(SOCK_CUSTOM); /* int type undefined by default */
node_socket_set_typeinfo(ntree, sock, stype);
@ -3547,15 +3547,15 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
const int own_index = ntree->cur_index++;
/* use the own_index as socket identifier */
if (in_out == SOCK_IN) {
BLI_snprintf(sock->identifier, MAX_NAME, "Input_%d", own_index);
SNPRINTF(sock->identifier, "Input_%d", own_index);
}
else {
BLI_snprintf(sock->identifier, MAX_NAME, "Output_%d", own_index);
SNPRINTF(sock->identifier, "Output_%d", own_index);
}
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
BLI_strncpy(sock->name, name, NODE_MAXSTR);
STRNCPY(sock->name, name);
sock->storage = nullptr;
sock->flag |= SOCK_COLLAPSED;
@ -4158,7 +4158,7 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh
*/
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
case ID: \
BLI_strncpy(ntype->idname, #Category #StructName, sizeof(ntype->idname)); \
STRNCPY(ntype->idname, #Category #StructName); \
ntype->rna_ext.srna = RNA_struct_find(#Category #StructName); \
BLI_assert(ntype->rna_ext.srna != nullptr); \
RNA_struct_blender_type_set(ntype->rna_ext.srna, ntype); \
@ -4172,7 +4172,7 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh
BLI_assert(ntype->idname[0] != '\0');
ntype->type = type;
BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name));
STRNCPY(ntype->ui_name, name);
ntype->nclass = nclass;
node_type_base_defaults(ntype);
@ -4186,9 +4186,9 @@ void node_type_base_custom(bNodeType *ntype,
const char *name,
const short nclass)
{
BLI_strncpy(ntype->idname, idname, sizeof(ntype->idname));
STRNCPY(ntype->idname, idname);
ntype->type = NODE_CUSTOM;
BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name));
STRNCPY(ntype->ui_name, name);
ntype->nclass = nclass;
node_type_base_defaults(ntype);
@ -4247,7 +4247,7 @@ void node_type_socket_templates(bNodeType *ntype,
}
for (bNodeSocketTemplate *ntemp = inputs; ntemp->type >= 0; ntemp++) {
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
STRNCPY(ntemp->identifier, ntemp->name);
unique_socket_template_identifier(inputs, ntemp, ntemp->identifier, '_');
}
}
@ -4258,7 +4258,7 @@ void node_type_socket_templates(bNodeType *ntype,
}
for (bNodeSocketTemplate *ntemp = outputs; ntemp->type >= 0; ntemp++) {
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
STRNCPY(ntemp->identifier, ntemp->name);
unique_socket_template_identifier(outputs, ntemp, ntemp->identifier, '_');
}
}
@ -4302,7 +4302,7 @@ void node_type_storage(bNodeType *ntype,
const bNode *src_node))
{
if (storagename) {
BLI_strncpy(ntype->storagename, storagename, sizeof(ntype->storagename));
STRNCPY(ntype->storagename, storagename);
}
else {
ntype->storagename[0] = '\0';

View File

@ -709,37 +709,42 @@ class NodeTreeMainUpdater {
ntree.ensure_topology_cache();
ntree.runtime->runtime_flag = 0;
if (ntree.type != NTREE_SHADER) {
return;
}
/* Check if a used node group has an animated image. */
for (const bNode *group_node : ntree.nodes_by_type("ShaderNodeGroup")) {
for (const bNode *group_node : ntree.group_nodes()) {
const bNodeTree *group = reinterpret_cast<bNodeTree *>(group_node->id);
if (group != nullptr) {
ntree.runtime->runtime_flag |= group->runtime->runtime_flag;
}
}
/* Check if the tree itself has an animated image. */
for (const StringRefNull idname : {"ShaderNodeTexImage", "ShaderNodeTexEnvironment"}) {
for (const bNode *node : ntree.nodes_by_type(idname)) {
Image *image = reinterpret_cast<Image *>(node->id);
if (image != nullptr && BKE_image_is_animated(image)) {
ntree.runtime->runtime_flag |= NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION;
if (ntree.type == NTREE_SHADER) {
/* Check if the tree itself has an animated image. */
for (const StringRefNull idname : {"ShaderNodeTexImage", "ShaderNodeTexEnvironment"}) {
for (const bNode *node : ntree.nodes_by_type(idname)) {
Image *image = reinterpret_cast<Image *>(node->id);
if (image != nullptr && BKE_image_is_animated(image)) {
ntree.runtime->runtime_flag |= NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION;
break;
}
}
}
/* Check if the tree has a material output. */
for (const StringRefNull idname : {"ShaderNodeOutputMaterial",
"ShaderNodeOutputLight",
"ShaderNodeOutputWorld",
"ShaderNodeOutputAOV"})
{
const Span<const bNode *> nodes = ntree.nodes_by_type(idname);
if (!nodes.is_empty()) {
ntree.runtime->runtime_flag |= NTREE_RUNTIME_FLAG_HAS_MATERIAL_OUTPUT;
break;
}
}
}
/* Check if the tree has a material output. */
for (const StringRefNull idname : {"ShaderNodeOutputMaterial",
"ShaderNodeOutputLight",
"ShaderNodeOutputWorld",
"ShaderNodeOutputAOV"})
{
const Span<const bNode *> nodes = ntree.nodes_by_type(idname);
if (!nodes.is_empty()) {
ntree.runtime->runtime_flag |= NTREE_RUNTIME_FLAG_HAS_MATERIAL_OUTPUT;
break;
if (ntree.type == NTREE_GEOMETRY) {
/* Check if there is a simulation zone. */
if (!ntree.nodes_by_type("GeometryNodeSimulationOutput").is_empty()) {
ntree.runtime->runtime_flag |= NTREE_RUNTIME_FLAG_HAS_SIMULATION_ZONE;
}
}
}

Some files were not shown because too many files have changed in this diff Show More