UI: Increase Color Picker Size #111153

Merged
Harley Acheson merged 3 commits from Harley/blender:ColorPickerSize into main 2023-08-16 22:59:21 +02:00
256 changed files with 2828 additions and 1134 deletions
Showing only changes of commit 6dc951f662 - Show all commits

17
AUTHORS
View File

@ -15,6 +15,9 @@
# See python fnmatch module documentation for more information.
#
# Please keep the list sorted.
#
# The individual authors section can be regenerated using:
# make authors
# BEGIN individuals section.
Aaron Carlisle <carlisle.aaron00@gmail.com>
@ -25,7 +28,6 @@ Adrian Newton <TFS>
AgAmemnno <kaz380@hotmail.co.jp>
Aidan Davey <ShadowDragon>
Aidan Haile <tactical_fluke>
Alan <Al@AlanTroth.me.uk>
Alan Babu <alanaman>
Alan Troth <Al>
Alaska <alaskayou01@gmail.com>
@ -53,7 +55,6 @@ Ali-Erdinc-Koroglu <ali-erdinc-koroglu@noreply.localhost>
Aliaksandr Sharstniou <kartiz0l@noreply.localhost>
Alistair Sealy <alisealy>
Almaz Shinbay <almaz.shinbay@nu.edu.kz>
Almaz-Shinbay <almaz-shinbay@noreply.localhost>
Amélie Fondevilla <amelie.fondevilla@les-fees-speciales.coop>
Anatoly TechTonik <techtonik@gmail.com>
Andras-Borsanyi <andras-borsanyi@noreply.localhost>
@ -71,7 +72,6 @@ Angel Bueno <angelbpineda>
Angus Stanton <abstanton>
Ankit Meel <ankitjmeel@gmail.com>
Ankur Deria <DAnkur>
Anthony <anthony-roberts@noreply.localhost>
Anthony Edlin <akrashe@gmail.com>
Anthony Eriksson <Kony>
Anthony Roberts <anthony.roberts@linaro.org>
@ -185,7 +185,6 @@ Dominik Fill <dominikfill>
Domino Marama <domino@dominodesigns.info>
Dontsov Valentin <@blend4web.com>
Dorian <BD3D>
Dotsnov Valentin <invalid@nodomain.com>
Doug Hammond <doughammond@hamsterfight.co.uk>
Ed Halley <ed@halley.cc>
Edgar Roman Cervantes <redvant>
@ -271,7 +270,6 @@ Jacques Guignot <guignot@wanadoo.fr>
Jacques Lucke <jacques@blender.org>
Jagannadhan Ravi <easythrees>
Jaggz H <jaggz>
Jake <Welp>
Jakub Steiner <jimmac@gmail.com>
Jamell Moore <JamellMoore>
James <devpalestrina>
@ -374,7 +372,6 @@ Luc Revardel <luc.revardel@gmail.com>
Luca Bonavita <mindrones@gmail.com>
Luca Rood <dev@lucarood.com>
Lucas Boutrot <thornydre>
Lucas Tadeu <yup_lucas@noreply.localhost>
Lucas Tadeu Teixeira <lucas@lucastadeu.com>
Lucas Veber <lucky3>
Luis Pereira <LuisPereira>
@ -483,7 +480,6 @@ Pablo Dobarro <pablodp606@gmail.com>
Pablo Vazquez <pablo@blender.org>
Paolo Acampora <pkrime>
Pascal Schoen <pascal.schoen@adidas-group.com>
Pascal Schön <VanCantus>
Patrick Bender <ichbinkeinreh>
Patrick Busch <xylvier@noreply.localhost>
Patrick Foley <Patrick-Foley>
@ -512,7 +508,6 @@ Phoenix Katsch <phoenixkatsch>
Pi Lanningham <Quantumplation>
Pierluigi Grassi <pierluigi@tukano.it>
Pierre Risch <prisch>
PiloeGAO <leonumerique@gmail.com>
Piotr Makal <pmakal>
Piotr Ostrowski <postrowski>
Pratik Borhade <pratikborhade302@gmail.com>
@ -527,7 +522,6 @@ Rateeb Riyasat <bmollusc>
Ray Molenkamp <github@lazydodo.com>
Rebecca Dengate <beckyd>
Red Mser <RedMser>
RedMser <redmser.jj2@gmail.com>
Reinier de Blois <rddeblois@gmail.com>
Remigiusz Fiedler <migius@gmx.net>
Remy Fayet <rems64des@gmail.com>
@ -672,12 +666,9 @@ Zijun Zhou <eary@noreply.localhost>
andreas atteneder <atti>
b-init <b-init>
bird_d <bird_d>
bonj <jorijndegraaf@gmail.com>
brunoT <drehuwann@gmail.com>
cgtinker <Denys.Hsu@gmail.com>
demeterdzadik@gmail.com <demeterdzadik@gmail.com>
fiord <hyoga_quasar@yahoo.co.jp>
frogstomp <email.frogstomp@gmail.com>
himisa <himisa@noreply.localhost>
jim man <jimman2003>
jon denning <gfxcoder@gmail.com>
@ -690,8 +681,6 @@ n-kall <noa@tutamail.com>
nBurn <nbwashburn@gmail.com>
nutti <nutti.metro@gmail.com>
ok_what <ip1149a@gmail.com>
pembem22 <pembem22>
salipourto <sahar.alipourkashi@amd.com>
swann <slumber>
unclezeiv <davide.vercelli@gmail.com>
yves <valfeur>

View File

@ -650,7 +650,8 @@ if(NOT APPLE)
# Radeon VII (gfx906) not currently working with HIP SDK, so left out of the list.
set(CYCLES_HIP_BINARIES_ARCH
gfx900 gfx90c gfx902
gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 gfx1035
gfx1010 gfx1011 gfx1012
gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 gfx1036
gfx1100 gfx1101 gfx1102
CACHE STRING "AMD HIP architectures to build binaries for"
)

View File

@ -96,6 +96,9 @@ Spell Checkers
Utilities
Not associated with building Blender.
* authors:
Update the AUTHORS file using GIT history.
* icons:
Updates PNG icons from SVG files.
@ -547,6 +550,8 @@ source_archive_complete: .FORCE
# This assumes CMake is still using a default `PACKAGE_DIR` variable:
@$(PYTHON) ./build_files/utils/make_source_archive.py --include-packages "$(BUILD_DIR)/source_archive/packages"
authors: .FORCE
@$(PYTHON) ./tools/utils/authors_git_gen.py
INKSCAPE_BIN?="inkscape"
icons: .FORCE

View File

@ -50,7 +50,7 @@ set(OPENVDB_PATCH ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATC
if(APPLE)
set(OPENVDB_PATCH
${OPENVDB_PATCH} &&
${PATCH_CMD} -p 0 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb_metal.diff
${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb_metal.diff
)
endif()

View File

@ -2,6 +2,8 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(SDL_PATCH ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/sdl/src/external_sdl < ${PATCH_DIR}/sdl.diff)
if(WIN32)
set(SDL_EXTRA_ARGS
-DSDL_STATIC=Off
@ -13,6 +15,14 @@ else()
-DSDL_VIDEO=OFF
-DSNDIO=OFF
)
# Core Haptics only available once macOS 11.0 becomes minimum.
if(APPLE AND NOT BLENDER_PLATFORM_ARM)
list(APPEND SDL_EXTRA_ARGS -DSDL_HAPTICS=OFF)
set(SDL_PATCH
${SDL_PATCH} &&
${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/sdl/src/external_sdl < ${PATCH_DIR}/sdl_haptics.diff)
endif()
endif()
ExternalProject_Add(external_sdl
@ -20,7 +30,7 @@ ExternalProject_Add(external_sdl
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${SDL_HASH_TYPE}=${SDL_HASH}
PREFIX ${BUILD_DIR}/sdl
PATCH_COMMAND ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/sdl/src/external_sdl < ${PATCH_DIR}/sdl.diff
PATCH_COMMAND ${SDL_PATCH}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/sdl ${DEFAULT_CMAKE_FLAGS} ${SDL_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/sdl
)

View File

@ -128,9 +128,9 @@ set(OPENSUBDIV_HASH 230f5cd2911d6240e58a3773b9c6e5e4)
set(OPENSUBDIV_HASH_TYPE MD5)
set(OPENSUBDIV_FILE opensubdiv-${OPENSUBDIV_VERSION}.tar.gz)
set(SDL_VERSION 2.0.20)
set(SDL_VERSION 2.28.2)
set(SDL_URI https://www.libsdl.org/release/SDL2-${SDL_VERSION}.tar.gz)
set(SDL_HASH a53acc02e1cca98c4123229069b67c9e)
set(SDL_HASH 06ff379c406cd8318d18f0de81ee2709)
set(SDL_HASH_TYPE MD5)
set(SDL_FILE SDL2-${SDL_VERSION}.tar.gz)
set(SDL_CPE "cpe:2.3:a:libsdl:sdl:${SDL_VERSION}:*:*:*:*:*:*:*")

File diff suppressed because it is too large Load Diff

View File

@ -2,34 +2,14 @@ diff -ru ./src/video/SDL_video.c ./src/video/SDL_video.c
--- CMakeLists.txt.old 2016-01-02 12:56:31 -0700
+++ CMakeLists.txt 2016-10-03 11:24:24 -0600
@@ -609,7 +609,7 @@
list(APPEND EXTRA_LIBS m)
endif()
- check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
+ #check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
if(HAVE_LIBICONV)
list(APPEND EXTRA_LIBS iconv)
set(HAVE_ICONV 1)
--- src/video/SDL_video.c 2018-09-10 23:27:57.000000000 +0200
+++ src/video/SDL_video.c 2018-09-10 23:28:09.000000000 +0200
@@ -1176,7 +1176,7 @@
return 0;
}
-#ifdef __MACOSX__
+#if defined(__MACOSX__) && SDL_VIDEO_DRIVER_COCOA
/* if the window is going away and no resolution change is necessary,
do nothing, or else we may trigger an ugly double-transition
*/
@@ -2563,7 +2563,7 @@
return SDL_FALSE;
}
-#ifdef __MACOSX__
+#if defined(__MACOSX__) && SDL_VIDEO_DRIVER_COCOA
if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */
if (Cocoa_IsWindowInFullscreenSpace(window)) {
return SDL_FALSE;
if(SDL_SYSTEM_ICONV)
- check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
+ #check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
if(HAVE_LIBICONV)
list(APPEND EXTRA_LIBS iconv)
set(HAVE_ICONV 1)
--- CMakeLists.txt 2022-12-09 20:40:00
+++ CMakeLists.txt 2022-12-09 20:40:00
@@ -526,6 +526,13 @@

View File

@ -0,0 +1,12 @@
--- src/joystick/iphoneos/SDL_mfijoystick.m 2023-08-16 18:57:36
+++ src/joystick/iphoneos/SDL_mfijoystick.m2 2023-08-16 18:57:25
@@ -95,7 +95,8 @@
#if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 140000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 140000) || (__MAC_OS_VERSION_MAX_ALLOWED > 1500000) || (__MAC_OS_X_VERSION_MAX_ALLOWED > 101600)
#define ENABLE_MFI_BATTERY
-#define ENABLE_MFI_RUMBLE
+// BLENDER: disable until macOS 11.0 becomes the minimum version and Core Haptics is available.
+//#define ENABLE_MFI_RUMBLE
#define ENABLE_MFI_LIGHT
#define ENABLE_MFI_SENSORS
#define ENABLE_MFI_SYSTEM_GESTURE_STATE

View File

@ -7,7 +7,7 @@ string(TIMESTAMP CURRENT_YEAR "%Y")
set(PROJECT_DESCRIPTION "Blender is the free and open source 3D creation suite software.")
set(PROJECT_COPYRIGHT "Copyright (C) 2001-${CURRENT_YEAR} Blender Authors")
set(PROJECT_CONTACT "foundation@blender.org")
set(PROJECT_VENDOR "Blender Authors")
set(PROJECT_VENDOR "Blender Foundation")
set(MAJOR_VERSION ${BLENDER_VERSION_MAJOR})
set(MINOR_VERSION ${BLENDER_VERSION_MINOR})
@ -84,8 +84,8 @@ if(APPLE)
endif()
if(WIN32)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Blender Authors/Blender ${MAJOR_VERSION}.${MINOR_VERSION}")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "Blender Authors/Blender ${MAJOR_VERSION}.${MINOR_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Blender Foundation/Blender ${MAJOR_VERSION}.${MINOR_VERSION}")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "Blender Foundation/Blender ${MAJOR_VERSION}.${MINOR_VERSION}")
set(CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.ico)
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")

View File

@ -231,7 +231,7 @@ def main() -> None:
long_description=long_description,
long_description_content_type='text/markdown',
license="GPL-3.0",
author="Blender Authors",
author="Blender Foundation",
author_email="bf-committers@blender.org",
url="https://www.blender.org"
)

View File

@ -1957,7 +1957,7 @@ except ModuleNotFoundError:
fw(" 'papersize': 'a4paper',\n")
fw("}\n\n")
fw("latex_documents = [ ('contents', 'contents.tex', 'Blender Index', 'Blender Authors', 'manual'), ]\n")
fw("latex_documents = [ ('contents', 'contents.tex', 'Blender Index', 'Blender Foundation', 'manual'), ]\n")
# Workaround for useless links leading to compile errors
# See https://github.com/sphinx-doc/sphinx/issues/3866

View File

@ -78,7 +78,7 @@ shader node_principled_bsdf(string distribution = "multi_ggx",
}
closure color TransmissionBSDF = 0;
if (Metallic < 1.0 && Transmission > 1.0) {
if (Metallic < 1.0 && Transmission > 0.0) {
color reflectTint = mix(color(1.0), BaseColor, SpecularTint);
float eta = max(IOR, 1e-5);
eta = backfacing() ? 1.0 / eta : eta;

View File

@ -764,6 +764,13 @@ extern void GHOST_SetMultitouchGestures(GHOST_SystemHandle systemhandle, const b
*/
extern void GHOST_SetTabletAPI(GHOST_SystemHandle systemhandle, GHOST_TTabletAPI api);
/**
* Get the color of the pixel at the current mouse cursor location
* \param r_color: returned sRGB float colors
* \return Success value (true == successful and supported by platform)
*/
extern GHOST_TSuccess GHOST_GetPixelAtCursor(float r_color[3]);
/**
* Access to rectangle width.
* \param rectanglehandle: The handle to the rectangle.

View File

@ -441,6 +441,13 @@ class GHOST_ISystem {
*/
virtual void setTabletAPI(GHOST_TTabletAPI api) = 0;
/**
* Get the color of the pixel at the current mouse cursor location
* \param r_color: returned sRGB float colors
* \return Success value (true == successful and supported by platform)
*/
virtual GHOST_TSuccess getPixelAtCursor(float r_color[3]) const = 0;
#ifdef WITH_INPUT_NDOF
/**
* Sets 3D mouse deadzone

View File

@ -107,6 +107,10 @@ typedef enum {
* Set when there is support for system clipboard copy/paste.
*/
GHOST_kCapabilityClipboardImages = (1 << 4),
/**
* Support for sampling a color outside of the Blender windows.
*/
GHOST_kCapabilityDesktopSample = (1 << 5),
} GHOST_TCapabilityFlag;
/**
@ -115,7 +119,8 @@ typedef enum {
*/
#define GHOST_CAPABILITY_FLAG_ALL \
(GHOST_kCapabilityCursorWarp | GHOST_kCapabilityWindowPosition | \
GHOST_kCapabilityPrimaryClipboard | GHOST_kCapabilityGPUReadFrontBuffer)
GHOST_kCapabilityPrimaryClipboard | GHOST_kCapabilityGPUReadFrontBuffer | \
GHOST_kCapabilityClipboardImages | GHOST_kCapabilityDesktopSample)
/* Xtilt and Ytilt represent how much the pen is tilted away from
* vertically upright in either the X or Y direction, with X and Y the

View File

@ -768,6 +768,12 @@ void GHOST_SetTabletAPI(GHOST_SystemHandle systemhandle, GHOST_TTabletAPI api)
system->setTabletAPI(api);
}
GHOST_TSuccess GHOST_GetPixelAtCursor(float r_color[3])
{
GHOST_ISystem *system = GHOST_ISystem::getSystem();
return system->getPixelAtCursor(r_color);
}
int32_t GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
{
return ((GHOST_Rect *)rectanglehandle)->getWidth();

View File

@ -341,6 +341,11 @@ GHOST_TTabletAPI GHOST_System::getTabletAPI()
return m_tabletAPI;
}
GHOST_TSuccess GHOST_System::getPixelAtCursor(float[3] /* r_color */) const
{
return GHOST_kFailure;
}
#ifdef WITH_INPUT_NDOF
void GHOST_System::setNDOFDeadZone(float deadzone)
{

View File

@ -256,6 +256,13 @@ class GHOST_System : public GHOST_ISystem {
virtual void setTabletAPI(GHOST_TTabletAPI api);
GHOST_TTabletAPI getTabletAPI(void);
/**
* Get the color of the pixel at the current mouse cursor location
* \param r_color: returned sRGB float colors
* \return Success value (true == successful and supported by platform)
*/
GHOST_TSuccess getPixelAtCursor(float r_color[3]) const;
#ifdef WITH_INPUT_NDOF
/***************************************************************************************
* Access to 3D mouse.

View File

@ -921,6 +921,8 @@ GHOST_TCapabilityFlag GHOST_SystemCocoa::getCapabilities() const
~(
/* Cocoa has no support for a primary selection clipboard. */
GHOST_kCapabilityPrimaryClipboard |
/* Cocoa has no support for sampling colors from the desktop. */
GHOST_kCapabilityDesktopSample |
/* This Cocoa back-end has not yet implemented image copy/paste. */
GHOST_kCapabilityClipboardImages));
}

View File

@ -50,6 +50,7 @@ class GHOST_SystemHeadless : public GHOST_System {
/* No windowing functionality supported. */
~(GHOST_kCapabilityWindowPosition | GHOST_kCapabilityCursorWarp |
GHOST_kCapabilityPrimaryClipboard |
GHOST_kCapabilityDesktopSample |
GHOST_kCapabilityClipboardImages));
}
char *getClipboard(bool /*selection*/) const override

View File

@ -31,7 +31,7 @@ const char *GHOST_SystemPathsWin32::getSystemDir(int, const char *versionstr) co
if (hResult == S_OK) {
conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3);
CoTaskMemFree(knownpath_16);
strcat(knownpath, "\\Blender Authors\\Blender\\");
strcat(knownpath, "\\Blender Foundation\\Blender\\");
strcat(knownpath, versionstr);
return knownpath;
}
@ -50,7 +50,7 @@ const char *GHOST_SystemPathsWin32::getUserDir(int, const char *versionstr) cons
if (hResult == S_OK) {
conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3);
CoTaskMemFree(knownpath_16);
strcat(knownpath, "\\Blender Authors\\Blender\\");
strcat(knownpath, "\\Blender Foundation\\Blender\\");
strcat(knownpath, versionstr);
return knownpath;
}

View File

@ -772,6 +772,8 @@ GHOST_TCapabilityFlag GHOST_SystemSDL::getCapabilities() const
~(
/* This SDL back-end has not yet implemented primary clipboard. */
GHOST_kCapabilityPrimaryClipboard |
/* This SDL back-end has not yet implemented color sampling the desktop. */
GHOST_kCapabilityDesktopSample |
/* This SDL back-end has not yet implemented image copy/paste. */
GHOST_kCapabilityClipboardImages));
}

View File

@ -6843,6 +6843,8 @@ GHOST_TCapabilityFlag GHOST_SystemWayland::getCapabilities() const
* screen-shot and eye-dropper sampling logic, both operations where the overhead
* is negligible. */
GHOST_kCapabilityGPUReadFrontBuffer |
/* This WAYLAND back-end has not yet implemented desktop color sample. */
GHOST_kCapabilityDesktopSample |
/* This WAYLAND back-end has not yet implemented image copy/paste. */
GHOST_kCapabilityClipboardImages));
}

View File

@ -448,6 +448,31 @@ GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(int32_t x, int32_t y)
return ::SetCursorPos(x, y) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
GHOST_TSuccess GHOST_SystemWin32::getPixelAtCursor(float r_color[3]) const
{
POINT point;
if (!GetCursorPos(&point)) {
return GHOST_kFailure;
}
HDC dc = GetDC(NULL);
if (dc == NULL) {
return GHOST_kFailure;
}
COLORREF color = GetPixel(dc, point.x, point.y);
ReleaseDC(NULL, dc);
if (color == CLR_INVALID) {
return GHOST_kFailure;
}
r_color[0] = GetRValue(color) / 255.0f;
r_color[1] = GetGValue(color) / 255.0f;
r_color[2] = GetBValue(color) / 255.0f;
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys &keys) const
{
/* `GetAsyncKeyState` returns the current interrupt-level state of the hardware, which is needed

View File

@ -182,6 +182,13 @@ class GHOST_SystemWin32 : public GHOST_System {
*/
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y);
/**
* Get the color of the pixel at the current mouse cursor location
* \param r_color: returned sRGB float colors
* \return Success value (true == successful and supported by platform)
*/
GHOST_TSuccess getPixelAtCursor(float r_color[3]) const;
/***************************************************************************************
** Access to mouse button and keyboard states.
***************************************************************************************/

View File

@ -1693,6 +1693,8 @@ GHOST_TCapabilityFlag GHOST_SystemX11::getCapabilities() const
{
return GHOST_TCapabilityFlag(GHOST_CAPABILITY_FLAG_ALL &
~(
/* No support yet for desktop sampling. */
GHOST_kCapabilityDesktopSample |
/* No support yet for image copy/paste. */
GHOST_kCapabilityClipboardImages));
}

View File

@ -128,3 +128,4 @@ if "%BUILD_WITH_NINJA%" == "" (
)
:EOF
if errorlevel 1 exit /b %errorlevel%

View File

@ -287,7 +287,6 @@ const bTheme U_theme_default = {
.space_view3d = {
.back = RGBA(0x3d3d3dff),
.back_grad = RGBA(0x30303000),
.background_type = 2,
.title = RGBA(0xeeeeeeff),
.text = RGBA(0xe6e6e6ff),
.text_hi = RGBA(0xffffffff),
@ -569,11 +568,11 @@ const bTheme U_theme_default = {
.vertex_size = 3,
.outline_width = 1,
.facedot_size = 4,
.simulated_frames = RGBA(0x721e65ff),
.keyframe_scale_fac = 1.0f,
.handle_vertex_size = 4,
.anim_active = RGBA(0x4d272766),
.anim_preview_range = RGBA(0xa14d0066),
.simulated_frames = RGBA(0x721e65ff),
},
.space_nla = {
.back = RGBA(0x30303000),

View File

@ -7,6 +7,7 @@
*/
#include <fstream>
#include <iostream>
#include <set>
#include "AS_asset_catalog.hh"

View File

@ -10,6 +10,8 @@
#include "BLI_path_util.h"
#include <sstream>
namespace blender::asset_system {
const char AssetCatalogPath::SEPARATOR = '/';

View File

@ -21,6 +21,7 @@
*/
#include <fstream>
#include <iostream>
#include <optional>
#include <fcntl.h>

View File

@ -62,7 +62,7 @@ bool BKE_appdir_folder_documents(char *dir) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RES
/**
* Get the user's cache directory, i.e.
* - Linux: `$HOME/.cache/blender/`
* - Windows: `%USERPROFILE%\AppData\Local\Blender Authors\Blender\`
* - Windows: `%USERPROFILE%\AppData\Local\Blender Foundation\Blender\`
* - MacOS: `/Library/Caches/Blender`
*
* \returns True if the path is valid. It doesn't create or checks format

View File

@ -6,11 +6,9 @@
#include <optional>
#include "BLI_color.hh"
#include "BLI_function_ref.hh"
#include "BLI_generic_span.hh"
#include "BLI_generic_virtual_array.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_offset_indices.hh"
#include "BLI_set.hh"

View File

@ -8,12 +8,13 @@
* \ingroup bke
*/
#include <iostream>
#include <iosfwd>
#include <mutex>
#include "BLI_bounds_types.hh"
#include "BLI_function_ref.hh"
#include "BLI_map.hh"
#include "BLI_math_vector_types.hh"
#include "BKE_attribute.hh"

View File

@ -122,6 +122,67 @@ class Drawing : public ::GreasePencilDrawing {
class LayerGroup;
class Layer;
/* Defines the common functions used by #TreeNode, #Layer, and #LayerGroup.
* Note: Because we cannot mix C-style and C++ inheritance (all of these three classes wrap a
* C-struct that already uses "inheritance"), we define and implement these methods on all these
* classes individually. This just means that we can call `layer->name()` directly instead of
* having to write `layer->as_node().name()`. For #Layer and #LayerGroup the calls are just
* forwarded to #TreeNode. */
#define TREENODE_COMMON_METHODS \
StringRefNull name() const; \
void set_name(StringRefNull new_name); \
bool is_visible() const; \
void set_visible(bool visible); \
bool is_locked() const; \
void set_locked(bool locked); \
bool is_editable() const; \
bool is_selected() const; \
void set_selected(bool selected); \
bool use_onion_skinning() const;
/* Implements the forwarding of the methods defined by #TREENODE_COMMON_METHODS. */
#define TREENODE_COMMON_METHODS_FORWARD_IMPL(class_name) \
inline StringRefNull class_name::name() const \
{ \
return this->as_node().name(); \
} \
inline void class_name::set_name(StringRefNull new_name) \
{ \
return this->as_node().set_name(new_name); \
} \
inline bool class_name::is_visible() const \
{ \
return this->as_node().is_visible(); \
} \
inline void class_name::set_visible(const bool visible) \
{ \
this->as_node().set_visible(visible); \
} \
inline bool class_name::is_locked() const \
{ \
return this->as_node().is_locked(); \
} \
inline void class_name::set_locked(const bool locked) \
{ \
this->as_node().set_locked(locked); \
} \
inline bool class_name::is_editable() const \
{ \
return this->as_node().is_editable(); \
} \
inline bool class_name::is_selected() const \
{ \
return this->as_node().is_selected(); \
} \
inline void class_name::set_selected(const bool selected) \
{ \
this->as_node().set_selected(selected); \
} \
inline bool class_name::use_onion_skinning() const \
{ \
return this->as_node().use_onion_skinning(); \
}
/**
* A TreeNode represents one node in the layer tree.
* It can either be a layer or a group. The node has zero children if it is a layer or zero or
@ -135,50 +196,34 @@ class TreeNode : public ::GreasePencilLayerTreeNode {
TreeNode(const TreeNode &other);
public:
/* Define the common functions for #TreeNode. */
TREENODE_COMMON_METHODS;
/**
* \returns true if this node is a LayerGroup.
* \returns true if this node is a #LayerGroup.
*/
bool is_group() const
{
return this->type == GP_LAYER_TREE_GROUP;
}
bool is_group() const;
/**
* \returns true if this node is a #Layer.
*/
bool is_layer() const;
/**
* \returns true if this node is a Layer.
*/
bool is_layer() const
{
return this->type == GP_LAYER_TREE_LEAF;
}
/**
* \returns this tree node as a LayerGroup.
* \note This results in undefined behavior if the node is not a LayerGroup.
*/
const LayerGroup &as_group() const;
/**
* \returns this tree node as a Layer.
* \note This results in undefined behavior if the node is not a Layer.
* \returns this node as a #Layer.
*/
Layer &as_layer();
const Layer &as_layer() const;
/**
* \returns this tree node as a mutable LayerGroup.
* \note This results in undefined behavior if the node is not a LayerGroup.
* \returns this node as a #LayerGroup.
*/
LayerGroup &as_group_for_write();
/**
* \returns this tree node as a mutable Layer.
* \note This results in undefined behavior if the node is not a Layer.
*/
Layer &as_layer_for_write();
LayerGroup &as_group();
const LayerGroup &as_group() const;
/**
* \returns the parent layer group or nullptr for the root group.
*/
LayerGroup *parent_group() const;
TreeNode *parent_node() const;
};
/**
@ -269,36 +314,27 @@ class Layer : public ::GreasePencilLayer {
Layer(const Layer &other);
~Layer();
/**
* \returns the layer name.
*/
StringRefNull name() const;
void set_name(StringRefNull new_name);
/**
* \returns the parent layer group.
*/
LayerGroup &parent_group() const;
public:
/* Define the common functions for #TreeNode. */
TREENODE_COMMON_METHODS;
/**
* \returns the layer as a `TreeNode`.
*/
const TreeNode &as_node() const;
TreeNode &as_node();
/**
* \returns the parent #LayerGroup of this layer.
*/
LayerGroup &parent_group() const;
/**
* \returns the frames mapping.
*/
const Map<FramesMapKey, GreasePencilFrame> &frames() const;
Map<FramesMapKey, GreasePencilFrame> &frames_for_write();
bool is_visible() const;
bool is_locked() const;
bool is_editable() const;
bool is_empty() const;
bool is_selected() const;
bool use_onion_skinning() const;
/**
* Adds a new frame into the layer frames map.
@ -406,12 +442,8 @@ class LayerGroup : public ::GreasePencilLayerTreeGroup {
~LayerGroup();
public:
StringRefNull name() const;
void set_name(StringRefNull new_name);
bool is_visible() const;
bool is_locked() const;
/* Define the common functions for #TreeNode. */
TREENODE_COMMON_METHODS;
/**
* \returns the group as a `TreeNode`.
*/
@ -520,6 +552,53 @@ inline bool Drawing::has_users() const
{
return this->runtime->user_count.load(std::memory_order_relaxed) > 0;
}
inline bool TreeNode::is_group() const
{
return this->type == GP_LAYER_TREE_GROUP;
}
inline bool TreeNode::is_layer() const
{
return this->type == GP_LAYER_TREE_LEAF;
}
inline bool TreeNode::is_visible() const
{
return ((this->flag & GP_LAYER_TREE_NODE_HIDE) == 0) &&
(!this->parent_group() || this->parent_group()->as_node().is_visible());
}
inline void TreeNode::set_visible(const bool visible)
{
SET_FLAG_FROM_TEST(this->flag, !visible, GP_LAYER_TREE_NODE_HIDE);
}
inline bool TreeNode::is_locked() const
{
return ((this->flag & GP_LAYER_TREE_NODE_LOCKED) != 0) ||
(!this->parent_group() || this->parent_group()->as_node().is_locked());
}
inline void TreeNode::set_locked(const bool locked)
{
SET_FLAG_FROM_TEST(this->flag, locked, GP_LAYER_TREE_NODE_LOCKED);
}
inline bool TreeNode::is_editable() const
{
return this->is_visible() && !this->is_locked();
}
inline bool TreeNode::is_selected() const
{
return (this->flag & GP_LAYER_TREE_NODE_SELECT) != 0;
}
inline void TreeNode::set_selected(const bool selected)
{
SET_FLAG_FROM_TEST(this->flag, selected, GP_LAYER_TREE_NODE_SELECT);
}
inline bool TreeNode::use_onion_skinning() const
{
return ((this->flag & GP_LAYER_TREE_NODE_USE_ONION_SKINNING) != 0);
}
inline StringRefNull TreeNode::name() const
{
return this->name_ptr;
}
inline const TreeNode &LayerGroup::as_node() const
{
return *reinterpret_cast<const TreeNode *>(this);
@ -538,20 +617,17 @@ inline TreeNode &Layer::as_node()
return *reinterpret_cast<TreeNode *>(this);
}
inline StringRefNull Layer::name() const
TREENODE_COMMON_METHODS_FORWARD_IMPL(Layer);
inline bool Layer::is_empty() const
{
return this->base.name;
return (this->frames().size() == 0);
}
inline LayerGroup &Layer::parent_group() const
{
return this->base.parent->wrap();
return *this->as_node().parent_group();
}
inline StringRefNull LayerGroup::name() const
{
return this->base.name;
}
TREENODE_COMMON_METHODS_FORWARD_IMPL(LayerGroup);
namespace convert {

View File

@ -755,6 +755,7 @@ bool nodeGroupPoll(const struct bNodeTree *nodetree,
void node_type_base_custom(struct bNodeType *ntype,
const char *idname,
const char *name,
const char *enum_name,
short nclass);
/**

View File

@ -215,7 +215,7 @@ bool BKE_appdir_folder_caches(char *path, const size_t path_maxncpy)
#ifdef WIN32
BLI_path_join(
path, path_maxncpy, caches_root_path, "Blender Authors", "Blender", "Cache", SEP_STR);
path, path_maxncpy, caches_root_path, "Blender Foundation", "Blender", "Cache", SEP_STR);
#elif defined(__APPLE__)
BLI_path_join(path, path_maxncpy, caches_root_path, "Blender", SEP_STR);
#else /* __linux__ */

View File

@ -20,6 +20,8 @@
#include "RNA_access.hh"
#include "RNA_enum_types.hh"
#include <sstream>
namespace blender::bke {
using namespace io::serialize;

View File

@ -160,23 +160,6 @@ bool BKE_blendfile_is_readable(const char *path, ReportList *reports)
/** \name Blend File IO (High Level)
* \{ */
static bool blendfile_or_libraries_versions_atleast(Main *bmain,
const short versionfile,
const short subversionfile)
{
if (!MAIN_VERSION_FILE_ATLEAST(bmain, versionfile, subversionfile)) {
return false;
}
LISTBASE_FOREACH (Library *, library, &bmain->libraries) {
if (!MAIN_VERSION_FILE_ATLEAST(library, versionfile, subversionfile)) {
return false;
}
}
return true;
}
static bool foreach_path_clean_cb(BPathForeachPathData * /*bpath_data*/,
char *path_dst,
size_t path_dst_maxncpy,
@ -887,25 +870,11 @@ static void setup_app_data(bContext *C,
}
#endif
/* FIXME: this version patching should really be part of the file-reading code,
* but we still get too many unrelated data-corruption crashes otherwise... */
if (bmain->versionfile < 250) {
do_versions_ipos_to_animato(bmain);
}
/* NOTE: readfile's `do_versions` does not allow to create new IDs, and only operates on a single
* library at a time. This code needs to operate on the whole Main at once. */
/* NOTE: Check Main version (i.e. current blend file version), AND the versions of all the
* linked libraries. */
if (mode != LOAD_UNDO && !blendfile_or_libraries_versions_atleast(bmain, 302, 1)) {
BKE_lib_override_library_main_proxy_convert(bmain, reports);
/* Currently liboverride code can generate invalid namemap. This is a known issue, requires
* #107847 to be properly fixed. */
BKE_main_namemap_validate_and_fix(bmain);
}
if (mode != LOAD_UNDO && !blendfile_or_libraries_versions_atleast(bmain, 302, 3)) {
BKE_lib_override_library_main_hierarchy_root_ensure(bmain);
if (mode != LOAD_UNDO) {
/* Perform complex versioning that involves adding or removing IDs, and/or needs to operate
* over the whole Main data-base (versioning done in readfile code only operates on a
* per-library basis). */
BLO_read_do_version_after_setup(bmain, reports);
}
bmain->recovered = false;

View File

@ -6,6 +6,8 @@
#include "BKE_compute_contexts.hh"
#include <ostream>
namespace blender::bke {
ModifierComputeContext::ModifierComputeContext(const ComputeContext *parent,

View File

@ -424,7 +424,7 @@ TreeNode::TreeNode()
this->next = this->prev = nullptr;
this->parent = nullptr;
this->name = nullptr;
this->name_ptr = nullptr;
this->flag = 0;
this->color[0] = this->color[1] = this->color[2] = 0;
}
@ -437,19 +437,24 @@ TreeNode::TreeNode(GreasePencilLayerTreeNodeType type) : TreeNode()
TreeNode::TreeNode(GreasePencilLayerTreeNodeType type, StringRefNull name) : TreeNode()
{
this->type = type;
this->name = BLI_strdup(name.c_str());
this->name_ptr = BLI_strdup(name.c_str());
}
TreeNode::TreeNode(const TreeNode &other)
: TreeNode::TreeNode(GreasePencilLayerTreeNodeType(other.type))
{
if (other.name) {
this->name = BLI_strdup(other.name);
if (!other.name().is_empty()) {
this->name_ptr = BLI_strdup(other.name().c_str());
}
this->flag = other.flag;
copy_v3_v3_uchar(this->color, other.color);
}
void TreeNode::set_name(StringRefNull name)
{
this->name_ptr = BLI_strdup(name.c_str());
}
const LayerGroup &TreeNode::as_group() const
{
return *reinterpret_cast<const LayerGroup *>(this);
@ -460,22 +465,24 @@ const Layer &TreeNode::as_layer() const
return *reinterpret_cast<const Layer *>(this);
}
LayerGroup &TreeNode::as_group_for_write()
LayerGroup &TreeNode::as_group()
{
return *reinterpret_cast<LayerGroup *>(this);
}
Layer &TreeNode::as_layer_for_write()
Layer &TreeNode::as_layer()
{
return *reinterpret_cast<Layer *>(this);
}
LayerGroup *TreeNode::parent_group() const
{
if (this->parent) {
return &this->parent->wrap();
}
return nullptr;
return (this->parent) ? &this->parent->wrap() : nullptr;
}
TreeNode *TreeNode::parent_node() const
{
return this->parent_group() ? &this->parent->wrap().as_node() : nullptr;
}
LayerMask::LayerMask()
@ -522,7 +529,7 @@ Layer::Layer()
Layer::Layer(StringRefNull name) : Layer()
{
this->base.name = BLI_strdup(name.c_str());
this->base.name_ptr = BLI_strdup(name.c_str());
}
Layer::Layer(const Layer &other) : Layer()
@ -543,7 +550,7 @@ Layer::Layer(const Layer &other) : Layer()
Layer::~Layer()
{
MEM_SAFE_FREE(this->base.name);
MEM_SAFE_FREE(this->base.name_ptr);
MEM_SAFE_FREE(this->frames_storage.keys);
MEM_SAFE_FREE(this->frames_storage.values);
@ -556,11 +563,6 @@ Layer::~Layer()
this->runtime = nullptr;
}
void Layer::set_name(StringRefNull new_name)
{
this->base.name = BLI_strdup(new_name.c_str());
}
const Map<int, GreasePencilFrame> &Layer::frames() const
{
return this->runtime->frames_;
@ -571,36 +573,6 @@ Map<int, GreasePencilFrame> &Layer::frames_for_write()
return this->runtime->frames_;
}
bool Layer::is_visible() const
{
return this->parent_group().is_visible() && (this->base.flag & GP_LAYER_TREE_NODE_HIDE) == 0;
}
bool Layer::is_locked() const
{
return this->parent_group().is_locked() || (this->base.flag & GP_LAYER_TREE_NODE_LOCKED) != 0;
}
bool Layer::is_editable() const
{
return !this->is_locked() && this->is_visible();
}
bool Layer::is_empty() const
{
return (this->frames().size() == 0);
}
bool Layer::is_selected() const
{
return ((this->base.flag & GP_LAYER_TREE_NODE_SELECT) != 0);
}
bool Layer::use_onion_skinning() const
{
return ((this->base.flag & GP_LAYER_TREE_NODE_USE_ONION_SKINNING) != 0);
}
Layer::SortedKeysIterator Layer::remove_leading_null_frames_in_range(
Layer::SortedKeysIterator begin, Layer::SortedKeysIterator end)
{
@ -795,7 +767,7 @@ LayerGroup::LayerGroup()
LayerGroup::LayerGroup(StringRefNull name) : LayerGroup()
{
this->base.name = BLI_strdup(name.c_str());
this->base.name_ptr = BLI_strdup(name.c_str());
}
LayerGroup::LayerGroup(const LayerGroup &other) : LayerGroup()
@ -822,7 +794,7 @@ LayerGroup::LayerGroup(const LayerGroup &other) : LayerGroup()
LayerGroup::~LayerGroup()
{
MEM_SAFE_FREE(this->base.name);
MEM_SAFE_FREE(this->base.name_ptr);
LISTBASE_FOREACH_MUTABLE (GreasePencilLayerTreeNode *, child, &this->children) {
switch (child->type) {
@ -843,29 +815,6 @@ 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);
@ -1058,10 +1007,10 @@ void LayerGroup::print_nodes(StringRefNull header) const
std::cout << " ";
}
if (node->is_layer()) {
std::cout << StringRefNull(node->name);
std::cout << node->name();
}
else if (node->is_group()) {
std::cout << StringRefNull(node->name) << ": ";
std::cout << node->name() << ": ";
LISTBASE_FOREACH_BACKWARD (GreasePencilLayerTreeNode *, child_, &node->as_group().children) {
TreeNode *child = reinterpret_cast<TreeNode *>(child_);
next_node.push(std::make_pair(indent + 1, child));
@ -1084,18 +1033,18 @@ void LayerGroup::ensure_nodes_cache() const
this->runtime->nodes_cache_.append(node);
switch (node->type) {
case GP_LAYER_TREE_LEAF: {
this->runtime->layer_cache_.append(&node->as_layer_for_write());
this->runtime->layer_cache_.append(&node->as_layer());
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->layer_group_cache_.append(&node->as_group());
for (TreeNode *child : node->as_group().nodes_for_write()) {
this->runtime->nodes_cache_.append(child);
if (child->is_layer()) {
this->runtime->layer_cache_.append(&child->as_layer_for_write());
this->runtime->layer_cache_.append(&child->as_layer());
}
else if (child->is_group()) {
this->runtime->layer_group_cache_.append(&child->as_group_for_write());
this->runtime->layer_group_cache_.append(&child->as_group());
}
}
break;
@ -1853,12 +1802,12 @@ bool GreasePencil::is_layer_active(const blender::bke::greasepencil::Layer *laye
return this->get_active_layer() == layer;
}
static blender::VectorSet<blender::StringRefNull> get_node_names(GreasePencil &grease_pencil)
static blender::VectorSet<blender::StringRefNull> get_node_names(const GreasePencil &grease_pencil)
{
using namespace blender;
VectorSet<StringRefNull> names;
for (const blender::bke::greasepencil::TreeNode *node : grease_pencil.nodes()) {
names.add(node->name);
names.add(node->name());
}
return names;
}
@ -1870,23 +1819,41 @@ static bool check_unique_node_cb(void *arg, const char *name)
return names.contains(name);
}
static bool unique_layer_name(VectorSet<blender::StringRefNull> &names, char *name)
static bool unique_node_name_ex(VectorSet<blender::StringRefNull> &names,
const char *default_name,
char *name)
{
return BLI_uniquename_cb(check_unique_node_cb, &names, "GP_Layer", '.', name, MAX_NAME);
return BLI_uniquename_cb(check_unique_node_cb, &names, default_name, '.', name, MAX_NAME);
}
static bool unique_layer_group_name(VectorSet<blender::StringRefNull> &names, char *name)
static std::string unique_node_name(const GreasePencil &grease_pencil,
const char *default_name,
blender::StringRefNull name)
{
return BLI_uniquename_cb(check_unique_node_cb, &names, "GP_Group", '.', name, MAX_NAME);
using namespace blender;
std::string unique_name(name.c_str());
VectorSet<StringRefNull> names = get_node_names(grease_pencil);
unique_node_name_ex(names, default_name, unique_name.data());
return unique_name;
}
static std::string unique_layer_name(const GreasePencil &grease_pencil,
blender::StringRefNull name)
{
return unique_node_name(grease_pencil, "GP_Layer", name);
}
static std::string unique_layer_group_name(const GreasePencil &grease_pencil,
blender::StringRefNull name)
{
return unique_node_name(grease_pencil, "GP_Group", name);
}
blender::bke::greasepencil::Layer &GreasePencil::add_layer(
blender::bke::greasepencil::LayerGroup &group, const blender::StringRefNull name)
{
using namespace blender;
VectorSet<StringRefNull> names = get_node_names(*this);
std::string unique_name(name.c_str());
unique_layer_name(names, unique_name.data());
std::string unique_name = unique_layer_name(*this, name);
return group.add_layer(unique_name);
}
@ -1896,9 +1863,7 @@ blender::bke::greasepencil::Layer &GreasePencil::add_layer_after(
const blender::StringRefNull name)
{
using namespace blender;
VectorSet<StringRefNull> names = get_node_names(*this);
std::string unique_name(name.c_str());
unique_layer_name(names, unique_name.data());
std::string unique_name = unique_layer_name(*this, name);
return group.add_layer_after(unique_name, link);
}
@ -1911,9 +1876,7 @@ blender::bke::greasepencil::LayerGroup &GreasePencil::add_layer_group(
blender::bke::greasepencil::LayerGroup &group, const blender::StringRefNull name)
{
using namespace blender;
VectorSet<StringRefNull> names = get_node_names(*this);
std::string unique_name(name.c_str());
unique_layer_group_name(names, unique_name.data());
std::string unique_name = unique_layer_group_name(*this, name);
return group.add_group(unique_name);
}
@ -1923,9 +1886,7 @@ blender::bke::greasepencil::LayerGroup &GreasePencil::add_layer_group_after(
const blender::StringRefNull name)
{
using namespace blender;
VectorSet<StringRefNull> names = get_node_names(*this);
std::string unique_name(name.c_str());
unique_layer_group_name(names, unique_name.data());
std::string unique_name = unique_layer_group_name(*this, name);
return group.add_group_after(unique_name, node);
}
@ -1959,30 +1920,15 @@ blender::bke::greasepencil::LayerGroup *GreasePencil::find_group_by_name(
return this->root_group().find_group_by_name(name);
}
void GreasePencil::rename_layer(blender::bke::greasepencil::Layer &layer,
blender::StringRefNull new_name)
void GreasePencil::rename_node(blender::bke::greasepencil::TreeNode &node,
blender::StringRefNull new_name)
{
using namespace blender;
if (layer.name() == new_name) {
if (node.name() == new_name) {
return;
}
VectorSet<StringRefNull> names = get_node_names(*this);
std::string unique_name(new_name.c_str());
unique_layer_name(names, unique_name.data());
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);
node.set_name(node.is_layer() ? unique_layer_name(*this, new_name) :
unique_layer_group_name(*this, new_name));
}
void GreasePencil::remove_layer(blender::bke::greasepencil::Layer &layer)
@ -2120,7 +2066,7 @@ static void read_layer(BlendDataReader *reader,
GreasePencilLayer *node,
GreasePencilLayerTreeGroup *parent)
{
BLO_read_data_address(reader, &node->base.name);
BLO_read_data_address(reader, &node->base.name_ptr);
node->base.parent = parent;
/* Read frames storage. */
@ -2145,7 +2091,7 @@ static void read_layer_tree_group(BlendDataReader *reader,
GreasePencilLayerTreeGroup *node,
GreasePencilLayerTreeGroup *parent)
{
BLO_read_data_address(reader, &node->base.name);
BLO_read_data_address(reader, &node->base.name_ptr);
node->base.parent = parent;
/* Read list of children. */
BLO_read_list(reader, &node->children);
@ -2209,7 +2155,7 @@ static void write_layer(BlendWriter *writer, GreasePencilLayer *node)
}
BLO_write_struct(writer, GreasePencilLayer, node);
BLO_write_string(writer, node->base.name);
BLO_write_string(writer, node->base.name_ptr);
BLO_write_int32_array(writer, node->frames_storage.num, node->frames_storage.keys);
BLO_write_struct_array(
@ -2224,7 +2170,7 @@ static void write_layer(BlendWriter *writer, GreasePencilLayer *node)
static void write_layer_tree_group(BlendWriter *writer, GreasePencilLayerTreeGroup *node)
{
BLO_write_struct(writer, GreasePencilLayerTreeGroup, node);
BLO_write_string(writer, node->base.name);
BLO_write_string(writer, node->base.name_ptr);
LISTBASE_FOREACH (GreasePencilLayerTreeNode *, child, &node->children) {
switch (child->type) {
case GP_LAYER_TREE_LEAF: {

View File

@ -190,11 +190,9 @@ void legacy_gpencil_to_grease_pencil(Main &bmain, GreasePencil &grease_pencil, b
grease_pencil.root_group(), StringRefNull(gpl->info, BLI_strnlen(gpl->info, 128)));
/* Flags. */
SET_FLAG_FROM_TEST(new_layer.base.flag, (gpl->flag & GP_LAYER_HIDE), GP_LAYER_TREE_NODE_HIDE);
SET_FLAG_FROM_TEST(
new_layer.base.flag, (gpl->flag & GP_LAYER_LOCKED), GP_LAYER_TREE_NODE_LOCKED);
SET_FLAG_FROM_TEST(
new_layer.base.flag, (gpl->flag & GP_LAYER_SELECT), GP_LAYER_TREE_NODE_SELECT);
new_layer.set_visible((gpl->flag & GP_LAYER_HIDE) == 0);
new_layer.set_locked((gpl->flag & GP_LAYER_LOCKED) != 0);
new_layer.set_selected((gpl->flag & GP_LAYER_SELECT) != 0);
SET_FLAG_FROM_TEST(
new_layer.base.flag, (gpl->flag & GP_LAYER_FRAMELOCK), GP_LAYER_TREE_NODE_MUTE);
SET_FLAG_FROM_TEST(

View File

@ -132,7 +132,7 @@ TEST(greasepencil, layer_tree_pre_order_iteration)
Span<const TreeNode *> children = ex.root.nodes();
for (const int i : children.index_range()) {
const TreeNode &child = *children[i];
EXPECT_STREQ(child.name, ex.names[i].data());
EXPECT_STREQ(child.name().data(), ex.names[i].data());
}
}

View File

@ -2161,15 +2161,15 @@ void do_versions_ipos_to_animato(Main *bmain)
/* check PoseChannels for constraints with local data */
if (ob->pose) {
/* Verify if there's AnimData block */
BKE_animdata_ensure_id(id);
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
/* if constraint has own IPO, convert add these to Object
* (NOTE: they're most likely to be drivers too)
*/
if (con->ipo) {
/* Verify if there's AnimData block */
BKE_animdata_ensure_id(id);
/* although this was the constraint's local IPO, we still need to provide pchan + con
* so that drivers can be added properly...
*/
@ -2204,9 +2204,6 @@ void do_versions_ipos_to_animato(Main *bmain)
/* check constraint channels - we need to remove them anyway... */
if (ob->constraintChannels.first) {
/* Verify if there's AnimData block */
BKE_animdata_ensure_id(id);
for (conchan = static_cast<bConstraintChannel *>(ob->constraintChannels.first); conchan;
conchan = conchann)
{
@ -2215,6 +2212,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* convert Constraint Channel's IPO data */
if (conchan->ipo) {
/* Verify if there's AnimData block */
BKE_animdata_ensure_id(id);
ipo_to_animdata(bmain, id, conchan->ipo, nullptr, conchan->name, nullptr);
id_us_min(&conchan->ipo->id);
conchan->ipo = nullptr;

View File

@ -8,6 +8,7 @@
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>

View File

@ -4301,12 +4301,14 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh
void node_type_base_custom(bNodeType *ntype,
const char *idname,
const char *name,
const char *enum_name,
const short nclass)
{
STRNCPY(ntype->idname, idname);
ntype->type = NODE_CUSTOM;
STRNCPY(ntype->ui_name, name);
ntype->nclass = nclass;
ntype->enum_name_legacy = enum_name;
blender::bke::node_type_base_defaults(ntype);
}

View File

@ -13,6 +13,8 @@
#include "BLI_resource_scope.hh"
#include <sstream>
namespace blender::bke::anonymous_attribute_inferencing {
namespace aal = nodes::aal;
using nodes::NodeDeclaration;

View File

@ -17,6 +17,7 @@
#include "BLI_string_utf8.h"
#include "BLI_array.hh"
#include "BLI_math_color.hh"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_matrix.hh"

View File

@ -26,6 +26,7 @@
#include "BLI_bitmap.h"
#include "BLI_hash.h"
#include "BLI_listbase.h"
#include "BLI_math_color.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.h"
#include "BLI_string_utf8.h"

View File

@ -14,6 +14,8 @@
#include "IMB_imbuf_types.h"
#include <sstream>
namespace blender::bke::paint::canvas {
static TexPaintSlot *get_active_slot(Object *ob)
{

View File

@ -8,7 +8,9 @@
#include "pbvh_uv_islands.hh"
#include <iostream>
#include <optional>
#include <sstream>
namespace blender::bke::pbvh::uv_islands {

View File

@ -790,17 +790,19 @@ static void scene_foreach_toolsettings(LibraryForeachIDData *data,
#undef BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_IDSUPER
#undef BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_FUNCTION_CALL
static void scene_foreach_layer_collection(LibraryForeachIDData *data, ListBase *lb)
static void scene_foreach_layer_collection(LibraryForeachIDData *data,
ListBase *lb,
const bool is_master)
{
const int data_flags = BKE_lib_query_foreachid_process_flags_get(data);
LISTBASE_FOREACH (LayerCollection *, lc, lb) {
const int cb_flag = (lc->collection != nullptr &&
(data_flags & IDWALK_NO_ORIG_POINTERS_ACCESS) == 0 &&
(lc->collection->id.flag & LIB_EMBEDDED_DATA) != 0) ?
IDWALK_CB_EMBEDDED_NOT_OWNING :
IDWALK_CB_NOP;
if ((data_flags & IDWALK_NO_ORIG_POINTERS_ACCESS) == 0 && lc->collection != nullptr) {
BLI_assert(is_master == ((lc->collection->id.flag & LIB_EMBEDDED_DATA) != 0));
}
const int cb_flag = is_master ? IDWALK_CB_EMBEDDED_NOT_OWNING : IDWALK_CB_NOP;
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, lc->collection, cb_flag | IDWALK_CB_DIRECT_WEAK_LINK);
scene_foreach_layer_collection(data, &lc->layer_collections);
scene_foreach_layer_collection(data, &lc->layer_collections, false);
}
}
@ -886,22 +888,15 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
}
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(
data, scene_foreach_layer_collection(data, &view_layer->layer_collections));
data, scene_foreach_layer_collection(data, &view_layer->layer_collections, true));
LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
if (fmc->script) {
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, fmc->script, IDWALK_CB_NOP);
}
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, fmc->script, IDWALK_CB_NOP);
}
LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
if (fls->group) {
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, fls->group, IDWALK_CB_USER);
}
if (fls->linestyle) {
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, fls->linestyle, IDWALK_CB_USER);
}
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, fls->group, IDWALK_CB_USER);
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, fls->linestyle, IDWALK_CB_USER);
}
}

View File

@ -25,6 +25,8 @@
#include "RNA_access.hh"
#include "RNA_enum_types.hh"
#include <sstream>
namespace blender::bke::sim {
/**

View File

@ -20,7 +20,7 @@
#include "BLI_index_range.hh"
#include "BLI_utildefines.h"
#include <ostream>
#include <iosfwd>
namespace blender::bits {
@ -234,15 +234,8 @@ class MutableBitRef {
}
};
inline std::ostream &operator<<(std::ostream &stream, const BitRef &bit)
{
return stream << (bit ? "1" : "0");
}
inline std::ostream &operator<<(std::ostream &stream, const MutableBitRef &bit)
{
return stream << BitRef(bit);
}
std::ostream &operator<<(std::ostream &stream, const BitRef &bit);
std::ostream &operator<<(std::ostream &stream, const MutableBitRef &bit);
} // namespace blender::bits

View File

@ -4,7 +4,7 @@
#pragma once
#include <iostream>
#include <ostream>
#include "BLI_math_color.h"

View File

@ -637,22 +637,9 @@ class CPPType : NonCopyable, NonMovable {
print_(value, ss);
}
std::string to_string(const void *value) const
{
std::stringstream ss;
this->print(value, ss);
return ss.str();
}
std::string to_string(const void *value) const;
void print_or_default(const void *value, std::stringstream &ss, StringRef default_value) const
{
if (this->is_printable()) {
this->print(value, ss);
}
else {
ss << default_value;
}
}
void print_or_default(const void *value, std::stringstream &ss, StringRef default_value) const;
bool is_equal(const void *a, const void *b) const
{

View File

@ -10,6 +10,7 @@
#include "BLI_cpp_type.hh"
#include "BLI_utildefines.h"
#include <sstream>
namespace blender::cpp_type_util {

View File

@ -18,8 +18,8 @@
#include "BLI_dot_export_attribute_enums.hh"
#include <iosfwd>
#include <optional>
#include <sstream>
namespace blender::dot {

View File

@ -303,26 +303,7 @@ class HashTableStats {
removed_load_factor_ = (float)removed_amount_ / (float)capacity_;
}
void print(StringRef name = "")
{
std::cout << "Hash Table Stats: " << name << "\n";
std::cout << " Address: " << address_ << "\n";
std::cout << " Total Slots: " << capacity_ << "\n";
std::cout << " Occupied Slots: " << size_ << " (" << load_factor_ * 100.0f << " %)\n";
std::cout << " Removed Slots: " << removed_amount_ << " (" << removed_load_factor_ * 100.0f
<< " %)\n";
char memory_size_str[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE];
BLI_str_format_byte_unit(memory_size_str, size_in_bytes_, true);
std::cout << " Size: ~" << memory_size_str << "\n";
std::cout << " Size per Slot: " << size_per_element_ << " bytes\n";
std::cout << " Average Collisions: " << average_collisions_ << "\n";
for (int64_t collision_count : keys_by_collision_count_.index_range()) {
std::cout << " " << collision_count
<< " Collisions: " << keys_by_collision_count_[collision_count] << "\n";
}
}
void print(StringRef name = "") const;
};
/** \} */

View File

@ -38,9 +38,8 @@
*/
#include <algorithm>
#include <atomic>
#include <cmath>
#include <iostream>
#include <iosfwd>
#include "BLI_utildefines.h"
@ -324,11 +323,7 @@ class IndexRange {
return IndexRange(start_ + n, size_);
}
friend std::ostream &operator<<(std::ostream &stream, IndexRange range)
{
stream << "[" << range.start() << ", " << range.one_after_last() << ")";
return stream;
}
friend std::ostream &operator<<(std::ostream &stream, IndexRange range);
};
struct AlignedIndexRanges {

View File

@ -7,6 +7,8 @@
#include "BLI_array.hh"
#include "BLI_dot_export.hh"
#include <sstream>
namespace blender {
/**

View File

@ -10,9 +10,6 @@
#include "BLI_index_mask.hh"
#include "BLI_math_base.hh"
#include "BLI_math_color.hh"
#include "BLI_math_quaternion.hh"
#include "BLI_math_vector.hh"
namespace blender::length_parameterize {

View File

@ -17,7 +17,7 @@
* This design allows some function overloads to be more efficient with certain types.
*/
#include <iostream>
#include <ostream>
#include "BLI_math_base.hh"

View File

@ -20,7 +20,7 @@
* the fastest and more correct option.
*/
#include <iostream>
#include <ostream>
#include "BLI_math_angle_types.hh"
#include "BLI_math_base.hh"

View File

@ -23,7 +23,7 @@
* - Curve Tangent-Space: X-left, Y-up, Z-forward
*/
#include <iostream>
#include <iosfwd>
#include "BLI_math_base.hh"
#include "BLI_math_vector_types.hh"
@ -88,20 +88,7 @@ class Axis {
/** Avoid hell. */
explicit operator bool() const = delete;
friend std::ostream &operator<<(std::ostream &stream, const Axis axis)
{
switch (axis.axis_) {
default:
BLI_assert_unreachable();
return stream << "Invalid Axis";
case Value::X:
return stream << 'X';
case Value::Y:
return stream << 'Y';
case Value::Z:
return stream << 'Z';
}
}
friend std::ostream &operator<<(std::ostream &stream, const Axis axis);
};
/**
@ -190,21 +177,7 @@ class AxisSigned {
/** Avoid hell. */
explicit operator bool() const = delete;
friend std::ostream &operator<<(std::ostream &stream, const AxisSigned axis)
{
switch (axis.axis_) {
default:
BLI_assert_unreachable();
return stream << "Invalid AxisSigned";
case Value::X_POS:
case Value::Y_POS:
case Value::Z_POS:
case Value::X_NEG:
case Value::Y_NEG:
case Value::Z_NEG:
return stream << axis.axis() << (axis.sign() == -1 ? '-' : '+');
}
}
friend std::ostream &operator<<(std::ostream &stream, const AxisSigned axis);
};
constexpr static bool operator<=(const Axis::Value a, const Axis::Value b)
@ -417,10 +390,7 @@ struct CartesianBasis {
return axes.z;
}
friend std::ostream &operator<<(std::ostream &stream, const CartesianBasis &rot)
{
return stream << "CartesianBasis" << rot.axes;
}
friend std::ostream &operator<<(std::ostream &stream, const CartesianBasis &rot);
};
/**

View File

@ -26,7 +26,7 @@
* eg: `Euler3 my_euler(EulerOrder::XYZ); my_euler = my_quaternion:`
*/
#include <iostream>
#include <ostream>
#include "BLI_math_angle_types.hh"
#include "BLI_math_base.hh"

View File

@ -257,6 +257,7 @@ template<typename MatT, typename VectorT>
* Extract euler rotation from transform matrix.
* \return the rotation with the smallest values from the potential candidates.
*/
template<typename T> [[nodiscard]] inline AngleRadianBase<T> to_angle(const MatBase<T, 2, 2> &mat);
template<typename T> [[nodiscard]] inline EulerXYZBase<T> to_euler(const MatBase<T, 3, 3> &mat);
template<typename T> [[nodiscard]] inline EulerXYZBase<T> to_euler(const MatBase<T, 4, 4> &mat);
template<typename T>
@ -316,6 +317,15 @@ template<bool AllowNegativeScale = false, typename T>
* Rotation and scale values will be flipped if it is negative.
* This is a costly operation so it is disabled by default.
*/
template<bool AllowNegativeScale = false, typename T>
inline void to_rot_scale(const MatBase<T, 2, 2> &mat,
AngleRadianBase<T> &r_rotation,
VecBase<T, 2> &r_scale);
template<bool AllowNegativeScale = false, typename T>
inline void to_loc_rot_scale(const MatBase<T, 3, 3> &mat,
VecBase<T, 2> &r_location,
AngleRadianBase<T> &r_rotation,
VecBase<T, 2> &r_scale);
template<bool AllowNegativeScale = false, typename T, typename RotationT>
inline void to_rot_scale(const MatBase<T, 3, 3> &mat,
RotationT &r_rotation,
@ -705,6 +715,12 @@ template<typename T, int NumCol, int NumRow, typename VectorT>
namespace detail {
template<typename T> AngleRadianBase<T> normalized_to_angle(const MatBase<T, 2, 2> &mat)
{
BLI_assert(math::is_unit_scale(mat));
return AngleRadianBase(mat[0][0], mat[0][1]);
}
template<typename T>
void normalized_to_eul2(const MatBase<T, 3, 3> &mat, EulerXYZBase<T> &eul1, EulerXYZBase<T> &eul2)
{
@ -1070,6 +1086,11 @@ extern template MatBase<float, 4, 4> from_rotation(const AxisAngleCartesian &rot
} // namespace detail
template<typename T> [[nodiscard]] inline AngleRadianBase<T> to_angle(const MatBase<T, 2, 2> &mat)
{
return detail::normalized_to_angle(mat);
}
template<typename T>
[[nodiscard]] inline Euler3Base<T> to_euler(const MatBase<T, 3, 3> &mat, EulerOrder order)
{
@ -1188,6 +1209,12 @@ template<bool AllowNegativeScale, typename T>
/* Implementation details. Use `to_euler` and `to_quaternion` instead. */
namespace detail {
template<typename T>
inline void to_rotation(const MatBase<T, 2, 2> &mat, AngleRadianBase<T> &r_rotation)
{
r_rotation = to_angle<T>(mat);
}
template<typename T>
inline void to_rotation(const MatBase<T, 3, 3> &mat, QuaternionBase<T> &r_rotation)
{
@ -1208,6 +1235,31 @@ inline void to_rotation(const MatBase<T, 3, 3> &mat, Euler3Base<T> &r_rotation)
} // namespace detail
template<bool AllowNegativeScale, typename T>
inline void to_rot_scale(const MatBase<T, 2, 2> &mat,
AngleRadianBase<T> &r_rotation,
VecBase<T, 2> &r_scale)
{
MatBase<T, 2, 2> normalized_mat = normalize_and_get_size(mat, r_scale);
if constexpr (AllowNegativeScale) {
if (UNLIKELY(is_negative(normalized_mat))) {
normalized_mat = -normalized_mat;
r_scale = -r_scale;
}
}
detail::to_rotation<T>(normalized_mat, r_rotation);
}
template<bool AllowNegativeScale, typename T>
inline void to_loc_rot_scale(const MatBase<T, 3, 3> &mat,
VecBase<T, 2> &r_location,
AngleRadianBase<T> &r_rotation,
VecBase<T, 2> &r_scale)
{
r_location = mat.location();
to_rot_scale<AllowNegativeScale>(MatBase<T, 2, 2>(mat), r_rotation, r_scale);
}
template<bool AllowNegativeScale, typename T, typename RotationT>
inline void to_rot_scale(const MatBase<T, 3, 3> &mat,
RotationT &r_rotation,

View File

@ -33,7 +33,7 @@
#include <array>
#include <cmath>
#include <iostream>
#include <ostream>
#include <type_traits>
#include "BLI_math_vector_types.hh"

View File

@ -8,7 +8,7 @@
* \ingroup bli
*/
#include <iostream>
#include <ostream>
#include "BLI_math_angle_types.hh"
#include "BLI_math_base.hh"

View File

@ -10,7 +10,7 @@
#include <array>
#include <cmath>
#include <iostream>
#include <ostream>
#include <type_traits>
#include "BLI_utildefines.h"

View File

@ -13,7 +13,7 @@
#ifdef WITH_GMP
# include <iostream>
# include <iosfwd>
# include "BLI_array.hh"
# include "BLI_index_range.hh"

View File

@ -59,7 +59,7 @@
* `serialize`/`deserialize` methods should be implemented.
*/
#include <ostream>
#include <iosfwd>
#include "BLI_map.hh"
#include "BLI_string_ref.hh"

View File

@ -58,7 +58,6 @@
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>
@ -449,29 +448,6 @@ template<typename T> class Span {
{
return !(a == b);
}
/**
* A debug utility to print the content of the Span. Every element will be printed on a
* separate line using the given callback.
*/
template<typename PrintLineF> void print_as_lines(std::string name, PrintLineF print_line) const
{
std::cout << "Span: " << name << " \tSize:" << size_ << '\n';
for (const T &value : *this) {
std::cout << " ";
print_line(value);
std::cout << '\n';
}
}
/**
* A debug utility to print the content of the span. Every element be printed on a separate
* line.
*/
void print_as_lines(std::string name) const
{
this->print_as_lines(name, [](const T &value) { std::cout << value; });
}
};
/**

View File

@ -32,7 +32,6 @@
*/
#include <cstring>
#include <sstream>
#include <string>
#include <string_view>
@ -571,17 +570,8 @@ constexpr StringRef::StringRef(std::string_view view)
/** \name Operator Overloads
* \{ */
inline std::ostream &operator<<(std::ostream &stream, StringRef ref)
{
stream << std::string(ref);
return stream;
}
inline std::ostream &operator<<(std::ostream &stream, StringRefNull ref)
{
stream << std::string(ref.data(), size_t(ref.size()));
return stream;
}
std::ostream &operator<<(std::ostream &stream, StringRef ref);
std::ostream &operator<<(std::ostream &stream, StringRefNull ref);
/**
* Adding two #StringRefs will allocate an std::string.

View File

@ -57,7 +57,8 @@ bool BLI_uuid_parse_string(bUUID *uuid, const char *buffer) ATTR_NONNULL();
}
# include <initializer_list>
# include <ostream>
# include <iosfwd>
# include <string>
/** Output the UUID as formatted ASCII string, see #BLI_uuid_format(). */
std::ostream &operator<<(std::ostream &stream, bUUID uuid);

View File

@ -27,7 +27,6 @@
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <memory>
#include "BLI_allocator.hh"
@ -36,7 +35,6 @@
#include "BLI_math_base.h"
#include "BLI_memory_utils.hh"
#include "BLI_span.hh"
#include "BLI_string.h"
#include "BLI_string_ref.hh"
#include "BLI_utildefines.h"
@ -44,6 +42,15 @@
namespace blender {
namespace internal {
void vector_print_stats(StringRef name,
void *address,
int64_t size,
int64_t capacity,
int64_t inlineCapacity,
int64_t memorySize);
}
template<
/**
* Type of the values stored in this vector. It has to be movable.
@ -978,15 +985,8 @@ class Vector {
*/
void print_stats(StringRef name = "") const
{
std::cout << "Vector Stats: " << name << "\n";
std::cout << " Address: " << this << "\n";
std::cout << " Elements: " << this->size() << "\n";
std::cout << " Capacity: " << (capacity_end_ - begin_) << "\n";
std::cout << " Inline Capacity: " << InlineBufferCapacity << "\n";
char memory_size_str[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE];
BLI_str_format_byte_unit(memory_size_str, sizeof(*this), true);
std::cout << " Size on Stack: " << memory_size_str << "\n";
internal::vector_print_stats(
name, this, this->size(), capacity_end_ - begin_, InlineBufferCapacity, sizeof(*this));
}
private:

View File

@ -1071,6 +1071,10 @@ template<typename T> class VArraySpan final : public Span<T> {
}
};
namespace internal {
void print_mutable_varray_span_warning();
}
/**
* Same as #VArraySpan, but for a mutable span.
* The important thing to note is that when changing this span, the results might not be
@ -1141,7 +1145,7 @@ template<typename T> class MutableVArraySpan final : public MutableSpan<T> {
if (varray_) {
if (show_not_saved_warning_) {
if (!save_has_been_called_) {
std::cout << "Warning: Call `save()` to make sure that changes persist in all cases.\n";
internal::print_mutable_varray_span_warning();
}
}
}

View File

@ -48,6 +48,7 @@ set(SRC
intern/array_utils.cc
intern/astar.c
intern/atomic_disjoint_set.cc
intern/bit_ref.cc
intern/bit_span.cc
intern/bitmap.c
intern/bitmap_draw_2d.c
@ -56,6 +57,7 @@ set(SRC
intern/cache_mutex.cc
intern/compute_context.cc
intern/convexhull_2d.c
intern/cpp_type.cc
intern/cpp_types.cc
intern/delaunay_2d.cc
intern/dot_export.cc
@ -78,8 +80,10 @@ set(SRC
intern/hash_md5.c
intern/hash_mm2a.c
intern/hash_mm3.c
intern/hash_tables.cc
intern/implicit_sharing.cc
intern/index_mask.cc
intern/index_range.cc
intern/jitter_2d.c
intern/kdtree_1d.c
intern/kdtree_2d.c
@ -92,6 +96,7 @@ set(SRC
intern/math_base.c
intern/math_base_inline.c
intern/math_base_safe_inline.c
intern/math_basis_types.cc
intern/math_bits_inline.c
intern/math_boolean.cc
intern/math_color.c
@ -135,6 +140,7 @@ set(SRC
intern/storage.c
intern/string.c
intern/string_cursor_utf8.c
intern/string_ref.cc
intern/string_search.cc
intern/string_utf8.c
intern/string_utils.c
@ -151,6 +157,8 @@ set(SRC
intern/timeit.cc
intern/uuid.cc
intern/uvproject.c
intern/vector.cc
intern/virtual_array.cc
intern/voronoi_2d.c
intern/voxel.c
intern/winstuff.c

View File

@ -4,6 +4,8 @@
#include "BLI_color.hh"
#include <ostream>
namespace blender {
std::ostream &operator<<(std::ostream &stream, const eAlpha &space)
@ -40,4 +42,23 @@ std::ostream &operator<<(std::ostream &stream, const eSpace &space)
return stream;
}
template<typename ChannelStorageType, eSpace Space, eAlpha Alpha>
std::ostream &operator<<(std::ostream &stream,
const ColorRGBA<ChannelStorageType, Space, Alpha> &c)
{
stream << Space << Alpha << "(" << c.r << ", " << c.g << ", " << c.b << ", " << c.a << ")";
return stream;
}
template std::ostream &operator<<(
std::ostream &stream, const ColorRGBA<float, eSpace::SceneLinear, eAlpha::Premultiplied> &c);
template std::ostream &operator<<(
std::ostream &stream, const ColorRGBA<float, eSpace::SceneLinear, eAlpha::Straight> &c);
template std::ostream &operator<<(
std::ostream &stream,
const ColorRGBA<uint8_t, eSpace::SceneLinearByteEncoded, eAlpha::Premultiplied> &c);
template std::ostream &operator<<(
std::ostream &stream,
const ColorRGBA<uint8_t, eSpace::SceneLinearByteEncoded, eAlpha::Straight> &c);
} // namespace blender

View File

@ -0,0 +1,21 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_bit_ref.hh"
#include <ostream>
namespace blender::bits {
std::ostream &operator<<(std::ostream &stream, const BitRef &bit)
{
return stream << (bit ? '1' : '0');
}
std::ostream &operator<<(std::ostream &stream, const MutableBitRef &bit)
{
return stream << BitRef(bit);
}
} // namespace blender::bits

View File

@ -5,6 +5,8 @@
#include "BLI_bit_span.hh"
#include "BLI_bit_span_ops.hh"
#include <ostream>
namespace blender::bits {
void MutableBitSpan::set_all()

View File

@ -4,6 +4,7 @@
#include "BLI_compute_context.hh"
#include "BLI_hash_md5.h"
#include <sstream>
namespace blender {

View File

@ -0,0 +1,30 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_cpp_type.hh"
#include <sstream>
namespace blender {
std::string CPPType::to_string(const void *value) const
{
std::stringstream ss;
this->print(value, ss);
return ss.str();
}
void CPPType::print_or_default(const void *value,
std::stringstream &ss,
StringRef default_value) const
{
if (this->is_printable()) {
this->print(value, ss);
}
else {
ss << default_value;
}
}
} // namespace blender

View File

@ -6,6 +6,8 @@
#include "BLI_dot_export.hh"
#include <sstream>
namespace blender::dot {
/* Graph Building

View File

@ -0,0 +1,29 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_hash_tables.hh"
#include "BLI_string.h"
#include <iostream>
void blender::HashTableStats::print(StringRef name) const
{
std::cout << "Hash Table Stats: " << name << "\n";
std::cout << " Address: " << address_ << "\n";
std::cout << " Total Slots: " << capacity_ << "\n";
std::cout << " Occupied Slots: " << size_ << " (" << load_factor_ * 100.0f << " %)\n";
std::cout << " Removed Slots: " << removed_amount_ << " (" << removed_load_factor_ * 100.0f
<< " %)\n";
char memory_size_str[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE];
BLI_str_format_byte_unit(memory_size_str, size_in_bytes_, true);
std::cout << " Size: ~" << memory_size_str << "\n";
std::cout << " Size per Slot: " << size_per_element_ << " bytes\n";
std::cout << " Average Collisions: " << average_collisions_ << "\n";
for (int64_t collision_count : keys_by_collision_count_.index_range()) {
std::cout << " " << collision_count
<< " Collisions: " << keys_by_collision_count_[collision_count] << "\n";
}
}

View File

@ -0,0 +1,17 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_index_range.hh"
#include <ostream>
namespace blender {
std::ostream &operator<<(std::ostream &stream, IndexRange range)
{
stream << '[' << range.start() << ", " << range.one_after_last() << ')';
return stream;
}
} // namespace blender

View File

@ -0,0 +1,45 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_math_basis_types.hh"
#include <ostream>
namespace blender::math {
std::ostream &operator<<(std::ostream &stream, const Axis axis)
{
switch (axis.axis_) {
default:
BLI_assert_unreachable();
return stream << "Invalid Axis";
case Axis::Value::X:
return stream << 'X';
case Axis::Value::Y:
return stream << 'Y';
case Axis::Value::Z:
return stream << 'Z';
}
}
std::ostream &operator<<(std::ostream &stream, const AxisSigned axis)
{
switch (axis.axis_) {
default:
BLI_assert_unreachable();
return stream << "Invalid AxisSigned";
case AxisSigned::Value::X_POS:
case AxisSigned::Value::Y_POS:
case AxisSigned::Value::Z_POS:
case AxisSigned::Value::X_NEG:
case AxisSigned::Value::Y_NEG:
case AxisSigned::Value::Z_NEG:
return stream << axis.axis() << (axis.sign() == -1 ? '-' : '+');
}
}
std::ostream &operator<<(std::ostream &stream, const CartesianBasis &rot)
{
return stream << "CartesianBasis" << rot.axes;
}
} // namespace blender::math

View File

@ -0,0 +1,23 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_string_ref.hh"
#include <ostream>
namespace blender {
std::ostream &operator<<(std::ostream &stream, StringRef ref)
{
stream << std::string(ref);
return stream;
}
std::ostream &operator<<(std::ostream &stream, StringRefNull ref)
{
stream << std::string(ref.data(), size_t(ref.size()));
return stream;
}
}

View File

@ -0,0 +1,26 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_string.h"
#include "BLI_vector.hh"
#include <iostream>
void blender::internal::vector_print_stats(StringRef name,
void *address,
int64_t size,
int64_t capacity,
int64_t inlineCapacity,
int64_t memorySize)
{
std::cout << "Vector Stats: " << name << "\n";
std::cout << " Address: " << address << "\n";
std::cout << " Elements: " << size << "\n";
std::cout << " Capacity: " << capacity << "\n";
std::cout << " Inline Capacity: " << inlineCapacity << "\n";
char memory_size_str[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE];
BLI_str_format_byte_unit(memory_size_str, memorySize, true);
std::cout << " Size on Stack: " << memory_size_str << "\n";
}

View File

@ -0,0 +1,12 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_virtual_array.hh"
#include <iostream>
void blender::internal::print_mutable_varray_span_warning()
{
std::cout << "Warning: Call `save()` to make sure that changes persist in all cases.\n";
}

View File

@ -2,6 +2,9 @@
*
* SPDX-License-Identifier: Apache-2.0 */
#include "BLI_math_color.hh"
#include "BLI_math_vector.hh"
#include "BLI_array.hh"
#include "BLI_length_parameterize.hh"
#include "BLI_vector.hh"

View File

@ -411,6 +411,23 @@ TEST(math_matrix, MatrixMethods)
EXPECT_V3_NEAR(float3(eul), float3(expect_eul), 0.0002f);
}
TEST(math_matrix, Transformation2DMatrixDecomposition)
{
const float2 translation = float2(1.0f, 2.0f);
const AngleRadian rotation = AngleRadian(0.5f);
const float2 scale = float2(5.0f, 3.0f);
const float3x3 transformation = from_loc_rot_scale<float3x3>(translation, rotation, scale);
AngleRadian decomposed_rotation;
float2 decomposed_translation, decomposed_scale;
to_loc_rot_scale(transformation, decomposed_translation, decomposed_rotation, decomposed_scale);
EXPECT_V2_NEAR(decomposed_translation, translation, 0.00001f);
EXPECT_V2_NEAR(decomposed_scale, scale, 0.00001f);
EXPECT_NEAR(decomposed_rotation.radian(), rotation.radian(), 0.00001f);
}
TEST(math_matrix, MatrixToQuaternionLegacy)
{
float3x3 mat = {{0.808309, -0.578051, -0.111775},

View File

@ -195,6 +195,17 @@ BlendFileData *BLO_read_from_memfile(struct Main *oldmain,
*/
void BLO_blendfiledata_free(BlendFileData *bfd);
/**
* Does versioning code that requires the Main data-base to be fully loaded and valid.
*
* readfile's `do_versions` does not allow to create (or delete) IDs, and only operates on a single
* library at a time.
*
* Called at the end of #setup_add_data from BKE's `blendfile.cc`.
*
* \param new_bmain the newly read Main data-base. */
void BLO_read_do_version_after_setup(struct Main *new_bmain, struct BlendFileReadReport *reports);
/** \} */
/* -------------------------------------------------------------------- */

View File

@ -502,3 +502,8 @@ void BLO_blendfiledata_free(BlendFileData *bfd)
MEM_freeN(bfd);
}
void BLO_read_do_version_after_setup(struct Main *new_bmain, struct BlendFileReadReport *reports)
{
do_versions_after_setup(new_bmain, reports);
}

View File

@ -244,6 +244,8 @@ void do_versions_after_linking_300(struct FileData *fd, struct Main *bmain);
void do_versions_after_linking_400(struct FileData *fd, struct Main *bmain);
void do_versions_after_linking_cycles(struct Main *bmain);
void do_versions_after_setup(struct Main *new_bmain, struct BlendFileReadReport *reports);
/**
* Direct data-blocks with global linking.
*

View File

@ -20,7 +20,9 @@
#include "BKE_animsys.h"
#include "BKE_idprop.h"
#include "BKE_ipo.h"
#include "BKE_lib_id.h"
#include "BKE_lib_override.hh"
#include "BKE_main.h"
#include "BKE_main_namemap.h"
#include "BKE_node.hh"
@ -28,6 +30,8 @@
#include "MEM_guardedalloc.h"
#include "BLO_readfile.h"
#include "readfile.h"
#include "versioning_common.h"
using blender::Map;
@ -448,3 +452,67 @@ void version_update_node_input(
version_socket_update_is_used(ntree);
}
}
static bool blendfile_or_libraries_versions_atleast(Main *bmain,
const short versionfile,
const short subversionfile)
{
if (!MAIN_VERSION_FILE_ATLEAST(bmain, versionfile, subversionfile)) {
return false;
}
LISTBASE_FOREACH (Library *, library, &bmain->libraries) {
if (!MAIN_VERSION_FILE_ATLEAST(library, versionfile, subversionfile)) {
return false;
}
}
return true;
}
void do_versions_after_setup(Main *new_bmain, BlendFileReadReport *reports)
{
/* WARNING: The code below may add IDs. These IDs _will_ be (by definition) conforming to current
* code's version already, and _must not_ be 'versionned' again.
*
* This means that when adding code here, _extreme_ care must be taken that it will not badly
* affect these 'modern' IDs potentially added by already existing processing.
*
* Adding code here should only be done in exceptional cases.
*
* Some further points to keep in mind:
* - While typically versioning order should be respected in code below (i.e. versioning
* affecting older versions should be done first), _this is not a hard rule_. And it should
* not be assumed older code must not be checked when adding newer code.
* - Do not rely strongly on versioning numbers here. This code may be run on data from
* different Blender versions (through the usage of linked data), and all existing data have
* already been processed through the whole do_version during blendfile reading itself. So
* decision to apply some versioning on some data should mostly rely on the data itself.
* - Unlike the regular do_version code, this one should _not_ be assumed as 'valid forever'.
* It is closer to the Editing or BKE code in that respect, changes to the logic or data
* model of an ID will require carefull update here as well.
*
* Another critical weakness of this code is that it is currently _not_ performed on data linked
* during an editing session, but only on data linked while reading a whole blendfile. This will
* have to be fixed at some point.
*/
/* NOTE: Version number is checked against Main version (i.e. current blend file version), AND
* the versions of all the linked libraries. */
if (!blendfile_or_libraries_versions_atleast(new_bmain, 250, 0)) {
do_versions_ipos_to_animato(new_bmain);
}
if (!blendfile_or_libraries_versions_atleast(new_bmain, 302, 1)) {
BKE_lib_override_library_main_proxy_convert(new_bmain, reports);
/* Currently liboverride code can generate invalid namemap. This is a known issue, requires
* #107847 to be properly fixed. */
BKE_main_namemap_validate_and_fix(new_bmain);
}
if (!blendfile_or_libraries_versions_atleast(new_bmain, 302, 3)) {
/* Does not add any new IDs, but needs the full Main data-base. */
BKE_lib_override_library_main_hierarchy_root_ensure(new_bmain);
}
}

View File

@ -10,10 +10,10 @@
#include "COM_Enums.h"
#include "BLI_math_interp.h"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "IMB_colormanagement.h"
struct ColormanageProcessor;
struct ImBuf;
namespace blender::compositor {

View File

@ -7,6 +7,8 @@
#include "COM_ConvertOperation.h"
#include "COM_SetAlphaMultiplyOperation.h"
#include "BLI_math_color.h"
namespace blender::compositor {
ChannelMatteNode::ChannelMatteNode(bNode *editor_node) : Node(editor_node)

View File

@ -7,6 +7,8 @@
#include "COM_ConvertOperation.h"
#include "COM_SetAlphaMultiplyOperation.h"
#include "BLI_math_color.h"
namespace blender::compositor {
ChromaMatteNode::ChromaMatteNode(bNode *editor_node) : Node(editor_node)

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