Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2020-07-16 18:45:15 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-07-16 18:45:15 +0300
commit5f87af907d6bdb28754299d08fa5cdb065f9c35e (patch)
tree14e1be6c69f64493a3cea1d9791d510f8b0a6458
parent030e86768b0acfb74e488e099673e4926c19953b (diff)
parent09a483a3aac34f0f4226de0bd23d7ec7e6eb3c4e (diff)
Merge branch 'master' into greasepencil-edit-curve
-rw-r--r--CMakeLists.txt6
-rw-r--r--build_files/build_environment/CMakeLists.txt8
-rw-r--r--build_files/build_environment/cmake/clang.cmake5
-rw-r--r--build_files/build_environment/cmake/harvest.cmake12
-rw-r--r--build_files/build_environment/cmake/llvm.cmake8
-rw-r--r--build_files/build_environment/cmake/numpy.cmake1
-rw-r--r--build_files/build_environment/cmake/opencolorio.cmake7
-rw-r--r--build_files/build_environment/cmake/openmp.cmake1
-rw-r--r--build_files/build_environment/cmake/options.cmake26
-rw-r--r--build_files/build_environment/cmake/png.cmake4
-rw-r--r--build_files/build_environment/cmake/python.cmake8
-rw-r--r--build_files/build_environment/cmake/sqlite.cmake2
-rw-r--r--build_files/build_environment/cmake/ssl.cmake2
-rw-r--r--build_files/build_environment/cmake/ssl.conf5
-rw-r--r--build_files/build_environment/cmake/theora.cmake1
-rw-r--r--build_files/build_environment/cmake/vpx.cmake6
-rw-r--r--build_files/build_environment/cmake/x264.cmake11
-rw-r--r--build_files/build_environment/patches/blosc.diff38
-rw-r--r--build_files/build_environment/patches/numpy.diff27
-rw-r--r--build_files/build_environment/patches/opencollada.diff44
-rw-r--r--build_files/build_environment/patches/openmp.diff23
-rw-r--r--build_files/build_environment/patches/python_macos.diff289
-rw-r--r--build_files/build_environment/patches/sqlite.diff14
-rw-r--r--build_files/build_environment/patches/theora.diff18
-rw-r--r--build_files/build_environment/patches/usd.diff33
-rw-r--r--build_files/cmake/Modules/GTestTesting.cmake5
-rw-r--r--build_files/cmake/macros.cmake36
-rw-r--r--build_files/cmake/platform/platform_apple.cmake16
-rw-r--r--build_files/cmake/platform/platform_apple_xcode.cmake21
-rwxr-xr-xbuild_files/utils/make_utils.py2
-rw-r--r--extern/mantaflow/helper/util/vectorbase.h30
-rw-r--r--extern/mantaflow/preprocessed/gitinfo.h2
-rw-r--r--extern/mantaflow/preprocessed/mesh.cpp4
-rw-r--r--extern/mantaflow/preprocessed/particle.cpp4
-rw-r--r--extern/mantaflow/preprocessed/plugin/initplugins.cpp144
-rw-r--r--extern/mantaflow/preprocessed/registration.cpp4
-rw-r--r--intern/libmv/CMakeLists.txt2
-rw-r--r--release/darwin/background.tifbin33768 -> 143624 bytes
-rw-r--r--release/darwin/buildbot/background.tifbin20286 -> 220950 bytes
-rw-r--r--release/scripts/presets/keyconfig/blender.py15
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/blender_default.py14
-rw-r--r--release/scripts/startup/bl_ui/space_image.py7
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py2
-rw-r--r--source/blender/CMakeLists.txt2
-rw-r--r--source/blender/blenkernel/BKE_node_tree_multi_function.hh32
-rw-r--r--source/blender/blenkernel/CMakeLists.txt15
-rw-r--r--source/blender/blenkernel/intern/armature_test.cc (renamed from tests/gtests/blenkernel/BKE_armature_test.cc)4
-rw-r--r--source/blender/blenkernel/intern/cloth.c20
-rw-r--r--source/blender/blenkernel/intern/fcurve_test.cc (renamed from tests/gtests/blenkernel/BKE_fcurve_test.cc)4
-rw-r--r--source/blender/blenkernel/intern/image.c26
-rw-r--r--source/blender/blenkernel/intern/node_tree_multi_function.cc118
-rw-r--r--source/blender/blenkernel/intern/simulation.cc11
-rw-r--r--source/blender/blenlib/BLI_math_base_safe.h50
-rw-r--r--source/blender/blenlib/CMakeLists.txt3
-rw-r--r--source/blender/blenlib/intern/math_base_safe_inline.c79
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc2
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.cc2
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.h1
-rw-r--r--source/blender/draw/engines/eevee/eevee_lut_gen.c3
-rw-r--r--source/blender/draw/engines/eevee/eevee_render.c1
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c6
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_render.c1
-rw-r--r--source/blender/draw/engines/overlay/overlay_wireframe.c3
-rw-r--r--source/blender/draw/engines/workbench/workbench_render.c1
-rw-r--r--source/blender/draw/intern/draw_hair.c2
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c11
-rw-r--r--source/blender/draw/intern/draw_select_buffer.c17
-rw-r--r--source/blender/draw/intern/draw_view.c8
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c4
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c10
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c9
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c4
-rw-r--r--source/blender/editors/interface/interface.c6
-rw-r--r--source/blender/editors/interface/interface_align.c16
-rw-r--r--source/blender/editors/interface/interface_context_menu.c3
-rw-r--r--source/blender/editors/interface/interface_handlers.c2
-rw-r--r--source/blender/editors/interface/interface_intern.h2
-rw-r--r--source/blender/editors/interface/interface_layout.c7
-rw-r--r--source/blender/editors/interface/interface_ops.c10
-rw-r--r--source/blender/editors/screen/area.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c19
-rw-r--r--source/blender/editors/space_clip/clip_draw.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c4
-rw-r--r--source/blender/editors/util/ed_util_imbuf.c7
-rw-r--r--source/blender/functions/FN_multi_function_builder.hh11
-rw-r--r--source/blender/functions/intern/multi_function_builder.cc29
-rw-r--r--source/blender/gpu/GPU_extensions.h2
-rw-r--r--source/blender/gpu/GPU_framebuffer.h16
-rw-r--r--source/blender/gpu/GPU_state.h6
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c8
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c79
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c4
-rw-r--r--source/blender/gpu/intern/gpu_select_sample_query.c4
-rw-r--r--source/blender/gpu/intern/gpu_state.c32
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c8
-rw-r--r--source/blender/makesrna/RNA_access.h17
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt2
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c36
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c10
-rw-r--r--source/blender/nodes/CMakeLists.txt6
-rw-r--r--source/blender/nodes/shader/node_shader_util.h2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_map_range.cc (renamed from source/blender/nodes/shader/nodes/node_shader_map_range.c)90
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.cc215
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc (renamed from source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c)45
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc32
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.cc (renamed from source/blender/nodes/shader/nodes/node_shader_valToRgb.c)48
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_math.cc102
-rw-r--r--source/blender/render/CMakeLists.txt2
-rw-r--r--source/blender/simulation/CMakeLists.txt (renamed from source/blender/physics/CMakeLists.txt)4
-rw-r--r--source/blender/simulation/SIM_mass_spring.h (renamed from source/blender/physics/BPH_mass_spring.h)28
-rw-r--r--source/blender/simulation/intern/ConstrainedConjugateGradient.h (renamed from source/blender/physics/intern/ConstrainedConjugateGradient.h)0
-rw-r--r--source/blender/simulation/intern/SIM_mass_spring.cpp (renamed from source/blender/physics/intern/BPH_mass_spring.cpp)156
-rw-r--r--source/blender/simulation/intern/eigen_utils.h (renamed from source/blender/physics/intern/eigen_utils.h)0
-rw-r--r--source/blender/simulation/intern/hair_volume.cpp (renamed from source/blender/physics/intern/hair_volume.cpp)26
-rw-r--r--source/blender/simulation/intern/implicit.h (renamed from source/blender/physics/intern/implicit.h)96
-rw-r--r--source/blender/simulation/intern/implicit_blender.c (renamed from source/blender/physics/intern/implicit_blender.c)94
-rw-r--r--source/blender/simulation/intern/implicit_eigen.cpp (renamed from source/blender/physics/intern/implicit_eigen.cpp)70
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c4
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c78
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c9
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c10
-rw-r--r--source/blender/windowmanager/intern/wm_window.c14
-rw-r--r--tests/gtests/CMakeLists.txt13
-rw-r--r--tests/gtests/blenkernel/CMakeLists.txt44
-rw-r--r--tests/gtests/blenlib/BLI_math_base_safe_test.cc37
-rw-r--r--tests/gtests/blenlib/CMakeLists.txt1
-rw-r--r--tests/gtests/runner/CMakeLists.txt63
-rw-r--r--tests/gtests/runner/blender_test.cc25
-rw-r--r--tests/gtests/testing/CMakeLists.txt4
131 files changed, 2300 insertions, 744 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 149b7d93aed..49b974596f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -900,7 +900,7 @@ if(MSVC)
# endianess-detection and auto-setting is counterproductive
# so we just set endianness according CMAKE_OSX_ARCHITECTURES
-elseif(CMAKE_OSX_ARCHITECTURES MATCHES i386 OR CMAKE_OSX_ARCHITECTURES MATCHES x86_64)
+elseif(CMAKE_OSX_ARCHITECTURES MATCHES i386 OR CMAKE_OSX_ARCHITECTURES MATCHES x86_64 OR CMAKE_OSX_ARCHITECTURES MATCHES arm64)
add_definitions(-D__LITTLE_ENDIAN__)
elseif(CMAKE_OSX_ARCHITECTURES MATCHES ppc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc64)
add_definitions(-D__BIG_ENDIAN__)
@@ -1628,10 +1628,6 @@ endif()
#-----------------------------------------------------------------------------
# Libraries
-if(WITH_GTESTS)
- include(GTestTesting)
-endif()
-
if(WITH_BLENDER)
add_subdirectory(intern)
add_subdirectory(extern)
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt
index 7e7c5d58d71..276311fe2d8 100644
--- a/build_files/build_environment/CMakeLists.txt
+++ b/build_files/build_environment/CMakeLists.txt
@@ -94,9 +94,11 @@ if(UNIX)
else()
include(cmake/pugixml.cmake)
endif()
-include(cmake/ispc.cmake)
-include(cmake/openimagedenoise.cmake)
-include(cmake/embree.cmake)
+if((NOT APPLE) OR ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64"))
+ include(cmake/ispc.cmake)
+ include(cmake/openimagedenoise.cmake)
+ include(cmake/embree.cmake)
+endif()
if(NOT APPLE)
include(cmake/xr_openxr.cmake)
endif()
diff --git a/build_files/build_environment/cmake/clang.cmake b/build_files/build_environment/cmake/clang.cmake
index f7dfd434d4a..8b928f968fd 100644
--- a/build_files/build_environment/cmake/clang.cmake
+++ b/build_files/build_environment/cmake/clang.cmake
@@ -30,6 +30,11 @@ else()
set(CLANG_GENERATOR "Unix Makefiles")
endif()
+if(APPLE)
+ set(CLANG_EXTRA_ARGS ${CLANG_EXTRA_ARGS}
+ -DLIBXML2_LIBRARY=${LIBDIR}/xml2/lib/libxml2.a
+ )
+endif()
ExternalProject_Add(external_clang
URL ${CLANG_URI}
diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake
index 33b7f9db192..3f5d2044dbc 100644
--- a/build_files/build_environment/cmake/harvest.cmake
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -42,7 +42,7 @@ if(BUILD_MODE STREQUAL Release)
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/glew/include/ ${HARVEST_TARGET}/opengl/include/ &&
# tiff
${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiff.lib ${HARVEST_TARGET}/tiff/lib/libtiff.lib &&
- ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/ &&
+ ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/
DEPENDS
)
endif()
@@ -132,8 +132,12 @@ harvest(openimageio/bin openimageio/bin "maketx")
harvest(openimageio/bin openimageio/bin "oiiotool")
harvest(openimageio/include openimageio/include "*")
harvest(openimageio/lib openimageio/lib "*.a")
-harvest(openimagedenoise/include openimagedenoise/include "*")
-harvest(openimagedenoise/lib openimagedenoise/lib "*.a")
+if((NOT APPLE) OR ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64"))
+ harvest(openimagedenoise/include openimagedenoise/include "*")
+ harvest(openimagedenoise/lib openimagedenoise/lib "*.a")
+ harvest(embree/include embree/include "*.h")
+ harvest(embree/lib embree/lib "*.a")
+endif()
harvest(openjpeg/include/openjpeg-2.3 openjpeg/include "*.h")
harvest(openjpeg/lib openjpeg/lib "*.a")
harvest(opensubdiv/include opensubdiv/include "*.h")
@@ -168,8 +172,6 @@ harvest(vpx/lib ffmpeg/lib "*.a")
harvest(webp/lib ffmpeg/lib "*.a")
harvest(x264/lib ffmpeg/lib "*.a")
harvest(xvidcore/lib ffmpeg/lib "*.a")
-harvest(embree/include embree/include "*.h")
-harvest(embree/lib embree/lib "*.a")
harvest(usd/include usd/include "*.h")
harvest(usd/lib/usd usd/lib/usd "*")
harvest(usd/plugin usd/plugin "*")
diff --git a/build_files/build_environment/cmake/llvm.cmake b/build_files/build_environment/cmake/llvm.cmake
index 981db9c72b7..8c9a6076068 100644
--- a/build_files/build_environment/cmake/llvm.cmake
+++ b/build_files/build_environment/cmake/llvm.cmake
@@ -16,11 +16,17 @@
#
# ***** END GPL LICENSE BLOCK *****
+if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(LLVM_TARGETS AArch64)
+else()
+ set(LLVM_TARGETS X86)
+endif()
+
set(LLVM_EXTRA_ARGS
-DLLVM_USE_CRT_RELEASE=MD
-DLLVM_USE_CRT_DEBUG=MDd
-DLLVM_INCLUDE_TESTS=OFF
- -DLLVM_TARGETS_TO_BUILD=X86
+ -DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS}
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_ENABLE_TERMINFO=OFF
-DLLVM_BUILD_LLVM_C_DYLIB=OFF
diff --git a/build_files/build_environment/cmake/numpy.cmake b/build_files/build_environment/cmake/numpy.cmake
index abf2464e88c..03316a8fc63 100644
--- a/build_files/build_environment/cmake/numpy.cmake
+++ b/build_files/build_environment/cmake/numpy.cmake
@@ -38,6 +38,7 @@ ExternalProject_Add(external_numpy
PREFIX ${BUILD_DIR}/numpy
PATCH_COMMAND ${NUMPY_PATCH}
CONFIGURE_COMMAND ""
+ PATCH_COMMAND COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff
LOG_BUILD 1
BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build ${NUMPY_BUILD_OPTION} install --old-and-unmanageable
INSTALL_COMMAND ""
diff --git a/build_files/build_environment/cmake/opencolorio.cmake b/build_files/build_environment/cmake/opencolorio.cmake
index 502e9a6c03b..e8b0043edf7 100644
--- a/build_files/build_environment/cmake/opencolorio.cmake
+++ b/build_files/build_environment/cmake/opencolorio.cmake
@@ -30,6 +30,13 @@ set(OPENCOLORIO_EXTRA_ARGS
-DOCIO_STATIC_JNIGLUE=OFF
)
+if(APPLE AND NOT("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64"))
+ set(OPENCOLORIO_EXTRA_ARGS
+ ${OPENCOLORIO_EXTRA_ARGS}
+ -DOCIO_USE_SSE=OFF
+ )
+endif()
+
if(WIN32)
set(OCIO_PATCH opencolorio_win.diff)
set(OPENCOLORIO_EXTRA_ARGS
diff --git a/build_files/build_environment/cmake/openmp.cmake b/build_files/build_environment/cmake/openmp.cmake
index 05b590e4926..ec0756a6693 100644
--- a/build_files/build_environment/cmake/openmp.cmake
+++ b/build_files/build_environment/cmake/openmp.cmake
@@ -22,6 +22,7 @@ ExternalProject_Add(external_openmp
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${OPENMP_HASH}
PREFIX ${BUILD_DIR}/openmp
+ PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openmp/src/external_openmp < ${PATCH_DIR}/openmp.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openmp ${DEFAULT_CMAKE_FLAGS}
INSTALL_COMMAND cd ${BUILD_DIR}/openmp/src/external_openmp-build && install_name_tool -id @executable_path/../Resources/lib/libomp.dylib runtime/src/libomp.dylib && make install
INSTALL_DIR ${LIBDIR}/openmp
diff --git a/build_files/build_environment/cmake/options.cmake b/build_files/build_environment/cmake/options.cmake
index 39334af0bcf..fe2f1fa34e5 100644
--- a/build_files/build_environment/cmake/options.cmake
+++ b/build_files/build_environment/cmake/options.cmake
@@ -117,16 +117,28 @@ else()
COMMAND xcodebuild -version -sdk macosx SDKVersion
OUTPUT_VARIABLE MACOSX_SDK_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(OSX_ARCHITECTURES x86_64)
- set(OSX_DEPLOYMENT_TARGET 10.13)
+ if(NOT CMAKE_OSX_ARCHITECTURES)
+ execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Detected native architecture ${ARCHITECTURE}.")
+ set(CMAKE_OSX_ARCHITECTURES "${ARCHITECTURE}")
+ endif()
+ if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
+ set(OSX_DEPLOYMENT_TARGET 10.13)
+ else()
+ set(OSX_DEPLOYMENT_TARGET 11.00)
+ endif()
set(OSX_SYSROOT ${XCODE_DEV_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk)
- set(PLATFORM_CFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
- set(PLATFORM_CXXFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -std=c++11 -stdlib=libc++")
- set(PLATFORM_LDFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
- set(PLATFORM_BUILD_TARGET --build=x86_64-apple-darwin17.0.0) # OS X 10.13
+ set(PLATFORM_CFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -arch ${CMAKE_OSX_ARCHITECTURES}")
+ set(PLATFORM_CXXFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -std=c++11 -stdlib=libc++ -arch ${CMAKE_OSX_ARCHITECTURES}")
+ set(PLATFORM_LDFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -arch ${CMAKE_OSX_ARCHITECTURES}")
+ if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
+ set(PLATFORM_BUILD_TARGET --build=x86_64-apple-darwin17.0.0) # OS X 10.13
+ else()
+ set(PLATFORM_BUILD_TARGET --build=aarch64-apple-darwin20.0.0) # macOS 11.00
+ endif()
set(PLATFORM_CMAKE_FLAGS
- -DCMAKE_OSX_ARCHITECTURES:STRING=${OSX_ARCHITECTURES}
+ -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${OSX_DEPLOYMENT_TARGET}
-DCMAKE_OSX_SYSROOT:PATH=${OSX_SYSROOT}
)
diff --git a/build_files/build_environment/cmake/png.cmake b/build_files/build_environment/cmake/png.cmake
index 8dd3c25b88b..9f8641873e6 100644
--- a/build_files/build_environment/cmake/png.cmake
+++ b/build_files/build_environment/cmake/png.cmake
@@ -22,6 +22,10 @@ set(PNG_EXTRA_ARGS
-DPNG_STATIC=ON
)
+if(APPLE AND ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64"))
+ set(PNG_EXTRA_ARGS ${PNG_EXTRA_ARGS} -DPNG_HARDWARE_OPTIMIZATIONS=ON -DPNG_ARM_NEON=on -DCMAKE_SYSTEM_PROCESSOR="aarch64")
+endif()
+
ExternalProject_Add(external_png
URL ${PNG_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
diff --git a/build_files/build_environment/cmake/python.cmake b/build_files/build_environment/cmake/python.cmake
index 681b20577d6..9cd56423941 100644
--- a/build_files/build_environment/cmake/python.cmake
+++ b/build_files/build_environment/cmake/python.cmake
@@ -69,12 +69,17 @@ else()
export ac_cv_header_libintl_h=no &&
export ac_cv_lib_intl_textdomain=no
)
+ if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(PYTHON_FUNC_CONFIGS ${PYTHON_FUNC_CONFIGS} && export PYTHON_DECIMAL_WITH_MACHINE=ansi64)
+ endif()
set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV} && ${PYTHON_FUNC_CONFIGS})
set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python.exe)
+ set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_macos.diff)
else()
set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV})
set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python)
- endif()
+ set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_linux.diff)
+ endif()
set(PYTHON_CONFIGURE_EXTRA_ARGS "--with-openssl=${LIBDIR}/ssl")
set(PYTHON_CFLAGS "-I${LIBDIR}/sqlite/include -I${LIBDIR}/bzip2/include -I${LIBDIR}/lzma/include -I${LIBDIR}/zlib/include")
@@ -84,7 +89,6 @@ else()
export CPPFLAGS=${PYTHON_CFLAGS} &&
export LDFLAGS=${PYTHON_LDFLAGS} &&
export PKG_CONFIG_PATH=${LIBDIR}/ffi/lib/pkgconfig)
- set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_linux.diff)
ExternalProject_Add(external_python
URL ${PYTHON_URI}
diff --git a/build_files/build_environment/cmake/sqlite.cmake b/build_files/build_environment/cmake/sqlite.cmake
index 9fa2fa7c708..90330c68811 100644
--- a/build_files/build_environment/cmake/sqlite.cmake
+++ b/build_files/build_environment/cmake/sqlite.cmake
@@ -51,7 +51,7 @@ ExternalProject_Add(external_sqlite
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA1=${SQLITE_HASH}
PREFIX ${BUILD_DIR}/sqlite
- PATCH_COMMAND ${SQLITE_PATCH_CMD}
+ PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/sqlite/src/external_sqlite < ${PATCH_DIR}/sqlite.diff
CONFIGURE_COMMAND ${SQLITE_CONFIGURE_ENV} && cd ${BUILD_DIR}/sqlite/src/external_sqlite/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/sqlite ${SQLITE_CONFIGURATION_ARGS}
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sqlite/src/external_sqlite/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sqlite/src/external_sqlite/ && make install
diff --git a/build_files/build_environment/cmake/ssl.cmake b/build_files/build_environment/cmake/ssl.cmake
index 6d81c6c9a26..e1c168817f4 100644
--- a/build_files/build_environment/cmake/ssl.cmake
+++ b/build_files/build_environment/cmake/ssl.cmake
@@ -20,7 +20,7 @@ set(SSL_CONFIGURE_COMMAND ./Configure)
set(SSL_PATCH_CMD echo .)
if(APPLE)
- set(SSL_OS_COMPILER "blender-darwin-x86_64")
+ set(SSL_OS_COMPILER "blender-darwin-${CMAKE_OSX_ARCHITECTURES}")
else()
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(SSL_EXTRA_ARGS enable-ec_nistp_64_gcc_128)
diff --git a/build_files/build_environment/cmake/ssl.conf b/build_files/build_environment/cmake/ssl.conf
index 818e5a625ab..8a9c9dcab4c 100644
--- a/build_files/build_environment/cmake/ssl.conf
+++ b/build_files/build_environment/cmake/ssl.conf
@@ -12,4 +12,9 @@ my %targets = (
inherit_from => [ "darwin64-x86_64-cc" ],
cflags => add("-fPIC"),
},
+ "blender-darwin-arm64" => {
+ inherit_from => [ "darwin-common" ],
+ cxxflags => add("-fPIC -arch arm64"),
+ cflags => add("-fPIC -arch arm64"),
+ },
);
diff --git a/build_files/build_environment/cmake/theora.cmake b/build_files/build_environment/cmake/theora.cmake
index b1352c40e37..b6f9c589423 100644
--- a/build_files/build_environment/cmake/theora.cmake
+++ b/build_files/build_environment/cmake/theora.cmake
@@ -27,6 +27,7 @@ ExternalProject_Add(external_theora
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA256=${THEORA_HASH}
PREFIX ${BUILD_DIR}/theora
+ PATCH_COMMAND ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/theora/src/external_theora < ${PATCH_DIR}/theora.diff
CONFIGURE_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/theora
--disable-shared
--enable-static
diff --git a/build_files/build_environment/cmake/vpx.cmake b/build_files/build_environment/cmake/vpx.cmake
index 741493859e2..799dea0189c 100644
--- a/build_files/build_environment/cmake/vpx.cmake
+++ b/build_files/build_environment/cmake/vpx.cmake
@@ -24,7 +24,11 @@ if(WIN32)
endif()
else()
if(APPLE)
- set(VPX_EXTRA_FLAGS --target=x86_64-darwin13-gcc)
+ if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(VPX_EXTRA_FLAGS --target=generic-gnu)
+ else()
+ set(VPX_EXTRA_FLAGS --target=x86_64-darwin17-gcc)
+ endif()
else()
set(VPX_EXTRA_FLAGS --target=generic-gnu)
endif()
diff --git a/build_files/build_environment/cmake/x264.cmake b/build_files/build_environment/cmake/x264.cmake
index 96bf031ce83..993e4591cb7 100644
--- a/build_files/build_environment/cmake/x264.cmake
+++ b/build_files/build_environment/cmake/x264.cmake
@@ -22,9 +22,14 @@ endif()
if(APPLE)
- set(X264_CONFIGURE_ENV
- export AS=${LIBDIR}/nasm/bin/nasm
- )
+ if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(X264_EXTRA_ARGS ${X264_EXTRA_ARGS} "--disable-asm")
+ set(X264_CONFIGURE_ENV echo .)
+ else()
+ set(X264_CONFIGURE_ENV
+ export AS=${LIBDIR}/nasm/bin/nasm
+ )
+ endif()
else()
set(X264_CONFIGURE_ENV echo .)
endif()
diff --git a/build_files/build_environment/patches/blosc.diff b/build_files/build_environment/patches/blosc.diff
index ee5826a2e98..0080694fae1 100644
--- a/build_files/build_environment/patches/blosc.diff
+++ b/build_files/build_environment/patches/blosc.diff
@@ -91,3 +91,41 @@ diff -Naur external_blosc.orig/blosc/blosc.c external_blosc/blosc/blosc.c
/* Some useful units */
+ diff --git a/blosc/shuffle.c b/blosc/shuffle.c
+ index 84b5095..23053b4 100644
+ --- a/blosc/shuffle.c
+ +++ b/blosc/shuffle.c
+ @@ -490,12 +490,12 @@ void unshuffle(size_t bytesoftype, size_t blocksize,
+ #else /* no __SSE2__ available */
+
+ void shuffle(size_t bytesoftype, size_t blocksize,
+ - uint8_t* _src, uint8_t* _dest) {
+ + const uint8_t* _src, uint8_t* _dest) {
+ _shuffle(bytesoftype, blocksize, _src, _dest);
+ }
+
+ void unshuffle(size_t bytesoftype, size_t blocksize,
+ - uint8_t* _src, uint8_t* _dest) {
+ + const uint8_t* _src, uint8_t* _dest) {
+ _unshuffle(bytesoftype, blocksize, _src, _dest);
+ }
+ --- a/cmake/FindSSE.cmake
+ +++ b/cmake/FindSSE.cmake
+ @@ -49,6 +49,17 @@
+ set(AVX_FOUND false CACHE BOOL "AVX available on host")
+ ENDIF (AVX_TRUE)
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ + execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
+ + message(STATUS "Detected architecture ${ARCHITECTURE}")
+ + IF("${ARCHITECTURE}" STREQUAL "arm64")
+ + set(SSE2_FOUND false CACHE BOOL "SSE2 available on host")
+ + set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
+ + set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
+ + set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
+ + set(AVX_FOUND false CACHE BOOL "AVX available on host")
+ + return()
+ + ENDIF()
+ +
+ EXEC_PROGRAM("/usr/sbin/sysctl -n machdep.cpu.features" OUTPUT_VARIABLE
+ CPUINFO)
+ \ No newline at end of file
diff --git a/build_files/build_environment/patches/numpy.diff b/build_files/build_environment/patches/numpy.diff
new file mode 100644
index 00000000000..a9b783dd856
--- /dev/null
+++ b/build_files/build_environment/patches/numpy.diff
@@ -0,0 +1,27 @@
+diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
+index ba2b1f4..b10f7df 100644
+--- a/numpy/distutils/system_info.py
++++ b/numpy/distutils/system_info.py
+@@ -2164,8 +2164,8 @@ class accelerate_info(system_info):
+ 'accelerate' in libraries):
+ if intel:
+ args.extend(['-msse3'])
+- else:
+- args.extend(['-faltivec'])
++# else:
++# args.extend(['-faltivec'])
+ args.extend([
+ '-I/System/Library/Frameworks/vecLib.framework/Headers'])
+ link_args.extend(['-Wl,-framework', '-Wl,Accelerate'])
+@@ -2174,8 +2174,8 @@ class accelerate_info(system_info):
+ 'veclib' in libraries):
+ if intel:
+ args.extend(['-msse3'])
+- else:
+- args.extend(['-faltivec'])
++# else:
++# args.extend(['-faltivec'])
+ args.extend([
+ '-I/System/Library/Frameworks/vecLib.framework/Headers'])
+ link_args.extend(['-Wl,-framework', '-Wl,vecLib'])
+
diff --git a/build_files/build_environment/patches/opencollada.diff b/build_files/build_environment/patches/opencollada.diff
index cd4cc2c1652..e8efc1a6909 100644
--- a/build_files/build_environment/patches/opencollada.diff
+++ b/build_files/build_environment/patches/opencollada.diff
@@ -86,3 +86,47 @@ index 1f9a3ee..d151e9a 100644
return isnan( value );
#else
return std::isnan(value);
+
+
+diff --git a/DAEValidator/library/src/Dae.cpp b/DAEValidator/library/src/Dae.cpp
+index 9256ee1..241ad67 100644
+--- a/DAEValidator/library/src/Dae.cpp
++++ b/DAEValidator/library/src/Dae.cpp
+@@ -304,7 +304,7 @@ namespace opencollada
+ if (auto root_node = root())
+ {
+ const auto & nodes = root_node.selectNodes("//*[@id]");
+- for (const auto & node : nodes)
++ for (const auto node : nodes)
+ {
+ string id = node.attribute("id").value();
+ mIdCache.insert(id);
+@@ -312,4 +312,4 @@ namespace opencollada
+ }
+ }
+ }
+-}
+\ No newline at end of file
++}
+diff --git a/DAEValidator/library/src/DaeValidator.cpp b/DAEValidator/library/src/DaeValidator.cpp
+index 715d903..24423ce 100644
+--- a/DAEValidator/library/src/DaeValidator.cpp
++++ b/DAEValidator/library/src/DaeValidator.cpp
+@@ -162,7 +162,7 @@ namespace opencollada
+
+ // Find xsi:schemaLocation attributes in dae and try to validate against specified xsd documents
+ const auto & elements = dae.root().selectNodes("//*[@xsi:schemaLocation]");
+- for (const auto & element : elements)
++ for (const auto element : elements)
+ {
+ if (auto schemaLocation = element.attribute("schemaLocation"))
+ {
+@@ -274,7 +274,7 @@ namespace opencollada
+ int result = 0;
+ map<string, size_t> ids;
+ const auto & nodes = dae.root().selectNodes("//*[@id]");
+- for (const auto & node : nodes)
++ for (const auto node : nodes)
+ {
+ string id = node.attribute("id").value();
+ size_t line = node.line();
diff --git a/build_files/build_environment/patches/openmp.diff b/build_files/build_environment/patches/openmp.diff
new file mode 100644
index 00000000000..201ab5c7713
--- /dev/null
+++ b/build_files/build_environment/patches/openmp.diff
@@ -0,0 +1,23 @@
+diff --git a/runtime/src/z_Linux_asm.S b/runtime/src/z_Linux_asm.S
+index 0d8885e..42aa5ad 100644
+--- a/runtime/src/z_Linux_asm.S
++++ b/runtime/src/z_Linux_asm.S
+@@ -1540,10 +1540,12 @@ __kmp_unnamed_critical_addr:
+ .comm .gomp_critical_user_,32,8
+ .data
+ .align 8
+- .global __kmp_unnamed_critical_addr
+-__kmp_unnamed_critical_addr:
++ .global ___kmp_unnamed_critical_addr
++___kmp_unnamed_critical_addr:
+ .8byte .gomp_critical_user_
+- .size __kmp_unnamed_critical_addr,8
++# if !(KMP_OS_DARWIN)
++ .size ___kmp_unnamed_critical_addr,8
++# endif
+ #endif /* KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 */
+
+ #if KMP_OS_LINUX
+
+
+
diff --git a/build_files/build_environment/patches/python_macos.diff b/build_files/build_environment/patches/python_macos.diff
new file mode 100644
index 00000000000..22ccbebee2f
--- /dev/null
+++ b/build_files/build_environment/patches/python_macos.diff
@@ -0,0 +1,289 @@
+diff -ru a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
+--- a/Doc/library/ctypes.rst 2020-03-10 07:11:12.000000000 +0100
++++ b/Doc/library/ctypes.rst 2020-07-14 08:10:10.000000000 +0200
+@@ -1551,6 +1551,13 @@
+ value usable as argument (integer, string, ctypes instance). This allows
+ defining adapters that can adapt custom objects as function parameters.
+
++ .. attribute:: variadic
++
++ Assign a boolean to specify that the function takes a variable number of
++ arguments. This does not matter on most platforms, but for Apple arm64
++ platforms variadic functions have a different calling convention than
++ normal functions.
++
+ .. attribute:: errcheck
+
+ Assign a Python function or another callable to this attribute. The
+diff -ru a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
+--- a/Modules/_ctypes/_ctypes.c 2020-03-10 07:11:12.000000000 +0100
++++ b/Modules/_ctypes/_ctypes.c 2020-07-14 08:14:41.000000000 +0200
+@@ -3175,6 +3175,35 @@
+ }
+
+ static int
++PyCFuncPtr_set_variadic(PyCFuncPtrObject *self, PyObject *ob, void *Py_UNUSED(ignored))
++{
++ StgDictObject *dict = PyObject_stgdict((PyObject *)self);
++ assert(dict);
++ int r = PyObject_IsTrue(ob);
++ if (r == 1) {
++ dict->flags |= FUNCFLAG_VARIADIC;
++ return 0;
++ } else if (r == 0) {
++ dict->flags &= ~FUNCFLAG_VARIADIC;
++ return 0;
++ } else {
++ return -1;
++ }
++}
++
++static PyObject *
++PyCFuncPtr_get_variadic(PyCFuncPtrObject *self, void *Py_UNUSED(ignored))
++{
++ StgDictObject *dict = PyObject_stgdict((PyObject *)self);
++ assert(dict); /* Cannot be NULL for PyCFuncPtrObject instances */
++ if (dict->flags & FUNCFLAG_VARIADIC)
++ Py_RETURN_TRUE;
++ else
++ Py_RETURN_FALSE;
++}
++
++
++static int
+ PyCFuncPtr_set_argtypes(PyCFuncPtrObject *self, PyObject *ob, void *Py_UNUSED(ignored))
+ {
+ PyObject *converters;
+@@ -5632,6 +5661,7 @@
+ PyModule_AddObject(m, "FUNCFLAG_USE_ERRNO", PyLong_FromLong(FUNCFLAG_USE_ERRNO));
+ PyModule_AddObject(m, "FUNCFLAG_USE_LASTERROR", PyLong_FromLong(FUNCFLAG_USE_LASTERROR));
+ PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyLong_FromLong(FUNCFLAG_PYTHONAPI));
++ PyModule_AddObject(m, "FUNCFLAG_VARIADIC", PyLong_FromLong(FUNCFLAG_VARIADIC));
+ PyModule_AddStringConstant(m, "__version__", "1.1.0");
+
+ PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove));
+diff -ru a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
+--- a/Modules/_ctypes/callproc.c 2020-03-10 07:11:12.000000000 +0100
++++ b/Modules/_ctypes/callproc.c 2020-07-14 08:18:33.000000000 +0200
+@@ -767,7 +767,8 @@
+ ffi_type **atypes,
+ ffi_type *restype,
+ void *resmem,
+- int argcount)
++ int argcount,
++ int argtypecount)
+ {
+ PyThreadState *_save = NULL; /* For Py_BLOCK_THREADS and Py_UNBLOCK_THREADS */
+ PyObject *error_object = NULL;
+@@ -793,15 +794,38 @@
+ if ((flags & FUNCFLAG_CDECL) == 0)
+ cc = FFI_STDCALL;
+ #endif
+- if (FFI_OK != ffi_prep_cif(&cif,
+- cc,
+- argcount,
+- restype,
+- atypes)) {
+- PyErr_SetString(PyExc_RuntimeError,
+- "ffi_prep_cif failed");
+- return -1;
+- }
++#if HAVE_FFI_PREP_CIF_VAR
++ /* Everyone SHOULD set f.variadic=True on variadic function pointers, but
++ * lots of existing code will not. If there's at least one arg and more
++ * args are passed than are defined in the prototype, then it must be a
++ * variadic function. */
++ if ((flags & FUNCFLAG_VARIADIC) ||
++ (argtypecount != 0 && argcount > argtypecount))
++ {
++ if (FFI_OK != ffi_prep_cif_var(&cif,
++ cc,
++ argtypecount,
++ argcount,
++ restype,
++ atypes)) {
++ PyErr_SetString(PyExc_RuntimeError,
++ "ffi_prep_cif_var failed");
++ return -1;
++ }
++ } else {
++#endif
++ if (FFI_OK != ffi_prep_cif(&cif,
++ cc,
++ argcount,
++ restype,
++ atypes)) {
++ PyErr_SetString(PyExc_RuntimeError,
++ "ffi_prep_cif failed");
++ return -1;
++ }
++#if HAVE_FFI_PREP_CIF_VAR
++ }
++#endif
+
+ if (flags & (FUNCFLAG_USE_ERRNO | FUNCFLAG_USE_LASTERROR)) {
+ error_object = _ctypes_get_errobj(&space);
+@@ -1185,9 +1209,8 @@
+
+ if (-1 == _call_function_pointer(flags, pProc, avalues, atypes,
+ rtype, resbuf,
+- Py_SAFE_DOWNCAST(argcount,
+- Py_ssize_t,
+- int)))
++ Py_SAFE_DOWNCAST(argcount, Py_ssize_t, int),
++ Py_SAFE_DOWNCAST(argtype_count, Py_ssize_t, int)))
+ goto cleanup;
+
+ #ifdef WORDS_BIGENDIAN
+diff -ru a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
+--- a/Modules/_ctypes/ctypes.h 2020-03-10 07:11:12.000000000 +0100
++++ b/Modules/_ctypes/ctypes.h 2020-07-14 08:30:53.000000000 +0200
+@@ -285,6 +285,7 @@
+ #define FUNCFLAG_PYTHONAPI 0x4
+ #define FUNCFLAG_USE_ERRNO 0x8
+ #define FUNCFLAG_USE_LASTERROR 0x10
++#define FUNCFLAG_VARIADIC 0x20
+
+ #define TYPEFLAG_ISPOINTER 0x100
+ #define TYPEFLAG_HASPOINTER 0x200
+diff -ru a/configure b/configure
+--- a/configure 2020-03-10 07:11:12.000000000 +0100
++++ b/configure 2020-07-14 08:03:27.000000000 +0200
+@@ -3374,7 +3374,7 @@
+ # has no effect, don't bother defining them
+ Darwin/[6789].*)
+ define_xopen_source=no;;
+- Darwin/1[0-9].*)
++ Darwin/[12][0-9].*)
+ define_xopen_source=no;;
+ # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
+ # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
+@@ -9251,6 +9251,9 @@
+ ppc)
+ MACOSX_DEFAULT_ARCH="ppc64"
+ ;;
++ arm64)
++ MACOSX_DEFAULT_ARCH="arm64"
++ ;;
+ *)
+ as_fn_error $? "Unexpected output of 'arch' on OSX" "$LINENO" 5
+ ;;
+diff -ru a/configure.ac b/configure.ac
+--- a/configure.ac 2020-03-10 07:11:12.000000000 +0100
++++ b/configure.ac 2020-07-14 08:03:27.000000000 +0200
+@@ -2456,6 +2456,9 @@
+ ppc)
+ MACOSX_DEFAULT_ARCH="ppc64"
+ ;;
++ arm64)
++ MACOSX_DEFAULT_ARCH="arm64"
++ ;;
+ *)
+ AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
+ ;;
+diff -ru a/setup.py b/setup.py
+--- a/setup.py 2020-03-10 07:11:12.000000000 +0100
++++ b/setup.py 2020-07-14 08:28:12.000000000 +0200
+@@ -141,6 +141,13 @@
+ os.unlink(tmpfile)
+
+ return MACOS_SDK_ROOT
++
++def is_macosx_at_least(vers):
++ if host_platform == 'darwin':
++ dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
++ if dep_target:
++ return tuple(map(int, dep_target.split('.'))) >= vers
++ return False
+
+ def is_macosx_sdk_path(path):
+ """
+@@ -150,6 +157,13 @@
+ or path.startswith('/System/')
+ or path.startswith('/Library/') )
+
++def grep_headers_for(function, headers):
++ for header in headers:
++ with open(header, 'r') as f:
++ if function in f.read():
++ return True
++ return False
++
+ def find_file(filename, std_dirs, paths):
+ """Searches for the directory where a given file is located,
+ and returns a possibly-empty list of additional directories, or None
+@@ -1972,7 +1986,11 @@
+ return True
+
+ def detect_ctypes(self, inc_dirs, lib_dirs):
+- self.use_system_libffi = False
++ if not sysconfig.get_config_var("LIBFFI_INCLUDEDIR") and is_macosx_at_least((10,15)):
++ self.use_system_libffi = True
++ else:
++ self.use_system_libffi = '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS")
++
+ include_dirs = []
+ extra_compile_args = []
+ extra_link_args = []
+@@ -2016,32 +2034,48 @@
+ ext_test = Extension('_ctypes_test',
+ sources=['_ctypes/_ctypes_test.c'],
+ libraries=['m'])
++ ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
++ ffi_lib = None
++
+ self.extensions.extend([ext, ext_test])
+
+ if host_platform == 'darwin':
+- if '--with-system-ffi' not in sysconfig.get_config_var("CONFIG_ARGS"):
++ if not self.use_system_libffi:
+ return
+- # OS X 10.5 comes with libffi.dylib; the include files are
+- # in /usr/include/ffi
+- inc_dirs.append('/usr/include/ffi')
+-
+- ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
+- if not ffi_inc or ffi_inc[0] == '':
+- ffi_inc = find_file('ffi.h', [], inc_dirs)
+- if ffi_inc is not None:
+- ffi_h = ffi_inc[0] + '/ffi.h'
++ ffi_in_sdk = os.path.join(macosx_sdk_root(), "usr/include/ffi")
++ if os.path.exists(ffi_in_sdk):
++ ffi_inc = ffi_in_sdk
++ ffi_lib = 'ffi'
++ else:
++ # OS X 10.5 comes with libffi.dylib; the include files are
++ # in /usr/include/ffi
++ ffi_inc_dirs.append('/usr/include/ffi')
++
++ if not ffi_inc:
++ found = find_file('ffi.h', [], ffi_inc_dirs)
++ if found:
++ ffi_inc = found[0]
++ if ffi_inc:
++ ffi_h = ffi_inc + '/ffi.h'
+ if not os.path.exists(ffi_h):
+ ffi_inc = None
+ print('Header file {} does not exist'.format(ffi_h))
+- ffi_lib = None
+- if ffi_inc is not None:
++ if ffi_lib is None and ffi_inc:
+ for lib_name in ('ffi', 'ffi_pic'):
+ if (self.compiler.find_library_file(lib_dirs, lib_name)):
+ ffi_lib = lib_name
+ break
+
+ if ffi_inc and ffi_lib:
+- ext.include_dirs.extend(ffi_inc)
++ ffi_headers = glob(os.path.join(ffi_inc, '*.h'))
++ if grep_headers_for('ffi_closure_alloc', ffi_headers):
++ try:
++ sources.remove('_ctypes/malloc_closure.c')
++ except ValueError:
++ pass
++ if grep_headers_for('ffi_prep_cif_var', ffi_headers):
++ ext.extra_compile_args.append("-DHAVE_FFI_PREP_CIF_VAR=1")
++ ext.include_dirs.append(ffi_inc)
+ ext.libraries.append(ffi_lib)
+ self.use_system_libffi = True
+
diff --git a/build_files/build_environment/patches/sqlite.diff b/build_files/build_environment/patches/sqlite.diff
new file mode 100644
index 00000000000..80f1384f9cf
--- /dev/null
+++ b/build_files/build_environment/patches/sqlite.diff
@@ -0,0 +1,14 @@
+Only in external_sqlite_orig: config.log
+diff -ru external_sqlite_orig/config.sub external_sqlite/config.sub
+--- external_sqlite_orig/config.sub 2020-07-10 14:06:42.000000000 +0200
++++ external_sqlite/config.sub 2020-07-10 14:10:24.000000000 +0200
+@@ -314,6 +314,7 @@
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
++ | aarch64-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+Only in external_sqlite: mksourceid
+Only in external_sqlite: sqlite3session.h
diff --git a/build_files/build_environment/patches/theora.diff b/build_files/build_environment/patches/theora.diff
new file mode 100644
index 00000000000..3abadb66be9
--- /dev/null
+++ b/build_files/build_environment/patches/theora.diff
@@ -0,0 +1,18 @@
+--- config.sub
++++ config.sub
+@@ -226,6 +226,7 @@
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
++ | aarch64 \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+@@ -286,6 +287,7 @@
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
++ | aarch64-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
diff --git a/build_files/build_environment/patches/usd.diff b/build_files/build_environment/patches/usd.diff
index 8f457271a5c..fe767829a70 100644
--- a/build_files/build_environment/patches/usd.diff
+++ b/build_files/build_environment/patches/usd.diff
@@ -97,3 +97,36 @@ diff -Naur external_usd_base/cmake/macros/Public.cmake external_usd/cmake/macros
endforeach()
foreach(lib ${PXR_OBJECT_LIBS})
set(objects "${objects};\$<TARGET_OBJECTS:${lib}>")
+
+diff --git a/pxr/base/arch/align.h b/pxr/base/arch/align.h
+index f3cabf4..ebc8a69 100644
+--- a/pxr/base/arch/align.h
++++ b/pxr/base/arch/align.h
+@@ -77,7 +77,11 @@ ArchAlignMemory(void *base)
+ /// The size of a CPU cache line on the current processor architecture in bytes.
+ ///
+ /// \hideinitializer
++#if defined(ARCH_OS_DARWIN) && defined(ARCH_CPU_ARM)
++#define ARCH_CACHE_LINE_SIZE 128
++#else
+ #define ARCH_CACHE_LINE_SIZE 64
++#endif
+
+ ///@}
+
+diff --git a/pxr/base/arch/math.h b/pxr/base/arch/math.h
+index 3e66c37..64a052c 100644
+--- a/pxr/base/arch/math.h
++++ b/pxr/base/arch/math.h
+@@ -42,7 +42,7 @@ PXR_NAMESPACE_OPEN_SCOPE
+ /// \addtogroup group_arch_Math
+ ///@{
+
+-#if defined (ARCH_CPU_INTEL) || defined(doxygen)
++#if defined (ARCH_CPU_INTEL) || defined(ARCH_CPU_ARM) || defined(doxygen)
+
+ /// This is the smallest value e such that 1+e^2 == 1, using floats.
+ /// True for all IEEE754 chipsets.
+
+
+
diff --git a/build_files/cmake/Modules/GTestTesting.cmake b/build_files/cmake/Modules/GTestTesting.cmake
index c36b264a300..ea9a1edeb43 100644
--- a/build_files/cmake/Modules/GTestTesting.cmake
+++ b/build_files/cmake/Modules/GTestTesting.cmake
@@ -37,6 +37,11 @@ macro(BLENDER_SRC_GTEST_EX)
if(WIN32)
set(MANIFEST "${CMAKE_BINARY_DIR}/tests.exe.manifest")
endif()
+
+ add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
+ add_definitions(${GFLAGS_DEFINES})
+ add_definitions(${GLOG_DEFINES})
+
add_executable(${TARGET_NAME} ${ARG_SRC} ${MANIFEST})
target_include_directories(${TARGET_NAME} PUBLIC "${TEST_INC}")
target_include_directories(${TARGET_NAME} SYSTEM PUBLIC "${TEST_INC_SYS}")
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index efe05d0bf5f..708efc3d2f7 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -354,6 +354,42 @@ function(blender_add_lib
set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
endfunction()
+# blender_add_test_lib() is used to define a test library. It is intended to be
+# called in tandem with blender_add_lib(). The test library will be linked into
+# the bf_gtest_runner_test executable (see tests/gtests/CMakeLists.txt).
+function(blender_add_test_lib
+ name
+ sources
+ includes
+ includes_sys
+ library_deps
+ )
+
+ add_cc_flags_custom_test(${name} PARENT_SCOPE)
+
+ # Otherwise external projects will produce warnings that we cannot fix.
+ remove_strict_flags()
+
+ # This duplicates logic that's also in GTestTesting.cmake, macro BLENDER_SRC_GTEST_EX.
+ # TODO(Sybren): deduplicate after the general approach in D7649 has been approved.
+ LIST(APPEND includes
+ ${CMAKE_SOURCE_DIR}/tests/gtests
+ )
+ LIST(APPEND includes_sys
+ ${GLOG_INCLUDE_DIRS}
+ ${GFLAGS_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}/extern/gtest/include
+ ${CMAKE_SOURCE_DIR}/extern/gmock/include
+ )
+ add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
+ add_definitions(${GFLAGS_DEFINES})
+ add_definitions(${GLOG_DEFINES})
+
+ blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}")
+
+ set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name})
+endfunction()
+
# Ninja only: assign 'heavy pool' to some targets that are especially RAM-consuming to build.
function(setup_heavy_lib_pool)
if(WITH_NINJA_POOL_JOBS AND NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index b24d7734423..a80b0b56901 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -20,7 +20,11 @@
# Libraries configuration for Apple.
-set(MACOSX_DEPLOYMENT_TARGET "10.13")
+if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(MACOSX_DEPLOYMENT_TARGET 11.00)
+else()
+ set(MACOSX_DEPLOYMENT_TARGET 10.13)
+endif()
macro(find_package_wrapper)
# do nothing, just satisfy the macro
@@ -378,6 +382,12 @@ if(WITH_CYCLES_OSL)
endif()
endif()
+if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(WITH_CYCLES_EMBREE OFF)
+ set(WITH_OPENIMAGEDENOISE OFF)
+ set(WITH_CPU_SSE OFF)
+endif()
+
if(WITH_CYCLES_EMBREE)
find_package(Embree 3.8.0 REQUIRED)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Xlinker -stack_size -Xlinker 0x100000")
@@ -439,8 +449,8 @@ if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize -fvariable-expansion-in-unroller")
endif()
else()
- set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
- set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
+ set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -fno-strict-aliasing")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -fno-strict-aliasing")
endif()
if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5)
diff --git a/build_files/cmake/platform/platform_apple_xcode.cmake b/build_files/cmake/platform/platform_apple_xcode.cmake
index 434c2ee31b9..3a43ca317dd 100644
--- a/build_files/cmake/platform/platform_apple_xcode.cmake
+++ b/build_files/cmake/platform/platform_apple_xcode.cmake
@@ -21,8 +21,10 @@
# Xcode and system configuration for Apple.
if(NOT CMAKE_OSX_ARCHITECTURES)
- set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
- "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
+ execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Detected native architecture ${ARCHITECTURE}.")
+ set(CMAKE_OSX_ARCHITECTURES ${ARCHITECTURE} CACHE STRING
+ "Choose the architecture you want to build Blender for: arm64 or x86_64"
FORCE)
endif()
@@ -129,14 +131,21 @@ if(${CMAKE_GENERATOR} MATCHES "Xcode")
endif()
unset(OSX_SDKROOT)
+
# 10.13 is our min. target, if you use higher sdk, weak linking happens
+if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(OSX_MIN_DEPLOYMENT_TARGET 11.00)
+else()
+ set(OSX_MIN_DEPLOYMENT_TARGET 10.13)
+endif()
+
if(CMAKE_OSX_DEPLOYMENT_TARGET)
- if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.13)
- message(STATUS "Setting deployment target to 10.13, lower versions are not supported")
- set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "" FORCE)
+ if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS ${OSX_MIN_DEPLOYMENT_TARGET})
+ message(STATUS "Setting deployment target to ${OSX_MIN_DEPLOYMENT_TARGET}, lower versions are not supported")
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "${OSX_MIN_DEPLOYMENT_TARGET}" CACHE STRING "" FORCE)
endif()
else()
- set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "" FORCE)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "${OSX_MIN_DEPLOYMENT_TARGET}" CACHE STRING "" FORCE)
endif()
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
diff --git a/build_files/utils/make_utils.py b/build_files/utils/make_utils.py
index 9a3d25f4952..e94c8e3550a 100755
--- a/build_files/utils/make_utils.py
+++ b/build_files/utils/make_utils.py
@@ -48,7 +48,7 @@ def git_branch(git_command):
def git_tag(git_command):
# Get current tag name.
try:
- tag = subprocess.check_output([git_command, "describe", "--exact-match"])
+ tag = subprocess.check_output([git_command, "describe", "--exact-match"], stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
return None
diff --git a/extern/mantaflow/helper/util/vectorbase.h b/extern/mantaflow/helper/util/vectorbase.h
index 9ccf445f42c..9b4d9c83f0b 100644
--- a/extern/mantaflow/helper/util/vectorbase.h
+++ b/extern/mantaflow/helper/util/vectorbase.h
@@ -439,6 +439,36 @@ inline Real normSquare(const int v)
return square(v);
}
+//! Compute sum of all components, allow use of int, Real too
+template<class S> inline S sum(const S v)
+{
+ return v;
+}
+template<class S> inline S sum(const Vector3D<S> &v)
+{
+ return v.x + v.y + v.z;
+}
+
+//! Get absolute representation of vector, allow use of int, Real too
+inline Real abs(const Real v)
+{
+ return std::fabs(v);
+}
+inline int abs(const int v)
+{
+ return std::abs(v);
+}
+
+template<class S> inline Vector3D<S> abs(const Vector3D<S> &v)
+{
+ Vector3D<S> cp(v.x, v.y, v.z);
+ for (int i = 0; i < 3; ++i) {
+ if (cp[i] < 0)
+ cp[i] *= (-1.0);
+ }
+ return cp;
+}
+
//! Returns a normalized vector
template<class S> inline Vector3D<S> getNormalized(const Vector3D<S> &v)
{
diff --git a/extern/mantaflow/preprocessed/gitinfo.h b/extern/mantaflow/preprocessed/gitinfo.h
index 03dcbb3d9c5..67cede606da 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
-#define MANTA_GIT_VERSION "commit 7395d36e3f504edbdabe34b30edc855b422c7baa"
+#define MANTA_GIT_VERSION "commit 1881a368ed10797e84b470645d7c738ef75ad6d8"
diff --git a/extern/mantaflow/preprocessed/mesh.cpp b/extern/mantaflow/preprocessed/mesh.cpp
index d93c2ac04c0..c99d621d2bd 100644
--- a/extern/mantaflow/preprocessed/mesh.cpp
+++ b/extern/mantaflow/preprocessed/mesh.cpp
@@ -1339,8 +1339,8 @@ template<class T> void MeshDataImpl<T>::setSource(Grid<T> *grid, bool isMAC)
{
mpGridSource = grid;
mGridSourceMAC = isMAC;
- if (isMAC)
- assertMsg(dynamic_cast<MACGrid *>(grid) != NULL, "Given grid is not a valid MAC grid");
+ if (grid && isMAC)
+ assertMsg(grid->getType() & GridBase::TypeMAC, "Given grid is not a valid MAC grid");
}
template<class T> void MeshDataImpl<T>::initNewValue(IndexInt idx, Vec3 pos)
diff --git a/extern/mantaflow/preprocessed/particle.cpp b/extern/mantaflow/preprocessed/particle.cpp
index c719fc8f27d..6e1ef2fa5d8 100644
--- a/extern/mantaflow/preprocessed/particle.cpp
+++ b/extern/mantaflow/preprocessed/particle.cpp
@@ -359,8 +359,8 @@ template<class T> void ParticleDataImpl<T>::setSource(Grid<T> *grid, bool isMAC)
{
mpGridSource = grid;
mGridSourceMAC = isMAC;
- if (isMAC)
- assertMsg(dynamic_cast<MACGrid *>(grid) != NULL, "Given grid is not a valid MAC grid");
+ if (grid && isMAC)
+ assertMsg(grid->getType() & GridBase::TypeMAC, "Given grid is not a valid MAC grid");
}
template<class T> void ParticleDataImpl<T>::initNewValue(IndexInt idx, Vec3 pos)
diff --git a/extern/mantaflow/preprocessed/plugin/initplugins.cpp b/extern/mantaflow/preprocessed/plugin/initplugins.cpp
index 7a765813f9f..6ccd3afc8d1 100644
--- a/extern/mantaflow/preprocessed/plugin/initplugins.cpp
+++ b/extern/mantaflow/preprocessed/plugin/initplugins.cpp
@@ -1479,48 +1479,24 @@ void PbRegister_addTestParts()
}
//! calculate the difference between two pdata fields (note - slow!, not parallelized)
-
-Real pdataMaxDiff(const ParticleDataBase *a, const ParticleDataBase *b)
+template<class T> Real getPdataMaxDiff(const ParticleDataImpl<T> *a, const ParticleDataImpl<T> *b)
{
- double maxVal = 0.;
- // debMsg(" PD "<< a->getType()<<" as"<<a->getSizeSlow()<<" bs"<<b->getSizeSlow() , 1);
assertMsg(a->getType() == b->getType(), "pdataMaxDiff problem - different pdata types!");
assertMsg(a->getSizeSlow() == b->getSizeSlow(), "pdataMaxDiff problem - different pdata sizes!");
- if (a->getType() & ParticleDataBase::TypeReal) {
- const ParticleDataImpl<Real> &av = *dynamic_cast<const ParticleDataImpl<Real> *>(a);
- const ParticleDataImpl<Real> &bv = *dynamic_cast<const ParticleDataImpl<Real> *>(b);
- FOR_PARTS(av)
- {
- maxVal = std::max(maxVal, (double)fabs(av[idx] - bv[idx]));
- }
- }
- else if (a->getType() & ParticleDataBase::TypeInt) {
- const ParticleDataImpl<int> &av = *dynamic_cast<const ParticleDataImpl<int> *>(a);
- const ParticleDataImpl<int> &bv = *dynamic_cast<const ParticleDataImpl<int> *>(b);
- FOR_PARTS(av)
- {
- maxVal = std::max(maxVal, (double)fabs((double)av[idx] - bv[idx]));
- }
- }
- else if (a->getType() & ParticleDataBase::TypeVec3) {
- const ParticleDataImpl<Vec3> &av = *dynamic_cast<const ParticleDataImpl<Vec3> *>(a);
- const ParticleDataImpl<Vec3> &bv = *dynamic_cast<const ParticleDataImpl<Vec3> *>(b);
- FOR_PARTS(av)
- {
- double d = 0.;
- for (int c = 0; c < 3; ++c) {
- d += fabs((double)av[idx][c] - (double)bv[idx][c]);
- }
- maxVal = std::max(maxVal, d);
- }
- }
- else {
- errMsg("pdataMaxDiff: Grid Type is not supported (only Real, Vec3, int)");
+ Real maxVal = 0.;
+ FOR_PARTS(*a)
+ {
+ T diff = a->get(idx) - b->get(idx);
+ Real s = (Real)sum(abs(diff));
+ maxVal = std::max(maxVal, s);
}
-
return maxVal;
}
+Real pdataMaxDiff(const ParticleDataImpl<Real> *a, const ParticleDataImpl<Real> *b)
+{
+ return getPdataMaxDiff(a, b);
+}
static PyObject *_W_15(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
@@ -1531,8 +1507,8 @@ static PyObject *_W_15(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
PyObject *_retval = 0;
{
ArgLocker _lock;
- const ParticleDataBase *a = _args.getPtr<ParticleDataBase>("a", 0, &_lock);
- const ParticleDataBase *b = _args.getPtr<ParticleDataBase>("b", 1, &_lock);
+ const ParticleDataImpl<Real> *a = _args.getPtr<ParticleDataImpl<Real>>("a", 0, &_lock);
+ const ParticleDataImpl<Real> *b = _args.getPtr<ParticleDataImpl<Real>>("b", 1, &_lock);
_retval = toPy(pdataMaxDiff(a, b));
_args.check();
}
@@ -1552,6 +1528,76 @@ void PbRegister_pdataMaxDiff()
}
}
+Real pdataMaxDiffInt(const ParticleDataImpl<int> *a, const ParticleDataImpl<int> *b)
+{
+ return getPdataMaxDiff(a, b);
+}
+static PyObject *_W_16(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+{
+ try {
+ PbArgs _args(_linargs, _kwds);
+ FluidSolver *parent = _args.obtainParent();
+ bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
+ pbPreparePlugin(parent, "pdataMaxDiffInt", !noTiming);
+ PyObject *_retval = 0;
+ {
+ ArgLocker _lock;
+ const ParticleDataImpl<int> *a = _args.getPtr<ParticleDataImpl<int>>("a", 0, &_lock);
+ const ParticleDataImpl<int> *b = _args.getPtr<ParticleDataImpl<int>>("b", 1, &_lock);
+ _retval = toPy(pdataMaxDiffInt(a, b));
+ _args.check();
+ }
+ pbFinalizePlugin(parent, "pdataMaxDiffInt", !noTiming);
+ return _retval;
+ }
+ catch (std::exception &e) {
+ pbSetError("pdataMaxDiffInt", e.what());
+ return 0;
+ }
+}
+static const Pb::Register _RP_pdataMaxDiffInt("", "pdataMaxDiffInt", _W_16);
+extern "C" {
+void PbRegister_pdataMaxDiffInt()
+{
+ KEEP_UNUSED(_RP_pdataMaxDiffInt);
+}
+}
+
+Real pdataMaxDiffVec3(const ParticleDataImpl<Vec3> *a, const ParticleDataImpl<Vec3> *b)
+{
+ return getPdataMaxDiff(a, b);
+}
+static PyObject *_W_17(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+{
+ try {
+ PbArgs _args(_linargs, _kwds);
+ FluidSolver *parent = _args.obtainParent();
+ bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
+ pbPreparePlugin(parent, "pdataMaxDiffVec3", !noTiming);
+ PyObject *_retval = 0;
+ {
+ ArgLocker _lock;
+ const ParticleDataImpl<Vec3> *a = _args.getPtr<ParticleDataImpl<Vec3>>("a", 0, &_lock);
+ const ParticleDataImpl<Vec3> *b = _args.getPtr<ParticleDataImpl<Vec3>>("b", 1, &_lock);
+ _retval = toPy(pdataMaxDiffVec3(a, b));
+ _args.check();
+ }
+ pbFinalizePlugin(parent, "pdataMaxDiffVec3", !noTiming);
+ return _retval;
+ }
+ catch (std::exception &e) {
+ pbSetError("pdataMaxDiffVec3", e.what());
+ return 0;
+ }
+}
+static const Pb::Register _RP_pdataMaxDiffVec3("", "pdataMaxDiffVec3", _W_17);
+extern "C" {
+void PbRegister_pdataMaxDiffVec3()
+{
+ KEEP_UNUSED(_RP_pdataMaxDiffVec3);
+}
+}
+
//! calculate center of mass given density grid, for re-centering
Vec3 calcCenterOfMass(const Grid<Real> &density)
@@ -1567,7 +1613,7 @@ Vec3 calcCenterOfMass(const Grid<Real> &density)
p /= w;
return p;
}
-static PyObject *_W_16(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+static PyObject *_W_18(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1589,7 +1635,7 @@ static PyObject *_W_16(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
return 0;
}
}
-static const Pb::Register _RP_calcCenterOfMass("", "calcCenterOfMass", _W_16);
+static const Pb::Register _RP_calcCenterOfMass("", "calcCenterOfMass", _W_18);
extern "C" {
void PbRegister_calcCenterOfMass()
{
@@ -1789,7 +1835,7 @@ void updateFractions(const FlagGrid &flags,
fractions.setConst(Vec3(0.));
KnUpdateFractions(flags, phiObs, fractions, boundaryWidth, fracThreshold);
}
-static PyObject *_W_17(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+static PyObject *_W_19(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1816,7 +1862,7 @@ static PyObject *_W_17(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
return 0;
}
}
-static const Pb::Register _RP_updateFractions("", "updateFractions", _W_17);
+static const Pb::Register _RP_updateFractions("", "updateFractions", _W_19);
extern "C" {
void PbRegister_updateFractions()
{
@@ -1968,7 +2014,7 @@ void setObstacleFlags(FlagGrid &flags,
{
KnUpdateFlagsObs(flags, fractions, phiObs, phiOut, phiIn, boundaryWidth);
}
-static PyObject *_W_18(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+static PyObject *_W_20(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1996,7 +2042,7 @@ static PyObject *_W_18(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
return 0;
}
}
-static const Pb::Register _RP_setObstacleFlags("", "setObstacleFlags", _W_18);
+static const Pb::Register _RP_setObstacleFlags("", "setObstacleFlags", _W_20);
extern "C" {
void PbRegister_setObstacleFlags()
{
@@ -2113,7 +2159,7 @@ void initVortexVelocity(const Grid<Real> &phiObs,
{
kninitVortexVelocity(phiObs, vel, center, radius);
}
-static PyObject *_W_19(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+static PyObject *_W_21(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -2139,7 +2185,7 @@ static PyObject *_W_19(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
return 0;
}
}
-static const Pb::Register _RP_initVortexVelocity("", "initVortexVelocity", _W_19);
+static const Pb::Register _RP_initVortexVelocity("", "initVortexVelocity", _W_21);
extern "C" {
void PbRegister_initVortexVelocity()
{
@@ -2465,7 +2511,7 @@ int blurMacGrid(MACGrid &oG, MACGrid &tG, float si)
}
return tmGK.mDim;
}
-static PyObject *_W_20(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+static PyObject *_W_22(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -2489,7 +2535,7 @@ static PyObject *_W_20(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
return 0;
}
}
-static const Pb::Register _RP_blurMacGrid("", "blurMacGrid", _W_20);
+static const Pb::Register _RP_blurMacGrid("", "blurMacGrid", _W_22);
extern "C" {
void PbRegister_blurMacGrid()
{
@@ -2501,7 +2547,7 @@ int blurRealGrid(Grid<Real> &oG, Grid<Real> &tG, float si)
{
return blurGrid<Real>(oG, tG, si);
}
-static PyObject *_W_21(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+static PyObject *_W_23(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -2525,7 +2571,7 @@ static PyObject *_W_21(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
return 0;
}
}
-static const Pb::Register _RP_blurRealGrid("", "blurRealGrid", _W_21);
+static const Pb::Register _RP_blurRealGrid("", "blurRealGrid", _W_23);
extern "C" {
void PbRegister_blurRealGrid()
{
diff --git a/extern/mantaflow/preprocessed/registration.cpp b/extern/mantaflow/preprocessed/registration.cpp
index 6c1e68e6523..d5dae479f0e 100644
--- a/extern/mantaflow/preprocessed/registration.cpp
+++ b/extern/mantaflow/preprocessed/registration.cpp
@@ -111,6 +111,8 @@ extern void PbRegister_checkSymmetryVec3();
extern void PbRegister_projectPpmFull();
extern void PbRegister_addTestParts();
extern void PbRegister_pdataMaxDiff();
+extern void PbRegister_pdataMaxDiffInt();
+extern void PbRegister_pdataMaxDiffVec3();
extern void PbRegister_calcCenterOfMass();
extern void PbRegister_updateFractions();
extern void PbRegister_setObstacleFlags();
@@ -306,6 +308,8 @@ void MantaEnsureRegistration()
PbRegister_projectPpmFull();
PbRegister_addTestParts();
PbRegister_pdataMaxDiff();
+ PbRegister_pdataMaxDiffInt();
+ PbRegister_pdataMaxDiffVec3();
PbRegister_calcCenterOfMass();
PbRegister_updateFractions();
PbRegister_setObstacleFlags();
diff --git a/intern/libmv/CMakeLists.txt b/intern/libmv/CMakeLists.txt
index c6078268512..5bb66649529 100644
--- a/intern/libmv/CMakeLists.txt
+++ b/intern/libmv/CMakeLists.txt
@@ -212,6 +212,8 @@ if(WITH_LIBMV)
if(WITH_GTESTS)
+ include(GTestTesting)
+
blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "" "" "")
BLENDER_SRC_GTEST("libmv_predict_tracks" "./libmv/autotrack/predict_tracks_test.cc" "libmv_test_dataset;bf_intern_libmv;extern_ceres")
diff --git a/release/darwin/background.tif b/release/darwin/background.tif
index d8785b9c9a4..65d73a86389 100644
--- a/release/darwin/background.tif
+++ b/release/darwin/background.tif
Binary files differ
diff --git a/release/darwin/buildbot/background.tif b/release/darwin/buildbot/background.tif
index 5253a6bf439..8cf364599b1 100644
--- a/release/darwin/buildbot/background.tif
+++ b/release/darwin/buildbot/background.tif
Binary files differ
diff --git a/release/scripts/presets/keyconfig/blender.py b/release/scripts/presets/keyconfig/blender.py
index 0bff9974aaa..cbdd01b3cbe 100644
--- a/release/scripts/presets/keyconfig/blender.py
+++ b/release/scripts/presets/keyconfig/blender.py
@@ -54,6 +54,15 @@ class Prefs(bpy.types.KeyConfigPreferences):
default='PLAY',
update=update_fn,
)
+ use_alt_click_leader: BoolProperty(
+ name="Alt Click Tool Prompt",
+ description=(
+ "Tapping Alt (without pressing any other keys) shows a prompt in the status-bar\n"
+ "prompting a second keystroke to activate the tool"
+ ),
+ default=False,
+ update=update_fn,
+ )
use_select_all_toggle: BoolProperty(
name="Select All Toggles",
description=(
@@ -164,13 +173,16 @@ class Prefs(bpy.types.KeyConfigPreferences):
col = layout.column()
col.row().prop(self, "select_mouse", text="Select with Mouse Button", expand=True)
col.row().prop(self, "spacebar_action", text="Spacebar Action", expand=True)
+
if is_select_left:
col.row().prop(self, "gizmo_action", text="Activate Gizmo Event", expand=True)
# Checkboxes sub-layout.
col = layout.column()
sub = col.column(align=True)
- sub.prop(self, "use_select_all_toggle")
+ row = sub.row()
+ row.prop(self, "use_select_all_toggle")
+ row.prop(self, "use_alt_click_leader")
# 3DView settings.
col = layout.column()
@@ -217,6 +229,7 @@ def load():
kc_prefs.select_mouse == 'LEFT' and
kc_prefs.gizmo_action == 'DRAG'
),
+ use_alt_click_leader=kc_prefs.use_alt_click_leader,
use_pie_click_drag=kc_prefs.use_pie_click_drag,
),
)
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 241a8240f49..8a9d3052a2e 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -52,6 +52,8 @@ class Params:
"use_v3d_shade_ex_pie",
# Swap orbit/pan keys (for 2D workflows).
"use_v3d_mmb_pan",
+ # Alt click to access tools.
+ "use_alt_click_leader",
# Experimental option.
"use_pie_click_drag",
"v3d_tilde_action",
@@ -73,6 +75,7 @@ class Params:
use_v3d_tab_menu=False,
use_v3d_shade_ex_pie=False,
use_v3d_mmb_pan=False,
+ use_alt_click_leader=False,
use_pie_click_drag=False,
v3d_tilde_action='VIEW',
v3d_alt_mmb_drag_action='RELATIVE',
@@ -126,6 +129,7 @@ class Params:
self.v3d_tilde_action = v3d_tilde_action
self.v3d_alt_mmb_drag_action = v3d_alt_mmb_drag_action
+ self.use_alt_click_leader = use_alt_click_leader
self.use_pie_click_drag = use_pie_click_drag
if not use_pie_click_drag:
self.pie_value = 'PRESS'
@@ -449,11 +453,15 @@ def km_window(params):
op_menu("TOPBAR_MT_file_context_menu", {"type": 'F4', "value": 'PRESS'}),
# Pass through when when no tool-system exists or the fallback isn't available.
("wm.toolbar_fallback_pie", {"type": 'W', "value": 'PRESS', "alt": True}, None),
- # Alt as "Leader-Key".
- ("wm.toolbar_prompt", {"type": 'LEFT_ALT', "value": 'CLICK'}, None),
- ("wm.toolbar_prompt", {"type": 'RIGHT_ALT', "value": 'CLICK'}, None),
])
+ if params.use_alt_click_leader:
+ items.extend([
+ # Alt as "Leader-Key".
+ ("wm.toolbar_prompt", {"type": 'LEFT_ALT', "value": 'CLICK'}, None),
+ ("wm.toolbar_prompt", {"type": 'RIGHT_ALT', "value": 'CLICK'}, None),
+ ])
+
if params.spacebar_action == 'TOOL':
items.append(
("wm.toolbar", {"type": 'SPACE', "value": 'PRESS'}, None),
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 651866cf316..75c1bb5e3f9 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -699,7 +699,12 @@ class IMAGE_HT_header(Header):
# Proportional Editing
row = layout.row(align=True)
- row.prop(tool_settings, "use_proportional_edit", icon_only=True)
+ row.prop(
+ tool_settings,
+ "use_proportional_edit",
+ icon_only=True,
+ icon='PROP_CON' if tool_settings.use_proportional_connected else 'PROP_ON',
+ )
sub = row.row(align=True)
sub.active = tool_settings.use_proportional_edit
sub.prop_with_popover(
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index c7556dad4fe..fe80a0c1c36 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1102,7 +1102,7 @@ class VIEW3D_MT_mirror(Menu):
for axis_index, axis_name in enumerate("XYZ"):
props = layout.operator("transform.mirror", text=f"{axis_name!s} {space_name!s}")
props.constraint_axis[axis_index] = True
- props.orient_type = 'GLOBAL'
+ props.orient_type = space_id
if space_id == 'GLOBAL':
layout.separator()
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 50edb0b55ee..e178b0f7935 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -112,7 +112,7 @@ add_subdirectory(blentranslation)
add_subdirectory(blenloader)
add_subdirectory(depsgraph)
add_subdirectory(ikplugin)
-add_subdirectory(physics)
+add_subdirectory(simulation)
add_subdirectory(gpu)
add_subdirectory(imbuf)
add_subdirectory(nodes)
diff --git a/source/blender/blenkernel/BKE_node_tree_multi_function.hh b/source/blender/blenkernel/BKE_node_tree_multi_function.hh
index dcbd551591f..7219eb1726a 100644
--- a/source/blender/blenkernel/BKE_node_tree_multi_function.hh
+++ b/source/blender/blenkernel/BKE_node_tree_multi_function.hh
@@ -88,6 +88,7 @@ class MFNetworkTreeMap {
void add(const DSocket &dsocket, fn::MFSocket &socket)
{
BLI_assert(dsocket.is_input() == socket.is_input());
+ BLI_assert(dsocket.is_input() || sockets_by_dsocket_id_[dsocket.id()].size() == 0);
sockets_by_dsocket_id_[dsocket.id()].append(&socket);
}
@@ -98,6 +99,8 @@ class MFNetworkTreeMap {
void add(const DOutputSocket &dsocket, fn::MFOutputSocket &socket)
{
+ /* There can be at most one matching output socket. */
+ BLI_assert(sockets_by_dsocket_id_[dsocket.id()].size() == 0);
sockets_by_dsocket_id_[dsocket.id()].append(&socket);
}
@@ -319,11 +322,11 @@ class SocketMFNetworkBuilder : public MFNetworkBuilderBase {
*/
class NodeMFNetworkBuilder : public MFNetworkBuilderBase {
private:
- const DNode &node_;
+ const DNode &dnode_;
public:
- NodeMFNetworkBuilder(CommonMFNetworkBuilderData &common, const DNode &node)
- : MFNetworkBuilderBase(common), node_(node)
+ NodeMFNetworkBuilder(CommonMFNetworkBuilderData &common, const DNode &dnode)
+ : MFNetworkBuilderBase(common), dnode_(dnode)
{
}
@@ -331,10 +334,23 @@ class NodeMFNetworkBuilder : public MFNetworkBuilderBase {
* Tells the builder to build a function that corresponds to the node that is being built. It
* will try to match up sockets.
*/
- template<typename T, typename... Args> void construct_and_set_matching_fn(Args &&... args)
+ template<typename T, typename... Args> T &construct_and_set_matching_fn(Args &&... args)
{
- const fn::MultiFunction &function = this->construct_fn<T>(std::forward<Args>(args)...);
+ T &function = this->construct_fn<T>(std::forward<Args>(args)...);
this->set_matching_fn(function);
+ return function;
+ }
+
+ const fn::MultiFunction &get_not_implemented_fn()
+ {
+ return this->get_default_fn("Not Implemented (" + dnode_.name() + ")");
+ }
+
+ const fn::MultiFunction &get_default_fn(StringRef name);
+
+ const void set_not_implemented()
+ {
+ this->set_matching_fn(this->get_not_implemented_fn());
}
/**
@@ -344,7 +360,7 @@ class NodeMFNetworkBuilder : public MFNetworkBuilderBase {
void set_matching_fn(const fn::MultiFunction &function)
{
fn::MFFunctionNode &node = common_.network.add_function(function);
- common_.network_map.add_try_match(node_, node);
+ common_.network_map.add_try_match(dnode_, node);
}
/**
@@ -352,7 +368,7 @@ class NodeMFNetworkBuilder : public MFNetworkBuilderBase {
*/
bNode &bnode()
{
- return *node_.node_ref().bnode();
+ return *dnode_.node_ref().bnode();
}
/**
@@ -360,7 +376,7 @@ class NodeMFNetworkBuilder : public MFNetworkBuilderBase {
*/
const DNode &dnode() const
{
- return node_;
+ return dnode_;
}
};
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 25710ef29ca..30e6baf1a9d 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -36,7 +36,7 @@ set(INC
../makesrna
../modifiers
../nodes
- ../physics
+ ../simulation
../shader_fx
../render/extern/include
../../../intern/ghost
@@ -701,3 +701,16 @@ blender_add_lib(bf_blenkernel "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# Needed so we can use dna_type_offsets.h for defaults initialization.
add_dependencies(bf_blenkernel bf_dna)
+
+
+if(WITH_GTESTS)
+ set(TEST_SRC
+ intern/armature_test.cc
+ intern/fcurve_test.cc
+ )
+ set(TEST_INC
+ ../editors/include
+ )
+ include(GTestTesting)
+ blender_add_test_lib(bf_blenkernel_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB}")
+endif()
diff --git a/tests/gtests/blenkernel/BKE_armature_test.cc b/source/blender/blenkernel/intern/armature_test.cc
index ed6045081d4..cf17c37bc69 100644
--- a/tests/gtests/blenkernel/BKE_armature_test.cc
+++ b/source/blender/blenkernel/intern/armature_test.cc
@@ -23,6 +23,8 @@
#include "testing/testing.h"
+namespace blender::bke::tests {
+
static const float FLOAT_EPSILON = 1.2e-7;
TEST(mat3_vec_to_roll, UnitMatrix)
@@ -87,3 +89,5 @@ TEST(mat3_vec_to_roll, Rotationmatrix)
EXPECT_NEAR(0.57158958f, roll, FLOAT_EPSILON);
}
}
+
+} // namespace blender::bke::tests
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index f45cd5b679a..467bd68c631 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -47,7 +47,7 @@
#include "BKE_modifier.h"
#include "BKE_pointcache.h"
-#include "BPH_mass_spring.h"
+#include "SIM_mass_spring.h"
// #include "PIL_time.h" /* timing for debug prints */
@@ -344,12 +344,12 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int
return 0;
}
- BKE_cloth_solver_set_positions(clmd);
+ SIM_cloth_solver_set_positions(clmd);
ClothSimSettings *parms = clmd->sim_parms;
if (parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE &&
!(parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE_VOL)) {
- BKE_cloth_solver_set_volume(clmd);
+ SIM_cloth_solver_set_volume(clmd);
}
clmd->clothObject->last_frame = MINFRAME - 1;
@@ -404,7 +404,7 @@ static int do_step_cloth(
// TIMEIT_START(cloth_step)
/* call the solver. */
- ret = BPH_cloth_solve(depsgraph, ob, framenr, clmd, effectors);
+ ret = SIM_cloth_solve(depsgraph, ob, framenr, clmd, effectors);
// TIMEIT_END(cloth_step)
@@ -479,7 +479,7 @@ void clothModifier_do(ClothModifierData *clmd,
if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED ||
(!can_simulate && cache_result == PTCACHE_READ_OLD)) {
- BKE_cloth_solver_set_positions(clmd);
+ SIM_cloth_solver_set_positions(clmd);
cloth_to_object(ob, clmd, vertexCos);
BKE_ptcache_validate(cache, framenr);
@@ -493,7 +493,7 @@ void clothModifier_do(ClothModifierData *clmd,
return;
}
if (cache_result == PTCACHE_READ_OLD) {
- BKE_cloth_solver_set_positions(clmd);
+ SIM_cloth_solver_set_positions(clmd);
}
else if (
/* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */
@@ -537,7 +537,7 @@ void cloth_free_modifier(ClothModifierData *clmd)
cloth = clmd->clothObject;
if (cloth) {
- BPH_cloth_solver_free(clmd);
+ SIM_cloth_solver_free(clmd);
// Free the verts.
if (cloth->verts != NULL) {
@@ -619,7 +619,7 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
printf("cloth_free_modifier_extern in\n");
}
- BPH_cloth_solver_free(clmd);
+ SIM_cloth_solver_free(clmd);
// Free the verts.
if (cloth->verts != NULL) {
@@ -919,10 +919,10 @@ static int cloth_from_object(
}
// init our solver
- BPH_cloth_solver_init(ob, clmd);
+ SIM_cloth_solver_init(ob, clmd);
if (!first) {
- BKE_cloth_solver_set_positions(clmd);
+ SIM_cloth_solver_set_positions(clmd);
}
clmd->clothObject->bvhtree = bvhtree_build_from_cloth(clmd, clmd->coll_parms->epsilon);
diff --git a/tests/gtests/blenkernel/BKE_fcurve_test.cc b/source/blender/blenkernel/intern/fcurve_test.cc
index e994dd43af9..2248cce37e5 100644
--- a/tests/gtests/blenkernel/BKE_fcurve_test.cc
+++ b/source/blender/blenkernel/intern/fcurve_test.cc
@@ -27,6 +27,8 @@ extern "C" {
#include "DNA_anim_types.h"
}
+namespace blender::bke::tests {
+
// Epsilon for floating point comparisons.
static const float EPSILON = 1e-7f;
@@ -209,3 +211,5 @@ TEST(evaluate_fcurve, ExtrapolationBezierKeys)
BKE_fcurve_free(fcu);
}
+
+} // namespace blender::bke::tests
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 647349108e1..a246265c3f2 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -5213,24 +5213,32 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, bool *r_is_in_ran
void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
{
if (iuser) {
- bool is_in_range;
- const int framenr = BKE_image_user_frame_get(iuser, cfra, &is_in_range);
+ if (ima && BKE_image_is_animated(ima)) {
+ /* Compute current frame for animated image. */
+ bool is_in_range;
+ const int framenr = BKE_image_user_frame_get(iuser, cfra, &is_in_range);
- if (is_in_range) {
- iuser->flag |= IMA_USER_FRAME_IN_RANGE;
+ if (is_in_range) {
+ iuser->flag |= IMA_USER_FRAME_IN_RANGE;
+ }
+ else {
+ iuser->flag &= ~IMA_USER_FRAME_IN_RANGE;
+ }
+
+ iuser->framenr = framenr;
}
else {
- iuser->flag &= ~IMA_USER_FRAME_IN_RANGE;
+ /* Set fixed frame number for still image. */
+ iuser->framenr = 0;
+ iuser->flag |= IMA_USER_FRAME_IN_RANGE;
}
- iuser->framenr = framenr;
-
- if (ima && BKE_image_is_animated(ima) && ima->gpuframenr != framenr) {
+ if (ima && ima->gpuframenr != iuser->framenr) {
/* Note: a single texture and refresh doesn't really work when
* multiple image users may use different frames, this is to
* be improved with perhaps a GPU texture cache. */
ima->gpuflag |= IMA_GPU_REFRESH;
- ima->gpuframenr = framenr;
+ ima->gpuframenr = iuser->framenr;
}
if (iuser->ok == 0) {
diff --git a/source/blender/blenkernel/intern/node_tree_multi_function.cc b/source/blender/blenkernel/intern/node_tree_multi_function.cc
index 4e505db9b9d..537ec056126 100644
--- a/source/blender/blenkernel/intern/node_tree_multi_function.cc
+++ b/source/blender/blenkernel/intern/node_tree_multi_function.cc
@@ -16,6 +16,7 @@
#include "BKE_node_tree_multi_function.hh"
+#include "BLI_color.hh"
#include "BLI_float3.hh"
namespace blender {
@@ -31,6 +32,35 @@ static std::optional<fn::MFDataType> try_get_multi_function_data_type_of_socket(
return bsocket->typeinfo->get_mf_data_type();
}
+const fn::MultiFunction &NodeMFNetworkBuilder::get_default_fn(StringRef name)
+{
+ Vector<fn::MFDataType, 10> input_types;
+ Vector<fn::MFDataType, 10> output_types;
+
+ for (const DInputSocket *dsocket : dnode_.inputs()) {
+ if (dsocket->is_available()) {
+ std::optional<fn::MFDataType> data_type = try_get_multi_function_data_type_of_socket(
+ dsocket->bsocket());
+ if (data_type.has_value()) {
+ input_types.append(*data_type);
+ }
+ }
+ }
+ for (const DOutputSocket *dsocket : dnode_.outputs()) {
+ if (dsocket->is_available()) {
+ std::optional<fn::MFDataType> data_type = try_get_multi_function_data_type_of_socket(
+ dsocket->bsocket());
+ if (data_type.has_value()) {
+ output_types.append(*data_type);
+ }
+ }
+ }
+
+ const fn::MultiFunction &fn = this->construct_fn<fn::CustomMF_DefaultOutput>(
+ name, input_types, output_types);
+ return fn;
+}
+
static void insert_dummy_node(CommonMFNetworkBuilderData &common, const DNode &dnode)
{
constexpr uint stack_capacity = 10;
@@ -138,55 +168,65 @@ static fn::MFOutputSocket *try_find_origin(CommonMFNetworkBuilderData &common,
}
if (from_dsockets.size() == 1) {
- if (is_multi_function_data_socket(from_dsockets[0]->bsocket())) {
- return &common.network_map.lookup(*from_dsockets[0]);
- }
- else {
+ const DOutputSocket &from_dsocket = *from_dsockets[0];
+ if (!from_dsocket.is_available()) {
return nullptr;
}
+ if (is_multi_function_data_socket(from_dsocket.bsocket())) {
+ return &common.network_map.lookup(from_dsocket);
+ }
+ return nullptr;
}
else {
- if (is_multi_function_data_socket(from_group_inputs[0]->bsocket())) {
- return &common.network_map.lookup(*from_group_inputs[0]);
- }
- else {
- return nullptr;
+ const DGroupInput &from_group_input = *from_group_inputs[0];
+ if (is_multi_function_data_socket(from_group_input.bsocket())) {
+ return &common.network_map.lookup(from_group_input);
}
+ return nullptr;
}
}
-static const fn::MultiFunction *try_get_conversion_function(fn::MFDataType from, fn::MFDataType to)
+using ImplicitConversionsMap =
+ Map<std::pair<fn::MFDataType, fn::MFDataType>, const fn::MultiFunction *>;
+
+template<typename From, typename To>
+static void add_implicit_conversion(ImplicitConversionsMap &map)
{
- if (from == fn::MFDataType::ForSingle<float>()) {
- if (to == fn::MFDataType::ForSingle<int32_t>()) {
- static fn::CustomMF_Convert<float, int32_t> function;
- return &function;
- }
- if (to == fn::MFDataType::ForSingle<float3>()) {
- static fn::CustomMF_Convert<float, float3> function;
- return &function;
- }
- }
- if (from == fn::MFDataType::ForSingle<float3>()) {
- if (to == fn::MFDataType::ForSingle<float>()) {
- static fn::CustomMF_SI_SO<float3, float> function{"Vector Length",
- [](float3 a) { return a.length(); }};
- return &function;
- }
- }
- if (from == fn::MFDataType::ForSingle<int32_t>()) {
- if (to == fn::MFDataType::ForSingle<float>()) {
- static fn::CustomMF_Convert<int32_t, float> function;
- return &function;
- }
- if (to == fn::MFDataType::ForSingle<float3>()) {
- static fn::CustomMF_SI_SO<int32_t, float3> function{
- "int32 to float3", [](int32_t a) { return float3((float)a); }};
- return &function;
- }
- }
+ static fn::CustomMF_Convert<From, To> function;
+ map.add({fn::MFDataType::ForSingle<From>(), fn::MFDataType::ForSingle<To>()}, &function);
+}
+
+template<typename From, typename To, typename ConversionF>
+static void add_implicit_conversion(ImplicitConversionsMap &map,
+ StringRef name,
+ ConversionF conversion)
+{
+ static fn::CustomMF_SI_SO<From, To> function{name, conversion};
+ map.add({fn::MFDataType::ForSingle<From>(), fn::MFDataType::ForSingle<To>()}, &function);
+}
- return nullptr;
+static ImplicitConversionsMap get_implicit_conversions()
+{
+ ImplicitConversionsMap conversions;
+ add_implicit_conversion<float, int32_t>(conversions);
+ add_implicit_conversion<float, float3>(conversions);
+ add_implicit_conversion<int32_t, float>(conversions);
+ add_implicit_conversion<float3, float>(
+ conversions, "Vector Length", [](float3 a) { return a.length(); });
+ add_implicit_conversion<int32_t, float3>(
+ conversions, "int32 to float3", [](int32_t a) { return float3((float)a); });
+ add_implicit_conversion<float3, Color4f>(
+ conversions, "float3 to Color4f", [](float3 a) { return Color4f(a.x, a.y, a.z, 1.0f); });
+ add_implicit_conversion<Color4f, float3>(
+ conversions, "Color4f to float3", [](Color4f a) { return float3(a.r, a.g, a.b); });
+ return conversions;
+}
+
+static const fn::MultiFunction *try_get_conversion_function(fn::MFDataType from, fn::MFDataType to)
+{
+ static const ImplicitConversionsMap conversions = get_implicit_conversions();
+ const fn::MultiFunction *function = conversions.lookup_default({from, to}, nullptr);
+ return function;
}
static fn::MFOutputSocket &insert_default_value_for_type(CommonMFNetworkBuilderData &common,
diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
index e735c30ffae..831de084500 100644
--- a/source/blender/blenkernel/intern/simulation.cc
+++ b/source/blender/blenkernel/intern/simulation.cc
@@ -619,9 +619,12 @@ static const ParticleFunction *create_particle_function_for_inputs(
Vector<const ParticleFunctionInput *> per_particle_inputs;
for (const fn::MFOutputSocket *socket : dummy_deps) {
- StringRef attribute_name = attribute_inputs.lookup(socket);
+ const std::string *attribute_name = attribute_inputs.lookup_ptr(socket);
+ if (attribute_name == nullptr) {
+ return nullptr;
+ }
per_particle_inputs.append(&resources.construct<ParticleAttributeInput>(
- AT, attribute_name, socket->data_type().single_type()));
+ AT, *attribute_name, socket->data_type().single_type()));
}
const fn::MultiFunction &per_particle_fn = resources.construct<fn::MFNetworkEvaluator>(
@@ -732,12 +735,12 @@ static void simulation_data_update(Depsgraph *depsgraph, Scene *scene, Simulatio
fn::MFNetwork network;
ResourceCollector resources;
MFNetworkTreeMap network_map = insert_node_tree_into_mf_network(network, tree, resources);
- // WM_clipboard_text_set(tree.to_dot().c_str(), false);
Map<const fn::MFOutputSocket *, std::string> attribute_inputs = deduplicate_attribute_nodes(
network, network_map, tree);
fn::mf_network_optimization::constant_folding(network, resources);
fn::mf_network_optimization::common_subnetwork_elimination(network);
fn::mf_network_optimization::dead_node_removal(network);
+ // WM_clipboard_text_set(network.to_dot().c_str(), false);
Map<std::string, Vector<const ParticleForce *>> forces_by_simulation = collect_forces(
network_map, resources, attribute_inputs);
@@ -763,7 +766,7 @@ static void simulation_data_update(Depsgraph *depsgraph, Scene *scene, Simulatio
for (uint i : positions.index_range()) {
positions[i] = {i / 100.0f, 0, 0};
- velocities[i] = {0, BLI_rng_get_float(rng), BLI_rng_get_float(rng) * 2 + 1};
+ velocities[i] = {0, BLI_rng_get_float(rng) - 0.5f, BLI_rng_get_float(rng) - 0.5f};
ids[i] = i;
}
}
diff --git a/source/blender/blenlib/BLI_math_base_safe.h b/source/blender/blenlib/BLI_math_base_safe.h
new file mode 100644
index 00000000000..88a08c3cbc7
--- /dev/null
+++ b/source/blender/blenlib/BLI_math_base_safe.h
@@ -0,0 +1,50 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __BLI_MATH_BASE_SAFE_H__
+#define __BLI_MATH_BASE_SAFE_H__
+
+/** \file
+ * \ingroup bli
+ *
+ * This file provides safe alternatives to common math functions like sqrt, powf.
+ * In this context "safe" means that the output is not NaN if the input is not NaN.
+ */
+
+#include "BLI_math_base.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+MINLINE float safe_divide(float a, float b);
+MINLINE float safe_modf(float a, float b);
+MINLINE float safe_logf(float a, float base);
+MINLINE float safe_sqrtf(float a);
+MINLINE float safe_inverse_sqrtf(float a);
+MINLINE float safe_asinf(float a);
+MINLINE float safe_acosf(float a);
+MINLINE float safe_powf(float base, float exponent);
+
+#ifdef __cplusplus
+}
+#endif
+
+#if BLI_MATH_DO_INLINE
+# include "intern/math_base_safe_inline.c"
+#endif
+
+#endif /* __BLI_MATH_BASE_SAFE_H__ */
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 1ed5c8e9b10..c6e04d4147a 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -86,6 +86,7 @@ set(SRC
intern/listbase.c
intern/math_base.c
intern/math_base_inline.c
+ intern/math_base_safe_inline.c
intern/math_bits_inline.c
intern/math_color.c
intern/math_color_blend_inline.c
@@ -209,6 +210,7 @@ set(SRC
BLI_map_slots.hh
BLI_math.h
BLI_math_base.h
+ BLI_math_base_safe.h
BLI_math_bits.h
BLI_math_color.h
BLI_math_color_blend.h
@@ -328,6 +330,7 @@ endif()
# no need to compile object files for inline headers.
set_source_files_properties(
intern/math_base_inline.c
+ intern/math_base_safe_inline.c
intern/math_bits_inline.c
intern/math_color_blend_inline.c
intern/math_color_inline.c
diff --git a/source/blender/blenlib/intern/math_base_safe_inline.c b/source/blender/blenlib/intern/math_base_safe_inline.c
new file mode 100644
index 00000000000..5600382e395
--- /dev/null
+++ b/source/blender/blenlib/intern/math_base_safe_inline.c
@@ -0,0 +1,79 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __MATH_BASE_SAFE_INLINE_C__
+#define __MATH_BASE_SAFE_INLINE_C__
+
+#include "BLI_math_base_safe.h"
+#include "BLI_utildefines.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+MINLINE float safe_divide(float a, float b)
+{
+ return (b != 0.0f) ? a / b : 0.0f;
+}
+
+MINLINE float safe_modf(float a, float b)
+{
+ return (b != 0.0f) ? fmodf(a, b) : 0.0f;
+}
+
+MINLINE float safe_logf(float a, float base)
+{
+ if (UNLIKELY(a <= 0.0f || base <= 0.0f)) {
+ return 0.0f;
+ }
+ return safe_divide(logf(a), logf(base));
+}
+
+MINLINE float safe_sqrtf(float a)
+{
+ return sqrtf(MAX2(a, 0.0f));
+}
+
+MINLINE float safe_inverse_sqrtf(float a)
+{
+ return (a > 0.0f) ? 1.0f / sqrtf(a) : 0.0f;
+}
+
+MINLINE float safe_asinf(float a)
+{
+ CLAMP(a, -1.0f, 1.0f);
+ return asinf(a);
+}
+
+MINLINE float safe_acosf(float a)
+{
+ CLAMP(a, -1.0f, 1.0f);
+ return acosf(a);
+}
+
+MINLINE float safe_powf(float base, float exponent)
+{
+ if (UNLIKELY(base < 0.0f && exponent != (int)exponent)) {
+ return 0.0f;
+ }
+ return powf(base, exponent);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MATH_BASE_SAFE_INLINE_C__ */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index f5cc5963253..c8309656f21 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -1831,6 +1831,10 @@ void DepsgraphNodeBuilder::build_scene_audio(Scene *scene)
return;
}
+ OperationNode *audio_entry_node = add_operation_node(
+ &scene->id, NodeType::AUDIO, OperationCode::AUDIO_ENTRY);
+ audio_entry_node->set_as_entry();
+
add_operation_node(&scene->id, NodeType::AUDIO, OperationCode::SOUND_EVAL);
Scene *scene_cow = get_cow_datablock(scene);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 8054946777c..fae67217913 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -2655,8 +2655,10 @@ void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
void DepsgraphRelationBuilder::build_scene_audio(Scene *scene)
{
+ OperationKey scene_audio_entry_key(&scene->id, NodeType::AUDIO, OperationCode::AUDIO_ENTRY);
OperationKey scene_audio_volume_key(&scene->id, NodeType::AUDIO, OperationCode::AUDIO_VOLUME);
OperationKey scene_sound_eval_key(&scene->id, NodeType::AUDIO, OperationCode::SOUND_EVAL);
+ add_relation(scene_audio_entry_key, scene_audio_volume_key, "Audio Entry -> Volume");
add_relation(scene_audio_volume_key, scene_sound_eval_key, "Audio Volume -> Sound");
if (scene->audio.flag & AUDIO_VOLUME_ANIMATED) {
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc
index 680e7757ebb..a32a43e2905 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc
@@ -61,6 +61,8 @@ const char *operationCodeAsString(OperationCode opcode)
/* Scene related. */
case OperationCode::SCENE_EVAL:
return "SCENE_EVAL";
+ case OperationCode::AUDIO_ENTRY:
+ return "AUDIO_ENTRY";
case OperationCode::AUDIO_VOLUME:
return "AUDIO_VOLUME";
/* Object related. */
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h
index 87168fc3659..52b6c9a753b 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.h
@@ -61,6 +61,7 @@ enum class OperationCode {
/* Scene related. ------------------------------------------------------- */
SCENE_EVAL,
+ AUDIO_ENTRY,
AUDIO_VOLUME,
/* Object related. ------------------------------------------------------ */
diff --git a/source/blender/draw/engines/eevee/eevee_lut_gen.c b/source/blender/draw/engines/eevee/eevee_lut_gen.c
index 5f20d6fbfb8..6cee05bf015 100644
--- a/source/blender/draw/engines/eevee/eevee_lut_gen.c
+++ b/source/blender/draw/engines/eevee/eevee_lut_gen.c
@@ -76,8 +76,7 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
DRW_draw_pass(pass);
float *data = MEM_mallocN(sizeof(float[3]) * w * h, "lut");
- glReadBuffer(GL_COLOR_ATTACHMENT0);
- glReadPixels(0, 0, w, h, GL_RGB, GL_FLOAT, data);
+ GPU_framebuffer_read_color(fb, 0, 0, w, h, 3, 0, GPU_DATA_FLOAT, data);
printf("{");
for (int i = 0; i < w * h * 3; i += 3) {
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c
index f903fa905e8..787fc16a7da 100644
--- a/source/blender/draw/engines/eevee/eevee_render.c
+++ b/source/blender/draw/engines/eevee/eevee_render.c
@@ -267,6 +267,7 @@ static void eevee_render_color_result(RenderLayer *rl,
BLI_rcti_size_y(rect),
num_channels,
0,
+ GPU_DATA_FLOAT,
rp->rect);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index dded83bacf1..dbad226099e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -525,12 +525,6 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl,
DRW_shgroup_uniform_texture(iter->grp, "gpStrokeTexture", tex_stroke);
iter->tex_stroke = tex_stroke;
}
-
- /* TODO(fclem): This is a quick workaround but
- * ideally we should have this as a permanent bind. */
- const bool is_masked = iter->tgp_ob->layers.last->mask_bits != NULL;
- GPUTexture **mask_tex = (is_masked) ? &iter->pd->mask_tx : &iter->pd->dummy_tx;
- DRW_shgroup_uniform_texture_ref(iter->grp, "gpMaskTexture", mask_tex);
}
bool do_sbuffer = (iter->do_sbuffer_call == DRAW_NOW);
diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c
index bb91bdbe396..4748858a6a8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_render.c
+++ b/source/blender/draw/engines/gpencil/gpencil_render.c
@@ -235,6 +235,7 @@ static void GPENCIL_render_result_combined(struct RenderLayer *rl,
BLI_rcti_size_y(rect),
4,
0,
+ GPU_DATA_FLOAT,
rp->rect);
}
diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.c b/source/blender/draw/engines/overlay/overlay_wireframe.c
index 2135e13ffe0..bf19d799474 100644
--- a/source/blender/draw/engines/overlay/overlay_wireframe.c
+++ b/source/blender/draw/engines/overlay/overlay_wireframe.c
@@ -102,12 +102,9 @@ void OVERLAY_wireframe_cache_init(OVERLAY_Data *vedata)
DRW_shgroup_uniform_bool_copy(grp, "isHair", false);
pd->wires_all_grp[xray][use_coloring] = grp = DRW_shgroup_create(wires_sh, pass);
- DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tx);
DRW_shgroup_uniform_float_copy(grp, "wireStepParam", 1.0f);
pd->wires_hair_grp[xray][use_coloring] = grp = DRW_shgroup_create(wires_sh, pass);
- /* TODO(fclem) texture ref persist */
- DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tx);
DRW_shgroup_uniform_bool_copy(grp, "isHair", true);
DRW_shgroup_uniform_float_copy(grp, "wireStepParam", 10.0f);
}
diff --git a/source/blender/draw/engines/workbench/workbench_render.c b/source/blender/draw/engines/workbench/workbench_render.c
index 9e66bcb07f4..77e16327a43 100644
--- a/source/blender/draw/engines/workbench/workbench_render.c
+++ b/source/blender/draw/engines/workbench/workbench_render.c
@@ -212,6 +212,7 @@ void workbench_render(void *ved, RenderEngine *engine, RenderLayer *render_layer
BLI_rcti_size_y(rect),
4,
0,
+ GPU_DATA_FLOAT,
rp->rect);
workbench_render_result_z(render_layer, viewname, rect);
diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c
index 6cfba0e2a78..cbdcbbf9090 100644
--- a/source/blender/draw/intern/draw_hair.c
+++ b/source/blender/draw/intern/draw_hair.c
@@ -343,7 +343,7 @@ void DRW_hair_update(void)
DRW_draw_pass_subset(g_tf_pass, pr_call->shgrp, pr_call->shgrp);
/* Readback result to main memory. */
- GPU_framebuffer_read_color(fb, 0, 0, width, height, 4, 0, data);
+ GPU_framebuffer_read_color(fb, 0, 0, width, height, 4, 0, GPU_DATA_FLOAT, data);
/* Upload back to VBO. */
GPU_vertbuf_use(pr_call->vbo);
glBufferSubData(GL_ARRAY_BUFFER,
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 59b4e9af14e..e0609533691 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -98,12 +98,7 @@ void drw_state_set(DRWState state)
{
int test;
if ((test = CHANGED_TO(DRW_STATE_WRITE_DEPTH))) {
- if (test == 1) {
- glDepthMask(GL_TRUE);
- }
- else {
- glDepthMask(GL_FALSE);
- }
+ GPU_depth_mask(test == 1);
}
}
@@ -142,10 +137,10 @@ void drw_state_set(DRWState state)
int test;
if ((test = CHANGED_TO(DRW_STATE_WRITE_COLOR))) {
if (test == 1) {
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ GPU_color_mask(true, true, true, true);
}
else {
- glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+ GPU_color_mask(false, false, false, false);
}
}
}
diff --git a/source/blender/draw/intern/draw_select_buffer.c b/source/blender/draw/intern/draw_select_buffer.c
index 558d5441136..84c8d0f861f 100644
--- a/source/blender/draw/intern/draw_select_buffer.c
+++ b/source/blender/draw/intern/draw_select_buffer.c
@@ -84,14 +84,15 @@ uint *DRW_select_buffer_read(struct Depsgraph *depsgraph,
GPUFrameBuffer *select_id_fb = DRW_engine_select_framebuffer_get();
GPU_framebuffer_bind(select_id_fb);
- glReadBuffer(GL_COLOR_ATTACHMENT0);
- glReadPixels(rect_clamp.xmin,
- rect_clamp.ymin,
- BLI_rcti_size_x(&rect_clamp),
- BLI_rcti_size_y(&rect_clamp),
- GL_RED_INTEGER,
- GL_UNSIGNED_INT,
- r_buf);
+ GPU_framebuffer_read_color(select_id_fb,
+ rect_clamp.xmin,
+ rect_clamp.ymin,
+ BLI_rcti_size_x(&rect_clamp),
+ BLI_rcti_size_y(&rect_clamp),
+ 1,
+ 0,
+ GPU_DATA_UNSIGNED_INT,
+ r_buf);
if (!BLI_rcti_compare(rect, &rect_clamp)) {
/* The rect has been clamped so you need to realign the buffer and fill in the blanks */
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 06026d51faf..3c470f802ec 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -103,9 +103,9 @@ void DRW_draw_cursor(void)
Scene *scene = draw_ctx->scene;
ViewLayer *view_layer = draw_ctx->view_layer;
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glDepthMask(GL_FALSE);
- glDisable(GL_DEPTH_TEST);
+ GPU_color_mask(true, true, true, true);
+ GPU_depth_mask(false);
+ GPU_depth_test(false);
if (is_cursor_visible(draw_ctx, scene, view_layer)) {
int co[2];
@@ -217,5 +217,5 @@ void DRW_draw_gizmo_2d(void)
WM_gizmomap_draw(region->gizmo_map, draw_ctx->evil_C, WM_GIZMOMAP_DRAWSTEP_2D);
- glDepthMask(GL_TRUE);
+ GPU_depth_mask(true);
}
diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
index 262f4b78b95..5d7c3a9e717 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
@@ -461,10 +461,6 @@ static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id
GPU_select_load_id(select_id);
dial_draw_intern(C, gz, true, false, clip_plane);
-
- if (clip_plane) {
- glDisable(GL_CLIP_DISTANCE0);
- }
}
static void gizmo_dial_draw(const bContext *C, wmGizmo *gz)
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index 20307e7f809..8c8e6da75c0 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -555,11 +555,8 @@ static void annotation_draw_strokes(const bGPDframe *gpf,
/* check which stroke-drawer to use */
if (dflag & GP_DRAWDATA_ONLY3D) {
const int no_xray = (dflag & GP_DRAWDATA_NO_XRAY);
- int mask_orig = 0;
if (no_xray) {
- glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
- glDepthMask(0);
GPU_depth_test(true);
/* first arg is normally rv3d->dist, but this isn't
@@ -578,7 +575,6 @@ static void annotation_draw_strokes(const bGPDframe *gpf,
}
if (no_xray) {
- glDepthMask(mask_orig);
GPU_depth_test(false);
bglPolygonOffset(0.0, 0.0);
@@ -743,12 +739,18 @@ static void annotation_draw_data(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
+ /* Do not write to depth (avoid self-occlusion). */
+ bool prev_depth_mask = GPU_depth_mask_get();
+ GPU_depth_mask(false);
+
/* draw! */
annotation_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag);
/* turn off alpha blending, then smooth lines */
GPU_blend(false); // alpha blending
GPU_line_smooth(false); // smooth lines
+
+ GPU_depth_mask(prev_depth_mask);
}
/* if we have strokes for scenes (3d view)/clips (movie clip editor)
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 60fd52db707..4df071c84f8 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -306,6 +306,10 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw)
GPU_program_point_size(true);
+ /* Do not write to depth (avoid self-occlusion). */
+ bool prev_depth_mask = GPU_depth_mask_get();
+ GPU_depth_mask(false);
+
bGPDstroke *gps_init = (tgpw->gps) ? tgpw->gps : tgpw->t_gpf->strokes.first;
for (bGPDstroke *gps = gps_init; gps; gps = gps->next) {
@@ -343,11 +347,8 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw)
/* check which stroke-drawer to use */
if (tgpw->dflag & GP_DRAWDATA_ONLY3D) {
const int no_xray = (tgpw->dflag & GP_DRAWDATA_NO_XRAY);
- int mask_orig = 0;
if (no_xray) {
- glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
- glDepthMask(0);
GPU_depth_test(true);
/* first arg is normally rv3d->dist, but this isn't
@@ -393,7 +394,6 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw)
}
}
if (no_xray) {
- glDepthMask(mask_orig);
GPU_depth_test(false);
bglPolygonOffset(0.0, 0.0);
@@ -405,6 +405,7 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw)
}
}
+ GPU_depth_mask(prev_depth_mask);
GPU_program_point_size(false);
}
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 60092febd57..4651234bb66 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -398,8 +398,8 @@ static bool gpencil_render_offscreen(tGPDfill *tgpf)
GPU_matrix_push();
GPU_matrix_identity_set();
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
+ GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
ED_view3d_update_viewmat(
tgpf->depsgraph, tgpf->scene, tgpf->v3d, tgpf->region, NULL, winmat, NULL, true);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index ca89c5f606f..28b86674fdd 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1500,10 +1500,10 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
}
}
-void ui_but_override_flag(uiBut *but)
+void ui_but_override_flag(Main *bmain, uiBut *but)
{
const uint override_status = RNA_property_override_library_status(
- &but->rnapoin, but->rnaprop, but->rnaindex);
+ bmain, &but->rnapoin, but->rnaprop, but->rnaindex);
if (override_status & RNA_OVERRIDE_STATUS_OVERRIDDEN) {
but->flag |= UI_BUT_OVERRIDEN;
@@ -1762,7 +1762,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
}
ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
- ui_but_override_flag(but);
+ ui_but_override_flag(CTX_data_main(C), but);
if (UI_but_is_decorator(but)) {
ui_but_anim_decorate_update_from_flag(but);
}
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c
index 59436276277..8edae5d8740 100644
--- a/source/blender/editors/interface/interface_align.c
+++ b/source/blender/editors/interface/interface_align.c
@@ -31,6 +31,8 @@
#include "interface_intern.h"
+#include "MEM_guardedalloc.h"
+
#ifdef USE_UIBUT_SPATIAL_ALIGN
/**
@@ -416,7 +418,16 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region)
return;
}
- butal_array = alloca(sizeof(*butal_array) * (size_t)num_buttons);
+ /* Note that this is typically less than ~20, and almost always under ~100.
+ * Even so, we can't ensure this value won't exceed available stack memory.
+ * Fallback to allocation instead of using #alloca, see: T78636. */
+ ButAlign butal_array_buf[256];
+ if (num_buttons <= ARRAY_SIZE(butal_array_buf)) {
+ butal_array = butal_array_buf;
+ }
+ else {
+ butal_array = MEM_mallocN(sizeof(*butal_array) * num_buttons, __func__);
+ }
memset(butal_array, 0, sizeof(*butal_array) * (size_t)num_buttons);
/* Second loop: we initialize our ButAlign data for each button. */
@@ -515,6 +526,9 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region)
}
}
}
+ if (butal_array_buf != butal_array) {
+ MEM_freeN(butal_array);
+ }
}
# undef SIDE_TO_UI_BUT_ALIGN
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 565e9d6820b..a08c5c45b6f 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -560,7 +560,8 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
const bool is_array_component = (is_array && but->rnaindex != -1);
const bool is_whole_array = (is_array && but->rnaindex == -1);
- const uint override_status = RNA_property_override_library_status(ptr, prop, -1);
+ const uint override_status = RNA_property_override_library_status(
+ CTX_data_main(C), ptr, prop, -1);
const bool is_overridable = (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0;
/* Set the (button_pointer, button_prop)
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index bad833265d9..43c91f1d2eb 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -8418,7 +8418,7 @@ void UI_context_update_anim_flag(const bContext *C)
for (block = region->uiblocks.first; block; block = block->next) {
for (but = block->buttons.first; but; but = but->next) {
ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
- ui_but_override_flag(but);
+ ui_but_override_flag(CTX_data_main(C), but);
if (UI_but_is_decorator(but)) {
ui_but_anim_decorate_update_from_flag(but);
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index fac78808a9a..a7cbfc23399 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -548,7 +548,7 @@ extern bool ui_but_supports_cycling(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
extern int ui_but_is_pushed_ex(uiBut *but, double *value) ATTR_WARN_UNUSED_RESULT;
extern int ui_but_is_pushed(uiBut *but) ATTR_WARN_UNUSED_RESULT;
-void ui_but_override_flag(uiBut *but);
+void ui_but_override_flag(struct Main *bmain, uiBut *but);
extern void ui_block_bounds_calc(uiBlock *block);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 858b48ba9fa..f027a62cbfd 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -947,8 +947,11 @@ static uiBut *ui_item_with_label(uiLayout *layout,
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
#endif
- /* Always align item with label since text is already given enough space not to overlap. */
- sub = uiLayoutRow(layout, true);
+ /* Previously 'align' was enabled to make sure the label is spaced closely to the button.
+ * Set the space to zero instead as aligning a large number of labels can end up aligning
+ * thousands of buttons when displaying key-map search (a heavy operation), see: T78636. */
+ sub = uiLayoutRow(layout, false);
+ sub->space = 0;
UI_block_layout_set_current(block, sub);
#ifdef UI_PROP_DECORATE
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 5237e2ea3f7..39c1b8bb909 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -510,7 +510,8 @@ static bool override_type_set_button_poll(bContext *C)
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- const uint override_status = RNA_property_override_library_status(&ptr, prop, index);
+ const uint override_status = RNA_property_override_library_status(
+ CTX_data_main(C), &ptr, prop, index);
return (ptr.data && prop && (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE));
}
@@ -556,7 +557,7 @@ static int override_type_set_button_exec(bContext *C, wmOperator *op)
}
IDOverrideLibraryPropertyOperation *opop = RNA_property_override_property_operation_get(
- &ptr, prop, operation, index, true, NULL, &created);
+ CTX_data_main(C), &ptr, prop, operation, index, true, NULL, &created);
if (!created) {
opop->operation = operation;
}
@@ -610,7 +611,8 @@ static bool override_remove_button_poll(bContext *C)
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- const uint override_status = RNA_property_override_library_status(&ptr, prop, index);
+ const uint override_status = RNA_property_override_library_status(
+ CTX_data_main(C), &ptr, prop, index);
return (ptr.data && ptr.owner_id && prop && (override_status & RNA_OVERRIDE_STATUS_OVERRIDDEN));
}
@@ -627,7 +629,7 @@ static int override_remove_button_exec(bContext *C, wmOperator *op)
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
ID *id = ptr.owner_id;
- IDOverrideLibraryProperty *oprop = RNA_property_override_property_find(&ptr, prop, &id);
+ IDOverrideLibraryProperty *oprop = RNA_property_override_property_find(bmain, &ptr, prop, &id);
BLI_assert(oprop != NULL);
BLI_assert(id != NULL && id->override_library != NULL);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 887e26383cf..5016f39065d 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -357,12 +357,12 @@ static void region_draw_status_text(ScrArea *area, ARegion *region)
bool overlap = ED_region_is_overlap(area->spacetype, region->regiontype);
if (overlap) {
- GPU_clear_color(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
+ GPU_clear(GPU_COLOR_BIT);
}
else {
UI_ThemeClearColor(TH_HEADER);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear(GPU_COLOR_BIT);
}
int fontid = BLF_set_default();
@@ -527,7 +527,7 @@ void ED_region_do_draw(bContext *C, ARegion *region)
if (area && area_is_pseudo_minimized(area)) {
UI_ThemeClearColor(TH_EDITOR_OUTLINE);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear(GPU_COLOR_BIT);
return;
}
/* optional header info instead? */
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index be7b824fc3e..527d73ca725 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -638,8 +638,8 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
if (load_tex(brush, vc, zoom, col, primary)) {
GPU_blend(true);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glDepthMask(GL_FALSE);
+ GPU_color_mask(true, true, true, true);
+ GPU_depth_mask(false);
glDepthFunc(GL_ALWAYS);
if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
@@ -758,8 +758,8 @@ static bool paint_draw_cursor_overlay(
float center[2];
GPU_blend(true);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glDepthMask(GL_FALSE);
+ GPU_color_mask(true, true, true, true);
+ GPU_depth_mask(false);
glDepthFunc(GL_ALWAYS);
if (ups->draw_anchored) {
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index c84a3b9cbfc..6c5d6f4ee4e 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -55,9 +55,10 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "GPU_glew.h"
+#include "GPU_framebuffer.h"
#include "GPU_matrix.h"
#include "GPU_state.h"
+#include "GPU_texture.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
@@ -246,7 +247,7 @@ static void imapaint_project(float matrix[4][4], const float co[3], float pco[4]
}
static void imapaint_tri_weights(float matrix[4][4],
- const GLint view[4],
+ const int view[4],
const float v1[3],
const float v2[3],
const float v3[3],
@@ -300,7 +301,7 @@ static void imapaint_pick_uv(
int i, findex;
float p[2], w[3], absw, minabsw;
float matrix[4][4], proj[4][4];
- GLint view[4];
+ int view[4];
const eImagePaintMode mode = scene->toolsettings->imapaint.mode;
const MLoopTri *lt = BKE_mesh_runtime_looptri_ensure(me_eval);
@@ -576,20 +577,16 @@ void paint_sample_color(
}
if (!sample_success) {
- glReadBuffer(GL_FRONT);
- glReadPixels(
- x + region->winrct.xmin, y + region->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
- glReadBuffer(GL_BACK);
+ GPU_frontbuffer_read_pixels(
+ x + region->winrct.xmin, y + region->winrct.ymin, 1, 1, 4, GPU_DATA_UNSIGNED_BYTE, &col);
}
else {
return;
}
}
else {
- glReadBuffer(GL_FRONT);
- glReadPixels(
- x + region->winrct.xmin, y + region->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
- glReadBuffer(GL_BACK);
+ GPU_frontbuffer_read_pixels(
+ x + region->winrct.xmin, y + region->winrct.ymin, 1, 1, 4, GPU_DATA_UNSIGNED_BYTE, &col);
}
cp = (uchar *)&col;
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 68ebd6fed7a..227aa30b277 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -373,8 +373,7 @@ static void draw_stabilization_border(
/* Exclusive OR allows to get orig value when second operand is 0,
* and negative of orig value when second operand is 1. */
- glEnable(GL_COLOR_LOGIC_OP);
- glLogicOp(GL_XOR);
+ GPU_logic_op_xor_set(true);
GPU_matrix_push();
GPU_matrix_translate_2f(x, y);
@@ -399,7 +398,7 @@ static void draw_stabilization_border(
GPU_matrix_pop();
- glDisable(GL_COLOR_LOGIC_OP);
+ GPU_logic_op_xor_set(false);
}
}
@@ -790,15 +789,14 @@ static void draw_marker_areas(SpaceClip *sc,
immUniform1f("dash_width", 6.0f);
immUniform1f("dash_factor", 0.5f);
- glEnable(GL_COLOR_LOGIC_OP);
- glLogicOp(GL_XOR);
+ GPU_logic_op_xor_set(true);
immBegin(GPU_PRIM_LINES, 2);
immVertex2fv(shdr_pos, pos);
immVertex2fv(shdr_pos, marker_pos);
immEnd();
- glDisable(GL_COLOR_LOGIC_OP);
+ GPU_logic_op_xor_set(false);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index aa8fe1d63e5..82840f67699 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1085,7 +1085,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d)
GPU_blend(true);
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- glDepthMask(GL_FALSE); /* don't overwrite zbuf */
+ GPU_depth_mask(false); /* don't overwrite zbuf */
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -1175,7 +1175,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d)
immUnbindProgram();
GPU_blend(false);
- glDepthMask(GL_TRUE);
+ GPU_depth_mask(true);
}
#endif /* WITH_INPUT_NDOF */
diff --git a/source/blender/editors/util/ed_util_imbuf.c b/source/blender/editors/util/ed_util_imbuf.c
index 132a63a8249..3e85342e0d7 100644
--- a/source/blender/editors/util/ed_util_imbuf.c
+++ b/source/blender/editors/util/ed_util_imbuf.c
@@ -447,15 +447,16 @@ void ED_imbuf_sample_draw(const bContext *C, ARegion *region, void *arg_info)
(float[2]){event->x - region->winrct.xmin, event->y - region->winrct.ymin},
(float)(info->sample_size / 2.0f) * sima->zoom);
- glEnable(GL_COLOR_LOGIC_OP);
- glLogicOp(GL_XOR);
+ GPU_logic_op_xor_set(true);
+
GPU_line_width(1.0f);
imm_draw_box_wire_2d(pos,
(float)sample_rect_fl.xmin,
(float)sample_rect_fl.ymin,
(float)sample_rect_fl.xmax,
(float)sample_rect_fl.ymax);
- glDisable(GL_COLOR_LOGIC_OP);
+
+ GPU_logic_op_xor_set(false);
immUnbindProgram();
}
diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh
index 6e7efb21850..c2c95f7c355 100644
--- a/source/blender/functions/FN_multi_function_builder.hh
+++ b/source/blender/functions/FN_multi_function_builder.hh
@@ -302,6 +302,17 @@ template<typename T> class CustomMF_Constant : public MultiFunction {
}
};
+class CustomMF_DefaultOutput : public MultiFunction {
+ private:
+ uint output_amount_;
+
+ public:
+ CustomMF_DefaultOutput(StringRef name,
+ Span<MFDataType> input_types,
+ Span<MFDataType> output_types);
+ void call(IndexMask mask, MFParams params, MFContext context) const override;
+};
+
} // namespace blender::fn
#endif /* __FN_MULTI_FUNCTION_BUILDER_HH__ */
diff --git a/source/blender/functions/intern/multi_function_builder.cc b/source/blender/functions/intern/multi_function_builder.cc
index 889a2595aab..7797c19d563 100644
--- a/source/blender/functions/intern/multi_function_builder.cc
+++ b/source/blender/functions/intern/multi_function_builder.cc
@@ -87,4 +87,33 @@ void CustomMF_GenericConstantArray::call(IndexMask mask,
}
}
+CustomMF_DefaultOutput::CustomMF_DefaultOutput(StringRef name,
+ Span<MFDataType> input_types,
+ Span<MFDataType> output_types)
+ : output_amount_(output_types.size())
+{
+ MFSignatureBuilder signature = this->get_builder(name);
+ for (MFDataType data_type : input_types) {
+ signature.input("Input", data_type);
+ }
+ for (MFDataType data_type : output_types) {
+ signature.output("Output", data_type);
+ }
+}
+void CustomMF_DefaultOutput::call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const
+{
+ for (uint param_index : this->param_indices()) {
+ MFParamType param_type = this->param_type(param_index);
+ if (!param_type.is_output()) {
+ continue;
+ }
+
+ if (param_type.data_type().is_single()) {
+ GMutableSpan span = params.uninitialized_single_output(param_index);
+ const CPPType &type = span.type();
+ type.fill_uninitialized_indices(type.default_value(), span.buffer(), mask);
+ }
+ }
+}
+
} // namespace blender::fn
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index ab54148a2ff..263deeaf28d 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -57,6 +57,8 @@ void GPU_mem_stats_get(int *totalmem, int *freemem);
void GPU_code_generate_glsl_lib(void);
+bool GPU_stereo_quadbuffer_support(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h
index fcbe3ef2a78..6925839256b 100644
--- a/source/blender/gpu/GPU_framebuffer.h
+++ b/source/blender/gpu/GPU_framebuffer.h
@@ -28,7 +28,7 @@
extern "C" {
#endif
-struct GPUTexture;
+#include "GPU_texture.h"
typedef struct GPUAttachment {
struct GPUTexture *tex;
@@ -176,8 +176,15 @@ void GPU_framebuffer_clear(GPUFrameBuffer *fb,
void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const float (*clear_cols)[4]);
void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, int x, int y, int w, int h, float *data);
-void GPU_framebuffer_read_color(
- GPUFrameBuffer *fb, int x, int y, int w, int h, int channels, int slot, float *data);
+void GPU_framebuffer_read_color(GPUFrameBuffer *fb,
+ int x,
+ int y,
+ int w,
+ int h,
+ int channels,
+ int slot,
+ eGPUDataFormat format,
+ void *data);
void GPU_framebuffer_blit(GPUFrameBuffer *fb_read,
int read_slot,
@@ -214,6 +221,9 @@ void GPU_clear_color(float red, float green, float blue, float alpha);
void GPU_clear_depth(float depth);
void GPU_clear(eGPUFrameBufferBits flags);
+void GPU_frontbuffer_read_pixels(
+ int x, int y, int w, int h, int channels, eGPUDataFormat format, void *data);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index 4daf3f8dba5..bdff3e66217 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -65,11 +65,15 @@ void GPU_scissor_get_f(float coords[4]);
void GPU_scissor_get_i(int coords[4]);
void GPU_viewport_size_get_f(float coords[4]);
void GPU_viewport_size_get_i(int coords[4]);
+void GPU_color_mask(bool r, bool g, bool b, bool a);
+void GPU_depth_mask(bool depth);
+bool GPU_depth_mask_get(void);
+void GPU_stencil_mask(uint stencil);
void GPU_flush(void);
void GPU_finish(void);
-void GPU_logic_op_invert_set(bool enable);
+void GPU_logic_op_xor_set(bool enable);
/* Attribute push & pop. */
typedef enum eGPUAttrMask {
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index d1c7aba37df..1c533c80ab7 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -437,3 +437,11 @@ void GPU_mem_stats_get(int *totalmem, int *freemem)
*freemem = 0;
}
}
+
+/* Return support for the active context + window. */
+bool GPU_stereo_quadbuffer_support(void)
+{
+ GLboolean stereo = GL_FALSE;
+ glGetBooleanv(GL_STEREO, &stereo);
+ return stereo == GL_TRUE;
+}
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index 3e806e1a982..366a1d17d69 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -640,31 +640,65 @@ void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, int x, int y, int w, int h,
glReadPixels(x, y, w, h, type, GL_FLOAT, data);
}
-void GPU_framebuffer_read_color(
- GPUFrameBuffer *fb, int x, int y, int w, int h, int channels, int slot, float *data)
+static GLenum gpu_get_gl_datatype(eGPUDataFormat format)
{
- CHECK_FRAMEBUFFER_IS_BOUND(fb);
+ switch (format) {
+ case GPU_DATA_FLOAT:
+ return GL_FLOAT;
+ case GPU_DATA_INT:
+ return GL_INT;
+ case GPU_DATA_UNSIGNED_INT:
+ return GL_UNSIGNED_INT;
+ case GPU_DATA_UNSIGNED_BYTE:
+ return GL_UNSIGNED_BYTE;
+ case GPU_DATA_UNSIGNED_INT_24_8:
+ return GL_UNSIGNED_INT_24_8;
+ case GPU_DATA_10_11_11_REV:
+ return GL_UNSIGNED_INT_10F_11F_11F_REV;
+ default:
+ BLI_assert(!"Unhandled data format");
+ return GL_FLOAT;
+ }
+}
- GLenum type;
+static GLenum gpu_get_gl_channel_type(int channels)
+{
switch (channels) {
case 1:
- type = GL_RED;
- break;
+ return GL_RED;
case 2:
- type = GL_RG;
- break;
+ return GL_RG;
case 3:
- type = GL_RGB;
- break;
+ return GL_RGB;
case 4:
- type = GL_RGBA;
- break;
+ return GL_RGBA;
default:
- BLI_assert(false && "wrong number of read channels");
- return;
+ BLI_assert(!"Wrong number of read channels");
+ return GL_RED;
}
- glReadBuffer(GL_COLOR_ATTACHMENT0 + slot);
- glReadPixels(x, y, w, h, type, GL_FLOAT, data);
+}
+
+static void gpu_framebuffer_read_color_ex(
+ int x, int y, int w, int h, int channels, GLenum readfb, eGPUDataFormat format, float *data)
+{
+ GLenum type = gpu_get_gl_channel_type(channels);
+ GLenum gl_format = gpu_get_gl_datatype(format);
+ glReadBuffer(readfb);
+ glReadPixels(x, y, w, h, type, gl_format, data);
+}
+
+void GPU_framebuffer_read_color(GPUFrameBuffer *fb,
+ int x,
+ int y,
+ int w,
+ int h,
+ int channels,
+ int slot,
+ eGPUDataFormat format,
+ void *data)
+{
+ CHECK_FRAMEBUFFER_IS_BOUND(fb);
+ gpu_framebuffer_read_color_ex(x, y, w, h, channels, GL_COLOR_ATTACHMENT0 + slot, format, data);
}
/* read_slot and write_slot are only used for color buffers. */
@@ -749,9 +783,9 @@ void GPU_framebuffer_blit(GPUFrameBuffer *fb_read,
}
/**
- * Use this if you need to custom down-sample your texture and use the previous mip level as input.
- * This function only takes care of the correct texture handling.
- * It execute the callback for each texture level.
+ * Use this if you need to custom down-sample your texture and use the previous mip level as
+ * input. This function only takes care of the correct texture handling. It execute the callback
+ * for each texture level.
*/
void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *fb,
int max_lvl,
@@ -1035,3 +1069,10 @@ void GPU_clear(eGPUFrameBufferBits flags)
{
glClear(convert_buffer_bits_to_gl(flags));
}
+
+void GPU_frontbuffer_read_pixels(
+ int x, int y, int w, int h, int channels, eGPUDataFormat format, void *data)
+{
+ glReadBuffer(GL_FRONT);
+ gpu_framebuffer_read_color_ex(x, y, w, h, channels, GL_FRONT, format, data);
+} \ No newline at end of file
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 4b38cd333a1..3e5fc1ab19e 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -310,7 +310,7 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c
gpuPushAttr(GPU_DEPTH_BUFFER_BIT | GPU_VIEWPORT_BIT);
/* disable writing to the framebuffer */
- glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+ GPU_color_mask(false, false, false, false);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
@@ -539,7 +539,7 @@ uint gpu_select_pick_end(void)
gpu_select_pick_load_id(ps->gl.prev_id, true);
}
gpuPopAttr();
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ GPU_color_mask(true, true, true, true);
}
/* assign but never free directly since it may be in cache */
diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c
index c82d1e17c66..b20b6cac36b 100644
--- a/source/blender/gpu/intern/gpu_select_sample_query.c
+++ b/source/blender/gpu/intern/gpu_select_sample_query.c
@@ -88,7 +88,7 @@ void gpu_select_query_begin(
gpuPushAttr(GPU_DEPTH_BUFFER_BIT | GPU_VIEWPORT_BIT | GPU_SCISSOR_BIT);
/* disable writing to the framebuffer */
- glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+ GPU_color_mask(false, false, false, false);
/* In order to save some fill rate we minimize the viewport using rect.
* We need to get the region of the viewport so that our geometry doesn't
@@ -206,7 +206,7 @@ uint gpu_select_query_end(void)
MEM_freeN(g_query_state.queries);
MEM_freeN(g_query_state.id);
gpuPopAttr();
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ GPU_color_mask(true, true, true, true);
return hits;
}
diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c
index 30b258a73d1..636a5e2c31d 100644
--- a/source/blender/gpu/intern/gpu_state.c
+++ b/source/blender/gpu/intern/gpu_state.c
@@ -181,20 +181,39 @@ void GPU_finish(void)
glFinish();
}
-void GPU_logic_op_invert_set(bool enable)
+void GPU_logic_op_xor_set(bool enable)
{
if (enable) {
- glLogicOp(GL_INVERT);
+ glLogicOp(GL_XOR);
glEnable(GL_COLOR_LOGIC_OP);
- glDisable(GL_DITHER);
}
else {
- glLogicOp(GL_COPY);
glDisable(GL_COLOR_LOGIC_OP);
- glEnable(GL_DITHER);
}
}
+void GPU_color_mask(bool r, bool g, bool b, bool a)
+{
+ glColorMask(r, g, b, a);
+}
+
+void GPU_depth_mask(bool depth)
+{
+ glDepthMask(depth);
+}
+
+bool GPU_depth_mask_get(void)
+{
+ GLint mask;
+ glGetIntegerv(GL_DEPTH_WRITEMASK, &mask);
+ return mask == GL_TRUE;
+}
+
+void GPU_stencil_mask(uint stencil)
+{
+ glStencilMask(stencil);
+}
+
/** \name GPU Push/Pop State
* \{ */
@@ -207,7 +226,6 @@ typedef struct {
uint is_blend : 1;
uint is_cull_face : 1;
uint is_depth_test : 1;
- uint is_dither : 1;
/* uint is_lighting : 1; */ /* UNUSED */
uint is_line_smooth : 1;
uint is_color_logic_op : 1;
@@ -275,7 +293,6 @@ void gpuPushAttr(eGPUAttrMask mask)
Attr.is_cull_face = glIsEnabled(GL_CULL_FACE);
Attr.is_depth_test = glIsEnabled(GL_DEPTH_TEST);
- Attr.is_dither = glIsEnabled(GL_DITHER);
Attr.is_line_smooth = glIsEnabled(GL_LINE_SMOOTH);
Attr.is_color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP);
Attr.is_multisample = glIsEnabled(GL_MULTISAMPLE);
@@ -339,7 +356,6 @@ void gpuPopAttr(void)
restore_mask(GL_CULL_FACE, Attr.is_cull_face);
restore_mask(GL_DEPTH_TEST, Attr.is_depth_test);
- restore_mask(GL_DITHER, Attr.is_dither);
restore_mask(GL_LINE_SMOOTH, Attr.is_line_smooth);
restore_mask(GL_COLOR_LOGIC_OP, Attr.is_color_logic_op);
restore_mask(GL_MULTISAMPLE, Attr.is_multisample);
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 753da8544ea..4d31366f53f 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -630,13 +630,13 @@ void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo
if (settings == S3D_DISPLAY_ANAGLYPH) {
switch (stereo_format->anaglyph_type) {
case S3D_ANAGLYPH_REDCYAN:
- glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE);
+ GPU_color_mask(false, true, true, true);
break;
case S3D_ANAGLYPH_GREENMAGENTA:
- glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE);
+ GPU_color_mask(true, false, true, true);
break;
case S3D_ANAGLYPH_YELLOWBLUE:
- glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE);
+ GPU_color_mask(false, false, true, true);
break;
}
}
@@ -666,7 +666,7 @@ void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo
GPU_matrix_pop();
if (settings == S3D_DISPLAY_ANAGLYPH) {
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ GPU_color_mask(true, true, true, true);
}
GPU_framebuffer_restore();
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 53bb8899855..6acd9d16f80 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1484,16 +1484,24 @@ void RNA_struct_override_apply(struct Main *bmain,
struct PointerRNA *ptr_storage,
struct IDOverrideLibrary *override);
-struct IDOverrideLibraryProperty *RNA_property_override_property_find(PointerRNA *ptr,
+struct IDOverrideLibraryProperty *RNA_property_override_property_find(struct Main *bmain,
+ PointerRNA *ptr,
PropertyRNA *prop,
struct ID **r_owner_id);
-struct IDOverrideLibraryProperty *RNA_property_override_property_get(PointerRNA *ptr,
+struct IDOverrideLibraryProperty *RNA_property_override_property_get(struct Main *bmain,
+ PointerRNA *ptr,
PropertyRNA *prop,
bool *r_created);
struct IDOverrideLibraryPropertyOperation *RNA_property_override_property_operation_find(
- PointerRNA *ptr, PropertyRNA *prop, const int index, const bool strict, bool *r_strict);
+ struct Main *bmain,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ const int index,
+ const bool strict,
+ bool *r_strict);
struct IDOverrideLibraryPropertyOperation *RNA_property_override_property_operation_get(
+ struct Main *bmain,
PointerRNA *ptr,
PropertyRNA *prop,
const short operation,
@@ -1502,7 +1510,8 @@ struct IDOverrideLibraryPropertyOperation *RNA_property_override_property_operat
bool *r_strict,
bool *r_created);
-eRNAOverrideStatus RNA_property_override_library_status(PointerRNA *ptr,
+eRNAOverrideStatus RNA_property_override_library_status(struct Main *bmainm,
+ PointerRNA *ptr,
PropertyRNA *prop,
const int index);
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index c2f1e204073..a6ed705ec67 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -360,7 +360,7 @@ blender_include_dirs(
../../imbuf
../../makesdna
../../nodes/
- ../../physics
+ ../../simulation
../../windowmanager
../../editors/include
../../render/extern/include
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index 1b846fd898c..e4af02f70fe 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -1052,7 +1052,8 @@ void RNA_struct_override_apply(Main *bmain,
#endif
}
-static char *rna_property_override_property_real_id_owner(PointerRNA *ptr,
+static char *rna_property_override_property_real_id_owner(Main *bmain,
+ PointerRNA *ptr,
PropertyRNA *prop,
ID **r_id)
{
@@ -1079,10 +1080,9 @@ static char *rna_property_override_property_real_id_owner(PointerRNA *ptr,
rna_path_prefix = "shape_keys.";
break;
case ID_GR:
- /* Master collection, TODO. */
- break;
case ID_NT:
- /* Root node trees, TODO. */
+ /* Master collections, Root node trees. */
+ owner_id = RNA_find_real_ID_and_path(bmain, id, &rna_path_prefix);
break;
default:
BLI_assert(0);
@@ -1107,13 +1107,15 @@ static char *rna_property_override_property_real_id_owner(PointerRNA *ptr,
return NULL;
}
-IDOverrideLibraryProperty *RNA_property_override_property_find(PointerRNA *ptr,
+IDOverrideLibraryProperty *RNA_property_override_property_find(Main *bmain,
+ PointerRNA *ptr,
PropertyRNA *prop,
ID **r_owner_id)
{
char *rna_path;
- if ((rna_path = rna_property_override_property_real_id_owner(ptr, prop, r_owner_id)) != NULL) {
+ if ((rna_path = rna_property_override_property_real_id_owner(bmain, ptr, prop, r_owner_id)) !=
+ NULL) {
IDOverrideLibraryProperty *op = BKE_lib_override_library_property_find(
(*r_owner_id)->override_library, rna_path);
MEM_freeN(rna_path);
@@ -1122,14 +1124,15 @@ IDOverrideLibraryProperty *RNA_property_override_property_find(PointerRNA *ptr,
return NULL;
}
-IDOverrideLibraryProperty *RNA_property_override_property_get(PointerRNA *ptr,
+IDOverrideLibraryProperty *RNA_property_override_property_get(Main *bmain,
+ PointerRNA *ptr,
PropertyRNA *prop,
bool *r_created)
{
ID *id;
char *rna_path;
- if ((rna_path = rna_property_override_property_real_id_owner(ptr, prop, &id)) != NULL) {
+ if ((rna_path = rna_property_override_property_real_id_owner(bmain, ptr, prop, &id)) != NULL) {
IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
id->override_library, rna_path, r_created);
MEM_freeN(rna_path);
@@ -1139,10 +1142,15 @@ IDOverrideLibraryProperty *RNA_property_override_property_get(PointerRNA *ptr,
}
IDOverrideLibraryPropertyOperation *RNA_property_override_property_operation_find(
- PointerRNA *ptr, PropertyRNA *prop, const int index, const bool strict, bool *r_strict)
+ Main *bmain,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ const int index,
+ const bool strict,
+ bool *r_strict)
{
ID *owner_id;
- IDOverrideLibraryProperty *op = RNA_property_override_property_find(ptr, prop, &owner_id);
+ IDOverrideLibraryProperty *op = RNA_property_override_property_find(bmain, ptr, prop, &owner_id);
if (!op) {
return NULL;
@@ -1153,6 +1161,7 @@ IDOverrideLibraryPropertyOperation *RNA_property_override_property_operation_fin
}
IDOverrideLibraryPropertyOperation *RNA_property_override_property_operation_get(
+ Main *bmain,
PointerRNA *ptr,
PropertyRNA *prop,
const short operation,
@@ -1161,7 +1170,7 @@ IDOverrideLibraryPropertyOperation *RNA_property_override_property_operation_get
bool *r_strict,
bool *r_created)
{
- IDOverrideLibraryProperty *op = RNA_property_override_property_get(ptr, prop, NULL);
+ IDOverrideLibraryProperty *op = RNA_property_override_property_get(bmain, ptr, prop, NULL);
if (!op) {
return NULL;
@@ -1171,7 +1180,8 @@ IDOverrideLibraryPropertyOperation *RNA_property_override_property_operation_get
op, operation, NULL, NULL, index, index, strict, r_strict, r_created);
}
-eRNAOverrideStatus RNA_property_override_library_status(PointerRNA *ptr,
+eRNAOverrideStatus RNA_property_override_library_status(Main *bmain,
+ PointerRNA *ptr,
PropertyRNA *prop,
const int index)
{
@@ -1186,7 +1196,7 @@ eRNAOverrideStatus RNA_property_override_library_status(PointerRNA *ptr,
}
IDOverrideLibraryPropertyOperation *opop = RNA_property_override_property_operation_find(
- ptr, prop, index, false, NULL);
+ bmain, ptr, prop, index, false, NULL);
if (opop != NULL) {
override_status |= RNA_OVERRIDE_STATUS_OVERRIDDEN;
if (opop->flag & IDOVERRIDE_LIBRARY_FLAG_MANDATORY) {
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 594b77ea1ad..e99bd531c65 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -34,7 +34,7 @@
#include "BKE_cloth.h"
#include "BKE_modifier.h"
-#include "BPH_mass_spring.h"
+#include "SIM_mass_spring.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -482,18 +482,18 @@ static void rna_def_cloth_solver_result(BlenderRNA *brna)
PropertyRNA *prop;
static const EnumPropertyItem status_items[] = {
- {BPH_SOLVER_SUCCESS, "SUCCESS", 0, "Success", "Computation was successful"},
- {BPH_SOLVER_NUMERICAL_ISSUE,
+ {SIM_SOLVER_SUCCESS, "SUCCESS", 0, "Success", "Computation was successful"},
+ {SIM_SOLVER_NUMERICAL_ISSUE,
"NUMERICAL_ISSUE",
0,
"Numerical Issue",
"The provided data did not satisfy the prerequisites"},
- {BPH_SOLVER_NO_CONVERGENCE,
+ {SIM_SOLVER_NO_CONVERGENCE,
"NO_CONVERGENCE",
0,
"No Convergence",
"Iterative procedure did not converge"},
- {BPH_SOLVER_INVALID_INPUT,
+ {SIM_SOLVER_INVALID_INPUT,
"INVALID_INPUT",
0,
"Invalid Input",
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 2381e499eee..9106eacb31a 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -176,7 +176,7 @@ set(SRC
shader/nodes/node_shader_layer_weight.c
shader/nodes/node_shader_light_falloff.c
shader/nodes/node_shader_light_path.c
- shader/nodes/node_shader_map_range.c
+ shader/nodes/node_shader_map_range.cc
shader/nodes/node_shader_mapping.c
shader/nodes/node_shader_math.cc
shader/nodes/node_shader_mixRgb.c
@@ -193,7 +193,7 @@ set(SRC
shader/nodes/node_shader_rgb.c
shader/nodes/node_shader_script.c
shader/nodes/node_shader_sepcombHSV.c
- shader/nodes/node_shader_sepcombRGB.c
+ shader/nodes/node_shader_sepcombRGB.cc
shader/nodes/node_shader_sepcombXYZ.cc
shader/nodes/node_shader_shaderToRgb.c
shader/nodes/node_shader_squeeze.c
@@ -215,7 +215,7 @@ set(SRC
shader/nodes/node_shader_tex_white_noise.c
shader/nodes/node_shader_uvAlongStroke.c
shader/nodes/node_shader_uvmap.c
- shader/nodes/node_shader_valToRgb.c
+ shader/nodes/node_shader_valToRgb.cc
shader/nodes/node_shader_value.cc
shader/nodes/node_shader_vectTransform.c
shader/nodes/node_shader_vector_displacement.c
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index fc262544b4f..2aed485c8bc 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -42,6 +42,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
+#include "BLI_math_base_safe.h"
#include "BLI_rand.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
@@ -74,6 +75,7 @@
# include "BKE_node_tree_multi_function.hh"
+# include "BLI_color.hh"
# include "BLI_float3.hh"
extern "C" {
diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.c b/source/blender/nodes/shader/nodes/node_shader_map_range.cc
index 5db7983e752..3f8a516c175 100644
--- a/source/blender/nodes/shader/nodes/node_shader_map_range.c
+++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc
@@ -50,22 +50,33 @@ static void node_shader_init_map_range(bNodeTree *UNUSED(ntree), bNode *node)
node->custom2 = NODE_MAP_RANGE_LINEAR; /* interpolation */
}
+static const char *gpu_shader_get_name(int mode)
+{
+ switch (mode) {
+ case NODE_MAP_RANGE_LINEAR:
+ return "map_range_linear";
+ case NODE_MAP_RANGE_STEPPED:
+ return "map_range_stepped";
+ case NODE_MAP_RANGE_SMOOTHSTEP:
+ return "map_range_smoothstep";
+ case NODE_MAP_RANGE_SMOOTHERSTEP:
+ return "map_range_smootherstep";
+ }
+
+ return nullptr;
+}
+
static int gpu_shader_map_range(GPUMaterial *mat,
bNode *node,
bNodeExecData *UNUSED(execdata),
GPUNodeStack *in,
GPUNodeStack *out)
{
- static const char *names[] = {
- [NODE_MAP_RANGE_LINEAR] = "map_range_linear",
- [NODE_MAP_RANGE_STEPPED] = "map_range_stepped",
- [NODE_MAP_RANGE_SMOOTHSTEP] = "map_range_smoothstep",
- [NODE_MAP_RANGE_SMOOTHERSTEP] = "map_range_smootherstep",
- };
+ const char *name = gpu_shader_get_name(node->custom2);
int ret = 0;
- if (node->custom2 < ARRAY_SIZE(names) && names[node->custom2]) {
- ret = GPU_stack_link(mat, node, names[node->custom2], in, out);
+ if (name != nullptr) {
+ ret = GPU_stack_link(mat, node, name, in, out);
}
else {
ret = GPU_stack_link(mat, node, "map_range_linear", in, out);
@@ -77,6 +88,68 @@ static int gpu_shader_map_range(GPUMaterial *mat,
return ret;
}
+class MapRangeFunction : public blender::fn::MultiFunction {
+ private:
+ bool clamp_;
+
+ public:
+ MapRangeFunction(bool clamp) : clamp_(clamp)
+ {
+ blender::fn::MFSignatureBuilder signature = this->get_builder("Map Range");
+ signature.single_input<float>("Value");
+ signature.single_input<float>("From Min");
+ signature.single_input<float>("From Max");
+ signature.single_input<float>("To Min");
+ signature.single_input<float>("To Max");
+ signature.single_output<float>("Result");
+ }
+
+ void call(blender::IndexMask mask,
+ blender::fn::MFParams params,
+ blender::fn::MFContext UNUSED(context)) const override
+ {
+ blender::fn::VSpan<float> values = params.readonly_single_input<float>(0, "Value");
+ blender::fn::VSpan<float> from_min = params.readonly_single_input<float>(1, "From Min");
+ blender::fn::VSpan<float> from_max = params.readonly_single_input<float>(2, "From Max");
+ blender::fn::VSpan<float> to_min = params.readonly_single_input<float>(3, "To Min");
+ blender::fn::VSpan<float> to_max = params.readonly_single_input<float>(4, "To Max");
+ blender::MutableSpan<float> results = params.uninitialized_single_output<float>(5, "Result");
+
+ for (uint i : mask) {
+ float factor = safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]);
+ results[i] = to_min[i] + factor * (to_max[i] - to_min[i]);
+ }
+
+ if (clamp_) {
+ for (uint i : mask) {
+ CLAMP(results[i], 0.0f, 1.0f);
+ }
+ }
+ }
+};
+
+static void sh_node_map_range_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder)
+{
+ bNode &bnode = builder.bnode();
+ bool clamp = bnode.custom1 != 0;
+ int interpolation_type = bnode.custom2;
+
+ if (interpolation_type == NODE_MAP_RANGE_LINEAR) {
+ static MapRangeFunction fn_with_clamp{true};
+ static MapRangeFunction fn_without_clamp{false};
+
+ if (clamp) {
+ builder.set_matching_fn(fn_with_clamp);
+ }
+ else {
+ builder.set_matching_fn(fn_without_clamp);
+ }
+ }
+ else {
+ builder.set_not_implemented();
+ }
+}
+
void register_node_type_sh_map_range(void)
{
static bNodeType ntype;
@@ -86,6 +159,7 @@ void register_node_type_sh_map_range(void)
node_type_init(&ntype, node_shader_init_map_range);
node_type_update(&ntype, node_shader_update_map_range);
node_type_gpu(&ntype, gpu_shader_map_range);
+ ntype.expand_in_mf_network = sh_node_map_range_expand_in_mf_network;
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc
index a0eb5099f9d..c6762f17919 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_math.cc
@@ -146,38 +146,229 @@ static int gpu_shader_math(GPUMaterial *mat,
}
}
-static void sh_node_math_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder)
+static const blender::fn::MultiFunction &get_base_multi_function(
+ blender::bke::NodeMFNetworkBuilder &builder)
{
- /* TODO: Implement clamp and other operations. */
const int mode = builder.bnode().custom1;
switch (mode) {
case NODE_MATH_ADD: {
static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
"Add", [](float a, float b) { return a + b; }};
- builder.set_matching_fn(fn);
- break;
+ return fn;
}
case NODE_MATH_SUBTRACT: {
static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
"Subtract", [](float a, float b) { return a - b; }};
- builder.set_matching_fn(fn);
- break;
+ return fn;
}
case NODE_MATH_MULTIPLY: {
static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
"Multiply", [](float a, float b) { return a * b; }};
- builder.set_matching_fn(fn);
- break;
+ return fn;
}
case NODE_MATH_DIVIDE: {
+ static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{"Divide", safe_divide};
+ return fn;
+ }
+ case NODE_MATH_MULTIPLY_ADD: {
+ static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, float> fn{
+ "Multiply Add", [](float a, float b, float c) { return a * b + c; }};
+ return fn;
+ }
+
+ case NODE_MATH_POWER: {
+ static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{"Power", safe_powf};
+ return fn;
+ }
+ case NODE_MATH_LOGARITHM: {
+ static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{"Logarithm", safe_logf};
+ return fn;
+ }
+ case NODE_MATH_EXPONENT: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Exponent", expf};
+ return fn;
+ }
+ case NODE_MATH_SQRT: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Sqrt", safe_sqrtf};
+ return fn;
+ }
+ case NODE_MATH_INV_SQRT: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Inverse Sqrt", safe_inverse_sqrtf};
+ return fn;
+ };
+ case NODE_MATH_ABSOLUTE: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Absolute",
+ [](float a) { return fabs(a); }};
+ return fn;
+ }
+ case NODE_MATH_RADIANS: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Radians",
+ [](float a) { return DEG2RAD(a); }};
+ return fn;
+ }
+ case NODE_MATH_DEGREES: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Degrees",
+ [](float a) { return RAD2DEG(a); }};
+ return fn;
+ }
+
+ case NODE_MATH_MINIMUM: {
+ static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
+ "Minimum", [](float a, float b) { return std::min(a, b); }};
+ return fn;
+ }
+ case NODE_MATH_MAXIMUM: {
+ static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
+ "Maximum", [](float a, float b) { return std::max(a, b); }};
+ return fn;
+ }
+ case NODE_MATH_LESS_THAN: {
+ static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
+ "Less Than", [](float a, float b) { return (float)(a < b); }};
+ return fn;
+ }
+ case NODE_MATH_GREATER_THAN: {
+ static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
+ "Greater Than", [](float a, float b) { return (float)(a > b); }};
+ return fn;
+ }
+ case NODE_MATH_SIGN: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{
+ "Sign", [](float a) { return compatible_signf(a); }};
+ return fn;
+ }
+ case NODE_MATH_COMPARE: {
+ static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, float> fn{
+ "Compare", [](float a, float b, float c) -> float {
+ return ((a == b) || (fabsf(a - b) <= fmaxf(c, FLT_EPSILON))) ? 1.0f : 0.0f;
+ }};
+ return fn;
+ }
+ case NODE_MATH_SMOOTH_MIN: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_MATH_SMOOTH_MAX: {
+ return builder.get_not_implemented_fn();
+ }
+
+ case NODE_MATH_ROUND: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{
+ "Round", [](float a) { return floorf(a + 0.5f); }};
+ return fn;
+ }
+ case NODE_MATH_FLOOR: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Floor",
+ [](float a) { return floorf(a); }};
+ return fn;
+ }
+ case NODE_MATH_CEIL: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Ceil",
+ [](float a) { return ceilf(a); }};
+ return fn;
+ }
+ case NODE_MATH_FRACTION: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Fraction",
+ [](float a) { return a - floorf(a); }};
+ return fn;
+ }
+ case NODE_MATH_MODULO: {
static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
- "Divide", [](float a, float b) { return (b != 0.0f) ? a / b : 0.0f; }};
- builder.set_matching_fn(fn);
- break;
+ "Modulo", [](float a, float b) { return safe_modf(a, b); }};
+ return fn;
}
+ case NODE_MATH_TRUNC: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{
+ "Trunc", [](float a) { return a >= 0.0f ? floorf(a) : ceilf(a); }};
+ return fn;
+ }
+ case NODE_MATH_SNAP: {
+ static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
+ "Snap", [](float a, float b) { return floorf(safe_divide(a, b)) * b; }};
+ return fn;
+ }
+ case NODE_MATH_WRAP: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_MATH_PINGPONG: {
+ return builder.get_not_implemented_fn();
+ }
+
+ case NODE_MATH_SINE: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Sine", [](float a) { return sinf(a); }};
+ return fn;
+ }
+ case NODE_MATH_COSINE: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Cosine",
+ [](float a) { return cosf(a); }};
+ return fn;
+ }
+ case NODE_MATH_TANGENT: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Tangent",
+ [](float a) { return tanf(a); }};
+ return fn;
+ }
+ case NODE_MATH_SINH: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Hyperbolic Sine",
+ [](float a) { return sinhf(a); }};
+ return fn;
+ }
+ case NODE_MATH_COSH: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Hyperbolic Cosine",
+ [](float a) { return coshf(a); }};
+ return fn;
+ }
+ case NODE_MATH_TANH: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Hyperbolic Tangent",
+ [](float a) { return tanhf(a); }};
+ return fn;
+ }
+ case NODE_MATH_ARCSINE: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Arc Sine", safe_asinf};
+ return fn;
+ }
+ case NODE_MATH_ARCCOSINE: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Arc Cosine", safe_acosf};
+ return fn;
+ }
+ case NODE_MATH_ARCTANGENT: {
+ static blender::fn::CustomMF_SI_SO<float, float> fn{"Arc Tangent",
+ [](float a) { return atanf(a); }};
+ return fn;
+ }
+ case NODE_MATH_ARCTAN2: {
+ static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{
+ "Arc Tangent 2", [](float a, float b) { return atan2f(a, b); }};
+ return fn;
+ }
+
default:
BLI_assert(false);
- break;
+ return builder.get_not_implemented_fn();
+ }
+}
+
+static void sh_node_math_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder)
+{
+ const blender::fn::MultiFunction &base_function = get_base_multi_function(builder);
+
+ const blender::bke::DNode &dnode = builder.dnode();
+ blender::fn::MFNetwork &network = builder.network();
+ blender::fn::MFFunctionNode &base_node = network.add_function(base_function);
+
+ builder.network_map().add_try_match(dnode.inputs(), base_node.inputs());
+
+ const bool clamp_output = builder.bnode().custom2 != 0;
+ if (clamp_output) {
+ static blender::fn::CustomMF_SI_SO<float, float> clamp_fn{"Clamp", [](float value) {
+ CLAMP(value, 0.0f, 1.0f);
+ return value;
+ }};
+ blender::fn::MFFunctionNode &clamp_node = network.add_function(clamp_fn);
+ network.add_link(base_node.output(0), clamp_node.input(0));
+ builder.network_map().add(dnode.output(0), clamp_node.output(0));
+ }
+ else {
+ builder.network_map().add(dnode.output(0), base_node.output(0));
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
index d0dc45dcedd..8cab115c0b5 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
@@ -59,6 +59,42 @@ static int gpu_shader_seprgb(GPUMaterial *mat,
return GPU_stack_link(mat, node, "separate_rgb", in, out);
}
+class SeparateRGBFunction : public blender::fn::MultiFunction {
+ public:
+ SeparateRGBFunction()
+ {
+ blender::fn::MFSignatureBuilder signature = this->get_builder("Separate RGB");
+ signature.single_input<blender::Color4f>("Color");
+ signature.single_output<float>("R");
+ signature.single_output<float>("G");
+ signature.single_output<float>("B");
+ }
+
+ void call(blender::IndexMask mask,
+ blender::fn::MFParams params,
+ blender::fn::MFContext UNUSED(context)) const override
+ {
+ blender::fn::VSpan<blender::Color4f> colors = params.readonly_single_input<blender::Color4f>(
+ 0, "Color");
+ blender::MutableSpan<float> rs = params.uninitialized_single_output<float>(1, "R");
+ blender::MutableSpan<float> gs = params.uninitialized_single_output<float>(2, "G");
+ blender::MutableSpan<float> bs = params.uninitialized_single_output<float>(3, "B");
+
+ for (uint i : mask) {
+ blender::Color4f color = colors[i];
+ rs[i] = color.r;
+ gs[i] = color.g;
+ bs[i] = color.b;
+ }
+ }
+};
+
+static void sh_node_seprgb_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder)
+{
+ static SeparateRGBFunction fn;
+ builder.set_matching_fn(fn);
+}
+
void register_node_type_sh_seprgb(void)
{
static bNodeType ntype;
@@ -67,6 +103,7 @@ void register_node_type_sh_seprgb(void)
node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_seprgb);
node_type_gpu(&ntype, gpu_shader_seprgb);
+ ntype.expand_in_mf_network = sh_node_seprgb_expand_in_mf_network;
nodeRegisterType(&ntype);
}
@@ -109,6 +146,13 @@ static int gpu_shader_combrgb(GPUMaterial *mat,
return GPU_stack_link(mat, node, "combine_rgb", in, out);
}
+static void sh_node_combrgb_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder)
+{
+ static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, blender::Color4f> fn{
+ "Combine RGB", [](float r, float g, float b) { return blender::Color4f(r, g, b, 1.0f); }};
+ builder.set_matching_fn(fn);
+}
+
void register_node_type_sh_combrgb(void)
{
static bNodeType ntype;
@@ -117,6 +161,7 @@ void register_node_type_sh_combrgb(void)
node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_combrgb);
node_type_gpu(&ntype, gpu_shader_combrgb);
+ ntype.expand_in_mf_network = sh_node_combrgb_expand_in_mf_network;
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc
index 4dbe10f3982..d9af37ab46b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc
@@ -113,37 +113,11 @@ static int gpu_shader_combxyz(GPUMaterial *mat,
return GPU_stack_link(mat, node, "combine_xyz", in, out);
}
-class MF_CombineXYZ : public blender::fn::MultiFunction {
- public:
- MF_CombineXYZ()
- {
- blender::fn::MFSignatureBuilder signature = this->get_builder("Combine XYZ");
- signature.single_input<float>("X");
- signature.single_input<float>("Y");
- signature.single_input<float>("Z");
- signature.single_output<blender::float3>("XYZ");
- }
-
- void call(blender::IndexMask mask,
- blender::fn::MFParams params,
- blender::fn::MFContext UNUSED(context)) const override
- {
- blender::fn::VSpan<float> xs = params.readonly_single_input<float>(0, "X");
- blender::fn::VSpan<float> ys = params.readonly_single_input<float>(1, "Y");
- blender::fn::VSpan<float> zs = params.readonly_single_input<float>(2, "Z");
- blender::MutableSpan<blender::float3> vectors =
- params.uninitialized_single_output<blender::float3>(3, "XYZ");
-
- for (uint i : mask) {
- vectors[i] = {xs[i], ys[i], zs[i]};
- }
- }
-};
-
static void sh_node_combxyz_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder)
{
- static MF_CombineXYZ combine_fn;
- builder.set_matching_fn(combine_fn);
+ static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, blender::float3> fn{
+ "Combine Vector", [](float x, float y, float z) { return blender::float3(x, y, z); }};
+ builder.set_matching_fn(fn);
}
void register_node_type_sh_combxyz(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
index 20f280d00c3..76409c836d8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
@@ -22,6 +22,11 @@
*/
#include "IMB_colormanagement.h"
+
+#include "DNA_texture_types.h"
+
+#include "BLI_color.hh"
+
#include "node_shader_util.h"
/* **************** VALTORGB ******************** */
@@ -49,7 +54,7 @@ static void node_shader_exec_valtorgb(void *UNUSED(data),
float fac;
nodestack_get_vec(&fac, SOCK_FLOAT, in[0]);
- BKE_colorband_evaluate(node->storage, fac, out[0]->vec);
+ BKE_colorband_evaluate((ColorBand *)node->storage, fac, out[0]->vec);
out[1]->vec[0] = out[0]->vec[3];
}
}
@@ -65,7 +70,7 @@ static int gpu_shader_valtorgb(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- struct ColorBand *coba = node->storage;
+ struct ColorBand *coba = (ColorBand *)node->storage;
float *array, layer;
int size;
@@ -121,6 +126,44 @@ static int gpu_shader_valtorgb(GPUMaterial *mat,
}
}
+class ColorBandFunction : public blender::fn::MultiFunction {
+ private:
+ const ColorBand &color_band_;
+
+ public:
+ ColorBandFunction(const ColorBand &color_band) : color_band_(color_band)
+ {
+ blender::fn::MFSignatureBuilder signature = this->get_builder("Color Band");
+ signature.single_input<float>("Value");
+ signature.single_output<blender::Color4f>("Color");
+ signature.single_output<float>("Alpha");
+ }
+
+ void call(blender::IndexMask mask,
+ blender::fn::MFParams params,
+ blender::fn::MFContext UNUSED(context)) const override
+ {
+ blender::fn::VSpan<float> values = params.readonly_single_input<float>(0, "Value");
+ blender::MutableSpan<blender::Color4f> colors =
+ params.uninitialized_single_output<blender::Color4f>(1, "Color");
+ blender::MutableSpan<float> alphas = params.uninitialized_single_output<float>(2, "Alpha");
+
+ for (uint i : mask) {
+ blender::Color4f color;
+ BKE_colorband_evaluate(&color_band_, values[i], color);
+ colors[i] = color;
+ alphas[i] = color.a;
+ }
+ }
+};
+
+static void sh_node_valtorgb_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder)
+{
+ bNode &bnode = builder.bnode();
+ const ColorBand *color_band = (const ColorBand *)bnode.storage;
+ builder.construct_and_set_matching_fn<ColorBandFunction>(*color_band);
+}
+
void register_node_type_sh_valtorgb(void)
{
static bNodeType ntype;
@@ -132,6 +175,7 @@ void register_node_type_sh_valtorgb(void)
node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_valtorgb);
node_type_gpu(&ntype, gpu_shader_valtorgb);
+ ntype.expand_in_mf_network = sh_node_valtorgb_expand_in_mf_network;
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
index 414d05e996a..8301ab4d855 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
@@ -160,43 +160,123 @@ static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node
}
}
-static void sh_node_vector_math_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder)
+static const blender::fn::MultiFunction &get_multi_function(
+ blender::bke::NodeMFNetworkBuilder &builder)
{
using blender::float3;
- /* TODO: Implement other operations. */
const int mode = builder.bnode().custom1;
switch (mode) {
case NODE_VECTOR_MATH_ADD: {
static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{
"Add", [](float3 a, float3 b) { return a + b; }};
- builder.set_matching_fn(fn);
- break;
+ return fn;
}
case NODE_VECTOR_MATH_SUBTRACT: {
static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{
"Subtract", [](float3 a, float3 b) { return a - b; }};
- builder.set_matching_fn(fn);
- break;
+ return fn;
}
case NODE_VECTOR_MATH_MULTIPLY: {
static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{
"Multiply", [](float3 a, float3 b) { return a * b; }};
- builder.set_matching_fn(fn);
- break;
+ return fn;
}
case NODE_VECTOR_MATH_DIVIDE: {
static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{
"Divide", [](float3 a, float3 b) { return float3::safe_divide(a, b); }};
- builder.set_matching_fn(fn);
- break;
+ return fn;
+ }
+
+ case NODE_VECTOR_MATH_CROSS_PRODUCT: {
+ static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{
+ "Cross Product", float3::cross_high_precision};
+ return fn;
+ }
+ case NODE_VECTOR_MATH_PROJECT: {
+ static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{"Project", float3::project};
+ return fn;
+ }
+ case NODE_VECTOR_MATH_REFLECT: {
+ static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{
+ "Reflect", [](float3 a, float3 b) { return a.reflected(b); }};
+ return fn;
+ }
+ case NODE_VECTOR_MATH_DOT_PRODUCT: {
+ static blender::fn::CustomMF_SI_SI_SO<float3, float3, float> fn{"Dot Product", float3::dot};
+ return fn;
+ }
+
+ case NODE_VECTOR_MATH_DISTANCE: {
+ static blender::fn::CustomMF_SI_SI_SO<float3, float3, float> fn{"Distance",
+ float3::distance};
+ return fn;
+ }
+ case NODE_VECTOR_MATH_LENGTH: {
+ static blender::fn::CustomMF_SI_SO<float3, float> fn{"Length",
+ [](float3 a) { return a.length(); }};
+ return fn;
+ }
+ case NODE_VECTOR_MATH_SCALE: {
+ static blender::fn::CustomMF_SI_SI_SO<float3, float, float3> fn{
+ "Scale", [](float3 a, float factor) { return a * factor; }};
+ return fn;
+ }
+ case NODE_VECTOR_MATH_NORMALIZE: {
+ static blender::fn::CustomMF_SI_SO<float3, float3> fn{
+ "Normalize", [](float3 a) { return a.normalized(); }};
+ return fn;
+ }
+
+ case NODE_VECTOR_MATH_SNAP: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_FLOOR: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_CEIL: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_MODULO: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_FRACTION: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_ABSOLUTE: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_MINIMUM: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_MAXIMUM: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_WRAP: {
+ return builder.get_not_implemented_fn();
}
+ case NODE_VECTOR_MATH_SINE: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_COSINE: {
+ return builder.get_not_implemented_fn();
+ }
+ case NODE_VECTOR_MATH_TANGENT: {
+ return builder.get_not_implemented_fn();
+ }
+
default:
BLI_assert(false);
- break;
+ return builder.get_not_implemented_fn();
};
}
+static void sh_node_vector_math_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder)
+{
+ const blender::fn::MultiFunction &fn = get_multi_function(builder);
+ builder.set_matching_fn(fn);
+}
+
void register_node_type_sh_vect_math(void)
{
static bNodeType ntype;
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index f49c68a258d..e3c3cf712f9 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -32,7 +32,7 @@ set(INC
../makesdna
../makesrna
../nodes
- ../physics
+ ../simulation
../../../intern/atomic
../../../intern/guardedalloc
../../../intern/mikktspace
diff --git a/source/blender/physics/CMakeLists.txt b/source/blender/simulation/CMakeLists.txt
index 10520a18513..aced9664f51 100644
--- a/source/blender/physics/CMakeLists.txt
+++ b/source/blender/simulation/CMakeLists.txt
@@ -34,7 +34,7 @@ set(INC_SYS
)
set(SRC
- intern/BPH_mass_spring.cpp
+ intern/SIM_mass_spring.cpp
intern/ConstrainedConjugateGradient.h
intern/eigen_utils.h
intern/hair_volume.cpp
@@ -42,7 +42,7 @@ set(SRC
intern/implicit_blender.c
intern/implicit_eigen.cpp
- BPH_mass_spring.h
+ SIM_mass_spring.h
)
set(LIB
diff --git a/source/blender/physics/BPH_mass_spring.h b/source/blender/simulation/SIM_mass_spring.h
index 5a8c78812a4..d30a7160fd8 100644
--- a/source/blender/physics/BPH_mass_spring.h
+++ b/source/blender/simulation/SIM_mass_spring.h
@@ -21,8 +21,8 @@
* \ingroup bph
*/
-#ifndef __BPH_MASS_SPRING_H__
-#define __BPH_MASS_SPRING_H__
+#ifndef __SIM_MASS_SPRING_H__
+#define __SIM_MASS_SPRING_H__
#ifdef __cplusplus
extern "C" {
@@ -35,25 +35,25 @@ struct ListBase;
struct Object;
typedef enum eMassSpringSolverStatus {
- BPH_SOLVER_SUCCESS = (1 << 0),
- BPH_SOLVER_NUMERICAL_ISSUE = (1 << 1),
- BPH_SOLVER_NO_CONVERGENCE = (1 << 2),
- BPH_SOLVER_INVALID_INPUT = (1 << 3),
+ SIM_SOLVER_SUCCESS = (1 << 0),
+ SIM_SOLVER_NUMERICAL_ISSUE = (1 << 1),
+ SIM_SOLVER_NO_CONVERGENCE = (1 << 2),
+ SIM_SOLVER_INVALID_INPUT = (1 << 3),
} eMassSpringSolverStatus;
-struct Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings);
-void BPH_mass_spring_solver_free(struct Implicit_Data *id);
-int BPH_mass_spring_solver_numvert(struct Implicit_Data *id);
+struct Implicit_Data *SIM_mass_spring_solver_create(int numverts, int numsprings);
+void SIM_mass_spring_solver_free(struct Implicit_Data *id);
+int SIM_mass_spring_solver_numvert(struct Implicit_Data *id);
-int BPH_cloth_solver_init(struct Object *ob, struct ClothModifierData *clmd);
-void BPH_cloth_solver_free(struct ClothModifierData *clmd);
-int BPH_cloth_solve(struct Depsgraph *depsgraph,
+int SIM_cloth_solver_init(struct Object *ob, struct ClothModifierData *clmd);
+void SIM_cloth_solver_free(struct ClothModifierData *clmd);
+int SIM_cloth_solve(struct Depsgraph *depsgraph,
struct Object *ob,
float frame,
struct ClothModifierData *clmd,
struct ListBase *effectors);
-void BKE_cloth_solver_set_positions(struct ClothModifierData *clmd);
-void BKE_cloth_solver_set_volume(ClothModifierData *clmd);
+void SIM_cloth_solver_set_positions(struct ClothModifierData *clmd);
+void SIM_cloth_solver_set_volume(ClothModifierData *clmd);
#ifdef __cplusplus
}
diff --git a/source/blender/physics/intern/ConstrainedConjugateGradient.h b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
index c924490f97d..c924490f97d 100644
--- a/source/blender/physics/intern/ConstrainedConjugateGradient.h
+++ b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/simulation/intern/SIM_mass_spring.cpp
index 051f11aa1d9..4834d6d351c 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/simulation/intern/SIM_mass_spring.cpp
@@ -38,7 +38,7 @@
#include "BKE_collision.h"
#include "BKE_effect.h"
-#include "BPH_mass_spring.h"
+#include "SIM_mass_spring.h"
#include "implicit.h"
#include "DEG_depsgraph.h"
@@ -104,7 +104,7 @@ static void cloth_calc_pressure_gradient(ClothModifierData *clmd,
float pt[3];
for (unsigned int i = 0; i < mvert_num; i++) {
- BPH_mass_spring_get_position(data, i, pt);
+ SIM_mass_spring_get_position(data, i, pt);
r_vertex_pressure[i] = dot_v3v3(pt, gradient_vector);
}
}
@@ -127,7 +127,7 @@ static float cloth_calc_volume(ClothModifierData *clmd)
const MVertTri *vt = &tri[i];
if (cloth_get_pressure_weights(clmd, vt, weights)) {
- vol += BPH_tri_tetra_volume_signed_6x(data, vt->tri[0], vt->tri[1], vt->tri[2]);
+ vol += SIM_tri_tetra_volume_signed_6x(data, vt->tri[0], vt->tri[1], vt->tri[2]);
}
}
@@ -179,7 +179,7 @@ static float cloth_calc_average_pressure(ClothModifierData *clmd, const float *v
const MVertTri *vt = &tri[i];
if (cloth_get_pressure_weights(clmd, vt, weights)) {
- float area = BPH_tri_area(data, vt->tri[0], vt->tri[1], vt->tri[2]);
+ float area = SIM_tri_area(data, vt->tri[0], vt->tri[1], vt->tri[2]);
total_force += (vertex_pressure[vt->tri[0]] + vertex_pressure[vt->tri[1]] +
vertex_pressure[vt->tri[2]]) *
@@ -191,7 +191,7 @@ static float cloth_calc_average_pressure(ClothModifierData *clmd, const float *v
return total_force / total_area;
}
-int BPH_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd)
+int SIM_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd)
{
Cloth *cloth = clmd->clothObject;
ClothVertex *verts = cloth->verts;
@@ -200,30 +200,30 @@ int BPH_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd)
unsigned int i, nondiag;
nondiag = cloth_count_nondiag_blocks(cloth);
- cloth->implicit = id = BPH_mass_spring_solver_create(cloth->mvert_num, nondiag);
+ cloth->implicit = id = SIM_mass_spring_solver_create(cloth->mvert_num, nondiag);
for (i = 0; i < cloth->mvert_num; i++) {
- BPH_mass_spring_set_vertex_mass(id, i, verts[i].mass);
+ SIM_mass_spring_set_vertex_mass(id, i, verts[i].mass);
}
for (i = 0; i < cloth->mvert_num; i++) {
- BPH_mass_spring_set_motion_state(id, i, verts[i].x, ZERO);
+ SIM_mass_spring_set_motion_state(id, i, verts[i].x, ZERO);
}
return 1;
}
-void BPH_cloth_solver_free(ClothModifierData *clmd)
+void SIM_cloth_solver_free(ClothModifierData *clmd)
{
Cloth *cloth = clmd->clothObject;
if (cloth->implicit) {
- BPH_mass_spring_solver_free(cloth->implicit);
+ SIM_mass_spring_solver_free(cloth->implicit);
cloth->implicit = NULL;
}
}
-void BKE_cloth_solver_set_positions(ClothModifierData *clmd)
+void SIM_cloth_solver_set_positions(ClothModifierData *clmd)
{
Cloth *cloth = clmd->clothObject;
ClothVertex *verts = cloth->verts;
@@ -234,17 +234,17 @@ void BKE_cloth_solver_set_positions(ClothModifierData *clmd)
for (i = 0; i < mvert_num; i++) {
if (cloth_hairdata) {
ClothHairData *root = &cloth_hairdata[i];
- BPH_mass_spring_set_rest_transform(id, i, root->rot);
+ SIM_mass_spring_set_rest_transform(id, i, root->rot);
}
else {
- BPH_mass_spring_set_rest_transform(id, i, I3);
+ SIM_mass_spring_set_rest_transform(id, i, I3);
}
- BPH_mass_spring_set_motion_state(id, i, verts[i].x, verts[i].v);
+ SIM_mass_spring_set_motion_state(id, i, verts[i].x, verts[i].v);
}
}
-void BKE_cloth_solver_set_volume(ClothModifierData *clmd)
+void SIM_cloth_solver_set_volume(ClothModifierData *clmd)
{
Cloth *cloth = clmd->clothObject;
@@ -265,12 +265,12 @@ static void cloth_setup_constraints(ClothModifierData *clmd)
const float ZERO[3] = {0.0f, 0.0f, 0.0f};
- BPH_mass_spring_clear_constraints(data);
+ SIM_mass_spring_clear_constraints(data);
for (v = 0; v < mvert_num; v++) {
if (verts[v].flags & CLOTH_VERT_FLAG_PINNED) {
/* pinned vertex constraints */
- BPH_mass_spring_add_constraint_ndof0(data, v, ZERO); /* velocity is defined externally */
+ SIM_mass_spring_add_constraint_ndof0(data, v, ZERO); /* velocity is defined externally */
}
verts[v].impulse_count = 0;
@@ -388,7 +388,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
k = scaling * s->restlen *
0.1f; /* Multiplying by 0.1, just to scale the forces to more reasonable values. */
- BPH_mass_spring_force_spring_angular(
+ SIM_mass_spring_force_spring_angular(
data, s->ij, s->kl, s->pa, s->pb, s->la, s->lb, s->restang, k, parms->bending_damping);
#endif
}
@@ -409,7 +409,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
/* TODO: verify, half verified (couldn't see error)
* sewing springs usually have a large distance at first so clamp the force so we don't get
* tunneling through collision objects. */
- BPH_mass_spring_force_spring_linear(data,
+ SIM_mass_spring_force_spring_linear(data,
s->ij,
s->kl,
s->restlen,
@@ -427,7 +427,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
s->lin_stiffness * fabsf(parms->max_compression - parms->compression);
k_compression = scaling_compression / (parms->avg_spring_len + FLT_EPSILON);
- BPH_mass_spring_force_spring_linear(data,
+ SIM_mass_spring_force_spring_linear(data,
s->ij,
s->kl,
s->restlen,
@@ -465,7 +465,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
k_compression_damp = 0.0f;
}
- BPH_mass_spring_force_spring_linear(data,
+ SIM_mass_spring_force_spring_linear(data,
s->ij,
s->kl,
s->restlen,
@@ -488,7 +488,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
scaling = parms->shear + s->lin_stiffness * fabsf(parms->max_shear - parms->shear);
k = scaling / (parms->avg_spring_len + FLT_EPSILON);
- BPH_mass_spring_force_spring_linear(data,
+ SIM_mass_spring_force_spring_linear(data,
s->ij,
s->kl,
s->restlen,
@@ -513,7 +513,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
// Fix for [#45084] for cloth stiffness must have cb proportional to kb
cb = kb * parms->bending_damping;
- BPH_mass_spring_force_spring_bending(data, s->ij, s->kl, s->restlen, kb, cb);
+ SIM_mass_spring_force_spring_bending(data, s->ij, s->kl, s->restlen, kb, cb);
#endif
}
else if (s->type & CLOTH_SPRING_TYPE_BENDING_HAIR) {
@@ -534,14 +534,14 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
/* XXX assuming same restlen for ij and jk segments here,
* this can be done correctly for hair later. */
- BPH_mass_spring_force_spring_bending_hair(data, s->ij, s->kl, s->mn, s->target, kb, cb);
+ SIM_mass_spring_force_spring_bending_hair(data, s->ij, s->kl, s->mn, s->target, kb, cb);
# if 0
{
float x_kl[3], x_mn[3], v[3], d[3];
- BPH_mass_spring_get_motion_state(data, s->kl, x_kl, v);
- BPH_mass_spring_get_motion_state(data, s->mn, x_mn, v);
+ SIM_mass_spring_get_motion_state(data, s->kl, x_kl, v);
+ SIM_mass_spring_get_motion_state(data, s->mn, x_mn, v);
BKE_sim_debug_data_add_dot(clmd->debug_data, x_kl, 0.9, 0.9, 0.9, "target", 7980, s->kl);
BKE_sim_debug_data_add_line(
@@ -569,7 +569,7 @@ static void hair_get_boundbox(ClothModifierData *clmd, float gmin[3], float gmax
INIT_MINMAX(gmin, gmax);
for (i = 0; i < mvert_num; i++) {
float x[3];
- BPH_mass_spring_get_motion_state(data, i, x, NULL);
+ SIM_mass_spring_get_motion_state(data, i, x, NULL);
DO_MINMAX(x, gmin, gmax);
}
}
@@ -599,7 +599,7 @@ static void cloth_calc_force(
vert = cloth->verts;
for (i = 0; i < cloth->mvert_num; i++, vert++) {
- BPH_mass_spring_force_gravity(data, i, vert->mass, gravity);
+ SIM_mass_spring_force_gravity(data, i, vert->mass, gravity);
/* Vertex goal springs */
if ((!(vert->flags & CLOTH_VERT_FLAG_PINNED)) && (vert->goal > FLT_EPSILON)) {
@@ -613,7 +613,7 @@ static void cloth_calc_force(
k = vert->goal * clmd->sim_parms->goalspring /
(clmd->sim_parms->avg_spring_len + FLT_EPSILON);
- BPH_mass_spring_force_spring_goal(
+ SIM_mass_spring_force_spring_goal(
data, i, goal_x, goal_v, k, clmd->sim_parms->goalfrict * 0.01f);
}
}
@@ -622,7 +622,7 @@ static void cloth_calc_force(
/* cloth_calc_volume_force(clmd); */
#ifdef CLOTH_FORCE_DRAG
- BPH_mass_spring_force_drag(data, drag);
+ SIM_mass_spring_force_drag(data, drag);
#endif
/* handle pressure forces (making sure that this never gets computed for hair). */
if ((parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE) && (clmd->hairdata == NULL)) {
@@ -694,7 +694,7 @@ static void cloth_calc_force(
const MVertTri *vt = &tri[i];
if (cloth_get_pressure_weights(clmd, vt, weights)) {
- BPH_mass_spring_force_pressure(data,
+ SIM_mass_spring_force_pressure(data,
vt->tri[0],
vt->tri[1],
vt->tri[2],
@@ -724,7 +724,7 @@ static void cloth_calc_force(
float x[3], v[3];
EffectedPoint epoint;
- BPH_mass_spring_get_motion_state(data, i, x, v);
+ SIM_mass_spring_get_motion_state(data, i, x, v);
pd_point_from_loc(scene, x, v, i, &epoint);
BKE_effectors_apply(effectors,
NULL,
@@ -743,10 +743,10 @@ static void cloth_calc_force(
for (i = 0; i < cloth->primitive_num; i++) {
const MVertTri *vt = &tri[i];
if (has_wind) {
- BPH_mass_spring_force_face_wind(data, vt->tri[0], vt->tri[1], vt->tri[2], winvec);
+ SIM_mass_spring_force_face_wind(data, vt->tri[0], vt->tri[1], vt->tri[2], winvec);
}
if (has_force) {
- BPH_mass_spring_force_face_extern(data, vt->tri[0], vt->tri[1], vt->tri[2], forcevec);
+ SIM_mass_spring_force_face_extern(data, vt->tri[0], vt->tri[1], vt->tri[2], forcevec);
}
}
}
@@ -761,11 +761,11 @@ static void cloth_calc_force(
if (hairdata) {
hair_ij = &hairdata[spring->ij];
hair_kl = &hairdata[spring->kl];
- BPH_mass_spring_force_edge_wind(
+ SIM_mass_spring_force_edge_wind(
data, spring->ij, spring->kl, hair_ij->radius, hair_kl->radius, winvec);
}
else {
- BPH_mass_spring_force_edge_wind(data, spring->ij, spring->kl, 1.0f, 1.0f, winvec);
+ SIM_mass_spring_force_edge_wind(data, spring->ij, spring->kl, 1.0f, 1.0f, winvec);
}
}
}
@@ -776,10 +776,10 @@ static void cloth_calc_force(
for (i = 0; i < cloth->mvert_num; i++, vert++) {
if (hairdata) {
ClothHairData *hair = &hairdata[i];
- BPH_mass_spring_force_vertex_wind(data, i, hair->radius, winvec);
+ SIM_mass_spring_force_vertex_wind(data, i, hair->radius, winvec);
}
else {
- BPH_mass_spring_force_vertex_wind(data, i, 1.0f, winvec);
+ SIM_mass_spring_force_vertex_wind(data, i, 1.0f, winvec);
}
}
#endif
@@ -806,8 +806,8 @@ BLI_INLINE void cloth_get_grid_location(Implicit_Data *data,
float x[3],
float v[3])
{
- BPH_mass_spring_get_position(data, index, x);
- BPH_mass_spring_get_new_velocity(data, index, v);
+ SIM_mass_spring_get_position(data, index, x);
+ SIM_mass_spring_get_new_velocity(data, index, v);
mul_v3_fl(x, cell_scale);
add_v3_v3(x, cell_offset);
@@ -902,7 +902,7 @@ static LinkNode *cloth_continuum_add_hair_segments(HairGrid *grid,
zero_v3(dir3);
}
- BPH_hair_volume_add_segment(
+ SIM_hair_volume_add_segment(
grid, x1, v1, x2, v2, x3, v3, x4, v4, spring1 ? dir1 : NULL, dir2, spring3 ? dir3 : NULL);
}
@@ -921,7 +921,7 @@ static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth)
float x[3], v[3];
cloth_get_vertex_motion_state(data, vert, x, v);
- BPH_hair_volume_add_vertex(grid, x, v);
+ SIM_hair_volume_add_vertex(grid, x, v);
}
#else
LinkNode *link;
@@ -930,7 +930,7 @@ static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth)
/* scale and offset for transforming vertex locations into grid space
* (cell size is 0..1, gmin becomes origin)
*/
- BPH_hair_volume_grid_geometry(grid, &cellsize, NULL, gmin, NULL);
+ SIM_hair_volume_grid_geometry(grid, &cellsize, NULL, gmin, NULL);
cell_scale = cellsize > 0.0f ? 1.0f / cellsize : 0.0f;
mul_v3_v3fl(cell_offset, gmin, cell_scale);
negate_v3(cell_offset);
@@ -946,7 +946,7 @@ static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth)
}
}
#endif
- BPH_hair_volume_normalize_vertex_grid(grid);
+ SIM_hair_volume_normalize_vertex_grid(grid);
}
static void cloth_continuum_step(ClothModifierData *clmd, float dt)
@@ -977,31 +977,31 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
/* gather velocities & density */
if (smoothfac > 0.0f || density_strength > 0.0f) {
- HairGrid *grid = BPH_hair_volume_create_vertex_grid(
+ HairGrid *grid = SIM_hair_volume_create_vertex_grid(
clmd->sim_parms->voxel_cell_size, gmin, gmax);
cloth_continuum_fill_grid(grid, cloth);
/* main hair continuum solver */
- BPH_hair_volume_solve_divergence(grid, dt, density_target, density_strength);
+ SIM_hair_volume_solve_divergence(grid, dt, density_target, density_strength);
for (i = 0, vert = cloth->verts; i < mvert_num; i++, vert++) {
float x[3], v[3], nv[3];
/* calculate volumetric velocity influence */
- BPH_mass_spring_get_position(data, i, x);
- BPH_mass_spring_get_new_velocity(data, i, v);
+ SIM_mass_spring_get_position(data, i, x);
+ SIM_mass_spring_get_new_velocity(data, i, v);
- BPH_hair_volume_grid_velocity(grid, x, v, fluid_factor, nv);
+ SIM_hair_volume_grid_velocity(grid, x, v, fluid_factor, nv);
interp_v3_v3v3(nv, v, nv, smoothfac);
/* apply on hair data */
- BPH_mass_spring_set_new_velocity(data, i, nv);
+ SIM_mass_spring_set_new_velocity(data, i, nv);
}
/* store basic grid info in the modifier data */
- BPH_hair_volume_grid_geometry(grid,
+ SIM_hair_volume_grid_geometry(grid,
&clmd->hair_grid_cellsize,
clmd->hair_grid_res,
clmd->hair_grid_min,
@@ -1034,7 +1034,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
madd_v3_v3fl(x, b, (float)j / (float)(size - 1));
zero_v3(v);
- BPH_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL);
+ SIM_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL);
// BKE_sim_debug_data_add_circle(
// clmd->debug_data, x, gdensity, 0.7, 0.3, 1,
@@ -1074,7 +1074,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
}
#endif
- BPH_hair_volume_free_vertex_grid(grid);
+ SIM_hair_volume_free_vertex_grid(grid);
}
}
@@ -1099,7 +1099,7 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
/* gather velocities & density */
if (smoothfac > 0.0f || pressfac > 0.0f) {
- HairVertexGrid *vertex_grid = BPH_hair_volume_create_vertex_grid(
+ HairVertexGrid *vertex_grid = SIM_hair_volume_create_vertex_grid(
clmd->sim_parms->voxel_res, gmin, gmax);
vert = cloth->verts;
@@ -1111,11 +1111,11 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
copy_v3_v3(v, vert->v);
}
else {
- BPH_mass_spring_get_motion_state(data, vert->solver_index, x, v);
+ SIM_mass_spring_get_motion_state(data, vert->solver_index, x, v);
}
- BPH_hair_volume_add_vertex(vertex_grid, x, v);
+ SIM_hair_volume_add_vertex(vertex_grid, x, v);
}
- BPH_hair_volume_normalize_vertex_grid(vertex_grid);
+ SIM_hair_volume_normalize_vertex_grid(vertex_grid);
vert = cloth->verts;
for (i = 0; i < mvert_num; i++, vert++) {
@@ -1126,14 +1126,14 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
}
/* calculate volumetric forces */
- BPH_mass_spring_get_motion_state(data, vert->solver_index, x, v);
- BPH_hair_volume_vertex_grid_forces(
+ SIM_mass_spring_get_motion_state(data, vert->solver_index, x, v);
+ SIM_hair_volume_vertex_grid_forces(
vertex_grid, x, v, smoothfac, pressfac, minpress, f, dfdx, dfdv);
/* apply on hair data */
- BPH_mass_spring_force_extern(data, vert->solver_index, f, dfdx, dfdv);
+ SIM_mass_spring_force_extern(data, vert->solver_index, f, dfdx, dfdv);
}
- BPH_hair_volume_free_vertex_grid(vertex_grid);
+ SIM_hair_volume_free_vertex_grid(vertex_grid);
}
}
#endif
@@ -1148,8 +1148,8 @@ static void cloth_calc_average_acceleration(ClothModifierData *clmd, float dt)
for (i = 0; i < mvert_num; i++) {
float v[3], nv[3];
- BPH_mass_spring_get_velocity(data, i, v);
- BPH_mass_spring_get_new_velocity(data, i, nv);
+ SIM_mass_spring_get_velocity(data, i, v);
+ SIM_mass_spring_get_new_velocity(data, i, nv);
sub_v3_v3(nv, v);
add_v3_v3(total, nv);
@@ -1181,11 +1181,11 @@ static void cloth_solve_collisions(
return;
}
- BPH_mass_spring_solve_positions(id, dt);
+ SIM_mass_spring_solve_positions(id, dt);
/* Update verts to current positions. */
for (i = 0; i < mvert_num; i++) {
- BPH_mass_spring_get_new_position(id, i, verts[i].tx);
+ SIM_mass_spring_get_new_position(id, i, verts[i].tx);
sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold);
zero_v3(verts[i].dcvel);
@@ -1201,9 +1201,9 @@ static void cloth_solve_collisions(
continue;
}
- BPH_mass_spring_get_new_velocity(id, i, verts[i].tv);
+ SIM_mass_spring_get_new_velocity(id, i, verts[i].tv);
madd_v3_v3fl(verts[i].tv, verts[i].dcvel, time_multiplier);
- BPH_mass_spring_set_new_velocity(id, i, verts[i].tv);
+ SIM_mass_spring_set_new_velocity(id, i, verts[i].tv);
}
}
}
@@ -1224,7 +1224,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r
if (sres->status) { /* already initialized ? */
/* error only makes sense for successful iterations */
- if (result->status == BPH_SOLVER_SUCCESS) {
+ if (result->status == SIM_SOLVER_SUCCESS) {
sres->min_error = min_ff(sres->min_error, result->error);
sres->max_error = max_ff(sres->max_error, result->error);
sres->avg_error += result->error * dt;
@@ -1236,7 +1236,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r
}
else {
/* error only makes sense for successful iterations */
- if (result->status == BPH_SOLVER_SUCCESS) {
+ if (result->status == SIM_SOLVER_SUCCESS) {
sres->min_error = sres->max_error = result->error;
sres->avg_error += result->error * dt;
}
@@ -1248,7 +1248,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r
sres->status |= result->status;
}
-int BPH_cloth_solve(
+int SIM_cloth_solve(
Depsgraph *depsgraph, Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors)
{
/* Hair currently is a cloth sim in disguise ...
@@ -1287,7 +1287,7 @@ int BPH_cloth_solve(
// mul_v3_fl(v, clmd->sim_parms->stepsPerFrame);
/* divide by time_scale to prevent constrained velocities from being multiplied */
mul_v3_fl(v, 1.0f / clmd->sim_parms->time_scale);
- BPH_mass_spring_set_velocity(id, i, v);
+ SIM_mass_spring_set_velocity(id, i, v);
}
}
}
@@ -1303,13 +1303,13 @@ int BPH_cloth_solve(
cloth_setup_constraints(clmd);
/* initialize forces to zero */
- BPH_mass_spring_clear_forces(id);
+ SIM_mass_spring_clear_forces(id);
// calculate forces
cloth_calc_force(scene, clmd, frame, effectors, step);
// calculate new velocity and position
- BPH_mass_spring_solve_velocities(id, dt, &result);
+ SIM_mass_spring_solve_velocities(id, dt, &result);
cloth_record_result(clmd, &result, dt);
/* Calculate collision impulses. */
@@ -1323,8 +1323,8 @@ int BPH_cloth_solve(
cloth_calc_average_acceleration(clmd, dt);
}
- BPH_mass_spring_solve_positions(id, dt);
- BPH_mass_spring_apply_result(id);
+ SIM_mass_spring_solve_positions(id, dt);
+ SIM_mass_spring_apply_result(id);
/* move pinned verts to correct position */
for (i = 0; i < mvert_num; i++) {
@@ -1335,11 +1335,11 @@ int BPH_cloth_solve(
* delta locations from being multiplied */
interp_v3_v3v3(
x, verts[i].xold, verts[i].xconst, (step + dt) / clmd->sim_parms->time_scale);
- BPH_mass_spring_set_position(id, i, x);
+ SIM_mass_spring_set_position(id, i, x);
}
}
- BPH_mass_spring_get_motion_state(id, i, verts[i].txold, NULL);
+ SIM_mass_spring_get_motion_state(id, i, verts[i].txold, NULL);
}
step += dt;
@@ -1347,7 +1347,7 @@ int BPH_cloth_solve(
/* copy results back to cloth data */
for (i = 0; i < mvert_num; i++) {
- BPH_mass_spring_get_motion_state(id, i, verts[i].x, verts[i].v);
+ SIM_mass_spring_get_motion_state(id, i, verts[i].x, verts[i].v);
copy_v3_v3(verts[i].txold, verts[i].x);
}
diff --git a/source/blender/physics/intern/eigen_utils.h b/source/blender/simulation/intern/eigen_utils.h
index c186cf567df..c186cf567df 100644
--- a/source/blender/physics/intern/eigen_utils.h
+++ b/source/blender/simulation/intern/eigen_utils.h
diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp
index 1764d0a910c..c80ae69ce73 100644
--- a/source/blender/physics/intern/hair_volume.cpp
+++ b/source/blender/simulation/intern/hair_volume.cpp
@@ -205,7 +205,7 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid,
}
}
-void BPH_hair_volume_vertex_grid_forces(HairGrid *grid,
+void SIM_hair_volume_vertex_grid_forces(HairGrid *grid,
const float x[3],
const float v[3],
float smoothfac,
@@ -244,7 +244,7 @@ void BPH_hair_volume_vertex_grid_forces(HairGrid *grid,
mul_m3_fl(dfdv, smoothfac);
}
-void BPH_hair_volume_grid_interpolate(HairGrid *grid,
+void SIM_hair_volume_grid_interpolate(HairGrid *grid,
const float x[3],
float *density,
float velocity[3],
@@ -264,7 +264,7 @@ void BPH_hair_volume_grid_interpolate(HairGrid *grid,
velocity_gradient);
}
-void BPH_hair_volume_grid_velocity(
+void SIM_hair_volume_grid_velocity(
HairGrid *grid, const float x[3], const float v[3], float fluid_factor, float r_v[3])
{
float gdensity, gvelocity[3], gvel_smooth[3], ggrad[3], gvelgrad[3][3];
@@ -291,7 +291,7 @@ void BPH_hair_volume_grid_velocity(
interp_v3_v3v3(r_v, v_pic, v_flip, fluid_factor);
}
-void BPH_hair_volume_grid_clear(HairGrid *grid)
+void SIM_hair_volume_grid_clear(HairGrid *grid)
{
const int size = hair_grid_size(grid->res);
int i;
@@ -362,7 +362,7 @@ BLI_INLINE void grid_to_world(HairGrid *grid, float vecw[3], const float vec[3])
add_v3_v3(vecw, grid->gmin);
}
-void BPH_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[3])
+void SIM_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[3])
{
const int res[3] = {grid->res[0], grid->res[1], grid->res[2]};
float weights[8];
@@ -503,7 +503,7 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
* The radius of influence around a segment is assumed to be at most 2*cellsize,
* i.e. only cells containing the segment and their direct neighbors are examined.
*/
-void BPH_hair_volume_add_segment(HairGrid *grid,
+void SIM_hair_volume_add_segment(HairGrid *grid,
const float x1[3],
const float v1[3],
const float x2[3],
@@ -633,7 +633,7 @@ BLI_INLINE void hair_volume_eval_grid_vertex_sample(HairGridVert *vert,
/* XXX simplified test implementation using a series of discrete sample along the segment,
* instead of finding the closest point for all affected grid vertices.
*/
-void BPH_hair_volume_add_segment(HairGrid *grid,
+void SIM_hair_volume_add_segment(HairGrid *grid,
const float UNUSED(x1[3]),
const float UNUSED(v1[3]),
const float x2[3],
@@ -684,7 +684,7 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
}
#endif
-void BPH_hair_volume_normalize_vertex_grid(HairGrid *grid)
+void SIM_hair_volume_normalize_vertex_grid(HairGrid *grid)
{
int i, size = hair_grid_size(grid->res);
/* divide velocity with density */
@@ -715,7 +715,7 @@ BLI_INLINE float hair_volume_density_divergence(float density,
}
}
-bool BPH_hair_volume_solve_divergence(HairGrid *grid,
+bool SIM_hair_volume_solve_divergence(HairGrid *grid,
float /*dt*/,
float target_density,
float target_strength)
@@ -1078,7 +1078,7 @@ BLI_INLINE void hair_volume_filter_box_convolute(
}
}
-void BPH_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_size)
+void SIM_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_size)
{
int size = hair_grid_size(grid->res);
int kernel_sizev[3] = {kernel_size, kernel_size, kernel_size};
@@ -1113,7 +1113,7 @@ void BPH_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_siz
}
#endif
-HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize,
+HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize,
const float gmin[3],
const float gmax[3])
{
@@ -1170,7 +1170,7 @@ HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize,
return grid;
}
-void BPH_hair_volume_free_vertex_grid(HairGrid *grid)
+void SIM_hair_volume_free_vertex_grid(HairGrid *grid)
{
if (grid) {
if (grid->verts) {
@@ -1180,7 +1180,7 @@ void BPH_hair_volume_free_vertex_grid(HairGrid *grid)
}
}
-void BPH_hair_volume_grid_geometry(
+void SIM_hair_volume_grid_geometry(
HairGrid *grid, float *cellsize, int res[3], float gmin[3], float gmax[3])
{
if (cellsize) {
diff --git a/source/blender/physics/intern/implicit.h b/source/blender/simulation/intern/implicit.h
index 8bc09755180..17dfb8b88b9 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/simulation/intern/implicit.h
@@ -65,87 +65,87 @@ BLI_INLINE void implicit_print_matrix_elem(float v)
printf("%-8.3f", v);
}
-void BPH_mass_spring_set_vertex_mass(struct Implicit_Data *data, int index, float mass);
-void BPH_mass_spring_set_rest_transform(struct Implicit_Data *data, int index, float rot[3][3]);
+void SIM_mass_spring_set_vertex_mass(struct Implicit_Data *data, int index, float mass);
+void SIM_mass_spring_set_rest_transform(struct Implicit_Data *data, int index, float rot[3][3]);
-void BPH_mass_spring_set_motion_state(struct Implicit_Data *data,
+void SIM_mass_spring_set_motion_state(struct Implicit_Data *data,
int index,
const float x[3],
const float v[3]);
-void BPH_mass_spring_set_position(struct Implicit_Data *data, int index, const float x[3]);
-void BPH_mass_spring_set_velocity(struct Implicit_Data *data, int index, const float v[3]);
-void BPH_mass_spring_get_motion_state(struct Implicit_Data *data,
+void SIM_mass_spring_set_position(struct Implicit_Data *data, int index, const float x[3]);
+void SIM_mass_spring_set_velocity(struct Implicit_Data *data, int index, const float v[3]);
+void SIM_mass_spring_get_motion_state(struct Implicit_Data *data,
int index,
float x[3],
float v[3]);
-void BPH_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3]);
-void BPH_mass_spring_get_velocity(struct Implicit_Data *data, int index, float v[3]);
+void SIM_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3]);
+void SIM_mass_spring_get_velocity(struct Implicit_Data *data, int index, float v[3]);
/* access to modified motion state during solver step */
-void BPH_mass_spring_get_new_position(struct Implicit_Data *data, int index, float x[3]);
-void BPH_mass_spring_set_new_position(struct Implicit_Data *data, int index, const float x[3]);
-void BPH_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3]);
-void BPH_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3]);
+void SIM_mass_spring_get_new_position(struct Implicit_Data *data, int index, float x[3]);
+void SIM_mass_spring_set_new_position(struct Implicit_Data *data, int index, const float x[3]);
+void SIM_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3]);
+void SIM_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3]);
-void BPH_mass_spring_clear_constraints(struct Implicit_Data *data);
-void BPH_mass_spring_add_constraint_ndof0(struct Implicit_Data *data,
+void SIM_mass_spring_clear_constraints(struct Implicit_Data *data);
+void SIM_mass_spring_add_constraint_ndof0(struct Implicit_Data *data,
int index,
const float dV[3]);
-void BPH_mass_spring_add_constraint_ndof1(struct Implicit_Data *data,
+void SIM_mass_spring_add_constraint_ndof1(struct Implicit_Data *data,
int index,
const float c1[3],
const float c2[3],
const float dV[3]);
-void BPH_mass_spring_add_constraint_ndof2(struct Implicit_Data *data,
+void SIM_mass_spring_add_constraint_ndof2(struct Implicit_Data *data,
int index,
const float c1[3],
const float dV[3]);
-bool BPH_mass_spring_solve_velocities(struct Implicit_Data *data,
+bool SIM_mass_spring_solve_velocities(struct Implicit_Data *data,
float dt,
struct ImplicitSolverResult *result);
-bool BPH_mass_spring_solve_positions(struct Implicit_Data *data, float dt);
-void BPH_mass_spring_apply_result(struct Implicit_Data *data);
+bool SIM_mass_spring_solve_positions(struct Implicit_Data *data, float dt);
+void SIM_mass_spring_apply_result(struct Implicit_Data *data);
/* Clear the force vector at the beginning of the time step */
-void BPH_mass_spring_clear_forces(struct Implicit_Data *data);
+void SIM_mass_spring_clear_forces(struct Implicit_Data *data);
/* Fictitious forces introduced by moving coordinate systems */
-void BPH_mass_spring_force_reference_frame(struct Implicit_Data *data,
+void SIM_mass_spring_force_reference_frame(struct Implicit_Data *data,
int index,
const float acceleration[3],
const float omega[3],
const float domega_dt[3],
float mass);
/* Simple uniform gravity force */
-void BPH_mass_spring_force_gravity(struct Implicit_Data *data,
+void SIM_mass_spring_force_gravity(struct Implicit_Data *data,
int index,
float mass,
const float g[3]);
/* Global drag force (velocity damping) */
-void BPH_mass_spring_force_drag(struct Implicit_Data *data, float drag);
+void SIM_mass_spring_force_drag(struct Implicit_Data *data, float drag);
/* Custom external force */
-void BPH_mass_spring_force_extern(
+void SIM_mass_spring_force_extern(
struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3]);
/* Wind force, acting on a face (only generates pressure from the normal component) */
-void BPH_mass_spring_force_face_wind(
+void SIM_mass_spring_force_face_wind(
struct Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]);
/* Arbitrary per-unit-area vector force field acting on a face. */
-void BPH_mass_spring_force_face_extern(
+void SIM_mass_spring_force_face_extern(
struct Implicit_Data *data, int v1, int v2, int v3, const float (*forcevec)[3]);
/* Wind force, acting on an edge */
-void BPH_mass_spring_force_edge_wind(struct Implicit_Data *data,
+void SIM_mass_spring_force_edge_wind(struct Implicit_Data *data,
int v1,
int v2,
float radius1,
float radius2,
const float (*winvec)[3]);
/* Wind force, acting on a vertex */
-void BPH_mass_spring_force_vertex_wind(struct Implicit_Data *data,
+void SIM_mass_spring_force_vertex_wind(struct Implicit_Data *data,
int v,
float radius,
const float (*winvec)[3]);
/* Linear spring force between two points */
-bool BPH_mass_spring_force_spring_linear(struct Implicit_Data *data,
+bool SIM_mass_spring_force_spring_linear(struct Implicit_Data *data,
int i,
int j,
float restlen,
@@ -157,7 +157,7 @@ bool BPH_mass_spring_force_spring_linear(struct Implicit_Data *data,
bool new_compress,
float clamp_force);
/* Angular spring force between two polygons */
-bool BPH_mass_spring_force_spring_angular(struct Implicit_Data *data,
+bool SIM_mass_spring_force_spring_angular(struct Implicit_Data *data,
int i,
int j,
int *i_a,
@@ -168,10 +168,10 @@ bool BPH_mass_spring_force_spring_angular(struct Implicit_Data *data,
float stiffness,
float damping);
/* Bending force, forming a triangle at the base of two structural springs */
-bool BPH_mass_spring_force_spring_bending(
+bool SIM_mass_spring_force_spring_bending(
struct Implicit_Data *data, int i, int j, float restlen, float kb, float cb);
/* Angular bending force based on local target vectors */
-bool BPH_mass_spring_force_spring_bending_hair(struct Implicit_Data *data,
+bool SIM_mass_spring_force_spring_bending_hair(struct Implicit_Data *data,
int i,
int j,
int k,
@@ -179,17 +179,17 @@ bool BPH_mass_spring_force_spring_bending_hair(struct Implicit_Data *data,
float stiffness,
float damping);
/* Global goal spring */
-bool BPH_mass_spring_force_spring_goal(struct Implicit_Data *data,
+bool SIM_mass_spring_force_spring_goal(struct Implicit_Data *data,
int i,
const float goal_x[3],
const float goal_v[3],
float stiffness,
float damping);
-float BPH_tri_tetra_volume_signed_6x(struct Implicit_Data *data, int v1, int v2, int v3);
-float BPH_tri_area(struct Implicit_Data *data, int v1, int v2, int v3);
+float SIM_tri_tetra_volume_signed_6x(struct Implicit_Data *data, int v1, int v2, int v3);
+float SIM_tri_area(struct Implicit_Data *data, int v1, int v2, int v3);
-void BPH_mass_spring_force_pressure(struct Implicit_Data *data,
+void SIM_mass_spring_force_pressure(struct Implicit_Data *data,
int v1,
int v2,
int v3,
@@ -203,16 +203,16 @@ struct HairGrid;
#define MAX_HAIR_GRID_RES 256
-struct HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize,
+struct HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize,
const float gmin[3],
const float gmax[3]);
-void BPH_hair_volume_free_vertex_grid(struct HairGrid *grid);
-void BPH_hair_volume_grid_geometry(
+void SIM_hair_volume_free_vertex_grid(struct HairGrid *grid);
+void SIM_hair_volume_grid_geometry(
struct HairGrid *grid, float *cellsize, int res[3], float gmin[3], float gmax[3]);
-void BPH_hair_volume_grid_clear(struct HairGrid *grid);
-void BPH_hair_volume_add_vertex(struct HairGrid *grid, const float x[3], const float v[3]);
-void BPH_hair_volume_add_segment(struct HairGrid *grid,
+void SIM_hair_volume_grid_clear(struct HairGrid *grid);
+void SIM_hair_volume_add_vertex(struct HairGrid *grid, const float x[3], const float v[3]);
+void SIM_hair_volume_add_segment(struct HairGrid *grid,
const float x1[3],
const float v1[3],
const float x2[3],
@@ -225,17 +225,17 @@ void BPH_hair_volume_add_segment(struct HairGrid *grid,
const float dir2[3],
const float dir3[3]);
-void BPH_hair_volume_normalize_vertex_grid(struct HairGrid *grid);
+void SIM_hair_volume_normalize_vertex_grid(struct HairGrid *grid);
-bool BPH_hair_volume_solve_divergence(struct HairGrid *grid,
+bool SIM_hair_volume_solve_divergence(struct HairGrid *grid,
float dt,
float target_density,
float target_strength);
#if 0 /* XXX weighting is incorrect, disabled for now */
-void BPH_hair_volume_vertex_grid_filter_box(struct HairVertexGrid *grid, int kernel_size);
+void SIM_hair_volume_vertex_grid_filter_box(struct HairVertexGrid *grid, int kernel_size);
#endif
-void BPH_hair_volume_grid_interpolate(struct HairGrid *grid,
+void SIM_hair_volume_grid_interpolate(struct HairGrid *grid,
const float x[3],
float *density,
float velocity[3],
@@ -247,7 +247,7 @@ void BPH_hair_volume_grid_interpolate(struct HairGrid *grid,
* fluid_factor controls blending between PIC (Particle-in-Cell)
* and FLIP (Fluid-Implicit-Particle) methods (0 = only PIC, 1 = only FLIP)
*/
-void BPH_hair_volume_grid_velocity(
+void SIM_hair_volume_grid_velocity(
struct HairGrid *grid, const float x[3], const float v[3], float fluid_factor, float r_v[3]);
/* XXX Warning: expressing grid effects on velocity as a force is not very stable,
* due to discontinuities in interpolated values!
@@ -255,7 +255,7 @@ void BPH_hair_volume_grid_velocity(
* "Detail Preserving Continuum Simulation of Straight Hair"
* (McAdams, Selle 2009)
*/
-void BPH_hair_volume_vertex_grid_forces(struct HairGrid *grid,
+void SIM_hair_volume_vertex_grid_forces(struct HairGrid *grid,
const float x[3],
const float v[3],
float smoothfac,
diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c
index 54d38f3c10b..856572aa3f5 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/simulation/intern/implicit_blender.c
@@ -40,7 +40,7 @@
# include "BKE_collision.h"
# include "BKE_effect.h"
-# include "BPH_mass_spring.h"
+# include "SIM_mass_spring.h"
# ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wtype-limits"
@@ -679,7 +679,7 @@ typedef struct Implicit_Data {
fmatrix3x3 *P, *Pinv; /* pre-conditioning matrix */
} Implicit_Data;
-Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
+Implicit_Data *SIM_mass_spring_solver_create(int numverts, int numsprings)
{
Implicit_Data *id = (Implicit_Data *)MEM_callocN(sizeof(Implicit_Data), "implicit vecmat");
@@ -707,7 +707,7 @@ Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
return id;
}
-void BPH_mass_spring_solver_free(Implicit_Data *id)
+void SIM_mass_spring_solver_free(Implicit_Data *id)
{
del_bfmatrix(id->tfm);
del_bfmatrix(id->A);
@@ -924,8 +924,8 @@ static int cg_filtered(lfVector *ldV,
del_lfvector(s);
// printf("W/O conjgrad_loopcount: %d\n", conjgrad_loopcount);
- result->status = conjgrad_loopcount < conjgrad_looplimit ? BPH_SOLVER_SUCCESS :
- BPH_SOLVER_NO_CONVERGENCE;
+ result->status = conjgrad_loopcount < conjgrad_looplimit ? SIM_SOLVER_SUCCESS :
+ SIM_SOLVER_NO_CONVERGENCE;
result->iterations = conjgrad_loopcount;
result->error = bnorm2 > 0.0f ? sqrtf(delta_new / bnorm2) : 0.0f;
@@ -1139,7 +1139,7 @@ static int cg_filtered_pre(lfVector *dv,
}
# endif
-bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSolverResult *result)
+bool SIM_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSolverResult *result)
{
unsigned int numverts = data->dFdV[0].vcount;
@@ -1173,10 +1173,10 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
del_lfvector(dFdXmV);
- return result->status == BPH_SOLVER_SUCCESS;
+ return result->status == SIM_SOLVER_SUCCESS;
}
-bool BPH_mass_spring_solve_positions(Implicit_Data *data, float dt)
+bool SIM_mass_spring_solve_positions(Implicit_Data *data, float dt)
{
int numverts = data->M[0].vcount;
@@ -1186,20 +1186,20 @@ bool BPH_mass_spring_solve_positions(Implicit_Data *data, float dt)
return true;
}
-void BPH_mass_spring_apply_result(Implicit_Data *data)
+void SIM_mass_spring_apply_result(Implicit_Data *data)
{
int numverts = data->M[0].vcount;
cp_lfvector(data->X, data->Xnew, numverts);
cp_lfvector(data->V, data->Vnew, numverts);
}
-void BPH_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass)
+void SIM_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass)
{
unit_m3(data->M[index].m);
mul_m3_fl(data->M[index].m, mass);
}
-void BPH_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tfm[3][3])
+void SIM_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tfm[3][3])
{
# ifdef CLOTH_ROOT_FRAME
copy_m3_m3(data->tfm[index].m, tfm);
@@ -1209,7 +1209,7 @@ void BPH_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tf
# endif
}
-void BPH_mass_spring_set_motion_state(Implicit_Data *data,
+void SIM_mass_spring_set_motion_state(Implicit_Data *data,
int index,
const float x[3],
const float v[3])
@@ -1218,17 +1218,17 @@ void BPH_mass_spring_set_motion_state(Implicit_Data *data,
world_to_root_v3(data, index, data->V[index], v);
}
-void BPH_mass_spring_set_position(Implicit_Data *data, int index, const float x[3])
+void SIM_mass_spring_set_position(Implicit_Data *data, int index, const float x[3])
{
world_to_root_v3(data, index, data->X[index], x);
}
-void BPH_mass_spring_set_velocity(Implicit_Data *data, int index, const float v[3])
+void SIM_mass_spring_set_velocity(Implicit_Data *data, int index, const float v[3])
{
world_to_root_v3(data, index, data->V[index], v);
}
-void BPH_mass_spring_get_motion_state(struct Implicit_Data *data,
+void SIM_mass_spring_get_motion_state(struct Implicit_Data *data,
int index,
float x[3],
float v[3])
@@ -1241,39 +1241,39 @@ void BPH_mass_spring_get_motion_state(struct Implicit_Data *data,
}
}
-void BPH_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3])
+void SIM_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3])
{
root_to_world_v3(data, index, x, data->X[index]);
}
-void BPH_mass_spring_get_velocity(struct Implicit_Data *data, int index, float v[3])
+void SIM_mass_spring_get_velocity(struct Implicit_Data *data, int index, float v[3])
{
root_to_world_v3(data, index, v, data->V[index]);
}
-void BPH_mass_spring_get_new_position(struct Implicit_Data *data, int index, float x[3])
+void SIM_mass_spring_get_new_position(struct Implicit_Data *data, int index, float x[3])
{
root_to_world_v3(data, index, x, data->Xnew[index]);
}
-void BPH_mass_spring_set_new_position(struct Implicit_Data *data, int index, const float x[3])
+void SIM_mass_spring_set_new_position(struct Implicit_Data *data, int index, const float x[3])
{
world_to_root_v3(data, index, data->Xnew[index], x);
}
-void BPH_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3])
+void SIM_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3])
{
root_to_world_v3(data, index, v, data->Vnew[index]);
}
-void BPH_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3])
+void SIM_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3])
{
world_to_root_v3(data, index, data->Vnew[index], v);
}
/* -------------------------------- */
-static int BPH_mass_spring_add_block(Implicit_Data *data, int v1, int v2)
+static int SIM_mass_spring_add_block(Implicit_Data *data, int v1, int v2)
{
int s = data->M[0].vcount + data->num_blocks; /* index from array start */
BLI_assert(s < data->M[0].vcount + data->M[0].scount);
@@ -1291,7 +1291,7 @@ static int BPH_mass_spring_add_block(Implicit_Data *data, int v1, int v2)
return s;
}
-void BPH_mass_spring_clear_constraints(Implicit_Data *data)
+void SIM_mass_spring_clear_constraints(Implicit_Data *data)
{
int i, numverts = data->S[0].vcount;
for (i = 0; i < numverts; i++) {
@@ -1300,14 +1300,14 @@ void BPH_mass_spring_clear_constraints(Implicit_Data *data)
}
}
-void BPH_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3])
+void SIM_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3])
{
zero_m3(data->S[index].m);
world_to_root_v3(data, index, data->z[index], dV);
}
-void BPH_mass_spring_add_constraint_ndof1(
+void SIM_mass_spring_add_constraint_ndof1(
Implicit_Data *data, int index, const float c1[3], const float c2[3], const float dV[3])
{
float m[3][3], p[3], q[3], u[3], cmat[3][3];
@@ -1328,7 +1328,7 @@ void BPH_mass_spring_add_constraint_ndof1(
add_v3_v3(data->z[index], u);
}
-void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data,
+void SIM_mass_spring_add_constraint_ndof2(Implicit_Data *data,
int index,
const float c1[3],
const float dV[3])
@@ -1346,7 +1346,7 @@ void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data,
add_v3_v3(data->z[index], u);
}
-void BPH_mass_spring_clear_forces(Implicit_Data *data)
+void SIM_mass_spring_clear_forces(Implicit_Data *data)
{
int numverts = data->M[0].vcount;
zero_lfvector(data->F, numverts);
@@ -1356,7 +1356,7 @@ void BPH_mass_spring_clear_forces(Implicit_Data *data)
data->num_blocks = 0;
}
-void BPH_mass_spring_force_reference_frame(Implicit_Data *data,
+void SIM_mass_spring_force_reference_frame(Implicit_Data *data,
int index,
const float acceleration[3],
const float omega[3],
@@ -1411,7 +1411,7 @@ void BPH_mass_spring_force_reference_frame(Implicit_Data *data,
# endif
}
-void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, const float g[3])
+void SIM_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, const float g[3])
{
/* force = mass * acceleration (in this case: gravity) */
float f[3];
@@ -1421,7 +1421,7 @@ void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, c
add_v3_v3(data->F[index], f);
}
-void BPH_mass_spring_force_drag(Implicit_Data *data, float drag)
+void SIM_mass_spring_force_drag(Implicit_Data *data, float drag)
{
int i, numverts = data->M[0].vcount;
for (i = 0; i < numverts; i++) {
@@ -1436,7 +1436,7 @@ void BPH_mass_spring_force_drag(Implicit_Data *data, float drag)
}
}
-void BPH_mass_spring_force_extern(
+void SIM_mass_spring_force_extern(
struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3])
{
float tf[3], tdfdx[3][3], tdfdv[3][3];
@@ -1465,7 +1465,7 @@ static float calc_nor_area_tri(float nor[3],
/* XXX does not support force jacobians yet, since the effector system does not provide them either
*/
-void BPH_mass_spring_force_face_wind(
+void SIM_mass_spring_force_face_wind(
Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
{
const float effector_scale = 0.02f;
@@ -1505,7 +1505,7 @@ void BPH_mass_spring_force_face_wind(
madd_v3_v3fl(data->F[v3], nor, base_force + force[2]);
}
-void BPH_mass_spring_force_face_extern(
+void SIM_mass_spring_force_face_extern(
Implicit_Data *data, int v1, int v2, int v3, const float (*forcevec)[3])
{
const float effector_scale = 0.02f;
@@ -1536,20 +1536,20 @@ void BPH_mass_spring_force_face_extern(
}
}
-float BPH_tri_tetra_volume_signed_6x(Implicit_Data *data, int v1, int v2, int v3)
+float SIM_tri_tetra_volume_signed_6x(Implicit_Data *data, int v1, int v2, int v3)
{
/* The result will be 6x the volume */
return volume_tri_tetrahedron_signed_v3_6x(data->X[v1], data->X[v2], data->X[v3]);
}
-float BPH_tri_area(struct Implicit_Data *data, int v1, int v2, int v3)
+float SIM_tri_area(struct Implicit_Data *data, int v1, int v2, int v3)
{
float nor[3];
return calc_nor_area_tri(nor, data->X[v1], data->X[v2], data->X[v3]);
}
-void BPH_mass_spring_force_pressure(Implicit_Data *data,
+void SIM_mass_spring_force_pressure(Implicit_Data *data,
int v1,
int v2,
int v3,
@@ -1617,7 +1617,7 @@ static void edge_wind_vertex(const float dir[3],
mul_v3_v3fl(f, wind, density * cross_section);
}
-void BPH_mass_spring_force_edge_wind(
+void SIM_mass_spring_force_edge_wind(
Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float (*winvec)[3])
{
float win[3], dir[3], length;
@@ -1635,7 +1635,7 @@ void BPH_mass_spring_force_edge_wind(
add_v3_v3(data->F[v2], f);
}
-void BPH_mass_spring_force_vertex_wind(Implicit_Data *data,
+void SIM_mass_spring_force_vertex_wind(Implicit_Data *data,
int v,
float UNUSED(radius),
const float (*winvec)[3])
@@ -1766,7 +1766,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data,
BLI_INLINE void apply_spring(
Implicit_Data *data, int i, int j, const float f[3], float dfdx[3][3], float dfdv[3][3])
{
- int block_ij = BPH_mass_spring_add_block(data, i, j);
+ int block_ij = SIM_mass_spring_add_block(data, i, j);
add_v3_v3(data->F[i], f);
sub_v3_v3(data->F[j], f);
@@ -1780,7 +1780,7 @@ BLI_INLINE void apply_spring(
sub_m3_m3m3(data->dFdV[block_ij].m, data->dFdV[block_ij].m, dfdv);
}
-bool BPH_mass_spring_force_spring_linear(Implicit_Data *data,
+bool SIM_mass_spring_force_spring_linear(Implicit_Data *data,
int i,
int j,
float restlen,
@@ -1841,7 +1841,7 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data,
}
/* See "Stable but Responsive Cloth" (Choi, Ko 2005) */
-bool BPH_mass_spring_force_spring_bending(
+bool SIM_mass_spring_force_spring_bending(
Implicit_Data *data, int i, int j, float restlen, float kb, float cb)
{
float extent[3], length, dir[3], vel[3];
@@ -1948,7 +1948,7 @@ BLI_INLINE void spring_angle(Implicit_Data *data,
/* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps
* in Cloth Simulation". */
-bool BPH_mass_spring_force_spring_angular(Implicit_Data *data,
+bool SIM_mass_spring_force_spring_angular(Implicit_Data *data,
int i,
int j,
int *i_a,
@@ -2169,7 +2169,7 @@ BLI_INLINE void spring_hairbend_estimate_dfdv(Implicit_Data *data,
/* Angular spring that pulls the vertex toward the local target
* See "Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a)
*/
-bool BPH_mass_spring_force_spring_bending_hair(Implicit_Data *data,
+bool SIM_mass_spring_force_spring_bending_hair(Implicit_Data *data,
int i,
int j,
int k,
@@ -2184,9 +2184,9 @@ bool BPH_mass_spring_force_spring_bending_hair(Implicit_Data *data,
const float vecnull[3] = {0.0f, 0.0f, 0.0f};
- int block_ij = BPH_mass_spring_add_block(data, i, j);
- int block_jk = BPH_mass_spring_add_block(data, j, k);
- int block_ik = BPH_mass_spring_add_block(data, i, k);
+ int block_ij = SIM_mass_spring_add_block(data, i, j);
+ int block_jk = SIM_mass_spring_add_block(data, j, k);
+ int block_ik = SIM_mass_spring_add_block(data, i, k);
world_to_root_v3(data, j, goal, target);
@@ -2318,7 +2318,7 @@ bool BPH_mass_spring_force_spring_bending_hair(Implicit_Data *data,
return true;
}
-bool BPH_mass_spring_force_spring_goal(Implicit_Data *data,
+bool SIM_mass_spring_force_spring_goal(Implicit_Data *data,
int i,
const float goal_x[3],
const float goal_v[3],
diff --git a/source/blender/physics/intern/implicit_eigen.cpp b/source/blender/simulation/intern/implicit_eigen.cpp
index 58538c13116..15b9e30e32a 100644
--- a/source/blender/physics/intern/implicit_eigen.cpp
+++ b/source/blender/simulation/intern/implicit_eigen.cpp
@@ -78,7 +78,7 @@ extern "C" {
# include "BKE_effect.h"
# include "BKE_global.h"
-# include "BPH_mass_spring.h"
+# include "SIM_mass_spring.h"
}
typedef float Scalar;
@@ -460,20 +460,20 @@ struct Implicit_Data {
lMatrixCtor iS; /* filtering matrix for constraints */
};
-Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
+Implicit_Data *SIM_mass_spring_solver_create(int numverts, int numsprings)
{
Implicit_Data *id = new Implicit_Data(numverts);
return id;
}
-void BPH_mass_spring_solver_free(Implicit_Data *id)
+void SIM_mass_spring_solver_free(Implicit_Data *id)
{
if (id) {
delete id;
}
}
-int BPH_mass_spring_solver_numvert(Implicit_Data *id)
+int SIM_mass_spring_solver_numvert(Implicit_Data *id)
{
if (id) {
return id->numverts;
@@ -511,7 +511,7 @@ BLI_INLINE void root_to_world_m3(Implicit_Data *data, int index, float r[3][3],
/* ================================ */
-bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSolverResult *result)
+bool SIM_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSolverResult *result)
{
# ifdef USE_EIGEN_CORE
typedef ConjugateGradient solver_t;
@@ -566,16 +566,16 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
switch (cg.info()) {
case Eigen::Success:
- result->status = BPH_SOLVER_SUCCESS;
+ result->status = SIM_SOLVER_SUCCESS;
break;
case Eigen::NoConvergence:
- result->status = BPH_SOLVER_NO_CONVERGENCE;
+ result->status = SIM_SOLVER_NO_CONVERGENCE;
break;
case Eigen::InvalidInput:
- result->status = BPH_SOLVER_INVALID_INPUT;
+ result->status = SIM_SOLVER_INVALID_INPUT;
break;
case Eigen::NumericalIssue:
- result->status = BPH_SOLVER_NUMERICAL_ISSUE;
+ result->status = SIM_SOLVER_NUMERICAL_ISSUE;
break;
}
@@ -585,7 +585,7 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
return cg.info() == Eigen::Success;
}
-bool BPH_mass_spring_solve_positions(Implicit_Data *data, float dt)
+bool SIM_mass_spring_solve_positions(Implicit_Data *data, float dt)
{
data->Xnew = data->X + data->Vnew * dt;
return true;
@@ -593,13 +593,13 @@ bool BPH_mass_spring_solve_positions(Implicit_Data *data, float dt)
/* ================================ */
-void BPH_mass_spring_apply_result(Implicit_Data *data)
+void SIM_mass_spring_apply_result(Implicit_Data *data)
{
data->X = data->Xnew;
data->V = data->Vnew;
}
-void BPH_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass)
+void SIM_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass)
{
float m[3][3];
copy_m3_m3(m, I);
@@ -607,7 +607,7 @@ void BPH_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass)
data->iM.add(index, index, m);
}
-void BPH_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tfm[3][3])
+void SIM_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tfm[3][3])
{
# ifdef CLOTH_ROOT_FRAME
copy_m3_m3(data->tfm[index], tfm);
@@ -617,7 +617,7 @@ void BPH_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tf
# endif
}
-void BPH_mass_spring_set_motion_state(Implicit_Data *data,
+void SIM_mass_spring_set_motion_state(Implicit_Data *data,
int index,
const float x[3],
const float v[3])
@@ -626,17 +626,17 @@ void BPH_mass_spring_set_motion_state(Implicit_Data *data,
world_to_root_v3(data, index, data->V.v3(index), v);
}
-void BPH_mass_spring_set_position(Implicit_Data *data, int index, const float x[3])
+void SIM_mass_spring_set_position(Implicit_Data *data, int index, const float x[3])
{
world_to_root_v3(data, index, data->X.v3(index), x);
}
-void BPH_mass_spring_set_velocity(Implicit_Data *data, int index, const float v[3])
+void SIM_mass_spring_set_velocity(Implicit_Data *data, int index, const float v[3])
{
world_to_root_v3(data, index, data->V.v3(index), v);
}
-void BPH_mass_spring_get_motion_state(struct Implicit_Data *data,
+void SIM_mass_spring_get_motion_state(struct Implicit_Data *data,
int index,
float x[3],
float v[3])
@@ -649,22 +649,22 @@ void BPH_mass_spring_get_motion_state(struct Implicit_Data *data,
}
}
-void BPH_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3])
+void SIM_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3])
{
root_to_world_v3(data, index, x, data->X.v3(index));
}
-void BPH_mass_spring_get_new_velocity(Implicit_Data *data, int index, float v[3])
+void SIM_mass_spring_get_new_velocity(Implicit_Data *data, int index, float v[3])
{
root_to_world_v3(data, index, v, data->V.v3(index));
}
-void BPH_mass_spring_set_new_velocity(Implicit_Data *data, int index, const float v[3])
+void SIM_mass_spring_set_new_velocity(Implicit_Data *data, int index, const float v[3])
{
world_to_root_v3(data, index, data->V.v3(index), v);
}
-void BPH_mass_spring_clear_constraints(Implicit_Data *data)
+void SIM_mass_spring_clear_constraints(Implicit_Data *data)
{
int numverts = data->numverts;
for (int i = 0; i < numverts; i++) {
@@ -673,14 +673,14 @@ void BPH_mass_spring_clear_constraints(Implicit_Data *data)
}
}
-void BPH_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3])
+void SIM_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3])
{
data->iS.sub(index, index, I);
world_to_root_v3(data, index, data->z.v3(index), dV);
}
-void BPH_mass_spring_add_constraint_ndof1(
+void SIM_mass_spring_add_constraint_ndof1(
Implicit_Data *data, int index, const float c1[3], const float c2[3], const float dV[3])
{
float m[3][3], p[3], q[3], u[3], cmat[3][3];
@@ -701,7 +701,7 @@ void BPH_mass_spring_add_constraint_ndof1(
add_v3_v3(data->z.v3(index), u);
}
-void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data,
+void SIM_mass_spring_add_constraint_ndof2(Implicit_Data *data,
int index,
const float c1[3],
const float dV[3])
@@ -719,14 +719,14 @@ void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data,
add_v3_v3(data->z.v3(index), u);
}
-void BPH_mass_spring_clear_forces(Implicit_Data *data)
+void SIM_mass_spring_clear_forces(Implicit_Data *data)
{
data->F.setZero();
data->dFdX.setZero();
data->dFdV.setZero();
}
-void BPH_mass_spring_force_reference_frame(Implicit_Data *data,
+void SIM_mass_spring_force_reference_frame(Implicit_Data *data,
int index,
const float acceleration[3],
const float omega[3],
@@ -781,7 +781,7 @@ void BPH_mass_spring_force_reference_frame(Implicit_Data *data,
# endif
}
-void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, const float g[3])
+void SIM_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, const float g[3])
{
/* force = mass * acceleration (in this case: gravity) */
float f[3];
@@ -791,7 +791,7 @@ void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, c
add_v3_v3(data->F.v3(index), f);
}
-void BPH_mass_spring_force_drag(Implicit_Data *data, float drag)
+void SIM_mass_spring_force_drag(Implicit_Data *data, float drag)
{
int numverts = data->numverts;
for (int i = 0; i < numverts; i++) {
@@ -806,7 +806,7 @@ void BPH_mass_spring_force_drag(Implicit_Data *data, float drag)
}
}
-void BPH_mass_spring_force_extern(
+void SIM_mass_spring_force_extern(
struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3])
{
float tf[3], tdfdx[3][3], tdfdv[3][3];
@@ -835,7 +835,7 @@ static float calc_nor_area_tri(float nor[3],
/* XXX does not support force jacobians yet,
* since the effector system does not provide them either. */
-void BPH_mass_spring_force_face_wind(
+void SIM_mass_spring_force_face_wind(
Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
{
const float effector_scale = 0.02f;
@@ -856,7 +856,7 @@ void BPH_mass_spring_force_face_wind(
madd_v3_v3fl(data->F.v3(v3), nor, factor * dot_v3v3(win, nor));
}
-void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const float (*winvec)[3])
+void SIM_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const float (*winvec)[3])
{
const float effector_scale = 0.01;
float win[3], dir[3], nor[3], length;
@@ -1000,7 +1000,7 @@ BLI_INLINE void apply_spring(
data->idFdV.sub(j, i, dfdv);
}
-bool BPH_mass_spring_force_spring_linear(Implicit_Data *data,
+bool SIM_mass_spring_force_spring_linear(Implicit_Data *data,
int i,
int j,
float restlen,
@@ -1063,7 +1063,7 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data,
}
/* See "Stable but Responsive Cloth" (Choi, Ko 2005) */
-bool BPH_mass_spring_force_spring_bending(Implicit_Data *data,
+bool SIM_mass_spring_force_spring_bending(Implicit_Data *data,
int i,
int j,
float restlen,
@@ -1293,7 +1293,7 @@ BLI_INLINE void spring_angbend_estimate_dfdv(Implicit_Data *data,
/* Angular spring that pulls the vertex toward the local target
* See "Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a)
*/
-bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data,
+bool SIM_mass_spring_force_spring_bending_angular(Implicit_Data *data,
int i,
int j,
int k,
@@ -1444,7 +1444,7 @@ bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data,
return true;
}
-bool BPH_mass_spring_force_spring_goal(Implicit_Data *data,
+bool SIM_mass_spring_force_spring_goal(Implicit_Data *data,
int i,
const float goal_x[3],
const float goal_v[3],
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 6ed6c485e89..396b59ba6e2 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -548,7 +548,7 @@ static void gizmo_draw_select_3d_loop(const bContext *C,
/* pass */
}
else {
- glDepthMask(!is_depth_skip);
+ GPU_depth_mask(!is_depth_skip);
is_depth_skip_prev = is_depth_skip;
}
@@ -565,7 +565,7 @@ static void gizmo_draw_select_3d_loop(const bContext *C,
GPU_depth_test(false);
}
if (is_depth_skip_prev) {
- glDepthMask(true);
+ GPU_depth_mask(true);
}
}
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 2b679dfefde..4cc30d65fdb 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -403,14 +403,8 @@ static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen)
/* We don't support multisample textures here. */
BLI_assert(GPU_texture_target(texture) == GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture));
-
/* No mipmaps or filtering. */
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
- /* GL_TEXTURE_BASE_LEVEL = 0 by default */
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glBindTexture(GL_TEXTURE_2D, 0);
+ GPU_texture_mipmap_mode(texture, false, false);
}
static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_viewport)
@@ -554,24 +548,10 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
alpha = 1.0f;
}
- /* setup actual texture */
- GPUTexture *texture = wm_draw_region_texture(region, view);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture));
-
/* wmOrtho for the screen has this same offset */
const float halfx = GLA_PIXEL_OFS / (BLI_rcti_size_x(&region->winrct) + 1);
const float halfy = GLA_PIXEL_OFS / (BLI_rcti_size_y(&region->winrct) + 1);
- if (blend) {
- /* GL_ONE because regions drawn offscreen have premultiplied alpha. */
- GPU_blend(true);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- }
-
- GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
- GPU_shader_bind(shader);
-
rcti rect_geo = region->winrct;
rect_geo.xmax += 1;
rect_geo.ymax += 1;
@@ -598,26 +578,39 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
alpha = 1.0f;
}
- glUniform1i(GPU_shader_get_uniform(shader, "image"), 0);
- glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"),
- rect_tex.xmin,
- rect_tex.ymin,
- rect_tex.xmax,
- rect_tex.ymax);
- glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"),
- rect_geo.xmin,
- rect_geo.ymin,
- rect_geo.xmax,
- rect_geo.ymax);
- glUniform4f(
- GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
+ /* Not the same layout as rectf/recti. */
+ float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax};
+ float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax};
+
+ if (blend) {
+ /* GL_ONE because regions drawn offscreen have premultiplied alpha. */
+ GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ GPU_blend(true);
+ }
+
+ /* setup actual texture */
+ GPUTexture *texture = wm_draw_region_texture(region, view);
+
+ GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
+ GPU_shader_bind(shader);
+
+ int color_loc = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR);
+ int rect_tex_loc = GPU_shader_get_uniform(shader, "rect_icon");
+ int rect_geo_loc = GPU_shader_get_uniform(shader, "rect_geom");
+ int texture_bind_loc = GPU_shader_get_texture_binding(shader, "image");
+
+ GPU_texture_bind(texture, texture_bind_loc);
+
+ GPU_shader_uniform_vector(shader, rect_tex_loc, 4, 1, rectt);
+ GPU_shader_uniform_vector(shader, rect_geo_loc, 4, 1, rectg);
+ GPU_shader_uniform_vector(shader, color_loc, 4, 1, (const float[4]){1, 1, 1, 1});
GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4);
- glBindTexture(GL_TEXTURE_2D, 0);
+ GPU_texture_unbind(texture);
if (blend) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(false);
}
}
@@ -736,8 +729,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
wm_draw_region_buffer_create(region, false, false);
wm_draw_region_bind(region, 0);
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear_color(0, 0, 0, 0);
+ GPU_clear(GPU_COLOR_BIT);
ED_region_do_draw(C, region);
wm_draw_region_unbind(region);
@@ -759,8 +752,8 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
* Actually this is only a problem when resizing the window.
* If it becomes a problem we should clear only when window size changes. */
#if 0
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear_color(0, 0, 0, 0);
+ GPU_clear(GPU_COLOR_BIT);
#endif
/* Blit non-overlapping area regions. */
@@ -874,8 +867,7 @@ static void wm_draw_window(bContext *C, wmWindow *win)
GPU_offscreen_unbind(offscreen, false);
/* Draw offscreen buffer to screen. */
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture));
+ GPU_texture_bind(texture, 0);
wmWindowViewport(win);
if (win->stereo3d_format->display_mode == S3D_DISPLAY_SIDEBYSIDE) {
@@ -885,7 +877,7 @@ static void wm_draw_window(bContext *C, wmWindow *win)
wm_stereo3d_draw_topbottom(win, view);
}
- glBindTexture(GL_TEXTURE_2D, 0);
+ GPU_texture_unbind(texture);
}
GPU_offscreen_free(offscreen);
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 37c7e802554..50d2b4dd49e 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -58,6 +58,7 @@
#include "BIF_glutil.h"
#include "GPU_context.h"
+#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_init_exit.h"
@@ -309,8 +310,8 @@ static void playanim_toscreen(
CLAMP(offs_x, 0.0f, 1.0f);
CLAMP(offs_y, 0.0f, 1.0f);
- glClearColor(0.1, 0.1, 0.1, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear_color(0.1, 0.1, 0.1, 0.0);
+ GPU_clear(GPU_COLOR_BIT);
/* checkerboard for case alpha */
if (ibuf->planes == 32) {
@@ -1315,8 +1316,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
maxwiny = ibuf->y * (1 + (maxwiny / ibuf->y));
}
- glClearColor(0.1, 0.1, 0.1, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear_color(0.1, 0.1, 0.1, 0.0);
+ GPU_clear(GPU_COLOR_BIT);
int win_x, win_y;
playanim_window_get_size(&win_x, &win_y);
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 8ae343d5eb5..245560d3795 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -40,6 +40,7 @@
#include "ED_screen.h"
+#include "GPU_extensions.h"
#include "GPU_immediate.h"
#include "GPU_texture.h"
#include "GPU_viewport.h"
@@ -147,13 +148,6 @@ void wm_stereo3d_draw_topbottom(wmWindow *win, int view)
immUnbindProgram();
}
-static bool wm_stereo3d_quadbuffer_supported(void)
-{
- GLboolean stereo = GL_FALSE;
- glGetBooleanv(GL_STEREO, &stereo);
- return stereo == GL_TRUE;
-}
-
static bool wm_stereo3d_is_fullscreen_required(eStereoDisplayMode stereo_display)
{
return ELEM(stereo_display, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM);
@@ -325,7 +319,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
}
/* pageflip requires a new window to be created with the proper OS flags */
else if ((win_dst = wm_window_copy_test(C, win_src, false, false))) {
- if (wm_stereo3d_quadbuffer_supported()) {
+ if (GPU_stereo_quadbuffer_support()) {
BKE_report(op->reports, RPT_INFO, "Quad-buffer window successfully created");
}
else {
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index e1b2285313c..422b5fe5404 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -89,6 +89,7 @@
#include "GPU_init_exit.h"
#include "GPU_platform.h"
#include "GPU_state.h"
+#include "GPU_texture.h"
#include "UI_resources.h"
@@ -648,10 +649,10 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
}
#endif
/* until screens get drawn, make it nice gray */
- glClearColor(0.55, 0.55, 0.55, 0.0);
+ GPU_clear_color(0.55, 0.55, 0.55, 0.0);
/* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */
if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
- glClear(GL_COLOR_BUFFER_BIT);
+ GPU_clear(GPU_COLOR_BIT);
}
/* needed here, because it's used before it reads userdef */
@@ -2054,9 +2055,7 @@ void WM_window_pixel_sample_read(const wmWindowManager *wm,
GPU_context_active_set(win->gpuctx);
}
- glReadBuffer(GL_FRONT);
- glReadPixels(pos[0], pos[1], 1, 1, GL_RGB, GL_FLOAT, r_col);
- glReadBuffer(GL_BACK);
+ GPU_frontbuffer_read_pixels(pos[0], pos[1], 1, 1, 3, GPU_DATA_FLOAT, r_col);
if (setup_context) {
if (wm->windrawable) {
@@ -2089,10 +2088,7 @@ uint *WM_window_pixels_read(wmWindowManager *wm, wmWindow *win, int r_size[2])
const uint rect_len = r_size[0] * r_size[1];
uint *rect = MEM_mallocN(sizeof(*rect) * rect_len, __func__);
- glReadBuffer(GL_FRONT);
- glReadPixels(0, 0, r_size[0], r_size[1], GL_RGBA, GL_UNSIGNED_BYTE, rect);
- glFinish();
- glReadBuffer(GL_BACK);
+ GPU_frontbuffer_read_pixels(0, 0, r_size[0], r_size[1], 4, GPU_DATA_UNSIGNED_BYTE, rect);
if (setup_context) {
if (wm->windrawable) {
diff --git a/tests/gtests/CMakeLists.txt b/tests/gtests/CMakeLists.txt
index 0dfe041974e..4ce68a6f4c0 100644
--- a/tests/gtests/CMakeLists.txt
+++ b/tests/gtests/CMakeLists.txt
@@ -1,18 +1,13 @@
-# GTest
if(WITH_GTESTS)
-
- include(GTestTesting)
-
- add_definitions(${GFLAGS_DEFINES})
- add_definitions(${GLOG_DEFINES})
- add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
-
# Otherwise we get warnings here that we cant fix in external projects
remove_strict_flags()
+ # Build common test runner
+ add_subdirectory(runner)
+
+ # Build tests not yet ported to the common runner
add_subdirectory(testing)
- add_subdirectory(blenkernel)
add_subdirectory(blenlib)
add_subdirectory(blenloader)
add_subdirectory(guardedalloc)
diff --git a/tests/gtests/blenkernel/CMakeLists.txt b/tests/gtests/blenkernel/CMakeLists.txt
deleted file mode 100644
index 5cf4c7a27af..00000000000
--- a/tests/gtests/blenkernel/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# The Original Code is Copyright (C) 2020, Blender Foundation
-# All rights reserved.
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ..
- ../../../source/blender/blenkernel
- ../../../source/blender/blenlib
- ../../../source/blender/editors/include
- ../../../source/blender/makesdna
- ../../../source/blender/makesrna
- ../../../intern/guardedalloc
- ../../../intern/atomic
-)
-
-setup_libdirs()
-include_directories(${INC})
-
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
-set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
-
-if(WITH_BUILDINFO)
- set(BUILDINFO buildinfoobj)
-endif()
-
-BLENDER_TEST(BKE_armature "bf_blenloader;bf_blenkernel;bf_blenlib;${BUILDINFO}")
-BLENDER_TEST(BKE_fcurve "bf_blenloader;bf_blenkernel;bf_editor_animation;${BUILDINFO}")
diff --git a/tests/gtests/blenlib/BLI_math_base_safe_test.cc b/tests/gtests/blenlib/BLI_math_base_safe_test.cc
new file mode 100644
index 00000000000..2e3e083cf92
--- /dev/null
+++ b/tests/gtests/blenlib/BLI_math_base_safe_test.cc
@@ -0,0 +1,37 @@
+/* Apache License, Version 2.0 */
+
+#include "testing/testing.h"
+
+#include "BLI_math_base_safe.h"
+
+TEST(math_base, SafePowf)
+{
+ EXPECT_FLOAT_EQ(safe_powf(4.0f, 3.0f), 64.0f);
+ EXPECT_FLOAT_EQ(safe_powf(3.2f, 5.6f), 674.2793796f);
+ EXPECT_FLOAT_EQ(safe_powf(4.0f, -2.0f), 0.0625f);
+ EXPECT_FLOAT_EQ(safe_powf(6.0f, -3.2f), 0.003235311f);
+ EXPECT_FLOAT_EQ(safe_powf(-4.0f, 6), 4096.0f);
+ EXPECT_FLOAT_EQ(safe_powf(-3.0f, 5.5), 0.0f);
+ EXPECT_FLOAT_EQ(safe_powf(-2.5f, -4.0f), 0.0256f);
+ EXPECT_FLOAT_EQ(safe_powf(-3.7f, -4.5f), 0.0f);
+}
+
+TEST(math_base, SafeModf)
+{
+ EXPECT_FLOAT_EQ(safe_modf(3.4, 2.2f), 1.2f);
+ EXPECT_FLOAT_EQ(safe_modf(3.4, -2.2f), 1.2f);
+ EXPECT_FLOAT_EQ(safe_modf(-3.4, -2.2f), -1.2f);
+ EXPECT_FLOAT_EQ(safe_modf(-3.4, 0.0f), 0.0f);
+ EXPECT_FLOAT_EQ(safe_modf(0.0f, 3.0f), 0.0f);
+ EXPECT_FLOAT_EQ(safe_modf(55.0f, 10.0f), 5.0f);
+}
+
+TEST(math_base, SafeLogf)
+{
+ EXPECT_FLOAT_EQ(safe_logf(3.3f, 2.5f), 1.302995247f);
+ EXPECT_FLOAT_EQ(safe_logf(0.0f, 3.0f), 0.0f);
+ EXPECT_FLOAT_EQ(safe_logf(3.0f, 0.0f), 0.0f);
+ EXPECT_FLOAT_EQ(safe_logf(-2.0f, 4.3f), 0.0f);
+ EXPECT_FLOAT_EQ(safe_logf(2.0f, -4.3f), 0.0f);
+ EXPECT_FLOAT_EQ(safe_logf(-2.0f, -4.3f), 0.0f);
+}
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
index 496fe44234e..d151dacd7a4 100644
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ b/tests/gtests/blenlib/CMakeLists.txt
@@ -58,6 +58,7 @@ BLENDER_TEST(BLI_linklist_lockfree "bf_blenlib;bf_intern_numaapi")
BLENDER_TEST(BLI_listbase "bf_blenlib")
BLENDER_TEST(BLI_map "bf_blenlib")
BLENDER_TEST(BLI_math_base "bf_blenlib")
+BLENDER_TEST(BLI_math_base_safe "bf_blenlib")
BLENDER_TEST(BLI_math_bits "bf_blenlib")
BLENDER_TEST(BLI_math_color "bf_blenlib")
BLENDER_TEST(BLI_math_geom "bf_blenlib")
diff --git a/tests/gtests/runner/CMakeLists.txt b/tests/gtests/runner/CMakeLists.txt
new file mode 100644
index 00000000000..e7cbabfe7c6
--- /dev/null
+++ b/tests/gtests/runner/CMakeLists.txt
@@ -0,0 +1,63 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2020, Blender Foundation
+# All rights reserved.
+# ***** END GPL LICENSE BLOCK *****
+
+# Build the test runner. This runner takes care of running all GTests, i.e.
+# the code that was built using the blender_add_test_lib() CMake macro (see
+# macros.cmake).
+set(SRC
+ blender_test.cc
+)
+
+if(WITH_BUILDINFO)
+ list(APPEND SRC
+ "$<TARGET_OBJECTS:buildinfoobj>"
+ )
+endif()
+
+
+# Test libraries need to be linked "whole archive", because they're not
+# directly referenced from other code.
+get_property(_test_libs GLOBAL PROPERTY BLENDER_TEST_LIBS)
+if(WIN32)
+ list(APPEND TEST_LIBS ${_test_libs})
+elseif(APPLE)
+ list(APPEND TEST_LIBS "-Wl,-force_load" ${_test_libs})
+elseif(UNIX)
+ list(APPEND TEST_LIBS "-Wl,--whole-archive" ${_test_libs} "-Wl,--no-whole-archive")
+else()
+ message(FATAL_ERROR "Unknown how to link whole-archive with your compiler ${CMAKE_CXX_COMPILER_ID}")
+endif()
+unset(_test_libs)
+
+# This builds `bin/tests/blender_test`, but does not add it as a single test.
+setup_libdirs()
+BLENDER_SRC_GTEST_EX(
+ NAME blender
+ SRC "${SRC}"
+ EXTRA_LIBS "${TEST_LIBS}"
+ SKIP_ADD_TEST
+)
+setup_liblinks(blender_test)
+
+# This runs the blender_test executable with `--gtest_list_tests`, then
+# exposes those tests individually to the ctest runner.
+# See https://cmake.org/cmake/help/v3.18/module/GoogleTest.html
+include(GoogleTest)
+gtest_discover_tests(blender_test)
diff --git a/tests/gtests/runner/blender_test.cc b/tests/gtests/runner/blender_test.cc
new file mode 100644
index 00000000000..fbce7a4283f
--- /dev/null
+++ b/tests/gtests/runner/blender_test.cc
@@ -0,0 +1,25 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/* This file is intentionally left blank. It is necessary for CMake to have a source file for each
+ * executable. However, the blender_tests test runner only comprises of statically linked library
+ * files, including its main function.
+ *
+ * See source/blender/blenkernel/CMakeLists.txt for an example of how to add unit tests to the test
+ * runner. */
diff --git a/tests/gtests/testing/CMakeLists.txt b/tests/gtests/testing/CMakeLists.txt
index e08ee486933..c8a7f487c5d 100644
--- a/tests/gtests/testing/CMakeLists.txt
+++ b/tests/gtests/testing/CMakeLists.txt
@@ -18,6 +18,10 @@
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
+add_definitions(${GFLAGS_DEFINES})
+add_definitions(${GLOG_DEFINES})
+add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
+
set(INC
.
..