[Bf-blender-cvs] [f7a4ede79f9] master: Python: change bpy.app.binary_path behavior WITH_PYTHON_MODULE

2022-09-08 Thread Campbell Barton
Commit: f7a4ede79f9512f39db8632ff112e08a93f3a9d4
Author: Campbell Barton
Date:   Fri Sep 9 13:59:53 2022 +1000
Branches: master
https://developer.blender.org/rBf7a4ede79f9512f39db8632ff112e08a93f3a9d4

Python: change bpy.app.binary_path behavior WITH_PYTHON_MODULE

The following changes have been made to this attribute with
WITH_PYTHON_MODULE is defined:

- Defaults to an empty string (instead of pointing to __init__.so).
- It's writable, so script authors can point to a valid Blender binary.

`where_am_i(..)` is no longer used by BKE_appdir_program_path_init,
there is now a separate code-path for setting the initial program
directory, calls after this can be used to set the binary path.

===

M   source/blender/blenkernel/intern/appdir.c
M   source/blender/python/intern/bpy_app.c

===

diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index 845a890ba8b..295e85a5fc4 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -782,6 +782,7 @@ const char *BKE_appdir_folder_id_version(const int 
folder_id,
  * Access locations of Blender & Python.
  * \{ */
 
+#ifndef WITH_PYTHON_MODULE
 /**
  * Checks if name is a fully qualified filename to an executable.
  * If not it searches `$PATH` for the file. On Windows it also
@@ -793,14 +794,12 @@ const char *BKE_appdir_folder_id_version(const int 
folder_id,
  * \param fullname: The full path and full name of the executable
  * (must be #FILE_MAX minimum)
  * \param name: The name of the executable (usually `argv[0]`) to be checked
- * \param strict: When true, use `argv0` unmodified (besides making absolute & 
normalizing).
- * Otherwise other methods may be used to find the program path, including 
searching `$PATH`.
  */
-static void where_am_i(char *fullname, const size_t maxlen, const char *name, 
const bool strict)
+static void where_am_i(char *fullname, const size_t maxlen, const char *name)
 {
-#ifdef WITH_BINRELOC
+#  ifdef WITH_BINRELOC
   /* Linux uses `binreloc` since `argv[0]` is not reliable, call 
`br_init(NULL)` first. */
-  if (!strict) {
+  {
 const char *path = NULL;
 path = br_find_exe(NULL);
 if (path) {
@@ -809,9 +808,9 @@ static void where_am_i(char *fullname, const size_t maxlen, 
const char *name, co
   return;
 }
   }
-#endif
+#  endif
 
-#ifdef _WIN32
+#  ifdef _WIN32
   if (!strict) {
 wchar_t *fullname_16 = MEM_mallocN(maxlen * sizeof(wchar_t), 
"ProgramPath");
 if (GetModuleFileNameW(0, fullname_16, maxlen)) {
@@ -827,7 +826,7 @@ static void where_am_i(char *fullname, const size_t maxlen, 
const char *name, co
 
 MEM_freeN(fullname_16);
   }
-#endif
+#  endif
 
   /* Unix and non Linux. */
   if (name && name[0]) {
@@ -835,36 +834,35 @@ static void where_am_i(char *fullname, const size_t 
maxlen, const char *name, co
 BLI_strncpy(fullname, name, maxlen);
 if (name[0] == '.') {
   BLI_path_abs_from_cwd(fullname, maxlen);
-#ifdef _WIN32
+#  ifdef _WIN32
   if (!strict) {
 BLI_path_program_extensions_add_win32(fullname, maxlen);
   }
-#endif
+#  endif
 }
 else if (BLI_path_slash_rfind(name)) {
   /* Full path. */
   BLI_strncpy(fullname, name, maxlen);
-#ifdef _WIN32
+#  ifdef _WIN32
   if (!strict) {
 BLI_path_program_extensions_add_win32(fullname, maxlen);
   }
-#endif
+#  endif
 }
 else {
-  if (!strict) {
-BLI_path_program_search(fullname, maxlen, name);
-  }
+  BLI_path_program_search(fullname, maxlen, name);
 }
 /* Remove "/./" and "/../" so string comparisons can be used on the path. 
*/
 BLI_path_normalize(NULL, fullname);
 
-#if defined(DEBUG)
+#  if defined(DEBUG)
 if (!STREQ(name, fullname)) {
   CLOG_INFO(, 2, "guessing '%s' == '%s'", name, fullname);
 }
-#endif
+#  endif
   }
 }
+#endif /* WITH_PYTHON_MODULE */
 
 void BKE_appdir_program_path_init(const char *argv0)
 {
@@ -872,17 +870,28 @@ void BKE_appdir_program_path_init(const char *argv0)
   /* NOTE(@campbellbarton): Always use `argv[0]` as is, when building as a 
Python module.
* Otherwise other methods of detecting the binary that override this 
argument
* which must point to the Python module for data-files to be detected. */
-  const bool strict = true;
+  STRNCPY(g_app.program_filepath, argv0);
+  BLI_path_abs_from_cwd(g_app.program_filepath, 
sizeof(g_app.program_filepath));
+  BLI_path_normalize(NULL, g_app.program_filepath);
+
+  if (g_app.program_dirname[0] == '\0') {
+/* First time initializing, the file binary path isn't valid from a Python 
module.
+ * Calling again must set the `filepath` and leave the directory as-is. */
+BLI_split_dir_part(
+g_app.program_filepath, g_app.program_dirname, 
sizeof(g_app.program_dirname));
+g_app.program_filepath[0] = '\0';

[Bf-blender-cvs] [d455f1a0baa] master: Cleanup: quiet conversion warning

2022-09-08 Thread Campbell Barton
Commit: d455f1a0baacac952792f36a30ac254a07510ac7
Author: Campbell Barton
Date:   Fri Sep 9 12:17:59 2022 +1000
Branches: master
https://developer.blender.org/rBd455f1a0baacac952792f36a30ac254a07510ac7

Cleanup: quiet conversion warning

===

M   source/blender/draw/intern/draw_resource.hh

===

diff --git a/source/blender/draw/intern/draw_resource.hh 
b/source/blender/draw/intern/draw_resource.hh
index 22ee43592a9..2df38e32ed2 100644
--- a/source/blender/draw/intern/draw_resource.hh
+++ b/source/blender/draw/intern/draw_resource.hh
@@ -85,10 +85,11 @@ inline void ObjectInfos::sync(const 
blender::draw::ObjectRef ref, bool is_active
   if (ref.dupli_object == nullptr) {
 /* TODO(fclem): this is rather costly to do at draw time. Maybe we can
  * put it in ob->runtime and make depsgraph ensure it is up to date. */
-random = BLI_hash_int_2d(BLI_hash_string(ref.object->id.name + 2), 0) * 
(1.0f / 0x);
+random = BLI_hash_int_2d(BLI_hash_string(ref.object->id.name + 2), 0) *
+ (1.0f / (float)0x);
   }
   else {
-random = ref.dupli_object->random_id * (1.0f / 0x);
+random = ref.dupli_object->random_id * (1.0f / (float)0x);
   }
   /* Default values. Set if needed. */
   random = 0.0f;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3a01c23a84c] master: Cleanup: cmake line length, wrapping

2022-09-08 Thread Campbell Barton
Commit: 3a01c23a84c0641f0f656c805ac29194a240728e
Author: Campbell Barton
Date:   Fri Sep 9 11:52:14 2022 +1000
Branches: master
https://developer.blender.org/rB3a01c23a84c0641f0f656c805ac29194a240728e

Cleanup: cmake line length, wrapping

===

M   CMakeLists.txt
M   source/creator/CMakeLists.txt

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9688c711bc7..53859196cfb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -888,7 +888,11 @@ endif()
 if(WITH_CYCLES AND WITH_CYCLES_DEVICE_CUDA AND NOT WITH_CUDA_DYNLOAD)
   find_package(CUDA)
   if(NOT CUDA_FOUND)
-message(STATUS "CUDA toolkit not found, using dynamic runtime loading of 
libraries (WITH_CUDA_DYNLOAD) instead")
+message(
+  STATUS
+  "CUDA toolkit not found, "
+  "using dynamic runtime loading of libraries (WITH_CUDA_DYNLOAD) instead"
+)
 set(WITH_CUDA_DYNLOAD ON)
   endif()
 endif()
@@ -905,7 +909,8 @@ if(WITH_INTERNATIONAL)
   file(GLOB RESULT "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
   list(LENGTH RESULT DIR_LEN)
   if(DIR_LEN EQUAL 0)
-message(WARNING
+message(
+  WARNING
   "Translation path '${CMAKE_SOURCE_DIR}/release/datafiles/locale' is 
missing, "
   "This is a 'git submodule', which are known not to work with bridges to 
other version "
   "control systems, disabling 'WITH_INTERNATIONAL'."
@@ -923,13 +928,17 @@ if(WITH_PYTHON)
   # because UNIX will search for the old Python paths which may not exist.
   # giving errors about missing paths before this case is met.
   if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.10")
-message(FATAL_ERROR "At least Python 3.10 is required to build, but found 
Python ${PYTHON_VERSION}")
+message(
+  FATAL_ERROR
+  "At least Python 3.10 is required to build, but found Python 
${PYTHON_VERSION}"
+)
   endif()
 
   file(GLOB RESULT "${CMAKE_SOURCE_DIR}/release/scripts/addons")
   list(LENGTH RESULT DIR_LEN)
   if(DIR_LEN EQUAL 0)
-message(WARNING
+message(
+  WARNING
   "Addons path '${CMAKE_SOURCE_DIR}/release/scripts/addons' is missing, "
   "This is a 'git submodule', which are known not to work with bridges to 
other version "
   "control systems: * CONTINUING WITHOUT ADDONS *"
@@ -1037,13 +1046,15 @@ endif()
 
 if(WITH_CYCLES)
   if(NOT WITH_OPENIMAGEIO)
-message(FATAL_ERROR
+message(
+  FATAL_ERROR
   "Cycles requires WITH_OPENIMAGEIO, the library may not have been found. "
   "Configure OIIO or disable WITH_CYCLES"
 )
   endif()
   if(NOT WITH_BOOST)
-message(FATAL_ERROR
+message(
+  FATAL_ERROR
   "Cycles requires WITH_BOOST, the library may not have been found. "
   "Configure BOOST or disable WITH_CYCLES"
 )
@@ -1051,7 +1062,8 @@ if(WITH_CYCLES)
 
   if(WITH_CYCLES_OSL)
 if(NOT WITH_LLVM)
-  message(FATAL_ERROR
+  message(
+FATAL_ERROR
 "Cycles OSL requires WITH_LLVM, the library may not have been found. "
 "Configure LLVM or disable WITH_CYCLES_OSL"
   )
@@ -1061,7 +1073,8 @@ endif()
 
 if(WITH_INTERNATIONAL)
   if(NOT WITH_BOOST)
-message(FATAL_ERROR
+message(
+  FATAL_ERROR
   "Internationalization requires WITH_BOOST, the library may not have been 
found. "
   "Configure BOOST or disable WITH_INTERNATIONAL"
 )
@@ -1606,7 +1619,8 @@ endif()
 # be most problematic.
 if(WITH_PYTHON)
   if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
-message(FATAL_ERROR
+message(
+  FATAL_ERROR
   "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
   "Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
   "to a valid python include path. Containing "
@@ -1675,9 +1689,11 @@ if(WITH_COMPILER_SHORT_FILE_MACRO)
   if(XCODE AND ${XCODE_VERSION} VERSION_LESS 12.0)
   # Developers may have say LLVM Clang-10.0.1 toolchain (which supports 
the flag)
   # with Xcode-11 (the Clang of which doesn't support the flag).
-message(WARNING
+message(
+  WARNING
   "-fmacro-prefix-map flag is NOT supported by Clang shipped with 
Xcode-${XCODE_VERSION}."
-  " Some Xcode functionality in Product menu may not work. Disabling 
WITH_COMPILER_SHORT_FILE_MACRO."
+  " Some Xcode functionality in Product menu may not work. "
+  "Disabling WITH_COMPILER_SHORT_FILE_MACRO."
 )
 set(WITH_COMPILER_SHORT_FILE_MACRO OFF)
   endif()
@@ -1693,7 +1709,8 @@ if(WITH_COMPILER_SHORT_FILE_MACRO)
   unset(_bin_dir)
 endif()
   else()
-message(WARNING
+message(
+  WARNING
   "-fmacro-prefix-map flag is NOT supported by C/C++ compiler."
   " Disabling WITH_COMPILER_SHORT_FILE_MACRO."
 )
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 23cb38362c2..f8cbb9bc07c 100644
--- a/source/creator/CMakeLists.txt
+++ 

[Bf-blender-cvs] [ce5ad663305] master: GNUmakefile: change message to reference "bpy" when building as a module

2022-09-08 Thread Campbell Barton
Commit: ce5ad663305a46a61e95ade1700b9b290c6847f6
Author: Campbell Barton
Date:   Fri Sep 9 12:17:09 2022 +1000
Branches: master
https://developer.blender.org/rBce5ad663305a46a61e95ade1700b9b290c6847f6

GNUmakefile: change message to reference "bpy" when building as a module

===

M   GNUmakefile

===

diff --git a/GNUmakefile b/GNUmakefile
index a82d1bedace..a218b1d226c 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -162,6 +162,7 @@ CPU:=$(shell uname -m)
 # Source and Build DIR's
 BLENDER_DIR:=$(shell pwd -P)
 BUILD_TYPE:=Release
+BLENDER_IS_PYTHON_MODULE:=
 
 # CMake arguments, assigned to local variable to make it mutable.
 CMAKE_CONFIG_ARGS := $(BUILD_CMAKE_ARGS)
@@ -259,6 +260,7 @@ endif
 ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
BUILD_DIR:=$(BUILD_DIR)_bpy

CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake" 
$(CMAKE_CONFIG_ARGS)
+   BLENDER_IS_PYTHON_MODULE:=1
 endif
 
 ifneq "$(findstring developer, $(MAKECMDGOALS))" ""
@@ -297,8 +299,10 @@ endif
 # use the default build path can still use utility helpers.
 ifeq ($(OS), Darwin)
BLENDER_BIN?="$(BUILD_DIR)/bin/Blender.app/Contents/MacOS/Blender"
+   BLENDER_BIN_DIR?="$(BUILD_DIR)/bin/Blender.app/Contents/MacOS/Blender"
 else
BLENDER_BIN?="$(BUILD_DIR)/bin/blender"
+   BLENDER_BIN_DIR?="$(BUILD_DIR)/bin"
 endif
 
 
@@ -355,8 +359,12 @@ all: .FORCE
@echo Building Blender ...
$(BUILD_COMMAND) -C "$(BUILD_DIR)" -j $(NPROCS) install
@echo
-   @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run 
make again to rebuild.
-   @echo Blender successfully built, run from: $(BLENDER_BIN)
+   @echo Edit build configuration with: \"$(BUILD_DIR)/CMakeCache.txt\" 
run make again to rebuild.
+   @if test "$(BLENDER_IS_PYTHON_MODULE)" == ""; then \
+   echo Blender successfully built, run from: $(BLENDER_BIN); \
+   else \
+   echo Blender successfully built as a Python module, \"bpy\" can 
be imported from: $(BLENDER_BIN_DIR); \
+   fi
@echo
 
 debug: all

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9e0c2f6867d] master: CMake: exclude Python libs & batch scripts WITH_PYTHON_MODULE for WIN32

2022-09-08 Thread Campbell Barton
Commit: 9e0c2f6867d34a35e009d9a0caee256a4528edc5
Author: Campbell Barton
Date:   Fri Sep 9 11:32:42 2022 +1000
Branches: master
https://developer.blender.org/rB9e0c2f6867d34a35e009d9a0caee256a4528edc5

CMake: exclude Python libs & batch scripts WITH_PYTHON_MODULE for WIN32

===

M   source/creator/CMakeLists.txt

===

diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 2aa534d55eb..23cb38362c2 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -849,22 +849,24 @@ elseif(WIN32)
   if(WITH_PYTHON)
 string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
 
-if(NOT CMAKE_COMPILER_IS_GNUCC)
-  install(
-FILES
-  
${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python${_PYTHON_VERSION_NO_DOTS}.dll
-  ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python3.dll
-DESTINATION ${TARGETDIR_LIB}
-CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
-  )
+if(NOT WITH_PYTHON_MODULE)
+  if(NOT CMAKE_COMPILER_IS_GNUCC)
+install(
+  FILES
+
${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python${_PYTHON_VERSION_NO_DOTS}.dll
+${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python3.dll
+  DESTINATION ${TARGETDIR_LIB}
+  CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
+)
 
-  install(
-FILES
-  
${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python${_PYTHON_VERSION_NO_DOTS}_d.dll
-  ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python3_d.dll
-DESTINATION ${TARGETDIR_LIB}
-CONFIGURATIONS Debug
-  )
+install(
+  FILES
+
${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python${_PYTHON_VERSION_NO_DOTS}_d.dll
+${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python3_d.dll
+  DESTINATION ${TARGETDIR_LIB}
+  CONFIGURATIONS Debug
+)
+  endif()
 endif()
 
 if(WITH_PYTHON_INSTALL)
@@ -1035,16 +1037,19 @@ elseif(WIN32)
 )
   endif()
 
-  install(
-FILES
-  ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_debug_gpu.cmd
-  
${CMAKE_SOURCE_DIR}/release/windows/batch/blender_debug_gpu_glitchworkaround.cmd
-  ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_debug_log.cmd
-  ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_factory_startup.cmd
-  ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_oculus.cmd
-  ${CMAKE_SOURCE_DIR}/release/windows/batch/oculus.json
-DESTINATION ${TARGETDIR_LIB}
-  )
+
+  if(NOT WITH_PYTHON_MODULE)
+install(
+  FILES
+${CMAKE_SOURCE_DIR}/release/windows/batch/blender_debug_gpu.cmd
+
${CMAKE_SOURCE_DIR}/release/windows/batch/blender_debug_gpu_glitchworkaround.cmd
+${CMAKE_SOURCE_DIR}/release/windows/batch/blender_debug_log.cmd
+${CMAKE_SOURCE_DIR}/release/windows/batch/blender_factory_startup.cmd
+${CMAKE_SOURCE_DIR}/release/windows/batch/blender_oculus.cmd
+${CMAKE_SOURCE_DIR}/release/windows/batch/oculus.json
+  DESTINATION ${TARGETDIR_LIB}
+)
+  endif()
 
   if(WITH_BLENDER_THUMBNAILER)
 install(

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fad7a30de31] master: Cleanup: comments, spelling, line length for creator's CMake file

2022-09-08 Thread Campbell Barton
Commit: fad7a30de31977dee8c090dc196c796e17d2fcde
Author: Campbell Barton
Date:   Fri Sep 9 11:09:01 2022 +1000
Branches: master
https://developer.blender.org/rBfad7a30de31977dee8c090dc196c796e17d2fcde

Cleanup: comments, spelling, line length for creator's CMake file

===

M   source/creator/CMakeLists.txt

===

diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index a5afcefbc29..2aa534d55eb 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -26,9 +26,8 @@ if(HAVE_FEENABLEEXCEPT)
 endif()
 
 if(WITH_TBB)
-  # Force TBB libraries to be in front of MKL (part of OpenImageDenoise), so
-  # that it is initialized before MKL and static library initialization order
-  # issues are avoided.
+  # Force TBB libraries to be in front of MKL (part of `OpenImageDenoise`), so
+  # that it is initialized before MKL and static library initialization order 
issues are avoided.
   #
   # This isn't fully robust but seems to work.
   list(INSERT LIB 0 ${TBB_LIBRARIES})
@@ -58,7 +57,7 @@ endif()
 if(WITH_TBB)
   blender_include_dirs(${TBB_INCLUDE_DIRS})
   if(WIN32)
-# For pragma that links tbbmalloc_proxy.lib
+# For `pragma` that links `tbbmalloc_proxy.lib`.
 link_directories(${LIBDIR}/tbb/lib)
   endif()
 endif()
@@ -108,7 +107,7 @@ if(WITH_OPENCOLORIO)
   add_definitions(-DWITH_OCIO)
 endif()
 
-# Setup the exe sources and buildinfo
+# Setup the EXE sources and `buildinfo`.
 set(SRC
   creator.c
   creator_args.c
@@ -117,7 +116,7 @@ set(SRC
   creator_intern.h
 )
 
-# MSVC 2010 gives linking errors with the manifest
+# MSVC 2010 gives linking errors with the manifest.
 if(WIN32 AND NOT UNIX)
   add_definitions(
 -DBLEN_VER_RC_STR="${BLENDER_VERSION}"
@@ -173,19 +172,20 @@ if(WITH_BUILDINFO)
   unset(BUILD_SYSTEM)
 
   # --
-  # write header for values that change each build
-  # note, generated file is in build dir's source/creator
-  #   except when used as an include path.
+  # Write header for values that change each build
+  #
+  # NOTE: generated file is in build directory `source/creator`
+  # except when used as an include path.
 
   add_definitions(-DWITH_BUILDINFO_HEADER)
 
-  # include the output directory, where the buildinfo.h file is generated
+  # Include the output directory, where the `buildinfo.h` file is generated.
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
 
-  # XXX, ${buildinfo_h_fake} is used here,
+  # XXX: `${buildinfo_h_fake}` is used here,
   # because we rely on that file being detected as missing
-  # every build so that the real header "buildinfo.h" is updated.
+  # every build so that the real header `buildinfo.h` is updated.
   #
   # Keep this until we find a better way to resolve!
 
@@ -196,11 +196,12 @@ if(WITH_BUILDINFO)
 message(FATAL_ERROR "File \"${buildinfo_h_fake}\" found, this should never 
be created, remove!")
   endif()
 
-  # From the cmake documentation "If the output of the custom command is not 
actually created as a
+  # From the CMAKE documentation "If the output of the custom command is not 
actually created as a
   # file on disk it should be marked with the SYMBOLIC source file property."
   #
-  # Not doing this leads to build warnings for the not generated file on 
windows when using msbuild
-  SET_SOURCE_FILES_PROPERTIES(${buildinfo_h_fake} PROPERTIES SYMBOLIC TRUE)
+  # Not doing this leads to build warnings for the not generated file on
+  # MS-Windows when using `msbuild`.
+  set_source_files_properties(${buildinfo_h_fake} PROPERTIES SYMBOLIC TRUE)
 
   # a custom target that is always built
   add_custom_target(
@@ -208,19 +209,19 @@ if(WITH_BUILDINFO)
 DEPENDS ${buildinfo_h_fake}
   )
 
-  # creates buildinfo.h using cmake script
+  # Creates `buildinfo.h` using CMAKE script.
   add_custom_command(
 OUTPUT
   ${buildinfo_h_fake}  # ensure we always run
   ${buildinfo_h_real}
 COMMAND ${CMAKE_COMMAND}
 -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
-# overrides only used when non-empty strings
+# Overrides only used when non-empty strings.
 -DBUILD_DATE=${BUILDINFO_OVERRIDE_DATE}
 -DBUILD_TIME=${BUILDINFO_OVERRIDE_TIME}
 -P ${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo.cmake)
 
-  # buildinfo.h is a generated file
+  # `buildinfo.h` is a generated file.
   set_source_files_properties(
 ${buildinfo_h_real}
 PROPERTIES GENERATED TRUE
@@ -229,7 +230,7 @@ if(WITH_BUILDINFO)
   unset(buildinfo_h_real)
   unset(buildinfo_h_fake)
 
-  # add deps below, after adding blender
+  # Add dependencies below, after adding Blender
   # -- done with header values.
 
   list(APPEND SRC
@@ -247,10 +248,9 @@ add_cc_flags_custom_test(blender)
 if(WITH_PYTHON_MODULE)
   add_definitions(-DWITH_PYTHON_MODULE)
 
-  # Creates `./bpy/__init__.so` 

[Bf-blender-cvs] [22b84424c70] master: Cleanup: check for Python module in BKE_appdir_program_path_init

2022-09-08 Thread Campbell Barton
Commit: 22b84424c702a6a85ccf127dfcbb6ce28b101774
Author: Campbell Barton
Date:   Fri Sep 9 11:13:05 2022 +1000
Branches: master
https://developer.blender.org/rB22b84424c702a6a85ccf127dfcbb6ce28b101774

Cleanup: check for Python module in BKE_appdir_program_path_init

Replace the argument with an in ifdef in BKE_appdir_program_path_init.
At the time `blenkernel` didn't define WITH_PYTHON_MODULE, since it does
now there is no need for an argument. With the minor benefit of fewer
preprocessor checks in the main() function.

===

M   source/blender/blenkernel/BKE_appdir.h
M   source/blender/blenkernel/intern/appdir.c
M   source/creator/creator.c

===

diff --git a/source/blender/blenkernel/BKE_appdir.h 
b/source/blender/blenkernel/BKE_appdir.h
index 16488bdbf09..dcacc2ca7b3 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -105,11 +105,8 @@ void BKE_appdir_app_templates(struct ListBase *templates);
 
 /**
  * Initialize path to program executable.
- *
- * \param strict: When true, use `argv0` unmodified (besides making absolute & 
normalizing).
- * Otherwise other methods may be used to find the program path, including 
searching `$PATH`.
  */
-void BKE_appdir_program_path_init(const char *argv0, bool strict);
+void BKE_appdir_program_path_init(const char *argv0);
 
 /**
  * Path to executable
diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index 4bd8cfd5f47..845a890ba8b 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -793,6 +793,8 @@ const char *BKE_appdir_folder_id_version(const int 
folder_id,
  * \param fullname: The full path and full name of the executable
  * (must be #FILE_MAX minimum)
  * \param name: The name of the executable (usually `argv[0]`) to be checked
+ * \param strict: When true, use `argv0` unmodified (besides making absolute & 
normalizing).
+ * Otherwise other methods may be used to find the program path, including 
searching `$PATH`.
  */
 static void where_am_i(char *fullname, const size_t maxlen, const char *name, 
const bool strict)
 {
@@ -864,8 +866,16 @@ static void where_am_i(char *fullname, const size_t 
maxlen, const char *name, co
   }
 }
 
-void BKE_appdir_program_path_init(const char *argv0, const bool strict)
+void BKE_appdir_program_path_init(const char *argv0)
 {
+#ifdef WITH_PYTHON_MODULE
+  /* NOTE(@campbellbarton): Always use `argv[0]` as is, when building as a 
Python module.
+   * Otherwise other methods of detecting the binary that override this 
argument
+   * which must point to the Python module for data-files to be detected. */
+  const bool strict = true;
+#else
+  const bool strict = false;
+#endif
   where_am_i(g_app.program_filepath, sizeof(g_app.program_filepath), argv0, 
strict);
   BLI_split_dir_part(g_app.program_filepath, g_app.program_dirname, 
sizeof(g_app.program_dirname));
 }
diff --git a/source/creator/creator.c b/source/creator/creator.c
index e7e9eeed79a..7f236a39974 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -396,17 +396,7 @@ int main(int argc,
 #endif
 
   /* Initialize path to executable. */
-  {
-#ifdef WITH_PYTHON_MODULE
-/* NOTE(@campbellbarton): Always use `argv[0]` as is, when building as a 
Python module.
- * Otherwise other methods of detecting the binary that override this 
argument
- * which must point to the Python module for data-files to be detected. */
-const bool strict = true;
-#else
-const bool strict = false;
-#endif
-BKE_appdir_program_path_init(argv[0], strict);
-  }
+  BKE_appdir_program_path_init(argv[0]);
 
   BLI_threadapi_init();

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [81558783e40] master: Python: install "bpy" as a package WITH_PYTHON_MODULE

2022-09-08 Thread Campbell Barton
Commit: 81558783e40394c2c60f61626eb6814f17128503
Author: Campbell Barton
Date:   Fri Sep 9 10:25:35 2022 +1000
Branches: master
https://developer.blender.org/rB81558783e40394c2c60f61626eb6814f17128503

Python: install "bpy" as a package WITH_PYTHON_MODULE

Building WITH_PYTHON_MODULE was creating a "bpy" module that required
Blenders data-files to be located in the module search path too.

This mean that a typical installation on Linux would create:

- `/usr/lib/python3.10/site-packages/bpy.so`
- `/usr/lib/python3.10/site-packages/3.4`
  (containing `scripts` & `datafiles`).

The new behavior creates:

- `/usr/lib/python3.10/site-packages/bpy/__init__.so`
- `/usr/lib/python3.10/site-packages/bpy/3.4`

With the advantage that the "bpy" directory is the self contained Python
module.

No changes are needed for the module loading logic as the mechanism to
swap in blend internal Python "bpy" module
(defined in `release/scripts/modules/bpy/__init__.py`)
works the same in both instances.

Thanks to Brecht for macOS support.

Reviewed by brecht

Ref D15911

===

M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/appdir.c
M   source/creator/CMakeLists.txt

===

diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 9521da8417e..b982c69a378 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -659,6 +659,10 @@ if(WITH_PYTHON)
   )
   add_definitions(-DWITH_PYTHON)
 
+  if(WITH_PYTHON_MODULE)
+add_definitions(-DWITH_PYTHON_MODULE)
+  endif()
+
   if(WITH_PYTHON_SAFETY)
 add_definitions(-DWITH_PYTHON_SAFETY)
   endif()
diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index c19afdb4fb8..4bd8cfd5f47 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -374,7 +374,7 @@ static bool get_path_local_ex(char *targetpath,
   /* Try `{g_app.program_dirname}/2.xx/{folder_name}` the default directory
* for a portable distribution. See `WITH_INSTALL_PORTABLE` build-option. */
   const char *path_base = g_app.program_dirname;
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE)
   /* Due new code-sign situation in OSX > 10.9.5
* we must move the blender_version dir with contents to Resources. */
   char osx_resourses[FILE_MAX];
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 0e9c3a853aa..a5afcefbc29 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -247,19 +247,29 @@ add_cc_flags_custom_test(blender)
 if(WITH_PYTHON_MODULE)
   add_definitions(-DWITH_PYTHON_MODULE)
 
-  # creates ./bin/bpy.so which can be imported as a python module.
+  # Creates `./bpy/__init__.so` which can be imported as a python module.
   #
   # note that 'SHARED' works on Linux and Windows,
   # but not OSX which _must_ be 'MODULE'
   add_library(blender MODULE ${SRC})
+
+
+  get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY 
GENERATOR_IS_MULTI_CONFIG)
+  if(GENERATOR_IS_MULTI_CONFIG)
+set(BPY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$/bpy)
+  else()
+set(BPY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/bpy)
+  endif()
+
   set_target_properties(
 blender
 PROPERTIES
   PREFIX ""
-  OUTPUT_NAME bpy
-  LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
-  RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin  # only needed on 
windows
+  OUTPUT_NAME __init__
+  LIBRARY_OUTPUT_DIRECTORY ${BPY_OUTPUT_DIRECTORY}
+  RUNTIME_OUTPUT_DIRECTORY ${BPY_OUTPUT_DIRECTORY}
   )
+  unset(BPY_OUTPUT_DIRECTORY)
 
   if(APPLE)
 set_target_properties(blender PROPERTIES MACOSX_BUNDLE TRUE)
@@ -306,13 +316,13 @@ set(BLENDER_TEXT_FILES
 if(UNIX AND NOT APPLE)
   if(WITH_PYTHON_MODULE)
 if(WITH_INSTALL_PORTABLE)
-  set(TARGETDIR_BPY .)
-  set(TARGETDIR_VER ${BLENDER_VERSION})
-  set(TARGETDIR_LIB lib)
+  set(TARGETDIR_BPY bpy)
+  set(TARGETDIR_VER bpy/${BLENDER_VERSION})
+  set(TARGETDIR_LIB bpy/lib)
 else()
-  set(TARGETDIR_BPY ${PYTHON_SITE_PACKAGES})
-  set(TARGETDIR_VER ${PYTHON_SITE_PACKAGES}/${BLENDER_VERSION})
-  set(TARGETDIR_LIB ${PYTHON_SITE_PACKAGES}/lib)
+  set(TARGETDIR_BPY ${PYTHON_SITE_PACKAGES}/bpy)
+  set(TARGETDIR_VER ${PYTHON_SITE_PACKAGES}/bpy/${BLENDER_VERSION})
+  set(TARGETDIR_LIB ${PYTHON_SITE_PACKAGES}/bpy/lib)
 endif()
   else()
 if(WITH_INSTALL_PORTABLE)
@@ -326,21 +336,28 @@ if(UNIX AND NOT APPLE)
   endif()
 
 elseif(WIN32)
-  set(TARGETDIR_VER ${BLENDER_VERSION})
-  set(TARGETDIR_TEXT .)
-  set(TARGETDIR_LIB .)
-
+  if(WITH_PYTHON_MODULE)
+set(TARGETDIR_BPY $)
+set(TARGETDIR_VER $/${BLENDER_VERSION})
+# Important the DLL's are next to `__init__.pyd` otherwise it won't 

[Bf-blender-cvs] [4a71765f9a4] master: Fix T100521: Nodes added with link drag search not added to frame

2022-09-08 Thread Dominik Fill
Commit: 4a71765f9a41d6e13b36a53b121338bc373887ac
Author: Dominik Fill
Date:   Thu Sep 8 17:03:54 2022 -0500
Branches: master
https://developer.blender.org/rB4a71765f9a41d6e13b36a53b121338bc373887ac

Fix T100521: Nodes added with link drag search not added to frame

Use macro NODE_OT_translate_attach for attaching node created through
link-drag-search to frame, as suggested by Leon Schittek (@lone_noel)
in D15888.

Differential Revision: https://developer.blender.org/D15920

===

M   source/blender/editors/space_node/link_drag_search.cc

===

diff --git a/source/blender/editors/space_node/link_drag_search.cc 
b/source/blender/editors/space_node/link_drag_search.cc
index 21d5d8d7d26..a4be0a65230 100644
--- a/source/blender/editors/space_node/link_drag_search.cc
+++ b/source/blender/editors/space_node/link_drag_search.cc
@@ -227,7 +227,7 @@ static void link_drag_search_exec_fn(bContext *C, void 
*arg1, void *arg2)
   ED_node_tree_propagate_change(C, , snode.edittree);
 
   /* Start translation operator with the new node. */
-  wmOperatorType *ot = WM_operatortype_find("TRANSFORM_OT_translate", true);
+  wmOperatorType *ot = WM_operatortype_find("NODE_OT_translate_attach", true);
   BLI_assert(ot);
   PointerRNA ptr;
   WM_operator_properties_create_ptr(, ot);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ecaab96e0bd] temp-T73411-add-scene-parameters: WIP: Adding const Scene* to many areas.

2022-09-08 Thread Jeroen Bakker
Commit: ecaab96e0bd615eb69895f9adc6d186bb2fece0d
Author: Jeroen Bakker
Date:   Thu Sep 8 22:32:40 2022 +0200
Branches: temp-T73411-add-scene-parameters
https://developer.blender.org/rBecaab96e0bd615eb69895f9adc6d186bb2fece0d

WIP: Adding const Scene* to many areas.

===

M   source/blender/blenkernel/BKE_collection.h
M   source/blender/blenkernel/BKE_collision.h
M   source/blender/blenkernel/BKE_effect.h
M   source/blender/blenkernel/BKE_layer.h
M   source/blender/blenkernel/BKE_object.h
M   source/blender/blenkernel/BKE_scene.h
M   source/blender/blenkernel/intern/blender_copybuffer.c
M   source/blender/blenkernel/intern/collection.c
M   source/blender/blenkernel/intern/collision.c
M   source/blender/blenkernel/intern/effect.c
M   source/blender/blenkernel/intern/layer.c
M   source/blender/blenkernel/intern/layer_utils.c
M   source/blender/blenkernel/intern/object.cc
M   source/blender/draw/engines/overlay/overlay_edit_uv.c
M   source/blender/draw/intern/draw_manager.c
M   source/blender/editors/animation/anim_markers.c
M   source/blender/editors/armature/armature_add.c
M   source/blender/editors/armature/armature_edit.c
M   source/blender/editors/armature/armature_naming.c
M   source/blender/editors/armature/armature_relations.c
M   source/blender/editors/armature/armature_select.c
M   source/blender/editors/armature/editarmature_undo.c
M   source/blender/editors/armature/pose_edit.c
M   source/blender/editors/armature/pose_select.c
M   source/blender/editors/armature/pose_slide.c
M   source/blender/editors/armature/pose_transform.c
M   source/blender/editors/armature/pose_utils.c
M   source/blender/editors/curve/editcurve.c
M   source/blender/editors/curve/editcurve_query.c
M   source/blender/editors/curve/editcurve_select.c
M   source/blender/editors/curve/editcurve_undo.c
M   source/blender/editors/curve/editfont.c
M   source/blender/editors/curves/intern/curves_ops.cc
M   source/blender/editors/gpencil/gpencil_mesh.cc
M   source/blender/editors/gpencil/gpencil_ops_versioning.c
M   source/blender/editors/gpencil/gpencil_trace_ops.c
M   source/blender/editors/include/ED_armature.h
M   source/blender/editors/include/ED_object.h
M   source/blender/editors/include/ED_transform.h
M   source/blender/editors/include/ED_undo.h
M   source/blender/editors/interface/interface_ops.cc
M   source/blender/editors/lattice/editlattice_select.c
M   source/blender/editors/lattice/editlattice_tools.c
M   source/blender/editors/lattice/editlattice_undo.c
M   source/blender/editors/mesh/editmesh_bevel.c
M   source/blender/editors/mesh/editmesh_bisect.c
M   source/blender/editors/mesh/editmesh_extrude.c
M   source/blender/editors/mesh/editmesh_extrude_screw.c
M   source/blender/editors/mesh/editmesh_extrude_spin.c
M   source/blender/editors/mesh/editmesh_inset.c
M   source/blender/editors/mesh/editmesh_intersect.c
M   source/blender/editors/mesh/editmesh_knife.c
M   source/blender/editors/mesh/editmesh_knife_project.c
M   source/blender/editors/mesh/editmesh_loopcut.c
M   source/blender/editors/mesh/editmesh_path.c
M   source/blender/editors/mesh/editmesh_polybuild.c
M   source/blender/editors/mesh/editmesh_rip.c
M   source/blender/editors/mesh/editmesh_rip_edge.c
M   source/blender/editors/mesh/editmesh_select.c
M   source/blender/editors/mesh/editmesh_select_similar.c
M   source/blender/editors/mesh/editmesh_tools.c
M   source/blender/editors/mesh/editmesh_undo.c
M   source/blender/editors/mesh/editmesh_utils.c
M   source/blender/editors/mesh/mesh_intern.h
M   source/blender/editors/metaball/editmball_undo.c
M   source/blender/editors/metaball/mball_edit.c
M   source/blender/editors/object/object_add.cc
M   source/blender/editors/object/object_constraint.c
M   source/blender/editors/object/object_edit.c
M   source/blender/editors/object/object_hook.c
M   source/blender/editors/object/object_modes.c
M   source/blender/editors/object/object_modifier.cc
M   source/blender/editors/object/object_random.c
M   source/blender/editors/object/object_relations.c
M   source/blender/editors/object/object_select.c
M   source/blender/editors/object/object_transform.cc
M   source/blender/editors/object/object_utils.c
M   source/blender/editors/render/render_preview.cc
M   source/blender/editors/screen/area.c
M   source/blender/editors/screen/screen_context.c
M   source/blender/editors/screen/screen_edit.c
M   source/blender/editors/space_image/image_ops.c
M   source/blender/editors/space_info/info_stats.cc
M   source/blender/editors/space_outliner/outliner_collections.cc
M   source/blender/editors/space_outliner/outliner_select.cc
M   

[Bf-blender-cvs] [ff8cd484181] master: Fix T100833: Cycles UDIM baking broken after recent changes

2022-09-08 Thread Brecht Van Lommel
Commit: ff8cd484181fb6c6ee03ebd10433cdd176b1c323
Author: Brecht Van Lommel
Date:   Thu Sep 8 20:23:02 2022 +0200
Branches: master
https://developer.blender.org/rBff8cd484181fb6c6ee03ebd10433cdd176b1c323

Fix T100833: Cycles UDIM baking broken after recent changes

===

M   intern/cycles/blender/session.cpp
M   intern/cycles/blender/session.h

===

diff --git a/intern/cycles/blender/session.cpp 
b/intern/cycles/blender/session.cpp
index 321771b67a5..1b7aa38efb4 100644
--- a/intern/cycles/blender/session.cpp
+++ b/intern/cycles/blender/session.cpp
@@ -704,7 +704,7 @@ void BlenderSession::bake(BL::Depsgraph _depsgraph_,
 buffer_params.window_width = bake_width;
 buffer_params.window_height = bake_height;
 /* Unique layer name for multi-image baking. */
-buffer_params.layer = string_printf("bake_%d\n", 
(int)full_buffer_files_.size());
+buffer_params.layer = string_printf("bake_%d\n", bake_id++);
 
 /* Update session. */
 session->reset(session_params, buffer_params);
diff --git a/intern/cycles/blender/session.h b/intern/cycles/blender/session.h
index f9a5b6faf7e..ceca86016b8 100644
--- a/intern/cycles/blender/session.h
+++ b/intern/cycles/blender/session.h
@@ -146,6 +146,8 @@ class BlenderSession {
   BlenderDisplayDriver *display_driver_ = nullptr;
 
   vector full_buffer_files_;
+
+  int bake_id = 0;
 };
 
 CCL_NAMESPACE_END

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [599209a11b3] refactor-mesh-selection-generic: Fix calc_edges selection

2022-09-08 Thread Hans Goudey
Commit: 599209a11b3cd3794c410455c323b849c63e69a2
Author: Hans Goudey
Date:   Thu Sep 8 12:37:25 2022 -0500
Branches: refactor-mesh-selection-generic
https://developer.blender.org/rB599209a11b3cd3794c410455c323b849c63e69a2

Fix calc_edges selection

===

M   source/blender/blenkernel/intern/mesh_calc_edges.cc

===

diff --git a/source/blender/blenkernel/intern/mesh_calc_edges.cc 
b/source/blender/blenkernel/intern/mesh_calc_edges.cc
index 6d76bea4502..06bfce65efc 100644
--- a/source/blender/blenkernel/intern/mesh_calc_edges.cc
+++ b/source/blender/blenkernel/intern/mesh_calc_edges.cc
@@ -120,10 +120,8 @@ static void add_polygon_edges_to_hash_maps(Mesh *mesh,
   });
 }
 
-static void serialize_and_initialize_deduplicated_edges(Mesh ,
-MutableSpan 
edge_maps,
-MutableSpan 
new_edges,
-const bool 
select_new_edges)
+static void serialize_and_initialize_deduplicated_edges(MutableSpan 
edge_maps,
+MutableSpan 
new_edges)
 {
   /* All edges are distributed in the hash tables now. They have to be 
serialized into a single
* array below. To be able to parallelize this, we have to compute edge 
index offsets for each
@@ -155,23 +153,6 @@ static void 
serialize_and_initialize_deduplicated_edges(Mesh ,
   new_edge_index++;
 }
   });
-
-  if (select_new_edges) {
-SpanAttributeWriter selection_edge =
-
mesh.attributes_for_write().lookup_or_add_for_write_span(".selection_edge",
-   
ATTR_DOMAIN_EDGE);
-threading::parallel_for_each(edge_maps, [&](EdgeMap _map) {
-  const int task_index = _map - edge_maps.data();
-  int new_edge_index = edge_index_offsets[task_index];
-  for (EdgeMap::MutableItem item : edge_map.items()) {
-if (item.value.original_edge == nullptr) {
-  selection_edge.span[new_edge_index] = true;
-}
-new_edge_index++;
-  }
-});
-selection_edge.finish();
-  }
 }
 
 static void update_edge_indices_in_poly_loops(Mesh *mesh,
@@ -255,8 +236,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool 
keep_existing_edges, const bool select
   /* Create new edges. */
   MutableSpan new_edges{
   static_cast(MEM_calloc_arrayN(new_totedge, sizeof(MEdge), 
__func__)), new_totedge};
-  calc_edges::serialize_and_initialize_deduplicated_edges(
-  *mesh, edge_maps, new_edges, select_new_edges);
+  calc_edges::serialize_and_initialize_deduplicated_edges(edge_maps, 
new_edges);
   calc_edges::update_edge_indices_in_poly_loops(mesh, edge_maps, 
parallel_mask);
 
   /* Free old CustomData and assign new one. */
@@ -265,6 +245,24 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool 
keep_existing_edges, const bool select
   CustomData_add_layer(>edata, CD_MEDGE, CD_ASSIGN, new_edges.data(), 
new_totedge);
   mesh->totedge = new_totedge;
 
+  if (select_new_edges) {
+MutableAttributeAccessor attributes = mesh->attributes_for_write();
+SpanAttributeWriter selection_edge = 
attributes.lookup_or_add_for_write_span(
+".selection_edge", ATTR_DOMAIN_EDGE);
+if (selection_edge) {
+  int new_edge_index = 0;
+  for (const EdgeMap _map : edge_maps) {
+for (EdgeMap::Item item : edge_map.items()) {
+  if (item.value.original_edge == nullptr) {
+selection_edge.span[new_edge_index] = true;
+  }
+  new_edge_index++;
+}
+  }
+  selection_edge.finish();
+}
+  }
+
   /* Explicitly clear edge maps, because that way it can be parallelized. */
   clear_hash_tables(edge_maps);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [06a5741f427] master: Silence warnings/assert about invalid embedded IDs for older blendfiles.

2022-09-08 Thread Bastien Montagne
Commit: 06a5741f427467d671986ca907d47b76d53f3f6e
Author: Bastien Montagne
Date:   Thu Sep 8 16:55:46 2022 +0200
Branches: master
https://developer.blender.org/rB06a5741f427467d671986ca907d47b76d53f3f6e

Silence warnings/assert about invalid embedded IDs for older blendfiles.

there is no point in warning about files that are not supposed to be
'correct' in that regard.

===

M   source/blender/blenkernel/intern/collection.c
M   source/blender/blenkernel/intern/node.cc
M   source/blender/blenloader/BLO_read_write.h
M   source/blender/blenloader/intern/readfile.c

===

diff --git a/source/blender/blenkernel/intern/collection.c 
b/source/blender/blenkernel/intern/collection.c
index dc04eb0dba3..41ec120519b 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -234,8 +234,13 @@ void BKE_collection_compat_blend_read_data(BlendDataReader 
*reader, SceneCollect
 void BKE_collection_blend_read_data(BlendDataReader *reader, Collection 
*collection, ID *owner_id)
 {
   /* Special case for this pointer, do not rely on regular `lib_link` process 
here. Avoids needs
-   * for do_versioning, and ensures coherence of data in any case. */
-  BLI_assert((collection->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == 
NULL);
+   * for do_versioning, and ensures coherence of data in any case.
+   *
+   * NOTE: Old versions are very often 'broken' here, just fix it silently in 
these cases.
+   */
+  if (BLO_read_fileversion_get(reader) > 300) {
+BLI_assert((collection->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == 
NULL);
+  }
   BLI_assert(owner_id == NULL || owner_id->lib == collection->id.lib);
   if (owner_id != NULL && (collection->id.flag & LIB_EMBEDDED_DATA) == 0) {
 /* This is unfortunate, but currently a lot of existing files (including 
startup ones) have
@@ -244,11 +249,13 @@ void BKE_collection_blend_read_data(BlendDataReader 
*reader, Collection *collect
  * NOTE: Using do_version is not a solution here, since this code will be 
called before any
  * do_version takes place. Keeping it here also ensures future (or unknown 
existing) similar
  * bugs won't go easily unnoticed. */
-CLOG_WARN(,
-  "Fixing root node tree '%s' owned by '%s' missing EMBEDDED tag, 
please consider "
-  "re-saving your (startup) file",
-  collection->id.name,
-  owner_id->name);
+if (BLO_read_fileversion_get(reader) > 300) {
+  CLOG_WARN(,
+"Fixing root node tree '%s' owned by '%s' missing EMBEDDED 
tag, please consider "
+"re-saving your (startup) file",
+collection->id.name,
+owner_id->name);
+}
 collection->id.flag |= LIB_EMBEDDED_DATA;
   }
   collection->owner_id = owner_id;
diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index a78257a250b..fadcceae393 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -652,8 +652,13 @@ static void direct_link_node_socket(BlendDataReader 
*reader, bNodeSocket *sock)
 void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree 
*ntree)
 {
   /* Special case for this pointer, do not rely on regular `lib_link` process 
here. Avoids needs
-   * for do_versioning, and ensures coherence of data in any case. */
-  BLI_assert((ntree->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == nullptr);
+   * for do_versioning, and ensures coherence of data in any case.
+   *
+   * NOTE: Old versions are very often 'broken' here, just fix it silently in 
these cases.
+   */
+  if (BLO_read_fileversion_get(reader) > 300) {
+BLI_assert((ntree->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == 
nullptr);
+  }
   BLI_assert(owner_id == NULL || owner_id->lib == ntree->id.lib);
   if (owner_id != nullptr && (ntree->id.flag & LIB_EMBEDDED_DATA) == 0) {
 /* This is unfortunate, but currently a lot of existing files (including 
startup ones) have
@@ -662,11 +667,13 @@ void ntreeBlendReadData(BlendDataReader *reader, ID 
*owner_id, bNodeTree *ntree)
  * NOTE: Using do_version is not a solution here, since this code will be 
called before any
  * do_version takes place. Keeping it here also ensures future (or unknown 
existing) similar
  * bugs won't go easily unnoticed. */
-CLOG_WARN(,
-  "Fixing root node tree '%s' owned by '%s' missing EMBEDDED tag, 
please consider "
-  "re-saving your (startup) file",
-  ntree->id.name,
-  owner_id->name);
+if (BLO_read_fileversion_get(reader) > 300) {
+  CLOG_WARN(,
+"Fixing root node tree '%s' owned by '%s' missing EMBEDDED 
tag, please consider "
+"re-saving your (startup) file",
+ntree->id.name,
+  

[Bf-blender-cvs] [f56159e0b33] temp-angavrilov: Bone Overlay: support bone wireframe opacity depth fade.

2022-09-08 Thread Alexander Gavrilov
Commit: f56159e0b33591434942e50903a9756301d258f3
Author: Alexander Gavrilov
Date:   Sat Dec 11 18:04:34 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rBf56159e0b33591434942e50903a9756301d258f3

Bone Overlay: support bone wireframe opacity depth fade.

Add an option that allows fade based on the depth from the camera,
using exponential decay with the slider specifying the 'half-life'
depth. This is intended as a way to automatically hide bones
in distant parts of the mesh while focused on a specific part.

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/blenloader/intern/versioning_300.c
M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/overlay/overlay_armature.c
M   source/blender/draw/engines/overlay/overlay_private.h
M   
source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh
A   
source/blender/draw/engines/overlay/shaders/overlay_armature_alpha_lib.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_dof_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_envelope_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_shape_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_sphere_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_stick_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_wire_frag.glsl
M   source/blender/makesdna/DNA_view3d_defaults.h
M   source/blender/makesdna/DNA_view3d_types.h
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 23c3b0191d4..f748b1425d5 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6761,6 +6761,12 @@ class VIEW3D_PT_overlay_bones(Panel):
 if VIEW3D_PT_overlay_bones.is_using_wireframe(context):
 col.prop(overlay, "bone_wire_alpha")
 
+row = col.row()
+row.prop(overlay, "bone_wire_use_fade_depth", text="")
+sub = row.row()
+sub.active = overlay.bone_wire_use_fade_depth
+sub.prop(overlay, "bone_wire_fade_depth")
+
 
 class VIEW3D_PT_overlay_texture_paint(Panel):
 bl_space_type = 'VIEW_3D'
diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.c
index 374b4c9d89a..0c0e58c4e07 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -3369,5 +3369,19 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   }
   FOREACH_NODETREE_END;
 }
+
+/* Initialize the bone wireframe opacity depth fade setting. */
+if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", 
"bone_wire_fade_depth")) {
+  for (bScreen *screen = bmain->screens.first; screen; screen = 
screen->id.next) {
+LISTBASE_FOREACH (ScrArea *, area, >areabase) {
+  LISTBASE_FOREACH (SpaceLink *, sl, >spacedata) {
+if (sl->spacetype == SPACE_VIEW3D) {
+  View3D *v3d = (View3D *)sl;
+  v3d->overlay.bone_wire_fade_depth = 1.0f;
+}
+  }
+}
+  }
+}
   }
 }
diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index ac7f1c5ff68..c141e81c799 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -545,6 +545,7 @@ set(GLSL_SRC
   engines/basic/shaders/basic_depth_frag.glsl
 
   engines/overlay/shaders/overlay_antialiasing_frag.glsl
+  engines/overlay/shaders/overlay_armature_alpha_lib.glsl
   engines/overlay/shaders/overlay_armature_dof_solid_frag.glsl
   engines/overlay/shaders/overlay_armature_dof_vert.glsl
   engines/overlay/shaders/overlay_armature_envelope_outline_vert.glsl
diff --git a/source/blender/draw/engines/overlay/overlay_armature.c 
b/source/blender/draw/engines/overlay/overlay_armature.c
index defd6e538ce..5371e34d2e2 100644
--- a/source/blender/draw/engines/overlay/overlay_armature.c
+++ b/source/blender/draw/engines/overlay/overlay_armature.c
@@ -86,6 +86,8 @@ typedef struct ArmatureDrawContext {
   bool transparent;
   bool show_relations;
 
+  float *p_fade_depth_bias;
+
   const ThemeWireColor *bcolor; /* pchan color */
 } ArmatureDrawContext;
 
@@ -126,7 +128,14 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata)
draw_ctx->object_pose != NULL;
 
   const float wire_alpha = pd->overlay.bone_wire_alpha;
-  const bool use_wire_alpha = (wire_alpha < 1.0f);
+  const float wire_fade = (pd->overlay.flag & V3D_OVERLAY_BONE_FADE_DEPTH) ?
+   

[Bf-blender-cvs] [09856f60810] temp-angavrilov: Shrinkwrap: support smoothing the mesh after wrapping.

2022-09-08 Thread Alexander Gavrilov
Commit: 09856f60810bd64a268e1317e7ef2159a574ea5a
Author: Alexander Gavrilov
Date:   Thu Sep 1 19:18:51 2022 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB09856f60810bd64a268e1317e7ef2159a574ea5a

Shrinkwrap: support smoothing the mesh after wrapping.

Adds a smoothing post-processing option for the shrinkwrap modifier.
On any other setting than 0 iterations, the algorithm adds the laplacian
of the deltas to the base mesh to produce a smooth-looking deformed
mesh -- this makes it possible to avoid losing detail on parts of the
mesh that are not affected by the shrinkwrap displacement.

Deltas that would otherwise lose magnitude as a result of smoothing
are not updated to avoid further volume loss; this keeps the result
much closer to the surface of the target while still adjusting other
shrinkwrapped (and non-shrinkwrapped) vertexes to follow the smooth
surface.

Differential Revision: https://developer.blender.org/D6414

===

M   source/blender/blenkernel/intern/shrinkwrap.c
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_shrinkwrap.c

===

diff --git a/source/blender/blenkernel/intern/shrinkwrap.c 
b/source/blender/blenkernel/intern/shrinkwrap.c
index 4b4e3bdcfa6..3b656cf60ba 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -62,6 +62,8 @@ typedef struct ShrinkwrapCalcData {
   struct MVert *vert; /* Array of verts being projected. */
   const float (*vert_normals)[3];
   float (*vertexCos)[3]; /* vertexs being shrinkwraped */
+  float (*deltas)[3];/* cached vertex deltas */
+  float *weights;/* cached vertex weights */
   int numVerts;
 
   const struct MDeformVert *dvert; /* Pointer to mdeform array */
@@ -328,6 +330,19 @@ void BKE_shrinkwrap_compute_boundary_data(struct Mesh 
*mesh)
   mesh->runtime.shrinkwrap_data = shrinkwrap_build_boundary_data(mesh);
 }
 
+/** Output the computed vertex position either to the final coordinate or the 
delta array. */
+BLI_INLINE void shrinkwrap_save_result(
+ShrinkwrapCalcData *calc, int i, float *co, float *result, float weight)
+{
+  if (calc->deltas) {
+sub_v3_v3v3(calc->deltas[i], result, co);
+mul_v3_fl(calc->deltas[i], weight);
+  }
+  else {
+interp_v3_v3v3(co, co, result, weight); /* linear interpolation */
+  }
+}
+
 /**
  * Shrink-wrap to the nearest vertex
  *
@@ -356,6 +371,10 @@ static void shrinkwrap_calc_nearest_vertex_cb_ex(void 
*__restrict userdata,
 return;
   }
 
+  if (calc->weights) {
+calc->weights[i] = weight;
+  }
+
   /* Convert the vertex to tree coordinates */
   if (calc->vert) {
 copy_v3_v3(tmp_co, calc->vert[i].co);
@@ -392,7 +411,7 @@ static void shrinkwrap_calc_nearest_vertex_cb_ex(void 
*__restrict userdata,
 copy_v3_v3(tmp_co, nearest->co);
 BLI_space_transform_invert(>local2target, tmp_co);
 
-interp_v3_v3v3(co, co, tmp_co, weight); /* linear interpolation */
+shrinkwrap_save_result(calc, i, co, tmp_co, weight);
   }
 }
 
@@ -520,6 +539,10 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void 
*__restrict userdata,
 return;
   }
 
+  if (calc->weights) {
+calc->weights[i] = weight;
+  }
+
   if (calc->vert != NULL && calc->smd->projAxis == 
MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
 /* calc->vert contains verts from evaluated mesh. */
 /* These coordinates are deformed by vertexCos only for normal projection
@@ -610,7 +633,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void 
*__restrict userdata,
hit->co);
 }
 
-interp_v3_v3v3(co, co, hit->co, weight);
+shrinkwrap_save_result(calc, i, co, hit->co, weight);
   }
 }
 
@@ -1120,6 +1143,10 @@ static void 
shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdat
 return;
   }
 
+  if (calc->weights) {
+calc->weights[i] = weight;
+  }
+
   /* Convert the vertex to tree coordinates */
   if (calc->vert) {
 copy_v3_v3(tmp_co, calc->vert[i].co);
@@ -1164,7 +1191,8 @@ static void 
shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdat
 
 /* Convert the coordinates back to mesh coordinates */
 BLI_space_transform_invert(>local2target, tmp_co);
-interp_v3_v3v3(co, co, tmp_co, weight); /* linear interpolation */
+
+shrinkwrap_save_result(calc, i, co, tmp_co, weight);
   }
 }
 
@@ -1365,6 +1393,136 @@ static void 
shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
   0, calc->numVerts, , shrinkwrap_calc_nearest_surface_point_cb_ex, 
);
 }
 
+static void shrinkwrap_smooth(
+ShrinkwrapCalcData *calc, Object *ob, Mesh *mesh, float (*vertexCos)[3], 
int numVerts)
+{
+  if (mesh == NULL) {
+return;
+  }
+
+  /* Number of neighboring vertices for the given vertex. */
+  

[Bf-blender-cvs] [d9709628143] temp-angavrilov: Shrinkwrap: fix stability of the Target Normal Project mode.

2022-09-08 Thread Alexander Gavrilov
Commit: d9709628143da799c6296fc616ba8d6558f47da8
Author: Alexander Gavrilov
Date:   Sat Sep 3 17:03:11 2022 +0300
Branches: temp-angavrilov
https://developer.blender.org/rBd9709628143da799c6296fc616ba8d6558f47da8

Shrinkwrap: fix stability of the Target Normal Project mode.

This mode works by using an iterative process to solve a system
of equations for each triangle to find a point on its surface that
has the smooth normal pointing at the original point. If a point
within the triangle is not found, the next triangle is searched.

All instability with vertices jumping to the opposite side of
the mesh is caused by incorrectly discarding triangles for various
reasons when the solution is close to the triangle edge.

In order to optimize performance the old code was aggressively
aborting iteration when the local gradient at the edge was
pointing outside domain. However, it is wrong because it can be
caused by a sharp valley diagonal to the domain boundary with
the bottom gently sloping towards a minimum within the domain.

Now iteration is only aborted either if the solution deviates
nonsensically far from the domain, or if the gradient is proven
to slope towards the outside perpendicular to the boundary.
Until either condition is met, values are simply clamped to
the domain.

In addition, custom correction clearly has to be done after
the linear search phase of the iterative solver, because the
linear correction math assumes running after a normal Newton
method step, not some kind of custom clamping.

Differential Revision: https://developer.blender.org/D15892

===

M   source/blender/blenkernel/intern/shrinkwrap.c
M   source/blender/blenlib/intern/math_solvers.c

===

diff --git a/source/blender/blenkernel/intern/shrinkwrap.c 
b/source/blender/blenkernel/intern/shrinkwrap.c
index 3b656cf60ba..88063769a61 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -779,18 +779,30 @@ static void target_project_tri_jacobian(void *userdata, 
const float x[3], float
 }
 
 /* Clamp barycentric weights to the triangle. */
-static void target_project_tri_clamp(float x[3])
+static float target_project_tri_clamp(float x[3])
 {
+  float error = 0.0f;
+
   if (x[0] < 0.0f) {
+error = max_ff(error, -x[0]);
+
 x[0] = 0.0f;
   }
+
   if (x[1] < 0.0f) {
+error = max_ff(error, -x[1]);
+
 x[1] = 0.0f;
   }
+
   if (x[0] + x[1] > 1.0f) {
+error = max_ff(error, x[0] + x[1] - 1.0f);
+
 x[0] = x[0] / (x[0] + x[1]);
 x[1] = 1.0f - x[0];
   }
+
+  return error;
 }
 
 /* Correct the Newton's method step to keep the coordinates within the 
triangle. */
@@ -799,71 +811,36 @@ static bool target_project_tri_correct(void 
*UNUSED(userdata),
float step[3],
float x_next[3])
 {
-  /* Insignificant correction threshold */
-  const float epsilon = 1e-5f;
-  /* Dot product threshold for checking if step is 'clearly' pointing outside. 
*/
-  const float dir_epsilon = 0.5f;
-  bool fixed = false, locked = false;
-
-  /* The barycentric coordinate domain is a triangle bounded by
-   * the X and Y axes, plus the x+y=1 diagonal. First, clamp the
-   * movement against the diagonal. Note that step is subtracted. */
-  float sum = x[0] + x[1];
-  float sstep = -(step[0] + step[1]);
-
-  if (sum + sstep > 1.0f) {
-float ldist = 1.0f - sum;
-
-/* If already at the boundary, slide along it. */
-if (ldist < epsilon * (float)M_SQRT2) {
-  float step_len = len_v2(step);
-
-  /* Abort if the solution is clearly outside the domain. */
-  if (step_len > epsilon && sstep > step_len * dir_epsilon * 
(float)M_SQRT2) {
-return false;
-  }
+  const float error = target_project_tri_clamp(x_next);
 
-  /* Project the new position onto the diagonal. */
-  add_v2_fl(step, (sum + sstep - 1.0f) * 0.5f);
-  fixed = locked = true;
-}
-else {
-  /* Scale a significant step down to arrive at the boundary. */
-  mul_v3_fl(step, ldist / sstep);
-  fixed = true;
-}
+  /* Immediately abort on a clearly wrong point.
+   *
+   * It is not appropriate to abort unless the value is extremely
+   * wrong, because if the goal function gradient forms a sharp
+   * valley with a gently sloping bottom, the iterative process may
+   * be dragged against the edge of the domain by local gradients
+   * for a number of steps even when the ultimate minimum is within
+   * the domain.
+   *
+   * This threshold basically represents an estimate of something so
+   * far outside the domain that all assumptions about the solution
+   * behavior start to break down.
+   */
+  if (error > 1.0f) {
+return false;
   }
 
-  /* Weight 0 and 1 boundary checks - along axis. */
-  for (int i = 0; i < 2; i++) {
-if (step[i] > x[i]) 

[Bf-blender-cvs] [a9277186084] temp-angavrilov: Force Fields: implement new true power and custom falloff options.

2022-09-08 Thread Alexander Gavrilov
Commit: a9277186084ba35c272dc1f7985f23c1bc00654e
Author: Alexander Gavrilov
Date:   Sun Sep 12 19:35:48 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rBa9277186084ba35c272dc1f7985f23c1bc00654e

Force Fields: implement new true power and custom falloff options.

The 'power' falloff option in Blender force fields does not actually
generate a true power falloff function, as pointed out in D2389.
However, that patch adds a special 'gravity' falloff option to Force
fields, without addressing the shortcoming in the common options.

The reason for not using the true curve in the options, as far as
one can tell, is that the power curve goes up to infinity as the
distance is reduced to 0, while the falloff options are designed
so that the maximum value of the curve is 1.

However, in reality forces with a power falloff don't actually go
to infinity, because real objects have a nonzero size, and the force
reaches its maximum at the surface of the object. This can be used
to integrate an option to use a true power falloff with the design
of falloff settings, if it requires a nonzero 'minimum' distance
to be set, and uses a curve that reaches 1 at that distance.

Since this is adding a new feature to the minimum distance value,
it is also a good opportunity to add a feature to the maximum
distance. Specifically, the new options can be used to apply
arbitrary brush-style falloff curves between min and max,
including a fully custom curve option. When used together with
power falloff, the two curves are multiplied together.

While the true power option allows creating more physically
correct forces, the custom curves aid artistic effects.

Differential Revision: https://developer.blender.org/D8075

===

M   release/scripts/startup/bl_ui/properties_physics_common.py
M   release/scripts/startup/bl_ui/properties_physics_field.py
M   source/blender/blenkernel/BKE_effect.h
M   source/blender/blenkernel/BKE_particle.h
M   source/blender/blenkernel/intern/effect.c
M   source/blender/blenkernel/intern/object.cc
M   source/blender/blenkernel/intern/particle.c
M   source/blender/makesdna/DNA_object_force_types.h
M   source/blender/makesrna/intern/rna_object_force.c

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py 
b/release/scripts/startup/bl_ui/properties_physics_common.py
index 60f384a3839..757e3015cf1 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -337,6 +337,10 @@ def basic_force_field_falloff_ui(self, field):
 sub.prop(field, "distance_min", text="")
 row.prop_decorator(field, "distance_min")
 
+col = layout.column()
+col.active = field.use_min_distance and field.distance_min > 0
+col.prop(field, "use_true_power")
+
 col = layout.column(align=False, heading="Max Distance")
 col.use_property_decorate = False
 row = col.row(align=True)
@@ -347,6 +351,13 @@ def basic_force_field_falloff_ui(self, field):
 sub.prop(field, "distance_max", text="")
 row.prop_decorator(field, "distance_max")
 
+col = layout.column()
+col.active = field.use_max_distance and field.distance_max > 
field.distance_min
+col.prop(field, "falloff_curve_type", text="Curve")
+
+if field.falloff_curve_type == 'CUSTOM':
+col.template_curve_mapping(field, "falloff_curve", type='NONE', 
brush=True)
+
 
 classes = (
 PHYSICS_PT_add,
diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py 
b/release/scripts/startup/bl_ui/properties_physics_field.py
index 36d5dc7f68d..635897247c9 100644
--- a/release/scripts/startup/bl_ui/properties_physics_field.py
+++ b/release/scripts/startup/bl_ui/properties_physics_field.py
@@ -238,20 +238,36 @@ class 
PHYSICS_PT_field_falloff_angular(PhysicButtonsPanel, Panel):
 col = flow.column()
 col.prop(field, "radial_falloff", text="Power")
 
-col = flow.column()
-col.prop(field, "use_radial_min", text="Use Min Angle")
-
-sub = col.column()
+col = layout.column(align=False, heading="Min Angle")
+col.use_property_decorate = False
+row = col.row(align=True)
+sub = row.row(align=True)
+sub.prop(field, "use_radial_min", text="")
+sub = sub.row(align=True)
 sub.active = field.use_radial_min
-sub.prop(field, "radial_min", text="Min Angle")
-
-col = flow.column()
-col.prop(field, "use_radial_max", text="Use Max Angle")
+sub.prop(field, "radial_min", text="")
+row.prop_decorator(field, "radial_min")
 
-sub = col.column()
+col = layout.column()
+col.active = field.use_radial_min and field.radial_min > 0
+col.prop(field, "use_radial_true_power")
+
+col = layout.column(align=False, 

[Bf-blender-cvs] [06858c676e5] temp-angavrilov: Armature: apply Y scale to B-Bone segments.

2022-09-08 Thread Alexander Gavrilov
Commit: 06858c676e5d743f23ffa38ba1b06775b89153f1
Author: Alexander Gavrilov
Date:   Tue Jun 15 13:52:23 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB06858c676e5d743f23ffa38ba1b06775b89153f1

Armature: apply Y scale to B-Bone segments.

This fixes a strange behavior where the segments were not actually
scaled in the Y direction to match their actual length, thus
producing gaps or overlap depending on the shape of the curve. For
transformation the change should be very small if enough segments
are used, but this will affect the results of the Copy Transforms
and Armature constraints, so a backwards compatibility option is
provided. Newly created bones default to the new behavior.

===

M   release/scripts/startup/bl_ui/properties_data_bone.py
M   source/blender/blenkernel/BKE_armature.h
M   source/blender/blenkernel/intern/armature.c
M   source/blender/draw/engines/overlay/overlay_armature.c
M   source/blender/makesdna/DNA_armature_types.h
M   source/blender/makesrna/intern/rna_armature.c

===

diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py 
b/release/scripts/startup/bl_ui/properties_data_bone.py
index 8e1808949b3..026e581b2ba 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -162,6 +162,8 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
 col.prop(bbone, "bbone_easeout", text="Out", 
text_ctxt=i18n_contexts.id_armature)
 col.prop(bone, "use_scale_easing")
 
+topcol.prop(bone, "use_unscaled_segments")
+
 col = topcol.column(align=True)
 col.prop(bone, "bbone_handle_type_start", text="Start Handle")
 
diff --git a/source/blender/blenkernel/BKE_armature.h 
b/source/blender/blenkernel/BKE_armature.h
index ee0f41937e2..2b217ca3025 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -469,7 +469,7 @@ typedef struct BBoneSplineParameters {
   float length;
 
   /* Non-uniform scale correction. */
-  bool do_scale;
+  bool do_scale, do_scale_segments;
   float scale[3];
 
   /* Handle control bone data. */
diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index 0027f6dd707..7f9daab6dbe 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -944,6 +944,8 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel 
*pchan,
   param->segments = bone->segments;
   param->length = bone->length;
 
+  param->do_scale_segments = (bone->bbone_flag & BBONE_SCALE_SEGMENTS) != 0;
+
   if (!rest) {
 float scale[3];
 
@@ -1309,6 +1311,7 @@ static void 
make_bbone_spline_matrix(BBoneSplineParameters *param,
  const float axis[3],
  float roll,
  float scalex,
+ float scaley,
  float scalez,
  float result[4][4])
 {
@@ -1326,6 +1329,7 @@ static void 
make_bbone_spline_matrix(BBoneSplineParameters *param,
 
   /* BBone scale... */
   mul_v3_fl(result[0], scalex);
+  mul_v3_fl(result[1], scaley);
   mul_v3_fl(result[2], scalez);
 }
 
@@ -1393,6 +1397,8 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters 
*param,
   equalize_cubic_bezier(
   bezt_controls, MAX_BBONE_SUBDIV, param->segments, segment_scales, 
bezt_points);
 
+  const float scale_fac = param->segments / length;
+
   /* Deformation uses N+1 matrices computed at points between the segments. */
   if (for_deform) {
 /* Bezier derivatives. */
@@ -1405,6 +1411,32 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters 
*param,
   sub_v3_v3v3(bezt_deriv2[i], bezt_deriv1[i + 1], bezt_deriv1[i]);
 }
 
+/* Inner segment points. */
+float points[MAX_BBONE_SUBDIV][3], tangents[MAX_BBONE_SUBDIV][3];
+
+copy_v3_v3(points[0], bezt_controls[0]);
+
+for (int a = 1; a < param->segments; a++) {
+  evaluate_cubic_bezier(bezt_controls, bezt_points[a], points[a], 
tangents[a]);
+}
+
+/* Segment lengths. */
+float seg_length[MAX_BBONE_SUBDIV + 1];
+
+if (param->do_scale_segments) {
+  for (int a = 1; a < param->segments; a++) {
+seg_length[a] = len_v3v3(points[a - 1], points[a]) * scale_fac;
+  }
+
+  seg_length[param->segments] = len_v3v3(points[param->segments - 1], 
bezt_controls[3]) *
+scale_fac;
+}
+else {
+  for (int a = 1; a <= param->segments; a++) {
+seg_length[a] = 1;
+  }
+}
+
 /* End points require special handling to fix zero length handles. */
 ease_handle_axis(bezt_deriv1[0], bezt_deriv2[0], axis);
 make_bbone_spline_matrix(param,
@@ 

[Bf-blender-cvs] [0190f19acc8] temp-angavrilov: Temporary Hack: provide B-Bone scale versioning for files with old patch.

2022-09-08 Thread Alexander Gavrilov
Commit: 0190f19acc825735e8dd200aa9782d31d7339f70
Author: Alexander Gavrilov
Date:   Tue Jun 22 16:38:26 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB0190f19acc825735e8dd200aa9782d31d7339f70

Temporary Hack: provide B-Bone scale versioning for files with old patch.

Run the versioning code for the conversion of bbone scale to an xyz
vector if it has fields that correspond to the old version of the
patch before that change requiring versioning.

The actual Y (length) scale value from the old patch isn't versioned
and will be lost, requiring manual fixing.

===

M   source/blender/blenloader/intern/versioning_300.c

===

diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.c
index 1692fd2d747..374b4c9d89a 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1842,7 +1842,8 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
 }
 
 /* Initialize length-wise scale B-Bone settings. */
-if (!DNA_struct_elem_find(fd->filesdna, "Bone", "int", "bbone_flag")) {
+if (!DNA_struct_elem_find(fd->filesdna, "Bone", "int", "bbone_flag") ||
+DNA_struct_elem_find(fd->filesdna, "Bone", "float", "scale_in_len")) {
   /* Update armature data and pose channels. */
   LISTBASE_FOREACH (bArmature *, arm, >armatures) {
 do_version_bones_bbone_len_scale(>bonebase);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8abd07b4f03] temp-angavrilov: Animation: support filtering for curves that have cycle issues.

2022-09-08 Thread Alexander Gavrilov
Commit: 8abd07b4f03367bf607062efd6a9d83f9d9c0aeb
Author: Alexander Gavrilov
Date:   Mon May 3 17:27:53 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB8abd07b4f03367bf607062efd6a9d83f9d9c0aeb

Animation: support filtering for curves that have cycle issues.

It is possible to have curves with cyclic extrapolation that
have a mismatch in their end keyframes, causing a jump.

Also, since the looping behavior is defined per curve rather than at
action level, it is possible for curve loop periods to get out of
sync with each other. This commit adds an option to compare curves
against the manual frame range specified in the action, and treat
any mismatches as errors for the purpose of F-Curve filtering.

When enabled, the check verifies that end values of cyclic curves
match, curves within a cyclic action have valid cyclic extrapolation,
and the action period evenly divides by the curve period (since
a curve looping at e.g. half of the action period length still
repeats in sync with the action).

Ref: D11803

Differential Revision: https://developer.blender.org/D13349

===

M   release/scripts/startup/bl_ui/space_dopesheet.py
M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/editors/animation/anim_filter.c
M   source/blender/makesdna/DNA_action_types.h
M   source/blender/makesrna/intern/rna_action.c

===

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index a2e691c2d9f..b4f580839b7 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -63,6 +63,12 @@ class DopesheetFilterPopoverBase:
 else:  # graph and dopesheet editors - F-Curves and drivers only
 col.prop(dopesheet, "show_only_errors", icon='NONE')
 
+col.separator()
+
+col2 = col.column(align=True)
+col2.active = dopesheet.show_only_errors
+col2.prop(dopesheet, "show_cycle_errors")
+
 # Name/Membership Filters
 # XXX: Perhaps these should just stay in the headers (exclusively)?
 @classmethod
diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index c5788c07336..68fa879a0ce 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -448,7 +448,7 @@ typedef enum eFCU_Cycle_Type {
 /**
  * Checks if the F-Curve has a Cycles modifier, and returns the type of the 
cycle behavior.
  */
-eFCU_Cycle_Type BKE_fcurve_get_cycle_type(struct FCurve *fcu);
+eFCU_Cycle_Type BKE_fcurve_get_cycle_type(const struct FCurve *fcu);
 
 /**
  * Recompute bezier handles of all three given BezTriples, so that `bezt` can 
be inserted between
diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index f5876e48241..038e0fc 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1156,7 +1156,7 @@ void fcurve_samples_to_keyframes(FCurve *fcu, const int 
start, const int end)
  * that the handles are correct.
  */
 
-eFCU_Cycle_Type BKE_fcurve_get_cycle_type(FCurve *fcu)
+eFCU_Cycle_Type BKE_fcurve_get_cycle_type(const FCurve *fcu)
 {
   FModifier *fcm = fcu->modifiers.first;
 
diff --git a/source/blender/editors/animation/anim_filter.c 
b/source/blender/editors/animation/anim_filter.c
index 6dc11292a3a..fb98df09233 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -63,6 +63,7 @@
 #include "BLI_alloca.h"
 #include "BLI_blenlib.h"
 #include "BLI_ghash.h"
+#include "BLI_math.h"
 #include "BLI_string.h"
 #include "BLI_utildefines.h"
 
@@ -1199,6 +1200,53 @@ static bool skip_fcurve_with_name(
   return true;
 }
 
+/* Check if the F-Curve doesn't cycle properly based on action settings. */
+static bool fcurve_has_cycle_errors(const FCurve *fcu, const bAction *act)
+{
+  /* Check if the curve is cyclic. */
+  const eFCU_Cycle_Type cycle_type = BKE_fcurve_get_cycle_type(fcu);
+
+  if (cycle_type == FCU_CYCLE_NONE) {
+/* Curves in a cyclic action should be cyclic; in an ordinary action 
either way is fine. */
+return BKE_action_is_cyclic(act);
+  }
+
+  /* Check if the curve has enough points. */
+  if (fcu->totvert < 2 || !fcu->bezt) {
+return true;
+  }
+
+  const BezTriple *first = >bezt[0], *last = >bezt[fcu->totvert - 1];
+
+  if (BKE_action_is_cyclic(act)) {
+/* Check that it has a nonzero period length. */
+const float curve_period = last->vec[1][0] - first->vec[1][0];
+
+if (curve_period < 0.1f) {
+  return true;
+}
+
+/* Check that the action period is divisible by the curve period. */
+const float action_period = act->frame_end - act->frame_start;
+const float 

[Bf-blender-cvs] [77522ea27cf] temp-angavrilov: Depsgraph: connect up drivers on various physics properties.

2022-09-08 Thread Alexander Gavrilov
Commit: 77522ea27cf3546d1e48faa08fa2068506c21bda
Author: Alexander Gavrilov
Date:   Sat Jan 9 21:19:37 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB77522ea27cf3546d1e48faa08fa2068506c21bda

Depsgraph: connect up drivers on various physics properties.

It seems drivers for physics properties weren't being linked to
evaluation nodes. This connects settings used by modifiers
to Geometry; particle settings and rigid body data to Transform
which seems to contain rigid body evaluation; and force fields
to object Transform, since fields can exist on empties.

Differential Revision: https://developer.blender.org/D10088

===

M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   source/blender/depsgraph/intern/builder/deg_builder_rna.cc

===

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 313d4996dcf..aa29e3794fd 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -2024,6 +2024,27 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene 
*scene)
 }
 FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
   }
+  /* Constraints. */
+  if (rbw->constraints != nullptr) {
+build_collection(nullptr, nullptr, rbw->constraints);
+FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->constraints, object) {
+  if (object->rigidbody_constraint == nullptr) {
+continue;
+  }
+  if (object->rigidbody_object != nullptr) {
+/* Avoid duplicate relations for constraints attached to objects. */
+continue;
+  }
+
+  /* Simulation uses object transformation after parenting and solving 
constraints. */
+  OperationKey object_transform_simulation_init_key(
+  >id, NodeType::TRANSFORM, 
OperationCode::TRANSFORM_SIMULATION_INIT);
+  add_relation(object_transform_simulation_init_key,
+   rb_simulate_key,
+   "Object Transform -> Rigidbody Sim Eval");
+}
+FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
+  }
 }
 
 void DepsgraphRelationBuilder::build_particle_systems(Object *object)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index d94746fb7fa..09ad99ad585 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -283,7 +283,16 @@ RNANodeIdentifier 
RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
RNA_struct_is_a(ptr->type, _MeshUVLoop) ||
RNA_struct_is_a(ptr->type, _MeshLoopColor) ||
RNA_struct_is_a(ptr->type, _VertexGroupElement) ||
-   RNA_struct_is_a(ptr->type, _ShaderFx)) {
+   RNA_struct_is_a(ptr->type, _ShaderFx) ||
+   ELEM(ptr->type,
+_CollisionSettings,
+_SoftBodySettings,
+_ClothSettings,
+_ClothCollisionSettings,
+_DynamicPaintSurface,
+_DynamicPaintCanvasSettings,
+_DynamicPaintBrushSettings) ||
+   (ELEM(ptr->type, _EffectorWeights) && 
GS(node_identifier.id->name) == ID_OB)) {
 /* When modifier is used as FROM operation this is likely referencing to
  * the property (for example, modifier's influence).
  * But when it's used as TO operation, this is geometry component. */
@@ -383,6 +392,20 @@ RNANodeIdentifier 
RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
 node_identifier.type = NodeType::GEOMETRY;
 return node_identifier;
   }
+  else if (GS(node_identifier.id->name) == ID_PA &&
+   ELEM(ptr->type, _EffectorWeights, _FieldSettings, 
_ParticleSettings)) {
+node_identifier.type = NodeType::PARTICLE_SETTINGS;
+return node_identifier;
+  }
+  else if (ELEM(ptr->type,
+_EffectorWeights,
+_RigidBodyWorld,
+_FieldSettings,
+_RigidBodyObject,
+_RigidBodyConstraint)) {
+node_identifier.type = NodeType::TRANSFORM;
+return node_identifier;
+  }
   if (prop != nullptr) {
 /* All unknown data effectively falls under "parameter evaluation". */
 node_identifier.type = NodeType::PARAMETERS;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8878696639f] temp-angavrilov: Dope Sheet: distinguish Constant and Linear from other interpolation modes.

2022-09-08 Thread Alexander Gavrilov
Commit: 8878696639ffaa349232dd1bbdee6fbb58843716
Author: Alexander Gavrilov
Date:   Sat Feb 5 14:11:29 2022 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB8878696639ffaa349232dd1bbdee6fbb58843716

Dope Sheet: distinguish Constant and Linear from other interpolation modes.

There is an option to display handles and interpolation modes in
the dope sheet, but the only interpolation mode it distinguishes
is Bezier. This adds distinct display for Constant and Linear:

- Constant is drawn as a thicker line.
- Linear is drawn the same as now.
- Other non-Bezier modes are drawn as a double line.

Constant, Linear and Bezier are the most common modes, so it makes
sense to distinguish them from all others.

Differential Revision: https://developer.blender.org/D15855

===

M   source/blender/editors/animation/keyframes_draw.c
M   source/blender/editors/animation/keyframes_keylist.cc
M   source/blender/editors/include/ED_keyframes_keylist.h

===

diff --git a/source/blender/editors/animation/keyframes_draw.c 
b/source/blender/editors/animation/keyframes_draw.c
index 786204a52ed..1e6aa4602ea 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -287,14 +287,30 @@ static void draw_keylist_block_interpolation_line(const 
DrawKeylistUIData *ctx,
   const ActKeyColumn *ab,
   float ypos)
 {
+  float width = ctx->ipo_size;
+  bool fill = true;
+
+  switch (ab->block.ipo) {
+case BEZT_IPO_CONST:
+  width *= 1.7f;
+  break;
+
+case BEZT_IPO_LIN:
+  break;
+
+default:
+  width *= 2.0f;
+  fill = false;
+  }
+
   UI_draw_roundbox_4fv(
   &(const rctf){
   .xmin = ab->cfra,
   .xmax = ab->next->cfra,
-  .ymin = ypos - ctx->ipo_size,
-  .ymax = ypos + ctx->ipo_size,
+  .ymin = ypos - width,
+  .ymax = ypos + width,
   },
-  true,
+  fill,
   3.0f,
   (ab->block.conflict & ACTKEYBLOCK_FLAG_NON_BEZIER) ? ctx->ipo_color_mix 
: ctx->ipo_color);
 }
diff --git a/source/blender/editors/animation/keyframes_keylist.cc 
b/source/blender/editors/animation/keyframes_keylist.cc
index da266dd4253..dac61f54c60 100644
--- a/source/blender/editors/animation/keyframes_keylist.cc
+++ b/source/blender/editors/animation/keyframes_keylist.cc
@@ -749,6 +749,10 @@ static void compute_keyblock_data(ActKeyBlockInfo *info,
   /* Remember non-bezier interpolation info. */
   if (prev->ipo != BEZT_IPO_BEZ) {
 info->flag |= ACTKEYBLOCK_FLAG_NON_BEZIER;
+info->ipo = prev->ipo;
+  }
+  else {
+info->ipo = -1;
   }
 
   info->sel = BEZT_ISSEL_ANY(prev) || BEZT_ISSEL_ANY(beztn);
@@ -765,6 +769,13 @@ static void add_keyblock_info(ActKeyColumn *col, const 
ActKeyBlockInfo *block)
 col->block.conflict |= (col->block.flag ^ block->flag);
 col->block.flag |= block->flag;
 col->block.sel |= block->sel;
+
+/* Combine interpolations; detect conflicts and use max value. */
+if (col->block.ipo != block->ipo) {
+  col->block.conflict |= ACTKEYBLOCK_FLAG_NON_BEZIER;
+}
+
+col->block.ipo = MAX2(col->block.ipo, block->ipo);
   }
 
   if (block->flag) {
diff --git a/source/blender/editors/include/ED_keyframes_keylist.h 
b/source/blender/editors/include/ED_keyframes_keylist.h
index 251b6e4d83d..d82d98777b8 100644
--- a/source/blender/editors/include/ED_keyframes_keylist.h
+++ b/source/blender/editors/include/ED_keyframes_keylist.h
@@ -37,6 +37,9 @@ typedef struct ActKeyBlockInfo {
 
   /* Selection flag. */
   char sel;
+
+  /* Interpolation mode. */
+  signed char ipo;
 } ActKeyBlockInfo;
 
 /* Keyframe Column Struct */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e5a74706388] master: Fix: link drag search feature only works forgeometry nodes groups

2022-09-08 Thread Hans Goudey
Commit: e5a7470638803fd0780f98d8b23052cc16ca8d7d
Author: Hans Goudey
Date:   Thu Sep 8 10:57:21 2022 -0500
Branches: master
https://developer.blender.org/rBe5a7470638803fd0780f98d8b23052cc16ca8d7d

Fix: link drag search feature only works forgeometry nodes groups

The node tree used to detect if the tree was a node group wasn't the
last in the node editor's path like it should be, so the search thought
that all shader node groups weren't node groups.

===

M   source/blender/editors/space_node/link_drag_search.cc

===

diff --git a/source/blender/editors/space_node/link_drag_search.cc 
b/source/blender/editors/space_node/link_drag_search.cc
index 553d4013324..21d5d8d7d26 100644
--- a/source/blender/editors/space_node/link_drag_search.cc
+++ b/source/blender/editors/space_node/link_drag_search.cc
@@ -247,8 +247,8 @@ static uiBlock *create_search_popup_block(bContext *C, 
ARegion *region, void *ar
 {
   LinkDragSearchStorage  = *(LinkDragSearchStorage *)arg_op;
 
-  bNodeTree *node_tree = CTX_wm_space_node(C)->nodetree;
-  gather_socket_link_operations(*node_tree, storage.from_socket, 
storage.search_link_ops);
+  bNodeTree _tree = *CTX_wm_space_node(C)->edittree;
+  gather_socket_link_operations(node_tree, storage.from_socket, 
storage.search_link_ops);
 
   uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
   UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | 
UI_BLOCK_SEARCH_MENU);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3d1244c1342] temp-geometry-nodes-evaluator-refactor: comments

2022-09-08 Thread Jacques Lucke
Commit: 3d1244c1342e06a3cbeb26e87229640e579ac8f7
Author: Jacques Lucke
Date:   Thu Sep 8 16:07:02 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB3d1244c1342e06a3cbeb26e87229640e579ac8f7

comments

===

M   source/blender/functions/FN_lazy_function_graph.hh
M   source/blender/functions/intern/lazy_function_graph.cc
M   source/blender/functions/intern/lazy_function_graph_executor.cc

===

diff --git a/source/blender/functions/FN_lazy_function_graph.hh 
b/source/blender/functions/FN_lazy_function_graph.hh
index 0826bfe7c21..4ede28c4f26 100644
--- a/source/blender/functions/FN_lazy_function_graph.hh
+++ b/source/blender/functions/FN_lazy_function_graph.hh
@@ -4,6 +4,15 @@
 
 /** \file
  * \ingroup fn
+ *
+ * This file contains a graph data structure that allows composing multiple 
lazy-functions into a
+ * combined lazy-function.
+ *
+ * There are two types of nodes in the graph:
+ * - #FunctionNode: Corresponds to a #LazyFunction. The inputs and outputs of 
the function become
+ *   input and output sockets of the node.
+ * - #DummyNode: Is used to indicate inputs and outputs of the entire graph. 
It can have an
+ *   arbitrary number of sockets.
  */
 
 #include "BLI_linear_allocator.hh"
@@ -18,11 +27,27 @@ class OutputSocket;
 class Node;
 class Graph;
 
+/**
+ * A #Socket is the interface of a #Node. Every #Socket is either an 
#InputSocket or #OutputSocket.
+ * Links can be created from output sockets to input sockets.
+ */
 class Socket : NonCopyable, NonMovable {
  protected:
+  /**
+   * The node the socket belongs to.
+   */
   Node *node_;
+  /**
+   * Data type of the socket. Only sockets with the same type can be linked.
+   */
   const CPPType *type_;
+  /**
+   * Indicates whether this is an #InputSocket or #OutputSocket.
+   */
   bool is_input_;
+  /**
+   * Index of the socket. E.g. 0 for the first input and the first output 
socket.
+   */
   int index_in_node_;
 
   friend Graph;
@@ -31,7 +56,7 @@ class Socket : NonCopyable, NonMovable {
   bool is_input() const;
   bool is_output() const;
 
-  int index_in_node() const;
+  int index() const;
 
   InputSocket _input();
   OutputSocket _output();
@@ -48,7 +73,20 @@ class Socket : NonCopyable, NonMovable {
 
 class InputSocket : public Socket {
  private:
+  /**
+   * An input can have at most one link connected to it. The linked socket is 
the "origin" because
+   * it's where the data is coming from. The type of the origin must be the 
same as the type of
+   * this socket.
+   */
   OutputSocket *origin_;
+  /**
+   * Can be null or a non-owning pointer to a value of the type of the socket. 
This value will be
+   * used when the input is used but not linked.
+   *
+   * This is technically not needed, because one could just create a separate 
node that just
+   * outputs the value, but that would have more overhead. Especially because 
it's commonly the
+   * case that most inputs are unlinked.
+   */
   const void *default_value_ = nullptr;
 
   friend Graph;
@@ -63,6 +101,9 @@ class InputSocket : public Socket {
 
 class OutputSocket : public Socket {
  private:
+  /**
+   * An output can be linked to an arbitrary number of inputs of the same type.
+   */
   Vector targets_;
 
   friend Graph;
@@ -72,11 +113,30 @@ class OutputSocket : public Socket {
   Span targets() const;
 };
 
+/**
+ * A #Node has input and output sockets. Every node is either a #FunctionNode 
or a #DummyNode.
+ */
 class Node : NonCopyable, NonMovable {
  protected:
+  /**
+   * The function this node corresponds to. If this is null, the node is a 
#DummyNode.
+   * The function is not owned by this #Node nor by the #Graph.
+   */
   const LazyFunction *fn_ = nullptr;
+  /**
+   * Input sockets of the node.
+   */
   Span inputs_;
+  /**
+   * Output sockets of the node.
+   */
   Span outputs_;
+  /**
+   * An index that is set when calling #Graph::update_node_indices. This can 
be used to create
+   * efficient mappings from nodes to other data using just an array instead 
of a hash map.
+   *
+   * This is technically not necessary but has better performance than always 
using hash maps.
+   */
   int index_in_graph_ = -1;
 
   friend Graph;
@@ -99,11 +159,18 @@ class Node : NonCopyable, NonMovable {
   std::string name() const;
 };
 
+/**
+ * A #Node that corresponds to a specific #LazyFunction.
+ */
 class FunctionNode : public Node {
  public:
   const LazyFunction () const;
 };
 
+/**
+ * A #Node that does *not* correspond to a #LazyFunction. Instead it can be 
used to indicate inputs
+ * and outputs of the entire graph. It can have an arbitrary number of inputs 
and outputs.
+ */
 class DummyNode : public Node {
  private:
   std::string name_;
@@ -111,24 +178,57 @@ class DummyNode : public Node {
   friend Node;
 };
 
+/**
+ * A container for an arbitrary number of nodes and 

[Bf-blender-cvs] [9007489c515] temp-geometry-nodes-evaluator-refactor: comments

2022-09-08 Thread Jacques Lucke
Commit: 9007489c515269c6ef90b3ebf853fb2e2e0d36a5
Author: Jacques Lucke
Date:   Thu Sep 8 16:53:43 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB9007489c515269c6ef90b3ebf853fb2e2e0d36a5

comments

===

M   source/blender/functions/intern/lazy_function_graph_executor.cc

===

diff --git a/source/blender/functions/intern/lazy_function_graph_executor.cc 
b/source/blender/functions/intern/lazy_function_graph_executor.cc
index b6b3ca591bc..9d7e143838e 100644
--- a/source/blender/functions/intern/lazy_function_graph_executor.cc
+++ b/source/blender/functions/intern/lazy_function_graph_executor.cc
@@ -470,6 +470,8 @@ class Executor {
 NodeState _state = *node_states_[node.index_in_graph()];
 OutputState _state = node_state.outputs[index_in_node];
 
+/* The notified output socket might be an input of the entire graph. In 
this case, notify the
+ * caller that the input is required. */
 if (node.is_dummy()) {
   const int graph_input_index = self_.graph_inputs_.index_of();
   std::atomic _loaded = loaded_inputs_[graph_input_index];
@@ -529,6 +531,10 @@ class Executor {
 BLI_assert(locked_node.node.is_function());
 switch (locked_node.node_state.schedule_state) {
   case NodeScheduleState::NotScheduled: {
+/* Don't add the node to the task pool immeditately, because the task 
pool might start
+ * executing it immediatly (when Blender is started with a single 
thread). That would often
+ * result in a deadlock, because we are still holding the mutex of the 
current node.
+ * Also see comments in #LockedNode. */
 locked_node.node_state.schedule_state = NodeScheduleState::Scheduled;
 locked_node.delayed_scheduled_nodes.append(
 _cast(locked_node.node));
@@ -584,6 +590,9 @@ class Executor {
   void schedule_new_nodes(const Span nodes, CurrentTask 
_task)
   {
 for (const FunctionNode *node_to_schedule : nodes) {
+  /* Avoid a round trip through the task pool for the first node that is 
scheduled by the
+   * current node execution. Other nodes are added to the pool so that 
other threads can pick
+   * them up. */
   const FunctionNode *expected = nullptr;
   if (current_task.next_node.compare_exchange_strong(
   expected, node_to_schedule, std::memory_order_relaxed)) {
@@ -606,6 +615,8 @@ class Executor {
 Executor  = *static_cast(user_data);
 const FunctionNode  = *static_cast(task_data);
 
+/* This loop reduces the number of round trips through the task pool as 
long as the current
+ * node is scheduling more nodes. */
 CurrentTask current_task;
 current_task.next_node = 
 while (current_task.next_node != nullptr) {
@@ -694,6 +705,9 @@ class Executor {
 });
 
 if (node_needs_execution) {
+  /* Importantly, the node must not be locked when it is executed. That 
would result in locks
+   * being hold very long in some cases and results in multiple locks 
being hold by the same
+   * thread in the same graph which can lead to deadlocks. */
   this->execute_node(node, node_state, current_task);
 }
 
@@ -883,6 +897,7 @@ class Executor {
 self_.logger_->log_socket_value(*context_, *target_socket, 
value_to_forward);
   }
   if (target_node.is_dummy()) {
+/* Forward the value to the outside of the graph. */
 const int graph_output_index = 
self_.graph_outputs_.index_of_try(target_socket);
 if (graph_output_index != -1 &&
 params_->get_output_usage(graph_output_index) != 
ValueUsage::Unused) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [079b38f8def] temp-geometry-nodes-evaluator-refactor: comments

2022-09-08 Thread Jacques Lucke
Commit: 079b38f8def1143f1319d367fa32661926ecc8b0
Author: Jacques Lucke
Date:   Thu Sep 8 16:37:35 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB079b38f8def1143f1319d367fa32661926ecc8b0

comments

===

M   source/blender/functions/FN_lazy_function_graph_executor.hh
M   source/blender/functions/intern/lazy_function_graph_executor.cc

===

diff --git a/source/blender/functions/FN_lazy_function_graph_executor.hh 
b/source/blender/functions/FN_lazy_function_graph_executor.hh
index cabc69f34ac..ad4098aeee6 100644
--- a/source/blender/functions/FN_lazy_function_graph_executor.hh
+++ b/source/blender/functions/FN_lazy_function_graph_executor.hh
@@ -4,6 +4,9 @@
 
 /** \file
  * \ingroup fn
+ *
+ * This file provides means to create a #LazyFunction from #Graph (which could 
then e.g. be used in
+ * another #Graph again).
  */
 
 #include "BLI_vector.hh"
@@ -13,6 +16,9 @@
 
 namespace blender::fn::lazy_function {
 
+/**
+ * Can be implemented to log values produced during graph evaluation.
+ */
 class GraphExecutorLogger {
  public:
   virtual ~GraphExecutorLogger() = default;
@@ -22,6 +28,11 @@ class GraphExecutorLogger {
 GPointer value) const;
 };
 
+/**
+ * Has to be implemented when some of the nodes in the graph may have side 
effects. The
+ * #GraphExecutor has to know about that to make sure that these nodes will be 
executed even though
+ * their outputs are not needed.
+ */
 class GraphExecutorSideEffectProvider {
  public:
   virtual ~GraphExecutorSideEffectProvider() = default;
diff --git a/source/blender/functions/intern/lazy_function_graph_executor.cc 
b/source/blender/functions/intern/lazy_function_graph_executor.cc
index 97393b04f8e..b6b3ca591bc 100644
--- a/source/blender/functions/intern/lazy_function_graph_executor.cc
+++ b/source/blender/functions/intern/lazy_function_graph_executor.cc
@@ -1,5 +1,43 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
+/**
+ * This file implements the evaluation of a lazy-function graph. It's main 
objectices are:
+ * - Only compute values that are actually used.
+ * - Allow to spread the work over an arbitrary number of CPU cores.
+ *
+ * Other (simpler) executors with different main objectives could be 
implemented in the future. For
+ * some scenarios those could be simpler when many nodes do very little work 
or most nodes have to
+ * be processed sequentially. Those assumptions make the first and second 
objective less important
+ * respectively.
+ *
+ * The design implemented in this executor requires *no* main thread that 
coordinates everything.
+ * Instead, one thread will trigger some initial work and then many threads 
coordinate themselves
+ * in a distributed fashion. In an ideal situation, every thread ends up 
processing a separate part
+ * of the graph which results in less communication overhead. The way TBB 
schedules tasks helps
+ * with that: a thread will next process the task that it added to a task pool 
just before.
+ *
+ * Communication between threads is synchronized by using a mutex in every 
node. When a thread
+ * wants to access the state of a node, its mutex has to be locked first 
(there some documented
+ * exceptions) to that. The assumption here is that most nodes are only ever 
touched by a single
+ * thread and therefore the lock contention is reduced the more nodes there 
are.
+ *
+ * Similar to how a #LazyFunction can be thought of as a state machine (see 
`FN_lazy_function.hh`),
+ * each node can also be thought of as a state machine. The state of a node 
contains the evaluation
+ * state of its inputs and outputs. Every time a node is executed, it has to 
advance its state in
+ * some way (e.g. it requests a new input or computes a new output).
+ *
+ * At the core of the executor is a task pool. Every task in that pool 
represents a node execution.
+ * When a node is executed it may send notifications to other nodes which may 
in turn add those
+ * nodes to the task pool. For example, the current node has computed one of 
its outputs, then the
+ * computed value is forwarded to all linked inputs, changing their node 
states in the process. If
+ * this input was the last missing required input, the node will be added to 
the task pool so that
+ * it is executed next.
+ *
+ * When the task pool is empty, the executor gives back control to the caller 
which may later
+ * provide new inputs to the graph which in turn adds new nodes to the task 
pool and the process
+ * starts again.
+ */
+
 #include 
 
 #include "BLI_enumerable_thread_specific.hh"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [011a1f3335c] temp-geometry-nodes-evaluator-refactor: fix

2022-09-08 Thread Jacques Lucke
Commit: 011a1f3335ceb58e798ac306f860f10c223cc9da
Author: Jacques Lucke
Date:   Thu Sep 8 17:21:48 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB011a1f3335ceb58e798ac306f860f10c223cc9da

fix

===

M   source/blender/nodes/NOD_geometry_nodes_log.hh
M   source/blender/nodes/intern/geometry_nodes_log.cc

===

diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh 
b/source/blender/nodes/NOD_geometry_nodes_log.hh
index 297702bd0b2..e239654fc33 100644
--- a/source/blender/nodes/NOD_geometry_nodes_log.hh
+++ b/source/blender/nodes/NOD_geometry_nodes_log.hh
@@ -156,6 +156,7 @@ class GeoTreeLog {
  private:
   GeoModifierLog *modifier_log_;
   Vector tree_loggers_;
+  VectorSet children_hashes_;
   bool reduced_node_warnings_ = false;
   bool reduced_node_run_times_ = false;
   bool reduced_socket_values_ = false;
diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc 
b/source/blender/nodes/intern/geometry_nodes_log.cc
index db1f5311534..715ea1291ab 100644
--- a/source/blender/nodes/intern/geometry_nodes_log.cc
+++ b/source/blender/nodes/intern/geometry_nodes_log.cc
@@ -124,6 +124,11 @@ GeoNodeLog::~GeoNodeLog() = default;
 GeoTreeLog::GeoTreeLog(GeoModifierLog *modifier_log, Vector 
tree_loggers)
 : modifier_log_(modifier_log), tree_loggers_(std::move(tree_loggers))
 {
+  for (GeoTreeLogger *tree_logger : tree_loggers_) {
+for (const ComputeContextHash  : tree_logger->children_hashes) {
+  children_hashes_.add(hash);
+}
+  }
 }
 
 GeoTreeLog::~GeoTreeLog() = default;
@@ -195,17 +200,16 @@ void GeoTreeLog::ensure_node_warnings()
   
this->nodes.lookup_or_add_default(warnings.first).warnings.append(warnings.second);
   this->all_warnings.append(warnings.second);
 }
-for (const ComputeContextHash _hash : tree_logger->children_hashes) {
-  GeoTreeLog _log = modifier_log_->get_tree_log(child_hash);
-  child_log.ensure_node_warnings();
-  const std::optional _node_name =
-  child_log.tree_loggers_[0]->group_node_name;
-  if (group_node_name.has_value()) {
-this->nodes.lookup_or_add_default(*group_node_name)
-.warnings.extend(child_log.all_warnings);
-  }
-  this->all_warnings.extend(child_log.all_warnings);
+  }
+  for (const ComputeContextHash _hash : children_hashes_) {
+GeoTreeLog _log = modifier_log_->get_tree_log(child_hash);
+child_log.ensure_node_warnings();
+const std::optional _node_name =
+child_log.tree_loggers_[0]->group_node_name;
+if (group_node_name.has_value()) {
+  
this->nodes.lookup_or_add_default(*group_node_name).warnings.extend(child_log.all_warnings);
 }
+this->all_warnings.extend(child_log.all_warnings);
   }
   reduced_node_warnings_ = true;
 }
@@ -223,16 +227,16 @@ void GeoTreeLog::ensure_node_run_time()
   this->nodes.lookup_or_add_default_as(node_name).run_time += duration;
   this->run_time_sum += duration;
 }
-for (const ComputeContextHash _hash : tree_logger->children_hashes) {
-  GeoTreeLog _log = modifier_log_->get_tree_log(child_hash);
-  child_log.ensure_node_run_time();
-  const std::optional _node_name =
-  child_log.tree_loggers_[0]->group_node_name;
-  if (group_node_name.has_value()) {
-this->nodes.lookup_or_add_default(*group_node_name).run_time += 
child_log.run_time_sum;
-  }
-  this->run_time_sum += child_log.run_time_sum;
+  }
+  for (const ComputeContextHash _hash : children_hashes_) {
+GeoTreeLog _log = modifier_log_->get_tree_log(child_hash);
+child_log.ensure_node_run_time();
+const std::optional _node_name =
+child_log.tree_loggers_[0]->group_node_name;
+if (group_node_name.has_value()) {
+  this->nodes.lookup_or_add_default(*group_node_name).run_time += 
child_log.run_time_sum;
 }
+this->run_time_sum += child_log.run_time_sum;
   }
   reduced_node_run_times_ = true;
 }
@@ -322,14 +326,14 @@ void GeoTreeLog::ensure_used_named_attributes()
  tree_logger->used_named_attributes_) {
   add_attribute(std::get<0>(item), std::get<1>(item), std::get<2>(item));
 }
-for (const ComputeContextHash _hash : tree_logger->children_hashes) {
-  GeoTreeLog _log = modifier_log_->get_tree_log(child_hash);
-  child_log.ensure_used_named_attributes();
-  if (const std::optional _node_name =
-  child_log.tree_loggers_[0]->group_node_name) {
-for (const auto  : child_log.used_named_attributes.items()) {
-  add_attribute(*group_node_name, item.key, item.value);
-}
+  }
+  for (const ComputeContextHash _hash : children_hashes_) {
+GeoTreeLog _log = modifier_log_->get_tree_log(child_hash);
+child_log.ensure_used_named_attributes();
+if (const std::optional _node_name =
+

[Bf-blender-cvs] [a0e1d123fc9] temp-geometry-nodes-evaluator-refactor: comments

2022-09-08 Thread Jacques Lucke
Commit: a0e1d123fc92851ef95c481cc4e4fdc9ac7060cf
Author: Jacques Lucke
Date:   Thu Sep 8 15:34:17 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rBa0e1d123fc92851ef95c481cc4e4fdc9ac7060cf

comments

===

M   source/blender/functions/FN_lazy_function.hh
M   source/blender/functions/intern/lazy_function.cc

===

diff --git a/source/blender/functions/FN_lazy_function.hh 
b/source/blender/functions/FN_lazy_function.hh
index 8ec914e5dd5..5c62b48a209 100644
--- a/source/blender/functions/FN_lazy_function.hh
+++ b/source/blender/functions/FN_lazy_function.hh
@@ -4,6 +4,38 @@
 
 /** \file
  * \ingroup fn
+ *
+ * A `LazyFunction` encapsulates a computation which has inputs, outputs and 
potentially side
+ * effects. Most importantly, a `LazyFunction` supports lazyness in its inputs 
and outputs:
+ * - Only outputs that are actually used have to be computed.
+ * - Inputs can be requested lazily based on which outputs are used or what 
side effects the
+ *   function has.
+ *
+ * A lazy-function that uses lazyness may be executed more than once. The most 
common example is
+ * the geometry nodes switch node. Depending on a condition input, it decides 
which one of the
+ * other inputs is actually used. From the perspective of the switch node, its 
execution works as
+ * follows:
+ * 1. The switch node is first executed. It sees that the output is used. Now 
it requests the
+ *condition input from the caller and exits.
+ * 2. Once the caller is able to provide the condition input the switch node 
is executed again.
+ *This time it retrieves the condition and requests one of the other 
inputs. Then the node
+ *exits again, giving back control to the caller.
+ * 3. When the caller computed the second requested input the switch node 
executes a last time.
+ *This time it retrieves the new input and forwards it to the output.
+ *
+ * In some sense, a lazy-function can be thought of like a state machine. 
Every time it is
+ * executed, it advances its state until all required outputs are ready.
+ *
+ * The lazy-function interface is designed to support composition of many such 
functions into a new
+ * lazy-functions. All while keeping the lazyness working. For example, in 
geometry nodes a switch
+ * node in a node group should still be able to decide whether a node in the 
parent group will be
+ * executed or not. This is essential to avoid doing unnecessary work.
+ *
+ * The lazy-function system consists of multiple core components:
+ * - The interface of a lazy-function itself including its calling convention.
+ * - A graph data structure that allows composing many lazy-functions by 
connecting their inputs
+ *   and outputs.
+ * - An executor that allows multi-threaded execution or such a graph.
  */
 
 #include "BLI_cpp_type.hh"
@@ -14,32 +46,68 @@
 namespace blender::fn::lazy_function {
 
 enum class ValueUsage {
+  /**
+   * The value is definitely used and therefore has to be computed.
+   */
   Used,
+  /**
+   * It's unknown whether this value will be used or not. Computing it is ok 
but the result may be
+   * discarded.
+   */
   Maybe,
+  /**
+   * The value will definitely not be used. It can still be computed but the 
result will be
+   * discarded in all cases.
+   */
   Unused,
 };
 
 class LazyFunction;
 
+/**
+ * This allows passing arbitrary data into a lazy-function during execution. 
For that, #UserData
+ * has to be subclassed. This mainly exists because it's more type safe than 
passing a `void *`
+ * with no type information attached.
+ *
+ * Some lazy-functions may expect to find a certain type of user data when 
executed.
+ */
 class UserData {
  public:
   virtual ~UserData() = default;
 };
 
+/**
+ * Passed to the lazy-function when it is executed.
+ */
 struct Context {
+  /**
+   * If the lazy-function has some state (which only makes sense when it is 
executed more than once
+   * to finish its job), the state is stored here. This points to memory 
returned from
+   * #LazyFunction::init_storage.
+   */
   void *storage;
+  /**
+   * Custom user data that can be used in the function.
+   */
   UserData *user_data;
 };
 
+/**
+ * Defines the calling convention for a lazy-function. During execution, a 
lazy-function retrieves
+ * its inputs and sets the outputs through #Params.
+ */
 class Params {
  public:
+  /**
+   * The lazy-function this #Params has been prepared for.
+   */
   const LazyFunction _;
 
  public:
   Params(const LazyFunction );
 
   /**
-   * Get a pointer to an input value if the value is available already.
+   * Get a pointer to an input value if the value is available already. 
Otherwise null is returned.
*
* The #LazyFunction must leave returned object in an initialized state, but 
can move from it.
*/
@@ -52,7 +120,7 @@ class Params {
   void 

[Bf-blender-cvs] [04c91471e0e] temp-geometry-nodes-evaluator-refactor: cleanup

2022-09-08 Thread Jacques Lucke
Commit: 04c91471e0ee46b3d384fe02f0a58caa85b5b276
Author: Jacques Lucke
Date:   Thu Sep 8 12:23:00 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB04c91471e0ee46b3d384fe02f0a58caa85b5b276

cleanup

===

M   source/blender/editors/space_node/node_draw.cc
M   source/blender/editors/space_node/node_intern.hh

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 89a6dbab041..d0a84c1ccb9 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1906,17 +1906,6 @@ static Vector 
node_get_extra_info(TreeDrawContext _draw_c
   rows.append(std::move(row));
 }
   }
-  // const geo_log::NodeLog *node_log =
-  // geo_log::ModifierLog::find_node_by_node_editor_context(snode,
-  //   
node);
-  // if (node_log != nullptr) {
-  //   for (const std::string  : node_log->debug_messages()) {
-  // NodeExtraInfoRow row;
-  // row.text = message;
-  // row.icon = ICON_INFO;
-  // rows.append(std::move(row));
-  //   }
-  // }
 
   return rows;
 }
diff --git a/source/blender/editors/space_node/node_intern.hh 
b/source/blender/editors/space_node/node_intern.hh
index b9435a00843..456cbf5064d 100644
--- a/source/blender/editors/space_node/node_intern.hh
+++ b/source/blender/editors/space_node/node_intern.hh
@@ -31,11 +31,6 @@ struct wmGizmoGroupType;
 struct wmKeyConfig;
 struct wmWindow;
 
-namespace blender::nodes::geo_eval_log {
-class ValueLog;
-class GeoTreeLog;
-}  // namespace blender::nodes::geo_eval_log
-
 /* Outside of blender namespace to avoid Python documentation build error with 
`ctypes`. */
 extern "C" {
 extern const char *node_context_dir[];

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e356fe95fdd] temp-geometry-nodes-evaluator-refactor: cleanup

2022-09-08 Thread Jacques Lucke
Commit: e356fe95fdde01bfb0f3e20a17773d8e42276420
Author: Jacques Lucke
Date:   Thu Sep 8 12:17:05 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rBe356fe95fdde01bfb0f3e20a17773d8e42276420

cleanup

===

M   
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
M   source/blender/nodes/NOD_geometry_nodes_log.hh
M   source/blender/nodes/intern/geometry_nodes_log.cc

===

diff --git 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index 49483b3f25a..1c2d288630b 100644
--- 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -412,66 +412,6 @@ int VolumeDataSource::tot_rows() const
   return BKE_volume_num_grids(volume);
 }
 
-static const ViewerNodeLog *try_find_viewer_node_log(const SpaceSpreadsheet 
)
-{
-  Vector context_path = sspreadsheet.context_path;
-  if (context_path.size() < 3) {
-return nullptr;
-  }
-  if (context_path[0]->type != SPREADSHEET_CONTEXT_OBJECT) {
-return nullptr;
-  }
-  if (context_path[1]->type != SPREADSHEET_CONTEXT_MODIFIER) {
-return nullptr;
-  }
-  const SpreadsheetContextObject *object_context =
-  reinterpret_cast(context_path[0]);
-  const SpreadsheetContextModifier *modifier_context =
-  reinterpret_cast(context_path[1]);
-  if (object_context->object == nullptr) {
-return nullptr;
-  }
-  NodesModifierData *nmd = nullptr;
-  LISTBASE_FOREACH (ModifierData *, md, _context->object->modifiers) {
-if (STREQ(md->name, modifier_context->modifier_name)) {
-  if (md->type == eModifierType_Nodes) {
-nmd = reinterpret_cast(md);
-  }
-}
-  }
-  if (nmd == nullptr) {
-return nullptr;
-  }
-  if (nmd->runtime_eval_log == nullptr) {
-return nullptr;
-  }
-  nodes::geo_eval_log::GeoModifierLog *modifier_log =
-  static_cast(nmd->runtime_eval_log);
-
-  ComputeContextBuilder compute_context_builder;
-  
compute_context_builder.push(modifier_context->modifier_name);
-  for (const SpreadsheetContext *context : 
context_path.as_span().drop_front(2).drop_back(1)) {
-if (context->type != SPREADSHEET_CONTEXT_NODE) {
-  return nullptr;
-}
-const SpreadsheetContextNode _context = *reinterpret_cast(
-context);
-
compute_context_builder.push(node_context.node_name);
-  }
-  const ComputeContextHash context_hash = compute_context_builder.hash();
-  nodes::geo_eval_log::GeoTreeLog _log = 
modifier_log->get_tree_log(context_hash);
-  tree_log.ensure_viewer_node_logs();
-
-  const SpreadsheetContext *last_context = context_path.last();
-  if (last_context->type != SPREADSHEET_CONTEXT_NODE) {
-return nullptr;
-  }
-  const SpreadsheetContextNode _node_context =
-  *reinterpret_cast(last_context);
-  const ViewerNodeLog *viewer_log = 
tree_log.viewer_node_logs.lookup(last_node_context.node_name);
-  return viewer_log;
-}
-
 GeometrySet spreadsheet_get_display_geometry_set(const SpaceSpreadsheet 
*sspreadsheet,
  Object *object_eval)
 {
@@ -485,8 +425,8 @@ GeometrySet spreadsheet_get_display_geometry_set(const 
SpaceSpreadsheet *sspread
 BMEditMesh *em = mesh->edit_mesh;
 if (em != nullptr) {
   Mesh *new_mesh = (Mesh *)BKE_id_new_nomain(ID_ME, nullptr);
-  /* This is a potentially heavy operation to do on every redraw. The 
best solution here is
-   * to display the data directly from the bmesh without a conversion, 
which can be
+  /* This is a potentially heavy operation to do on every redraw. The 
best solution here
+   * is to display the data directly from the bmesh without a 
conversion, which can be
* implemented a bit later. */
   BM_mesh_bm_to_me_for_eval(em->bm, new_mesh, nullptr);
   mesh_component.replace(new_mesh, GeometryOwnershipType::Owned);
@@ -527,7 +467,9 @@ GeometrySet spreadsheet_get_display_geometry_set(const 
SpaceSpreadsheet *sspread
 }
   }
   else {
-if (const ViewerNodeLog *viewer_log = 
try_find_viewer_node_log(*sspreadsheet)) {
+if (const ViewerNodeLog *viewer_log =
+
nodes::geo_eval_log::GeoModifierLog::find_viewer_node_log_for_spreadsheet(
+*sspreadsheet)) {
   geometry_set = viewer_log->geometry;
 }
   }
@@ -546,7 +488,9 @@ static void find_fields_to_evaluate(const SpaceSpreadsheet 
*sspreadsheet,
 /* No viewer is currently referenced by the context path. */
 return;
   }
-  if (const ViewerNodeLog *viewer_log = 
try_find_viewer_node_log(*sspreadsheet)) {
+  if (const ViewerNodeLog *viewer_log =
+  

[Bf-blender-cvs] [3f9f9f03483] temp-geometry-nodes-evaluator-refactor: cleanup

2022-09-08 Thread Jacques Lucke
Commit: 3f9f9f03483ea244eeb277c3adde0b71053b3865
Author: Jacques Lucke
Date:   Thu Sep 8 12:39:06 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB3f9f9f03483ea244eeb277c3adde0b71053b3865

cleanup

===

M   
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index 1c2d288630b..a7645a2bc67 100644
--- 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -425,8 +425,8 @@ GeometrySet spreadsheet_get_display_geometry_set(const 
SpaceSpreadsheet *sspread
 BMEditMesh *em = mesh->edit_mesh;
 if (em != nullptr) {
   Mesh *new_mesh = (Mesh *)BKE_id_new_nomain(ID_ME, nullptr);
-  /* This is a potentially heavy operation to do on every redraw. The 
best solution here
-   * is to display the data directly from the bmesh without a 
conversion, which can be
+  /* This is a potentially heavy operation to do on every redraw. The 
best solution here is
+   * to display the data directly from the bmesh without a conversion, 
which can be
* implemented a bit later. */
   BM_mesh_bm_to_me_for_eval(em->bm, new_mesh, nullptr);
   mesh_component.replace(new_mesh, GeometryOwnershipType::Owned);
@@ -523,8 +523,8 @@ class GeometryComponentCacheKey : public 
SpreadsheetCache::Key {
 
 class GeometryComponentCacheValue : public SpreadsheetCache::Value {
  public:
-  /* Stores the result of fields evaluated on a geometry component. Without 
this, fields would
-   * have to be reevaluated on every redraw. */
+  /* Stores the result of fields evaluated on a geometry component. Without 
this, fields would have
+   * to be reevaluated on every redraw. */
   Map, GArray<>> arrays;
 };
 
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index c979ce381c9..8396aff1156 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -923,6 +923,8 @@ static void find_side_effect_nodes_for_spreadsheet(
 return;
   }
 
+  /* Not only mark the viewer node as having side effects, but also all group 
nodes it is contained
+   * in. */
   r_side_effect_nodes.add(compute_context_builder.hash(),
   _viewer_lf_node(*found_viewer_node));
   compute_context_builder.pop();
@@ -1125,8 +1127,6 @@ static GeometrySet compute_geometry(const bNodeTree 
,
 
   const blender::nodes::GeometryNodesLazyFunctionGraphInfo _graph_info =
   blender::nodes::ensure_geometry_nodes_lazy_function_graph(btree);
-  // std::cout << graph.to_dot() << "\n";
-
   const blender::nodes::GeometryNodeLazyFunctionMapping  = 
lf_graph_info.mapping;
 
   Vector graph_inputs;
@@ -1168,7 +1168,6 @@ static GeometrySet compute_geometry(const bNodeTree 
,
   user_data.compute_context = _compute_context;
 
   blender::LinearAllocator<> allocator;
-
   Vector inputs_to_destruct;
 
   int input_index;
@@ -1196,15 +1195,13 @@ static GeometrySet compute_geometry(const bNodeTree 
,
   lf::Context lf_context;
   lf_context.storage = graph_executor.init_storage(allocator);
   lf_context.user_data = _data;
-
-  lf::BasicParams params{graph_executor,
- param_inputs,
- param_outputs,
- param_input_usages,
- param_output_usages,
- param_set_outputs};
-  graph_executor.execute(params, lf_context);
-
+  lf::BasicParams lf_params{graph_executor,
+param_inputs,
+param_outputs,
+param_input_usages,
+param_output_usages,
+param_set_outputs};
+  graph_executor.execute(lf_params, lf_context);
   graph_executor.destruct_storage(lf_context.storage);
 
   for (GMutablePointer  : inputs_to_destruct) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4ce0711e677] temp-geometry-nodes-evaluator-refactor: comments

2022-09-08 Thread Jacques Lucke
Commit: 4ce0711e6775dd96244c3bfbfe671378ac406023
Author: Jacques Lucke
Date:   Thu Sep 8 15:43:16 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB4ce0711e6775dd96244c3bfbfe671378ac406023

comments

===

M   source/blender/functions/FN_lazy_function_execute.hh

===

diff --git a/source/blender/functions/FN_lazy_function_execute.hh 
b/source/blender/functions/FN_lazy_function_execute.hh
index d6a7ddcbd2a..3b781d2ea75 100644
--- a/source/blender/functions/FN_lazy_function_execute.hh
+++ b/source/blender/functions/FN_lazy_function_execute.hh
@@ -4,6 +4,8 @@
 
 /** \file
  * \ingroup fn
+ *
+ * This file common utilities for actually executing a lazy-function.
  */
 
 #include "BLI_parameter_pack_utils.hh"
@@ -12,6 +14,10 @@
 
 namespace blender::fn::lazy_function {
 
+/**
+ * Most basic implementation of #Params. It does not actually implement any 
logic for how to
+ * retrieve inputs or set outputs. Instead, code using #BasicParams has to 
implement that.
+ */
 class BasicParams : public Params {
  private:
   const Span inputs_;
@@ -39,6 +45,9 @@ class BasicParams : public Params {
 
 namespace detail {
 
+/**
+ * Utility to implement #execute_lazy_function_eagerly.
+ */
 template
 inline void execute_lazy_function_eagerly_impl(
 const LazyFunction ,
@@ -85,6 +94,15 @@ inline void execute_lazy_function_eagerly_impl(
 
 }  // namespace detail
 
+/**
+ * In some cases (mainly for tests), the set of inputs and outputs for a 
lazy-function is known at
+ * compile time and one just wants to compute the outputs based on the inputs, 
without any
+ * lazyness.
+ *
+ * This function does exactly that. It takes all inputs in a tuple and writes 
the outputs to points
+ * provided in a second tuple. Since all inputs have to be provided, the 
lazy-function has to
+ * compute all outputs.
+ */
 template
 inline void execute_lazy_function_eagerly(const LazyFunction ,
   UserData *user_data,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6c0ec45dafc] temp-geometry-nodes-evaluator-refactor: cleanup

2022-09-08 Thread Jacques Lucke
Commit: 6c0ec45dafce76f56748c87dda72d54abcafd6ee
Author: Jacques Lucke
Date:   Thu Sep 8 13:19:57 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB6c0ec45dafce76f56748c87dda72d54abcafd6ee

cleanup

===

M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index 6a51b566a37..6570377aa9f 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1177,7 +1177,7 @@ static GeometrySet compute_geometry(
 }
 
 const CPPType *type = interface_socket->typeinfo->geometry_nodes_cpp_type;
-BLI_assert(type != nullptr); /* Todo */
+BLI_assert(type != nullptr);
 void *value = allocator.allocate(type->size(), type->alignment());
 initialize_group_input(*nmd, *interface_socket, input_index, value);
 param_inputs[input_index] = {type, value};

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a8a71d6b630] temp-geometry-nodes-evaluator-refactor: bring back used named attributes overlay

2022-09-08 Thread Jacques Lucke
Commit: a8a71d6b63008d8206b420fbf25bbba3cd07f1c2
Author: Jacques Lucke
Date:   Thu Sep 8 11:39:36 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rBa8a71d6b63008d8206b420fbf25bbba3cd07f1c2

bring back used named attributes overlay

===

M   source/blender/editors/space_node/node_draw.cc
M   source/blender/nodes/NOD_geometry_nodes_log.hh
M   source/blender/nodes/intern/geometry_nodes_log.cc
M   source/blender/nodes/intern/node_geometry_exec.cc

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 12d023d83db..9acce34430b 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1845,35 +1845,11 @@ static NodeExtraInfoRow row_from_used_named_attribute(
   return row;
 }
 
-static std::optional node_get_accessed_attributes_row(const 
SpaceNode ,
-const 
bNode )
+static std::optional node_get_accessed_attributes_row(
+TreeDrawContext _draw_ctx, const bNode )
 {
-  UNUSED_VARS(snode);
-  if (node.type == NODE_GROUP) {
-// const geo_log::TreeLog *root_tree_log =
-// geo_log::ModifierLog::find_tree_by_node_editor_context(
-// snode);
-// if (root_tree_log == nullptr) {
-//   return std::nullopt;
-// }
-// const geo_log::TreeLog *tree_log = 
root_tree_log->lookup_child_log(node.name);
-// if (tree_log == nullptr) {
-//   return std::nullopt;
-// }
-
-Map usage_by_attribute;
-// tree_log->foreach_node_log([&](const geo_log::NodeLog _log) {
-//   for (const geo_log::UsedNamedAttribute _attribute : 
node_log.used_named_attributes())
-//   {
-// usage_by_attribute.lookup_or_add_as(used_attribute.name,
-// used_attribute.usage) |= 
used_attribute.usage;
-//   }
-// });
-if (usage_by_attribute.is_empty()) {
-  return std::nullopt;
-}
-
-return row_from_used_named_attribute(usage_by_attribute);
+  if (tree_draw_ctx.geo_tree_log == nullptr) {
+return std::nullopt;
   }
   if (ELEM(node.type,
GEO_NODE_STORE_NAMED_ATTRIBUTE,
@@ -1882,29 +1858,21 @@ static std::optional 
node_get_accessed_attributes_row(const Sp
 /* Only show the overlay when the name is passed in from somewhere else. */
 LISTBASE_FOREACH (bNodeSocket *, socket, ) {
   if (STREQ(socket->name, "Name")) {
-if ((socket->flag & SOCK_IN_USE) == 0) {
+if (!socket->is_directly_linked()) {
   return std::nullopt;
 }
   }
 }
-// const geo_log::NodeLog *node_log = 
geo_log::ModifierLog::find_node_by_node_editor_context(
-// snode, node.name);
-// if (node_log == nullptr) {
-//   return std::nullopt;
-// }
-Map usage_by_attribute;
-// for (const geo_log::UsedNamedAttribute _attribute : 
node_log->used_named_attributes())
-// {
-//   usage_by_attribute.lookup_or_add_as(used_attribute.name,
-//   used_attribute.usage) |= 
used_attribute.usage;
-// }
-// if (usage_by_attribute.is_empty()) {
-//   return std::nullopt;
-// }
-return row_from_used_named_attribute(usage_by_attribute);
   }
-
-  return std::nullopt;
+  tree_draw_ctx.geo_tree_log->ensure_used_named_attributes();
+  GeoNodeLog *node_log = 
tree_draw_ctx.geo_tree_log->nodes.lookup_ptr(node.name);
+  if (node_log == nullptr) {
+return std::nullopt;
+  }
+  if (node_log->used_named_attributes.is_empty()) {
+return std::nullopt;
+  }
+  return row_from_used_named_attribute(node_log->used_named_attributes);
 }
 
 static Vector node_get_extra_info(TreeDrawContext 
_draw_ctx,
@@ -1918,7 +1886,8 @@ static Vector 
node_get_extra_info(TreeDrawContext _draw_c
 
   if (snode.overlay.flag & SN_OVERLAY_SHOW_NAMED_ATTRIBUTES &&
   snode.edittree->type == NTREE_GEOMETRY) {
-if (std::optional row = 
node_get_accessed_attributes_row(snode, node)) {
+if (std::optional row = 
node_get_accessed_attributes_row(tree_draw_ctx,
+   
node)) {
   rows.append(std::move(*row));
 }
   }
diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh 
b/source/blender/nodes/NOD_geometry_nodes_log.hh
index b8fb55abffb..199fb1991b6 100644
--- a/source/blender/nodes/NOD_geometry_nodes_log.hh
+++ b/source/blender/nodes/NOD_geometry_nodes_log.hh
@@ -129,7 +129,10 @@ class GeoTreeLogger {
   Vector> 
output_socket_values;
   Vector> node_execution_times;
   Vector>, 0> 
viewer_node_logs_;
+  Vector, 0> 
used_named_attributes_;
 
+  GeoTreeLogger();
+  ~GeoTreeLogger();
   void log_value(const bNode , const bNodeSocket , GPointer value);
   void log_viewer_node(const 

[Bf-blender-cvs] [91a57c9cc29] temp-geometry-nodes-evaluator-refactor: cleanup

2022-09-08 Thread Jacques Lucke
Commit: 91a57c9cc29333196b8b4c47605d864265ec7739
Author: Jacques Lucke
Date:   Thu Sep 8 13:18:30 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB91a57c9cc29333196b8b4c47605d864265ec7739

cleanup

===

M   source/blender/functions/FN_lazy_function.hh
M   source/blender/functions/intern/lazy_function.cc
M   source/blender/functions/tests/FN_lazy_function_test.cc
M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/NOD_geometry_nodes_to_lazy_function_graph.hh
M   source/blender/nodes/intern/geometry_nodes_to_lazy_function_graph.cc

===

diff --git a/source/blender/functions/FN_lazy_function.hh 
b/source/blender/functions/FN_lazy_function.hh
index 3a332df34ce..8ec914e5dd5 100644
--- a/source/blender/functions/FN_lazy_function.hh
+++ b/source/blender/functions/FN_lazy_function.hh
@@ -116,7 +116,7 @@ struct Output {
 
 class LazyFunction {
  protected:
-  const char *static_name_ = "Unnamed Function";
+  const char *debug_name_ = "Unnamed Function";
   Vector inputs_;
   Vector outputs_;
 
diff --git a/source/blender/functions/intern/lazy_function.cc 
b/source/blender/functions/intern/lazy_function.cc
index 7de733d5a35..6d0dab40a3c 100644
--- a/source/blender/functions/intern/lazy_function.cc
+++ b/source/blender/functions/intern/lazy_function.cc
@@ -12,7 +12,7 @@ namespace blender::fn::lazy_function {
 
 std::string LazyFunction::name() const
 {
-  return static_name_;
+  return debug_name_;
 }
 
 std::string LazyFunction::input_name(int index) const
diff --git a/source/blender/functions/tests/FN_lazy_function_test.cc 
b/source/blender/functions/tests/FN_lazy_function_test.cc
index c8e0809b334..fcea334fcba 100644
--- a/source/blender/functions/tests/FN_lazy_function_test.cc
+++ b/source/blender/functions/tests/FN_lazy_function_test.cc
@@ -15,7 +15,7 @@ class AddLazyFunction : public LazyFunction {
  public:
   AddLazyFunction()
   {
-static_name_ = "Add";
+debug_name_ = "Add";
 inputs_.append({"A", CPPType::get()});
 inputs_.append({"B", CPPType::get()});
 outputs_.append({"Result", CPPType::get()});
@@ -37,7 +37,7 @@ class StoreValueFunction : public LazyFunction {
  public:
   StoreValueFunction(int *dst1, int *dst2) : dst1_(dst1), dst2_(dst2)
   {
-static_name_ = "Store Value";
+debug_name_ = "Store Value";
 inputs_.append({"A", CPPType::get()});
 inputs_.append({"B", CPPType::get(), ValueUsage::Maybe});
   }
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index 8396aff1156..6a51b566a37 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -845,12 +845,12 @@ static Vector 
find_spreadsheet_editors(Main *bmain)
 static const lf::FunctionNode _viewer_lf_node(const bNode _bnode)
 {
   return 
*blender::nodes::ensure_geometry_nodes_lazy_function_graph(viewer_bnode.owner_tree())
-  .mapping.viewer_node_map.lookup(_bnode);
+  ->mapping.viewer_node_map.lookup(_bnode);
 }
 static const lf::FunctionNode _group_lf_node(const bNode _bnode)
 {
   return 
*blender::nodes::ensure_geometry_nodes_lazy_function_graph(group_bnode.owner_tree())
-  .mapping.group_node_map.lookup(_bnode);
+  ->mapping.group_node_map.lookup(_bnode);
 }
 
 static void find_side_effect_nodes_for_spreadsheet(
@@ -1118,15 +1118,14 @@ static void store_output_attributes(GeometrySet 
,
 /**
  * Evaluate a node group to compute the output geometry.
  */
-static GeometrySet compute_geometry(const bNodeTree ,
-const bNode _node,
-GeometrySet input_geometry_set,
-NodesModifierData *nmd,
-const ModifierEvalContext *ctx)
+static GeometrySet compute_geometry(
+const bNodeTree ,
+const blender::nodes::GeometryNodesLazyFunctionGraphInfo _graph_info,
+const bNode _node,
+GeometrySet input_geometry_set,
+NodesModifierData *nmd,
+const ModifierEvalContext *ctx)
 {
-
-  const blender::nodes::GeometryNodesLazyFunctionGraphInfo _graph_info =
-  blender::nodes::ensure_geometry_nodes_lazy_function_graph(btree);
   const blender::nodes::GeometryNodeLazyFunctionMapping  = 
lf_graph_info.mapping;
 
   Vector graph_inputs;
@@ -1284,13 +1283,6 @@ static void modifyGeometry(ModifierData *md,
   tree.ensure_topology_cache();
   check_property_socket_sync(ctx->object, md);
 
-  /* Todo: Check for link cycles recursively. */
-  if (tree.has_link_cycle()) {
-BKE_modifier_set_error(ctx->object, md, "Node group has cycles");
-geometry_set.clear();
-return;
-  }
-
   const bNode *output_node = tree.group_output_node();
   if (output_node == nullptr) {
 

[Bf-blender-cvs] [6e09d256579] temp-geometry-nodes-evaluator-refactor: bring back attribute search in node editor

2022-09-08 Thread Jacques Lucke
Commit: 6e09d2565791924275cf48b1155e8318fbd9fe43
Author: Jacques Lucke
Date:   Thu Sep 8 12:12:23 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB6e09d2565791924275cf48b1155e8318fbd9fe43

bring back attribute search in node editor

===

M   source/blender/editors/space_node/node_draw.cc
M   source/blender/editors/space_node/node_geometry_attribute_search.cc
M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 9acce34430b..89a6dbab041 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1028,6 +1028,7 @@ static std::optional 
create_socket_inspection_string(TreeDrawContex
   const 
bNodeSocket )
 {
   using namespace blender::nodes::geo_eval_log;
+  tree_draw_ctx.geo_tree_log->ensure_socket_values();
   ValueLog *value_log = 
tree_draw_ctx.geo_tree_log->find_socket_value_log(socket);
   if (value_log == nullptr) {
 return std::nullopt;
diff --git 
a/source/blender/editors/space_node/node_geometry_attribute_search.cc 
b/source/blender/editors/space_node/node_geometry_attribute_search.cc
index c9dbc1649c4..809c4b2fe59 100644
--- a/source/blender/editors/space_node/node_geometry_attribute_search.cc
+++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc
@@ -71,6 +71,7 @@ static Vector 
get_attribute_info_from_context(
   if (tree_log == nullptr) {
 return {};
   }
+  tree_log->ensure_socket_values();
 
   /* For the attribute input node, collect attribute information from all 
nodes in the group. */
   if (node->type == GEO_NODE_INPUT_NAMED_ATTRIBUTE) {
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index e84f1e29687..c979ce381c9 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -125,11 +125,13 @@ using blender::nodes::geo_eval_log::GeoModifierLog;
 using blender::threading::EnumerableThreadSpecific;
 using namespace blender::fn::multi_function_types;
 using blender::nodes::geo_eval_log::GeometryAttributeInfo;
+using blender::nodes::geo_eval_log::GeometryInfoLog;
 using blender::nodes::geo_eval_log::GeoNodeLog;
 using blender::nodes::geo_eval_log::GeoTreeLog;
 using blender::nodes::geo_eval_log::NamedAttributeUsage;
 using blender::nodes::geo_eval_log::NodeWarning;
 using blender::nodes::geo_eval_log::NodeWarningType;
+using blender::nodes::geo_eval_log::ValueLog;
 
 static void initData(ModifierData *md)
 {
@@ -1395,6 +1397,16 @@ static NodesModifierData *get_modifier_data(Main ,
   return reinterpret_cast(md);
 }
 
+static GeoTreeLog *get_root_tree_log(const NodesModifierData )
+{
+  if (nmd.runtime_eval_log == nullptr) {
+return nullptr;
+  }
+  GeoModifierLog _log = *static_cast(nmd.runtime_eval_log);
+  blender::bke::ModifierComputeContext compute_context{nullptr, 
nmd.modifier.name};
+  return _log.get_tree_log(compute_context.hash());
+}
+
 static void attribute_search_update_fn(
 const bContext *C, void *arg, const char *str, uiSearchItems *items, const 
bool is_first)
 {
@@ -1403,27 +1415,52 @@ static void attribute_search_update_fn(
   if (nmd == nullptr) {
 return;
   }
-  // const geo_log::ModifierLog *modifier_log = static_cast(
-  // nmd->runtime_eval_log);
-  // if (modifier_log == nullptr) {
-  //   return;
-  // }
-  // const geo_log::GeometryInfoLog *geometry_log = data.is_output ?
-  // 
modifier_log->output_geometry_log() :
-  // 
modifier_log->input_geometry_log();
-  // if (geometry_log == nullptr) {
-  //   return;
-  // }
-
-  Span infos;
-
-  /* The shared attribute search code expects a span of pointers, so convert 
to that. */
-  Array info_ptrs(infos.size());
-  for (const int i : infos.index_range()) {
-info_ptrs[i] = [i];
+  if (nmd->node_group == nullptr) {
+return;
+  }
+  GeoTreeLog *tree_log = get_root_tree_log(*nmd);
+  if (tree_log == nullptr) {
+return;
+  }
+  tree_log->ensure_existing_attributes();
+  nmd->node_group->ensure_topology_cache();
+
+  Vector sockets_to_check;
+  if (data.is_output) {
+for (const bNode *node : 
nmd->node_group->nodes_by_type("NodeGroupOutput")) {
+  for (const bNodeSocket *socket : node->input_sockets()) {
+if (socket->type == SOCK_GEOMETRY) {
+  sockets_to_check.append(socket);
+}
+  }
+}
+  }
+  else {
+for (const bNode *node : nmd->node_group->nodes_by_type("NodeGroupInput")) 
{
+  for (const bNodeSocket *socket : node->output_sockets()) {
+if (socket->type == SOCK_GEOMETRY) {
+  

[Bf-blender-cvs] [90edc4472e3] temp-geometry-nodes-evaluator-refactor: Merge branch 'master' into temp-geometry-nodes-evaluator-refactor

2022-09-08 Thread Jacques Lucke
Commit: 90edc4472e3300f44beaac299b0193eb39a9
Author: Jacques Lucke
Date:   Thu Sep 8 12:55:44 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB90edc4472e3300f44beaac299b0193eb39a9

Merge branch 'master' into temp-geometry-nodes-evaluator-refactor

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [69ab1bd73ca] temp-geometry-nodes-evaluator-refactor: cleanup

2022-09-08 Thread Jacques Lucke
Commit: 69ab1bd73ca7957cf7bb42fd534c3c65e7dab02a
Author: Jacques Lucke
Date:   Thu Sep 8 11:01:37 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB69ab1bd73ca7957cf7bb42fd534c3c65e7dab02a

cleanup

===

M   source/blender/editors/space_node/node_draw.cc

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 9d5ce17a9be..f5a39bfd631 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -180,6 +180,12 @@ void ED_node_tag_update_id(ID *id)
 
 namespace blender::ed::space_node {
 
+static void node_socket_add_tooltip_in_node_editor(TreeDrawContext 
*UNUSED(tree_draw_ctx),
+   const bNodeTree *ntree,
+   const bNode *node,
+   const bNodeSocket *sock,
+   uiLayout *layout);
+
 static bool compare_nodes(const bNode *a, const bNode *b)
 {
   /* These tell if either the node or any of the parent nodes is selected.
@@ -333,390 +339,182 @@ float2 node_from_view(const bNode , const float2 
)
   return result;
 }
 
-struct SocketTooltipData {
-  const bNodeTree *ntree;
-  const bNode *node;
-  const bNodeSocket *socket;
-};
-
-static bool node_socket_has_tooltip(const bNodeTree *ntree, const bNodeSocket 
*socket)
+/**
+ * Based on settings and sockets in node, set drawing rect info.
+ */
+static void node_update_basis(const bContext ,
+  TreeDrawContext _draw_ctx,
+  bNodeTree ,
+  bNode ,
+  uiBlock )
 {
-  if (ntree->type == NTREE_GEOMETRY) {
-return true;
-  }
+  PointerRNA nodeptr;
+  RNA_pointer_create(, _Node, , );
 
-  if (socket->runtime->declaration != nullptr) {
-const nodes::SocketDeclaration _decl = 
*socket->runtime->declaration;
-return !socket_decl.description().is_empty();
-  }
+  const bool node_options = node.typeinfo->draw_buttons && (node.flag & 
NODE_OPTIONS);
+  const bool inputs_first = node.inputs.first &&
+!(node.outputs.first || (node.flag & NODE_PREVIEW) 
|| node_options);
 
-  return false;
-}
+  /* Get "global" coordinates. */
+  float2 loc = node_to_view(node, float2(0));
+  /* Round the node origin because text contents are always pixel-aligned. */
+  loc.x = round(loc.x);
+  loc.y = round(loc.y);
 
-static void create_inspection_string_for_generic_value(const GPointer value, 
std::stringstream )
-{
-  auto id_to_inspection_string = [&](const ID *id, const short idcode) {
-ss << (id ? id->name + 2 : TIP_("None")) << " (" << 
TIP_(BKE_idtype_idcode_to_name(idcode))
-   << ")";
-  };
+  int dy = loc.y;
 
-  const CPPType  = *value.type();
-  const void *buffer = value.get();
-  if (type.is()) {
-id_to_inspection_string(*static_cast(buffer), ID_OB);
-  }
-  else if (type.is()) {
-id_to_inspection_string(*static_cast(buffer), ID_MA);
-  }
-  else if (type.is()) {
-id_to_inspection_string(*static_cast(buffer), ID_TE);
-  }
-  else if (type.is()) {
-id_to_inspection_string(*static_cast(buffer), ID_IM);
-  }
-  else if (type.is()) {
-id_to_inspection_string(*static_cast(buffer), ID_GR);
-  }
-  else if (type.is()) {
-ss << *(int *)buffer << TIP_(" (Integer)");
-  }
-  else if (type.is()) {
-ss << *(float *)buffer << TIP_(" (Float)");
-  }
-  else if (type.is()) {
-ss << *(blender::float3 *)buffer << TIP_(" (Vector)");
-  }
-  else if (type.is()) {
-ss << ((*(bool *)buffer) ? TIP_("True") : TIP_("False")) << TIP_(" 
(Boolean)");
-  }
-  else if (type.is()) {
-ss << *(std::string *)buffer << TIP_(" (String)");
+  /* Header. */
+  dy -= NODE_DY;
+
+  /* Add a little bit of padding above the top socket. */
+  if (node.outputs.first || inputs_first) {
+dy -= NODE_DYS / 2;
   }
-}
 
-static void create_inspection_string_for_field_info(const 
geo_log::FieldInfoLog _log,
-std::stringstream )
-{
-  const CPPType  = value_log.type;
-  const Span input_tooltips = value_log.input_tooltips;
+  /* Output sockets. */
+  bool add_output_space = false;
 
-  if (input_tooltips.is_empty()) {
-/* Should have been logged as constant value. */
-BLI_assert_unreachable();
-ss << "Value has not been logged";
-  }
-  else {
-if (type.is()) {
-  ss << TIP_("Integer field");
+  int buty;
+  LISTBASE_FOREACH (bNodeSocket *, socket, ) {
+if (nodeSocketIsHidden(socket)) {
+  continue;
 }
-else if (type.is()) {
-  ss << TIP_("Float field");
+
+PointerRNA sockptr;
+RNA_pointer_create(, _NodeSocket, socket, );
+
+uiLayout *layout = 

[Bf-blender-cvs] [e599bb1793d] temp-geometry-nodes-evaluator-refactor: cleanup

2022-09-08 Thread Jacques Lucke
Commit: e599bb1793dfd185091ef04f1c0afb48d9dad9c7
Author: Jacques Lucke
Date:   Thu Sep 8 10:54:44 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rBe599bb1793dfd185091ef04f1c0afb48d9dad9c7

cleanup

===

M   source/blender/editors/space_node/node_draw.cc
M   source/blender/editors/space_node/node_geometry_attribute_search.cc
M   source/blender/editors/space_node/node_intern.hh
M   source/blender/nodes/NOD_geometry_nodes_log.hh
M   source/blender/nodes/intern/geometry_nodes_log.cc

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 79935f6396b..9d5ce17a9be 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -353,78 +353,6 @@ static bool node_socket_has_tooltip(const bNodeTree 
*ntree, const bNodeSocket *s
   return false;
 }
 
-nodes::geo_eval_log::ValueLog *find_socket_value_log(GeoTreeLog _log,
- const bNodeSocket 
_socket)
-{
-  using namespace blender::nodes::geo_eval_log;
-  tree_log.ensure_socket_values();
-
-  if (query_socket.is_multi_input()) {
-return nullptr;
-  }
-
-  Set added_sockets;
-  Stack sockets_to_check;
-  sockets_to_check.push(_socket);
-  added_sockets.add(_socket);
-
-  while (!sockets_to_check.is_empty()) {
-const bNodeSocket  = *sockets_to_check.pop();
-const bNode  = socket.owner_node();
-if (GeoNodeLog *node_log = tree_log.nodes.lookup_ptr(node.name)) {
-  ValueLog *value_log = socket.is_input() ?
-
node_log->input_values_.lookup_default(socket.identifier,
-   
nullptr) :
-
node_log->output_values_.lookup_default(socket.identifier,
-
nullptr);
-  if (value_log != nullptr) {
-return value_log;
-  }
-}
-
-if (socket.is_input()) {
-  const Span links = socket.directly_linked_links();
-  for (const bNodeLink *link : links) {
-const bNodeSocket _socket = *link->fromsock;
-if (added_sockets.add(_socket)) {
-  sockets_to_check.push(_socket);
-}
-  }
-}
-else {
-  if (node.is_reroute()) {
-const bNodeSocket _socket = node.input_socket(0);
-if (added_sockets.add(_socket)) {
-  sockets_to_check.push(_socket);
-}
-const Span links = 
input_socket.directly_linked_links();
-for (const bNodeLink *link : links) {
-  const bNodeSocket _socket = *link->fromsock;
-  if (added_sockets.add(_socket)) {
-sockets_to_check.push(_socket);
-  }
-}
-  }
-  else if (node.is_muted()) {
-if (const bNodeSocket *input_socket = socket.internal_link_input()) {
-  if (added_sockets.add(input_socket)) {
-sockets_to_check.push(input_socket);
-  }
-  const Span links = 
input_socket->directly_linked_links();
-  for (const bNodeLink *link : links) {
-const bNodeSocket _socket = *link->fromsock;
-if (added_sockets.add(_socket)) {
-  sockets_to_check.push(_socket);
-}
-  }
-}
-  }
-}
-  }
-
-  return nullptr;
-}
-
 static void create_inspection_string_for_generic_value(const GPointer value, 
std::stringstream )
 {
   auto id_to_inspection_string = [&](const ID *id, const short idcode) {
@@ -638,7 +566,7 @@ static std::optional 
create_socket_inspection_string(TreeDrawContex
   const 
bNodeSocket )
 {
   using namespace blender::nodes::geo_eval_log;
-  ValueLog *value_log = find_socket_value_log(*tree_draw_ctx.geo_tree_log, 
socket);
+  ValueLog *value_log = 
tree_draw_ctx.geo_tree_log->find_socket_value_log(socket);
   if (value_log == nullptr) {
 return std::nullopt;
   }
diff --git 
a/source/blender/editors/space_node/node_geometry_attribute_search.cc 
b/source/blender/editors/space_node/node_geometry_attribute_search.cc
index d65647aead0..c9dbc1649c4 100644
--- a/source/blender/editors/space_node/node_geometry_attribute_search.cc
+++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc
@@ -93,7 +93,7 @@ static Vector 
get_attribute_info_from_context(
 if (input_socket->type != SOCK_GEOMETRY) {
   continue;
 }
-const ValueLog *value_log = find_socket_value_log(*tree_log, 
*input_socket);
+const ValueLog *value_log = tree_log->find_socket_value_log(*input_socket);
 if (value_log == nullptr) {
   continue;
 }
diff --git a/source/blender/editors/space_node/node_intern.hh 

[Bf-blender-cvs] [a77491a6aea] temp-geometry-nodes-evaluator-refactor: bring back used named attribute logging in modifier

2022-09-08 Thread Jacques Lucke
Commit: a77491a6aea6e1bf3d73548a0395d2ca7ff17f61
Author: Jacques Lucke
Date:   Thu Sep 8 11:41:56 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rBa77491a6aea6e1bf3d73548a0395d2ca7ff17f61

bring back used named attribute logging in modifier

===

M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index a3c517864c0..e84f1e29687 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1729,14 +1729,11 @@ static void internal_dependencies_panel_draw(const 
bContext *UNUSED(C), Panel *p
   if (nmd->runtime_eval_log == nullptr) {
 return;
   }
-  Map usage_by_attribute;
-  // const geo_log::ModifierLog  = *static_cast(nmd->runtime_eval_log);
-  // log.foreach_node_log([&](const geo_log::NodeLog _log) {
-  //   for (const geo_log::UsedNamedAttribute _attribute : 
node_log.used_named_attributes()) {
-  // usage_by_attribute.lookup_or_add_as(used_attribute.name,
-  // used_attribute.usage) |= 
used_attribute.usage;
-  //   }
-  // });
+  GeoModifierLog _log = *static_cast(nmd->runtime_eval_log);
+  blender::bke::ModifierComputeContext compute_context{nullptr, 
nmd->modifier.name};
+  GeoTreeLog _log = modifier_log.get_tree_log(compute_context.hash());
+  tree_log.ensure_used_named_attributes();
+  const Map _by_attribute = 
tree_log.used_named_attributes;
 
   if (usage_by_attribute.is_empty()) {
 uiItemL(layout, IFACE_("No named attributes used"), ICON_INFO);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bf97ce64184] temp-geometry-nodes-evaluator-refactor: cleanup

2022-09-08 Thread Jacques Lucke
Commit: bf97ce641848ac82eafdd2c06c5d4de897e30634
Author: Jacques Lucke
Date:   Thu Sep 8 11:06:13 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rBbf97ce641848ac82eafdd2c06c5d4de897e30634

cleanup

===

M   source/blender/editors/space_node/node_draw.cc

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index f5a39bfd631..12d023d83db 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -815,20 +815,6 @@ struct SocketTooltipData {
   const bNodeSocket *socket;
 };
 
-static bool node_socket_has_tooltip(const bNodeTree *ntree, const bNodeSocket 
*socket)
-{
-  if (ntree->type == NTREE_GEOMETRY) {
-return true;
-  }
-
-  if (socket->runtime->declaration != nullptr) {
-const nodes::SocketDeclaration _decl = 
*socket->runtime->declaration;
-return !socket_decl.description().is_empty();
-  }
-
-  return false;
-}
-
 static void create_inspection_string_for_generic_value(const GPointer value, 
std::stringstream )
 {
   auto id_to_inspection_string = [&](const ID *id, const short idcode) {
@@ -1070,6 +1056,20 @@ static std::optional 
create_socket_inspection_string(TreeDrawContex
   return str;
 }
 
+static bool node_socket_has_tooltip(const bNodeTree *ntree, const bNodeSocket 
*socket)
+{
+  if (ntree->type == NTREE_GEOMETRY) {
+return true;
+  }
+
+  if (socket->runtime->declaration != nullptr) {
+const nodes::SocketDeclaration _decl = 
*socket->runtime->declaration;
+return !socket_decl.description().is_empty();
+  }
+
+  return false;
+}
+
 static char *node_socket_get_tooltip(const bContext *C,
  const bNodeTree *ntree,
  const bNode *UNUSED(node),
@@ -1081,7 +1081,6 @@ static char *node_socket_get_tooltip(const bContext *C,
 if (ntree->type == NTREE_GEOMETRY) {
   tree_draw_ctx.geo_tree_log =
   
nodes::geo_eval_log::GeoModifierLog::get_tree_log_for_node_editor(*snode);
-  ;
 }
   }
 
@@ -1643,16 +1642,12 @@ static char *node_errors_tooltip_fn(bContext 
*UNUSED(C), void *argN, const char
 
 #define NODE_HEADER_ICON_SIZE (0.8f * U.widget_unit)
 
-static void node_add_error_message_button(const bContext ,
-  TreeDrawContext _draw_ctx,
+static void node_add_error_message_button(TreeDrawContext _draw_ctx,
   bNode ,
   uiBlock ,
   const rctf ,
   float _offset)
 {
-  SpaceNode *snode = CTX_wm_space_node();
-  UNUSED_VARS(snode, node);
-
   Span warnings;
   if (tree_draw_ctx.geo_tree_log) {
 GeoNodeLog *node_log = 
tree_draw_ctx.geo_tree_log->nodes.lookup_ptr(node.name);
@@ -2195,7 +2190,7 @@ static void node_draw_basis(const bContext ,
 UI_block_emboss_set(, UI_EMBOSS);
   }
 
-  node_add_error_message_button(C, tree_draw_ctx, node, block, rct, iconofs);
+  node_add_error_message_button(tree_draw_ctx, node, block, rct, iconofs);
 
   /* Title. */
   if (node.flag & SELECT) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2f1d60a481e] temp-geometry-nodes-evaluator-refactor: improve compute context docs

2022-09-08 Thread Jacques Lucke
Commit: 2f1d60a481e2099b5c92f4e23a9ab22f94ed07cf
Author: Jacques Lucke
Date:   Thu Sep 8 10:35:43 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB2f1d60a481e2099b5c92f4e23a9ab22f94ed07cf

improve compute context docs

===

R056source/blender/blenkernel/BKE_context_stack.hh  
source/blender/blenkernel/BKE_compute_contexts.hh
M   source/blender/blenkernel/CMakeLists.txt
A   source/blender/blenkernel/intern/compute_contexts.cc
D   source/blender/blenkernel/intern/context_stack.cc
A   source/blender/blenlib/BLI_compute_context.hh
D   source/blender/blenlib/BLI_context_stack.hh
M   source/blender/blenlib/CMakeLists.txt
R055source/blender/blenlib/intern/context_stack.cc  
source/blender/blenlib/intern/compute_context.cc
M   source/blender/editors/space_node/node_draw.cc
M   
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/NOD_geometry_exec.hh
M   source/blender/nodes/NOD_geometry_nodes_log.hh
M   source/blender/nodes/NOD_geometry_nodes_to_lazy_function_graph.hh
M   source/blender/nodes/intern/geometry_nodes_log.cc
M   source/blender/nodes/intern/geometry_nodes_to_lazy_function_graph.cc

===

diff --git a/source/blender/blenkernel/BKE_context_stack.hh 
b/source/blender/blenkernel/BKE_compute_contexts.hh
similarity index 56%
rename from source/blender/blenkernel/BKE_context_stack.hh
rename to source/blender/blenkernel/BKE_compute_contexts.hh
index 1415a5e21b7..bb01aee788e 100644
--- a/source/blender/blenkernel/BKE_context_stack.hh
+++ b/source/blender/blenkernel/BKE_compute_contexts.hh
@@ -2,34 +2,35 @@
 
 #pragma once
 
-#include "BLI_context_stack.hh"
+/**
+ * This file implements some specific compute contexts for concepts in Blender.
+ */
+
+#include "BLI_compute_context.hh"
 
 namespace blender::bke {
 
-class ModifierContextStack : public ContextStack {
+class ModifierComputeContext : public ComputeContext {
  private:
   static constexpr const char *s_static_type = "MODIFIER";
 
   std::string modifier_name_;
 
  public:
-  ModifierContextStack(const ContextStack *parent, std::string modifier_name);
+  ModifierComputeContext(const ComputeContext *parent, std::string 
modifier_name);
 
  private:
   void print_current_in_line(std::ostream ) const override;
 };
 
-class NodeGroupContextStack : public ContextStack {
+class NodeGroupComputeContext : public ComputeContext {
  private:
   static constexpr const char *s_static_type = "NODE_GROUP";
 
   std::string node_name_;
-  std::string debug_group_name_;
 
  public:
-  NodeGroupContextStack(const ContextStack *parent,
-std::string node_name,
-std::string debug_group_name = "");
+  NodeGroupComputeContext(const ComputeContext *parent, std::string node_name);
 
   StringRefNull node_name() const;
 
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 228902f5d02..f8fb609f1c3 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -98,9 +98,9 @@ set(SRC
   intern/collision.c
   intern/colorband.c
   intern/colortools.c
+  intern/compute_contexts.cc
   intern/constraint.c
   intern/context.c
-  intern/context_stack.cc
   intern/crazyspace.cc
   intern/cryptomatte.cc
   intern/curve.cc
@@ -353,9 +353,9 @@ set(SRC
   BKE_collision.h
   BKE_colorband.h
   BKE_colortools.h
+  BKE_compute_contexts.hh
   BKE_constraint.h
   BKE_context.h
-  BKE_context_stack.hh
   BKE_crazyspace.h
   BKE_crazyspace.hh
   BKE_cryptomatte.h
diff --git a/source/blender/blenkernel/intern/compute_contexts.cc 
b/source/blender/blenkernel/intern/compute_contexts.cc
new file mode 100644
index 000..026706d363e
--- /dev/null
+++ b/source/blender/blenkernel/intern/compute_contexts.cc
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "BKE_compute_contexts.hh"
+
+namespace blender::bke {
+
+ModifierComputeContext::ModifierComputeContext(const ComputeContext *parent,
+   std::string modifier_name)
+: ComputeContext(s_static_type, parent), 
modifier_name_(std::move(modifier_name))
+{
+  hash_.mix_in(s_static_type, strlen(s_static_type));
+  hash_.mix_in(modifier_name_.data(), modifier_name_.size());
+}
+
+void ModifierComputeContext::print_current_in_line(std::ostream ) const
+{
+  stream << "Modifier: " << modifier_name_;
+}
+
+NodeGroupComputeContext::NodeGroupComputeContext(const ComputeContext *parent,
+ std::string node_name)
+: ComputeContext(s_static_type, parent), node_name_(std::move(node_name))
+{
+  hash_.mix_in(s_static_type, strlen(s_static_type));
+  

[Bf-blender-cvs] [198f8c209f6] temp-geometry-nodes-evaluator-refactor: cleanup

2022-09-08 Thread Jacques Lucke
Commit: 198f8c209f6955709c83e2d099652e7c8e7add36
Author: Jacques Lucke
Date:   Thu Sep 8 10:43:58 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB198f8c209f6955709c83e2d099652e7c8e7add36

cleanup

===

M   source/blender/blenkernel/BKE_node_runtime.hh
M   source/blender/editors/space_node/node_draw.cc

===

diff --git a/source/blender/blenkernel/BKE_node_runtime.hh 
b/source/blender/blenkernel/BKE_node_runtime.hh
index 24d8dcd9a2c..658f6f4cced 100644
--- a/source/blender/blenkernel/BKE_node_runtime.hh
+++ b/source/blender/blenkernel/BKE_node_runtime.hh
@@ -49,6 +49,11 @@ class bNodeTreeRuntime : NonCopyable, NonMovable {
   /** Information about how inputs and outputs of the node group interact with 
fields. */
   std::unique_ptr 
field_inferencing_interface;
 
+  /**
+   * For geometry nodes, a lazy function graph with some additional info is 
cached. This is used to
+   * evaluate the node group. Caching it here allows us to reuse the 
preprocessed node tree in case
+   * its used multiple times.
+   */
   std::mutex geometry_nodes_lazy_function_graph_info_mutex;
   std::unique_ptr
   geometry_nodes_lazy_function_graph_info;
diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index a8fa27c0313..79935f6396b 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -97,7 +97,14 @@ extern void ui_draw_dropshadow(
 const rctf *rct, float radius, float aspect, float alpha, int select);
 }
 
+/**
+ * This is passed to many functions which draw the node editor.
+ */
 struct TreeDrawContext {
+  /**
+   * Geometry nodes logs various data during execution. The logged data that 
corresponds to the
+   * currently drawn node tree can be retrieved from the log below.
+   */
   GeoTreeLog *geo_tree_log = nullptr;
 };
 
@@ -326,50 +333,6 @@ float2 node_from_view(const bNode , const float2 )
   return result;
 }
 
-static nodes::geo_eval_log::GeoTreeLog *get_geo_tree_log(SpaceNode )
-{
-  using namespace blender;
-  using namespace blender::nodes;
-  using namespace blender::nodes::geo_eval_log;
-
-  ComputeContextBuilder compute_context_builder;
-
-  if (snode.id == nullptr) {
-return nullptr;
-  }
-  if (GS(snode.id->name) != ID_OB) {
-return nullptr;
-  }
-  Object *object = reinterpret_cast(snode.id);
-  NodesModifierData *nmd = nullptr;
-  LISTBASE_FOREACH (ModifierData *, md_iter, >modifiers) {
-if (md_iter->type == eModifierType_Nodes) {
-  NodesModifierData *nmd_iter = reinterpret_cast(md_iter);
-  if (nmd_iter->node_group == snode.nodetree) {
-nmd = nmd_iter;
-break;
-  }
-}
-  }
-  if (nmd == nullptr) {
-return nullptr;
-  }
-  if (nmd->runtime_eval_log == nullptr) {
-return nullptr;
-  }
-  GeoModifierLog _log = *static_cast(nmd->runtime_eval_log);
-  
compute_context_builder.push(nmd->modifier.name);
-  Vector tree_path_vec{snode.treepath};
-  if (tree_path_vec.is_empty()) {
-return nullptr;
-  }
-  for (const bNodeTreePath *path : tree_path_vec.as_span().drop_front(1)) {
-
compute_context_builder.push(path->node_name);
-  }
-
-  return _log.get_tree_log(compute_context_builder.hash());
-}
-
 struct SocketTooltipData {
   const bNodeTree *ntree;
   const bNode *node;
@@ -383,7 +346,7 @@ static bool node_socket_has_tooltip(const bNodeTree *ntree, 
const bNodeSocket *s
   }
 
   if (socket->runtime->declaration != nullptr) {
-const blender::nodes::SocketDeclaration _decl = 
*socket->runtime->declaration;
+const nodes::SocketDeclaration _decl = 
*socket->runtime->declaration;
 return !socket_decl.description().is_empty();
   }
 
@@ -712,7 +675,9 @@ static char *node_socket_get_tooltip(const bContext *C,
   TreeDrawContext tree_draw_ctx;
   if (snode != nullptr) {
 if (ntree->type == NTREE_GEOMETRY) {
-  tree_draw_ctx.geo_tree_log = get_geo_tree_log(*snode);
+  tree_draw_ctx.geo_tree_log =
+  
nodes::geo_eval_log::GeoModifierLog::get_tree_log_for_node_editor(*snode);
+  ;
 }
   }
 
@@ -3173,7 +3138,8 @@ static void draw_nodetree(const bContext ,
 
   TreeDrawContext tree_draw_ctx;
   if (ntree.type == NTREE_GEOMETRY) {
-tree_draw_ctx.geo_tree_log = get_geo_tree_log(*snode);
+tree_draw_ctx.geo_tree_log = 
nodes::geo_eval_log::GeoModifierLog::get_tree_log_for_node_editor(
+*snode);
 if (tree_draw_ctx.geo_tree_log != nullptr) {
   tree_draw_ctx.geo_tree_log->ensure_node_warnings();
   tree_draw_ctx.geo_tree_log->ensure_node_run_time();

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1c37a515bc2] temp-geometry-nodes-evaluator-refactor: Merge branch 'master' into temp-geometry-nodes-evaluator-refactor

2022-09-08 Thread Jacques Lucke
Commit: 1c37a515bc257635b172dc343764aa2f64f7121c
Author: Jacques Lucke
Date:   Thu Sep 8 09:50:40 2022 +0200
Branches: temp-geometry-nodes-evaluator-refactor
https://developer.blender.org/rB1c37a515bc257635b172dc343764aa2f64f7121c

Merge branch 'master' into temp-geometry-nodes-evaluator-refactor

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b9727dae829] master: Cleanup: Remove redundant vertex duplication in extrude node

2022-09-08 Thread Hans Goudey
Commit: b9727dae829dcdfcf4df09dec91185608bcffdd0
Author: Hans Goudey
Date:   Thu Sep 8 09:50:28 2022 -0500
Branches: master
https://developer.blender.org/rBb9727dae829dcdfcf4df09dec91185608bcffdd0

Cleanup: Remove redundant vertex duplication in extrude node

Now this is done by `Mesh::verts_for_write()`

===

M   source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc 
b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
index 9224e9d55f3..64779494e3e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
@@ -98,10 +98,6 @@ static void expand_mesh(Mesh ,
 mesh.totvert += vert_expand;
 CustomData_realloc(, mesh.totvert);
   }
-  else {
-/* Even when the number of vertices is not changed, the mesh can still be 
deformed. */
-CustomData_duplicate_referenced_layer(, CD_MVERT, mesh.totvert);
-  }
   if (edge_expand != 0) {
 CustomData_duplicate_referenced_layers(, mesh.totedge);
 mesh.totedge += edge_expand;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ff7bba8dad5] master: Fix: Integer type in linear probing strategy

2022-09-08 Thread Hans Goudey
Commit: ff7bba8dad5d09f8b3e53a9a31a5f5fa50099b44
Author: Hans Goudey
Date:   Thu Sep 8 09:52:42 2022 -0500
Branches: master
https://developer.blender.org/rBff7bba8dad5d09f8b3e53a9a31a5f5fa50099b44

Fix: Integer type in linear probing strategy

Probing strategies must iterate over every possible hash, but the linear
strategy only did 2^32 iterations, not 2^64. Updating this was missed
in 8cbbdedaf4dfec9e3. Also fix an unnecessary comma.

Differential Revision: https://developer.blender.org/D15913

===

M   source/blender/blenlib/BLI_probing_strategies.hh

===

diff --git a/source/blender/blenlib/BLI_probing_strategies.hh 
b/source/blender/blenlib/BLI_probing_strategies.hh
index c6152e4d03d..2c001270495 100644
--- a/source/blender/blenlib/BLI_probing_strategies.hh
+++ b/source/blender/blenlib/BLI_probing_strategies.hh
@@ -2,6 +2,8 @@
 
 #pragma once
 
+#include 
+
 /** \file
  * \ingroup bli
  *
@@ -20,7 +22,7 @@
  * clustering issues. However, more linear steps can also make things slower 
when the initial hash
  * produces many collisions.
  *
- * Every probing strategy has to guarantee, that every possible uint64_t is 
returned eventually.
+ * Every probing strategy has to guarantee that every possible uint64_t is 
returned eventually.
  * This is necessary for correctness. If this is not the case, empty slots 
might not be found.
  *
  * The SLOT_PROBING_BEGIN and SLOT_PROBING_END macros can be used to implement 
a loop that iterates
@@ -69,7 +71,7 @@ class LinearProbingStrategy {
 
   int64_t linear_steps() const
   {
-return UINT32_MAX;
+return std::numeric_limits::max();
   }
 };

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [17f37b43f1f] master: Cleanup: Remove unused face customdata for merging meshes

2022-09-08 Thread Hans Goudey
Commit: 17f37b43f1f4aa2d2111a88e10dd0aaab659f203
Author: Hans Goudey
Date:   Thu Sep 8 09:50:50 2022 -0500
Branches: master
https://developer.blender.org/rB17f37b43f1f4aa2d2111a88e10dd0aaab659f203

Cleanup: Remove unused face customdata for merging meshes

===

M   source/blender/editors/mesh/meshtools.cc

===

diff --git a/source/blender/editors/mesh/meshtools.cc 
b/source/blender/editors/mesh/meshtools.cc
index 58702d9e966..9d1ea499e42 100644
--- a/source/blender/editors/mesh/meshtools.cc
+++ b/source/blender/editors/mesh/meshtools.cc
@@ -347,7 +347,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
   int totloop = 0, totpoly = 0, vertofs, *matmap = nullptr;
   int i, haskey = 0, edgeofs, loopofs, polyofs;
   bool ok = false, join_parent = false;
-  CustomData vdata, edata, fdata, ldata, pdata;
+  CustomData vdata, edata, ldata, pdata;
 
   if (ob->mode & OB_MODE_EDIT) {
 BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode");
@@ -586,7 +586,6 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
   /* setup new data for destination mesh */
   CustomData_reset();
   CustomData_reset();
-  CustomData_reset();
   CustomData_reset();
   CustomData_reset();

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [59f6c60fb60] master: Cleanup: Remove unused variable in RNA path function

2022-09-08 Thread Julian Eisel
Commit: 59f6c60fb60ecd143d5e5984a4e7883d91766007
Author: Julian Eisel
Date:   Thu Sep 8 16:44:24 2022 +0200
Branches: master
https://developer.blender.org/rB59f6c60fb60ecd143d5e5984a4e7883d91766007

Cleanup: Remove unused variable in RNA path function

Caused by 462014b59b4f

===

M   source/blender/makesrna/intern/rna_path.cc

===

diff --git a/source/blender/makesrna/intern/rna_path.cc 
b/source/blender/makesrna/intern/rna_path.cc
index 6fc1eed7e23..96f46f5dbe6 100644
--- a/source/blender/makesrna/intern/rna_path.cc
+++ b/source/blender/makesrna/intern/rna_path.cc
@@ -927,7 +927,6 @@ ID *RNA_find_real_ID_and_path(ID *id, const char **r_path)
 return id;
   }
 
-  const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
   if (r_path) {
 switch (GS(id->name)) {
   case ID_NT:

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7eda9d8dda5] master: Outliner: Hide "data operations" context menu entries unless supported

2022-09-08 Thread Julian Eisel
Commit: 7eda9d8dda59cd2bfebe665114447adc0a5ce778
Author: Julian Eisel
Date:   Thu Sep 8 16:31:54 2022 +0200
Branches: master
https://developer.blender.org/rB7eda9d8dda59cd2bfebe665114447adc0a5ce778

Outliner: Hide "data operations" context menu entries unless supported

The context menu would always show a section with "Select", "Deselect",
"Hide", "Unhide" and "Select Linked" if there were no more specific
operators to show (e.g. modifier operations). For many tree elements
they did not make sense and simply would do nothing. Only show the
section for supported types.

===

M   source/blender/editors/space_outliner/outliner_tools.cc

===

diff --git a/source/blender/editors/space_outliner/outliner_tools.cc 
b/source/blender/editors/space_outliner/outliner_tools.cc
index c93622b7cfb..bab5b945d43 100644
--- a/source/blender/editors/space_outliner/outliner_tools.cc
+++ b/source/blender/editors/space_outliner/outliner_tools.cc
@@ -3185,6 +3185,24 @@ void OUTLINER_OT_modifier_operation(wmOperatorType *ot)
 /** \name Data Menu Operator
  * \{ */
 
+static bool outliner_data_operation_poll(bContext *C)
+{
+  if (!ED_operator_outliner_active(C)) {
+return false;
+  }
+  const SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+  const TreeElement *te = get_target_element(space_outliner);
+  int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
+  get_element_operation_type(te, , , , 
);
+  return ELEM(datalevel,
+  TSE_POSE_CHANNEL,
+  TSE_BONE,
+  TSE_EBONE,
+  TSE_SEQUENCE,
+  TSE_GP_LAYER,
+  TSE_RNA_STRUCT);
+}
+
 static int outliner_data_operation_exec(bContext *C, wmOperator *op)
 {
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
@@ -3295,7 +3313,7 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
   /* callbacks */
   ot->invoke = WM_menu_invoke;
   ot->exec = outliner_data_operation_exec;
-  ot->poll = outliner_operation_tree_element_poll;
+  ot->poll = outliner_data_operation_poll;
 
   ot->flag = 0;
 
@@ -3317,9 +3335,12 @@ static int outliner_operator_menu(bContext *C, const 
char *opname)
 
   /* set this so the default execution context is the same as submenus */
   uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
-  uiItemsEnumO(layout, ot->idname, RNA_property_identifier(ot->prop));
 
-  uiItemS(layout);
+  if (WM_operator_poll(C, ot)) {
+uiItemsEnumO(layout, ot->idname, RNA_property_identifier(ot->prop));
+
+uiItemS(layout);
+  }
 
   uiItemMContents(layout, "OUTLINER_MT_context_menu");

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8f6a38ed7e4] master: Cleanup: Simplify outliner context menu building queries

2022-09-08 Thread Julian Eisel
Commit: 8f6a38ed7e448e2b80b5fe5334e446ffb15cb25c
Author: Julian Eisel
Date:   Thu Sep 8 16:20:53 2022 +0200
Branches: master
https://developer.blender.org/rB8f6a38ed7e448e2b80b5fe5334e446ffb15cb25c

Cleanup: Simplify outliner context menu building queries

- Remove unnecessary calls to `get_element_operation_type()` (result
  wasn't used).
- Remove branches/checks for cases that couldn't possibly happen.
  (assert instead).
- Ensure all return arguments are set so caller can't make the mistake
  of forgetting that.
- Early exit instead of big `if` block.
- Use `const`.

===

M   source/blender/editors/space_outliner/outliner_tools.cc

===

diff --git a/source/blender/editors/space_outliner/outliner_tools.cc 
b/source/blender/editors/space_outliner/outliner_tools.cc
index b0d24c88eea..c93622b7cfb 100644
--- a/source/blender/editors/space_outliner/outliner_tools.cc
+++ b/source/blender/editors/space_outliner/outliner_tools.cc
@@ -104,97 +104,96 @@ using blender::Vector;
  * \{ */
 
 static void get_element_operation_type(
-TreeElement *te, int *scenelevel, int *objectlevel, int *idlevel, int 
*datalevel)
+const TreeElement *te, int *scenelevel, int *objectlevel, int *idlevel, 
int *datalevel)
 {
-  TreeStoreElem *tselem = TREESTORE(te);
-  if (tselem->flag & TSE_SELECTED) {
-/* Layer collection points to collection ID. */
-if (!ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION)) {
-  if (*datalevel == 0) {
-*datalevel = tselem->type;
-  }
-  else if (*datalevel != tselem->type) {
-*datalevel = -1;
-  }
-}
-else {
-  const int idcode = (int)GS(tselem->id->name);
-  bool is_standard_id = false;
-  switch ((ID_Type)idcode) {
-case ID_SCE:
-  *scenelevel = 1;
-  break;
-case ID_OB:
-  *objectlevel = 1;
-  break;
+  *scenelevel = *objectlevel = *idlevel = *datalevel = 0;
 
-case ID_ME:
-case ID_CU_LEGACY:
-case ID_MB:
-case ID_LT:
-case ID_LA:
-case ID_AR:
-case ID_CA:
-case ID_SPK:
-case ID_MA:
-case ID_TE:
-case ID_IP:
-case ID_IM:
-case ID_SO:
-case ID_KE:
-case ID_WO:
-case ID_AC:
-case ID_TXT:
-case ID_GR:
-case ID_LS:
-case ID_LI:
-case ID_VF:
-case ID_NT:
-case ID_BR:
-case ID_PA:
-case ID_GD:
-case ID_MC:
-case ID_MSK:
-case ID_PAL:
-case ID_PC:
-case ID_CF:
-case ID_WS:
-case ID_LP:
-case ID_CV:
-case ID_PT:
-case ID_VO:
-case ID_SIM:
-  is_standard_id = true;
-  break;
-case ID_WM:
-case ID_SCR:
-  /* Those are ignored here. */
-  /* NOTE: while Screens should be manageable here, deleting a screen 
used by a workspace
-   * will cause crashes when trying to use that workspace, so for now 
let's play minimal,
-   * safe change. */
-  break;
-  }
-  if (idcode == ID_NLA) {
-/* Fake one, not an actual ID type... */
+  const TreeStoreElem *tselem = TREESTORE(te);
+  if ((tselem->flag & TSE_SELECTED) == 0) {
+return;
+  }
+
+  /* Layer collection points to collection ID. */
+  if (!ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION)) {
+*datalevel = tselem->type;
+  }
+  else {
+const int idcode = (int)GS(tselem->id->name);
+bool is_standard_id = false;
+switch ((ID_Type)idcode) {
+  case ID_SCE:
+*scenelevel = 1;
+break;
+  case ID_OB:
+*objectlevel = 1;
+break;
+
+  case ID_ME:
+  case ID_CU_LEGACY:
+  case ID_MB:
+  case ID_LT:
+  case ID_LA:
+  case ID_AR:
+  case ID_CA:
+  case ID_SPK:
+  case ID_MA:
+  case ID_TE:
+  case ID_IP:
+  case ID_IM:
+  case ID_SO:
+  case ID_KE:
+  case ID_WO:
+  case ID_AC:
+  case ID_TXT:
+  case ID_GR:
+  case ID_LS:
+  case ID_LI:
+  case ID_VF:
+  case ID_NT:
+  case ID_BR:
+  case ID_PA:
+  case ID_GD:
+  case ID_MC:
+  case ID_MSK:
+  case ID_PAL:
+  case ID_PC:
+  case ID_CF:
+  case ID_WS:
+  case ID_LP:
+  case ID_CV:
+  case ID_PT:
+  case ID_VO:
+  case ID_SIM:
 is_standard_id = true;
-  }
+break;
+  case ID_WM:
+  case ID_SCR:
+/* Those are ignored here. */
+/* NOTE: while Screens should be manageable here, deleting a screen 
used by a workspace
+ * will cause crashes when trying to use that workspace, so for now 
let's play minimal,
+ * safe change. */
+break;
+}
+if (idcode == ID_NLA) {
+  /* Fake one, not an actual ID type... */
+  is_standard_id = true;
+

[Bf-blender-cvs] [406243c2fde] master: IDManagement: change `IDTypeInfo.owner_get` to instead return address of the owner_id pointer.

2022-09-08 Thread Bastien Montagne
Commit: 406243c2fde7472ea39f1eb6316311aec5b72e13
Author: Bastien Montagne
Date:   Thu Sep 8 16:32:35 2022 +0200
Branches: master
https://developer.blender.org/rB406243c2fde7472ea39f1eb6316311aec5b72e13

IDManagement: change `IDTypeInfo.owner_get` to instead return address of the 
owner_id pointer.

Also rename the callback. That way, we can keep moving toward a more
generic handling of those embedded IDs (think e.g. about copy code).

===

M   source/blender/blenkernel/BKE_idtype.h
M   source/blender/blenkernel/intern/action.c
M   source/blender/blenkernel/intern/armature.c
M   source/blender/blenkernel/intern/brush.cc
M   source/blender/blenkernel/intern/cachefile.c
M   source/blender/blenkernel/intern/camera.c
M   source/blender/blenkernel/intern/collection.c
M   source/blender/blenkernel/intern/curve.cc
M   source/blender/blenkernel/intern/curves.cc
M   source/blender/blenkernel/intern/gpencil.c
M   source/blender/blenkernel/intern/image.cc
M   source/blender/blenkernel/intern/ipo.c
M   source/blender/blenkernel/intern/key.c
M   source/blender/blenkernel/intern/lattice.c
M   source/blender/blenkernel/intern/lib_id.c
M   source/blender/blenkernel/intern/library.c
M   source/blender/blenkernel/intern/light.c
M   source/blender/blenkernel/intern/lightprobe.c
M   source/blender/blenkernel/intern/linestyle.c
M   source/blender/blenkernel/intern/mask.c
M   source/blender/blenkernel/intern/material.c
M   source/blender/blenkernel/intern/mball.cc
M   source/blender/blenkernel/intern/mesh.cc
M   source/blender/blenkernel/intern/movieclip.c
M   source/blender/blenkernel/intern/node.cc
M   source/blender/blenkernel/intern/object.cc
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/blenkernel/intern/particle.c
M   source/blender/blenkernel/intern/pointcloud.cc
M   source/blender/blenkernel/intern/scene.cc
M   source/blender/blenkernel/intern/screen.c
M   source/blender/blenkernel/intern/simulation.cc
M   source/blender/blenkernel/intern/sound.c
M   source/blender/blenkernel/intern/speaker.c
M   source/blender/blenkernel/intern/text.c
M   source/blender/blenkernel/intern/texture.c
M   source/blender/blenkernel/intern/vfont.c
M   source/blender/blenkernel/intern/volume.cc
M   source/blender/blenkernel/intern/workspace.c
M   source/blender/blenkernel/intern/world.c
M   source/blender/windowmanager/intern/wm.c

===

diff --git a/source/blender/blenkernel/BKE_idtype.h 
b/source/blender/blenkernel/BKE_idtype.h
index 7e2cd87cb0d..256ddec5505 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -85,7 +85,7 @@ typedef void (*IDTypeForeachCacheFunction)(struct ID *id,
 
 typedef void (*IDTypeForeachPathFunction)(struct ID *id, struct 
BPathForeachPathData *bpath_data);
 
-typedef struct ID *(*IDTypeEmbeddedOwnerGetFunction)(struct ID *id);
+typedef struct ID **(*IDTypeEmbeddedOwnerPointerGetFunction)(struct ID *id);
 
 typedef void (*IDTypeBlendWriteFunction)(struct BlendWriter *writer,
  struct ID *id,
@@ -180,9 +180,9 @@ typedef struct IDTypeInfo {
   IDTypeForeachPathFunction foreach_path;
 
   /**
-   * For embedded IDs, return their owner ID.
+   * For embedded IDs, return the address of the pointer to their owner ID.
*/
-  IDTypeEmbeddedOwnerGetFunction owner_get;
+  IDTypeEmbeddedOwnerPointerGetFunction owner_pointer_get;
 
   /* ** Callbacks for reading and writing .blend files. ** */
 
diff --git a/source/blender/blenkernel/intern/action.c 
b/source/blender/blenkernel/intern/action.c
index c16d19588ed..e0ae1d88760 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -315,7 +315,7 @@ IDTypeInfo IDType_ID_AC = {
 .foreach_id = action_foreach_id,
 .foreach_cache = NULL,
 .foreach_path = NULL,
-.owner_get = NULL,
+.owner_pointer_get = NULL,
 
 .blend_write = action_blend_write,
 .blend_read_data = action_blend_read_data,
diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index 7be3fe6f0e1..0027f6dd707 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -313,7 +313,7 @@ IDTypeInfo IDType_ID_AR = {
 .foreach_id = armature_foreach_id,
 .foreach_cache = NULL,
 .foreach_path = NULL,
-.owner_get = NULL,
+.owner_pointer_get = NULL,
 
 .blend_write = armature_blend_write,
 .blend_read_data = armature_blend_read_data,
diff --git a/source/blender/blenkernel/intern/brush.cc 
b/source/blender/blenkernel/intern/brush.cc
index 34b87dda338..c206a04fecc 100644
--- a/source/blender/blenkernel/intern/brush.cc
+++ 

[Bf-blender-cvs] [462014b59b4] master: IDManagement: Add new `BKE_id_owner_get` accessor.

2022-09-08 Thread Bastien Montagne
Commit: 462014b59b4f5ad110ebfcbc17dfa1f896582110
Author: Bastien Montagne
Date:   Thu Sep 8 13:06:40 2022 +0200
Branches: master
https://developer.blender.org/rB462014b59b4f5ad110ebfcbc17dfa1f896582110

IDManagement: Add new `BKE_id_owner_get` accessor.

Essentially calls `IDTypeInfo->owner_get` for now, will make more sense
once the callback is changed to return the address of the pointer
instead.

===

M   source/blender/blenkernel/BKE_lib_id.h
M   source/blender/blenkernel/intern/lib_id.c
M   source/blender/blenkernel/intern/lib_override.cc
M   source/blender/blenkernel/intern/lib_query.c
M   source/blender/editors/space_outliner/outliner_collections.cc
M   source/blender/makesrna/intern/rna_path.cc
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/source/blender/blenkernel/BKE_lib_id.h 
b/source/blender/blenkernel/BKE_lib_id.h
index febdad2ca0d..4e4b393fcd6 100644
--- a/source/blender/blenkernel/BKE_lib_id.h
+++ b/source/blender/blenkernel/BKE_lib_id.h
@@ -620,6 +620,13 @@ bool BKE_id_is_in_global_main(struct ID *id);
 
 bool BKE_id_can_be_asset(const struct ID *id);
 
+/**
+ * Return the owner ID of the given `id`, if any.
+ *
+ * \note: This will only return non-NULL for embedded IDs (master collections 
etc.), and shapekeys.
+ */
+struct ID *BKE_id_owner_get(struct ID *id);
+
 /** Check if that ID can be considered as editable from a high-level (editor) 
perspective.
  *
  * NOTE: This used to be done with a check on whether ID was linked or not, 
but now with system
diff --git a/source/blender/blenkernel/intern/lib_id.c 
b/source/blender/blenkernel/intern/lib_id.c
index 5a394a05d86..cead6702080 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -1965,6 +1965,15 @@ bool BKE_id_can_be_asset(const ID *id)
  BKE_idtype_idcode_is_linkable(GS(id->name));
 }
 
+ID *BKE_id_owner_get(ID *id)
+{
+  const IDTypeInfo *idtype = BKE_idtype_get_info_from_id(id);
+  if (idtype->owner_get != NULL) {
+return idtype->owner_get(id);
+  }
+  return NULL;
+}
+
 bool BKE_id_is_editable(const Main *bmain, const ID *id)
 {
   return !(ID_IS_LINKED(id) || 
BKE_lib_override_library_is_system_defined(bmain, id));
diff --git a/source/blender/blenkernel/intern/lib_override.cc 
b/source/blender/blenkernel/intern/lib_override.cc
index a85a6c5730f..0200b534ace 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -97,21 +97,17 @@ BLI_INLINE const IDOverrideLibrary 
*BKE_lib_override_library_get(const Main * /*
  const ID * 
/*owner_id_hint*/,
  const ID 
**r_owner_id)
 {
-  if (r_owner_id != nullptr) {
-*r_owner_id = id;
-  }
   if (id->flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE) {
-const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
-if (id_type->owner_get != nullptr) {
-  /* The #IDTypeInfo::owner_get callback should not modify the arguments, 
so casting away const
-   * is okay. */
-  const ID *owner_id = id_type->owner_get(const_cast(id));
-  if (r_owner_id != nullptr) {
-*r_owner_id = owner_id;
-  }
-  return owner_id->override_library;
+const ID *owner_id = BKE_id_owner_get(const_cast(id));
+BLI_assert_msg(owner_id != nullptr, "Liboverride-embedded ID with no 
owner");
+if (r_owner_id != nullptr) {
+  *r_owner_id = owner_id;
 }
-BLI_assert_msg(0, "IDTypeInfo of liboverride-embedded ID with no owner 
getter");
+return owner_id->override_library;
+  }
+
+  if (r_owner_id != nullptr) {
+*r_owner_id = id;
   }
   return id->override_library;
 }
@@ -2211,9 +2207,9 @@ static bool lib_override_resync_id_lib_level_is_valid(ID 
*id,
 static ID *lib_override_library_main_resync_root_get(Main * /*bmain*/, ID *id)
 {
   if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
-const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
-if (id_type->owner_get != nullptr) {
-  id = id_type->owner_get(id);
+ID *id_owner = BKE_id_owner_get(id);
+if (id_owner != nullptr) {
+  id = id_owner;
 }
 BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id));
   }
diff --git a/source/blender/blenkernel/intern/lib_query.c 
b/source/blender/blenkernel/intern/lib_query.c
index e51f3c524fa..50843b18d18 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -711,9 +711,8 @@ static void lib_query_unused_ids_tag_recurse(Main *bmain,
 ID *id_from = id_from_item->id_pointer.from;
 if ((id_from->flag & LIB_EMBEDDED_DATA) != 0) {
   /* Directly 'by-pass' to actual real ID owner. */
-  const IDTypeInfo *type_info_from = BKE_idtype_get_info_from_id(id_from);
-  

[Bf-blender-cvs] [b31a8e30cba] temp-T73411-view-layer-lazy-cache: Rename to BKE_view_layer_need_resync_tag, BKE_view_layer_synced_ensure

2022-09-08 Thread Monique
Commit: b31a8e30cba735e5f5880b9ed59e5576ecc2d9eb
Author: Monique
Date:   Thu Sep 8 16:19:13 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rBb31a8e30cba735e5f5880b9ed59e5576ecc2d9eb

Rename to BKE_view_layer_need_resync_tag, BKE_view_layer_synced_ensure

===

M   source/blender/blenkernel/BKE_layer.h
M   source/blender/blenkernel/intern/DerivedMesh.cc
M   source/blender/blenkernel/intern/blendfile_link_append.c
M   source/blender/blenkernel/intern/collection.c
M   source/blender/blenkernel/intern/context.c
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/blenkernel/intern/layer.c
M   source/blender/blenkernel/intern/layer_utils.c
M   source/blender/blenkernel/intern/lib_override.cc
M   source/blender/blenkernel/intern/mball.cc
M   source/blender/blenkernel/intern/object.cc
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/blenkernel/intern/particle.c
M   source/blender/blenkernel/intern/rigidbody.c
M   source/blender/blenkernel/intern/scene.cc
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M   source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   
source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
M   source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
M   source/blender/draw/engines/overlay/overlay_extra.c
M   source/blender/draw/intern/draw_common.c
M   source/blender/draw/intern/draw_manager.c
M   source/blender/editors/animation/anim_channels_edit.c
M   source/blender/editors/animation/anim_filter.c
M   source/blender/editors/animation/anim_markers.c
M   source/blender/editors/armature/armature_select.c
M   source/blender/editors/armature/editarmature_undo.c
M   source/blender/editors/armature/pose_select.c
M   source/blender/editors/curve/editcurve.c
M   source/blender/editors/curve/editcurve_add.c
M   source/blender/editors/curve/editcurve_select.c
M   source/blender/editors/curve/editcurve_undo.c
M   source/blender/editors/curve/editfont.c
M   source/blender/editors/curve/editfont_undo.c
M   source/blender/editors/gpencil/gpencil_armature.c
M   source/blender/editors/gpencil/gpencil_convert.c
M   source/blender/editors/interface/interface_ops.cc
M   source/blender/editors/lattice/editlattice_select.c
M   source/blender/editors/lattice/editlattice_undo.c
M   source/blender/editors/mesh/editmesh_path.c
M   source/blender/editors/mesh/editmesh_polybuild.c
M   source/blender/editors/mesh/editmesh_select.c
M   source/blender/editors/mesh/editmesh_undo.c
M   source/blender/editors/metaball/editmball_undo.c
M   source/blender/editors/metaball/mball_edit.c
M   source/blender/editors/object/object_add.cc
M   source/blender/editors/object/object_bake_api.c
M   source/blender/editors/object/object_collection.c
M   source/blender/editors/object/object_constraint.c
M   source/blender/editors/object/object_edit.c
M   source/blender/editors/object/object_hook.c
M   source/blender/editors/object/object_modes.c
M   source/blender/editors/object/object_modifier.cc
M   source/blender/editors/object/object_relations.c
M   source/blender/editors/object/object_select.c
M   source/blender/editors/object/object_utils.c
M   source/blender/editors/physics/particle_edit.c
M   source/blender/editors/physics/particle_edit_undo.c
M   source/blender/editors/physics/particle_object.c
M   source/blender/editors/physics/rigidbody_constraint.c
M   source/blender/editors/render/render_internal.cc
M   source/blender/editors/render/render_preview.cc
M   source/blender/editors/screen/screen_context.c
M   source/blender/editors/screen/screen_edit.c
M   source/blender/editors/sculpt_paint/paint_image_ops_paint.cc
M   source/blender/editors/sculpt_paint/paint_image_proj.c
M   source/blender/editors/sculpt_paint/paint_utils.c
M   source/blender/editors/sculpt_paint/sculpt_ops.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c
M   source/blender/editors/space_buttons/buttons_context.c
M   source/blender/editors/space_buttons/buttons_texture.c
M   source/blender/editors/space_clip/tracking_ops_orient.c
M   source/blender/editors/space_image/image_edit.c
M   source/blender/editors/space_image/space_image.c
M   source/blender/editors/space_info/info_stats.cc
M   source/blender/editors/space_nla/nla_channels.c
M   source/blender/editors/space_outliner/outliner_collections.cc
M   source/blender/editors/space_outliner/outliner_dragdrop.cc
M   source/blender/editors/space_outliner/outliner_draw.cc
M   

[Bf-blender-cvs] [173d8edb0bb] master: Cleanup: make meaning of base visibility flags more clear

2022-09-08 Thread Brecht Van Lommel
Commit: 173d8edb0bb6e017235ef85a10963f39725c29ef
Author: Brecht Van Lommel
Date:   Mon Sep 5 17:14:40 2022 +0200
Branches: master
https://developer.blender.org/rB173d8edb0bb6e017235ef85a10963f39725c29ef

Cleanup: make meaning of base visibility flags more clear

Rename, add comments, and use flag in the depsgraph to ensure the logic
matches.

Differential Revision: https://developer.blender.org/D15883

===

M   source/blender/blenkernel/BKE_layer.h
M   source/blender/blenkernel/intern/layer.c
M   source/blender/blenkernel/intern/object.cc
M   source/blender/blenkernel/intern/object_update.c
M   source/blender/depsgraph/intern/depsgraph_query_iter.cc
M   source/blender/depsgraph/intern/eval/deg_eval_visibility.cc
M   source/blender/draw/intern/draw_manager.c
M   source/blender/editors/animation/anim_filter.c
M   source/blender/editors/object/object_add.cc
M   source/blender/editors/object/object_bake_api.c
M   source/blender/editors/object/object_edit.c
M   source/blender/editors/object/object_select.c
M   source/blender/editors/render/render_internal.cc
M   source/blender/editors/render/render_preview.cc
M   source/blender/editors/space_info/info_stats.cc
M   source/blender/editors/space_outliner/outliner_draw.cc
M   source/blender/editors/space_outliner/outliner_select.cc
M   source/blender/editors/space_outliner/outliner_tree.cc
M   source/blender/editors/space_view3d/space_view3d.c
M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/makesdna/DNA_layer_types.h

===

diff --git a/source/blender/blenkernel/BKE_layer.h 
b/source/blender/blenkernel/BKE_layer.h
index 49dc87629d6..8bc89c56450 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -245,8 +245,8 @@ void BKE_layer_collection_set_flag(struct LayerCollection 
*lc, int flag, bool va
 
 /**
  * Applies object's restrict flags on top of flags coming from the collection
- * and stores those in `base->flag`. #BASE_VISIBLE_DEPSGRAPH ignores viewport 
flags visibility
- * (i.e., restriction and local collection).
+ * and stores those in `base->flag`. 
#BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT ignores viewport
+ * flags visibility (i.e., restriction and local collection).
  */
 void BKE_base_eval_flags(struct Base *base);
 
diff --git a/source/blender/blenkernel/intern/layer.c 
b/source/blender/blenkernel/intern/layer.c
index 53a9b6d469d..2b49da6dbe9 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -56,7 +56,8 @@
 static CLG_LogRef LOG = {"bke.layercollection"};
 
 /* Set of flags which are dependent on a collection settings. */
-static const short g_base_collection_flags = (BASE_VISIBLE_DEPSGRAPH | 
BASE_VISIBLE_VIEWLAYER |
+static const short g_base_collection_flags = 
(BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT |
+  
BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT |
   BASE_SELECTABLE | 
BASE_ENABLED_VIEWPORT |
   BASE_ENABLED_RENDER | 
BASE_HOLDOUT |
   BASE_INDIRECT_ONLY);
@@ -998,9 +999,10 @@ static void layer_collection_objects_sync(ViewLayer 
*view_layer,
 }
 
 if ((collection_restrict & COLLECTION_HIDE_VIEWPORT) == 0) {
-  base->flag_from_collection |= (BASE_ENABLED_VIEWPORT | 
BASE_VISIBLE_DEPSGRAPH);
+  base->flag_from_collection |= (BASE_ENABLED_VIEWPORT |
+ 
BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT);
   if ((layer_restrict & LAYER_COLLECTION_HIDE) == 0) {
-base->flag_from_collection |= BASE_VISIBLE_VIEWLAYER;
+base->flag_from_collection |= 
BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT;
   }
   if (((collection_restrict & COLLECTION_HIDE_SELECT) == 0)) {
 base->flag_from_collection |= BASE_SELECTABLE;
@@ -1452,7 +1454,8 @@ bool BKE_layer_collection_has_selected_objects(ViewLayer 
*view_layer, LayerColle
 LISTBASE_FOREACH (CollectionObject *, cob, >collection->gobject) {
   Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
 
-  if (base && (base->flag & BASE_SELECTED) && (base->flag & 
BASE_VISIBLE_DEPSGRAPH)) {
+  if (base && (base->flag & BASE_SELECTED) &&
+  (base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT)) {
 return true;
   }
 }
@@ -1508,12 +1511,12 @@ void BKE_base_set_visible(Scene *scene, ViewLayer 
*view_layer, Base *base, bool
 
 bool BKE_base_is_visible(const View3D *v3d, const Base *base)
 {
-  if ((base->flag & BASE_VISIBLE_DEPSGRAPH) == 0) {
+  if ((base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT) == 0) {
 return false;
   }
 
   if (v3d == NULL) {
-return base->flag & 

[Bf-blender-cvs] [4ac69c26db4] master: Fix Cycles wrong MIS logic in shade_light kernel after recent changes

2022-09-08 Thread Brecht Van Lommel
Commit: 4ac69c26db4c246dfb597411884af2a7ecc7ee66
Author: Brecht Van Lommel
Date:   Thu Sep 8 15:11:27 2022 +0200
Branches: master
https://developer.blender.org/rB4ac69c26db4c246dfb597411884af2a7ecc7ee66

Fix Cycles wrong MIS logic in shade_light kernel after recent changes

Though end result was still correct. Thanks to Alaska for spotting this.

===

M   intern/cycles/kernel/integrator/shade_light.h

===

diff --git a/intern/cycles/kernel/integrator/shade_light.h 
b/intern/cycles/kernel/integrator/shade_light.h
index a4246f99bbf..f2d65eddfbb 100644
--- a/intern/cycles/kernel/integrator/shade_light.h
+++ b/intern/cycles/kernel/integrator/shade_light.h
@@ -62,8 +62,7 @@ ccl_device_inline void integrate_light(KernelGlobals kg,
 /* multiple importance sampling, get regular light pdf,
  * and compute weight with respect to BSDF pdf */
 const float mis_ray_pdf = INTEGRATOR_STATE(state, path, mis_ray_pdf);
-const float mis_weight = light_sample_mis_weight_forward(kg, mis_ray_pdf, 
ls.pdf);
-light_eval *= mis_weight;
+mis_weight = light_sample_mis_weight_forward(kg, mis_ray_pdf, ls.pdf);
   }
 
   /* Write to render buffer. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3b2bc5d1463] bevelv2: Added a mesh_inset Blenlib function.

2022-09-08 Thread Howard Trickey
Commit: 3b2bc5d1463a10c445fb74e9a7888ef4d59e368c
Author: Howard Trickey
Date:   Thu Sep 8 10:04:20 2022 -0400
Branches: bevelv2
https://developer.blender.org/rB3b2bc5d1463a10c445fb74e9a7888ef4d59e368c

Added a mesh_inset Blenlib function.

Based on python code from Henrik Dick, this libray function
calculates a Straight Skeleton, and hence, deals properly
with cases where the advancing inset geometry would overlap
or pass through opposite edges. It still needs work but the
basic tests pass.
This function will be used for edge and face bevels but is
not yet hooked up for that.

===

A   source/blender/blenlib/BLI_mesh_inset.hh
M   source/blender/blenlib/CMakeLists.txt
A   source/blender/blenlib/intern/mesh_inset.cc
A   source/blender/blenlib/tests/BLI_mesh_inset_test.cc

===

diff --git a/source/blender/blenlib/BLI_mesh_inset.hh 
b/source/blender/blenlib/BLI_mesh_inset.hh
new file mode 100644
index 000..cd7dfcb57df
--- /dev/null
+++ b/source/blender/blenlib/BLI_mesh_inset.hh
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#pragma once
+
+/** \file
+ * \ingroup bli
+ *
+ * This header file contains a C++ interface to a 3D mesh inset algorithm
+ * which is based on a 2D Straight Skeleton construction.
+ */
+
+#include "BLI_array.hh"
+#include "BLI_math_vec_types.hh"
+#include "BLI_span.hh"
+#include "BLI_vector.hh"
+
+
+namespace blender::meshinset {
+
+class MeshInset_Input {
+public:
+  /** The vertices. Can be a superset of the needed vertices. */
+  Span vert;
+  /** The faces, each a CCW ordering of vertex indices. */
+  Span> face;
+  /** The contours to inset; ints are vert indices; contour is on left side of 
implied edges. */
+  Span> contour;
+  float inset_amount;
+  bool need_ids;
+};
+
+class MeshInset_Result {
+public:
+  /** The output vertices. A subset (perhaps) of input vertices, plus some new 
ones. */
+  Array vert;
+  /** The output faces, each a CCW ordering of the output vertices. */
+  Array> face;
+  /** The output contours -- where the input contours ended up. */
+  Array> contour;
+  /** Maps output vertex indices to input vertex indices, -1 if there is none. 
*/
+  Array orig_vert;
+  /** Maps output faces tot input faces that they were part of. */
+  Array orig_face;
+};
+
+MeshInset_Result mesh_inset_calc(const MeshInset_Input );
+
+}  // namespace blender::meshinset
diff --git a/source/blender/blenlib/CMakeLists.txt 
b/source/blender/blenlib/CMakeLists.txt
index d87c60e6099..fea46237997 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -107,6 +107,7 @@ set(SRC
   intern/math_vector_inline.c
   intern/memory_utils.c
   intern/mesh_boolean.cc
+  intern/mesh_inset.cc
   intern/mesh_intersect.cc
   intern/noise.c
   intern/noise.cc
@@ -275,6 +276,7 @@ set(SRC
   BLI_memory_utils.hh
   BLI_mempool.h
   BLI_mesh_boolean.hh
+  BLI_mesh_inset.hh
   BLI_mesh_intersect.hh
   BLI_mmap.h
   BLI_multi_value_map.hh
@@ -473,6 +475,7 @@ if(WITH_GTESTS)
 tests/BLI_memiter_test.cc
 tests/BLI_memory_utils_test.cc
 tests/BLI_mesh_boolean_test.cc
+tests/BLI_mesh_inset_test.cc
 tests/BLI_mesh_intersect_test.cc
 tests/BLI_multi_value_map_test.cc
 tests/BLI_path_util_test.cc
diff --git a/source/blender/blenlib/intern/mesh_inset.cc 
b/source/blender/blenlib/intern/mesh_inset.cc
new file mode 100644
index 000..69bddbb8035
--- /dev/null
+++ b/source/blender/blenlib/intern/mesh_inset.cc
@@ -0,0 +1,3058 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/** \file
+ * \ingroup bli
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "BLI_array.hh"
+#include "BLI_heap.h"
+#include "BLI_map.hh"
+#include "BLI_math_vector.h"
+#include "BLI_math_vector.hh"
+#include "BLI_memarena.h"
+#include "BLI_mesh_inset.hh"
+#include "BLI_polyfill_2d.h"
+#include "BLI_polyfill_2d_beautify.h"
+#include "BLI_set.hh"
+#include "BLI_span.hh"
+#include "BLI_vector.hh"
+
+#include "BLI_mesh_inset.hh"
+
+namespace blender::meshinset {
+
+class Vert;
+class Edge;
+class Triangle;
+
+/** The predecessor index to \a i in a triangle. */
+static inline int pred_index(const int i)
+{
+  return (i + 2) % 3;
+}
+
+/** The successor index to \a i in a triangle. */
+static inline int succ_index(const int i)
+{
+  return (i + 1) % 3;
+}
+
+/** The ith edge of triangle tri. Not shared with the adjacent triangle. */
+class Edge {
+  /* Assume Triangles are allocated on at least 4 byte boundaries.
+   * Then, use the lower two bits of the pointer as the index (0,1,2)
+   * saying which edge of the triangle we refer to.
+   */
+
+  /** A pointer with lower two bits used for index. */
+  Triangle *tri_and_index_;
+
+ public:
+  Edge() : tri_and_index_(nullptr)
+  {
+  }
+  Edge(const Triangle *tri, int tri_edge_index)
+  {
+static_assert(sizeof(Triangle *) % 4 == 0);
+

[Bf-blender-cvs] [81341d1e94c] bevelv2: Update for new Mesh API for verts, etc.

2022-09-08 Thread Howard Trickey
Commit: 81341d1e94c0ab320e15536f93e3032ef695bffb
Author: Howard Trickey
Date:   Thu Sep 8 09:16:55 2022 -0400
Branches: bevelv2
https://developer.blender.org/rB81341d1e94c0ab320e15536f93e3032ef695bffb

Update for new Mesh API for verts, etc.

===

M   source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc 
b/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
index 79ff9c168dc..eb5c2584300 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
@@ -119,17 +119,17 @@ class MeshTopology {
 
   float3 vert_co(int v) const
   {
-return float3(mesh_.mvert[v].co);
+return float3(mesh_.verts()[v].co);
   }
 
   int edge_v1(int e) const
   {
-return mesh_.medge[e].v1;
+return mesh_.edges()[e].v1;
   }
 
   int edge_v2(int e) const
   {
-return mesh_.medge[e].v2;
+return mesh_.edges()[e].v2;
   }
 
   float3 edge_dir_from_vert(int e, int v) const;
@@ -140,14 +140,14 @@ MeshTopology::MeshTopology(const Mesh ) : mesh_(mesh)
 {
   // timeit::ScopedTimer t("MeshTopology construction");
   BKE_mesh_vert_edge_map_create(
-  _edge_map_, _edge_map_mem_, mesh.medge, mesh.totvert, 
mesh.totedge);
+  _edge_map_, _edge_map_mem_, BKE_mesh_edges(), 
mesh.totvert, mesh.totedge);
   BKE_mesh_edge_poly_map_create(_poly_map_,
 _poly_map_mem_,
-mesh.medge,
+BKE_mesh_edges(),
 mesh.totedge,
-mesh.mpoly,
+BKE_mesh_polys(),
 mesh.totpoly,
-mesh.mloop,
+BKE_mesh_loops(),
 mesh.totloop);
 }
 
@@ -172,20 +172,21 @@ int MeshTopology::edge_other_manifold_face(int e, int f) 
const
 
 int MeshTopology::face_other_edge_at_vert(int f, int v, int e) const
 {
-  const MPoly  = mesh_.mpoly[f];
+  const MPoly  = mesh_.polys()[f];
+  Span loops = mesh_.loops();
   const int loopstart = mpoly.loopstart;
   const int loopend = mpoly.loopstart + mpoly.totloop - 1;
   for (int l = loopstart; l <= loopend; l++) {
-const MLoop  = mesh_.mloop[l];
+const MLoop  = loops[l];
 if (mloop.e == e) {
   if (mloop.v == v) {
 /* The other edge with vertex v is the preceding (incoming) edge. */
-MLoop _prev = l == loopstart ? mesh_.mloop[loopend] : 
mesh_.mloop[l - 1];
+const MLoop _prev = l == loopstart ? loops[loopend] : loops[l - 
1];
 return mloop_prev.e;
   }
   else {
 /* The other edge with vertex v is the next (outgoing) edge, which 
should have vertex v. */
-MLoop _next = l == loopend ? mesh_.mloop[loopstart] : 
mesh_.mloop[l + 1];
+const MLoop _next = l == loopend ? loops[loopstart] : loops[l + 
1];
 BLI_assert(mloop_next.v == v);
 return mloop_next.e;
   }
@@ -198,13 +199,14 @@ int MeshTopology::face_other_edge_at_vert(int f, int v, 
int e) const
 
 bool MeshTopology::edge_is_successor_in_face(const int e0, const int e1, const 
int f) const
 {
-  const MPoly  = mesh_.mpoly[f];
+  const MPoly  = mesh_.polys()[f];
   const int loopstart = mpoly.loopstart;
   const int loopend = mpoly.loopstart + mpoly.totloop - 1;
+  Span loops = mesh_.loops();
   for (int l = loopstart; l <= loopend; l++) {
-const MLoop  = mesh_.mloop[l];
+const MLoop  = loops[l];
 if (mloop.e == e0) {
-  const MLoop _next = l == loopend ? mesh_.mloop[loopstart] : 
mesh_.mloop[l + 1];
+  const MLoop _next = l == loopend ? loops[loopstart] : loops[l + 1];
   return mloop_next.e == e1;
 }
   }
@@ -213,7 +215,7 @@ bool MeshTopology::edge_is_successor_in_face(const int e0, 
const int e1, const i
 
 float3 MeshTopology::edge_dir_from_vert(int e, int v) const
 {
-  const MEdge  = mesh_.medge[e];
+  const MEdge  = mesh_.edges()[e];
   if (medge.v1 == v) {
 return vert_co(medge.v2) - vert_co(medge.v1);
   }
@@ -880,7 +882,6 @@ int MeshDelta::new_face(int loopstart, int totloop, int rep)
   MPoly mpoly;
   mpoly.loopstart = loopstart;
   mpoly.totloop = totloop;
-  mpoly.mat_nr = 0;
   mpoly.flag = 0;
   new_polys_.append(mpoly);
   new_poly_rep_.append(rep);
@@ -894,7 +895,7 @@ void MeshDelta::delete_face(int f)
 {
   poly_deletes_.add(f);
   BLI_assert(f >= 0 && f < mesh_.totpoly);
-  const MPoly  = mesh_.mpoly[f];
+  const MPoly  = mesh_.polys()[f];
   for (int l = mpoly.loopstart; l < mpoly.loopstart + mpoly.totloop; l++) {
 loop_deletes_.add(l);
   }
@@ -907,18 +908,18 @@ static std::ostream <<(std::ostream , const 
Mesh *mesh)
   os << "Mesh, totvert=" << mesh->totvert << " totedge=" << mesh->totedge
  << " 

[Bf-blender-cvs] [78d4e63b5f1] temp-T73411-view-layer-lazy-cache: Remove const char name

2022-09-08 Thread Monique
Commit: 78d4e63b5f1e0e1f80b4b25ecf40f85e030a4da8
Author: Monique
Date:   Thu Sep 8 14:31:23 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rB78d4e63b5f1e0e1f80b4b25ecf40f85e030a4da8

Remove const char name

===

M   source/blender/blenkernel/BKE_layer.h
M   source/blender/blenkernel/intern/collection.c
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/blenkernel/intern/layer.c
M   source/blender/blenkernel/intern/layer_utils.c
M   source/blender/blenkernel/intern/mball.cc
M   source/blender/blenkernel/intern/object.cc
M   source/blender/blenkernel/intern/scene.cc
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M   source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   
source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
M   source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
M   source/blender/editors/animation/anim_channels_edit.c
M   source/blender/editors/animation/anim_filter.c
M   source/blender/editors/gpencil/gpencil_armature.c
M   source/blender/editors/object/object_edit.c
M   source/blender/editors/object/object_select.c
M   source/blender/editors/object/object_utils.c
M   source/blender/editors/render/render_internal.cc
M   source/blender/editors/render/render_preview.cc
M   source/blender/editors/screen/screen_context.c
M   source/blender/editors/space_buttons/buttons_context.c
M   source/blender/editors/space_nla/nla_channels.c
M   source/blender/editors/space_outliner/outliner_collections.cc
M   source/blender/editors/space_outliner/outliner_select.cc
M   source/blender/editors/space_outliner/outliner_tools.cc
M   source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/editors/space_view3d/view3d_navigate.c
M   source/blender/editors/space_view3d/view3d_select.cc
M   source/blender/editors/space_view3d/view3d_view.c
M   source/blender/editors/transform/transform_convert_object.c
M   source/blender/editors/transform/transform_gizmo_3d.c
M   source/blender/editors/transform/transform_snap_object.cc
M   source/blender/editors/undo/ed_undo.c
M   source/blender/io/alembic/exporter/abc_subdiv_disabler.cc
M   source/blender/io/collada/BlenderContext.cpp
M   source/blender/io/gpencil/intern/gpencil_io_base.cc
M   source/blender/makesrna/intern/rna_layer.c

===

diff --git a/source/blender/blenkernel/BKE_layer.h 
b/source/blender/blenkernel/BKE_layer.h
index dcef62c1a78..26f22a0b751 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -440,7 +440,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator 
*iter);
 Object *_instance; \
 Base *_base; \
 BKE_view_layer_ensure_sync(scene, view_layer); \
-for (_base = (Base *)BKE_view_layer_object_bases_get(view_layer, 
__func__)->first; _base; \
+for (_base = (Base *)BKE_view_layer_object_bases_get(view_layer)->first; 
_base; \
  _base = _base->next) { \
   _instance = _base->object;
 
@@ -577,7 +577,7 @@ struct Object 
**BKE_view_layer_array_from_objects_in_mode_unique_data(const stru
 struct Object *BKE_view_layer_active_object_get(const struct ViewLayer 
*view_layer);
 struct Object *BKE_view_layer_edit_object_get(const struct ViewLayer 
*view_layer);
 
-struct ListBase *BKE_view_layer_object_bases_get(struct ViewLayer *view_layer, 
const char *name);
+struct ListBase *BKE_view_layer_object_bases_get(struct ViewLayer *view_layer);
 struct Base *BKE_view_layer_active_base_get(struct ViewLayer *view_layer, 
const char *name);
 
 struct LayerCollection *BKE_view_layer_active_collection_get(struct ViewLayer 
*view_layer,
diff --git a/source/blender/blenkernel/intern/collection.c 
b/source/blender/blenkernel/intern/collection.c
index 7d28533a875..afb5f4ef2a6 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -860,7 +860,7 @@ Base *BKE_collection_or_layer_objects(const Scene *scene,
 return BKE_collection_object_cache_get(collection).first;
   }
   BKE_view_layer_ensure_sync(scene, view_layer);
-  return BKE_view_layer_object_bases_get(view_layer, __func__)->first;
+  return BKE_view_layer_object_bases_get(view_layer)->first;
 }
 
 /** \} */
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index d7cb64f8256..d354dfb0939 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -562,7 +562,7 @@ static 

[Bf-blender-cvs] [791d23c1eb1] temp-T73411-view-layer-lazy-cache: Merge branch 'temp-T73411-view-layer-lazy-cache' of git.blender.org:blender into temp-T73411-view-layer-lazy-cache

2022-09-08 Thread Monique
Commit: 791d23c1eb13f07328fa569e0ccdfcd2f232f3dd
Author: Monique
Date:   Thu Sep 8 15:25:24 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rB791d23c1eb13f07328fa569e0ccdfcd2f232f3dd

Merge branch 'temp-T73411-view-layer-lazy-cache' of git.blender.org:blender 
into temp-T73411-view-layer-lazy-cache

===



===

diff --cc source/blender/makesrna/intern/rna_layer.c
index 1b551554b3a,7e51867a819..22d5ead474d
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@@ -50,8 -50,10 +50,10 @@@
  
  static PointerRNA rna_ViewLayer_active_layer_collection_get(PointerRNA *ptr)
  {
+   const Scene *scene = (const Scene *)ptr->owner_id;
ViewLayer *view_layer = (ViewLayer *)ptr->data;
+   BKE_view_layer_ensure_sync(scene, view_layer);
 -  LayerCollection *lc = BKE_view_layer_active_collection_get(view_layer, 
__func__);
 +  LayerCollection *lc = BKE_view_layer_active_collection_get(view_layer);
return rna_pointer_inherit_refine(ptr, _LayerCollection, lc);
  }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7e43934b883] temp-T73411-view-layer-lazy-cache: Remove const char name

2022-09-08 Thread Monique
Commit: 7e43934b8830ae67dc2bf23bddbbaf20bf664388
Author: Monique
Date:   Thu Sep 8 14:43:50 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rB7e43934b8830ae67dc2bf23bddbbaf20bf664388

Remove const char name

===

M   source/blender/blenkernel/BKE_layer.h
M   source/blender/blenkernel/intern/layer_utils.c
M   source/blender/blenkernel/intern/object.cc
M   source/blender/draw/intern/draw_common.c
M   source/blender/editors/armature/armature_select.c
M   source/blender/editors/curve/editcurve.c
M   source/blender/editors/curve/editcurve_select.c
M   source/blender/editors/lattice/editlattice_select.c
M   source/blender/editors/mesh/editmesh_path.c
M   source/blender/editors/mesh/editmesh_polybuild.c
M   source/blender/editors/mesh/editmesh_select.c
M   source/blender/editors/metaball/mball_edit.c
M   source/blender/editors/object/object_add.cc
M   source/blender/editors/object/object_constraint.c
M   source/blender/editors/object/object_hook.c
M   source/blender/editors/object/object_select.c
M   source/blender/editors/space_buttons/buttons_context.c
M   source/blender/editors/space_info/info_stats.cc
M   source/blender/editors/space_outliner/outliner_collections.cc
M   source/blender/editors/space_outliner/outliner_tools.cc
M   source/blender/editors/space_outliner/outliner_tree.cc
M   source/blender/editors/space_view3d/space_view3d.c
M   source/blender/editors/space_view3d/view3d_buttons.c
M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/editors/space_view3d/view3d_gizmo_armature.c
M   source/blender/editors/space_view3d/view3d_gizmo_camera.c
M   source/blender/editors/space_view3d/view3d_gizmo_empty.c
M   source/blender/editors/space_view3d/view3d_gizmo_forcefield.c
M   source/blender/editors/space_view3d/view3d_gizmo_light.c
M   source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
M   source/blender/editors/space_view3d/view3d_select.cc
M   source/blender/editors/transform/transform_generics.c
M   source/blender/editors/transform/transform_gizmo_3d.c
M   source/blender/editors/transform/transform_snap.c
M   source/blender/editors/transform/transform_snap_object.cc
M   source/blender/editors/undo/ed_undo.c
M   source/blender/makesrna/intern/rna_layer.c

===

diff --git a/source/blender/blenkernel/BKE_layer.h 
b/source/blender/blenkernel/BKE_layer.h
index 26f22a0b751..48f1b50a89d 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -372,7 +372,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator 
*iter);
 data_.view_layer = _view_layer; \
 data_.v3d = _v3d; \
 BKE_view_layer_ensure_sync(_scene, _view_layer); \
-data_.base_active = BKE_view_layer_active_base_get(_view_layer, __func__); 
\
+data_.base_active = BKE_view_layer_active_base_get(_view_layer); \
 ITER_BEGIN (BKE_view_layer_bases_in_mode_iterator_begin, \
 BKE_view_layer_bases_in_mode_iterator_next, \
 BKE_view_layer_bases_in_mode_iterator_end, \
@@ -578,10 +578,9 @@ struct Object *BKE_view_layer_active_object_get(const 
struct ViewLayer *view_lay
 struct Object *BKE_view_layer_edit_object_get(const struct ViewLayer 
*view_layer);
 
 struct ListBase *BKE_view_layer_object_bases_get(struct ViewLayer *view_layer);
-struct Base *BKE_view_layer_active_base_get(struct ViewLayer *view_layer, 
const char *name);
+struct Base *BKE_view_layer_active_base_get(struct ViewLayer *view_layer);
 
-struct LayerCollection *BKE_view_layer_active_collection_get(struct ViewLayer 
*view_layer,
- const char *name);
+struct LayerCollection *BKE_view_layer_active_collection_get(struct ViewLayer 
*view_layer);
 
 void BKE_view_layer_tag_out_of_sync(struct ViewLayer *view_layer);
 void BKE_view_layer_ensure_sync(const struct Scene *scene, struct ViewLayer 
*view_layer);
diff --git a/source/blender/blenkernel/intern/layer_utils.c 
b/source/blender/blenkernel/intern/layer_utils.c
index e98969d33ee..c13d27b2fff 100644
--- a/source/blender/blenkernel/intern/layer_utils.c
+++ b/source/blender/blenkernel/intern/layer_utils.c
@@ -217,20 +217,20 @@ struct Object 
**BKE_view_layer_array_from_objects_in_mode_unique_data(const Scen
 
 struct ListBase *BKE_view_layer_object_bases_get(struct ViewLayer *view_layer)
 {
-  BLI_assert_msg((view_layer->flag & VIEW_LAYER_OUT_OF_SYNC) == 0, "Object 
Bases out of sync");
+  BLI_assert_msg((view_layer->flag & VIEW_LAYER_OUT_OF_SYNC) == 0, "Object 
Bases out of sync.");
   return _layer->object_bases;
 }
 
-struct Base *BKE_view_layer_active_base_get(struct ViewLayer *view_layer, 
const char *name)
+struct Base 

[Bf-blender-cvs] [5b259f801ff] temp-T73411-view-layer-lazy-cache: Fix import PLY.

2022-09-08 Thread Jeroen Bakker
Commit: 5b259f801ffb3e6181ee95f3ce526a35a5b3666f
Author: Jeroen Bakker
Date:   Thu Sep 8 15:17:53 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rB5b259f801ffb3e6181ee95f3ce526a35a5b3666f

Fix import PLY.

===

M   source/blender/makesrna/intern/rna_layer.c

===

diff --git a/source/blender/makesrna/intern/rna_layer.c 
b/source/blender/makesrna/intern/rna_layer.c
index aea91f9d62f..7e51867a819 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -50,7 +50,9 @@
 
 static PointerRNA rna_ViewLayer_active_layer_collection_get(PointerRNA *ptr)
 {
+  const Scene *scene = (const Scene *)ptr->owner_id;
   ViewLayer *view_layer = (ViewLayer *)ptr->data;
+  BKE_view_layer_ensure_sync(scene, view_layer);
   LayerCollection *lc = BKE_view_layer_active_collection_get(view_layer, 
__func__);
   return rna_pointer_inherit_refine(ptr, _LayerCollection, lc);
 }
@@ -59,8 +61,10 @@ static void 
rna_ViewLayer_active_layer_collection_set(PointerRNA *ptr,
   PointerRNA value,
   struct ReportList 
*UNUSED(reports))
 {
+  const Scene *scene = (const Scene *)ptr->owner_id;
   ViewLayer *view_layer = (ViewLayer *)ptr->data;
   LayerCollection *lc = (LayerCollection *)value.data;
+  BKE_view_layer_ensure_sync(scene, view_layer);
   const int index = BKE_layer_collection_findindex(view_layer, lc);
   if (index != -1) {
 BKE_layer_collection_activate(view_layer, lc);
@@ -69,7 +73,9 @@ static void 
rna_ViewLayer_active_layer_collection_set(PointerRNA *ptr,
 
 static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr)
 {
+  const Scene *scene = (Scene *)ptr->owner_id;
   ViewLayer *view_layer = (ViewLayer *)ptr->data;
+  BKE_view_layer_ensure_sync(scene, view_layer);
   return rna_pointer_inherit_refine(
   ptr, _Object, BKE_view_layer_active_object_get(view_layer));
 }
@@ -78,9 +84,11 @@ static void rna_LayerObjects_active_object_set(PointerRNA 
*ptr,
PointerRNA value,
struct ReportList *reports)
 {
+  const Scene *scene = (Scene *)ptr->owner_id;
   ViewLayer *view_layer = (ViewLayer *)ptr->data;
   if (value.data) {
 Object *ob = value.data;
+BKE_view_layer_ensure_sync(scene, view_layer);
 Base *basact_test = BKE_view_layer_base_find(view_layer, ob);
 if (basact_test != NULL) {
   view_layer->basact = basact_test;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ee2fc1eb773] cycles_path_guiding: Guiding: Added option to enable deterministic path guiding

2022-09-08 Thread Sebastian Herholz
Commit: ee2fc1eb7730c48b3880c0366449f43760ad6a05
Author: Sebastian Herholz
Date:   Thu Sep 8 14:25:26 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rBee2fc1eb7730c48b3880c0366449f43760ad6a05

Guiding: Added option to enable deterministic path guiding

This commits enables to run the training of the guiding caches in a 
deterministic way.
As a result two individual renderings should result in exactly the same image.
Note: this option can increase the training time by 5-10%.

===

M   intern/cycles/blender/addon/properties.py
M   intern/cycles/blender/addon/ui.py
M   intern/cycles/blender/sync.cpp
M   intern/cycles/integrator/guiding.h
M   intern/cycles/integrator/path_trace.cpp
M   intern/cycles/integrator/path_trace.h
M   intern/cycles/integrator/render_scheduler.cpp
M   intern/cycles/integrator/render_scheduler.h
M   intern/cycles/scene/integrator.cpp
M   intern/cycles/scene/integrator.h

===

diff --git a/intern/cycles/blender/addon/properties.py 
b/intern/cycles/blender/addon/properties.py
index bc913f4c2c6..3afb27a1ac7 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -521,6 +521,14 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
 default=False,
 )
 
+deterministic_guiding: BoolProperty(
+name="Deterministic",
+description="Makes path guiding deterministic which means renderings 
will be"
+"reproducable (i.e., same pixel noise/value). This feature increases 
the"
+"compute time during training",
+default=False,
+)
+
 guiding_distribution_type: EnumProperty(
 name="Guiding Distribution Type",
 description="Type of representation for the guiding distribution",
diff --git a/intern/cycles/blender/addon/ui.py 
b/intern/cycles/blender/addon/ui.py
index cfccbb9edb9..5181a41e993 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -349,6 +349,7 @@ class 
CYCLES_RENDER_PT_sampling_path_guiding(CyclesButtonsPanel, Panel):
 layout.active = cscene.use_guiding
 
 col = layout.column(align=True)
+col.prop(cscene, "deterministic_guiding", text="Deterministic")
 col.prop(cscene, "use_surface_guiding", text="Surface Guiding")
 col.prop(cscene, "use_volume_guiding", text="Volume Guiding")
 col.prop(cscene, "training_iterations", text="Training Iterations")
diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp
index b1e66f2ee3b..8e7d9e31c68 100644
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@ -414,6 +414,7 @@ void BlenderSync::sync_integrator(BL::ViewLayer 
_view_layer, bool background)
 #endif
 
   integrator->set_use_guiding(get_boolean(cscene, "use_guiding"));
+  integrator->set_deterministic_guiding(get_boolean(cscene, 
"deterministic_guiding"));
   integrator->set_use_surface_guiding(get_boolean(cscene, 
"use_surface_guiding"));
   integrator->set_use_volume_guiding(get_boolean(cscene, 
"use_volume_guiding"));
   integrator->set_training_iterations(get_int(cscene, "training_iterations"));
diff --git a/intern/cycles/integrator/guiding.h 
b/intern/cycles/integrator/guiding.h
index a1c6139567c..9bb87b88b23 100644
--- a/intern/cycles/integrator/guiding.h
+++ b/intern/cycles/integrator/guiding.h
@@ -11,12 +11,14 @@ struct GuidingParams {
   bool use = false;
   GuidingDistributionType type = GUIDING_TYPE_PARALLAX_AWARE_VMM;
   int training_iterations = 128;
+  bool deterministic = false;
   GuidingParams() = default;
 
   bool modified(const GuidingParams ) const
   {
 return !((use == other.use) && (type == other.type) &&
- (training_iterations == other.training_iterations));
+ (training_iterations == other.training_iterations) &&
+ (deterministic == other.deterministic));
   }
 };
 
diff --git a/intern/cycles/integrator/path_trace.cpp 
b/intern/cycles/integrator/path_trace.cpp
index 069fda92a53..2ee8718d4de 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -1288,7 +1288,9 @@ void PathTrace::set_guiding_params(const GuidingParams 
_params, const bo
   break;
 }
   }
-
+#  if OPENPGL_VERSION_MINOR >= 4
+  field_args.deterministic = guiding_params.deterministic;
+#  endif
   openpgl::cpp::Device *guiding_device = static_cast(
   device_->get_guiding_device());
   if (guiding_device) {
@@ -1323,9 +1325,11 @@ void PathTrace::guiding_prepare_structures()
   if ((guiding_params_.training_iterations == -1) ||
   (guiding_field_->GetIteration() < guiding_params_.training_iterations)) {
 device_scene_->data.integrator.train_guiding = true;
+render_scheduler_.set_limit_spp_for_guiding(true);
   }
   else {
 

[Bf-blender-cvs] [e262e4f2896] cycles_path_guiding: Guiding: Added support to handle different Open PGL versions

2022-09-08 Thread Sebastian Herholz
Commit: e262e4f2896d2c74bd3235930a4673690306a635
Author: Sebastian Herholz
Date:   Wed Sep 7 13:53:37 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rBe262e4f2896d2c74bd3235930a4673690306a635

Guiding: Added support to handle different Open PGL versions

===

M   intern/cycles/integrator/path_trace.cpp
M   intern/cycles/integrator/path_trace.h

===

diff --git a/intern/cycles/integrator/path_trace.cpp 
b/intern/cycles/integrator/path_trace.cpp
index fdcf1490614..069fda92a53 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -1333,14 +1333,12 @@ void PathTrace::guiding_prepare_structures()
 void PathTrace::guiding_update_structures()
 {
 #ifdef WITH_PATH_GUIDING
-  // TODO(sherholz): implement
 #  ifdef WITH_PATH_GUIDING_DEBUG_PRINT
   VLOG_WORK << "Path Guiding: update guiding structures";
   VLOG_WORK << "SampleDataStrorage: #surface samples = "
 << guiding_sample_data_storage_->GetSizeSurface()
 << "\t#volumesamples = " << 
guiding_sample_data_storage_->GetSizeVolume();
 #  endif
-  // int training_iteration = guiding_field_->GetIteration();
   if (true) {
 const size_t num_valid_samples = 
guiding_sample_data_storage_->GetSizeSurface() +
  
guiding_sample_data_storage_->GetSizeVolume();
@@ -1361,14 +1359,16 @@ void PathTrace::guiding_update_structures()
   }
 }
   */
+#if OPENPGL_VERSION_MINOR < 4
   const size_t num_samples = 1;
   guiding_field_->Update(*guiding_sample_data_storage_, num_samples);
+#else
+  guiding_field_->Update(*guiding_sample_data_storage_);
+#endif
   guiding_update_count++;
 #  if defined(WITH_PATH_GUIDING_DEBUG_PRINT) && PATH_GUIDING_DEBUG_VALIDATE
   VLOG_WORK << "Field: valid = " << guiding_field_->Validate();
 #  endif
-  // if(guiding_update_count<=1)
-
   guiding_sample_data_storage_->Clear();
 }
   }
diff --git a/intern/cycles/integrator/path_trace.h 
b/intern/cycles/integrator/path_trace.h
index fe823d73612..59a0ef6d742 100644
--- a/intern/cycles/integrator/path_trace.h
+++ b/intern/cycles/integrator/path_trace.h
@@ -17,6 +17,7 @@
 #include "util/vector.h"
 
 #ifdef WITH_PATH_GUIDING
+#  include 
 #  include 
 #endif

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b5fc8f611e3] master: Outliner: Hide ID type filter for library overrides

2022-09-08 Thread Julian Eisel
Commit: b5fc8f611e3948a19c26d425496d76079506f480
Author: Julian Eisel
Date:   Thu Sep 8 14:19:59 2022 +0200
Branches: master
https://developer.blender.org/rBb5fc8f611e3948a19c26d425496d76079506f480

Outliner: Hide ID type filter for library overrides

a) There were two filter icons next to each other in the header which
isn't exactly professional, b) the filter was redundant since IDs are
now grouped under an ID type element ("Objects", "Collection", ...)
anyway.
In the hierarchies view it was already hidden (because the whole point
of it is to show relationships between IDs, you wouldn't want to have
any parts of the hierarchy hidden).

===

M   release/scripts/startup/bl_ui/space_outliner.py

===

diff --git a/release/scripts/startup/bl_ui/space_outliner.py 
b/release/scripts/startup/bl_ui/space_outliner.py
index e3dfb5ffa61..ec0ad401f5a 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -53,11 +53,8 @@ class OUTLINER_HT_header(Header):
 text="",
 icon='FILTER',
 )
-if display_mode == 'LIBRARY_OVERRIDES' and 
space.lib_override_view_mode == 'HIERARCHIES':
-# Don't add ID type filter for library overrides hierarchies mode. 
Point of it is to see a hierarchy that is
-# usually constructed out of different ID types.
-pass
-elif display_mode in {'LIBRARIES', 'LIBRARY_OVERRIDES', 'ORPHAN_DATA'}:
+
+if display_mode in {'LIBRARIES' 'ORPHAN_DATA'}:
 row.prop(space, "use_filter_id_type", text="", icon='FILTER')
 sub = row.row(align=True)
 sub.active = space.use_filter_id_type

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2a769e76a09] master: Outliner: Hide search options for library overrides hierarchies view

2022-09-08 Thread Julian Eisel
Commit: 2a769e76a09b55dcbd21bc7c6660092e09c63f00
Author: Julian Eisel
Date:   Thu Sep 8 14:10:58 2022 +0200
Branches: master
https://developer.blender.org/rB2a769e76a09b55dcbd21bc7c6660092e09c63f00

Outliner: Hide search options for library overrides hierarchies view

Searching isn't possible in the hierarchies view anymore, so the options
for it shouldn't be displayed either.
Followup to 21b92a5f31a4, forgot to remove these.

===

M   release/scripts/startup/bl_ui/space_outliner.py

===

diff --git a/release/scripts/startup/bl_ui/space_outliner.py 
b/release/scripts/startup/bl_ui/space_outliner.py
index 6dcbef6aa56..e3dfb5ffa61 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -401,14 +401,19 @@ class OUTLINER_PT_filter(Panel):
 row.prop(space, "show_mode_column", text="Show Mode Column")
 layout.separator()
 
-col = layout.column(align=True)
-col.label(text="Search")
-col.prop(space, "use_filter_complete", text="Exact Match")
-col.prop(space, "use_filter_case_sensitive", text="Case Sensitive")
+filter_text_supported = True
+# Same exception for library overrides as in OUTLINER_HT_header.
+if display_mode == 'LIBRARY_OVERRIDES' and 
space.lib_override_view_mode == 'HIERARCHIES':
+filter_text_supported = False
+
+if filter_text_supported:
+col = layout.column(align=True)
+col.label(text="Search")
+col.prop(space, "use_filter_complete", text="Exact Match")
+col.prop(space, "use_filter_case_sensitive", text="Case Sensitive")
 
 if display_mode == 'LIBRARY_OVERRIDES' and 
space.lib_override_view_mode == 'PROPERTIES' and bpy.data.libraries:
-col.separator()
-row = col.row()
+row = layout.row()
 row.label(icon='LIBRARY_DATA_OVERRIDE')
 row.prop(space, "use_filter_lib_override_system", text="System 
Overrides")

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [21b92a5f31a] master: Outliner: Hide search button for library overrides hierarchies view

2022-09-08 Thread Julian Eisel
Commit: 21b92a5f31a45ff93ee3c989a6c6109c69482d48
Author: Julian Eisel
Date:   Thu Sep 8 12:47:23 2022 +0200
Branches: master
https://developer.blender.org/rB21b92a5f31a45ff93ee3c989a6c6109c69482d48

Outliner: Hide search button for library overrides hierarchies view

c9a996790307 added a workaround for performance issues in heavy
production scenes in the library overrides hierarchies view, reducing
the amounts of elements to be built. Searching for elements would still
have to build the entire tree, so Blender would essentially freeze when
searching in mentioned heavy scenes. Removing the search functionality
works around this issue for now.

===

M   release/scripts/startup/bl_ui/space_outliner.py

===

diff --git a/release/scripts/startup/bl_ui/space_outliner.py 
b/release/scripts/startup/bl_ui/space_outliner.py
index dc4eea13ce3..6dcbef6aa56 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -30,8 +30,15 @@ class OUTLINER_HT_header(Header):
 
 layout.separator_spacer()
 
-row = layout.row(align=True)
-row.prop(space, "filter_text", icon='VIEWZOOM', text="")
+filter_text_supported = True
+# No text filtering for library override hierarchies. The tree is lazy 
built to avoid
+# performance issues in complex files.
+if display_mode == 'LIBRARY_OVERRIDES' and 
space.lib_override_view_mode == 'HIERARCHIES':
+filter_text_supported = False
+
+if filter_text_supported:
+row = layout.row(align=True)
+row.prop(space, "filter_text", icon='VIEWZOOM', text="")
 
 layout.separator_spacer()

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d481fb10efb] master: Nodes: fix handling cyclic node trees

2022-09-08 Thread Jacques Lucke
Commit: d481fb10efb9f20094330766b562a77c643a15b0
Author: Jacques Lucke
Date:   Thu Sep 8 12:53:43 2022 +0200
Branches: master
https://developer.blender.org/rBd481fb10efb9f20094330766b562a77c643a15b0

Nodes: fix handling cyclic node trees

===

M   source/blender/blenkernel/intern/node_runtime.cc

===

diff --git a/source/blender/blenkernel/intern/node_runtime.cc 
b/source/blender/blenkernel/intern/node_runtime.cc
index 0c78c0f09d1..a8281820a0b 100644
--- a/source/blender/blenkernel/intern/node_runtime.cc
+++ b/source/blender/blenkernel/intern/node_runtime.cc
@@ -258,6 +258,7 @@ static void toposort_from_start_node(const 
ToposortDirection direction,
 
   Stack nodes_to_check;
   nodes_to_check.push({_node});
+  node_states[start_node.runtime->index_in_tree].is_in_stack = true;
   while (!nodes_to_check.is_empty()) {
 Item  = nodes_to_check.peek();
 bNode  = *item.node;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5e2d139ee30] master: Fix Blender as a Python module for WIN32

2022-09-08 Thread Campbell Barton
Commit: 5e2d139ee30d88b474d3e7d65d5ff37d0be086b6
Author: Campbell Barton
Date:   Thu Sep 8 20:27:03 2022 +1000
Branches: master
https://developer.blender.org/rB5e2d139ee30d88b474d3e7d65d5ff37d0be086b6

Fix Blender as a Python module for WIN32

BKE_appdir_program_path_init would override the module path extracted
from the Python module, replacing it with the Python executable.

This caused the data files not to be found and the module not to load.

===

M   source/blender/blenkernel/BKE_appdir.h
M   source/blender/blenkernel/intern/appdir.c
M   source/creator/creator.c

===

diff --git a/source/blender/blenkernel/BKE_appdir.h 
b/source/blender/blenkernel/BKE_appdir.h
index dcacc2ca7b3..16488bdbf09 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -105,8 +105,11 @@ void BKE_appdir_app_templates(struct ListBase *templates);
 
 /**
  * Initialize path to program executable.
+ *
+ * \param strict: When true, use `argv0` unmodified (besides making absolute & 
normalizing).
+ * Otherwise other methods may be used to find the program path, including 
searching `$PATH`.
  */
-void BKE_appdir_program_path_init(const char *argv0);
+void BKE_appdir_program_path_init(const char *argv0, bool strict);
 
 /**
  * Path to executable
diff --git a/source/blender/blenkernel/intern/appdir.c 
b/source/blender/blenkernel/intern/appdir.c
index 031d3647878..c19afdb4fb8 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -794,11 +794,11 @@ const char *BKE_appdir_folder_id_version(const int 
folder_id,
  * (must be #FILE_MAX minimum)
  * \param name: The name of the executable (usually `argv[0]`) to be checked
  */
-static void where_am_i(char *fullname, const size_t maxlen, const char *name)
+static void where_am_i(char *fullname, const size_t maxlen, const char *name, 
const bool strict)
 {
 #ifdef WITH_BINRELOC
   /* Linux uses `binreloc` since `argv[0]` is not reliable, call 
`br_init(NULL)` first. */
-  {
+  if (!strict) {
 const char *path = NULL;
 path = br_find_exe(NULL);
 if (path) {
@@ -810,7 +810,7 @@ static void where_am_i(char *fullname, const size_t maxlen, 
const char *name)
 #endif
 
 #ifdef _WIN32
-  {
+  if (!strict) {
 wchar_t *fullname_16 = MEM_mallocN(maxlen * sizeof(wchar_t), 
"ProgramPath");
 if (GetModuleFileNameW(0, fullname_16, maxlen)) {
   conv_utf_16_to_8(fullname_16, fullname, maxlen);
@@ -834,18 +834,24 @@ static void where_am_i(char *fullname, const size_t 
maxlen, const char *name)
 if (name[0] == '.') {
   BLI_path_abs_from_cwd(fullname, maxlen);
 #ifdef _WIN32
-  BLI_path_program_extensions_add_win32(fullname, maxlen);
+  if (!strict) {
+BLI_path_program_extensions_add_win32(fullname, maxlen);
+  }
 #endif
 }
 else if (BLI_path_slash_rfind(name)) {
   /* Full path. */
   BLI_strncpy(fullname, name, maxlen);
 #ifdef _WIN32
-  BLI_path_program_extensions_add_win32(fullname, maxlen);
+  if (!strict) {
+BLI_path_program_extensions_add_win32(fullname, maxlen);
+  }
 #endif
 }
 else {
-  BLI_path_program_search(fullname, maxlen, name);
+  if (!strict) {
+BLI_path_program_search(fullname, maxlen, name);
+  }
 }
 /* Remove "/./" and "/../" so string comparisons can be used on the path. 
*/
 BLI_path_normalize(NULL, fullname);
@@ -858,9 +864,9 @@ static void where_am_i(char *fullname, const size_t maxlen, 
const char *name)
   }
 }
 
-void BKE_appdir_program_path_init(const char *argv0)
+void BKE_appdir_program_path_init(const char *argv0, const bool strict)
 {
-  where_am_i(g_app.program_filepath, sizeof(g_app.program_filepath), argv0);
+  where_am_i(g_app.program_filepath, sizeof(g_app.program_filepath), argv0, 
strict);
   BLI_split_dir_part(g_app.program_filepath, g_app.program_dirname, 
sizeof(g_app.program_dirname));
 }
 
diff --git a/source/creator/creator.c b/source/creator/creator.c
index e7a803d383f..e7e9eeed79a 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -233,6 +233,12 @@ void gmp_blender_init_allocator()
 /** \name Main Function
  * \{ */
 
+/* When building as a Python module, don't use special argument handling
+ * so the module loading logic can control the `argv` & `argc`. */
+#if defined(WIN32) && !defined(WITH_PYTHON_MODULE)
+#  define USE_WIN32_UNICODE_ARGS
+#endif
+
 /**
  * Blender's main function responsibilities are:
  * - setup subsystems.
@@ -241,7 +247,7 @@ void gmp_blender_init_allocator()
  *   or exit immediately when running in background-mode.
  */
 int main(int argc,
-#ifdef WIN32
+#ifdef USE_WIN32_UNICODE_ARGS
  const char **UNUSED(argv_c)
 #else
  const char **argv
@@ -254,7 +260,7 @@ int main(int argc,
   bArgs *ba;
 #endif
 
-#ifdef WIN32
+#ifdef 

[Bf-blender-cvs] [82fc52ffc88] master: Console: Support page up/down and home keys for scrolling

2022-09-08 Thread Julian Eisel
Commit: 82fc52ffc88142e0fa29335e07595c87c173a3a6
Author: Julian Eisel
Date:   Thu Sep 8 12:17:38 2022 +0200
Branches: master
https://developer.blender.org/rB82fc52ffc88142e0fa29335e07595c87c173a3a6

Console: Support page up/down and home keys for scrolling

- Page up/down scrolls up/down an entire page
- Home resets the scrolling back to the bottom.

The fact that these were missing was probably an oversight. Other
similar editors have them.

This works by including the "View2D Buttons List" keymap for the
console, which the other similar editors use as well.

===

M   source/blender/editors/space_console/space_console.c

===

diff --git a/source/blender/editors/space_console/space_console.c 
b/source/blender/editors/space_console/space_console.c
index 417c65eb01a..a7ab6bc5169 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -121,6 +121,9 @@ static void console_main_region_init(wmWindowManager *wm, 
ARegion *region)
 region->v2d.cur.ymax = prev_y_min + cur_y_range;
   }
 
+  keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0);
+  WM_event_add_keymap_handler(>handlers, keymap);
+
   /* own keymap */
   keymap = WM_keymap_ensure(wm->defaultconf, "Console", SPACE_CONSOLE, 0);
   WM_event_add_keymap_handler_v2d_mask(>handlers, keymap);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [129993c026e] master: Fix T100887: Some C++ importers/exporters (e.g. OBJ) reset file dialog Sort By mode

2022-09-08 Thread Aras Pranckevicius
Commit: 129993c026e910b83b8bc7f0a394f7a4748a2cac
Author: Aras Pranckevicius
Date:   Thu Sep 8 13:07:31 2022 +0300
Branches: master
https://developer.blender.org/rB129993c026e910b83b8bc7f0a394f7a4748a2cac

Fix T100887: Some C++ importers/exporters (e.g. OBJ) reset file dialog Sort By 
mode

A couple years ago D8598 made it so that C++ operators generally
should use "default" sort mode, which remembers previously used sort
setting. Back then all the places that needed it got changed to use
this "default" one, but since then some more IO code landed, where
seemingly by accident it used "sort by file name":

- USD importer,
- Grease Pencil exporter,
- OBJ importer & exporter,
- STL importer.

Reviewed By: Julian Eisel
Differential Revision: https://developer.blender.org/D15906

===

M   source/blender/editors/io/io_gpencil_export.c
M   source/blender/editors/io/io_obj.c
M   source/blender/editors/io/io_stl_ops.c
M   source/blender/editors/io/io_usd.c

===

diff --git a/source/blender/editors/io/io_gpencil_export.c 
b/source/blender/editors/io/io_gpencil_export.c
index 12d87113a66..662a372b608 100644
--- a/source/blender/editors/io/io_gpencil_export.c
+++ b/source/blender/editors/io/io_gpencil_export.c
@@ -217,7 +217,7 @@ void WM_OT_gpencil_export_svg(wmOperatorType *ot)
  FILE_SAVE,
  WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
  FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
 
   gpencil_export_common_props_definition(ot);
 
@@ -375,7 +375,7 @@ void WM_OT_gpencil_export_pdf(wmOperatorType *ot)
  FILE_SAVE,
  WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
  FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
 
   static const EnumPropertyItem gpencil_export_frame_items[] = {
   {GP_EXPORT_FRAME_ACTIVE, "ACTIVE", 0, "Active", "Include only active 
frame"},
diff --git a/source/blender/editors/io/io_obj.c 
b/source/blender/editors/io/io_obj.c
index ef68a15933f..66e95c019f6 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -266,7 +266,7 @@ void WM_OT_obj_export(struct wmOperatorType *ot)
  FILE_SAVE,
  WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
  FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
 
   /* Animation options. */
   RNA_def_boolean(ot->srna,
@@ -494,7 +494,7 @@ void WM_OT_obj_import(struct wmOperatorType *ot)
  WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS |
  WM_FILESEL_DIRECTORY | WM_FILESEL_FILES,
  FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
   RNA_def_float(
   ot->srna,
   "clamp_size",
diff --git a/source/blender/editors/io/io_stl_ops.c 
b/source/blender/editors/io/io_stl_ops.c
index 858ea131577..c98e5beaf3b 100644
--- a/source/blender/editors/io/io_stl_ops.c
+++ b/source/blender/editors/io/io_stl_ops.c
@@ -104,7 +104,7 @@ void WM_OT_stl_import(struct wmOperatorType *ot)
  WM_FILESEL_FILEPATH | WM_FILESEL_FILES | 
WM_FILESEL_DIRECTORY |
  WM_FILESEL_SHOW_PROPS,
  FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
 
   RNA_def_float(ot->srna, "global_scale", 1.0f, 1e-6f, 1e6f, "Scale", "", 
0.001f, 1000.0f);
   RNA_def_boolean(ot->srna,
diff --git a/source/blender/editors/io/io_usd.c 
b/source/blender/editors/io/io_usd.c
index 74ce0cca16c..ba118a5e289 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -487,7 +487,7 @@ void WM_OT_usd_import(struct wmOperatorType *ot)
  FILE_OPENFILE,
  WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | 
WM_FILESEL_SHOW_PROPS,
  FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
 
   RNA_def_float(
   ot->srna,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4b8ae5fa1b6] temp-T73411-view-layer-lazy-cache: Remove redundant ensure, added (missed) ensure

2022-09-08 Thread Monique
Commit: 4b8ae5fa1b663571780709718415b48cdf10
Author: Monique
Date:   Thu Sep 8 11:20:41 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rB4b8ae5fa1b663571780709718415b48cdf10

Remove redundant ensure, added (missed) ensure

===

M   source/blender/editors/screen/screen_context.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c

===

diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 1648f1e94da..6d132620f1f 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -233,7 +233,6 @@ static eContextResult 
screen_ctx_objects_in_mode_unique_data(const bContext *C,
   Scene *scene = CTX_data_scene(C);
   ViewLayer *view_layer = WM_window_get_active_view_layer(win);
   BKE_view_layer_ensure_sync(scene, view_layer);
-  BKE_view_layer_ensure_sync(scene, view_layer);
   Object *obact = BKE_view_layer_active_object_get(view_layer);
 
   if (obact && (obact->mode != OB_MODE_OBJECT)) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c 
b/source/blender/editors/sculpt_paint/sculpt_undo.c
index c586576d7ef..7fee0c5f6bb 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -399,7 +399,9 @@ static bool sculpt_undo_restore_hidden(bContext *C, 
SculptUndoNode *unode, bool
 
 static bool sculpt_undo_restore_color(bContext *C, SculptUndoNode *unode, bool 
*modified_vertices)
 {
+  const Scene *scene = CTX_data_scene(C);
   ViewLayer *view_layer = CTX_data_view_layer(C);
+  BKE_view_layer_ensure_sync(scene, view_layer);
   Object *ob = BKE_view_layer_active_object_get(view_layer);
   SculptSession *ss = ob->sculpt;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fc5ea738f4e] temp-T73411-view-layer-lazy-cache: Merge branch 'temp-T73411-view-layer-lazy-cache' of git.blender.org:blender into temp-T73411-view-layer-lazy-cache

2022-09-08 Thread Monique
Commit: fc5ea738f4e900cbe91d33480210cfc9273ea280
Author: Monique
Date:   Thu Sep 8 11:57:56 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rBfc5ea738f4e900cbe91d33480210cfc9273ea280

Merge branch 'temp-T73411-view-layer-lazy-cache' of git.blender.org:blender 
into temp-T73411-view-layer-lazy-cache

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fc0e7062d72] temp-T73411-view-layer-lazy-cache: Remove todos

2022-09-08 Thread Monique
Commit: fc0e7062d720a1d01e23aec42df03a97754000fe
Author: Monique
Date:   Thu Sep 8 10:56:58 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rBfc0e7062d720a1d01e23aec42df03a97754000fe

Remove todos

===

M   source/blender/blenloader/intern/readfile.c
M   source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
M   source/blender/makesrna/intern/rna_layer.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index ff10d0a59b5..863f978daaf 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2468,7 +2468,6 @@ static void lib_link_window_scene_data_restore(wmWindow 
*win, Scene *scene, View
 
   /* Local-view can become invalid during undo/redo steps,
* so we exit it when no could be found. */
-  // TODO: Use BKE_view_layer_object_bases_get here?
   for (base = view_layer->object_bases.first; base; base = base->next) 
{
 if (base->local_view_bits & v3d->local_view_uuid) {
   break;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc 
b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index b800897b8c9..4fc0f5b94d8 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -456,7 +456,7 @@ void view_layer_update_orig_base_pointers(const ViewLayer 
*view_layer_orig,
 /* Happens when scene is only used for parameters or compositor/sequencer. 
*/
 return;
   }
-  // TODO: BKE_view_layer_object_bases_get this should be fine, but check just 
in case.
+
   Base *base_orig = reinterpret_cast(view_layer_orig->object_bases.first);
   LISTBASE_FOREACH (Base *, base_eval, _layer_eval->object_bases) {
 base_eval->base_orig = base_orig;
diff --git a/source/blender/makesrna/intern/rna_layer.c 
b/source/blender/makesrna/intern/rna_layer.c
index dc1191293b7..bdd5b822db8 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -564,7 +564,6 @@ void RNA_def_view_layer(BlenderRNA *brna)
   prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
   RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL);
   RNA_def_property_struct_type(prop, "Object");
-  // TODO: Use BKE_view_layer_object_bases_get?
   RNA_def_property_collection_funcs(
   prop, NULL, NULL, NULL, "rna_ViewLayer_objects_get", NULL, NULL, NULL, 
NULL);
   RNA_def_property_ui_text(prop, "Objects", "All the objects in this layer");

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c4b7bb1c908] temp-T73411-view-layer-lazy-cache: Formatting

2022-09-08 Thread Monique
Commit: c4b7bb1c908a567e91413fabe26687badeb8c51c
Author: Monique
Date:   Thu Sep 8 11:04:43 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rBc4b7bb1c908a567e91413fabe26687badeb8c51c

Formatting

===

M   source/blender/editors/transform/transform_generics.c

===

diff --git a/source/blender/editors/transform/transform_generics.c 
b/source/blender/editors/transform/transform_generics.c
index 9b58f412eb1..98c56b3545e 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1085,7 +1085,7 @@ bool calculateCenterActive(TransInfo *t, bool 
select_only, float r_center[3])
   }
   else {
 /* object mode */
-  BKE_view_layer_ensure_sync(t->scene, t->view_layer);
+BKE_view_layer_ensure_sync(t->scene, t->view_layer);
 Base *base = BKE_view_layer_active_base_get(t->view_layer, __func__);
 if (base && ((!select_only) || ((base->flag & BASE_SELECTED) != 0))) {
   copy_v3_v3(r_center, base->object->obmat[3]);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ba64e99bf04] temp-T73411-view-layer-lazy-cache: Add ensure_sync before BKE_view_layer_base_find.

2022-09-08 Thread Jeroen Bakker
Commit: ba64e99bf0440f37cbcee094b48502d00949e492
Author: Jeroen Bakker
Date:   Thu Sep 8 11:52:02 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rBba64e99bf0440f37cbcee094b48502d00949e492

Add ensure_sync before BKE_view_layer_base_find.

===

M   source/blender/blenkernel/BKE_collection.h
M   source/blender/blenkernel/BKE_layer.h
M   source/blender/blenkernel/BKE_object.h
M   source/blender/blenkernel/intern/blendfile_link_append.c
M   source/blender/blenkernel/intern/collection.c
M   source/blender/blenkernel/intern/context.c
M   source/blender/blenkernel/intern/layer.c
M   source/blender/blenkernel/intern/lib_override.cc
M   source/blender/blenkernel/intern/object.cc
M   source/blender/blenkernel/intern/rigidbody.c
M   source/blender/editors/animation/anim_markers.c
M   source/blender/editors/gpencil/gpencil_convert.c
M   source/blender/editors/include/ED_transform.h
M   source/blender/editors/interface/interface_ops.cc
M   source/blender/editors/mesh/editmesh_select.c
M   source/blender/editors/object/object_add.cc
M   source/blender/editors/object/object_bake_api.c
M   source/blender/editors/object/object_edit.c
M   source/blender/editors/object/object_modes.c
M   source/blender/editors/object/object_relations.c
M   source/blender/editors/object/object_select.c
M   source/blender/editors/render/render_preview.cc
M   source/blender/editors/screen/screen_edit.c
M   source/blender/editors/space_outliner/outliner_collections.cc
M   source/blender/editors/space_outliner/outliner_dragdrop.cc
M   source/blender/editors/space_outliner/outliner_draw.cc
M   source/blender/editors/space_outliner/outliner_select.cc
M   source/blender/editors/space_outliner/outliner_sync.cc
M   source/blender/editors/space_outliner/outliner_tools.cc
M   source/blender/editors/space_outliner/outliner_tree.cc
M   source/blender/editors/space_outliner/outliner_utils.cc
M   source/blender/editors/space_outliner/tree/tree_display.hh
M   source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
M   source/blender/editors/space_view3d/space_view3d.c
M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/editors/space_view3d/view3d_navigate.c
M   source/blender/editors/space_view3d/view3d_select.cc
M   source/blender/editors/transform/transform_generics.c
M   source/blender/editors/transform/transform_orientations.c
M   source/blender/editors/transform/transform_orientations.h
M   source/blender/io/alembic/intern/alembic_capi.cc
M   source/blender/io/collada/collada_utils.cpp
M   source/blender/io/stl/importer/stl_import.cc
M   source/blender/io/usd/intern/usd_capi_import.cc
M   source/blender/io/wavefront_obj/importer/obj_importer.cc
M   source/blender/makesrna/intern/rna_layer.c

===

diff --git a/source/blender/blenkernel/BKE_collection.h 
b/source/blender/blenkernel/BKE_collection.h
index 19dbee38f36..dd7866d83e5 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -240,7 +240,8 @@ const char *BKE_collection_ui_name_get(struct Collection 
*collection);
  * Select all the objects in this Collection (and its nested collections) for 
this ViewLayer.
  * Return true if any object was selected.
  */
-bool BKE_collection_objects_select(struct ViewLayer *view_layer,
+bool BKE_collection_objects_select(const struct Scene *scene,
+   struct ViewLayer *view_layer,
struct Collection *collection,
bool deselect);
 
diff --git a/source/blender/blenkernel/BKE_layer.h 
b/source/blender/blenkernel/BKE_layer.h
index aecdf13e7d8..dcef62c1a78 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -196,10 +196,12 @@ bool BKE_scene_has_object(struct Scene *scene, struct 
Object *ob);
  * It also select the objects that are in nested collections.
  * \note Recursive.
  */
-bool BKE_layer_collection_objects_select(struct ViewLayer *view_layer,
+bool BKE_layer_collection_objects_select(const struct Scene *scene,
+ struct ViewLayer *view_layer,
  struct LayerCollection *lc,
  bool deselect);
-bool BKE_layer_collection_has_selected_objects(struct ViewLayer *view_layer,
+bool BKE_layer_collection_has_selected_objects(const struct Scene *scene,
+   struct ViewLayer *view_layer,
struct LayerCollection *lc);
 bool BKE_layer_collection_has_layer_collection(struct LayerCollection 

[Bf-blender-cvs] [268e1eff8a5] master: Fix T96297: obj: improve layout of UI fields and axis validation

2022-09-08 Thread Aras Pranckevicius
Commit: 268e1eff8a54ef3b294b27e94b73e29338a3c469
Author: Aras Pranckevicius
Date:   Thu Sep 8 11:43:26 2022 +0300
Branches: master
https://developer.blender.org/rB268e1eff8a54ef3b294b27e94b73e29338a3c469

Fix T96297: obj: improve layout of UI fields and axis validation

Implement ideas from T96297:
- Fix "invalid axis settings" (both forward & up along the same
  direction) validation: now similar to the Python based code, when
  invalid axis is applied, the other axis is changed to not conflict.
- Make axis enums be expanded inside the row, similar to Collada UI.
- Move "selected only" near the top, similar to how it's in Collada,
  USD, FBX and glTF export UIs.
- Move animation export options to the bottom.

===

M   source/blender/editors/io/io_obj.c
M   source/blender/io/wavefront_obj/IO_wavefront_obj.h

===

diff --git a/source/blender/editors/io/io_obj.c 
b/source/blender/editors/io/io_obj.c
index 0c935a0e1da..ef68a15933f 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -114,28 +114,24 @@ static void ui_obj_export_settings(uiLayout *layout, 
PointerRNA *imfptr)
   uiLayoutSetPropSep(layout, true);
   uiLayoutSetPropDecorate(layout, false);
 
-  /* Animation options. */
-  uiLayout *box = uiLayoutBox(layout);
-  uiItemL(box, IFACE_("Animation"), ICON_ANIM);
-  uiLayout *col = uiLayoutColumn(box, false);
-  uiLayout *sub = uiLayoutColumn(col, false);
-  uiItemR(sub, imfptr, "export_animation", 0, NULL, ICON_NONE);
-  sub = uiLayoutColumn(sub, true);
-  uiItemR(sub, imfptr, "start_frame", 0, IFACE_("Frame Start"), ICON_NONE);
-  uiItemR(sub, imfptr, "end_frame", 0, IFACE_("End"), ICON_NONE);
-  uiLayoutSetEnabled(sub, export_animation);
+  uiLayout *box, *col, *sub, *row;
 
   /* Object Transform options. */
   box = uiLayoutBox(layout);
   uiItemL(box, IFACE_("Object Properties"), ICON_OBJECT_DATA);
   col = uiLayoutColumn(box, false);
-  sub = uiLayoutColumn(col, false);
-  uiItemR(sub, imfptr, "forward_axis", 0, IFACE_("Axis Forward"), ICON_NONE);
-  uiItemR(sub, imfptr, "up_axis", 0, IFACE_("Up"), ICON_NONE);
-  sub = uiLayoutColumn(col, false);
+  sub = uiLayoutColumnWithHeading(col, false, IFACE_("Limit to"));
+  uiItemR(sub, imfptr, "export_selected_objects", 0, IFACE_("Selected Only"), 
ICON_NONE);
   uiItemR(sub, imfptr, "scaling_factor", 0, NULL, ICON_NONE);
+
+  row = uiLayoutRow(box, false);
+  uiItemR(row, imfptr, "forward_axis", UI_ITEM_R_EXPAND, IFACE_("Foward 
Axis"), ICON_NONE);
+  row = uiLayoutRow(box, false);
+  uiItemR(row, imfptr, "up_axis", UI_ITEM_R_EXPAND, IFACE_("Up Axis"), 
ICON_NONE);
+
+  col = uiLayoutColumn(box, false);
+  sub = uiLayoutColumn(col, false);
   sub = uiLayoutColumnWithHeading(col, false, IFACE_("Objects"));
-  uiItemR(sub, imfptr, "export_selected_objects", 0, IFACE_("Selected Only"), 
ICON_NONE);
   uiItemR(sub, imfptr, "apply_modifiers", 0, IFACE_("Apply Modifiers"), 
ICON_NONE);
   uiItemR(sub, imfptr, "export_eval_mode", 0, IFACE_("Properties"), ICON_NONE);
   sub = uiLayoutColumn(sub, false);
@@ -144,7 +140,7 @@ static void ui_obj_export_settings(uiLayout *layout, 
PointerRNA *imfptr)
 
   /* Options for what to write. */
   box = uiLayoutBox(layout);
-  uiItemL(box, IFACE_("Geometry Export"), ICON_EXPORT);
+  uiItemL(box, IFACE_("Geometry"), ICON_EXPORT);
   col = uiLayoutColumn(box, false);
   sub = uiLayoutColumnWithHeading(col, false, IFACE_("Export"));
   uiItemR(sub, imfptr, "export_uv", 0, IFACE_("UV Coordinates"), ICON_NONE);
@@ -166,6 +162,17 @@ static void ui_obj_export_settings(uiLayout *layout, 
PointerRNA *imfptr)
   sub = uiLayoutColumn(sub, false);
   uiLayoutSetEnabled(sub, export_smooth_groups);
   uiItemR(sub, imfptr, "smooth_group_bitflags", 0, IFACE_("Smooth Group 
Bitflags"), ICON_NONE);
+
+  /* Animation options. */
+  box = uiLayoutBox(layout);
+  uiItemL(box, IFACE_("Animation"), ICON_ANIM);
+  col = uiLayoutColumn(box, false);
+  sub = uiLayoutColumn(col, false);
+  uiItemR(sub, imfptr, "export_animation", 0, NULL, ICON_NONE);
+  sub = uiLayoutColumn(sub, true);
+  uiItemR(sub, imfptr, "start_frame", 0, IFACE_("Frame Start"), ICON_NONE);
+  uiItemR(sub, imfptr, "end_frame", 0, IFACE_("End"), ICON_NONE);
+  uiLayoutSetEnabled(sub, export_animation);
 }
 
 static void wm_obj_export_draw(bContext *UNUSED(C), wmOperator *op)
@@ -211,15 +218,30 @@ static bool wm_obj_export_check(bContext *C, wmOperator 
*op)
 RNA_int_set(op->ptr, "start_frame", start);
 RNA_int_set(op->ptr, "end_frame", end);
   }
+  return changed;
+}
 
-  /* Both forward and up axes cannot be the same (or same except opposite 
sign). */
-  if (RNA_enum_get(op->ptr, "forward_axis") % TOTAL_AXES ==
-  (RNA_enum_get(op->ptr, "up_axis") % TOTAL_AXES)) {
-/* TODO(@ankitm): Show a warning here. */
-RNA_enum_set(op->ptr, "up_axis", RNA_enum_get(op->ptr, "up_axis") % 

[Bf-blender-cvs] [5b5e2d47737] temp-T73411-view-layer-lazy-cache: Add ensure_sync before BKE_view_layer_active_base_get.

2022-09-08 Thread Jeroen Bakker
Commit: 5b5e2d47737c2e2203ac82e3f5e7e80bb4703480
Author: Jeroen Bakker
Date:   Thu Sep 8 10:20:26 2022 +0200
Branches: temp-T73411-view-layer-lazy-cache
https://developer.blender.org/rB5b5e2d47737c2e2203ac82e3f5e7e80bb4703480

Add ensure_sync before BKE_view_layer_active_base_get.

===

M   source/blender/blenkernel/intern/object.cc
M   source/blender/draw/intern/draw_common.c
M   source/blender/editors/armature/armature_select.c
M   source/blender/editors/curve/editcurve.c
M   source/blender/editors/curve/editcurve_select.c
M   source/blender/editors/lattice/editlattice_select.c
M   source/blender/editors/mesh/editmesh_path.c
M   source/blender/editors/mesh/editmesh_polybuild.c
M   source/blender/editors/mesh/editmesh_select.c
M   source/blender/editors/metaball/mball_edit.c
M   source/blender/editors/object/object_add.cc
M   source/blender/editors/object/object_constraint.c
M   source/blender/editors/object/object_hook.c
M   source/blender/editors/object/object_select.c
M   source/blender/editors/space_outliner/outliner_collections.cc
M   source/blender/editors/space_outliner/outliner_tools.cc
M   source/blender/editors/space_outliner/outliner_tree.cc
M   source/blender/editors/space_view3d/space_view3d.c
M   source/blender/editors/space_view3d/view3d_buttons.c
M   source/blender/editors/space_view3d/view3d_gizmo_armature.c
M   source/blender/editors/space_view3d/view3d_gizmo_camera.c
M   source/blender/editors/space_view3d/view3d_gizmo_empty.c
M   source/blender/editors/space_view3d/view3d_gizmo_forcefield.c
M   source/blender/editors/space_view3d/view3d_gizmo_light.c
M   source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
M   source/blender/editors/space_view3d/view3d_select.cc
M   source/blender/editors/transform/transform_generics.c
M   source/blender/editors/transform/transform_snap.c
M   source/blender/editors/util/ed_util.c

===

diff --git a/source/blender/blenkernel/intern/object.cc 
b/source/blender/blenkernel/intern/object.cc
index 5336e79ce93..1b66bce94ee 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -2596,6 +2596,7 @@ Object **BKE_object_pose_array_get(const Scene *scene,
 Base **BKE_object_pose_base_array_get_ex(
 const Scene *scene, ViewLayer *view_layer, View3D *v3d, uint *r_bases_len, 
bool unique)
 {
+  BKE_view_layer_ensure_sync(scene, view_layer);
   Base *base_active = BKE_view_layer_active_base_get(view_layer, __func__);
   Object *ob_pose = base_active ? 
BKE_object_pose_armature_get(base_active->object) : nullptr;
   Base *base_pose = nullptr;
diff --git a/source/blender/draw/intern/draw_common.c 
b/source/blender/draw/intern/draw_common.c
index 866961066ef..1bc774a0922 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -280,6 +280,7 @@ int DRW_object_wire_theme_get(Object *ob, ViewLayer 
*view_layer, float **r_color
 {
   const DRWContextState *draw_ctx = DRW_context_state_get();
   const bool is_edit = (draw_ctx->object_mode & OB_MODE_EDIT) && (ob->mode & 
OB_MODE_EDIT);
+  BKE_view_layer_ensure_sync(draw_ctx->scene, view_layer);
   const Base *base = BKE_view_layer_active_base_get(view_layer, __func__);
   const bool active = base && ((ob->base_flag & BASE_FROM_DUPLI) ?
(DRW_object_get_dupli_parent(ob) == 
base->object) :
diff --git a/source/blender/editors/armature/armature_select.c 
b/source/blender/editors/armature/armature_select.c
index e87cd5e556e..3a8fa1051f7 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -1103,6 +1103,7 @@ bool ED_armature_edit_select_pick_bone(bContext *C,
   arm->act_edbone = ebone;
 }
 
+BKE_view_layer_ensure_sync(scene, view_layer);
 if (BKE_view_layer_active_base_get(view_layer, __func__) != basact) {
   ED_object_base_activate(C, basact);
 }
diff --git a/source/blender/editors/curve/editcurve.c 
b/source/blender/editors/curve/editcurve.c
index 3e94181224e..86524f4243e 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4961,6 +4961,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
   WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, NULL);
 }
 
+BKE_view_layer_ensure_sync(vc.scene, vc.view_layer);
 if (BKE_view_layer_active_base_get(vc.view_layer, __func__) != basact) {
   ED_object_base_activate(C, basact);
 }
diff --git a/source/blender/editors/curve/editcurve_select.c 
b/source/blender/editors/curve/editcurve_select.c
index 67bbbcaaa9d..d399314f2db 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ 

[Bf-blender-cvs] [ecf3287533c] master: Fix T100822: Merging objects does not assign materials correctly

2022-09-08 Thread Philipp Oeser
Commit: ecf3287533c8adc90250bc13957eddb7b2e22fc6
Author: Philipp Oeser
Date:   Mon Sep 5 12:22:51 2022 +0200
Branches: master
https://developer.blender.org/rBecf3287533c8adc90250bc13957eddb7b2e22fc6

Fix T100822: Merging objects does not assign materials correctly

Caused by {rBf1c0249f34c4}

This is what (I think) went wrong in the above commit:
- `join_mesh_single` was writing material indices to the custom data /
attribute of the source mesh
- the `polyofs` of each mesh that was joined was not taken into account

Now, instead of using the AttributeWriter on a particular mesh, use the
CustomData (`pdata`) - that is constantly changed during joining -
directly for writing.
Otherwise we end up writing into customdata that has not been "extended"
yet (even if we use the destination mesh).
Also note that even on the destination mesh, CustomData would be freed
anyways after all calls to `join_mesh_single` took place, to be replaced
with the mentioned `pdata` which should be the single customdata to
write to here.

When doing this (writing to `pdata`), we also need to take into account
the poly offset of each contributing mesh.

Maniphest Tasks: T100822

Differential Revision: https://developer.blender.org/D15878

===

M   source/blender/editors/mesh/meshtools.cc

===

diff --git a/source/blender/editors/mesh/meshtools.cc 
b/source/blender/editors/mesh/meshtools.cc
index d6713724e15..58702d9e966 100644
--- a/source/blender/editors/mesh/meshtools.cc
+++ b/source/blender/editors/mesh/meshtools.cc
@@ -253,15 +253,18 @@ static void join_mesh_single(Depsgraph *depsgraph,
 CustomData_merge(>pdata, pdata, CD_MASK_MESH.pmask, CD_SET_DEFAULT, 
totpoly);
 CustomData_copy_data_named(>pdata, pdata, 0, *polyofs, me->totpoly);
 
-blender::bke::AttributeWriter material_indices =
-me->attributes_for_write().lookup_for_write("material_index");
+/* Apply matmap. In case we dont have material indices yet, create them if 
more than one
+ * material is the result of joining. */
+int *material_indices = static_cast(
+CustomData_get_layer_named(pdata, CD_PROP_INT32, "material_index"));
+if (!material_indices && totcol > 1) {
+  material_indices = (int *)CustomData_add_layer_named(
+  pdata, CD_PROP_INT32, CD_SET_DEFAULT, NULL, totpoly, 
"material_index");
+}
 if (material_indices) {
-  blender::MutableVArraySpan 
material_indices_span(material_indices.varray);
-  for (const int i : material_indices_span.index_range()) {
-material_indices_span[i] = matmap ? matmap[material_indices_span[i]] : 
0;
+  for (a = 0; a < me->totpoly; a++) {
+material_indices[a + *polyofs] = matmap ? matmap[material_indices[a + 
*polyofs]] : 0;
   }
-  material_indices_span.save();
-  material_indices.finish();
 }
 
 for (a = 0; a < me->totpoly; a++, mpoly++) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs