diff options
32 files changed, 514 insertions, 298 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 80b8bfdbb3d..6abb430d523 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,7 +223,7 @@ if(UNIX AND NOT (APPLE OR HAIKU)) option(WITH_GHOST_WAYLAND "Enable building Blender against Wayland for windowing (under development)" OFF) mark_as_advanced(WITH_GHOST_WAYLAND) - if (WITH_GHOST_WAYLAND) + if(WITH_GHOST_WAYLAND) option(WITH_GHOST_WAYLAND_LIBDECOR "Optionally build with LibDecor window decorations" OFF) mark_as_advanced(WITH_GHOST_WAYLAND_LIBDECOR) @@ -464,8 +464,8 @@ if(NOT APPLE) option(WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED "Enable use of SYCL host (CPU) device execution by oneAPI implementation. This option is for debugging purposes and impacts GPU execution." OFF) # https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compilation/ahead-of-time-compilation.html - SET (CYCLES_ONEAPI_SPIR64_GEN_DEVICES "dg2" CACHE STRING "oneAPI Intel GPU architectures to build binaries for") - SET (CYCLES_ONEAPI_SYCL_TARGETS spir64 spir64_gen CACHE STRING "oneAPI targets to build AOT binaries for") + set(CYCLES_ONEAPI_SPIR64_GEN_DEVICES "dg2" CACHE STRING "oneAPI Intel GPU architectures to build binaries for") + set(CYCLES_ONEAPI_SYCL_TARGETS spir64 spir64_gen CACHE STRING "oneAPI targets to build AOT binaries for") mark_as_advanced(WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED) mark_as_advanced(CYCLES_ONEAPI_SPIR64_GEN_DEVICES) @@ -580,14 +580,14 @@ endif() # Metal -if (APPLE) +if(APPLE) option(WITH_METAL_BACKEND "Use Metal for graphics instead of (or as well as) OpenGL on macOS." OFF) mark_as_advanced(WITH_METAL_BACKEND) else() set(WITH_METAL_BACKEND OFF) endif() -if (WITH_METAL_BACKEND) +if(WITH_METAL_BACKEND) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE) endif() @@ -1196,7 +1196,8 @@ if(WITH_OPENVDB) list(APPEND OPENVDB_INCLUDE_DIRS ${BOOST_INCLUDE_DIR} ${TBB_INCLUDE_DIRS} - ${OPENEXR_INCLUDE_DIRS}) + ${OPENEXR_INCLUDE_DIRS} + ) list(APPEND OPENVDB_LIBRARIES ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES}) @@ -1346,7 +1347,7 @@ endif() #----------------------------------------------------------------------------- # Configure Metal. -if (WITH_METAL_BACKEND) +if(WITH_METAL_BACKEND) add_definitions(-DWITH_METAL_BACKEND) # No need to add frameworks here, all the ones we need for Metal and diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake index bc456858d2a..7ebad7a3da2 100644 --- a/build_files/build_environment/cmake/harvest.cmake +++ b/build_files/build_environment/cmake/harvest.cmake @@ -43,7 +43,8 @@ function(harvest from to) install( FILES ${LIBDIR}/${from} DESTINATION ${HARVEST_TARGET}/${dirpath} - RENAME ${filename}) + RENAME ${filename} + ) else() install( DIRECTORY ${LIBDIR}/${from}/ @@ -53,7 +54,8 @@ function(harvest from to) PATTERN "pkgconfig" EXCLUDE PATTERN "cmake" EXCLUDE PATTERN "__pycache__" EXCLUDE - PATTERN "tests" EXCLUDE) + PATTERN "tests" EXCLUDE + ) endif() endfunction() diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 406748b7ff0..0d7ed9d618c 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -803,7 +803,8 @@ if(CMAKE_COMPILER_IS_GNUCC) "The mold linker could not find the directory containing the linker command " "(typically " "\"${MOLD_PREFIX}/libexec/mold/ld\") or " - "\"${MOLD_PREFIX}/lib/mold/ld\") using system linker.") + "\"${MOLD_PREFIX}/lib/mold/ld\") using system linker." + ) set(WITH_LINKER_MOLD OFF) endif() unset(MOLD_PREFIX) @@ -942,7 +943,8 @@ function(CONFIGURE_ATOMIC_LIB_IF_NEEDED) int main(int argc, char **argv) { std::atomic<uint64_t> uint64; uint64++; return 0; - }") + }" + ) include(CheckCXXSourceCompiles) check_cxx_source_compiles("${_source}" ATOMIC_OPS_WITHOUT_LIBATOMIC) diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index 7e272ea26b0..e81582f0460 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -146,7 +146,7 @@ endif() if(WITH_COMPILER_ASAN AND MSVC AND NOT MSVC_CLANG) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.28.29828) #set a flag so we don't have to do this comparison all the time - SET(MSVC_ASAN ON) + set(MSVC_ASAN ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address") string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " /INCREMENTAL:NO") @@ -185,20 +185,20 @@ endif() if(WITH_WINDOWS_SCCACHE) - set(CMAKE_C_COMPILER_LAUNCHER sccache) - set(CMAKE_CXX_COMPILER_LAUNCHER sccache) + set(CMAKE_C_COMPILER_LAUNCHER sccache) + set(CMAKE_CXX_COMPILER_LAUNCHER sccache) + set(SYMBOL_FORMAT /Z7) + set(SYMBOL_FORMAT_RELEASE /Z7) +else() + unset(CMAKE_C_COMPILER_LAUNCHER) + unset(CMAKE_CXX_COMPILER_LAUNCHER) + if(MSVC_ASAN) set(SYMBOL_FORMAT /Z7) set(SYMBOL_FORMAT_RELEASE /Z7) -else() - unset(CMAKE_C_COMPILER_LAUNCHER) - unset(CMAKE_CXX_COMPILER_LAUNCHER) - if(MSVC_ASAN) - set(SYMBOL_FORMAT /Z7) - set(SYMBOL_FORMAT_RELEASE /Z7) - else() - set(SYMBOL_FORMAT /ZI) - set(SYMBOL_FORMAT_RELEASE /Zi) - endif() + else() + set(SYMBOL_FORMAT /ZI) + set(SYMBOL_FORMAT_RELEASE /Zi) + endif() endif() if(WITH_WINDOWS_PDB) @@ -416,7 +416,7 @@ if(WITH_CODEC_FFMPEG) ${LIBDIR}/ffmpeg/lib/avdevice.lib ${LIBDIR}/ffmpeg/lib/avutil.lib ${LIBDIR}/ffmpeg/lib/swscale.lib - ) + ) endif() endif() @@ -565,12 +565,14 @@ if(WITH_BOOST) if(WITH_CYCLES AND WITH_CYCLES_OSL) set(BOOST_LIBRARIES ${BOOST_LIBRARIES} optimized ${BOOST_LIBPATH}/libboost_wave-${BOOST_POSTFIX} - debug ${BOOST_LIBPATH}/libboost_wave-${BOOST_DEBUG_POSTFIX}) + debug ${BOOST_LIBPATH}/libboost_wave-${BOOST_DEBUG_POSTFIX} + ) endif() if(WITH_INTERNATIONAL) set(BOOST_LIBRARIES ${BOOST_LIBRARIES} optimized ${BOOST_LIBPATH}/libboost_locale-${BOOST_POSTFIX} - debug ${BOOST_LIBPATH}/libboost_locale-${BOOST_DEBUG_POSTFIX}) + debug ${BOOST_LIBPATH}/libboost_locale-${BOOST_DEBUG_POSTFIX} + ) endif() else() # we found boost using find_package set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) @@ -677,7 +679,8 @@ if(WITH_OPENIMAGEDENOISE) optimized ${OPENIMAGEDENOISE_LIBPATH}/dnnl.lib debug ${OPENIMAGEDENOISE_LIBPATH}/OpenImageDenoise_d.lib debug ${OPENIMAGEDENOISE_LIBPATH}/common_d.lib - debug ${OPENIMAGEDENOISE_LIBPATH}/dnnl_d.lib) + debug ${OPENIMAGEDENOISE_LIBPATH}/dnnl_d.lib + ) set(OPENIMAGEDENOISE_DEFINITIONS) endif() @@ -832,7 +835,8 @@ if(WITH_CYCLES AND WITH_CYCLES_EMBREE) debug ${LIBDIR}/embree/lib/math_d.lib debug ${LIBDIR}/embree/lib/simd_d.lib debug ${LIBDIR}/embree/lib/sys_d.lib - debug ${LIBDIR}/embree/lib/tasking_d.lib) + debug ${LIBDIR}/embree/lib/tasking_d.lib + ) endif() endif() diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 17145bdbe99..5f904d86b03 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -17,7 +17,6 @@ #include <ft2build.h> #include FT_FREETYPE_H -#include FT_CACHE_H /* FreeType Cache. */ #include FT_GLYPH_H #include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include FT_TRUETYPE_IDS_H /* Codepoint coverage constants. */ @@ -56,8 +55,6 @@ BatchBLF g_batch; /* freetype2 handle ONLY for this file! */ static FT_Library ft_lib = NULL; -static FTC_Manager ftc_manager = NULL; -static FTC_CMapCache ftc_charmap_cache = NULL; static SpinLock ft_lib_mutex; static SpinLock blf_glyph_cache_mutex; @@ -69,50 +66,11 @@ static ft_pix blf_font_height_max_ft_pix(struct FontBLF *font); static ft_pix blf_font_width_max_ft_pix(struct FontBLF *font); /* -------------------------------------------------------------------- */ -/** \name FreeType Caching - * \{ */ - -/* Called when a face is removed. FreeType will call FT_Done_Face itself. */ -static void blf_face_finalizer(void *object) -{ - FT_Face face = object; - FontBLF *font = (FontBLF *)face->generic.data; - font->face = NULL; -} -/* Called in response to FTC_Manager_LookupFace. Add a face to our font. */ -static FT_Error blf_cache_face_requester(FTC_FaceID faceID, - FT_Library lib, - FT_Pointer UNUSED(reqData), - FT_Face *face) -{ - FontBLF *font = (FontBLF *)faceID; - int err = FT_Err_Cannot_Open_Resource; - - BLI_spin_lock(font->ft_lib_mutex); - - if (font->filepath) { - err = FT_New_Face(lib, font->filepath, 0, face); - } - else if (font->mem) { - err = FT_New_Memory_Face(lib, font->mem, (FT_Long)font->mem_size, 0, face); - } - - BLI_spin_unlock(font->ft_lib_mutex); - - if (err == FT_Err_Ok) { - font->face = *face; - font->face->generic.data = font; - font->face->generic.finalizer = blf_face_finalizer; - } - - return err; -} - -/* Use cache, not blf_get_char_index, to return glyph id from charcode. */ +/* Return glyph id from charcode. */ uint blf_get_char_index(struct FontBLF *font, uint charcode) { - return FTC_CMapCache_Lookup(ftc_charmap_cache, font, -1, charcode); + return FT_Get_Char_Index(font->face, charcode); } /* -------------------------------------------------------------------- */ @@ -1207,27 +1165,12 @@ int blf_font_init(void) BLI_spin_init(&ft_lib_mutex); BLI_spin_init(&blf_glyph_cache_mutex); int err = FT_Init_FreeType(&ft_lib); - if (err == FT_Err_Ok) { - err = FTC_Manager_New(ft_lib, - BLF_CACHE_MAX_FACES, - BLF_CACHE_MAX_SIZES, - BLF_CACHE_BYTES, - blf_cache_face_requester, - NULL, - &ftc_manager); - if (err == FT_Err_Ok) { - err = FTC_CMapCache_New(ftc_manager, &ftc_charmap_cache); - } - } return err; } void blf_font_exit(void) { BLI_spin_end(&ft_lib_mutex); - if (ftc_manager) { - FTC_Manager_Done(ftc_manager); - } if (ft_lib) { FT_Done_FreeType(ft_lib); } @@ -1309,7 +1252,12 @@ bool blf_ensure_face(FontBLF *font) FT_Error err; - err = FTC_Manager_LookupFace(ftc_manager, font, &font->face); + if (font->filepath) { + err = FT_New_Face(ft_lib, font->filepath, 0, &font->face); + } + if (font->mem) { + err = FT_New_Memory_Face(ft_lib, font->mem, (FT_Long)font->mem_size, 0, &font->face); + } if (err) { if (ELEM(err, FT_Err_Unknown_File_Format, FT_Err_Unimplemented_Feature)) { @@ -1349,6 +1297,7 @@ bool blf_ensure_face(FontBLF *font) } } + font->ft_size = font->face->size; font->face_flags = font->face->face_flags; if (FT_HAS_MULTIPLE_MASTERS(font)) { @@ -1501,7 +1450,7 @@ void blf_font_free(FontBLF *font) } if (font->face) { - FTC_Manager_RemoveFaceID(ftc_manager, font); + FT_Done_Face(font->face); font->face = NULL; } if (font->filepath) { @@ -1530,23 +1479,17 @@ bool blf_font_size(FontBLF *font, float size, unsigned int dpi) /* Adjust our new size to be on even 64ths. */ size = (float)ft_size / 64.0f; - FTC_ScalerRec scaler = {0}; - scaler.face_id = font; - scaler.width = 0; - scaler.height = ft_size; - scaler.pixel = 0; - scaler.x_res = dpi; - scaler.y_res = dpi; - - if (FTC_Manager_LookupSize(ftc_manager, &scaler, &font->ft_size) != FT_Err_Ok) { - printf("The current font don't support the size, %f and dpi, %u\n", size, dpi); - return false; + if (font->size != size || font->dpi != dpi) { + if (FT_Set_Char_Size(font->face, 0, ft_size, dpi, dpi) == FT_Err_Ok) { + font->size = size; + font->dpi = dpi; + } + else { + printf("The current font does not support the size, %f and DPI, %u\n", size, dpi); + return false; + } } - font->size = size; - font->dpi = dpi; - font->ft_size->generic.data = (void *)font; - return true; } diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 780b75c6296..9cdca81af28 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -787,8 +787,8 @@ static bool blf_glyph_transform_weight(FT_GlyphSlot glyph, float factor, bool mo { if (glyph->format == FT_GLYPH_FORMAT_OUTLINE) { /* Fake bold if the font does not have this variable axis. */ - const FontBLF *font = (FontBLF *)glyph->face->generic.data; - const FT_Pos average_width = font->ft_size->metrics.height; + const FT_Pos average_width = FT_MulFix(glyph->face->units_per_EM, + glyph->face->size->metrics.x_scale); FT_Pos change = (FT_Pos)((float)average_width * factor * 0.1f); FT_Outline_EmboldenXY(&glyph->outline, change, change / 2); if (monospaced) { @@ -847,8 +847,7 @@ static bool blf_glyph_transform_width(FT_GlyphSlot glyph, float factor) static bool blf_glyph_transform_spacing(FT_GlyphSlot glyph, float factor) { if (glyph->advance.x > 0) { - const FontBLF *font = (FontBLF *)glyph->face->generic.data; - const long int size = font->ft_size->metrics.height; + const long int size = glyph->face->size->metrics.height; glyph->advance.x += (FT_Pos)(factor * (float)size / 6.0f); return true; } diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 8ff00d05e02..221e656f096 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -16,14 +16,7 @@ struct rcti; /* Max number of FontBLFs in memory. Take care that every font has a glyph cache per size/dpi, * so we don't need load the same font with different size, just load one and call BLF_size. */ -#define BLF_MAX_FONT 64 - -/* Maximum number of opened FT_Face objects managed by cache. 0 is default of 2. */ -#define BLF_CACHE_MAX_FACES 0 -/* Maximum number of opened FT_Size objects managed by cache. 0 is default of 4 */ -#define BLF_CACHE_MAX_SIZES 0 -/* Maximum number of bytes to use for cached data nodes. 0 is default of 200,000. */ -#define BLF_CACHE_BYTES 0 +#define BLF_MAX_FONT 32 extern struct FontBLF *global_font[BLF_MAX_FONT]; diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 007b717ab93..3064630de1b 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -329,7 +329,7 @@ typedef struct FontBLF { /* freetype2 face. */ FT_Face face; - /* FreeType size is separated from face when using their caching subsystem. */ + /* Point to face->size or to cache's size. */ FT_Size ft_size; /* Copy of the font->face->face_flags, in case we don't have a face loaded. */ diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_depth_of_field_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_depth_of_field_info.hh index 94ff694b147..b398a6cc4e7 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_depth_of_field_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_depth_of_field_info.hh @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #include "eevee_defines.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_motion_blur_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_motion_blur_info.hh index e32020f2be6..d6ff34b0ed2 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_motion_blur_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_motion_blur_info.hh @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #include "eevee_defines.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 931bb7be8bf..7d31950c869 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -1197,6 +1197,14 @@ bool ED_view3d_camera_lock_autokey(struct View3D *v3d, void ED_view3d_lock_clear(struct View3D *v3d); /** + * Check if creating an undo step should be performed if the viewport moves. + * \return true if #ED_view3d_camera_lock_undo_push would do an undo push. + */ +bool ED_view3d_camera_lock_undo_test(const View3D *v3d, + const RegionView3D *rv3d, + struct bContext *C); + +/** * Create an undo step when the camera is locked to the view. * \param str: The name of the undo step (typically #wmOperatorType.name should be used). * diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index c54bcad905f..e4a973a375e 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -27,13 +27,13 @@ set(INC ) set(SRC - eyedroppers/interface_eyedropper.c eyedroppers/eyedropper_color.c eyedroppers/eyedropper_colorband.c eyedroppers/eyedropper_datablock.c eyedroppers/eyedropper_depth.c eyedroppers/eyedropper_driver.c eyedroppers/eyedropper_gpencil_color.c + eyedroppers/interface_eyedropper.c interface.cc interface_align.c interface_anim.cc diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt index a716c00d5d9..568ece00c4c 100644 --- a/source/blender/editors/io/CMakeLists.txt +++ b/source/blender/editors/io/CMakeLists.txt @@ -11,9 +11,9 @@ set(INC ../../io/collada ../../io/common ../../io/gpencil + ../../io/stl ../../io/usd ../../io/wavefront_obj - ../../io/stl ../../makesdna ../../makesrna ../../windowmanager @@ -33,8 +33,8 @@ set(SRC io_gpencil_utils.c io_obj.c io_ops.c - io_usd.c io_stl_ops.c + io_usd.c io_alembic.h io_cache.h @@ -42,8 +42,8 @@ set(SRC io_gpencil.h io_obj.h io_ops.h - io_usd.h io_stl_ops.h + io_usd.h ) set(LIB diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 195a3686b3b..2882bdfcbf2 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -826,10 +826,10 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, } /* For each BMVert, sort associated linked list into unique uvs. */ - int i; - BM_ITER_MESH_INDEX (ev, &iter, bm, BM_VERTS_OF_MESH, i) { + int ev_index; + BM_ITER_MESH_INDEX (ev, &iter, bm, BM_VERTS_OF_MESH, ev_index) { UvElement *newvlist = NULL; - UvElement *vlist = element_map->vertex[i]; + UvElement *vlist = element_map->vertex[ev_index]; while (vlist) { /* Detach head from unsorted list. */ @@ -881,7 +881,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, } /* Write back sorted list. */ - element_map->vertex[i] = newvlist; + element_map->vertex[ev_index] = newvlist; } MEM_SAFE_FREE(winding); @@ -912,7 +912,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, /* at this point, every UvElement in vert points to a UvElement sharing the same vertex. * Now we should sort uv's in islands. */ - for (i = 0; i < totuv; i++) { + for (int i = 0; i < totuv; i++) { if (element_map->storage[i].island == INVALID_ISLAND) { int stacksize = 0; element_map->storage[i].island = nislands; @@ -965,7 +965,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, MEM_SAFE_FREE(island_number); /* remap */ - for (i = 0; i < bm->totvert; i++) { + for (int i = 0; i < bm->totvert; i++) { /* important since we may do selection only. Some of these may be NULL */ if (element_map->vertex[i]) { element_map->vertex[i] = &islandbuf[map[element_map->vertex[i] - element_map->storage]]; @@ -975,7 +975,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices) * nislands, "UvElementMap_island_indices"); j = 0; - for (i = 0; i < totuv; i++) { + for (int i = 0; i < totuv; i++) { UvElement *element = element_map->storage[i].next; if (element == NULL) { islandbuf[map[i]].next = NULL; diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index edb0f1cda4d..b170280ccf3 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -37,8 +37,8 @@ set(SRC curves_sculpt_ops.cc curves_sculpt_pinch.cc curves_sculpt_puff.cc - curves_sculpt_selection_paint.cc curves_sculpt_selection.cc + curves_sculpt_selection_paint.cc curves_sculpt_slide.cc curves_sculpt_smooth.cc curves_sculpt_snake_hook.cc diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index f2017e68b4c..2e2abd30ea2 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -629,11 +629,13 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm } /* fill the edges with data */ - int i = 0; - GHASH_ITER (gh_iter, edgeHash) { - data->uvedges[i++] = *((UvEdge *)BLI_ghashIterator_getKey(&gh_iter)); + { + int i = 0; + GHASH_ITER (gh_iter, edgeHash) { + data->uvedges[i++] = *((UvEdge *)BLI_ghashIterator_getKey(&gh_iter)); + } + data->totalUvEdges = BLI_ghash_len(edgeHash); } - data->totalUvEdges = BLI_ghash_len(edgeHash); /* cleanup temporary stuff */ BLI_ghash_free(edgeHash, NULL, NULL); diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 78ec057f921..b9f79303a06 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -48,11 +48,11 @@ set(SRC tree/tree_element_anim_data.cc tree/tree_element_collection.cc tree/tree_element_driver.cc - tree/tree_element_label.cc tree/tree_element_gpencil_layer.cc tree/tree_element_id.cc tree/tree_element_id_library.cc tree/tree_element_id_scene.cc + tree/tree_element_label.cc tree/tree_element_nla.cc tree/tree_element_overrides.cc tree/tree_element_rna.cc @@ -68,11 +68,11 @@ set(SRC tree/tree_element_anim_data.hh tree/tree_element_collection.hh tree/tree_element_driver.hh - tree/tree_element_label.hh tree/tree_element_gpencil_layer.hh tree/tree_element_id.hh tree/tree_element_id_library.hh tree/tree_element_id_scene.hh + tree/tree_element_label.hh tree/tree_element_nla.hh tree/tree_element_overrides.hh tree/tree_element_rna.hh diff --git a/source/blender/editors/space_view3d/view3d_navigate.c b/source/blender/editors/space_view3d/view3d_navigate.c index 88e004aac48..f50e933fdac 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.c +++ b/source/blender/editors/space_view3d/view3d_navigate.c @@ -495,6 +495,8 @@ static void axis_set_view(bContext *C, .camera_old = v3d->camera, .ofs = rv3d->ofs, .quat = quat, + /* No undo because this switches to/from camera. */ + .undo_str = NULL, }); } else if (orig_persp == RV3D_CAMOB && v3d->camera) { @@ -518,6 +520,8 @@ static void axis_set_view(bContext *C, .ofs = ofs, .quat = quat, .dist = &dist, + /* No undo because this switches to/from camera. */ + .undo_str = NULL, }); } else { @@ -540,6 +544,8 @@ static void axis_set_view(bContext *C, &(const V3D_SmoothParams){ .quat = quat, .dyn_ofs = dyn_ofs_pt, + /* No undo because this isn't a camera view. */ + .undo_str = NULL, }); } } @@ -694,6 +700,8 @@ static void view3d_from_minmax(bContext *C, .camera_old = v3d->camera, .ofs = new_ofs, .dist = ok_dist ? &new_dist : NULL, + /* The caller needs to use undo begin/end calls. */ + .undo_str = NULL, }); } else { @@ -704,6 +712,8 @@ static void view3d_from_minmax(bContext *C, &(const V3D_SmoothParams){ .ofs = new_ofs, .dist = ok_dist ? &new_dist : NULL, + /* The caller needs to use undo begin/end calls. */ + .undo_str = NULL, }); } @@ -736,6 +746,7 @@ static void view3d_from_minmax_multi(bContext *C, static int view3d_all_exec(bContext *C, wmOperator *op) { + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -802,6 +813,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* This is an approximation, see function documentation for details. */ ED_view3d_clipping_clamp_minmax(rv3d, min, max); } + ED_view3d_smooth_view_undo_begin(C, area); if (use_all_regions) { view3d_from_minmax_multi(C, v3d, min, max, true, smooth_viewtx); @@ -810,6 +822,8 @@ static int view3d_all_exec(bContext *C, wmOperator *op) view3d_from_minmax(C, v3d, region, min, max, true, smooth_viewtx); } + ED_view3d_smooth_view_undo_end(C, area, op->type->name, false); + return OPERATOR_FINISHED; } @@ -842,6 +856,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot) static int viewselected_exec(bContext *C, wmOperator *op) { + ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -971,6 +986,8 @@ static int viewselected_exec(bContext *C, wmOperator *op) ED_view3d_clipping_clamp_minmax(rv3d, min, max); } + ED_view3d_smooth_view_undo_begin(C, area); + if (use_all_regions) { view3d_from_minmax_multi(C, v3d, min, max, ok_dist, smooth_viewtx); } @@ -978,6 +995,8 @@ static int viewselected_exec(bContext *C, wmOperator *op) view3d_from_minmax(C, v3d, region, min, max, ok_dist, smooth_viewtx); } + ED_view3d_smooth_view_undo_end(C, area, op->type->name, false); + return OPERATOR_FINISHED; } @@ -1020,8 +1039,14 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *op) /* non camera center */ float new_ofs[3]; negate_v3_v3(new_ofs, scene->cursor.location); - ED_view3d_smooth_view( - C, v3d, region, smooth_viewtx, &(const V3D_SmoothParams){.ofs = new_ofs}); + ED_view3d_smooth_view(C, + v3d, + region, + smooth_viewtx, + &(const V3D_SmoothParams){ + .ofs = new_ofs, + .undo_str = op->type->name, + }); /* Smooth view does view-lock #RV3D_BOXVIEW copy. */ } @@ -1074,8 +1099,14 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev ED_view3d_win_to_3d_int(v3d, region, new_ofs, event->mval, new_ofs); } negate_v3(new_ofs); - ED_view3d_smooth_view( - C, v3d, region, smooth_viewtx, &(const V3D_SmoothParams){.ofs = new_ofs}); + ED_view3d_smooth_view(C, + v3d, + region, + smooth_viewtx, + &(const V3D_SmoothParams){ + .ofs = new_ofs, + .undo_str = op->type->name, + }); } return OPERATOR_FINISHED; @@ -1318,17 +1349,20 @@ static int view_camera_exec(bContext *C, wmOperator *op) /* finally do snazzy view zooming */ rv3d->persp = RV3D_CAMOB; - ED_view3d_smooth_view(C, - v3d, - region, - smooth_viewtx, - &(const V3D_SmoothParams){ - .camera = v3d->camera, - .ofs = rv3d->ofs, - .quat = rv3d->viewquat, - .dist = &rv3d->dist, - .lens = &v3d->lens, - }); + ED_view3d_smooth_view( + C, + v3d, + region, + smooth_viewtx, + &(const V3D_SmoothParams){ + .camera = v3d->camera, + .ofs = rv3d->ofs, + .quat = rv3d->viewquat, + .dist = &rv3d->dist, + .lens = &v3d->lens, + /* No undo because this changes cameras (and wont move the camera). */ + .undo_str = NULL, + }); } else { /* return to settings of last view */ @@ -1417,7 +1451,12 @@ static int vieworbit_exec(bContext *C, wmOperator *op) ED_view3d_smooth_view_force_finish(C, v3d, region); if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0 || (view_opposite != RV3D_VIEW_USER)) { - if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) { + const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d); + if ((rv3d->persp != RV3D_CAMOB) || is_camera_lock) { + if (is_camera_lock) { + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + ED_view3d_camera_lock_init(depsgraph, v3d, rv3d); + } int smooth_viewtx = WM_operator_smooth_viewtx_get(op); float quat_mul[4]; float quat_new[4]; @@ -1475,6 +1514,9 @@ static int vieworbit_exec(bContext *C, wmOperator *op) &(const V3D_SmoothParams){ .quat = quat_new, .dyn_ofs = dyn_ofs_pt, + /* Group as successive orbit may run by holding a key. */ + .undo_str = op->type->name, + .undo_grouped = true, }); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/view3d_navigate.h b/source/blender/editors/space_view3d/view3d_navigate.h index fc7bc11295a..721476ace57 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.h +++ b/source/blender/editors/space_view3d/view3d_navigate.h @@ -231,6 +231,14 @@ typedef struct V3D_SmoothParams { /** Alternate rotation center, when set `ofs` must be NULL. */ const float *dyn_ofs; + + /** When non-NULL, perform undo pushes when transforming the camera. */ + const char *undo_str; + /** + * When true use grouped undo pushes, use for incremental viewport manipulation + * which are likely to be activated by holding a key or from the mouse-wheel. + */ + bool undo_grouped; } V3D_SmoothParams; /** @@ -252,6 +260,22 @@ void ED_view3d_smooth_view(struct bContext *C, const V3D_SmoothParams *sview); /** + * Call before multiple smooth-view operations begin to properly handle undo. + * + * \note Only use explicit undo calls when multiple calls to smooth-view are necessary + * or when calling #ED_view3d_smooth_view_ex. + * Otherwise pass in #V3D_SmoothParams.undo_str so an undo step is pushed as needed. + */ +void ED_view3d_smooth_view_undo_begin(struct bContext *C, struct ScrArea *area); +/** + * Run after multiple smooth-view operations have run to push undo as needed. + */ +void ED_view3d_smooth_view_undo_end(struct bContext *C, + struct ScrArea *area, + const char *undo_str, + bool undo_grouped); + +/** * Apply the smooth-view immediately, use when we need to start a new view operation. * (so we don't end up half-applying a view operation when pressing keys quickly). */ diff --git a/source/blender/editors/space_view3d/view3d_navigate_roll.c b/source/blender/editors/space_view3d/view3d_navigate_roll.c index 087ca72211e..af93aa50238 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_roll.c +++ b/source/blender/editors/space_view3d/view3d_navigate_roll.c @@ -15,6 +15,8 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "DEG_depsgraph_query.h" + #include "ED_screen.h" #include "view3d_intern.h" @@ -167,7 +169,13 @@ static int viewroll_exec(bContext *C, wmOperator *op) } rv3d = region->regiondata; - if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) { + + const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d); + if ((rv3d->persp != RV3D_CAMOB) || is_camera_lock) { + if (is_camera_lock) { + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + ED_view3d_camera_lock_init(depsgraph, v3d, rv3d); + } ED_view3d_smooth_view_force_finish(C, v3d, region); @@ -202,6 +210,9 @@ static int viewroll_exec(bContext *C, wmOperator *op) &(const V3D_SmoothParams){ .quat = quat_new, .dyn_ofs = dyn_ofs_pt, + /* Group as successive roll may run by holding a key. */ + .undo_str = op->type->name, + .undo_grouped = true, }); viewops_data_free(C, op->customdata); diff --git a/source/blender/editors/space_view3d/view3d_navigate_smoothview.c b/source/blender/editors/space_view3d/view3d_navigate_smoothview.c index 48af126d8a9..8125e334492 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_smoothview.c +++ b/source/blender/editors/space_view3d/view3d_navigate_smoothview.c @@ -8,6 +8,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BKE_context.h" @@ -21,6 +22,114 @@ #include "view3d_intern.h" #include "view3d_navigate.h" /* own include */ +static void view3d_smoothview_apply_with_interp( + bContext *C, View3D *v3d, ARegion *region, const bool use_autokey, const float factor); + +/* -------------------------------------------------------------------- */ +/** \name Smooth View Undo Handling + * + * When the camera is locked to the viewport smooth-view operations + * may need to perform an undo push. + * + * In this case the smooth-view camera transformation is temporarily completed, + * undo is pushed then the change is rewound, and smooth-view completes from it's timer. + * In the case smooth-view executed the change immediately - an undo push is called. + * + * NOTE(@campbellbarton): While this is not ideal it's necessary as making the undo-push + * once smooth-view is complete because smooth-view is non-blocking and it's possible other + * operations are executed once smooth-view has started. + * \{ */ + +void ED_view3d_smooth_view_undo_begin(bContext *C, ScrArea *area) +{ + const View3D *v3d = area->spacedata.first; + Object *camera = v3d->camera; + if (!camera) { + return; + } + + /* Tag the camera object so it's known smooth-view is applied to the view-ports camera + * (needed to detect when a locked camera is being manipulated). + * NOTE: It doesn't matter if the actual object being manipulated is the camera or not. */ + camera->id.tag &= ~LIB_TAG_DOIT; + + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { + if (region->regiontype != RGN_TYPE_WINDOW) { + continue; + } + RegionView3D *rv3d = region->regiondata; + if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) { + camera->id.tag |= LIB_TAG_DOIT; + break; + } + } +} + +void ED_view3d_smooth_view_undo_end(bContext *C, + ScrArea *area, + const char *undo_str, + const bool undo_grouped) +{ + View3D *v3d = area->spacedata.first; + Object *camera = v3d->camera; + if (!camera) { + return; + } + if (camera->id.tag & LIB_TAG_DOIT) { + /* Smooth view didn't touch the camera. */ + camera->id.tag &= ~LIB_TAG_DOIT; + return; + } + + if ((U.uiflag & USER_GLOBALUNDO) == 0) { + return; + } + + /* NOTE(@campbellbarton): It is not possible that a single viewport references different cameras + * so even in the case there is a quad-view with multiple camera views set, these will all + * reference the same camera. In this case it doesn't matter which region is used. + * If in the future multiple cameras are supported, this logic can be extended. */ + ARegion *region_camera = NULL; + + /* An undo push should be performed. */ + bool is_interactive = false; + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { + if (region->regiontype != RGN_TYPE_WINDOW) { + continue; + } + RegionView3D *rv3d = region->regiondata; + if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) { + region_camera = region; + if (rv3d->sms) { + is_interactive = true; + } + } + } + + if (region_camera == NULL) { + return; + } + + /* Fast forward, undo push, then rewind. */ + if (is_interactive) { + view3d_smoothview_apply_with_interp(C, v3d, region_camera, false, 1.0f); + } + + RegionView3D *rv3d = region_camera->regiondata; + if (undo_grouped) { + ED_view3d_camera_lock_undo_grouped_push(undo_str, v3d, rv3d, C); + } + else { + ED_view3d_camera_lock_undo_push(undo_str, v3d, rv3d, C); + } + + if (is_interactive) { + view3d_smoothview_apply_with_interp(C, v3d, region_camera, false, 0.0f); + } +} + +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Smooth View Operator & Utilities * @@ -86,6 +195,11 @@ void ED_view3d_smooth_view_ex( const int smooth_viewtx, const V3D_SmoothParams *sview) { + /* In this case use #ED_view3d_smooth_view_undo_begin & end functions + * instead of passing in undo. */ + BLI_assert_msg(sview->undo_str == NULL, + "Only the 'ED_view3d_smooth_view' version of this function handles undo!"); + RegionView3D *rv3d = region->regiondata; struct SmoothView3DStore sms = {{0}}; @@ -236,6 +350,13 @@ void ED_view3d_smooth_view_ex( WM_event_add_mousemove(win); } + + if (sms.to_camera == false) { + /* See comments in #ED_view3d_smooth_view_undo_begin for why this is needed. */ + if (v3d->camera) { + v3d->camera->id.tag &= ~LIB_TAG_DOIT; + } + } } void ED_view3d_smooth_view(bContext *C, @@ -249,96 +370,128 @@ void ED_view3d_smooth_view(bContext *C, wmWindow *win = CTX_wm_window(C); ScrArea *area = CTX_wm_area(C); - ED_view3d_smooth_view_ex(depsgraph, wm, win, area, v3d, region, smooth_viewtx, sview); + /* #ED_view3d_smooth_view_ex asserts this is not set as it doesn't support undo. */ + struct V3D_SmoothParams sview_no_undo = *sview; + sview_no_undo.undo_str = NULL; + sview_no_undo.undo_grouped = false; + + const bool do_undo = (sview->undo_str != NULL); + if (do_undo) { + ED_view3d_smooth_view_undo_begin(C, area); + } + + ED_view3d_smooth_view_ex(depsgraph, wm, win, area, v3d, region, smooth_viewtx, &sview_no_undo); + + if (do_undo) { + ED_view3d_smooth_view_undo_end(C, area, sview->undo_str, sview->undo_grouped); + } } -/* only meant for timer usage */ -static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *region, bool sync_boxview) +/** + * Apply with interpolation, on completion run #view3d_smoothview_apply_and_finish. + */ +static void view3d_smoothview_apply_with_interp( + bContext *C, View3D *v3d, ARegion *region, const bool use_autokey, const float factor) { - wmWindowManager *wm = CTX_wm_manager(C); RegionView3D *rv3d = region->regiondata; struct SmoothView3DStore *sms = rv3d->sms; - float step, step_inv; - if (sms->time_allowed != 0.0) { - step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed); + interp_qt_qtqt(rv3d->viewquat, sms->src.quat, sms->dst.quat, factor); + + if (sms->use_dyn_ofs) { + view3d_orbit_apply_dyn_ofs( + rv3d->ofs, sms->src.ofs, sms->src.quat, rv3d->viewquat, sms->dyn_ofs); } else { - step = 1.0f; + interp_v3_v3v3(rv3d->ofs, sms->src.ofs, sms->dst.ofs, factor); } - /* end timer */ - if (step >= 1.0f) { - wmWindow *win = CTX_wm_window(C); + rv3d->dist = interpf(sms->dst.dist, sms->src.dist, factor); + v3d->lens = interpf(sms->dst.lens, sms->src.lens, factor); - /* if we went to camera, store the original */ - if (sms->to_camera) { - rv3d->persp = RV3D_CAMOB; - view3d_smooth_view_state_restore(&sms->org, v3d, rv3d); - } - else { - const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - - view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d); - - ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); - ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); - } + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); + if (use_autokey) { + ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); + } - if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) { - rv3d->view = sms->org_view; - } + ED_region_tag_redraw(region); +} - MEM_freeN(rv3d->sms); - rv3d->sms = NULL; +/** + * Apply the view-port transformation & free smooth-view related data. + */ +static void view3d_smoothview_apply_and_finish(bContext *C, View3D *v3d, ARegion *region) +{ + wmWindowManager *wm = CTX_wm_manager(C); + RegionView3D *rv3d = region->regiondata; + struct SmoothView3DStore *sms = rv3d->sms; - WM_event_remove_timer(wm, win, rv3d->smooth_timer); - rv3d->smooth_timer = NULL; - rv3d->rflag &= ~RV3D_NAVIGATING; + wmWindow *win = CTX_wm_window(C); - /* Event handling won't know if a UI item has been moved under the pointer. */ - WM_event_add_mousemove(win); + /* if we went to camera, store the original */ + if (sms->to_camera) { + rv3d->persp = RV3D_CAMOB; + view3d_smooth_view_state_restore(&sms->org, v3d, rv3d); } else { - /* ease in/out */ - step = (3.0f * step * step - 2.0f * step * step * step); - - step_inv = 1.0f - step; - - interp_qt_qtqt(rv3d->viewquat, sms->src.quat, sms->dst.quat, step); - - if (sms->use_dyn_ofs) { - view3d_orbit_apply_dyn_ofs( - rv3d->ofs, sms->src.ofs, sms->src.quat, rv3d->viewquat, sms->dyn_ofs); - } - else { - interp_v3_v3v3(rv3d->ofs, sms->src.ofs, sms->dst.ofs, step); - } + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv; - v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv; + view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d); - const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); - if (ED_screen_animation_playing(wm)) { - ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); - } + ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); } - if (sync_boxview && (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW)) { - view3d_boxview_copy(CTX_wm_area(C), region); + if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) { + rv3d->view = sms->org_view; } + MEM_freeN(rv3d->sms); + rv3d->sms = NULL; + + WM_event_remove_timer(wm, win, rv3d->smooth_timer); + rv3d->smooth_timer = NULL; + rv3d->rflag &= ~RV3D_NAVIGATING; + + /* Event handling won't know if a UI item has been moved under the pointer. */ + WM_event_add_mousemove(win); + /* NOTE: this doesn't work right because the v3d->lens is now used in ortho mode r51636, * when switching camera in quad-view the other ortho views would zoom & reset. * * For now only redraw all regions when smooth-view finishes. */ - if (step >= 1.0f) { - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); +} + +/* only meant for timer usage */ + +static void view3d_smoothview_apply_from_timer(bContext *C, View3D *v3d, ARegion *region) +{ + wmWindowManager *wm = CTX_wm_manager(C); + RegionView3D *rv3d = region->regiondata; + struct SmoothView3DStore *sms = rv3d->sms; + float factor; + + if (sms->time_allowed != 0.0) { + factor = (float)((rv3d->smooth_timer->duration) / sms->time_allowed); } else { - ED_region_tag_redraw(region); + factor = 1.0f; + } + if (factor >= 1.0f) { + view3d_smoothview_apply_and_finish(C, v3d, region); + } + else { + /* Ease in/out smoothing. */ + factor = (3.0f * factor * factor - 2.0f * factor * factor * factor); + const bool use_autokey = ED_screen_animation_playing(wm); + view3d_smoothview_apply_with_interp(C, v3d, region, use_autokey, factor); + } + + if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) { + view3d_boxview_copy(CTX_wm_area(C), region); } } @@ -353,7 +506,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w return OPERATOR_PASS_THROUGH; } - view3d_smoothview_apply(C, v3d, region, true); + view3d_smoothview_apply_from_timer(C, v3d, region); return OPERATOR_FINISHED; } @@ -363,8 +516,7 @@ void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *regio RegionView3D *rv3d = region->regiondata; if (rv3d && rv3d->sms) { - rv3d->sms->time_allowed = 0.0; /* force finishing */ - view3d_smoothview_apply(C, v3d, region, false); + view3d_smoothview_apply_and_finish(C, v3d, region); /* force update of view matrix so tools that run immediately after * can use them without redrawing first */ diff --git a/source/blender/editors/space_view3d/view3d_navigate_zoom_border.c b/source/blender/editors/space_view3d/view3d_navigate_zoom_border.c index f834efe4a7b..7cafc3dfd42 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_zoom_border.c +++ b/source/blender/editors/space_view3d/view3d_navigate_zoom_border.c @@ -159,11 +159,15 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) /* clamp after because we may have been zooming out */ CLAMP(new_dist, dist_range[0], dist_range[1]); - /* TODO(campbell): 'is_camera_lock' not currently working well. */ const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d); - if ((rv3d->persp == RV3D_CAMOB) && (is_camera_lock == false)) { + if (rv3d->persp == RV3D_CAMOB) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP); + if (is_camera_lock) { + ED_view3d_camera_lock_init(depsgraph, v3d, rv3d); + } + else { + ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP); + } } ED_view3d_smooth_view(C, @@ -173,6 +177,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) &(const V3D_SmoothParams){ .ofs = new_ofs, .dist = &new_dist, + .undo_str = op->type->name, }); if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) { diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 99f8cbc975b..0d88824a784 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -689,6 +689,18 @@ bool ED_view3d_camera_lock_autokey(View3D *v3d, return false; } +bool ED_view3d_camera_lock_undo_test(const View3D *v3d, + const RegionView3D *rv3d, + struct bContext *C) +{ + if (ED_view3d_camera_lock_check(v3d, rv3d)) { + if (ED_undo_is_memfile_compatible(C)) { + return true; + } + } + return false; +} + /** * Create a MEMFILE undo-step for locked camera movement when transforming the view. * Edit and texture paint mode don't use MEMFILE undo so undo push is skipped for them. @@ -699,16 +711,14 @@ bool ED_view3d_camera_lock_autokey(View3D *v3d, static bool view3d_camera_lock_undo_ex( const char *str, View3D *v3d, RegionView3D *rv3d, struct bContext *C, bool undo_group) { - if (ED_view3d_camera_lock_check(v3d, rv3d)) { - if (ED_undo_is_memfile_compatible(C)) { - if (undo_group) { - ED_undo_grouped_push(C, str); - } - else { - ED_undo_push(C, str); - } - return true; + if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) { + if (undo_group) { + ED_undo_grouped_push(C, str); + } + else { + ED_undo_push(C, str); } + return true; } return false; } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index fc88737ca70..b8042a9f215 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -202,6 +202,8 @@ static void sync_viewport_camera_smoothview(bContext *C, .quat = other_rv3d->viewquat, .dist = &other_rv3d->dist, .lens = &other_v3d->lens, + /* No undo because this switches cameras. */ + .undo_str = NULL, }); } else { @@ -256,6 +258,8 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op) .quat = rv3d->viewquat, .dist = &rv3d->dist, .lens = &v3d->lens, + /* No undo because this switches cameras. */ + .undo_str = NULL, }); } @@ -939,6 +943,8 @@ static bool view3d_localview_init(const Depsgraph *depsgraph, .quat = rv3d->viewquat, .dist = ok_dist ? &dist_new : NULL, .lens = &v3d->lens, + /* No undo because this doesn't move the camera. */ + .undo_str = NULL, }); } } @@ -1008,6 +1014,8 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, .ofs = rv3d->localvd->ofs, .quat = rv3d->localvd->viewquat, .dist = &rv3d->localvd->dist, + /* No undo because this doesn't move the camera. */ + .undo_str = NULL, }); } diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 4157caf45d7..91819a8806b 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -190,8 +190,8 @@ set(OPENGL_SRC set(METAL_SRC metal/mtl_backend.mm - metal/mtl_context.mm metal/mtl_command_buffer.mm + metal/mtl_context.mm metal/mtl_debug.mm metal/mtl_framebuffer.mm metal/mtl_memory.mm @@ -470,8 +470,8 @@ set(SRC_SHADER_CREATE_INFOS ../draw/engines/overlay/shaders/infos/overlay_grid_info.hh ../draw/engines/overlay/shaders/infos/overlay_outline_info.hh ../draw/engines/overlay/shaders/infos/overlay_paint_info.hh - ../draw/engines/overlay/shaders/infos/overlay_sculpt_info.hh ../draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh + ../draw/engines/overlay/shaders/infos/overlay_sculpt_info.hh ../draw/engines/overlay/shaders/infos/overlay_volume_info.hh ../draw/engines/overlay/shaders/infos/overlay_wireframe_info.hh ../draw/engines/select/shaders/infos/select_id_info.hh @@ -593,9 +593,9 @@ if(WITH_GPU_BUILDTIME_SHADER_BUILDER) endif() target_link_libraries(shader_builder PUBLIC + bf_blenlib bf_gpu bf_intern_clog - bf_blenlib bf_intern_ghost ${PLATFORM_LINKLIBS} ) diff --git a/source/blender/io/common/CMakeLists.txt b/source/blender/io/common/CMakeLists.txt index a6818c0bf5d..ee5c6a0a47f 100644 --- a/source/blender/io/common/CMakeLists.txt +++ b/source/blender/io/common/CMakeLists.txt @@ -19,15 +19,15 @@ set(SRC intern/dupli_parent_finder.cc intern/dupli_persistent_id.cc intern/object_identifier.cc - intern/path_util.cc intern/orientation.c + intern/path_util.cc IO_abstract_hierarchy_iterator.h IO_dupli_persistent_id.hh + IO_orientation.h IO_path_util.hh IO_path_util_types.h IO_types.h - IO_orientation.h intern/dupli_parent_finder.hh ) diff --git a/source/blender/io/stl/CMakeLists.txt b/source/blender/io/stl/CMakeLists.txt index e0c48bbbf7e..3a21da5c579 100644 --- a/source/blender/io/stl/CMakeLists.txt +++ b/source/blender/io/stl/CMakeLists.txt @@ -24,16 +24,16 @@ set(INC_SYS set(SRC IO_stl.cc - importer/stl_import_mesh.cc + importer/stl_import.cc importer/stl_import_ascii_reader.cc importer/stl_import_binary_reader.cc - importer/stl_import.cc + importer/stl_import_mesh.cc IO_stl.h - importer/stl_import_mesh.hh + importer/stl_import.hh importer/stl_import_ascii_reader.hh importer/stl_import_binary_reader.hh - importer/stl_import.hh + importer/stl_import_mesh.hh ) set(LIB diff --git a/source/blender/nodes/geometry/CMakeLists.txt b/source/blender/nodes/geometry/CMakeLists.txt index ddd8c8949b1..31c00cc6b82 100644 --- a/source/blender/nodes/geometry/CMakeLists.txt +++ b/source/blender/nodes/geometry/CMakeLists.txt @@ -76,8 +76,8 @@ set(SRC nodes/node_geo_input_index.cc nodes/node_geo_input_instance_rotation.cc nodes/node_geo_input_instance_scale.cc - nodes/node_geo_input_material_index.cc nodes/node_geo_input_material.cc + nodes/node_geo_input_material_index.cc nodes/node_geo_input_mesh_edge_angle.cc nodes/node_geo_input_mesh_edge_neighbors.cc nodes/node_geo_input_mesh_edge_vertices.cc @@ -118,9 +118,9 @@ set(SRC nodes/node_geo_mesh_to_points.cc nodes/node_geo_mesh_to_volume.cc nodes/node_geo_object_info.cc + nodes/node_geo_points.cc nodes/node_geo_points_to_vertices.cc nodes/node_geo_points_to_volume.cc - nodes/node_geo_points.cc nodes/node_geo_proximity.cc nodes/node_geo_raycast.cc nodes/node_geo_realize_instances.cc @@ -134,8 +134,8 @@ set(SRC nodes/node_geo_set_curve_radius.cc nodes/node_geo_set_curve_tilt.cc nodes/node_geo_set_id.cc - nodes/node_geo_set_material_index.cc nodes/node_geo_set_material.cc + nodes/node_geo_set_material_index.cc nodes/node_geo_set_point_radius.cc nodes/node_geo_set_position.cc nodes/node_geo_set_shade_smooth.cc diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_rgb.cc index c854bc733a3..3d28f5278a2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_rgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_rgb.cc @@ -17,7 +17,7 @@ static void node_declare(NodeDeclarationBuilder &b) static int gpu_shader_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), - GPUNodeStack *in, + GPUNodeStack * /*in*/, GPUNodeStack *out) { const bNodeSocket *socket = static_cast<bNodeSocket *>(node->outputs.first); diff --git a/source/blender/nodes/shader/nodes/node_shader_value.cc b/source/blender/nodes/shader/nodes/node_shader_value.cc index b6b7fe10cf9..14dbb3b25eb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_value.cc +++ b/source/blender/nodes/shader/nodes/node_shader_value.cc @@ -17,7 +17,7 @@ static void sh_node_value_declare(NodeDeclarationBuilder &b) static int gpu_shader_value(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), - GPUNodeStack *in, + GPUNodeStack * /*in*/, GPUNodeStack *out) { const bNodeSocket *socket = static_cast<bNodeSocket *>(node->outputs.first); diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 11f48a72908..b9912929a54 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -200,8 +200,10 @@ if(WITH_BUILDINFO) SET_SOURCE_FILES_PROPERTIES(${buildinfo_h_fake} PROPERTIES SYMBOLIC TRUE) # a custom target that is always built - add_custom_target(buildinfo ALL - DEPENDS ${buildinfo_h_fake}) + add_custom_target( + buildinfo ALL + DEPENDS ${buildinfo_h_fake} + ) # creates buildinfo.h using cmake script add_custom_command( @@ -272,13 +274,13 @@ if(WITH_PYTHON_MODULE) else() add_executable(blender ${EXETYPE} ${SRC}) if(WIN32) - add_executable(blender-launcher WIN32 - blender_launcher_win32.c - ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.rc - ${CMAKE_BINARY_DIR}/blender.exe.manifest - ) - target_compile_definitions (blender-launcher PRIVATE -D_UNICODE -DUNICODE) - target_link_libraries(blender-launcher Pathcch.lib) + add_executable(blender-launcher WIN32 + blender_launcher_win32.c + ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.rc + ${CMAKE_BINARY_DIR}/blender.exe.manifest + ) + target_compile_definitions (blender-launcher PRIVATE -D_UNICODE -DUNICODE) + target_link_libraries(blender-launcher Pathcch.lib) endif() endif() @@ -405,8 +407,8 @@ if(WITH_INTERNATIONAL) # Create a custom target which will compile all po to mo add_custom_target( locales - DEPENDS ${_all_mo_files}) - + DEPENDS ${_all_mo_files} + ) add_dependencies(blender locales) # Generate INSTALL rules @@ -464,7 +466,8 @@ if(UNIX AND NOT APPLE) blender_man_page ALL COMMAND ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1.py --blender ${EXECUTABLE_OUTPUT_PATH}/blender - --output ${CMAKE_CURRENT_BINARY_DIR}/blender.1) + --output ${CMAKE_CURRENT_BINARY_DIR}/blender.1 + ) add_dependencies(blender_man_page blender) endif() endif() @@ -719,15 +722,15 @@ elseif(WIN32) if(WITH_OPENMP AND MSVC_CLANG) install( - FILES ${CLANG_OPENMP_DLL} - DESTINATION "." + FILES ${CLANG_OPENMP_DLL} + DESTINATION "." ) endif() if(WITH_FFTW3) install( - FILES ${LIBDIR}/fftw3/lib/libfftw3-3.dll - DESTINATION "." + FILES ${LIBDIR}/fftw3/lib/libfftw3-3.dll + DESTINATION "." ) endif() if(MSVC_ASAN) @@ -738,14 +741,14 @@ elseif(WIN32) message(FATAL_ERROR "Asan is enabled, but the ASAN runtime is not detected, this is an optional component during the MSVC install, please install it") endif() install( - FILES ${ASAN_DLL} - DESTINATION "." - CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + FILES ${ASAN_DLL} + DESTINATION "." + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel ) install( - FILES ${ASAN_DEBUG_DLL} - DESTINATION "." - CONFIGURATIONS Debug + FILES ${ASAN_DEBUG_DLL} + DESTINATION "." + CONFIGURATIONS Debug ) unset(ASAN_DLL) unset(ASAN_DEBUG_DLL) @@ -753,18 +756,18 @@ elseif(WIN32) if(WITH_GMP) install( - FILES ${LIBDIR}/gmp/lib/libgmp-10.dll - DESTINATION "." + FILES ${LIBDIR}/gmp/lib/libgmp-10.dll + DESTINATION "." ) install( - FILES ${LIBDIR}/gmp/lib/libgmpxx.dll - DESTINATION "." - CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + FILES ${LIBDIR}/gmp/lib/libgmpxx.dll + DESTINATION "." + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel ) install( - FILES ${LIBDIR}/gmp/lib/libgmpxx_d.dll - DESTINATION "." - CONFIGURATIONS Debug + FILES ${LIBDIR}/gmp/lib/libgmpxx_d.dll + DESTINATION "." + CONFIGURATIONS Debug ) endif() @@ -780,16 +783,16 @@ elseif(WIN32) endif() if(WITH_OPENVDB) - install( - FILES ${LIBDIR}/openvdb/bin/openvdb.dll - DESTINATION "." - CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel - ) - install( - FILES ${LIBDIR}/openvdb/bin/openvdb_d.dll - DESTINATION "." - CONFIGURATIONS Debug - ) + install( + FILES ${LIBDIR}/openvdb/bin/openvdb.dll + DESTINATION "." + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + ) + install( + FILES ${LIBDIR}/openvdb/bin/openvdb_d.dll + DESTINATION "." + CONFIGURATIONS Debug + ) endif() if(WITH_PYTHON) @@ -1054,7 +1057,8 @@ elseif(APPLE) set_target_properties(blender PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist MACOSX_BUNDLE_SHORT_VERSION_STRING "${BLENDER_VERSION}.${BLENDER_VERSION_PATCH}" - MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION}.${BLENDER_VERSION_PATCH} ${BLENDER_DATE}") + MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION}.${BLENDER_VERSION_PATCH} ${BLENDER_DATE}" + ) # Gather the date in finder-style execute_process(COMMAND date "+%m/%d/%Y/%H:%M" @@ -1151,9 +1155,10 @@ endif() if(DEFINED BLENDER_TEXT_FILES_DESTINATION) - configure_file(${CMAKE_SOURCE_DIR}/release/text/readme.html - ${CMAKE_BINARY_DIR}/release/text/readme.html - @ONLY + configure_file( + ${CMAKE_SOURCE_DIR}/release/text/readme.html + ${CMAKE_BINARY_DIR}/release/text/readme.html + @ONLY ) list(APPEND BLENDER_TEXT_FILES ${CMAKE_BINARY_DIR}/release/text/readme.html @@ -1240,17 +1245,18 @@ if(WIN32) set_target_properties(blender PROPERTIES VS_GLOBAL_VcpkgEnabled "false") set_target_properties(blender PROPERTIES PDB_NAME "blender_private" - PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>") - if(WITH_WINDOWS_PDB AND WITH_WINDOWS_STRIPPED_PDB) - # This is slightly messy, but single target generators like ninja will not have the - # CMAKE_CFG_INTDIR variable and multitarget generators like msbuild will not have - # CMAKE_BUILD_TYPE. This can be simplified by target_link_options and the $<CONFIG> - # generator expression in newer cmake (2.13+) but until that time this fill have suffice. - if(CMAKE_BUILD_TYPE) - set_property(TARGET blender APPEND_STRING PROPERTY LINK_FLAGS " /PDBSTRIPPED:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/blender_public.pdb") - else() - set_property(TARGET blender APPEND_STRING PROPERTY LINK_FLAGS " /PDBSTRIPPED:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/blender_public.pdb") - endif() + PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>" + ) + if(WITH_WINDOWS_PDB AND WITH_WINDOWS_STRIPPED_PDB) + # This is slightly messy, but single target generators like ninja will not have the + # `CMAKE_CFG_INTDIR` variable and multi-target generators like `msbuild` will not have + # `CMAKE_BUILD_TYPE`. This can be simplified by target_link_options and the `$<CONFIG>` + # generator expression in newer CMAKE (2.13+) but until that time this fill have suffice. + if(CMAKE_BUILD_TYPE) + set_property(TARGET blender APPEND_STRING PROPERTY LINK_FLAGS " /PDBSTRIPPED:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/blender_public.pdb") + else() + set_property(TARGET blender APPEND_STRING PROPERTY LINK_FLAGS " /PDBSTRIPPED:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/blender_public.pdb") + endif() endif() endif() diff --git a/tests/python/gpu_info.py b/tests/python/gpu_info.py index 518fdc98bcc..426ce29e85d 100644 --- a/tests/python/gpu_info.py +++ b/tests/python/gpu_info.py @@ -1,7 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + """ - Prints GPU backend information to the console and exits. +Prints GPU back-end information to the console and exits. - Use this script as `blender --background --python gpu_info.py`. +Use this script as `blender --background --python gpu_info.py`. """ import bpy import gpu |