UI: Improve how region size snapping respects the maximum size #109027

Merged
Julian Eisel merged 4 commits from JulianEisel/blender:temp-region-snap-maxsize into main 2023-07-03 13:06:45 +02:00
595 changed files with 21062 additions and 14722 deletions
Showing only changes of commit b31c204a67 - Show all commits

View File

@ -480,8 +480,8 @@ set(EMBREE_HASH_TYPE MD5)
set(EMBREE_FILE embree-v${EMBREE_VERSION}.zip)
set(USD_VERSION 23.05)
set(USD_URI https://github.com/PixarAnimationStudios/USD/archive/v${USD_VERSION}.tar.gz)
set(USD_HASH 56684f4fdd1a9209dabf03856be5eca6)
set(USD_URI https://github.com/PixarAnimationStudios/OpenUSD/archive/v${USD_VERSION}.tar.gz)
set(USD_HASH d4d92ff112bc82a1718bcd129b853a54)
set(USD_HASH_TYPE MD5)
set(USD_FILE usd-v${USD_VERSION}.tar.gz)

View File

@ -47,17 +47,17 @@ macro(BLENDER_SRC_GTEST_EX)
target_compile_definitions(${TARGET_NAME} PRIVATE ${GLOG_DEFINES})
target_include_directories(${TARGET_NAME} PUBLIC "${TEST_INC}")
target_include_directories(${TARGET_NAME} SYSTEM PUBLIC "${TEST_INC_SYS}")
target_link_libraries(${TARGET_NAME} ${ARG_EXTRA_LIBS} ${PLATFORM_LINKLIBS})
blender_link_libraries(${TARGET_NAME} "${ARG_EXTRA_LIBS};${PLATFORM_LINKLIBS}")
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.
target_link_libraries(${TARGET_NAME} ${TBB_LIBRARIES})
target_link_libraries(${TARGET_NAME} PRIVATE ${TBB_LIBRARIES})
if(WITH_OPENIMAGEDENOISE)
target_link_libraries(${TARGET_NAME} ${OPENIMAGEDENOISE_LIBRARIES})
target_link_libraries(${TARGET_NAME} PRIVATE ${OPENIMAGEDENOISE_LIBRARIES})
endif()
endif()
target_link_libraries(${TARGET_NAME}
target_link_libraries(${TARGET_NAME} PRIVATE
bf_testing_main
bf_intern_eigen
bf_intern_guardedalloc
@ -68,16 +68,16 @@ macro(BLENDER_SRC_GTEST_EX)
${GLOG_LIBRARIES}
${GFLAGS_LIBRARIES})
if(WITH_OPENMP_STATIC)
target_link_libraries(${TARGET_NAME} ${OpenMP_LIBRARIES})
target_link_libraries(${TARGET_NAME} PRIVATE ${OpenMP_LIBRARIES})
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(${TARGET_NAME} bf_intern_libc_compat)
target_link_libraries(${TARGET_NAME} PRIVATE bf_intern_libc_compat)
endif()
if(WITH_TBB)
target_link_libraries(${TARGET_NAME} ${TBB_LIBRARIES})
target_link_libraries(${TARGET_NAME} PRIVATE ${TBB_LIBRARIES})
endif()
if(WITH_GMP)
target_link_libraries(${TARGET_NAME} ${GMP_LIBRARIES})
target_link_libraries(${TARGET_NAME} PRIVATE ${GMP_LIBRARIES})
endif()
GET_BLENDER_TEST_INSTALL_DIR(TEST_INSTALL_DIR)
@ -109,25 +109,3 @@ macro(BLENDER_SRC_GTEST_EX)
unset(TARGET_NAME)
endif()
endmacro()
macro(BLENDER_SRC_GTEST NAME SRC EXTRA_LIBS)
BLENDER_SRC_GTEST_EX(
NAME "${NAME}"
SRC "${SRC}"
EXTRA_LIBS "${EXTRA_LIBS}")
endmacro()
macro(BLENDER_TEST NAME EXTRA_LIBS)
BLENDER_SRC_GTEST_EX(
NAME "${NAME}"
SRC "${NAME}_test.cc"
EXTRA_LIBS "${EXTRA_LIBS}")
endmacro()
macro(BLENDER_TEST_PERFORMANCE NAME EXTRA_LIBS)
BLENDER_SRC_GTEST_EX(
NAME "${NAME}"
SRC "${NAME}_test.cc"
EXTRA_LIBS "${EXTRA_LIBS}"
SKIP_ADD_TEST)
endmacro()

View File

@ -25,11 +25,9 @@ CHECKER_IGNORE_PREFIX = [
"extern",
]
# To add files use a relative path.
CHECKER_EXCLUDE_SOURCE_FILES = set(os.path.join(*f.split("/")) for f in (
# These files hang (taking longer than 5min with v2.8.2 at time of writing).
# All other files process in under around 10seconds.
"source/blender/editors/space_text/text_format_pov.c",
"source/blender/editors/space_text/text_format_pov_ini.c",
# "source/blender/example.c",
))
CHECKER_ARGS = [

View File

@ -159,31 +159,60 @@ function(absolute_include_dirs
set(_ALL_INCS "")
foreach(_INC ${ARGN})
get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
list(APPEND _ALL_INCS ${_ABS_INC})
# for checking for invalid includes, disable for regular use
# if(NOT EXISTS "${_ABS_INC}/")
# message(FATAL_ERROR "Include not found: ${_ABS_INC}/")
# endif()
# Pass any scoping keywords as is
if(("${_INC}" STREQUAL "PUBLIC") OR
("${_INC}" STREQUAL "PRIVATE") OR
("${_INC}" STREQUAL "INTERFACE"))
list(APPEND _ALL_INCS ${_INC})
else()
get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
list(APPEND _ALL_INCS ${_ABS_INC})
# for checking for invalid includes, disable for regular use
# if(NOT EXISTS "${_ABS_INC}/")
# message(FATAL_ERROR "Include not found: ${_ABS_INC}/")
# endif()
endif()
endforeach()
set(${includes_absolute} ${_ALL_INCS} PARENT_SCOPE)
endfunction()
function(blender_target_include_dirs
name
function(blender_target_include_dirs_impl
target
system
includes
)
set(next_interface_mode "PRIVATE")
foreach(_INC ${includes})
if(("${_INC}" STREQUAL "PUBLIC") OR
("${_INC}" STREQUAL "PRIVATE") OR
("${_INC}" STREQUAL "INTERFACE"))
set(next_interface_mode "${_INC}")
else()
if(system)
target_include_directories(${target} SYSTEM ${next_interface_mode} ${_INC})
else()
target_include_directories(${target} ${next_interface_mode} ${_INC})
endif()
set(next_interface_mode "PRIVATE")
endif()
endforeach()
endfunction()
# Nicer makefiles with -I/1/foo/ instead of -I/1/2/3/../../foo/
# use it instead of target_include_directories()
function(blender_target_include_dirs
target
)
absolute_include_dirs(_ALL_INCS ${ARGN})
target_include_directories(${name} PRIVATE ${_ALL_INCS})
blender_target_include_dirs_impl(${target} FALSE "${_ALL_INCS}")
endfunction()
function(blender_target_include_dirs_sys
name
target
)
absolute_include_dirs(_ALL_INCS ${ARGN})
target_include_directories(${name} SYSTEM PRIVATE ${_ALL_INCS})
blender_target_include_dirs_impl(${target} TRUE "${_ALL_INCS}")
endfunction()
# Set include paths for header files included with "*.h" syntax.
@ -277,23 +306,11 @@ macro(add_cc_flags_custom_test
endmacro()
# only MSVC uses SOURCE_GROUP
function(blender_add_lib__impl
name
sources
includes
includes_sys
function(blender_link_libraries
target
library_deps
)
# message(STATUS "Configuring library ${name}")
add_library(${name} ${sources})
blender_target_include_dirs(${name} ${includes})
blender_target_include_dirs_sys(${name} ${includes_sys})
# On Windows certain libraries have two sets of binaries: one for debug builds and one for
# release builds. The root of this requirement goes into ABI, I believe, but that's outside
# of a scope of this comment.
@ -331,23 +348,49 @@ function(blender_add_lib__impl
# NOT: "optimized libfoo libbar debug libfoo_d libbar_d"
if(NOT "${library_deps}" STREQUAL "")
set(next_library_mode "")
set(next_interface_mode "PRIVATE")
foreach(library ${library_deps})
string(TOLOWER "${library}" library_lower)
if(("${library_lower}" STREQUAL "optimized") OR
("${library_lower}" STREQUAL "debug"))
set(next_library_mode "${library_lower}")
elseif(("${library}" STREQUAL "PUBLIC") OR
("${library}" STREQUAL "PRIVATE") OR
("${library}" STREQUAL "INTERFACE"))
set(next_interface_mode "${library}")
else()
if("${next_library_mode}" STREQUAL "optimized")
target_link_libraries(${name} INTERFACE optimized ${library})
target_link_libraries(${target} ${next_interface_mode} optimized ${library})
elseif("${next_library_mode}" STREQUAL "debug")
target_link_libraries(${name} INTERFACE debug ${library})
target_link_libraries(${target} ${next_interface_mode} debug ${library})
else()
target_link_libraries(${name} INTERFACE ${library})
target_link_libraries(${target} ${next_interface_mode} ${library})
endif()
set(next_library_mode "")
endif()
endforeach()
endif()
endfunction()
# only MSVC uses SOURCE_GROUP
function(blender_add_lib__impl
name
sources
includes
includes_sys
library_deps
)
# message(STATUS "Configuring library ${name}")
add_library(${name} ${sources})
blender_target_include_dirs(${name} ${includes})
blender_target_include_dirs_sys(${name} ${includes_sys})
if(library_deps)
blender_link_libraries(${name} "${library_deps}")
endif()
# works fine without having the includes
# listed is helpful for IDE's (QtCreator/MSVC)
@ -477,8 +520,9 @@ endfunction()
# To be used for smaller isolated libraries, that do not have many dependencies.
# For libraries that do drag in many other Blender libraries and would create a
# very large executable, blender_add_test_lib() should be used instead.
function(blender_add_test_executable
function(blender_add_test_executable_impl
name
add_test_suite
sources
includes
includes_sys
@ -496,14 +540,48 @@ function(blender_add_test_executable
EXTRA_LIBS "${library_deps}"
SKIP_ADD_TEST
)
if(add_test_suite)
blender_add_test_suite(
TARGET ${name}_test
SUITE_NAME ${name}
SOURCES "${sources}"
)
endif()
blender_target_include_dirs(${name}_test ${includes})
blender_target_include_dirs_sys(${name}_test ${includes_sys})
endfunction()
blender_add_test_suite(
TARGET ${name}_test
SUITE_NAME ${name}
SOURCES "${sources}"
function(blender_add_test_executable
name
sources
includes
includes_sys
library_deps
)
blender_add_test_executable_impl(
"${name}"
TRUE
"${sources}"
"${includes}"
"${includes_sys}"
"${library_deps}"
)
endfunction()
function(blender_add_performancetest_executable
name
sources
includes
includes_sys
library_deps
)
blender_add_test_executable_impl(
"${name}"
FALSE
"${sources}"
"${includes}"
"${includes_sys}"
"${library_deps}"
)
endfunction()
@ -547,17 +625,17 @@ function(setup_platform_linker_libs
)
# jemalloc must be early in the list, to be before pthread (see #57998).
if(WITH_MEM_JEMALLOC)
target_link_libraries(${target} ${JEMALLOC_LIBRARIES})
target_link_libraries(${target} PRIVATE ${JEMALLOC_LIBRARIES})
endif()
if(WIN32 AND NOT UNIX)
if(DEFINED PTHREADS_LIBRARIES)
target_link_libraries(${target} ${PTHREADS_LIBRARIES})
target_link_libraries(${target} PRIVATE ${PTHREADS_LIBRARIES})
endif()
endif()
# target_link_libraries(${target} ${PLATFORM_LINKLIBS} ${CMAKE_DL_LIBS})
target_link_libraries(${target} ${PLATFORM_LINKLIBS})
target_link_libraries(${target} PRIVATE ${PLATFORM_LINKLIBS})
endfunction()
macro(TEST_SSE_SUPPORT

View File

@ -1130,7 +1130,7 @@ endif()
# Environment variables to run precompiled executables that needed libraries.
list(JOIN PLATFORM_BUNDLED_LIBRARY_DIRS ";" _library_paths)
set(PLATFORM_ENV_BUILD_DIRS "${LIBDIR}/tbb/bin\;${LIBDIR}/OpenImageIO/bin\;${LIBDIR}/boost/lib\;${LIBDIR}/openexr/bin\;${LIBDIR}/imath/bin\;${PATH}")
set(PLATFORM_ENV_BUILD_DIRS "${LIBDIR}/epoxy/bin\;${LIBDIR}/tbb/bin\;${LIBDIR}/OpenImageIO/bin\;${LIBDIR}/boost/lib\;${LIBDIR}/openexr/bin\;${LIBDIR}/imath/bin\;${PATH}")
set(PLATFORM_ENV_BUILD "PATH=${PLATFORM_ENV_BUILD_DIRS}")
# Install needs the additional folders from PLATFORM_ENV_BUILD_DIRS as well, as tools like idiff and abcls use the release mode dlls
set(PLATFORM_ENV_INSTALL "PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/blender.shared/\;${PLATFORM_ENV_BUILD_DIRS}\;$ENV{PATH}")

View File

@ -318,8 +318,7 @@ def api_changelog(args):
props_moved.append((prop_id_old, prop_id_new))
# remove
if prop_id_old in set_props_old:
set_props_old.remove(prop_id_old)
set_props_old.discard(prop_id_old)
set_props_new.remove(prop_id_new)
# func args

View File

@ -9,6 +9,25 @@ set(INC
set(INC_SYS
)
add_library(bf_intern_atomic INTERFACE)
target_include_directories(bf_intern_atomic INTERFACE .)
# CMake 3.19+ allows one to populate the interface library with
# source files to show in the IDE, for people on older CMake versions
# these headers will be visible in the bf_intern_guardedalloc project
# where they historically have been.
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19")
set(SRC
atomic_ops.h
intern/atomic_ops_ext.h
intern/atomic_ops_msvc.h
intern/atomic_ops_unix.h
intern/atomic_ops_utils.h
)
target_sources(bf_intern_atomic PRIVATE ${SRC})
blender_source_group(bf_intern_atomic ${SRC})
endif()
if(WITH_GTESTS)
set(TEST_SRC
tests/atomic_test.cc
@ -16,6 +35,7 @@ if(WITH_GTESTS)
set(TEST_INC
)
set(TEST_LIB
PRIVATE bf_intern_atomic
)
include(GTestTesting)
blender_add_test_executable(atomic "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")

View File

@ -113,6 +113,9 @@ size_t oneapi_kernel_preferred_local_size(SyclQueue *queue,
/* Shader evaluation kernels seems to use some amount of shared memory, so better
* to avoid usage of maximum work group sizes for them. */
const static size_t preferred_work_group_size_shader_evaluation = 256;
/* NOTE(@nsirgien): 1024 currently may lead to issues with cryptomatte kernels, so
* for now their work-group size is restricted to 512. */
const static size_t preferred_work_group_size_cryptomatte = 512;
const static size_t preferred_work_group_size_default = 1024;
size_t preferred_work_group_size = 0;
@ -160,6 +163,10 @@ size_t oneapi_kernel_preferred_local_size(SyclQueue *queue,
preferred_work_group_size = GPU_PARALLEL_PREFIX_SUM_DEFAULT_BLOCK_SIZE;
break;
case DEVICE_KERNEL_CRYPTOMATTE_POSTPROCESS:
preferred_work_group_size = preferred_work_group_size_cryptomatte;
break;
case DEVICE_KERNEL_SHADER_EVAL_DISPLACE:
case DEVICE_KERNEL_SHADER_EVAL_BACKGROUND:
case DEVICE_KERNEL_SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY:

View File

@ -55,5 +55,6 @@ if(NOT APPLE)
endif()
if(WITH_GTESTS AND WITH_CYCLES_LOGGING)
blender_src_gtest(cycles "${SRC}" "${LIB}")
set(INC_SYS )
blender_add_test_executable(cycles "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
endif()

View File

@ -238,7 +238,7 @@ extern bool GHOST_ValidWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandl
* This window is invalid after full screen has been ended.
*/
extern GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
GHOST_DisplaySetting *setting,
const GHOST_DisplaySetting *setting,
const bool stereoVisual);
/**
@ -429,7 +429,7 @@ void GHOST_GetCursorGrabState(GHOST_WindowHandle windowhandle,
extern GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
GHOST_TGrabCursorMode mode,
GHOST_TAxisFlag wrap_axis,
int bounds[4],
const int bounds[4],
const int mouse_ungrab_xy[2]);
/***************************************************************************************

View File

@ -23,7 +23,7 @@
#include "intern/GHOST_CallbackEventConsumer.hh"
#include "intern/GHOST_XrException.hh"
GHOST_SystemHandle GHOST_CreateSystem(void)
GHOST_SystemHandle GHOST_CreateSystem()
{
GHOST_ISystem::createSystem(true, false);
GHOST_ISystem *system = GHOST_ISystem::getSystem();
@ -31,7 +31,7 @@ GHOST_SystemHandle GHOST_CreateSystem(void)
return (GHOST_SystemHandle)system;
}
GHOST_SystemHandle GHOST_CreateSystemBackground(void)
GHOST_SystemHandle GHOST_CreateSystemBackground()
{
GHOST_ISystem::createSystemBackground();
GHOST_ISystem *system = GHOST_ISystem::getSystem();
@ -216,7 +216,7 @@ bool GHOST_ValidWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windo
}
GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
GHOST_DisplaySetting *setting,
const GHOST_DisplaySetting *setting,
const bool stereoVisual)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
@ -409,7 +409,7 @@ GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
GHOST_TGrabCursorMode mode,
GHOST_TAxisFlag wrap_axis,
int bounds[4],
const int bounds[4],
const int mouse_ungrab_xy[2])
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
@ -781,7 +781,7 @@ int32_t GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
void GHOST_GetRectangle(
GHOST_RectangleHandle rectanglehandle, int32_t *l, int32_t *t, int32_t *r, int32_t *b)
{
GHOST_Rect *rect = (GHOST_Rect *)rectanglehandle;
const GHOST_Rect *rect = (GHOST_Rect *)rectanglehandle;
*l = rect->m_l;
*t = rect->m_t;
@ -885,7 +885,7 @@ void GHOST_putClipboard(const char *buffer, bool selection)
system->putClipboard(buffer, selection);
}
GHOST_TSuccess GHOST_hasClipboardImage(void)
GHOST_TSuccess GHOST_hasClipboardImage()
{
GHOST_ISystem *system = GHOST_ISystem::getSystem();
return system->hasClipboardImage();
@ -909,13 +909,13 @@ bool GHOST_setConsoleWindowState(GHOST_TConsoleWindowState action)
return system->setConsoleWindowState(action);
}
bool GHOST_UseNativePixels(void)
bool GHOST_UseNativePixels()
{
GHOST_ISystem *system = GHOST_ISystem::getSystem();
return system->useNativePixel();
}
GHOST_TCapabilityFlag GHOST_GetCapabilities(void)
GHOST_TCapabilityFlag GHOST_GetCapabilities()
{
GHOST_ISystem *system = GHOST_ISystem::getSystem();
return system->getCapabilities();

View File

@ -351,7 +351,7 @@ struct DummyContextWGL {
0,
0,
0,
0, /* accum bits (ignored) */
0, /* Accumulation bits (ignored). */
0, /* depth buffer */
0, /* stencil buffer */
0, /* no auxiliary buffers */

View File

@ -67,7 +67,7 @@ GHOST_TSuccess GHOST_DisplayManagerX11::getNumDisplaySettings(uint8_t display,
/* from SDL2 */
#ifdef WITH_X11_XF86VMODE
static int calculate_rate(XF86VidModeModeInfo *info)
static int calculate_rate(const XF86VidModeModeInfo *info)
{
return (info->htotal && info->vtotal) ? (1000 * info->dotclock / (info->htotal * info->vtotal)) :
0;

View File

@ -527,14 +527,14 @@ void GHOST_NDOFManager::setDeadZone(float dz)
CLOG_INFO(LOG, 2, "dead zone set to %.2f%s", dz, (dz > 0.5f) ? " (unexpectedly high)" : "");
}
static bool atHomePosition(GHOST_TEventNDOFMotionData *ndof)
static bool atHomePosition(const GHOST_TEventNDOFMotionData *ndof)
{
#define HOME(foo) (ndof->foo == 0.0f)
return HOME(tx) && HOME(ty) && HOME(tz) && HOME(rx) && HOME(ry) && HOME(rz);
#undef HOME
}
static bool nearHomePosition(GHOST_TEventNDOFMotionData *ndof, float threshold)
static bool nearHomePosition(const GHOST_TEventNDOFMotionData *ndof, float threshold)
{
if (threshold == 0.0f) {
return atHomePosition(ndof);

View File

@ -2432,16 +2432,21 @@ static void data_device_handle_drop(void *data, wl_data_device * /*wl_data_devic
std::vector<std::string> uris;
size_t pos = 0;
while (true) {
while (pos != std::string::npos) {
pos = data.find(file_proto, pos);
const size_t start = pos + sizeof(file_proto) - 1;
pos = data.find(lf, pos);
if (pos == std::string::npos) {
break;
}
/* Account for 'CRLF' case. */
const size_t start = pos + sizeof(file_proto) - 1;
pos = data.find(lf, pos);
size_t end = pos;
if (UNLIKELY(end == std::string::npos)) {
/* Note that most well behaved file managers will add a trailing newline,
* Gnome's web browser (44.3) doesn't, so support reading up until the last byte. */
end = data.size();
}
/* Account for 'CRLF' case. */
if (data[end - 1] == '\r') {
end -= 1;
}

View File

@ -9,7 +9,6 @@ endif()
set(INC
.
..
../atomic
)
set(INC_SYS
@ -36,6 +35,7 @@ set(SRC
)
set(LIB
PRIVATE bf_intern_atomic
)
if(WIN32 AND NOT UNIX)

View File

@ -29,7 +29,7 @@ enum TransformType {
#define COLORSPACE_SRGB ((OCIO_ConstColorSpaceRcPtr *)2)
#define COLORSPACE_DATA ((OCIO_ConstColorSpaceRcPtr *)3)
typedef struct OCIO_PackedImageDescription {
struct OCIO_PackedImageDescription {
float *data;
long width;
long height;
@ -37,7 +37,7 @@ typedef struct OCIO_PackedImageDescription {
long chanStrideBytes;
long xStrideBytes;
long yStrideBytes;
} OCIO_PackedImageDescription;
};
struct FallbackTransform {
FallbackTransform() : type(TRANSFORM_UNKNOWN), scale(1.0f), exponent(1.0f) {}

View File

@ -64,10 +64,9 @@ def get_root_modules():
# needed for modules defined in C
modules += sys.modules.keys()
modules = list(set(modules))
if '__init__' in modules:
modules.remove('__init__')
modules = sorted(modules)
modules = set(modules)
modules.discard("__init__")
modules = sorted(list(modules))
if store:
ROOT_MODULES = modules
return modules

View File

@ -87,9 +87,21 @@ def keyconfig_update(keyconfig_data, keyconfig_version):
keyconfig_data = copy.deepcopy(keyconfig_data)
has_copy = True
# "Snap Source Toggle" did not exist until then.
for km_name, _km_parms, km_items_data in keyconfig_data:
if km_name == "Transform Modal Map":
# Navigation during transform is now not optional and conflicts need to be resolved.
for (item_modal, item_event, _item_prop) in km_items_data["items"]:
if item_modal in {
"PROPORTIONAL_SIZE_UP",
"PROPORTIONAL_SIZE_DOWN",
"PROPORTIONAL_SIZE",
"AUTOIK_CHAIN_LEN_UP",
"AUTOIK_CHAIN_LEN_DOWN",
"AUTOCONSTRAIN",
"AUTOCONSTRAINPLANE"}:
item_event["alt"] = True
# "Snap Source Toggle" did not exist until then.
km_items_data["items"].extend(("EDIT_SNAP_SOURCE_ON", {"type": 'B', "value": 'PRESS'}, None))
km_items_data["items"].append(("EDIT_SNAP_SOURCE_OFF", {"type": 'B', "value": 'PRESS'}, None))
break

View File

@ -252,15 +252,6 @@ class Prefs(bpy.types.KeyConfigPreferences):
update=update_fn,
)
use_transform_navigation: BoolProperty(
name="Navigate during Transform",
description=(
"Enable view navigation while using transform operators. "
"Proportional Influence, Automatic Constraints and Auto IK Chain Length shortcuts will require holding Alt key"),
default=False,
update=update_fn,
)
def draw(self, layout):
from bpy import context
@ -324,7 +315,6 @@ class Prefs(bpy.types.KeyConfigPreferences):
sub.prop(self, "use_v3d_tab_menu")
sub.prop(self, "use_pie_click_drag")
sub.prop(self, "use_v3d_shade_ex_pie")
sub.prop(self, "use_transform_navigation")
# File Browser settings.
col = layout.column()
@ -385,7 +375,6 @@ def load():
use_pie_click_drag=kc_prefs.use_pie_click_drag,
use_file_single_click=kc_prefs.use_file_single_click,
experimental=prefs.experimental,
use_transform_navigation=kc_prefs.use_transform_navigation,
),
)

View File

@ -99,8 +99,6 @@ class Params:
"tool_maybe_tweak_event",
# Access to bpy.context.preferences.experimental
"experimental",
# Changes some transformers modal key-map items to avoid conflicts with navigation operations
"use_transform_navigation",
)
def __init__(
@ -129,7 +127,6 @@ class Params:
v3d_tilde_action='VIEW',
v3d_alt_mmb_drag_action='RELATIVE',
experimental=None,
use_transform_navigation=False,
):
from sys import platform
self.apple = (platform == 'darwin')
@ -228,7 +225,6 @@ class Params:
self.pie_value = 'CLICK_DRAG' if use_pie_click_drag else 'PRESS'
self.tool_tweak_event = {"type": self.tool_mouse, "value": 'CLICK_DRAG'}
self.tool_maybe_tweak_event = {"type": self.tool_mouse, "value": self.tool_maybe_tweak_value}
self.use_transform_navigation = use_transform_navigation
self.experimental = experimental
@ -1608,16 +1604,13 @@ def km_view3d(params):
# Transform.
("transform.translate", {"type": params.select_mouse, "value": 'CLICK_DRAG'}, None),
op_tool_optional(
("transform.translate", {"type": 'G', "value": 'PRESS'},
{"properties": [("allow_navigation", params.use_transform_navigation)]}),
("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.move"), params),
op_tool_optional(
("transform.rotate", {"type": 'R', "value": 'PRESS'},
{"properties": [("allow_navigation", params.use_transform_navigation)]}),
("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.rotate"), params),
op_tool_optional(
("transform.resize", {"type": 'S', "value": 'PRESS'},
{"properties": [("allow_navigation", params.use_transform_navigation)]}),
("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.scale"), params),
op_tool_optional(
("transform.tosphere", {"type": 'S', "value": 'PRESS', "shift": True, "alt": True}, None),
@ -3675,8 +3668,7 @@ def km_grease_pencil_stroke_edit_mode(params):
("gpencil.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
# Extrude and move selected points
op_tool_optional(
("gpencil.extrude_move", {"type": 'E', "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
("gpencil.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.extrude"), params),
# Delete
op_menu("VIEW3D_MT_edit_gpencil_delete", {"type": 'X', "value": 'PRESS'}),
@ -4685,10 +4677,8 @@ def km_object_mode(params):
op_menu("VIEW3D_MT_add", {"type": 'A', "value": 'PRESS', "shift": True}),
op_menu("VIEW3D_MT_object_apply", {"type": 'A', "value": 'PRESS', "ctrl": True}),
op_menu("VIEW3D_MT_make_links", {"type": 'L', "value": 'PRESS', "ctrl": True}),
("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True}, None),
("object.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
("wm.context_toggle", {"type": 'PERIOD', "value": 'PRESS', "ctrl": True},
{"properties": [("data_path", 'tool_settings.use_transform_data_origin')]}),
@ -4754,13 +4744,10 @@ def km_paint_curve(params):
("paintcurve.delete_point", {"type": 'DEL', "value": 'PRESS'}, None),
("paintcurve.draw", {"type": 'RET', "value": 'PRESS'}, None),
("paintcurve.draw", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None),
("transform.translate", {"type": 'G', "value": 'PRESS'},
{"properties": [("allow_navigation", params.use_transform_navigation)]}),
("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
("transform.translate", {"type": params.select_mouse, "value": 'CLICK_DRAG'}, None),
("transform.rotate", {"type": 'R', "value": 'PRESS'},
{"properties": [("allow_navigation", params.use_transform_navigation)]}),
("transform.resize", {"type": 'S', "value": 'PRESS'},
{"properties": [("allow_navigation", params.use_transform_navigation)]}),
("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
])
return keymap
@ -4793,8 +4780,7 @@ def km_curve(params):
("curve.separate", {"type": 'P', "value": 'PRESS'}, None),
("curve.split", {"type": 'Y', "value": 'PRESS'}, None),
op_tool_optional(
("curve.extrude_move", {"type": 'E', "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
("curve.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.extrude"), params),
("curve.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
("curve.make_segment", {"type": 'F', "value": 'PRESS'}, None),
@ -5403,8 +5389,7 @@ def km_mesh(params):
("mesh.normals_make_consistent", {"type": 'N', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("inside", True)]}),
op_tool_optional(
("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'},
{"properties": [("allow_navigation", params.use_transform_navigation)]}),
("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.extrude_region"), params),
op_menu("VIEW3D_MT_edit_mesh_extrude", {"type": 'E', "value": 'PRESS', "alt": True}),
("transform.edge_crease", {"type": 'E', "value": 'PRESS', "shift": True}, None),
@ -5421,13 +5406,11 @@ def km_mesh(params):
# No tool is available for this.
("mesh.rip_move", {"type": 'V', "value": 'PRESS', "alt": True},
{"properties": [("MESH_OT_rip", [("use_fill", True)],)]}),
("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True}, None),
op_menu("VIEW3D_MT_edit_mesh_merge", {"type": 'M', "value": 'PRESS'}),
op_menu("VIEW3D_MT_edit_mesh_split", {"type": 'M', "value": 'PRESS', "alt": True}),
("mesh.edge_face_add", {"type": 'F', "value": 'PRESS', "repeat": True}, None),
("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
op_menu("VIEW3D_MT_mesh_add", {"type": 'A', "value": 'PRESS', "shift": True}),
("mesh.separate", {"type": 'P', "value": 'PRESS'}, None),
("mesh.split", {"type": 'Y', "value": 'PRESS'}, None),
@ -5545,8 +5528,7 @@ def km_armature(params):
("armature.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
("armature.dissolve", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None),
op_tool_optional(
("armature.extrude_move", {"type": 'E', "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
("armature.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.extrude"), params),
("armature.extrude_forked", {"type": 'E', "value": 'PRESS', "shift": True}, None),
("armature.click_extrude", {"type": params.action_mouse, "value": 'CLICK', "ctrl": True}, None),
@ -5965,24 +5947,24 @@ def km_transform_modal_map(params):
("PROPORTIONAL_SIZE_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS', "repeat": True}, None),
("PROPORTIONAL_SIZE_UP", {"type": 'PAGE_UP', "value": 'PRESS', "shift": True, "repeat": True}, None),
("PROPORTIONAL_SIZE_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True, "repeat": True}, None),
("PROPORTIONAL_SIZE_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": params.use_transform_navigation}, None),
("PROPORTIONAL_SIZE_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": params.use_transform_navigation}, None),
("PROPORTIONAL_SIZE_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": True}, None),
("PROPORTIONAL_SIZE_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": True}, None),
("PROPORTIONAL_SIZE_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None),
("PROPORTIONAL_SIZE_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None),
("PROPORTIONAL_SIZE", {"type": 'TRACKPADPAN', "value": 'ANY', "alt": params.use_transform_navigation}, None),
("PROPORTIONAL_SIZE", {"type": 'TRACKPADPAN', "value": 'ANY', "alt": True}, None),
("AUTOIK_CHAIN_LEN_UP", {"type": 'PAGE_UP', "value": 'PRESS', "repeat": True}, None),
("AUTOIK_CHAIN_LEN_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS', "repeat": True}, None),
("AUTOIK_CHAIN_LEN_UP", {"type": 'PAGE_UP', "value": 'PRESS', "shift": True, "repeat": True}, None),
("AUTOIK_CHAIN_LEN_DOWN", {"type": 'PAGE_DOWN', "value": 'PRESS', "shift": True, "repeat": True}, None),
("AUTOIK_CHAIN_LEN_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": params.use_transform_navigation}, None),
("AUTOIK_CHAIN_LEN_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": params.use_transform_navigation}, None),
("AUTOIK_CHAIN_LEN_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "alt": True}, None),
("AUTOIK_CHAIN_LEN_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "alt": True}, None),
("AUTOIK_CHAIN_LEN_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None),
("AUTOIK_CHAIN_LEN_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None),
("INSERTOFS_TOGGLE_DIR", {"type": 'T', "value": 'PRESS'}, None),
("NODE_ATTACH_ON", {"type": 'LEFT_ALT', "value": 'RELEASE', "any": True}, None),
("NODE_ATTACH_OFF", {"type": 'LEFT_ALT', "value": 'PRESS', "any": True}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'ANY', "alt": params.use_transform_navigation}, None),
("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'ANY', "shift": True, "alt": params.use_transform_navigation}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'ANY', "alt": True}, None),
("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'ANY', "shift": True, "alt": True}, None),
("PRECISION", {"type": 'LEFT_SHIFT', "value": 'ANY', "any": True}, None),
("PRECISION", {"type": 'RIGHT_SHIFT', "value": 'ANY', "any": True}, None),
])

View File

@ -237,12 +237,17 @@ class NewGeometryNodeTreeAssign(Operator):
return geometry_modifier_poll(context)
def execute(self, context):
modifier = get_context_modifier(context)
if not modifier:
return {'CANCELLED'}
group = geometry_node_group_empty_new()
modifier.node_group = group
space = context.space_data
if space and space.type == 'NODE_EDITOR' and space.geometry_nodes_type == 'OPERATOR':
group = geometry_node_group_empty_new()
space.node_tree = group
return {'FINISHED'}
else:
modifier = get_context_modifier(context)
if not modifier:
return {'CANCELLED'}
group = geometry_node_group_empty_new()
modifier.node_group = group
return {'FINISHED'}

View File

@ -15,12 +15,6 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
bl_label = "Extrude Individual and Move"
bl_idname = "view3d.edit_mesh_extrude_individual_move"
allow_navigation: BoolProperty(
name="allow_navigation",
default=False,
description="Allow navigation",
)
@classmethod
def poll(cls, context):
obj = context.active_object
@ -40,27 +34,27 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
TRANSFORM_OT_translate={
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"allow_navigation": self.allow_navigation,
"release_confirm": False,
},
)
elif select_mode[2] and totface > 1:
bpy.ops.mesh.extrude_faces_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={
"allow_navigation": self.allow_navigation,
"release_confirm": False,
})
elif select_mode[1] and totedge >= 1:
bpy.ops.mesh.extrude_edges_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"allow_navigation": self.allow_navigation,
"release_confirm": False,
},
)
else:
bpy.ops.mesh.extrude_vertices_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"allow_navigation": self.allow_navigation,
"release_confirm": False,
},
)
@ -83,19 +77,13 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
description="Dissolves adjacent faces and intersects new geometry",
)
allow_navigation: BoolProperty(
name="allow_navigation",
default=False,
description="Allow navigation",
)
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj is not None and obj.mode == 'EDIT')
@staticmethod
def extrude_region(context, use_vert_normals, dissolve_and_intersect, allow_navigation):
def extrude_region(context, use_vert_normals, dissolve_and_intersect):
mesh = context.object.data
totface = mesh.total_face_sel
@ -107,7 +95,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
bpy.ops.mesh.extrude_region_shrink_fatten(
'INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={
"allow_navigation": allow_navigation,
"release_confirm": False,
},
)
elif dissolve_and_intersect:
@ -119,7 +107,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
TRANSFORM_OT_translate={
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"allow_navigation": allow_navigation,
"release_confirm": False,
},
)
else:
@ -128,7 +116,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
TRANSFORM_OT_translate={
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"allow_navigation": allow_navigation,
"release_confirm": False,
},
)
@ -142,13 +130,13 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
# Not a popular choice, too restrictive for retopo.
# "constraint_axis": (True, True, False)})
"constraint_axis": (False, False, False),
"allow_navigation": allow_navigation,
"release_confirm": False,
})
else:
bpy.ops.mesh.extrude_region_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"allow_navigation": allow_navigation,
"release_confirm": False,
},
)
@ -157,8 +145,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
return {'FINISHED'}
def execute(self, context):
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(
context, False, self.dissolve_and_intersect, self.allow_navigation)
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, False, self.dissolve_and_intersect)
def invoke(self, context, _event):
return self.execute(context)
@ -169,19 +156,13 @@ class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator):
bl_label = "Extrude and Move on Individual Normals"
bl_idname = "view3d.edit_mesh_extrude_move_shrink_fatten"
allow_navigation: BoolProperty(
name="allow_navigation",
default=False,
description="Allow navigation",
)
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj is not None and obj.mode == 'EDIT')
def execute(self, context):
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True, False, self.allow_navigation)
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True, False)
def invoke(self, context, _event):
return self.execute(context)
@ -192,12 +173,6 @@ class VIEW3D_OT_edit_mesh_extrude_manifold_normal(Operator):
bl_label = "Extrude Manifold Along Normals"
bl_idname = "view3d.edit_mesh_extrude_manifold_normal"
allow_navigation: BoolProperty(
name="allow_navigation",
default=False,
description="Allow navigation",
)
@classmethod
def poll(cls, context):
obj = context.active_object
@ -212,7 +187,7 @@ class VIEW3D_OT_edit_mesh_extrude_manifold_normal(Operator):
TRANSFORM_OT_translate={
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"allow_navigation": self.allow_navigation,
"release_confirm": False,
},
)
return {'FINISHED'}

View File

@ -145,6 +145,26 @@ class RENDER_PT_eevee_ambient_occlusion(RenderButtonsPanel, Panel):
col.prop(props, "use_gtao_bounce")
class RENDER_PT_eevee_next_ambient_occlusion(RenderButtonsPanel, Panel):
bl_label = "Ambient Occlusion"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
@classmethod
def poll(cls, context):
return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
layout.use_property_split = True
scene = context.scene
props = scene.eevee
col = layout.column()
col.prop(props, "gtao_distance")
col.prop(props, "gtao_quality")
class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
bl_label = "Motion Blur"
bl_options = {'DEFAULT_CLOSED'}
@ -935,6 +955,7 @@ classes = (
RENDER_PT_eevee_sampling,
RENDER_PT_eevee_next_sampling,
RENDER_PT_eevee_ambient_occlusion,
RENDER_PT_eevee_next_ambient_occlusion,
RENDER_PT_eevee_bloom,
RENDER_PT_eevee_depth_of_field,
RENDER_PT_eevee_next_depth_of_field,

View File

@ -139,25 +139,28 @@ class NODE_HT_header(Header):
layout.prop(snode_id, "use_nodes")
elif snode.tree_type == 'GeometryNodeTree':
layout.prop(snode, "geometry_nodes_type", text="")
NODE_MT_editor_menus.draw_collapsible(context, layout)
layout.separator_spacer()
ob = context.object
if snode.geometry_nodes_type == 'MODIFIER':
ob = context.object
row = layout.row()
if snode.pin:
row.enabled = False
row.template_ID(snode, "node_tree", new="node.new_geometry_node_group_assign")
elif ob:
active_modifier = ob.modifiers.active
if active_modifier and active_modifier.type == 'NODES':
if active_modifier.node_group:
row.template_ID(active_modifier, "node_group", new="object.geometry_node_tree_copy_assign")
row = layout.row()
if snode.pin:
row.enabled = False
row.template_ID(snode, "node_tree", new="node.new_geometry_node_group_assign")
elif ob:
active_modifier = ob.modifiers.active
if active_modifier and active_modifier.type == 'NODES':
if active_modifier.node_group:
row.template_ID(active_modifier, "node_group", new="object.geometry_node_tree_copy_assign")
else:
row.template_ID(active_modifier, "node_group", new="node.new_geometry_node_group_assign")
else:
row.template_ID(active_modifier, "node_group", new="node.new_geometry_node_group_assign")
else:
row.template_ID(snode, "node_tree", new="node.new_geometry_nodes_modifier")
row.template_ID(snode, "node_tree", new="node.new_geometry_nodes_modifier")
else:
layout.template_ID(snode, "node_tree", new="node.new_geometry_node_group_assign")
else:
# Custom node tree is edited as independent ID block
NODE_MT_editor_menus.draw_collapsible(context, layout)

View File

@ -110,7 +110,9 @@ class SPREADSHEET_HT_header(bpy.types.Header):
return obj.mode == 'EDIT'
if obj.type == 'CURVES':
return obj.mode in {'SCULPT_CURVES', 'EDIT'}
return True
if obj.type == 'POINTCLOUD':
return obj.mode == 'EDIT'
return False
classes = (

View File

@ -1518,12 +1518,16 @@ class USERPREF_PT_file_paths_asset_libraries(FilePathsPanel, Panel):
props = col.operator("preferences.asset_library_remove", text="", icon='REMOVE')
props.index = active_library_index
if active_library_index < 0:
try:
active_library = None if active_library_index < 0 else paths.asset_libraries[active_library_index]
except IndexError:
active_library = None
if active_library is None:
return
layout.separator()
active_library = paths.asset_libraries[active_library_index]
layout.prop(active_library, "path")
layout.prop(active_library, "import_method", text="Import Method")
layout.prop(active_library, "use_relative_path")

View File

@ -1018,6 +1018,7 @@ class VIEW3D_MT_editor_menus(Menu):
if mode_string == 'SCULPT_CURVES':
layout.menu("VIEW3D_MT_select_sculpt_curves")
layout.menu("VIEW3D_MT_sculpt_curves")
layout.template_node_operator_asset_root_items()
else:
layout.menu("VIEW3D_MT_object")
@ -1049,14 +1050,10 @@ class VIEW3D_MT_transform_base:
# TODO: get rid of the custom text strings?
def draw(self, context):
layout = self.layout
allow_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_transform_navigation",
False)
layout.operator("transform.translate").allow_navigation = allow_navigation
layout.operator("transform.rotate").allow_navigation = allow_navigation
layout.operator("transform.resize", text="Scale").allow_navigation = allow_navigation
layout.operator("transform.translate").release_confirm = False
layout.operator("transform.rotate").release_confirm = False
layout.operator("transform.resize", text="Scale").release_confirm = False
layout.separator()
@ -1076,18 +1073,13 @@ class VIEW3D_MT_transform_base:
# Generic transform menu - geometry types
class VIEW3D_MT_transform(VIEW3D_MT_transform_base, Menu):
def draw(self, context):
allow_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_transform_navigation",
False)
# base menu
VIEW3D_MT_transform_base.draw(self, context)
# generic...
layout = self.layout
if context.mode == 'EDIT_MESH':
layout.operator("transform.shrink_fatten", text="Shrink/Fatten").allow_navigation = allow_navigation
layout.operator("transform.shrink_fatten", text="Shrink/Fatten").release_confirm = False
layout.operator("transform.skin_resize")
elif context.mode == 'EDIT_CURVE':
layout.operator("transform.transform", text="Radius").mode = 'CURVE_SHRINKFATTEN'
@ -1096,10 +1088,11 @@ class VIEW3D_MT_transform(VIEW3D_MT_transform_base, Menu):
layout.separator()
props = layout.operator("transform.translate", text="Move Texture Space")
props.texture_space = True
props.allow_navigation = allow_navigation
props.release_confirm = False
props = layout.operator("transform.resize", text="Scale Texture Space")
props.texture_space = True
props.allow_navigation = allow_navigation
props.release_confirm = False
# Object-specific extensions to Transform menu
@ -2110,6 +2103,13 @@ class VIEW3D_MT_select_paint_mask_vertex(Menu):
layout.operator("paint.vert_select_linked", text="Select Linked")
class VIEW3D_MT_select_edit_point_cloud(Menu):
bl_label = "Select"
def draw(_self, _context):
pass
class VIEW3D_MT_edit_curves_select_more_less(Menu):
bl_label = "Select More/Less"
@ -2154,6 +2154,8 @@ class VIEW3D_MT_select_sculpt_curves(Menu):
layout.operator("curves.select_ends", text="Endpoints")
layout.operator("sculpt_curves.select_grow", text="Grow")
layout.template_node_operator_asset_menu_items(catalog_path="Select")
class VIEW3D_MT_mesh_add(Menu):
bl_idname = "VIEW3D_MT_mesh_add"
@ -3409,6 +3411,8 @@ class VIEW3D_MT_sculpt_curves(Menu):
layout.separator()
layout.operator("curves.convert_to_particle_system", text="Convert to Particle System")
layout.template_node_operator_asset_menu_items(catalog_path="Curves")
class VIEW3D_MT_mask(Menu):
bl_label = "Mask"
@ -4209,11 +4213,6 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
col.operator("mesh.delete", text="Delete Edges").type = 'EDGE'
if is_face_mode:
allow_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_transform_navigation",
False)
col = row.column(align=True)
col.label(text="Face Context Menu", icon='FACESEL')
@ -4224,12 +4223,10 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
col.separator()
col.operator("view3d.edit_mesh_extrude_move_normal",
text="Extrude Faces").allow_navigation = allow_navigation
col.operator("view3d.edit_mesh_extrude_move_shrink_fatten",
text="Extrude Faces Along Normals").allow_navigation = allow_navigation
col.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces")
col.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals")
col.operator("mesh.extrude_faces_move",
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.allow_navigation = allow_navigation
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.release_confirm = False
col.operator("mesh.inset")
col.operator("mesh.poke")
@ -4281,11 +4278,6 @@ class VIEW3D_MT_edit_mesh_extrude(Menu):
def draw(self, context):
from math import pi
allow_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_transform_navigation",
False)
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
@ -4294,23 +4286,20 @@ class VIEW3D_MT_edit_mesh_extrude(Menu):
mesh = context.object.data
if mesh.total_face_sel:
layout.operator("view3d.edit_mesh_extrude_move_normal",
text="Extrude Faces").allow_navigation = allow_navigation
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten",
text="Extrude Faces Along Normals").allow_navigation = allow_navigation
layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces")
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals")
layout.operator(
"mesh.extrude_faces_move",
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.allow_navigation = allow_navigation
layout.operator("view3d.edit_mesh_extrude_manifold_normal",
text="Extrude Manifold").allow_navigation = allow_navigation
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.release_confirm = False
layout.operator("view3d.edit_mesh_extrude_manifold_normal", text="Extrude Manifold")
if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
layout.operator("mesh.extrude_edges_move",
text="Extrude Edges").TRANSFORM_OT_translate.allow_navigation = allow_navigation
text="Extrude Edges").TRANSFORM_OT_translate.release_confirm = False
if mesh.total_vert_sel and select_mode[0]:
layout.operator("mesh.extrude_vertices_move",
text="Extrude Vertices").TRANSFORM_OT_translate.allow_navigation = allow_navigation
text="Extrude Vertices").TRANSFORM_OT_translate.release_confirm = False
layout.separator()
@ -4463,22 +4452,15 @@ class VIEW3D_MT_edit_mesh_faces(Menu):
bl_idname = "VIEW3D_MT_edit_mesh_faces"
def draw(self, context):
allow_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_transform_navigation",
False)
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("view3d.edit_mesh_extrude_move_normal",
text="Extrude Faces").allow_navigation = allow_navigation
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten",
text="Extrude Faces Along Normals").allow_navigation = allow_navigation
layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces")
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals")
layout.operator(
"mesh.extrude_faces_move",
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.allow_navigation = allow_navigation
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.release_confirm = False
layout.separator()
@ -5501,6 +5483,13 @@ class VIEW3D_MT_edit_curves(Menu):
layout.operator("curves.delete")
class VIEW3D_MT_edit_pointcloud(Menu):
bl_label = "Point Cloud"
def draw(_self, _context):
pass
class VIEW3D_MT_object_mode_pie(Menu):
bl_label = "Mode"
@ -8243,6 +8232,7 @@ classes = (
VIEW3D_MT_select_edit_gpencil,
VIEW3D_MT_select_paint_mask,
VIEW3D_MT_select_paint_mask_vertex,
VIEW3D_MT_select_edit_point_cloud,
VIEW3D_MT_edit_curves_select_more_less,
VIEW3D_MT_select_edit_curves,
VIEW3D_MT_select_sculpt_curves,
@ -8370,6 +8360,7 @@ classes = (
VIEW3D_MT_edit_armature_delete,
VIEW3D_MT_edit_gpencil_transform,
VIEW3D_MT_edit_curves,
VIEW3D_MT_edit_pointcloud,
VIEW3D_MT_object_mode_pie,
VIEW3D_MT_view_pie,
VIEW3D_MT_transform_gizmo_pie,

View File

@ -75,7 +75,7 @@ class MyCustomNode(MyCustomTreeNode, Node):
# === Custom Properties ===
# These work just like custom properties in ID data blocks
# Extensive information can be found under
# http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Properties
# https://docs.blender.org/api/current/bpy.props.html
my_string_prop: bpy.props.StringProperty()
my_float_prop: bpy.props.FloatProperty(default=3.1415926)

View File

@ -173,6 +173,8 @@ class AssetLibrary {
Vector<AssetLibraryReference> all_valid_asset_library_refs();
AssetLibraryReference all_library_reference();
} // namespace blender::asset_system
/**

View File

@ -359,4 +359,12 @@ Vector<AssetLibraryReference> all_valid_asset_library_refs()
return result;
}
AssetLibraryReference all_library_reference()
{
AssetLibraryReference all_library_ref{};
all_library_ref.custom_library_index = -1;
all_library_ref.type = ASSET_LIBRARY_ALL;
return all_library_ref;
}
} // namespace blender::asset_system

View File

@ -39,8 +39,6 @@ typedef struct BVHTreeFromEditMesh {
BVHTree_NearestPointCallback nearest_callback;
BVHTree_RayCastCallback raycast_callback;
struct BMEditMesh *em;
/* Private data */
bool cached;

View File

@ -119,6 +119,7 @@ typedef enum eContextObjectMode {
CTX_MODE_EDIT_LATTICE,
CTX_MODE_EDIT_CURVES,
CTX_MODE_EDIT_GREASE_PENCIL,
CTX_MODE_EDIT_POINT_CLOUD,
CTX_MODE_POSE,
CTX_MODE_SCULPT,
CTX_MODE_PAINT_WEIGHT,

View File

@ -461,7 +461,7 @@ void BKE_gpencil_layer_mask_cleanup_all_layers(struct bGPdata *gpd);
void BKE_gpencil_layer_frames_sort(struct bGPDlayer *gpl, bool *r_has_duplicate_frames);
struct bGPDlayer *BKE_gpencil_layer_get_by_name(struct bGPdata *gpd,
char *name,
const char *name,
int first_if_not_found);
/* Brush */

View File

@ -269,6 +269,10 @@ class LayerGroupRuntime {
* Caches all the layers in this group in a single pre-ordered vector.
*/
mutable Vector<Layer *> layer_cache_;
/**
* Caches all the layer groups in this group in a single pre-ordered vector.
*/
mutable Vector<LayerGroup *> layer_group_cache_;
};
/**
@ -282,10 +286,11 @@ class LayerGroup : public ::GreasePencilLayerTreeGroup {
~LayerGroup();
public:
StringRefNull name() const
{
return this->base.name;
}
StringRefNull name() const;
void set_name(StringRefNull new_name);
bool is_visible() const;
bool is_locked() const;
/**
* Adds a group at the end of this group.
@ -345,12 +350,24 @@ class LayerGroup : public ::GreasePencilLayerTreeGroup {
Span<const Layer *> layers() const;
Span<Layer *> layers_for_write();
/**
* Returns a `Span` of pointers to all the `LayerGroups`s in this group.
*/
Span<const LayerGroup *> groups() const;
Span<LayerGroup *> groups_for_write();
/**
* Returns a pointer to the layer with \a name. If no such layer was found, returns nullptr.
*/
const Layer *find_layer_by_name(StringRefNull name) const;
Layer *find_layer_by_name(StringRefNull name);
/**
* Returns a pointer to the group with \a name. If no such group was found, returns nullptr.
*/
const LayerGroup *find_group_by_name(StringRefNull name) const;
LayerGroup *find_group_by_name(StringRefNull name);
/**
* Print the nodes. For debugging purposes.
*/
@ -361,6 +378,15 @@ class LayerGroup : public ::GreasePencilLayerTreeGroup {
void tag_nodes_cache_dirty() const;
};
inline const TreeNode &Layer::as_node() const
{
return *reinterpret_cast<const TreeNode *>(this);
}
inline TreeNode &Layer::as_node()
{
return *reinterpret_cast<TreeNode *>(this);
}
inline StringRefNull Layer::name() const
{
return this->base.name;
@ -371,13 +397,9 @@ inline LayerGroup &Layer::parent_group() const
return this->base.parent->wrap();
}
inline const TreeNode &Layer::as_node() const
inline StringRefNull LayerGroup::name() const
{
return *reinterpret_cast<const TreeNode *>(this);
}
inline TreeNode &Layer::as_node()
{
return *reinterpret_cast<TreeNode *>(this);
return this->base.name;
}
namespace convert {

View File

@ -378,6 +378,9 @@ enum {
/** Clear asset data (in case the ID can actually be made local, in copy case asset data is never
* copied over). */
LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR = 1 << 3,
/** Clear any liboverride data as part of making this linked data local. */
LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR = 1 << 4,
};
/**

View File

@ -193,11 +193,11 @@ typedef struct LibraryForeachIDData LibraryForeachIDData;
* Check whether current iteration over ID usages should be stopped or not.
* \return true if the iteration should be stopped, false otherwise.
*/
bool BKE_lib_query_foreachid_iter_stop(struct LibraryForeachIDData *data);
bool BKE_lib_query_foreachid_iter_stop(const struct LibraryForeachIDData *data);
void BKE_lib_query_foreachid_process(struct LibraryForeachIDData *data,
struct ID **id_pp,
int cb_flag);
int BKE_lib_query_foreachid_process_flags_get(struct LibraryForeachIDData *data);
int BKE_lib_query_foreachid_process_flags_get(const struct LibraryForeachIDData *data);
int BKE_lib_query_foreachid_process_callback_flag_override(struct LibraryForeachIDData *data,
int cb_flag,
bool do_replace);

View File

@ -540,6 +540,16 @@ inline blender::MutableSpan<bNodePanel *> bNodeTree::panels_for_write()
return blender::MutableSpan(panels_array, panels_num);
}
inline blender::MutableSpan<bNestedNodeRef> bNodeTree::nested_node_refs_span()
{
return {this->nested_node_refs, this->nested_node_refs_num};
}
inline blender::Span<bNestedNodeRef> bNodeTree::nested_node_refs_span() const
{
return {this->nested_node_refs, this->nested_node_refs_num};
}
/** \} */
/* -------------------------------------------------------------------- */

View File

@ -9,6 +9,8 @@
#include "BLI_map.hh"
#include "BLI_sub_frame.hh"
struct bNodeTree;
namespace blender::bke::sim {
class BDataSharing;
@ -89,17 +91,17 @@ class SimulationZoneState {
/** Identifies a simulation zone (input and output node pair) used by a modifier. */
struct SimulationZoneID {
/** Every node identifier in the hierarchy of compute contexts. */
Vector<int> node_ids;
/** ID of the #bNestedNodeRef that references the output node of the zone. */
int32_t nested_node_id;
uint64_t hash() const
{
return get_default_hash(this->node_ids);
return this->nested_node_id;
}
friend bool operator==(const SimulationZoneID &a, const SimulationZoneID &b)
{
return a.node_ids == b.node_ids;
return a.nested_node_id == b.nested_node_id;
}
};
@ -122,7 +124,7 @@ class ModifierSimulationState {
const SimulationZoneState *get_zone_state(const SimulationZoneID &zone_id) const;
SimulationZoneState &get_zone_state_for_write(const SimulationZoneID &zone_id);
void ensure_bake_loaded() const;
void ensure_bake_loaded(const bNodeTree &ntree) const;
};
struct ModifierSimulationStateAtFrame {

View File

@ -163,7 +163,8 @@ void serialize_modifier_simulation_state(const ModifierSimulationState &state,
* Fill the simulation state by parsing the provided #DictionaryValue which also contains
* references to external binary data that is read using #bdata_reader.
*/
void deserialize_modifier_simulation_state(const DictionaryValue &io_root,
void deserialize_modifier_simulation_state(const bNodeTree &ntree,
const DictionaryValue &io_root,
const BDataReader &bdata_reader,
const BDataSharing &bdata_sharing,
ModifierSimulationState &r_state);

View File

@ -164,79 +164,9 @@ bool BKE_volume_save(const struct Volume *volume,
* file or copy shared grids to make them writeable. */
#ifdef __cplusplus
# include "BLI_math_matrix_types.hh"
# include "BLI_math_vector_types.hh"
# include "BLI_string_ref.hh"
bool BKE_volume_min_max(const Volume *volume, blender::float3 &r_min, blender::float3 &r_max);
# ifdef WITH_OPENVDB
# include <openvdb/openvdb.h>
# include <openvdb/points/PointDataGrid.h>
VolumeGrid *BKE_volume_grid_add_vdb(Volume &volume,
blender::StringRef name,
openvdb::GridBase::Ptr vdb_grid);
bool BKE_volume_grid_bounds(openvdb::GridBase::ConstPtr grid,
blender::float3 &r_min,
blender::float3 &r_max);
/**
* Return a new grid pointer with only the metadata and transform changed.
* This is useful for instances, where there is a separate transform on top of the original
* grid transform that must be applied for some operations that only take a grid argument.
*/
openvdb::GridBase::ConstPtr BKE_volume_grid_shallow_transform(openvdb::GridBase::ConstPtr grid,
const blender::float4x4 &transform);
openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_metadata(const struct VolumeGrid *grid);
openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_read(const struct Volume *volume,
const struct VolumeGrid *grid);
openvdb::GridBase::Ptr BKE_volume_grid_openvdb_for_write(const struct Volume *volume,
struct VolumeGrid *grid,
bool clear);
void BKE_volume_grid_clear_tree(Volume &volume, VolumeGrid &volume_grid);
void BKE_volume_grid_clear_tree(openvdb::GridBase &grid);
VolumeGridType BKE_volume_grid_type_openvdb(const openvdb::GridBase &grid);
template<typename OpType>
auto BKE_volume_grid_type_operation(const VolumeGridType grid_type, OpType &&op)
{
switch (grid_type) {
case VOLUME_GRID_FLOAT:
return op.template operator()<openvdb::FloatGrid>();
case VOLUME_GRID_VECTOR_FLOAT:
return op.template operator()<openvdb::Vec3fGrid>();
case VOLUME_GRID_BOOLEAN:
return op.template operator()<openvdb::BoolGrid>();
case VOLUME_GRID_DOUBLE:
return op.template operator()<openvdb::DoubleGrid>();
case VOLUME_GRID_INT:
return op.template operator()<openvdb::Int32Grid>();
case VOLUME_GRID_INT64:
return op.template operator()<openvdb::Int64Grid>();
case VOLUME_GRID_VECTOR_INT:
return op.template operator()<openvdb::Vec3IGrid>();
case VOLUME_GRID_VECTOR_DOUBLE:
return op.template operator()<openvdb::Vec3dGrid>();
case VOLUME_GRID_MASK:
return op.template operator()<openvdb::MaskGrid>();
case VOLUME_GRID_POINTS:
return op.template operator()<openvdb::points::PointDataGrid>();
case VOLUME_GRID_UNKNOWN:
break;
}
/* Should never be called. */
BLI_assert_msg(0, "should never be reached");
return op.template operator()<openvdb::FloatGrid>();
}
openvdb::GridBase::Ptr BKE_volume_grid_create_with_changed_resolution(
const VolumeGridType grid_type, const openvdb::GridBase &old_grid, float resolution_factor);
# endif
#endif

View File

@ -0,0 +1,80 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#ifdef WITH_OPENVDB
# include <openvdb/openvdb.h>
# include <openvdb/points/PointDataGrid.h>
# include "BLI_math_matrix_types.hh"
# include "BLI_math_vector_types.hh"
# include "BLI_string_ref.hh"
VolumeGrid *BKE_volume_grid_add_vdb(Volume &volume,
blender::StringRef name,
openvdb::GridBase::Ptr vdb_grid);
bool BKE_volume_grid_bounds(openvdb::GridBase::ConstPtr grid,
blender::float3 &r_min,
blender::float3 &r_max);
/**
* Return a new grid pointer with only the metadata and transform changed.
* This is useful for instances, where there is a separate transform on top of the original
* grid transform that must be applied for some operations that only take a grid argument.
*/
openvdb::GridBase::ConstPtr BKE_volume_grid_shallow_transform(openvdb::GridBase::ConstPtr grid,
const blender::float4x4 &transform);
openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_metadata(const struct VolumeGrid *grid);
openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_read(const struct Volume *volume,
const struct VolumeGrid *grid);
openvdb::GridBase::Ptr BKE_volume_grid_openvdb_for_write(const struct Volume *volume,
struct VolumeGrid *grid,
bool clear);
void BKE_volume_grid_clear_tree(Volume &volume, VolumeGrid &volume_grid);
void BKE_volume_grid_clear_tree(openvdb::GridBase &grid);
VolumeGridType BKE_volume_grid_type_openvdb(const openvdb::GridBase &grid);
template<typename OpType>
auto BKE_volume_grid_type_operation(const VolumeGridType grid_type, OpType &&op)
{
switch (grid_type) {
case VOLUME_GRID_FLOAT:
return op.template operator()<openvdb::FloatGrid>();
case VOLUME_GRID_VECTOR_FLOAT:
return op.template operator()<openvdb::Vec3fGrid>();
case VOLUME_GRID_BOOLEAN:
return op.template operator()<openvdb::BoolGrid>();
case VOLUME_GRID_DOUBLE:
return op.template operator()<openvdb::DoubleGrid>();
case VOLUME_GRID_INT:
return op.template operator()<openvdb::Int32Grid>();
case VOLUME_GRID_INT64:
return op.template operator()<openvdb::Int64Grid>();
case VOLUME_GRID_VECTOR_INT:
return op.template operator()<openvdb::Vec3IGrid>();
case VOLUME_GRID_VECTOR_DOUBLE:
return op.template operator()<openvdb::Vec3dGrid>();
case VOLUME_GRID_MASK:
return op.template operator()<openvdb::MaskGrid>();
case VOLUME_GRID_POINTS:
return op.template operator()<openvdb::points::PointDataGrid>();
case VOLUME_GRID_UNKNOWN:
break;
}
/* Should never be called. */
BLI_assert_msg(0, "should never be reached");
return op.template operator()<openvdb::FloatGrid>();
}
openvdb::GridBase::Ptr BKE_volume_grid_create_with_changed_resolution(
const VolumeGridType grid_type, const openvdb::GridBase &old_grid, float resolution_factor);
#endif

View File

@ -29,7 +29,6 @@ set(INC
../../../intern/ghost
../../../intern/guardedalloc
../../../intern/iksolver/extern
../../../intern/atomic
../../../intern/clog
../../../intern/libmv
../../../intern/mantaflow/extern
@ -503,6 +502,7 @@ set(SRC
BKE_vfontdata.h
BKE_viewer_path.h
BKE_volume.h
BKE_volume_openvdb.hh
BKE_volume_render.h
BKE_volume_to_mesh.hh
BKE_workspace.h
@ -556,7 +556,7 @@ set(LIB
bf_shader_fx
bf_simulation
extern_fmtlib
PRIVATE bf_intern_atomic
# For `vfontdata_freetype.c`.
${FREETYPE_LIBRARIES} ${BROTLI_LIBRARIES}
)

View File

@ -227,7 +227,7 @@ static void setup_app_userdef(BlendFileData *bfd)
* NOTE: this is only used when actually loading a real `.blend` file,
* loading of memfile undo steps does not need it.
*/
typedef struct ReuseOldBMainData {
struct ReuseOldBMainData {
Main *new_bmain;
Main *old_bmain;
@ -245,7 +245,7 @@ typedef struct ReuseOldBMainData {
/** Used to find matching IDs by name/lib in new main, to remap ID usages of data ported over
* from old main. */
IDNameLib_Map *id_map;
} ReuseOldBMainData;
};
/** Search for all libraries in `old_bmain` that are also in `new_bmain` (i.e. different Library
* IDs having the same absolute filepath), and create a remapping rule for these.
@ -447,6 +447,7 @@ static void swap_wm_data_for_blendfile(ReuseOldBMainData *reuse_data, const bool
else {
swap_old_bmain_data_for_blendfile(reuse_data, ID_WM);
old_wm->init_flag &= ~WM_INIT_FLAG_WINDOW;
reuse_data->wm_setup_data->old_wm = old_wm;
}
}
@ -1174,7 +1175,7 @@ UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf,
return userdef;
}
UserDef *BKE_blendfile_userdef_from_defaults(void)
UserDef *BKE_blendfile_userdef_from_defaults()
{
UserDef *userdef = static_cast<UserDef *>(MEM_callocN(sizeof(UserDef), __func__));
*userdef = blender::dna::shallow_copy(U_default);

View File

@ -125,9 +125,21 @@ typedef struct BlendfileLinkAppendContextCallBack {
BlendfileLinkAppendContextItem *item;
ReportList *reports;
/** Whether the currently evaluated usage is within some liboverride dependency context. Note
* that this include liboverride reference itself, but also e.g. if a linked Mesh is used by the
* reference of an overridden object.
*
* Mutually exclusive with #is_liboverride_dependency_only. */
bool is_liboverride_dependency;
/** Whether the currently evaluated usage is exclusively within some liboverride dependency
* context, i.e. the full all usages of this data so far have only been a part of liboverride
* references and their dependencies.
*
* Mutually exclusive with #is_liboverride_dependency. */
bool is_liboverride_dependency_only;
} BlendfileLinkAppendContextCallBack;
/* Actions to apply to an item (i.e. linked ID). */
/** Actions to apply to an item (i.e. linked ID). */
enum {
LINK_APPEND_ACT_UNSET = 0,
LINK_APPEND_ACT_KEEP_LINKED,
@ -136,10 +148,23 @@ enum {
LINK_APPEND_ACT_COPY_LOCAL,
};
/* Various status info about an item (i.e. linked ID). */
/** Various status info about an item (i.e. linked ID). */
enum {
/* An indirectly linked ID. */
/** An indirectly linked ID. */
LINK_APPEND_TAG_INDIRECT = 1 << 0,
/** An ID also used as liboverride dependency (either directly, as a liboverride reference, or
* indirectly, as data used by a liboverride reference). It should never be directly made local.
*
* Mutually exclusive with #LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY.
*/
LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY = 1 << 1,
/** An ID only used as liboverride dependency (either directly or indirectly, see
* #LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY for precisions). It should not be considered during
* the 'make local' process, and remain purely linked data.
*
* Mutually exclusive with #LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY.
*/
LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY = 1 << 2,
};
static BlendHandle *link_append_context_library_blohandle_ensure(
@ -929,7 +954,7 @@ static int foreach_libblock_link_append_callback(LibraryIDLinkCallbackData *cb_d
/* NOTE: It is important to also skip liboverride references here, as those should never be made
* local. */
if (cb_data->cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING | IDWALK_CB_INTERNAL |
IDWALK_CB_LOOPBACK | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE))
IDWALK_CB_LOOPBACK))
{
return IDWALK_RET_NOP;
}
@ -983,7 +1008,7 @@ static int foreach_libblock_link_append_callback(LibraryIDLinkCallbackData *cb_d
data->lapp_context, id->name, GS(id->name), NULL);
item->new_id = id;
item->source_library = id->lib;
/* Since we did not have an item for that ID yet, we know user did not selected it explicitly,
/* Since we did not have an item for that ID yet, we know user did not select it explicitly,
* it was rather linked indirectly. This info is important for instantiation of collections. */
item->tag |= LINK_APPEND_TAG_INDIRECT;
/* In linking case we already know what we want to do with those items. */
@ -991,6 +1016,54 @@ static int foreach_libblock_link_append_callback(LibraryIDLinkCallbackData *cb_d
item->action = LINK_APPEND_ACT_KEEP_LINKED;
}
new_id_to_item_mapping_add(data->lapp_context, id, item);
if ((cb_data->cb_flag & IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE) != 0 ||
data->is_liboverride_dependency_only)
{
/* New item, (currently) detected as only used as a liboverride linked dependency. */
item->tag |= LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY;
}
else if (data->is_liboverride_dependency) {
/* New item, (currently) detected as used as a liboverride linked dependency, among
* others. */
item->tag |= LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY;
}
}
else {
if ((cb_data->cb_flag & IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE) != 0 ||
data->is_liboverride_dependency_only)
{
/* Existing item, here only used as a liboverride reference dependency. If it was not tagged
* as such before, it is also used by non-liboverride reference data. */
if ((item->tag & LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY) == 0) {
item->tag |= LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY;
/* In case that item was already processed, and marked to be directly made local, its
* action needs to be changed to copying instead, since no liboverride reference (or their
* dependencies) should ever be made local. */
if (item->action == LINK_APPEND_ACT_MAKE_LOCAL) {
CLOG_INFO(
&LOG,
3,
"Appended ID '%s' is also used as a liboverride linked dependency, duplicating it.",
id->name);
item->action = LINK_APPEND_ACT_COPY_LOCAL;
}
}
}
else if ((item->tag & LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY) != 0) {
/* Existing item, here used in a non-liboverride dependency context. If it was
* tagged as a liboverride dependency only, its tag and action need to be updated. */
item->tag |= LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY;
item->tag &= ~LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY;
if (item->action == LINK_APPEND_ACT_KEEP_LINKED) {
CLOG_INFO(
&LOG,
3,
"Appended ID '%s' is also used as a liboverride linked dependency, duplicating it.",
id->name);
item->action = LINK_APPEND_ACT_COPY_LOCAL;
}
}
}
/* NOTE: currently there is no need to do anything else here, but in the future this would be
@ -1044,11 +1117,16 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *
const bool do_reuse_local_id = (lapp_context->params->flag &
BLO_LIBLINK_APPEND_LOCAL_ID_REUSE) != 0;
const int make_local_common_flags = LIB_ID_MAKELOCAL_FULL_LIBRARY |
((lapp_context->params->flag &
BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR) != 0 ?
LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR :
0);
const int make_local_common_flags =
LIB_ID_MAKELOCAL_FULL_LIBRARY |
((lapp_context->params->flag & BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR) != 0 ?
LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR :
0) |
/* In recursive case (i.e. everything becomes local), clear liboverrides. Otherwise (i.e.
* only data from immediately linked libraries is made local), preserve liboverrides. */
((lapp_context->params->flag & BLO_LIBLINK_APPEND_RECURSIVE) != 0 ?
LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR :
0);
LinkNode *itemlink;
@ -1072,29 +1150,61 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *
id->lib->filepath,
id->name) :
NULL;
const bool is_liboverride_dependency = (item->tag & LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY) !=
0;
const bool is_liboverride_dependency_only = (item->tag &
LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY) != 0;
/* These two flags are mutually exclusive. */
BLI_assert(!(is_liboverride_dependency && is_liboverride_dependency_only));
if (item->action != LINK_APPEND_ACT_UNSET) {
/* Already set, pass. */
}
else if (item->tag & LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY) {
CLOG_INFO(
&LOG,
3,
"Appended ID '%s' is only used as a liboverride linked dependency, keeping it linked.",
id->name);
item->action = LINK_APPEND_ACT_KEEP_LINKED;
}
else if (do_reuse_local_id && existing_local_id != NULL) {
CLOG_INFO(&LOG, 3, "Appended ID '%s' as a matching local one, re-using it...", id->name);
CLOG_INFO(&LOG, 3, "Appended ID '%s' as a matching local one, re-using it.", id->name);
item->action = LINK_APPEND_ACT_REUSE_LOCAL;
item->userdata = existing_local_id;
}
else if (id->tag & LIB_TAG_PRE_EXISTING) {
CLOG_INFO(&LOG, 3, "Appended ID '%s' was already linked, need to copy it...", id->name);
CLOG_INFO(&LOG, 3, "Appended ID '%s' was already linked, duplicating it.", id->name);
item->action = LINK_APPEND_ACT_COPY_LOCAL;
}
else if (item->tag & LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY) {
CLOG_INFO(
&LOG,
3,
"Appended ID '%s' is also used as a liboverride linked dependency, duplicating it.",
id->name);
item->action = LINK_APPEND_ACT_COPY_LOCAL;
}
else {
CLOG_INFO(&LOG, 3, "Appended ID '%s' will be made local...", id->name);
CLOG_INFO(&LOG, 3, "Appended ID '%s' will be made local.", id->name);
item->action = LINK_APPEND_ACT_MAKE_LOCAL;
}
/* Only check dependencies if we are not keeping linked data, nor re-using existing local data.
/* Only check dependencies if linked data are not kept, nor existing local data are re-used,
* and if the item is not used for liboverride dependencies.
*
* NOTE: liboverride dependencies require complete check of all usages of the ID, as this may
* change the status and action of its item (see #foreach_libblock_link_append_callback code).
*/
if (!ELEM(item->action, LINK_APPEND_ACT_KEEP_LINKED, LINK_APPEND_ACT_REUSE_LOCAL)) {
if (!ELEM(item->action, LINK_APPEND_ACT_KEEP_LINKED, LINK_APPEND_ACT_REUSE_LOCAL) ||
is_liboverride_dependency || is_liboverride_dependency_only)
{
BlendfileLinkAppendContextCallBack cb_data = {
.lapp_context = lapp_context, .item = item, .reports = reports};
.lapp_context = lapp_context,
.item = item,
.reports = reports,
.is_liboverride_dependency = is_liboverride_dependency,
.is_liboverride_dependency_only = is_liboverride_dependency_only};
BKE_library_foreach_ID_link(
bmain, id, foreach_libblock_link_append_callback, &cb_data, IDWALK_NOP);
}
@ -1219,6 +1329,12 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *
if (id->tag & LIB_TAG_PRE_EXISTING) {
continue;
}
/* Do NOT delete a linked data that is (also) used a liboverride dependency. */
if (item->tag &
(LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY | LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY))
{
continue;
}
id->tag |= LIB_TAG_DOIT;
}

View File

@ -464,13 +464,13 @@ IDTypeInfo IDType_ID_BR = {
static RNG *brush_rng;
void BKE_brush_system_init(void)
void BKE_brush_system_init()
{
brush_rng = BLI_rng_new(0);
BLI_rng_srandom(brush_rng, 31415682);
}
void BKE_brush_system_exit(void)
void BKE_brush_system_exit()
{
if (brush_rng == nullptr) {
return;

View File

@ -300,8 +300,7 @@ static void editmesh_looptri_nearest_point(void *userdata,
const float co[3],
BVHTreeNearest *nearest)
{
const BVHTreeFromEditMesh *data = (const BVHTreeFromEditMesh *)userdata;
BMEditMesh *em = data->em;
BMEditMesh *em = static_cast<BMEditMesh *>(userdata);
const BMLoop **ltri = (const BMLoop **)em->looptris[index];
const float *t0, *t1, *t2;
@ -405,8 +404,7 @@ static void editmesh_looptri_spherecast(void *userdata,
const BVHTreeRay *ray,
BVHTreeRayHit *hit)
{
const BVHTreeFromEditMesh *data = (BVHTreeFromEditMesh *)userdata;
BMEditMesh *em = data->em;
BMEditMesh *em = static_cast<BMEditMesh *>(userdata);
const BMLoop **ltri = (const BMLoop **)em->looptris[index];
const float *t0, *t1, *t2;
@ -492,8 +490,8 @@ static void editmesh_verts_spherecast(void *userdata,
const BVHTreeRay *ray,
BVHTreeRayHit *hit)
{
const BVHTreeFromEditMesh *data = (const BVHTreeFromEditMesh *)userdata;
BMVert *eve = BM_vert_at_index(data->em->bm, index);
BMEditMesh *em = static_cast<BMEditMesh *>(userdata);
BMVert *eve = BM_vert_at_index(em->bm, index);
mesh_verts_spherecast_do(index, eve->co, ray, hit);
}
@ -629,15 +627,12 @@ static void bvhtree_from_mesh_setup_data(BVHTree *tree,
static void bvhtree_from_editmesh_setup_data(BVHTree *tree,
const BVHCacheType bvh_cache_type,
BMEditMesh *em,
BVHTreeFromEditMesh *r_data)
{
memset(r_data, 0, sizeof(*r_data));
r_data->tree = tree;
r_data->em = em;
switch (bvh_cache_type) {
case BVHTREE_FROM_EM_LOOSEVERTS:
r_data->nearest_callback = nullptr;
@ -754,7 +749,7 @@ BVHTree *bvhtree_from_editmesh_verts_ex(BVHTreeFromEditMesh *data,
bvhtree_balance(tree, false);
if (data) {
bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_LOOSEVERTS, em, data);
bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_LOOSEVERTS, data);
}
return tree;
@ -870,7 +865,7 @@ BVHTree *bvhtree_from_editmesh_edges_ex(BVHTreeFromEditMesh *data,
bvhtree_balance(tree, false);
if (data) {
bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_EDGES, em, data);
bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_EDGES, data);
}
return tree;
@ -1047,7 +1042,7 @@ BVHTree *bvhtree_from_editmesh_looptri_ex(BVHTreeFromEditMesh *data,
bvhtree_balance(tree, false);
if (data) {
bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_LOOPTRI, em, data);
bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_LOOPTRI, data);
}
return tree;
}
@ -1281,7 +1276,7 @@ BVHTree *BKE_bvhtree_from_editmesh_get(BVHTreeFromEditMesh *data,
{
bool lock_started = false;
bvhtree_from_editmesh_setup_data(nullptr, bvh_cache_type, em, data);
bvhtree_from_editmesh_setup_data(nullptr, bvh_cache_type, data);
if (bvh_cache_p) {
data->cached = bvhcache_find(

View File

@ -101,7 +101,7 @@ struct bContext {
/* context */
bContext *CTX_create(void)
bContext *CTX_create()
{
bContext *C = MEM_cnew<bContext>(__func__);
@ -1188,6 +1188,8 @@ enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit,
return CTX_MODE_EDIT_CURVES;
case OB_GREASE_PENCIL:
return CTX_MODE_EDIT_GREASE_PENCIL;
case OB_POINTCLOUD:
return CTX_MODE_EDIT_POINT_CLOUD;
}
}
else {
@ -1248,29 +1250,12 @@ enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
* \note Must be aligned with above enum.
*/
static const char *data_mode_strings[] = {
"mesh_edit",
"curve_edit",
"surface_edit",
"text_edit",
"armature_edit",
"mball_edit",
"lattice_edit",
"curves_edit",
"grease_pencil_edit",
"posemode",
"sculpt_mode",
"weightpaint",
"vertexpaint",
"imagepaint",
"particlemode",
"objectmode",
"greasepencil_paint",
"greasepencil_edit",
"greasepencil_sculpt",
"greasepencil_weight",
"greasepencil_vertex",
"curves_sculpt",
nullptr,
"mesh_edit", "curve_edit", "surface_edit", "text_edit",
"armature_edit", "mball_edit", "lattice_edit", "curves_edit",
"grease_pencil_edit", "point_cloud_edit", "posemode", "sculpt_mode",
"weightpaint", "vertexpaint", "imagepaint", "particlemode",
"objectmode", "greasepencil_paint", "greasepencil_edit", "greasepencil_sculpt",
"greasepencil_weight", "greasepencil_vertex", "curves_sculpt", nullptr,
};
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings) == CTX_MODE_NUM + 1,
"Must have a string for each context mode")

View File

@ -89,7 +89,7 @@ static bool calc_curve_deform(
}
}
else {
CurveCache *cc = ob_curve->runtime.curve_cache;
const CurveCache *cc = ob_curve->runtime.curve_cache;
float totdist = BKE_anim_path_get_length(cc);
if (LIKELY(totdist > FLT_EPSILON)) {
fac = -(co[index] - cd->dmax[index]) / totdist;
@ -111,7 +111,7 @@ static bool calc_curve_deform(
}
}
else {
CurveCache *cc = ob_curve->runtime.curve_cache;
const CurveCache *cc = ob_curve->runtime.curve_cache;
float totdist = BKE_anim_path_get_length(cc);
if (LIKELY(totdist > FLT_EPSILON)) {
fac = +(co[index] - cd->dmin[index]) / totdist;

View File

@ -1946,7 +1946,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr,
nullptr,
nullptr},
/* 51: CD_HAIRLENGTH */
/* 51: CD_HAIRLENGTH */ /* DEPRECATED */ /* UNUSED */
{sizeof(float), "float", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},
/* 52: CD_PROP_QUATERNION */
{sizeof(float[4]),

View File

@ -486,7 +486,6 @@ bool try_capture_field_on_geometry(GeometryComponent &component,
}
const bke::GeometryFieldContext field_context{component, domain};
const IndexMask mask{IndexMask(domain_size)};
const bke::AttributeValidator validator = attributes.lookup_validator(attribute_id);
const std::optional<AttributeMetaData> meta_data = attributes.lookup_meta_data(attribute_id);
@ -496,10 +495,8 @@ bool try_capture_field_on_geometry(GeometryComponent &component,
/* We are writing to an attribute that exists already with the correct domain and type. */
if (attribute_matches) {
if (GSpanAttributeWriter dst_attribute = attributes.lookup_for_write_span(attribute_id)) {
const IndexMask mask{IndexMask(domain_size)};
const bke::GeometryFieldContext field_context{component, domain};
fn::FieldEvaluator evaluator{field_context, &mask};
fn::FieldEvaluator evaluator{field_context, domain_size};
evaluator.add(validator.validate_field_if_necessary(field));
evaluator.set_selection(selection);
evaluator.evaluate();
@ -528,7 +525,7 @@ bool try_capture_field_on_geometry(GeometryComponent &component,
if (!selection_is_full) {
type.value_initialize_n(buffer, domain_size);
}
fn::FieldEvaluator evaluator{field_context, &mask};
fn::FieldEvaluator evaluator{field_context, domain_size};
evaluator.add_with_destination(validator.validate_field_if_necessary(field),
GMutableSpan{type, buffer, domain_size});
evaluator.set_selection(selection);

View File

@ -1573,7 +1573,7 @@ bGPDlayer *BKE_gpencil_layer_active_get(bGPdata *gpd)
return NULL;
}
bGPDlayer *BKE_gpencil_layer_get_by_name(bGPdata *gpd, char *name, int first_if_not_found)
bGPDlayer *BKE_gpencil_layer_get_by_name(bGPdata *gpd, const char *name, int first_if_not_found)
{
bGPDlayer *gpl;

View File

@ -490,12 +490,12 @@ Map<int, GreasePencilFrame> &Layer::frames_for_write()
bool Layer::is_visible() const
{
return (this->base.flag & GP_LAYER_TREE_NODE_HIDE) == 0;
return this->parent_group().is_visible() && (this->base.flag & GP_LAYER_TREE_NODE_HIDE) == 0;
}
bool Layer::is_locked() const
{
return (this->base.flag & GP_LAYER_TREE_NODE_LOCKED) != 0;
return this->parent_group().is_locked() || (this->base.flag & GP_LAYER_TREE_NODE_LOCKED) != 0;
}
bool Layer::insert_frame(int frame_number, const GreasePencilFrame &frame)
@ -616,6 +616,29 @@ LayerGroup::~LayerGroup()
this->runtime = nullptr;
}
void LayerGroup::set_name(StringRefNull new_name)
{
this->base.name = BLI_strdup(new_name.c_str());
}
bool LayerGroup::is_visible() const
{
if (this->base.parent) {
return this->base.parent->wrap().is_visible() &&
(this->base.flag & GP_LAYER_TREE_NODE_HIDE) == 0;
}
return (this->base.flag & GP_LAYER_TREE_NODE_HIDE) == 0;
}
bool LayerGroup::is_locked() const
{
if (this->base.parent) {
return this->base.parent->wrap().is_locked() ||
(this->base.flag & GP_LAYER_TREE_NODE_LOCKED) != 0;
}
return (this->base.flag & GP_LAYER_TREE_NODE_LOCKED) != 0;
}
LayerGroup &LayerGroup::add_group(LayerGroup *group)
{
BLI_assert(group != nullptr);
@ -742,6 +765,18 @@ Span<Layer *> LayerGroup::layers_for_write()
return this->runtime->layer_cache_.as_span();
}
Span<const LayerGroup *> LayerGroup::groups() const
{
this->ensure_nodes_cache();
return this->runtime->layer_group_cache_.as_span();
}
Span<LayerGroup *> LayerGroup::groups_for_write()
{
this->ensure_nodes_cache();
return this->runtime->layer_group_cache_.as_span();
}
const Layer *LayerGroup::find_layer_by_name(const StringRefNull name) const
{
for (const Layer *layer : this->layers()) {
@ -762,6 +797,26 @@ Layer *LayerGroup::find_layer_by_name(const StringRefNull name)
return nullptr;
}
const LayerGroup *LayerGroup::find_group_by_name(StringRefNull name) const
{
for (const LayerGroup *group : this->groups()) {
if (StringRef(group->name()) == StringRef(name)) {
return group;
}
}
return nullptr;
}
LayerGroup *LayerGroup::find_group_by_name(StringRefNull name)
{
for (LayerGroup *group : this->groups_for_write()) {
if (StringRef(group->name()) == StringRef(name)) {
return group;
}
}
return nullptr;
}
void LayerGroup::print_nodes(StringRefNull header) const
{
std::cout << header << std::endl;
@ -795,6 +850,7 @@ void LayerGroup::ensure_nodes_cache() const
this->runtime->nodes_cache_mutex_.ensure([&]() {
this->runtime->nodes_cache_.clear_and_shrink();
this->runtime->layer_cache_.clear_and_shrink();
this->runtime->layer_group_cache_.clear_and_shrink();
LISTBASE_FOREACH (GreasePencilLayerTreeNode *, child_, &this->children) {
TreeNode *node = reinterpret_cast<TreeNode *>(child_);
@ -805,11 +861,15 @@ void LayerGroup::ensure_nodes_cache() const
break;
}
case GP_LAYER_TREE_GROUP: {
this->runtime->layer_group_cache_.append(&node->as_group_for_write());
for (TreeNode *child : node->as_group_for_write().nodes_for_write()) {
this->runtime->nodes_cache_.append(child);
if (child->is_layer()) {
this->runtime->layer_cache_.append(&child->as_layer_for_write());
}
else if (child->is_group()) {
this->runtime->layer_group_cache_.append(&child->as_group_for_write());
}
}
break;
}
@ -868,9 +928,7 @@ BoundBox *BKE_grease_pencil_boundbox_get(Object *ob)
return ob->runtime.bb;
}
void BKE_grease_pencil_data_update(struct Depsgraph * /*depsgraph*/,
struct Scene * /*scene*/,
Object *object)
void BKE_grease_pencil_data_update(Depsgraph * /*depsgraph*/, Scene * /*scene*/, Object *object)
{
/* Free any evaluated data and restore original data. */
BKE_object_free_derived_caches(object);
@ -1212,6 +1270,12 @@ std::optional<blender::Bounds<blender::float3>> GreasePencil::bounds_min_max() c
return bounds;
}
blender::Span<const blender::bke::greasepencil::TreeNode *> GreasePencil::nodes() const
{
BLI_assert(this->runtime != nullptr);
return this->root_group.wrap().nodes();
}
blender::Span<const blender::bke::greasepencil::Layer *> GreasePencil::layers() const
{
BLI_assert(this->runtime != nullptr);
@ -1224,10 +1288,16 @@ blender::Span<blender::bke::greasepencil::Layer *> GreasePencil::layers_for_writ
return this->root_group.wrap().layers_for_write();
}
blender::Span<const blender::bke::greasepencil::TreeNode *> GreasePencil::nodes() const
blender::Span<const blender::bke::greasepencil::LayerGroup *> GreasePencil::groups() const
{
BLI_assert(this->runtime != nullptr);
return this->root_group.wrap().nodes();
return this->root_group.wrap().groups();
}
blender::Span<blender::bke::greasepencil::LayerGroup *> GreasePencil::groups_for_write()
{
BLI_assert(this->runtime != nullptr);
return this->root_group.wrap().groups_for_write();
}
const blender::bke::greasepencil::Layer *GreasePencil::get_active_layer() const
@ -1346,6 +1416,18 @@ blender::bke::greasepencil::Layer *GreasePencil::find_layer_by_name(
return this->root_group.wrap().find_layer_by_name(name);
}
const blender::bke::greasepencil::LayerGroup *GreasePencil::find_group_by_name(
blender::StringRefNull name) const
{
return this->root_group.wrap().find_group_by_name(name);
}
blender::bke::greasepencil::LayerGroup *GreasePencil::find_group_by_name(
blender::StringRefNull name)
{
return this->root_group.wrap().find_group_by_name(name);
}
void GreasePencil::rename_layer(blender::bke::greasepencil::Layer &layer,
blender::StringRefNull new_name)
{
@ -1359,6 +1441,19 @@ void GreasePencil::rename_layer(blender::bke::greasepencil::Layer &layer,
layer.set_name(unique_name);
}
void GreasePencil::rename_group(blender::bke::greasepencil::LayerGroup &group,
blender::StringRefNull new_name)
{
using namespace blender;
if (group.name() == new_name) {
return;
}
VectorSet<StringRefNull> names = get_node_names(*this);
std::string unique_name(new_name.c_str());
unique_layer_group_name(names, unique_name.data());
group.set_name(unique_name);
}
void GreasePencil::remove_layer(blender::bke::greasepencil::Layer &layer)
{
using namespace blender::bke::greasepencil;

View File

@ -4831,7 +4831,7 @@ struct ImagePool {
ThreadMutex mutex;
};
ImagePool *BKE_image_pool_new(void)
ImagePool *BKE_image_pool_new()
{
ImagePool *pool = MEM_cnew<ImagePool>("Image Pool");
pool->memory_pool = BLI_mempool_create(sizeof(ImagePoolItem), 0, 128, BLI_MEMPOOL_NOP);

View File

@ -778,12 +778,12 @@ int BKE_layer_collection_findindex(ViewLayer *view_layer, const LayerCollection
static bool no_resync = false;
void BKE_layer_collection_resync_forbid(void)
void BKE_layer_collection_resync_forbid()
{
no_resync = true;
}
void BKE_layer_collection_resync_allow(void)
void BKE_layer_collection_resync_allow()
{
no_resync = false;
}

View File

@ -506,10 +506,16 @@ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags)
if (force_local) {
BKE_lib_id_clear_library_data(bmain, id, flags);
if ((flags & LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR) != 0) {
BKE_lib_override_library_make_local(id);
}
BKE_lib_id_expand_local(bmain, id, flags);
}
else if (force_copy) {
ID *id_new = BKE_id_copy(bmain, id);
const int copy_flags =
(LIB_ID_COPY_DEFAULT |
((flags & LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR) != 0 ? LIB_ID_COPY_NO_LIB_OVERRIDE : 0));
ID *id_new = BKE_id_copy_ex(bmain, id, NULL, copy_flags);
/* Should not fail in expected use cases,
* but a few ID types cannot be copied (LIB, WM, SCR...). */

View File

@ -138,7 +138,7 @@ static const blender::bke::id::remapper::IDRemapper *unwrap(const IDRemapper *re
extern "C" {
IDRemapper *BKE_id_remapper_create(void)
IDRemapper *BKE_id_remapper_create()
{
blender::bke::id::remapper::IDRemapper *remapper =
MEM_new<blender::bke::id::remapper::IDRemapper>(__func__);

View File

@ -4699,7 +4699,7 @@ bool BKE_lib_override_library_id_is_user_deletable(Main *bmain, ID *id)
* exact same data as "desired" ones (kind of "baked" data-blocks).
*/
OverrideLibraryStorage *BKE_lib_override_library_operations_store_init(void)
OverrideLibraryStorage *BKE_lib_override_library_operations_store_init()
{
return BKE_main_new();
}

View File

@ -61,7 +61,7 @@ typedef struct LibraryForeachIDData {
BLI_LINKSTACK_DECLARE(ids_todo, ID *);
} LibraryForeachIDData;
bool BKE_lib_query_foreachid_iter_stop(LibraryForeachIDData *data)
bool BKE_lib_query_foreachid_iter_stop(const LibraryForeachIDData *data)
{
return (data->status & IDWALK_STOP) != 0;
}
@ -107,7 +107,7 @@ void BKE_lib_query_foreachid_process(LibraryForeachIDData *data, ID **id_pp, int
}
}
int BKE_lib_query_foreachid_process_flags_get(LibraryForeachIDData *data)
int BKE_lib_query_foreachid_process_flags_get(const LibraryForeachIDData *data)
{
return data->flag;
}

View File

@ -2004,7 +2004,7 @@ static void mask_clipboard_free_ex(bool final_free)
}
}
void BKE_mask_clipboard_free(void)
void BKE_mask_clipboard_free()
{
mask_clipboard_free_ex(true);
}
@ -2041,7 +2041,7 @@ void BKE_mask_clipboard_copy_from_layer(MaskLayer *mask_layer)
}
}
bool BKE_mask_clipboard_is_empty(void)
bool BKE_mask_clipboard_is_empty()
{
return BLI_listbase_is_empty(&mask_clipboard.splines);
}

View File

@ -187,11 +187,11 @@ float (*BKE_mask_spline_differentiate(
/* ** feather points self-intersection collapse routine ** */
typedef struct FeatherEdgesBucket {
struct FeatherEdgesBucket {
int tot_segment;
int (*segments)[2];
int alloc_segment;
} FeatherEdgesBucket;
};
static void feather_bucket_add_edge(FeatherEdgesBucket *bucket, int start, int end)
{

View File

@ -153,7 +153,7 @@ static ScanFillVert *scanfill_vert_add_v2_with_depth(ScanFillContext *sf_ctx,
*
* \note internal use only.
*/
typedef struct MaskRasterLayer {
struct MaskRasterLayer {
/* geometry */
uint face_tot;
uint (*face_array)[4]; /* access coords tri/quad */
@ -175,10 +175,9 @@ typedef struct MaskRasterLayer {
char blend;
char blend_flag;
char falloff;
};
} MaskRasterLayer;
typedef struct MaskRasterSplineInfo {
struct MaskRasterSplineInfo {
/* body of the spline */
uint vertex_offset;
uint vertex_total;
@ -188,7 +187,7 @@ typedef struct MaskRasterSplineInfo {
uint vertex_total_cap_tail;
bool is_cyclic;
} MaskRasterSplineInfo;
};
/**
* opaque local struct for mask pixel lookup, each MaskLayer needs one of these
@ -205,7 +204,7 @@ struct MaskRasterHandle {
/* alloc / free functions */
/* --------------------------------------------------------------------- */
MaskRasterHandle *BKE_maskrasterize_handle_new(void)
MaskRasterHandle *BKE_maskrasterize_handle_new()
{
MaskRasterHandle *mr_handle;
@ -1424,14 +1423,14 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x
return value;
}
typedef struct MaskRasterizeBufferData {
struct MaskRasterizeBufferData {
MaskRasterHandle *mr_handle;
float x_inv, y_inv;
float x_px_ofs, y_px_ofs;
uint width;
float *buffer;
} MaskRasterizeBufferData;
};
static void maskrasterize_buffer_cb(void *__restrict userdata,
const int y,

View File

@ -2015,32 +2015,32 @@ static void material_default_holdout_init(Material *ma)
nodeSetActive(ntree, output);
}
Material *BKE_material_default_empty(void)
Material *BKE_material_default_empty()
{
return &default_material_empty;
}
Material *BKE_material_default_holdout(void)
Material *BKE_material_default_holdout()
{
return &default_material_holdout;
}
Material *BKE_material_default_surface(void)
Material *BKE_material_default_surface()
{
return &default_material_surface;
}
Material *BKE_material_default_volume(void)
Material *BKE_material_default_volume()
{
return &default_material_volume;
}
Material *BKE_material_default_gpencil(void)
Material *BKE_material_default_gpencil()
{
return &default_material_gpencil;
}
void BKE_material_defaults_free_gpu(void)
void BKE_material_defaults_free_gpu()
{
for (int i = 0; default_materials[i]; i++) {
Material *ma = default_materials[i];
@ -2052,7 +2052,7 @@ void BKE_material_defaults_free_gpu(void)
/* Module functions called on startup and exit. */
void BKE_materials_init(void)
void BKE_materials_init()
{
for (int i = 0; default_materials[i]; i++) {
material_init_data(&default_materials[i]->id);
@ -2064,7 +2064,7 @@ void BKE_materials_init(void)
material_default_gpencil_init(&default_material_gpencil);
}
void BKE_materials_exit(void)
void BKE_materials_exit()
{
for (int i = 0; default_materials[i]; i++) {
material_free_data(&default_materials[i]->id);

View File

@ -48,62 +48,62 @@
/* Data types */
/** Corner of a cube. */
typedef struct corner {
struct CORNER {
int i, j, k; /* (i, j, k) is index within lattice */
float co[3], value; /* location and function value */
corner *next;
} CORNER;
CORNER *next;
};
/** Partitioning cell (cube). */
typedef struct cube {
struct CUBE {
int i, j, k; /* lattice location of cube */
CORNER *corners[8]; /* eight corners */
} CUBE;
};
/** Linked list of cubes acting as stack. */
typedef struct cubes {
struct CUBES {
CUBE cube; /* a single cube */
cubes *next; /* remaining elements */
} CUBES;
CUBES *next; /* remaining elements */
};
/** List of cube locations. */
typedef struct centerlist {
struct CENTERLIST {
int i, j, k; /* cube location */
centerlist *next; /* remaining elements */
} CENTERLIST;
CENTERLIST *next; /* remaining elements */
};
/** List of edges. */
typedef struct edgelist {
struct EDGELIST {
int i1, j1, k1, i2, j2, k2; /* edge corner ids */
int vid; /* vertex id */
edgelist *next; /* remaining elements */
} EDGELIST;
EDGELIST *next; /* remaining elements */
};
/** List of integers. */
typedef struct intlist {
struct INTLIST {
int i; /* an integer */
intlist *next; /* remaining elements */
} INTLIST;
INTLIST *next; /* remaining elements */
};
/** List of list of integers. */
typedef struct intlists {
struct INTLISTS {
INTLIST *list; /* a list of integers */
intlists *next; /* remaining elements */
} INTLISTS;
INTLISTS *next; /* remaining elements */
};
/** An AABB with pointer to metal-elem. */
typedef struct Box {
struct Box {
float min[3], max[3];
const MetaElem *ml;
} Box;
};
typedef struct MetaballBVHNode { /* BVH node */
Box bb[2]; /* AABB of children */
struct MetaballBVHNode { /* node */
Box bb[2]; /* AABB of children */
MetaballBVHNode *child[2];
} MetaballBVHNode;
};
/** Parameters, storage. */
typedef struct process {
struct PROCESS {
float thresh, size; /* mball threshold, single cube size */
float delta; /* small delta for calculating normals */
uint converge_res; /* converge procedure resolution (more = slower) */
@ -131,7 +131,7 @@ typedef struct process {
/* memory allocation from common pool */
MemArena *pgn_elements;
} PROCESS;
};
/* Forward declarations */
static int vertid(PROCESS *process, const CORNER *c1, const CORNER *c2);
@ -826,7 +826,7 @@ static void makecubetable()
}
}
void BKE_mball_cubeTable_free(void)
void BKE_mball_cubeTable_free()
{
for (int i = 0; i < 256; i++) {
INTLISTS *lists = cubetable[i];

View File

@ -983,28 +983,26 @@ static int find_object_active_key_uid(const Key &key, const Object &object)
}
static void move_shapekey_layers_to_keyblocks(const Mesh &mesh,
CustomData &custom_data,
const CustomData &custom_data,
Key &key_dst,
const int actshape_uid)
{
using namespace blender::bke;
for (const int i : IndexRange(CustomData_number_of_layers(&custom_data, CD_SHAPEKEY))) {
const int layer_index = CustomData_get_layer_index_n(&custom_data, CD_SHAPEKEY, i);
CustomDataLayer &layer = custom_data.layers[layer_index];
const CustomDataLayer &layer = custom_data.layers[layer_index];
KeyBlock *kb = keyblock_ensure_from_uid(key_dst, layer.uid, layer.name);
MEM_SAFE_FREE(kb->data);
kb->totelem = mesh.totvert;
kb->data = MEM_malloc_arrayN(kb->totelem, sizeof(float3), __func__);
MutableSpan<float3> kb_coords(static_cast<float3 *>(kb->data), kb->totelem);
if (kb->uid == actshape_uid) {
kb->data = MEM_malloc_arrayN(kb->totelem, sizeof(float3), __func__);
MutableSpan<float3> kb_coords(static_cast<float3 *>(kb->data), kb->totelem);
mesh.attributes().lookup<float3>("position").varray.materialize(kb_coords);
}
else {
kb->data = layer.data;
layer.data = nullptr;
kb_coords.copy_from({static_cast<const float3 *>(layer.data), mesh.totvert});
}
}

View File

@ -1442,6 +1442,9 @@ void BKE_mesh_legacy_bevel_weight_to_generic(Mesh *mesh)
void BKE_mesh_legacy_edge_crease_to_layers(Mesh *mesh)
{
using namespace blender;
if (!mesh->medge) {
return;
}
if (CustomData_has_layer(&mesh->edata, CD_CREASE)) {
return;
}

View File

@ -80,7 +80,7 @@ static CLG_LogRef LOG = {"bke.modifier"};
static ModifierTypeInfo *modifier_types[NUM_MODIFIER_TYPES] = {nullptr};
static VirtualModifierData virtualModifierCommonData;
void BKE_modifier_init(void)
void BKE_modifier_init()
{
ModifierData *md;

View File

@ -83,7 +83,7 @@
#include "NOD_node_declaration.hh"
#include "NOD_register.hh"
#include "NOD_shader.h"
#include "NOD_socket.h"
#include "NOD_socket.hh"
#include "NOD_texture.h"
#include "DEG_depsgraph.h"
@ -253,6 +253,13 @@ static void ntree_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, cons
}
}
if (ntree_src->nested_node_refs) {
ntree_dst->nested_node_refs = static_cast<bNestedNodeRef *>(
MEM_malloc_arrayN(ntree_src->nested_node_refs_num, sizeof(bNestedNodeRef), __func__));
uninitialized_copy_n(
ntree_src->nested_node_refs, ntree_src->nested_node_refs_num, ntree_dst->nested_node_refs);
}
if (flag & LIB_ID_COPY_NO_PREVIEW) {
ntree_dst->preview = nullptr;
}
@ -316,6 +323,10 @@ static void ntree_free_data(ID *id)
BKE_libblock_free_data(&ntree->id, true);
}
if (ntree->nested_node_refs) {
MEM_freeN(ntree->nested_node_refs);
}
BKE_previewimg_free(&ntree->preview);
MEM_delete(ntree->runtime);
}
@ -684,6 +695,9 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
BLO_write_string(writer, panel->name);
}
BLO_write_struct_array(
writer, bNestedNodeRef, ntree->nested_node_refs_num, ntree->nested_node_refs);
BKE_previewimg_blend_write(writer, ntree->preview);
}
@ -911,6 +925,8 @@ void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree)
BLO_read_data_address(reader, &ntree->panels_array[i]->name);
}
BLO_read_data_address(reader, &ntree->nested_node_refs);
/* TODO: should be dealt by new generic cache handling of IDs... */
ntree->previews = nullptr;

View File

@ -554,3 +554,53 @@ void bNodeTree::ensure_topology_cache() const
{
blender::bke::node_tree_runtime::ensure_topology_cache(*this);
}
const bNestedNodeRef *bNodeTree::find_nested_node_ref(const int32_t nested_node_id) const
{
for (const bNestedNodeRef &ref : this->nested_node_refs_span()) {
if (ref.id == nested_node_id) {
return &ref;
}
}
return nullptr;
}
const bNestedNodeRef *bNodeTree::nested_node_ref_from_node_id_path(
const blender::Span<int32_t> node_ids) const
{
if (node_ids.is_empty()) {
return nullptr;
}
for (const bNestedNodeRef &ref : this->nested_node_refs_span()) {
blender::Vector<int> current_node_ids;
if (this->node_id_path_from_nested_node_ref(ref.id, current_node_ids)) {
if (current_node_ids.as_span() == node_ids) {
return &ref;
}
}
}
return nullptr;
}
bool bNodeTree::node_id_path_from_nested_node_ref(const int32_t nested_node_id,
blender::Vector<int> &r_node_ids) const
{
const bNestedNodeRef *ref = this->find_nested_node_ref(nested_node_id);
if (ref == nullptr) {
return false;
}
const int32_t node_id = ref->path.node_id;
const bNode *node = this->node_by_id(node_id);
if (node == nullptr) {
return false;
}
r_node_ids.append(node_id);
if (!node->is_group()) {
return true;
}
const bNodeTree *group = reinterpret_cast<const bNodeTree *>(node->id);
if (group == nullptr) {
return false;
}
return group->node_id_path_from_nested_node_ref(ref->path.id_in_node, r_node_ids);
}

View File

@ -35,8 +35,10 @@ static const aal::RelationsInNode &get_relations_in_node(const bNode &node, Reso
if (!ntreeIsRegistered(group)) {
return scope.construct<aal::RelationsInNode>();
}
BLI_assert(group->runtime->anonymous_attribute_inferencing);
/* It's possible that the inferencing failed on the group. */
if (!group->runtime->anonymous_attribute_inferencing) {
return scope.construct<aal::RelationsInNode>();
}
return group->runtime->anonymous_attribute_inferencing->tree_relations;
}
}
@ -134,6 +136,10 @@ class bNodeTreeToDotOptionsForAnonymousAttributeInferencing : public bNodeTreeTo
ss << socket.identifier << " [";
bits::foreach_1_index(result_.required_fields_by_geometry_socket[socket.index_in_tree()],
[&](const int i) { ss << i << ","; });
ss << "] [";
bits::foreach_1_index(
result_.propagate_to_output_by_geometry_socket[socket.index_in_tree()],
[&](const int i) { ss << result_.propagated_output_geometry_indices[i] << ","; });
ss << "]";
return ss.str();
}

View File

@ -5,11 +5,14 @@
#include "BLI_map.hh"
#include "BLI_multi_value_map.hh"
#include "BLI_noise.hh"
#include "BLI_rand.hh"
#include "BLI_set.hh"
#include "BLI_stack.hh"
#include "BLI_timeit.hh"
#include "BLI_vector_set.hh"
#include "PIL_time.h"
#include "DNA_anim_types.h"
#include "DNA_modifier_types.h"
#include "DNA_node_types.h"
@ -25,7 +28,7 @@
#include "MOD_nodes.h"
#include "NOD_node_declaration.hh"
#include "NOD_socket.h"
#include "NOD_socket.hh"
#include "NOD_texture.h"
#include "DEG_depsgraph_query.h"
@ -486,6 +489,10 @@ class NodeTreeMainUpdater {
this->update_socket_link_and_use(ntree);
this->update_link_validation(ntree);
if (this->update_nested_node_refs(ntree)) {
result.interface_changed = true;
}
if (ntree.type == NTREE_TEXTURE) {
ntreeTexCheckCyclics(&ntree);
}
@ -1086,6 +1093,115 @@ class NodeTreeMainUpdater {
return false;
}
/**
* Make sure that the #bNodeTree::nested_node_refs is up to date. It's supposed to contain a
* reference to all (nested) simulation zones.
*/
bool update_nested_node_refs(bNodeTree &ntree)
{
ntree.ensure_topology_cache();
/* Simplify lookup of old ids. */
Map<bNestedNodePath, int32_t> old_id_by_path;
Set<int32_t> old_ids;
for (const bNestedNodeRef &ref : ntree.nested_node_refs_span()) {
old_id_by_path.add(ref.path, ref.id);
old_ids.add(ref.id);
}
Vector<bNestedNodePath> nested_node_paths;
/* Don't forget nested node refs just because the linked file is not available right now. */
for (const bNestedNodePath &path : old_id_by_path.keys()) {
const bNode *node = ntree.node_by_id(path.node_id);
if (node && node->is_group() && node->id) {
if (node->id->tag & LIB_TAG_MISSING) {
nested_node_paths.append(path);
}
}
}
if (ntree.type == NTREE_GEOMETRY) {
/* Create references for simulations in geometry nodes. */
for (const bNode *node : ntree.nodes_by_type("GeometryNodeSimulationOutput")) {
nested_node_paths.append({node->identifier, -1});
}
}
/* Propagate references to nested nodes in group nodes. */
for (const bNode *node : ntree.group_nodes()) {
const bNodeTree *group = reinterpret_cast<const bNodeTree *>(node->id);
if (group == nullptr) {
continue;
}
for (const int i : group->nested_node_refs_span().index_range()) {
const bNestedNodeRef &child_ref = group->nested_node_refs[i];
nested_node_paths.append({node->identifier, child_ref.id});
}
}
/* Used to generate new unique IDs if necessary. */
RandomNumberGenerator rng(PIL_check_seconds_timer_i() & UINT_MAX);
Map<int32_t, bNestedNodePath> new_path_by_id;
for (const bNestedNodePath &path : nested_node_paths) {
const int32_t old_id = old_id_by_path.lookup_default(path, -1);
if (old_id != -1) {
/* The same path existed before, it should keep the same ID as before. */
new_path_by_id.add(old_id, path);
continue;
}
int32_t new_id;
while (true) {
new_id = rng.get_int32(INT32_MAX);
if (!old_ids.contains(new_id) && !new_path_by_id.contains(new_id)) {
break;
}
}
/* The path is new, it should get a new ID that does not collide with any existing IDs. */
new_path_by_id.add(new_id, path);
}
/* Check if the old and new references are identical. */
if (!this->nested_node_refs_changed(ntree, new_path_by_id)) {
return false;
}
MEM_SAFE_FREE(ntree.nested_node_refs);
if (new_path_by_id.is_empty()) {
ntree.nested_node_refs_num = 0;
return true;
}
/* Allocate new array for the nested node references contained in the node tree. */
bNestedNodeRef *new_refs = static_cast<bNestedNodeRef *>(
MEM_malloc_arrayN(new_path_by_id.size(), sizeof(bNestedNodeRef), __func__));
int index = 0;
for (const auto item : new_path_by_id.items()) {
bNestedNodeRef &ref = new_refs[index];
ref.id = item.key;
ref.path = item.value;
index++;
}
ntree.nested_node_refs = new_refs;
ntree.nested_node_refs_num = new_path_by_id.size();
return true;
}
bool nested_node_refs_changed(const bNodeTree &ntree,
const Map<int32_t, bNestedNodePath> &new_path_by_id)
{
if (ntree.nested_node_refs_num != new_path_by_id.size()) {
return true;
}
for (const bNestedNodeRef &ref : ntree.nested_node_refs_span()) {
if (!new_path_by_id.contains(ref.id)) {
return true;
}
}
return false;
}
void reset_changed_flags(bNodeTree &ntree)
{
ntree.runtime->changed_flag = NTREE_CHANGED_NOTHING;
@ -1227,6 +1343,16 @@ void BKE_ntree_update_tag_image_user_changed(bNodeTree *ntree, ImageUser * /*ius
add_tree_tag(ntree, NTREE_CHANGED_ANY);
}
uint64_t bNestedNodePath::hash() const
{
return blender::get_default_hash_2(this->node_id, this->id_in_node);
}
bool operator==(const bNestedNodePath &a, const bNestedNodePath &b)
{
return a.node_id == b.node_id && a.id_in_node == b.id_in_node;
}
/**
* Protect from recursive calls into the updating function. Some node update functions might
* trigger this from Python or in other cases.

View File

@ -295,6 +295,13 @@ static std::unique_ptr<bNodeTreeZones> discover_tree_zones(const bNodeTree &tree
return {};
}
for (const bNode *node : tree.nodes_by_type("NodeGroupOutput")) {
if (tree_zones->zone_by_node_id.contains(node->identifier)) {
/* Group output nodes must not be in a zone. */
return {};
}
}
for (const int node_i : all_nodes.index_range()) {
const bNode *node = all_nodes[node_i];
const int zone_i = tree_zones->zone_by_node_id.lookup_default(node->identifier, -1);

View File

@ -1963,8 +1963,7 @@ bool BKE_object_is_in_editmode(const Object *ob)
/* Grease Pencil object has no edit mode data. */
return GPENCIL_EDIT_MODE((bGPdata *)ob->data);
case OB_CURVES:
/* Curves object has no edit mode data. */
return ob->mode == OB_MODE_EDIT;
case OB_POINTCLOUD:
case OB_GREASE_PENCIL:
return ob->mode == OB_MODE_EDIT;
default:
@ -1994,6 +1993,7 @@ bool BKE_object_data_is_in_editmode(const Object *ob, const ID *id)
case ID_AR:
return ((const bArmature *)id)->edbo != nullptr;
case ID_CV:
case ID_PT:
case ID_GP:
if (ob) {
return BKE_object_is_in_editmode(ob);
@ -2046,14 +2046,10 @@ char *BKE_object_data_editmode_flush_ptr_get(ID *id)
bArmature *arm = (bArmature *)id;
return &arm->needs_flush_to_id;
}
case ID_CV: {
/* Curves have no edit mode data. */
case ID_GP:
case ID_PT:
case ID_CV:
return nullptr;
}
case ID_GP: {
/* Grease Pencil has no edit mode data. */
return nullptr;
}
default:
BLI_assert_unreachable();
return nullptr;

View File

@ -274,13 +274,13 @@ void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, Cu
}
}
void BKE_paint_invalidate_overlay_all(void)
void BKE_paint_invalidate_overlay_all()
{
overlay_flags |= (PAINT_OVERLAY_INVALID_TEXTURE_SECONDARY |
PAINT_OVERLAY_INVALID_TEXTURE_PRIMARY | PAINT_OVERLAY_INVALID_CURVE);
}
ePaintOverlayControlFlags BKE_paint_get_overlay_flags(void)
ePaintOverlayControlFlags BKE_paint_get_overlay_flags()
{
return overlay_flags;
}

View File

@ -517,7 +517,7 @@ uint PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT];
uint PSYS_FRAND_SEED_MULTIPLIER[PSYS_FRAND_COUNT];
float PSYS_FRAND_BASE[PSYS_FRAND_COUNT];
void BKE_particle_init_rng(void)
void BKE_particle_init_rng()
{
RNG *rng = BLI_rng_new_srandom(5831); /* arbitrary */
for (int i = 0; i < PSYS_FRAND_COUNT; i++) {
@ -1273,7 +1273,7 @@ void psys_interpolate_particle(
}
}
typedef struct ParticleInterpolationData {
struct ParticleInterpolationData {
HairKey *hkey[2];
Mesh *mesh;
@ -1292,7 +1292,7 @@ typedef struct ParticleInterpolationData {
/** Die on this frame, see #ParticleData.dietime for details. */
float dietime;
int bspline;
} ParticleInterpolationData;
};
/**
* Assumes pointcache->mem_cache exists, so for disk cached particles
* call #psys_make_temp_pointcache() before use.
@ -3569,14 +3569,14 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
}
}
typedef struct CacheEditrPathsIterData {
struct CacheEditrPathsIterData {
Object *object;
PTCacheEdit *edit;
ParticleSystemModifierData *psmd;
ParticleData *pa;
int segments;
bool use_weight;
} CacheEditrPathsIterData;
};
static void psys_cache_edit_paths_iter(void *__restrict iter_data_v,
const int iter,

View File

@ -568,7 +568,7 @@ static float do_clump_level(float result[3],
float clumpfac,
float clumppow,
float pa_clump,
CurveMapping *clumpcurve)
const CurveMapping *clumpcurve)
{
float clump = 0.0f;
@ -610,7 +610,7 @@ float do_clump(ParticleKey *state,
float pa_clump,
bool use_clump_noise,
float clump_noise_size,
CurveMapping *clumpcurve)
const CurveMapping *clumpcurve)
{
float clump;
@ -726,7 +726,7 @@ static void twist_get_axis(const ParticleChildModifierContext *modifier_ctx,
}
}
static float BKE_curvemapping_integrate_clamped(CurveMapping *curve,
static float BKE_curvemapping_integrate_clamped(const CurveMapping *curve,
float start,
float end,
float step)

View File

@ -15,6 +15,7 @@
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
@ -109,7 +110,6 @@ void BKE_report(ReportList *reports, eReportType type, const char *_message)
void BKE_reportf(ReportList *reports, eReportType type, const char *_format, ...)
{
DynStr *ds;
Report *report;
va_list args;
const char *format = TIP_(_format);
@ -126,15 +126,11 @@ void BKE_reportf(ReportList *reports, eReportType type, const char *_format, ...
if (reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
report = MEM_callocN(sizeof(Report), "Report");
ds = BLI_dynstr_new();
va_start(args, _format);
BLI_dynstr_vappendf(ds, format, args);
report->message = BLI_vsprintfN(format, args);
va_end(args);
report->message = BLI_dynstr_get_cstring(ds);
report->len = BLI_dynstr_get_len(ds);
BLI_dynstr_free(ds);
report->len = strlen(report->message);
report->type = type;
report->typestr = BKE_report_type_str(type);
@ -142,55 +138,44 @@ void BKE_reportf(ReportList *reports, eReportType type, const char *_format, ...
}
}
void BKE_reports_prepend(ReportList *reports, const char *_prepend)
/**
* Shared logic behind #BKE_reports_prepend & #BKE_reports_prependf.
*/
static void reports_prepend_impl(ReportList *reports, const char *prepend)
{
Report *report;
DynStr *ds;
const char *prepend = TIP_(_prepend);
if (!reports) {
return;
}
for (report = reports->list.first; report; report = report->next) {
ds = BLI_dynstr_new();
BLI_dynstr_append(ds, prepend);
BLI_dynstr_append(ds, report->message);
/* Caller must ensure. */
BLI_assert(reports && reports->list.first);
const size_t prefix_len = strlen(prepend);
for (Report *report = reports->list.first; report; report = report->next) {
char *message = BLI_string_joinN(prepend, report->message);
MEM_freeN((void *)report->message);
report->message = BLI_dynstr_get_cstring(ds);
report->len = BLI_dynstr_get_len(ds);
BLI_dynstr_free(ds);
report->message = message;
report->len += prefix_len;
BLI_assert(report->len == strlen(message));
}
}
void BKE_reports_prependf(ReportList *reports, const char *_prepend, ...)
void BKE_reports_prepend(ReportList *reports, const char *prepend)
{
Report *report;
DynStr *ds;
va_list args;
const char *prepend = TIP_(_prepend);
if (!reports) {
if (!reports || !reports->list.first) {
return;
}
reports_prepend_impl(reports, TIP_(prepend));
}
for (report = reports->list.first; report; report = report->next) {
ds = BLI_dynstr_new();
va_start(args, _prepend);
BLI_dynstr_vappendf(ds, prepend, args);
va_end(args);
BLI_dynstr_append(ds, report->message);
MEM_freeN((void *)report->message);
report->message = BLI_dynstr_get_cstring(ds);
report->len = BLI_dynstr_get_len(ds);
BLI_dynstr_free(ds);
void BKE_reports_prependf(ReportList *reports, const char *prepend_format, ...)
{
if (!reports || !reports->list.first) {
return;
}
va_list args;
va_start(args, prepend_format);
char *prepend = BLI_vsprintfN(TIP_(prepend_format), args);
va_end(args);
reports_prepend_impl(reports, prepend);
MEM_freeN(prepend);
}
eReportType BKE_report_print_level(ReportList *reports)

View File

@ -1790,7 +1790,7 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
rigidbody_validate_sim_shape(rbw, ob, true);
/* now tell RB sim about it */
/* XXX: we assume that this can only get applied for active/passive shapes
* that will be included as rigidbodies. */
* that will be included as rigid-bodies. */
if (rbo->shared->physics_object != NULL && rbo->shared->physics_shape != NULL) {
RB_body_set_collision_shape(rbo->shared->physics_object, rbo->shared->physics_shape);
}

View File

@ -202,7 +202,7 @@ SimulationZoneState &ModifierSimulationState::get_zone_state_for_write(
[]() { return std::make_unique<SimulationZoneState>(); });
}
void ModifierSimulationState::ensure_bake_loaded() const
void ModifierSimulationState::ensure_bake_loaded(const bNodeTree &ntree) const
{
std::scoped_lock lock{mutex_};
if (bake_loaded_) {
@ -223,7 +223,8 @@ void ModifierSimulationState::ensure_bake_loaded() const
}
const DiskBDataReader bdata_reader{*bdata_dir_};
deserialize_modifier_simulation_state(*io_root,
deserialize_modifier_simulation_state(ntree,
*io_root,
bdata_reader,
*owner_->bdata_sharing_,
const_cast<ModifierSimulationState &>(*this));

View File

@ -7,6 +7,7 @@
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_mesh.hh"
#include "BKE_node_runtime.hh"
#include "BKE_pointcloud.h"
#include "BKE_simulation_state_serialize.hh"
@ -790,12 +791,17 @@ static std::shared_ptr<io::serialize::Value> serialize_primitive_value(
return {};
}
/**
* Version written to the baked data.
*/
static constexpr int serialize_format_version = 2;
void serialize_modifier_simulation_state(const ModifierSimulationState &state,
BDataWriter &bdata_writer,
BDataSharing &bdata_sharing,
DictionaryValue &r_io_root)
{
r_io_root.append_int("version", 1);
r_io_root.append_int("version", serialize_format_version);
auto io_zones = r_io_root.append_array("zones");
for (const auto item : state.zone_states_.items()) {
@ -804,11 +810,7 @@ void serialize_modifier_simulation_state(const ModifierSimulationState &state,
auto io_zone = io_zones->append_dict();
auto io_zone_id = io_zone->append_array("zone_id");
for (const int node_id : zone_id.node_ids) {
io_zone_id->append_int(node_id);
}
io_zone->append_int("state_id", zone_id.nested_node_id);
auto io_state_items = io_zone->append_array("state_items");
for (const MapItem<int, std::unique_ptr<SimulationStateItem>> &state_item_with_id :
@ -980,7 +982,8 @@ template<typename T>
return false;
}
void deserialize_modifier_simulation_state(const DictionaryValue &io_root,
void deserialize_modifier_simulation_state(const bNodeTree &ntree,
const DictionaryValue &io_root,
const BDataReader &bdata_reader,
const BDataSharing &bdata_sharing,
ModifierSimulationState &r_state)
@ -990,7 +993,7 @@ void deserialize_modifier_simulation_state(const DictionaryValue &io_root,
if (!version) {
return;
}
if (*version != 1) {
if (*version > serialize_format_version) {
return;
}
const io::serialize::ArrayValue *io_zones = io_root.lookup_array("zones");
@ -1002,14 +1005,27 @@ void deserialize_modifier_simulation_state(const DictionaryValue &io_root,
if (!io_zone) {
continue;
}
const io::serialize::ArrayValue *io_zone_id = io_zone->lookup_array("zone_id");
bke::sim::SimulationZoneID zone_id;
for (const auto &io_zone_id_element : io_zone_id->elements()) {
const io::serialize::IntValue *io_node_id = io_zone_id_element->as_int_value();
if (!io_node_id) {
if (const std::optional<int> state_id = io_zone->lookup_int("state_id")) {
zone_id.nested_node_id = *state_id;
}
else if (const io::serialize::ArrayValue *io_zone_id = io_zone->lookup_array("zone_id")) {
/* In the initial release of simulation nodes, the entire node id path was written to the
* baked data. For backward compatibility the node ids are read here and then the nested node
* id is looked up. */
Vector<int> node_ids;
for (const auto &io_zone_id_element : io_zone_id->elements()) {
const io::serialize::IntValue *io_node_id = io_zone_id_element->as_int_value();
if (!io_node_id) {
continue;
}
node_ids.append(io_node_id->value());
}
const bNestedNodeRef *nested_node_ref = ntree.nested_node_ref_from_node_id_path(node_ids);
if (!nested_node_ref) {
continue;
}
zone_id.node_ids.append(io_node_id->value());
zone_id.nested_node_id = nested_node_ref->id;
}
const io::serialize::ArrayValue *io_state_items = io_zone->lookup_array("state_items");

View File

@ -549,7 +549,7 @@ static void sound_load_audio(Main *bmain, bSound *sound, bool free_waveform)
/* load sound */
PackedFile *pf = sound->packedfile;
/* don't modify soundact->sound->filepath, only change a copy */
/* Don't modify `sound->filepath`, only change a copy. */
STRNCPY(fullpath, sound->filepath);
BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id));

View File

@ -347,7 +347,7 @@ void BKE_texture_mapping_init(TexMapping *texmap)
}
}
ColorMapping *BKE_texture_colormapping_add(void)
ColorMapping *BKE_texture_colormapping_add()
{
ColorMapping *colormap = MEM_cnew<ColorMapping>("ColorMapping");
@ -407,7 +407,7 @@ void BKE_texture_mtex_default(MTex *mtex)
/* ------------------------------------------------------------------------- */
MTex *BKE_texture_mtex_add(void)
MTex *BKE_texture_mtex_add()
{
MTex *mtex;
@ -635,7 +635,7 @@ void BKE_texture_pointdensity_init_data(PointDensity *pd)
BKE_curvemapping_changed(pd->falloff_curve, false);
}
PointDensity *BKE_texture_pointdensity_add(void)
PointDensity *BKE_texture_pointdensity_add()
{
PointDensity *pd = static_cast<PointDensity *>(
MEM_callocN(sizeof(PointDensity), "pointdensity"));

View File

@ -54,13 +54,13 @@
#include "libmv-capi.h"
#include "tracking_private.h"
typedef struct MovieDistortion {
struct MovieDistortion {
libmv_CameraIntrinsics *intrinsics;
/* Parameters needed for coordinates normalization. */
float principal_px[2];
float pixel_aspect;
float focal;
} MovieDistortion;
};
static struct {
ListBase tracks;
@ -164,13 +164,13 @@ void BKE_tracking_free(MovieTracking *tracking)
tracking_dopesheet_free(&tracking->dopesheet);
}
typedef struct TrackingCopyContext {
struct TrackingCopyContext {
/* Map from point and plane track pointer from the source object to the destination object. */
GHash *old_to_new_track_map;
GHash *old_to_new_plane_track_map;
} TrackingCopyContext;
};
static TrackingCopyContext tracking_copy_context_new(void)
static TrackingCopyContext tracking_copy_context_new()
{
TrackingCopyContext ctx = {};
ctx.old_to_new_track_map = BLI_ghash_ptr_new(__func__);
@ -436,7 +436,7 @@ void BKE_tracking_get_projection_matrix(MovieTracking *tracking,
* Clipboard.
*/
void BKE_tracking_clipboard_free(void)
void BKE_tracking_clipboard_free()
{
MovieTrackingTrack *track = static_cast<MovieTrackingTrack *>(tracking_clipboard.tracks.first),
*next_track;
@ -469,7 +469,7 @@ void BKE_tracking_clipboard_copy_tracks(MovieTracking * /*tracking*/,
}
}
bool BKE_tracking_clipboard_has_tracks(void)
bool BKE_tracking_clipboard_has_tracks()
{
return (BLI_listbase_is_empty(&tracking_clipboard.tracks) == false);
}
@ -1077,11 +1077,11 @@ static bGPDlayer *track_mask_gpencil_layer_get(const MovieTrackingTrack *track)
return nullptr;
}
typedef struct TrackMaskSetPixelData {
struct TrackMaskSetPixelData {
float *mask;
int mask_width;
int mask_height;
} TrackMaskSetPixelData;
};
static void track_mask_set_pixel_cb(int x, int x_end, int y, void *user_data)
{

View File

@ -31,16 +31,16 @@
#include "libmv-capi.h"
#include "tracking_private.h"
typedef struct AutoTrackClip {
struct AutoTrackClip {
MovieClip *clip;
/* Dimensions of movie frame, in pixels.
*
* NOTE: All frames within a clip are expected to have match3ed dimensions. */
int width, height;
} AutoTrackClip;
};
typedef struct AutoTrackTrack {
struct AutoTrackTrack {
/* Index of a clip from `AutoTrackContext::autotrack_clips` this track belongs to. */
int clip_index;
@ -53,11 +53,11 @@ typedef struct AutoTrackTrack {
* Is usually initialized based on track's selection. Non-trackable tracks are still added to the
* context to provide AutoTrack all knowledge about what is going on in the scene. */
bool is_trackable;
} AutoTrackTrack;
};
typedef struct AutoTrackMarker {
struct AutoTrackMarker {
libmv_Marker libmv_marker;
} AutoTrackMarker;
};
/* Result of tracking step for a single marker.
*
@ -65,15 +65,15 @@ typedef struct AutoTrackMarker {
*
* On failure marker's frame number is initialized to frame number where it was attempted to be
* tracked to. The position and other fields of tracked marker are the same as the input. */
typedef struct AutoTrackTrackingResult {
struct AutoTrackTrackingResult {
AutoTrackTrackingResult *next, *prev;
bool success;
libmv_Marker libmv_marker;
libmv_TrackRegionResult libmv_result;
} AutoTrackTrackingResult;
};
typedef struct AutoTrackContext {
struct AutoTrackContext {
/* --------------------------------------------------------------------
* Invariant part.
* Stays unchanged during the tracking process.
@ -133,7 +133,7 @@ typedef struct AutoTrackContext {
int synchronized_scene_frame;
SpinLock spin_lock;
} AutoTrackContext;
};
/* -------------------------------------------------------------------- */
/** \name Marker coordinate system conversion.
@ -624,9 +624,9 @@ void BKE_autotrack_context_start(AutoTrackContext *context)
/* NOTE: This is a TLS in a sense that this struct is never accessed from multiple threads, and
* that threads are re-using the struct as much as possible. */
typedef struct AutoTrackTLS {
struct AutoTrackTLS {
ListBase results; /* Elements of `AutoTrackTrackingResult`. */
} AutoTrackTLS;
};
static void autotrack_context_step_cb(void *__restrict userdata,
const int marker_index,

View File

@ -32,7 +32,7 @@
#include "libmv-capi.h"
#include "tracking_private.h"
typedef struct MovieReconstructContext {
struct MovieReconstructContext {
libmv_Tracks *tracks;
bool select_keyframes;
int keyframe1, keyframe2;
@ -53,15 +53,15 @@ typedef struct MovieReconstructContext {
/* Details about reconstruction error, reported by Libmv. */
char error_message[1024];
} MovieReconstructContext;
};
typedef struct ReconstructProgressData {
struct ReconstructProgressData {
bool *stop;
bool *do_update;
float *progress;
char *stats_message;
int message_size;
} ReconstructProgressData;
};
/* Create new libmv Tracks structure from blender's tracks list. */
static libmv_Tracks *libmv_tracks_new(MovieClip *clip, ListBase *tracksbase, int width, int height)

View File

@ -63,7 +63,7 @@ static float EPSILON_WEIGHT = 0.005f;
* This struct with private working data is associated to the local call context
* via `StabContext::private_track_data`
*/
typedef struct TrackStabilizationBase {
struct TrackStabilizationBase {
float stabilization_offset_base[2];
/* measured relative to translated pivot */
@ -74,19 +74,19 @@ typedef struct TrackStabilizationBase {
bool is_init_for_stabilization;
FCurve *track_weight_curve;
} TrackStabilizationBase;
};
/* Tracks are reordered for initialization, starting as close as possible to
* anchor_frame
*/
typedef struct TrackInitOrder {
struct TrackInitOrder {
int sort_value;
int reference_frame;
MovieTrackingTrack *data;
} TrackInitOrder;
};
/* Per frame private working data, for accessing possibly animated values. */
typedef struct StabContext {
struct StabContext {
MovieClip *clip;
MovieTracking *tracking;
MovieTrackingStabilization *stab;
@ -98,7 +98,7 @@ typedef struct StabContext {
FCurve *target_rot;
FCurve *target_scale;
bool use_animation;
} StabContext;
};
static TrackStabilizationBase *access_stabilization_baseline_data(StabContext *ctx,
MovieTrackingTrack *track)
@ -1287,13 +1287,13 @@ void BKE_tracking_stabilization_data_get(MovieClip *clip,
typedef void (*interpolation_func)(const ImBuf *, ImBuf *, float, float, int, int);
typedef struct TrackingStabilizeFrameInterpolationData {
struct TrackingStabilizeFrameInterpolationData {
ImBuf *ibuf;
ImBuf *tmpibuf;
float (*mat)[4];
interpolation_func interpolation;
} TrackingStabilizeFrameInterpolationData;
};
static void tracking_stabilize_frame_interpolation_cb(void *__restrict userdata,
const int j,

View File

@ -673,7 +673,7 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
{
/* First try to get fully processed image from the cache. */
CACHE_PRINTF("Calculate new buffer for frame %d\n", frame);
/* And now we do postprocessing of the original frame. */
/* And now we do post-processing of the original frame. */
ImBuf *orig_ibuf = accessor_get_preprocessed_ibuf(accessor, clip_index, frame);
if (orig_ibuf == nullptr) {
return nullptr;

View File

@ -249,7 +249,7 @@ static void undosys_stack_validate(UndoStack *ustack, bool expect_non_empty)
static void undosys_stack_validate(UndoStack * /*ustack*/, bool /*expect_non_empty*/) {}
#endif
UndoStack *BKE_undosys_stack_create(void)
UndoStack *BKE_undosys_stack_create()
{
UndoStack *ustack = MEM_cnew<UndoStack>(__func__);
return ustack;
@ -893,7 +893,7 @@ UndoType *BKE_undosys_type_append(void (*undosys_fn)(UndoType *))
return ut;
}
void BKE_undosys_type_free_all(void)
void BKE_undosys_type_free_all()
{
UndoType *ut;
while ((ut = static_cast<UndoType *>(BLI_pophead(&g_undo_types)))) {

View File

@ -212,7 +212,7 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, const VFont
return NULL;
}
VChar *che = (VChar *)MEM_callocN(sizeof(struct VChar), "objfnt_char");
VChar *che = (VChar *)MEM_callocN(sizeof(VChar), "objfnt_char");
freetype_outline_to_curves(face->glyph->outline, &che->nurbsbase, vfd->scale);
che->index = charcode;
che->width = face->glyph->advance.x * vfd->scale;

View File

@ -43,6 +43,7 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_volume.h"
#include "BKE_volume_openvdb.hh"
#include "BLT_translation.h"

View File

@ -17,6 +17,7 @@
#include "DNA_volume_types.h"
#include "BKE_volume.h"
#include "BKE_volume_openvdb.hh"
#include "BKE_volume_render.h"
#ifdef WITH_OPENVDB

View File

@ -14,6 +14,7 @@
#include "BKE_mesh.hh"
#include "BKE_volume.h"
#include "BKE_volume_openvdb.hh"
#ifdef WITH_OPENVDB
# include <openvdb/tools/GridTransformer.h>

View File

@ -49,7 +49,7 @@ float do_clump(ParticleKey *state,
float pa_clump,
bool use_clump_noise,
float clump_noise_size,
struct CurveMapping *clumpcurve);
const struct CurveMapping *clumpcurve);
void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx,
float mat[4][4],
ParticleKey *state,

View File

@ -26,7 +26,7 @@ void *BLI_hash_md5_buffer(const char *buffer, size_t len, void *resblock);
*/
int BLI_hash_md5_stream(FILE *stream, void *resblock);
char *BLI_hash_md5_to_hexdigest(void *resblock, char r_hex_digest[33]);
char *BLI_hash_md5_to_hexdigest(const void *resblock, char r_hex_digest[33]);
#ifdef __cplusplus
}

View File

@ -236,12 +236,28 @@ size_t BLI_vsnprintf_rlen(char *__restrict dst,
const char *__restrict format,
va_list arg) ATTR_PRINTF_FORMAT(3, 0);
char *BLI_sprintfN_with_buffer(char *fixed_buf,
size_t fixed_buf_size,
size_t *result_len,
const char *__restrict format,
...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 3, 4)
ATTR_PRINTF_FORMAT(4, 5);
char *BLI_vsprintfN_with_buffer(char *fixed_buf,
size_t fixed_buf_size,
size_t *result_len,
const char *__restrict format,
va_list args) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 3, 4)
ATTR_PRINTF_FORMAT(4, 0);
/**
* Print formatted string into a newly #MEM_mallocN'd string
* and return it.
*/
char *BLI_sprintfN(const char *__restrict format, ...) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1, 2);
/** A version of #BLI_sprintfN that takes a #va_list. */
char *BLI_vsprintfN(const char *__restrict format, va_list args) ATTR_NONNULL(1, 2) ATTR_MALLOC
ATTR_PRINTF_FORMAT(1, 0);
/**
* This roughly matches C and Python's string escaping with double quotes - `"`.

View File

@ -168,7 +168,7 @@ size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst,
size_t dst_maxncpy) ATTR_NONNULL(1, 2);
size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w,
const char *__restrict src_c,
size_t dst_maxncpy) ATTR_NONNULL(1, 2);
size_t dst_w_maxncpy) ATTR_NONNULL(1, 2);
/**
* Count columns that character/string occupies (based on `wcwidth.co`).

View File

@ -6,38 +6,67 @@
/** \file
* \ingroup bli
*
* Unicode characters as UTF-8 strings.
*/
#ifdef __cplusplus
extern "C" {
#endif
/* Unicode characters as UTF-8 strings. Last portion should include the official assigned name.
* Please do not add defines here that are not actually in use. */
/* Notes:
* - Last portion should include the official assigned name.
* - Please do not add defines here that are not actually in use.
* - Use literal UTF-8 encoding as this `u8` prefixes cause both
* `-Wc++20-compat` & `-Wc99-compat` warnings under CLANG.
*/
#define BLI_STR_UTF8_MULTIPLICATION_SIGN u8"\u00D7" /* × */
#define BLI_STR_UTF8_EM_DASH u8"\u2014" /* — */
#define BLI_STR_UTF8_BULLET u8"\u2022" /* • */
#define BLI_STR_UTF8_HORIZONTAL_ELLIPSIS u8"\u2026" /* … */
#define BLI_STR_UTF8_LEFTWARDS_ARROW u8"\u2190" /* ← */
#define BLI_STR_UTF8_UPWARDS_ARROW u8"\u2191" /* ↑ */
#define BLI_STR_UTF8_RIGHTWARDS_ARROW u8"\u2192" /* → */
#define BLI_STR_UTF8_DOWNWARDS_ARROW u8"\u2193" /* ↓ */
#define BLI_STR_UTF8_UPWARDS_WHITE_ARROW u8"\u21E7" /* ⇧ */
#define BLI_STR_UTF8_UP_ARROWHEAD u8"\u2303" /* ⌃ */
#define BLI_STR_UTF8_PLACE_OF_INTEREST_SIGN u8"\u2318" /* ⌘ */
#define BLI_STR_UTF8_OPTION_KEY u8"\u2325" /* ⌥ */
#define BLI_STR_UTF8_ERASE_TO_THE_LEFT u8"\u232B" /* ⌫ */
#define BLI_STR_UTF8_BROKEN_CIRCLE_WITH_NORTHWEST_ARROW u8"\u238B" /* ⎋ */
#define BLI_STR_UTF8_RETURN_SYMBOL u8"\u23CE" /* ⏎ */
#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR u8"\u23ED" /* ⏭ */
#define BLI_STR_UTF8_BLACK_LEFT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR u8"\u23EE" /* ⏮ */
#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_TRIANGLE_WITH_DOUBLE_VERTICAL_BAR u8"\u23EF" /* ⏯ */
#define BLI_STR_UTF8_BLACK_SQUARE_FOR_STOP u8"\u23F9" /* ⏹ */
#define BLI_STR_UTF8_OPEN_BOX u8"\u2423" /* ␣ */
#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_SMALL_TRIANGLE u8"\u25B8" /* ▸ */
#define BLI_STR_UTF8_HORIZONTAL_TAB_KEY u8"\u2B7E" /* ⭾ */
#define BLI_STR_UTF8_BLACK_DIAMOND_MINUS_WHITE_X u8"\u2756" /* ❖ */
/** u00D7: `×`. */
#define BLI_STR_UTF8_MULTIPLICATION_SIGN "\xc3\x97"
/** u2014: `—` */
#define BLI_STR_UTF8_EM_DASH "\xe2\x80\x94"
/** u2022: `•` */
#define BLI_STR_UTF8_BULLET "\xe2\x80\xa2"
/** u2026: `…` */
#define BLI_STR_UTF8_HORIZONTAL_ELLIPSIS "\xe2\x80\xa6"
/** u2190: `←` */
#define BLI_STR_UTF8_LEFTWARDS_ARROW "\xe2\x86\x90"
/** u2191: `↑` */
#define BLI_STR_UTF8_UPWARDS_ARROW "\xe2\x86\x91"
/** u2192: `→` */
#define BLI_STR_UTF8_RIGHTWARDS_ARROW "\xe2\x86\x92"
/** u2193: `↓` */
#define BLI_STR_UTF8_DOWNWARDS_ARROW "\xe2\x86\x93"
/** u21E7: `⇧` */
#define BLI_STR_UTF8_UPWARDS_WHITE_ARROW "\xe2\x87\xa7"
/** u2303: `⌃` */
#define BLI_STR_UTF8_UP_ARROWHEAD "\xe2\x8c\x83"
/** u2318: `⌘` */
#define BLI_STR_UTF8_PLACE_OF_INTEREST_SIGN "\xe2\x8c\x98"
/** u2325: `⌥` */
#define BLI_STR_UTF8_OPTION_KEY "\xe2\x8c\xa5"
/** u232B: `⌫` */
#define BLI_STR_UTF8_ERASE_TO_THE_LEFT "\xe2\x8c\xab"
/** u238B: `⎋` */
#define BLI_STR_UTF8_BROKEN_CIRCLE_WITH_NORTHWEST_ARROW "\xe2\x8e\x8b"
/** u23CE: `⏎` */
#define BLI_STR_UTF8_RETURN_SYMBOL "\xe2\x8f\x8e"
/** u23ED: `⏭` */
#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR "\xe2\x8f\xad"
/** u23EE: `⏮` */
#define BLI_STR_UTF8_BLACK_LEFT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR "\xe2\x8f\xae"
/** u23EF: `⏯` */
#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_TRIANGLE_WITH_DOUBLE_VERTICAL_BAR "\xe2\x8f\xaf"
/** u23F9: `⏹` */
#define BLI_STR_UTF8_BLACK_SQUARE_FOR_STOP "\xe2\x8f\xb9"
/** u2423: `␣` */
#define BLI_STR_UTF8_OPEN_BOX "\xe2\x90\xa3"
/** u25B8: `▸` */
#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_SMALL_TRIANGLE "\xe2\x96\xb8"
/** u2B7E: `⭾` */
#define BLI_STR_UTF8_HORIZONTAL_TAB_KEY "\xe2\xad\xbe"
/** u2756: `❖` */
#define BLI_STR_UTF8_BLACK_DIAMOND_MINUS_WHITE_X "\xe2\x9d\x96"
#ifdef __cplusplus
}

View File

@ -11,7 +11,6 @@ set(INC
..
# ../blenkernel # don't add this back!
../makesdna
../../../intern/atomic
../../../intern/eigen
../../../intern/guardedalloc
)
@ -394,7 +393,7 @@ set(LIB
bf_intern_eigen
bf_intern_guardedalloc
extern_wcwidth
PRIVATE bf_intern_atomic
${ZLIB_LIBRARIES}
${ZSTD_LIBRARIES}
)

View File

@ -17,20 +17,6 @@
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
#ifdef _WIN32
# ifndef vsnprintf
# define vsnprintf _vsnprintf
# endif
#endif
#ifndef va_copy
# ifdef __va_copy
# define va_copy(a, b) __va_copy(a, b)
# else /* !__va_copy */
# define va_copy(a, b) ((a) = (b))
# endif /* __va_copy */
#endif /* va_copy */
/***/
typedef struct DynStrElem DynStrElem;
@ -114,121 +100,27 @@ void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len)
void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, va_list args)
{
char *message, fixedmessage[256];
int len = sizeof(fixedmessage);
const int maxlen = 65536;
int retval;
while (1) {
va_list args_cpy;
if (len == sizeof(fixedmessage)) {
message = fixedmessage;
}
else {
message = MEM_callocN(sizeof(char) * len, "BLI_dynstr_appendf");
}
/* can't reuse the same args, so work on a copy */
va_copy(args_cpy, args);
retval = vsnprintf(message, len, format, args_cpy);
va_end(args_cpy);
if (retval == -1) {
/* -1 means not enough space, but on windows it may also mean
* there is a formatting error, so we impose a maximum length */
if (message != fixedmessage) {
MEM_freeN(message);
}
message = NULL;
len *= 2;
if (len > maxlen) {
fprintf(stderr, "BLI_dynstr_append text too long or format error.\n");
break;
}
}
else if (retval >= len) {
/* in C99 the actual length required is returned */
if (message != fixedmessage) {
MEM_freeN(message);
}
message = NULL;
/* retval doesn't include \0 terminator */
len = retval + 1;
}
else {
break;
}
}
if (message) {
BLI_dynstr_append(ds, message);
if (message != fixedmessage) {
MEM_freeN(message);
}
char *str, fixed_buf[256];
size_t str_len;
str = BLI_vsprintfN_with_buffer(fixed_buf, sizeof(fixed_buf), &str_len, format, args);
BLI_dynstr_append(ds, str);
if (str != fixed_buf) {
MEM_freeN(str);
}
}
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ...)
{
va_list args;
char *message, fixedmessage[256];
int len = sizeof(fixedmessage);
const int maxlen = 65536;
int retval;
/* note that it's tempting to just call BLI_dynstr_vappendf here
* and avoid code duplication, that crashes on some system because
* va_start/va_end have to be called for each vsnprintf call */
while (1) {
if (len == sizeof(fixedmessage)) {
message = fixedmessage;
}
else {
message = MEM_callocN(sizeof(char) * (len), "BLI_dynstr_appendf");
}
va_start(args, format);
retval = vsnprintf(message, len, format, args);
va_end(args);
if (retval == -1) {
/* -1 means not enough space, but on windows it may also mean
* there is a formatting error, so we impose a maximum length */
if (message != fixedmessage) {
MEM_freeN(message);
}
message = NULL;
len *= 2;
if (len > maxlen) {
fprintf(stderr, "BLI_dynstr_append text too long or format error.\n");
break;
}
}
else if (retval >= len) {
/* in C99 the actual length required is returned */
if (message != fixedmessage) {
MEM_freeN(message);
}
message = NULL;
/* retval doesn't include \0 terminator */
len = retval + 1;
}
else {
break;
}
}
if (message) {
BLI_dynstr_append(ds, message);
if (message != fixedmessage) {
MEM_freeN(message);
char *str, fixed_buf[256];
size_t str_len;
va_start(args, format);
str = BLI_vsprintfN_with_buffer(fixed_buf, sizeof(fixed_buf), &str_len, format, args);
va_end(args);
if (LIKELY(str)) {
BLI_dynstr_append(ds, str);
if (str != fixed_buf) {
MEM_freeN(str);
}
}
}

View File

@ -379,7 +379,7 @@ void *BLI_hash_md5_buffer(const char *buffer, size_t len, void *resblock)
return md5_read_ctx(&ctx, resblock);
}
char *BLI_hash_md5_to_hexdigest(void *resblock, char r_hex_digest[33])
char *BLI_hash_md5_to_hexdigest(const void *resblock, char r_hex_digest[33])
{
static const char hex_map[17] = "0123456789abcdef";
const unsigned char *p;

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