Merge branch 'master' into sculpt-dev

This commit is contained in:
Pablo Dobarro 2021-07-31 17:16:02 +02:00
commit d3faf09082
219 changed files with 4493 additions and 3527 deletions

View File

@ -251,16 +251,6 @@ if(WITH_GHOST_X11)
option(WITH_X11_ALPHA "Enable X11 transparent background" ON)
endif()
if(UNIX AND NOT APPLE)
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
else()
# not an option for other OS's
set(WITH_SYSTEM_GLEW OFF)
set(WITH_SYSTEM_GLES OFF)
endif()
if(UNIX AND NOT APPLE)
option(WITH_SYSTEM_EIGEN3 "Use the systems Eigen3 library" OFF)
endif()
@ -403,14 +393,14 @@ set(CYCLES_TEST_DEVICES CPU CACHE STRING "Run regression tests on the specified
set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 compute_75 CACHE STRING "CUDA architectures to build binaries for")
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
unset(PLATFORM_DEFAULT)
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
option(WITH_CYCLES_DEBUG "Build Cycles with extra debug capabilities" OFF)
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
option(WITH_CYCLES_DEBUG_NAN "Build Cycles with additional asserts for detecting NaNs and invalid values" OFF)
option(WITH_CYCLES_NATIVE_ONLY "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF)
option(WITH_CYCLES_KERNEL_ASAN "Build Cycles kernels with address sanitizer when WITH_COMPILER_ASAN is on, even if it's very slow" OFF)
mark_as_advanced(WITH_CYCLES_KERNEL_ASAN)
mark_as_advanced(WITH_CYCLES_CUBIN_COMPILER)
mark_as_advanced(WITH_CYCLES_LOGGING)
mark_as_advanced(WITH_CYCLES_DEBUG)
mark_as_advanced(WITH_CYCLES_DEBUG_NAN)
mark_as_advanced(WITH_CYCLES_NATIVE_ONLY)
option(WITH_CYCLES_DEVICE_CUDA "Enable Cycles CUDA compute support" ON)
@ -485,15 +475,32 @@ endif()
# OpenGL
if(UNIX AND NOT APPLE)
# GLEW can only built with either GLX or EGL support and most binary
# distributions are built with GLX support. So we always compile GLEW
# with EGL support manually, and the options are no longer available.
set(WITH_SYSTEM_GLEW OFF)
set(WITH_SYSTEM_GLES ON)
# Always use EGL instead of GLX, for X11, Wayland and headless.
set(WITH_GL_EGL ON)
else()
# System GLEW and GLES were never an option on other platforms.
set(WITH_SYSTEM_GLEW OFF)
set(WITH_SYSTEM_GLES OFF)
# Experimental EGL option.
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL or WGL)" OFF)
mark_as_advanced(WITH_GL_EGL)
endif()
option(WITH_OPENGL "When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)" ON)
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (through either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
mark_as_advanced(
WITH_OPENGL
WITH_GLEW_ES
WITH_GL_EGL
WITH_GL_PROFILE_ES20
)

View File

@ -30,6 +30,7 @@ if(WIN32)
--enable-w32threads
--disable-pthreads
--enable-libopenjpeg
--disable-mediafoundation
)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
set(FFMPEG_EXTRA_FLAGS

View File

@ -66,7 +66,11 @@ ExternalProject_Add(ll
if(MSVC)
if(BUILD_MODE STREQUAL Release)
set(LLVM_HARVEST_COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/ ${HARVEST_TARGET}/llvm/ )
set(LLVM_HARVEST_COMMAND
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/lib ${HARVEST_TARGET}/llvm/lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/include ${HARVEST_TARGET}/llvm/include &&
${CMAKE_COMMAND} -E copy ${LIBDIR}/llvm/bin/clang-format.exe ${HARVEST_TARGET}/llvm/bin/clang-format.exe
)
else()
set(LLVM_HARVEST_COMMAND
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/lib/ ${HARVEST_TARGET}/llvm/debug/lib/ &&

View File

@ -474,25 +474,25 @@ OPENEXR_FORCE_REBUILD=false
OPENEXR_SKIP=false
_with_built_openexr=false
OIIO_VERSION="2.1.15.0"
OIIO_VERSION_SHORT="2.1"
OIIO_VERSION="2.2.15.1"
OIIO_VERSION_SHORT="2.2"
OIIO_VERSION_MIN="2.1.12"
OIIO_VERSION_MAX="2.2.10"
OIIO_VERSION_MAX="2.3.0"
OIIO_FORCE_BUILD=false
OIIO_FORCE_REBUILD=false
OIIO_SKIP=false
LLVM_VERSION="9.0.1"
LLVM_VERSION_SHORT="9.0"
LLVM_VERSION_MIN="6.0"
LLVM_VERSION_MAX="12.0"
LLVM_VERSION="12.0.0"
LLVM_VERSION_SHORT="12.0"
LLVM_VERSION_MIN="11.0"
LLVM_VERSION_MAX="13.0"
LLVM_VERSION_FOUND=""
LLVM_FORCE_BUILD=false
LLVM_FORCE_REBUILD=false
LLVM_SKIP=false
# OSL needs to be compiled for now!
OSL_VERSION="1.11.10.0"
OSL_VERSION="1.11.14.1"
OSL_VERSION_SHORT="1.11"
OSL_VERSION_MIN="1.11"
OSL_VERSION_MAX="2.0"
@ -553,7 +553,7 @@ EMBREE_FORCE_BUILD=false
EMBREE_FORCE_REBUILD=false
EMBREE_SKIP=false
OIDN_VERSION="1.4.0"
OIDN_VERSION="1.4.1"
OIDN_VERSION_SHORT="1.4"
OIDN_VERSION_MIN="1.4.0"
OIDN_VERSION_MAX="1.5"
@ -561,7 +561,7 @@ OIDN_FORCE_BUILD=false
OIDN_FORCE_REBUILD=false
OIDN_SKIP=false
ISPC_VERSION="1.14.1"
ISPC_VERSION="1.16.0"
FFMPEG_VERSION="4.4"
FFMPEG_VERSION_SHORT="4.4"
@ -603,9 +603,6 @@ MP3LAME_DEV=""
OPENJPEG_USE=false
OPENJPEG_DEV=""
# Whether to use system GLEW or not (OpenSubDiv needs recent glew to work).
NO_SYSTEM_GLEW=false
# Switch to english language, else some things (like check_package_DEB()) won't work!
LANG_BACK=$LANG
LANG=""
@ -1129,7 +1126,7 @@ Those libraries should be available as packages in all recent distributions (opt
* libjpeg, libpng, libtiff, [openjpeg2], [libopenal].
* libx11, libxcursor, libxi, libxrandr, libxinerama (and other libx... as needed).
* libwayland-client0, libwayland-cursor0, libwayland-egl1, libxkbcommon0, libdbus-1-3, libegl1 (Wayland)
* libsqlite3, libbz2, libssl, libfftw3, libxml2, libtinyxml, yasm, libyaml-cpp.
* libsqlite3, libzstd, libbz2, libssl, libfftw3, libxml2, libtinyxml, yasm, libyaml-cpp, flex.
* libsdl2, libglew, libpugixml, libpotrace, [libgmp], [libglewmx], fontconfig, [libharu/libhpdf].\""
DEPS_SPECIFIC_INFO="\"BUILDABLE DEPENDENCIES:
@ -2316,6 +2313,7 @@ compile_OSL() {
tar -C $SRC --transform "s,(.*/?)OpenShadingLanguage-[^/]*(.*),\1OpenShadingLanguage-$OSL_VERSION\2,x" \
-xf $_src.tar.gz
fi
patch -d $_src -p1 < $SCRIPT_DIR/patches/osl.diff
fi
cd $_src
@ -2338,7 +2336,6 @@ compile_OSL() {
cmake_d="-D CMAKE_BUILD_TYPE=Release"
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
cmake_d="$cmake_d -D BUILD_TESTING=OFF"
cmake_d="$cmake_d -D STOP_ON_WARNING=OFF"
cmake_d="$cmake_d -D OSL_BUILD_PLUGINS=OFF"
cmake_d="$cmake_d -D OSL_BUILD_TESTS=OFF"
@ -2346,7 +2343,10 @@ compile_OSL() {
cmake_d="$cmake_d -D USE_PARTIO=OFF"
cmake_d="$cmake_d -D OSL_BUILD_MATERIALX=OFF"
cmake_d="$cmake_d -D USE_QT=OFF"
cmake_d="$cmake_d -D USE_Qt5=OFF"
cmake_d="$cmake_d -D USE_PYTHON=OFF"
cmake_d="$cmake_d -D USE_PARTIO=OFF"
cmake_d="$cmake_d -D INSTALL_DOCS=OFF"
if [ $(uname -m) != "aarch64" ]; then
cmake_d="$cmake_d -D USE_SIMD=sse2"
@ -2368,10 +2368,7 @@ compile_OSL() {
fi
if [ -d $INST/oiio ]; then
cmake_d="$cmake_d -D OPENIMAGEIO_ROOT_DIR=$INST/oiio"
# HACK! SIC!!!!
# Quiet incredible, but if root dir is given, path to lib is found, but not path to include...
cmake_d="$cmake_d -D OPENIMAGEIO_INCLUDE_DIR=$INST/oiio/include"
cmake_d="$cmake_d -D OpenImageIO_ROOT=$INST/oiio"
fi
if [ ! -z $LLVM_VERSION_FOUND ]; then
@ -3844,7 +3841,7 @@ install_DEB() {
libbz2-dev libncurses5-dev libssl-dev liblzma-dev libreadline-dev \
libopenal-dev libglew-dev yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV \
libsdl2-dev libfftw3-dev patch bzip2 libxml2-dev libtinyxml-dev libjemalloc-dev \
libgmp-dev libpugixml-dev libpotrace-dev libhpdf-dev"
libgmp-dev libpugixml-dev libpotrace-dev libhpdf-dev libzstd-dev"
# libglewmx-dev (broken in deb testing currently...)
VORBIS_USE=true
@ -3985,13 +3982,9 @@ install_DEB() {
version_ge $_glew "1.7.0"
if [ $? -eq 1 ]; then
WARNING "OpenSubdiv disabled because GLEW-$_glew is not enough"
WARNING "Blender will not use system GLEW library"
OSD_SKIP=true
NO_SYSTEM_GLEW=true
else
WARNING "OpenSubdiv will compile with GLEW-$_glew but with limited capability"
WARNING "Blender will not use system GLEW library"
NO_SYSTEM_GLEW=true
fi
fi
@ -4112,6 +4105,8 @@ install_DEB() {
PRINT ""
# Debian OIIO includes again libopencv, without even properly dealing with this dependency...
OIIO_FORCE_BUILD=true
if [ "$OIIO_SKIP" = true ]; then
WARNING "Skipping OpenImageIO installation, as requested..."
elif [ "$OIIO_FORCE_BUILD" = true ]; then
@ -4514,7 +4509,7 @@ install_RPM() {
wget ncurses-devel readline-devel $OPENJPEG_DEV openal-soft-devel \
glew-devel yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV patch \
libxml2-devel yaml-cpp-devel tinyxml-devel jemalloc-devel \
gmp-devel pugixml-devel potrace-devel libharu-devel"
gmp-devel pugixml-devel potrace-devel libharu-devel libzstd-devel"
OPENJPEG_USE=true
VORBIS_USE=true
@ -5092,10 +5087,11 @@ install_ARCH() {
BASE_DEVEL=`pacman -Sgq base-devel | sed -e 's/^gcc$/gcc-multilib/g' | paste -s -d' '`
fi
_packages="$BASE_DEVEL git cmake fontconfig \
_packages="$BASE_DEVEL git cmake fontconfig flex \
libxi libxcursor libxrandr libxinerama glew libpng libtiff wget openal \
$OPENJPEG_DEV $VORBIS_DEV $OGG_DEV $THEORA_DEV yasm sdl2 fftw \
libxml2 yaml-cpp tinyxml python-requests jemalloc gmp potrace pugixml libharu"
libxml2 yaml-cpp tinyxml python-requests jemalloc gmp potrace pugixml libharu \
zstd"
OPENJPEG_USE=true
VORBIS_USE=true
@ -5959,12 +5955,6 @@ print_info() {
fi
fi
if [ "$NO_SYSTEM_GLEW" = true ]; then
_1="-D WITH_SYSTEM_GLEW=OFF"
PRINT " $_1"
_buildargs="$_buildargs $_1"
fi
if [ "$FFMPEG_SKIP" = false ]; then
_1="-D WITH_CODEC_FFMPEG=ON"
_2="-D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;swresample;lzma;rt;`print_info_ffmpeglink`'"

View File

@ -1,18 +1,3 @@
diff -Naur OpenShadingLanguage-Release-1.9.9/src/cmake/flexbison.cmake.rej external_osl/src/cmake/flexbison.cmake.rej
--- OpenShadingLanguage-Release-1.9.9/src/cmake/flexbison.cmake.rej 1969-12-31 17:00:00 -0700
+++ external_osl/src/cmake/flexbison.cmake.rej 2018-08-24 17:42:11 -0600
@@ -0,0 +1,11 @@
+--- src/cmake/flexbison.cmake 2018-05-01 16:39:02 -0600
++++ src/cmake/flexbison.cmake 2018-08-24 10:24:03 -0600
+@@ -77,7 +77,7 @@
+ DEPENDS ${${compiler_headers}}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
+ ADD_CUSTOM_COMMAND ( OUTPUT ${flexoutputcxx}
+- COMMAND ${FLEX_EXECUTABLE} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}"
++ COMMAND ${FLEX_EXECUTABLE} ${FLEX_EXTRA_OPTIONS} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}"
+ MAIN_DEPENDENCY ${flexsrc}
+ DEPENDS ${${compiler_headers}}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
diff -Naur OpenShadingLanguage-Release-1.9.9/src/include/OSL/llvm_util.h external_osl/src/include/OSL/llvm_util.h
--- OpenShadingLanguage-Release-1.9.9/src/include/OSL/llvm_util.h 2018-05-01 16:39:02 -0600
+++ external_osl/src/include/OSL/llvm_util.h 2018-08-25 14:05:00 -0600

View File

@ -7,7 +7,6 @@
set(WITH_ASSERT_ABORT ON CACHE BOOL "" FORCE)
set(WITH_BUILDINFO OFF CACHE BOOL "" FORCE)
set(WITH_COMPILER_ASAN ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEBUG ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_NATIVE_ONLY ON CACHE BOOL "" FORCE)
set(WITH_DOC_MANPAGE OFF CACHE BOOL "" FORCE)
set(WITH_GTESTS ON CACHE BOOL "" FORCE)

View File

@ -581,8 +581,6 @@ if(WITH_GHOST_WAYLAND)
pkg_check_modules(wayland-cursor REQUIRED wayland-cursor)
pkg_check_modules(dbus REQUIRED dbus-1)
set(WITH_GL_EGL ON)
list(APPEND PLATFORM_LINKLIBS
${wayland-client_LINK_LIBRARIES}
${wayland-egl_LINK_LIBRARIES}

View File

@ -1,8 +1,11 @@
Pipeline Config
===============
This configuration file is used by buildbot new pipeline for the `update-code` step.
This configuration file is used by buildbot new build pipeline for the `update-code` step.
It will soon be used by the ../utils/make_update.py script.
It will also be used by the `../utils/make_update.py` script in the near future.
Both buildbot and developers will eventually use the same configuration file.
NOTES:
* Keep both `yaml` and `json` files in sync until deployment of build pipeline updates.
* The `json` file be removed once all branches are running with the `yaml` file.
* Expected buildbot pipeline update is *Friday, July 30th* or *Monday August, 2nd*.

View File

@ -307,9 +307,9 @@ if(WITH_CYCLES_LOGGING)
)
endif()
# Debugging capabilities (debug passes etc).
if(WITH_CYCLES_DEBUG)
add_definitions(-DWITH_CYCLES_DEBUG)
# NaN debugging
if(WITH_CYCLES_DEBUG_NAN)
add_definitions(-DWITH_CYCLES_DEBUG_NAN)
endif()
if(NOT OPENIMAGEIO_PUGIXML_FOUND)

View File

@ -235,9 +235,12 @@ def system_info():
def list_render_passes(scene, srl):
# Builtin Blender passes.
crl = srl.cycles
# Combined pass.
yield ("Combined", "RGBA", 'COLOR')
# Data passes.
if srl.use_pass_z: yield ("Depth", "Z", 'VALUE')
if srl.use_pass_mist: yield ("Mist", "Z", 'VALUE')
if srl.use_pass_normal: yield ("Normal", "XYZ", 'VECTOR')
@ -245,8 +248,8 @@ def list_render_passes(scene, srl):
if srl.use_pass_uv: yield ("UV", "UVA", 'VECTOR')
if srl.use_pass_object_index: yield ("IndexOB", "X", 'VALUE')
if srl.use_pass_material_index: yield ("IndexMA", "X", 'VALUE')
if srl.use_pass_shadow: yield ("Shadow", "RGB", 'COLOR')
if srl.use_pass_ambient_occlusion: yield ("AO", "RGB", 'COLOR')
# Light passes.
if srl.use_pass_diffuse_direct: yield ("DiffDir", "RGB", 'COLOR')
if srl.use_pass_diffuse_indirect: yield ("DiffInd", "RGB", 'COLOR')
if srl.use_pass_diffuse_color: yield ("DiffCol", "RGB", 'COLOR')
@ -256,19 +259,16 @@ def list_render_passes(scene, srl):
if srl.use_pass_transmission_direct: yield ("TransDir", "RGB", 'COLOR')
if srl.use_pass_transmission_indirect: yield ("TransInd", "RGB", 'COLOR')
if srl.use_pass_transmission_color: yield ("TransCol", "RGB", 'COLOR')
if crl.use_pass_volume_direct: yield ("VolumeDir", "RGB", 'COLOR')
if crl.use_pass_volume_indirect: yield ("VolumeInd", "RGB", 'COLOR')
if srl.use_pass_emit: yield ("Emit", "RGB", 'COLOR')
if srl.use_pass_environment: yield ("Env", "RGB", 'COLOR')
if srl.use_pass_shadow: yield ("Shadow", "RGB", 'COLOR')
if srl.use_pass_ambient_occlusion: yield ("AO", "RGB", 'COLOR')
# Cycles specific passes.
crl = srl.cycles
# Debug passes.
if crl.pass_debug_render_time: yield ("Debug Render Time", "X", 'VALUE')
if crl.pass_debug_bvh_traversed_nodes: yield ("Debug BVH Traversed Nodes", "X", 'VALUE')
if crl.pass_debug_bvh_traversed_instances: yield ("Debug BVH Traversed Instances", "X", 'VALUE')
if crl.pass_debug_bvh_intersections: yield ("Debug BVH Intersections", "X", 'VALUE')
if crl.pass_debug_ray_bounces: yield ("Debug Ray Bounces", "X", 'VALUE')
if crl.pass_debug_sample_count: yield ("Debug Sample Count", "X", 'VALUE')
if crl.use_pass_volume_direct: yield ("VolumeDir", "RGB", 'COLOR')
if crl.use_pass_volume_indirect: yield ("VolumeInd", "RGB", 'COLOR')
# Cryptomatte passes.
crypto_depth = (srl.pass_cryptomatte_depth + 1) // 2

View File

@ -1325,30 +1325,6 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
pass_debug_bvh_traversed_nodes: BoolProperty(
name="Debug BVH Traversed Nodes",
description="Store Debug BVH Traversed Nodes pass",
default=False,
update=update_render_passes,
)
pass_debug_bvh_traversed_instances: BoolProperty(
name="Debug BVH Traversed Instances",
description="Store Debug BVH Traversed Instances pass",
default=False,
update=update_render_passes,
)
pass_debug_bvh_intersections: BoolProperty(
name="Debug BVH Intersections",
description="Store Debug BVH Intersections",
default=False,
update=update_render_passes,
)
pass_debug_ray_bounces: BoolProperty(
name="Debug Ray Bounces",
description="Store Debug Ray Bounces pass",
default=False,
update=update_render_passes,
)
pass_debug_render_time: BoolProperty(
name="Debug Render Time",
description="Render time in milliseconds per sample and pixel",

View File

@ -936,29 +936,6 @@ class CYCLES_RENDER_PT_passes_crypto(CyclesButtonsPanel, ViewLayerCryptomattePan
bl_parent_id = "CYCLES_RENDER_PT_passes"
class CYCLES_RENDER_PT_passes_debug(CyclesButtonsPanel, Panel):
bl_label = "Debug"
bl_context = "view_layer"
bl_parent_id = "CYCLES_RENDER_PT_passes"
@classmethod
def poll(cls, context):
import _cycles
return _cycles.with_cycles_debug
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
cycles_view_layer = context.view_layer.cycles
layout.prop(cycles_view_layer, "pass_debug_bvh_traversed_nodes")
layout.prop(cycles_view_layer, "pass_debug_bvh_traversed_instances")
layout.prop(cycles_view_layer, "pass_debug_bvh_intersections")
layout.prop(cycles_view_layer, "pass_debug_ray_bounces")
class CYCLES_RENDER_PT_passes_aov(CyclesButtonsPanel, ViewLayerAOVPanel):
bl_label = "Shader AOV"
bl_context = "view_layer"
@ -2317,7 +2294,6 @@ classes = (
CYCLES_RENDER_PT_passes_data,
CYCLES_RENDER_PT_passes_light,
CYCLES_RENDER_PT_passes_crypto,
CYCLES_RENDER_PT_passes_debug,
CYCLES_RENDER_PT_passes_aov,
CYCLES_RENDER_PT_filter,
CYCLES_RENDER_PT_override,

View File

@ -1055,10 +1055,45 @@ static BL::MeshSequenceCacheModifier object_mesh_cache_find(BL::Object &b_ob)
return BL::MeshSequenceCacheModifier(PointerRNA_NULL);
}
/* Check whether some of "built-in" motion-related attributes are needed to be exported (includes
* things like velocity from cache modifier, fluid simulation).
*
* NOTE: This code is run prior to object motion blur initialization. so can not access properties
* set by `sync_object_motion_init()`. */
static bool mesh_need_motion_attribute(BL::Object &b_ob, Scene *scene)
{
const Scene::MotionType need_motion = scene->need_motion();
if (need_motion == Scene::MOTION_NONE) {
/* Simple case: neither motion pass nor motion blur is needed, no need in the motion related
* attributes. */
return false;
}
if (need_motion == Scene::MOTION_BLUR) {
/* A bit tricky and implicit case:
* - Motion blur is enabled in the scene, which implies specific number of time steps for
* objects.
* - If the object has motion blur disabled on it, it will have 0 time steps.
* - Motion attribute expects non-zero time steps.
*
* Avoid adding motion attributes if the motion blur will enforce 0 motion steps. */
PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
const bool use_motion = get_boolean(cobject, "use_motion_blur");
if (!use_motion) {
return false;
}
}
/* Motion pass which implies 3 motion steps, or motion blur which is not disabled on object
* level. */
return true;
}
static void sync_mesh_cached_velocities(BL::Object &b_ob, Scene *scene, Mesh *mesh)
{
if (scene->need_motion() == Scene::MOTION_NONE)
if (!mesh_need_motion_attribute(b_ob, scene)) {
return;
}
BL::MeshSequenceCacheModifier b_mesh_cache = object_mesh_cache_find(b_ob);
@ -1102,8 +1137,9 @@ static void sync_mesh_cached_velocities(BL::Object &b_ob, Scene *scene, Mesh *me
static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh)
{
if (scene->need_motion() == Scene::MOTION_NONE)
if (!mesh_need_motion_attribute(b_ob, scene)) {
return;
}
BL::FluidDomainSettings b_fluid_domain = object_fluid_liquid_domain_find(b_ob);

View File

@ -1098,14 +1098,6 @@ void *CCL_python_module_init()
PyModule_AddStringConstant(mod, "osl_version_string", "unknown");
#endif
#ifdef WITH_CYCLES_DEBUG
PyModule_AddObject(mod, "with_cycles_debug", Py_True);
Py_INCREF(Py_True);
#else
PyModule_AddObject(mod, "with_cycles_debug", Py_False);
Py_INCREF(Py_False);
#endif
#ifdef WITH_NETWORK
PyModule_AddObject(mod, "with_network", Py_True);
Py_INCREF(Py_True);

View File

@ -538,12 +538,6 @@ PassType BlenderSync::get_pass_type(BL::RenderPass &b_pass)
MAP_PASS("BakePrimitive", PASS_BAKE_PRIMITIVE);
MAP_PASS("BakeDifferential", PASS_BAKE_DIFFERENTIAL);
#ifdef __KERNEL_DEBUG__
MAP_PASS("Debug BVH Traversed Nodes", PASS_BVH_TRAVERSED_NODES);
MAP_PASS("Debug BVH Traversed Instances", PASS_BVH_TRAVERSED_INSTANCES);
MAP_PASS("Debug BVH Intersections", PASS_BVH_INTERSECTIONS);
MAP_PASS("Debug Ray Bounces", PASS_RAY_BOUNCES);
#endif
MAP_PASS("Debug Render Time", PASS_RENDER_TIME);
MAP_PASS("AdaptiveAuxBuffer", PASS_ADAPTIVE_AUX_BUFFER);
MAP_PASS("Debug Sample Count", PASS_SAMPLE_COUNT);
@ -641,24 +635,6 @@ vector<Pass> BlenderSync::sync_render_passes(BL::Scene &b_scene,
}
}
#ifdef __KERNEL_DEBUG__
if (get_boolean(crl, "pass_debug_bvh_traversed_nodes")) {
b_engine.add_pass("Debug BVH Traversed Nodes", 1, "X", b_view_layer.name().c_str());
Pass::add(PASS_BVH_TRAVERSED_NODES, passes, "Debug BVH Traversed Nodes");
}
if (get_boolean(crl, "pass_debug_bvh_traversed_instances")) {
b_engine.add_pass("Debug BVH Traversed Instances", 1, "X", b_view_layer.name().c_str());
Pass::add(PASS_BVH_TRAVERSED_INSTANCES, passes, "Debug BVH Traversed Instances");
}
if (get_boolean(crl, "pass_debug_bvh_intersections")) {
b_engine.add_pass("Debug BVH Intersections", 1, "X", b_view_layer.name().c_str());
Pass::add(PASS_BVH_INTERSECTIONS, passes, "Debug BVH Intersections");
}
if (get_boolean(crl, "pass_debug_ray_bounces")) {
b_engine.add_pass("Debug Ray Bounces", 1, "X", b_view_layer.name().c_str());
Pass::add(PASS_RAY_BOUNCES, passes, "Debug Ray Bounces");
}
#endif
if (get_boolean(crl, "pass_debug_render_time")) {
b_engine.add_pass("Debug Render Time", 1, "X", b_view_layer.name().c_str());
Pass::add(PASS_RENDER_TIME, passes, "Debug Render Time");

View File

@ -351,9 +351,6 @@ string CUDADevice::compile_kernel_get_common_cflags(
if (extra_cflags) {
cflags += string(" ") + string(extra_cflags);
}
# ifdef WITH_CYCLES_DEBUG
cflags += " -D__KERNEL_DEBUG__";
# endif
if (split) {
cflags += " -D__SPLIT__";

View File

@ -57,8 +57,8 @@
#include "util/util_function.h"
#include "util/util_logging.h"
#include "util/util_map.h"
#include "util/util_openimagedenoise.h"
#include "util/util_opengl.h"
#include "util/util_openimagedenoise.h"
#include "util/util_optimization.h"
#include "util/util_progress.h"
#include "util/util_system.h"

View File

@ -233,9 +233,6 @@ class OptiXDevice : public CUDADevice {
break;
}
};
# endif
# if OPTIX_ABI_VERSION >= 41 && defined(WITH_CYCLES_DEBUG)
options.validationMode = OPTIX_DEVICE_CONTEXT_VALIDATION_MODE_ALL;
# endif
check_result_optix(optixDeviceContextCreate(cuContext, &options, &context));
# ifdef WITH_CYCLES_LOGGING
@ -369,13 +366,8 @@ class OptiXDevice : public CUDADevice {
OptixModuleCompileOptions module_options = {};
module_options.maxRegisterCount = 0; // Do not set an explicit register limit
# ifdef WITH_CYCLES_DEBUG
module_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_0;
module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_FULL;
# else
module_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_3;
module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
# endif
# if OPTIX_ABI_VERSION >= 41
module_options.boundValues = nullptr;
@ -578,11 +570,7 @@ class OptiXDevice : public CUDADevice {
OptixPipelineLinkOptions link_options = {};
link_options.maxTraceDepth = 1;
# ifdef WITH_CYCLES_DEBUG
link_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_FULL;
# else
link_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
# endif
# if OPTIX_ABI_VERSION < 24
link_options.overrideUsesMotionBlur = motion_blur;
# endif

View File

@ -1968,10 +1968,6 @@ string OpenCLDevice::kernel_build_options(const string *debug_src)
build_options += "-D__KERNEL_OPENCL_DEBUG__ ";
}
# ifdef WITH_CYCLES_DEBUG
build_options += "-D__KERNEL_DEBUG__ ";
# endif
# ifdef WITH_NANOVDB
if (info.has_nanovdb) {
build_options += "-DWITH_NANOVDB ";

View File

@ -444,10 +444,6 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(name ${name}_experimental)
endif()
if(WITH_CYCLES_DEBUG)
set(cuda_flags ${cuda_flags} -D __KERNEL_DEBUG__)
endif()
if(WITH_NANOVDB)
set(cuda_flags ${cuda_flags}
-D WITH_NANOVDB
@ -562,11 +558,6 @@ if(WITH_CYCLES_DEVICE_OPTIX AND WITH_CYCLES_CUDA_BINARIES)
--use_fast_math
-o ${output})
if(WITH_CYCLES_DEBUG)
set(cuda_flags ${cuda_flags}
-D __KERNEL_DEBUG__)
endif()
if(WITH_NANOVDB)
set(cuda_flags ${cuda_flags}
-D WITH_NANOVDB

View File

@ -67,8 +67,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
isect->prim = PRIM_NONE;
isect->object = OBJECT_NONE;
BVH_DEBUG_INIT();
/* traversal loop */
do {
do {
@ -118,7 +116,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
--stack_ptr;
}
}
BVH_DEBUG_NEXT_NODE();
}
/* if node is leaf, fetch triangle list */
@ -138,7 +135,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
switch (type & PRIMITIVE_ALL) {
case PRIMITIVE_TRIANGLE: {
for (; prim_addr < prim_addr2; prim_addr++) {
BVH_DEBUG_NEXT_INTERSECTION();
kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
if (triangle_intersect(kg, isect, P, dir, visibility, object, prim_addr)) {
/* shadow ray early termination */
@ -151,7 +147,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
#if BVH_FEATURE(BVH_MOTION)
case PRIMITIVE_MOTION_TRIANGLE: {
for (; prim_addr < prim_addr2; prim_addr++) {
BVH_DEBUG_NEXT_INTERSECTION();
kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type);
if (motion_triangle_intersect(
kg, isect, P, dir, ray->time, visibility, object, prim_addr)) {
@ -169,7 +164,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
case PRIMITIVE_CURVE_RIBBON:
case PRIMITIVE_MOTION_CURVE_RIBBON: {
for (; prim_addr < prim_addr2; prim_addr++) {
BVH_DEBUG_NEXT_INTERSECTION();
const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr);
kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL));
const bool hit = curve_intersect(
@ -201,8 +195,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
traversal_stack[stack_ptr] = ENTRYPOINT_SENTINEL;
node_addr = kernel_tex_fetch(__object_node, object);
BVH_DEBUG_NEXT_INSTANCE();
}
}
} while (node_addr != ENTRYPOINT_SENTINEL);

View File

@ -42,33 +42,6 @@ CCL_NAMESPACE_BEGIN
#define BVH_FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0)
/* Debugging helpers. */
#ifdef __KERNEL_DEBUG__
# define BVH_DEBUG_INIT() \
do { \
isect->num_traversed_nodes = 0; \
isect->num_traversed_instances = 0; \
isect->num_intersections = 0; \
} while (0)
# define BVH_DEBUG_NEXT_NODE() \
do { \
++isect->num_traversed_nodes; \
} while (0)
# define BVH_DEBUG_NEXT_INTERSECTION() \
do { \
++isect->num_intersections; \
} while (0)
# define BVH_DEBUG_NEXT_INSTANCE() \
do { \
++isect->num_traversed_instances; \
} while (0)
#else /* __KERNEL_DEBUG__ */
# define BVH_DEBUG_INIT()
# define BVH_DEBUG_NEXT_NODE()
# define BVH_DEBUG_NEXT_INTERSECTION()
# define BVH_DEBUG_NEXT_INSTANCE()
#endif /* __KERNEL_DEBUG__ */
CCL_NAMESPACE_END
#endif /* __BVH_TYPES__ */

View File

@ -432,9 +432,9 @@ ccl_device void bssrdf_sample(const ShaderClosure *sc, float xi, float *r, float
xi *= bssrdf->channels;
if (xi < 1.0f) {
radius = (bssrdf->radius.x > 0.0f) ?
bssrdf->radius.x :
(bssrdf->radius.y > 0.0f) ? bssrdf->radius.y : bssrdf->radius.z;
radius = (bssrdf->radius.x > 0.0f) ? bssrdf->radius.x :
(bssrdf->radius.y > 0.0f) ? bssrdf->radius.y :
bssrdf->radius.z;
}
else if (xi < 2.0f) {
xi -= 1.0f;

View File

@ -52,15 +52,14 @@ typedef struct TileInfo {
tile_buffer_6, tile_buffer_7, tile_buffer_8, tile_buffer_9
# define ccl_get_tile_buffer(id) \
(id == 0 ? tile_buffer_1 : \
id == 1 ? \
tile_buffer_2 : \
id == 2 ? \
tile_buffer_3 : \
id == 3 ? tile_buffer_4 : \
id == 4 ? tile_buffer_5 : \
id == 5 ? tile_buffer_6 : \
id == 6 ? tile_buffer_7 : \
id == 7 ? tile_buffer_8 : tile_buffer_9)
id == 1 ? tile_buffer_2 : \
id == 2 ? tile_buffer_3 : \
id == 3 ? tile_buffer_4 : \
id == 4 ? tile_buffer_5 : \
id == 5 ? tile_buffer_6 : \
id == 6 ? tile_buffer_7 : \
id == 7 ? tile_buffer_8 : \
tile_buffer_9)
#else
# ifdef __KERNEL_CUDA__
# define CCL_FILTER_TILE_INFO ccl_global TileInfo *tile_info

View File

@ -225,13 +225,6 @@ ccl_device_inline void path_radiance_init(KernelGlobals *kg, PathRadiance *L)
L->denoising_albedo = zero_float3();
L->denoising_depth = 0.0f;
#endif
#ifdef __KERNEL_DEBUG__
L->debug_data.num_bvh_traversed_nodes = 0;
L->debug_data.num_bvh_traversed_instances = 0;
L->debug_data.num_bvh_intersections = 0;
L->debug_data.num_ray_bounces = 0;
#endif
}
ccl_device_inline void path_radiance_bsdf_bounce(KernelGlobals *kg,
@ -595,7 +588,9 @@ ccl_device_inline void path_radiance_sum_shadowcatcher(KernelGlobals *kg,
float shadow;
if (UNLIKELY(!isfinite_safe(path_total))) {
# ifdef __KERNEL_DEBUG_NAN__
kernel_assert(!"Non-finite total radiance along the path");
# endif
shadow = 0.0f;
}
else if (path_total == 0.0f) {
@ -641,7 +636,9 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg,
/* Reject invalid value */
if (!isfinite_safe(sum)) {
# ifdef __KERNEL_DEBUG_NAN__
kernel_assert(!"Non-finite sum in path_radiance_clamp_and_sum!");
# endif
L_sum = zero_float3();
L->direct_diffuse = zero_float3();
@ -667,7 +664,9 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg,
/* Reject invalid value */
float sum = fabsf((L_sum).x) + fabsf((L_sum).y) + fabsf((L_sum).z);
if (!isfinite_safe(sum)) {
#ifdef __KERNEL_DEBUG_NAN__
kernel_assert(!"Non-finite final sum in path_radiance_clamp_and_sum!");
#endif
L_sum = zero_float3();
}
}

View File

@ -122,31 +122,6 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg,
}
#endif /* __DENOISING_FEATURES__ */
#ifdef __KERNEL_DEBUG__
ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
ccl_global float *buffer,
PathRadiance *L)
{
int flag = kernel_data.film.pass_flag;
if (flag & PASSMASK(BVH_TRAVERSED_NODES)) {
kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_nodes,
L->debug_data.num_bvh_traversed_nodes);
}
if (flag & PASSMASK(BVH_TRAVERSED_INSTANCES)) {
kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_instances,
L->debug_data.num_bvh_traversed_instances);
}
if (flag & PASSMASK(BVH_INTERSECTIONS)) {
kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_intersections,
L->debug_data.num_bvh_intersections);
}
if (flag & PASSMASK(RAY_BOUNCES)) {
kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces,
L->debug_data.num_ray_bounces);
}
}
#endif /* __KERNEL_DEBUG__ */
#ifdef __KERNEL_CPU__
# define WRITE_ID_SLOT(buffer, depth, id, matte_weight, name) \
kernel_write_id_pass_cpu(buffer, depth * 2, id, matte_weight, kg->coverage_##name)
@ -389,10 +364,6 @@ ccl_device_inline void kernel_write_result(KernelGlobals *kg,
}
#endif /* __DENOISING_FEATURES__ */
#ifdef __KERNEL_DEBUG__
kernel_write_debug_passes(kg, buffer, L);
#endif
/* Adaptive Sampling. Fill the additional buffer with the odd samples and calculate our stopping
criteria. This is the heuristic from "A hierarchical automatic stopping condition for Monte
Carlo global illumination" except that here it is applied per pixel and not in hierarchical

View File

@ -70,15 +70,6 @@ ccl_device_forceinline bool kernel_path_scene_intersect(KernelGlobals *kg,
bool hit = scene_intersect(kg, ray, visibility, isect);
#ifdef __KERNEL_DEBUG__
if (state->flag & PATH_RAY_CAMERA) {
L->debug_data.num_bvh_traversed_nodes += isect->num_traversed_nodes;
L->debug_data.num_bvh_traversed_instances += isect->num_traversed_instances;
L->debug_data.num_bvh_intersections += isect->num_intersections;
}
L->debug_data.num_ray_bounces++;
#endif /* __KERNEL_DEBUG__ */
return hit;
}

View File

@ -182,9 +182,8 @@ CCL_NAMESPACE_BEGIN
# undef __SHADER_RAYTRACE__
#endif
/* Features that enable others */
#ifdef WITH_CYCLES_DEBUG
# define __KERNEL_DEBUG__
#ifdef WITH_CYCLES_DEBUG_NAN
# define __KERNEL_DEBUG_NAN__
#endif
#if defined(__SUBSURFACE__) || defined(__SHADER_RAYTRACE__)
@ -356,12 +355,6 @@ typedef enum PassType {
PASS_MATERIAL_ID,
PASS_MOTION,
PASS_MOTION_WEIGHT,
#ifdef __KERNEL_DEBUG__
PASS_BVH_TRAVERSED_NODES,
PASS_BVH_TRAVERSED_INSTANCES,
PASS_BVH_INTERSECTIONS,
PASS_RAY_BOUNCES,
#endif
PASS_RENDER_TIME,
PASS_CRYPTOMATTE,
PASS_AOV_COLOR,
@ -465,18 +458,6 @@ typedef enum DenoiseFlag {
DENOISING_CLEAN_ALL_PASSES = (1 << 6) - 1,
} DenoiseFlag;
#ifdef __KERNEL_DEBUG__
/* NOTE: This is a runtime-only struct, alignment is not
* really important here.
*/
typedef struct DebugData {
int num_bvh_traversed_nodes;
int num_bvh_traversed_instances;
int num_bvh_intersections;
int num_ray_bounces;
} DebugData;
#endif
typedef ccl_addr_space struct PathRadianceState {
#ifdef __PASSES__
float3 diffuse;
@ -552,10 +533,6 @@ typedef ccl_addr_space struct PathRadiance {
float3 denoising_albedo;
float denoising_depth;
#endif /* __DENOISING_FEATURES__ */
#ifdef __KERNEL_DEBUG__
DebugData debug_data;
#endif /* __KERNEL_DEBUG__ */
} PathRadiance;
typedef struct BsdfEval {
@ -671,12 +648,6 @@ typedef struct Intersection {
int prim;
int object;
int type;
#ifdef __KERNEL_DEBUG__
int num_traversed_nodes;
int num_traversed_instances;
int num_intersections;
#endif
} Intersection;
/* Primitives */
@ -1265,13 +1236,6 @@ typedef struct KernelFilm {
int pass_bake_differential;
int pad;
#ifdef __KERNEL_DEBUG__
int pass_bvh_traversed_nodes;
int pass_bvh_traversed_instances;
int pass_bvh_intersections;
int pass_ray_bounces;
#endif
/* viewport rendering options */
int display_pass_stride;
int display_pass_components;

View File

@ -54,14 +54,18 @@ vector4 safe_divide(vector4 a, float b)
}
/*
* Smooth Voronoi:
* Original code is under the MIT License, Copyright (c) 2013 Inigo Quilez.
*
* Smooth Voronoi:
* - https://wiki.blender.org/wiki/User:OmarSquircleArt/GSoC2019/Documentation/Smooth_Voronoi
*
* Distance To Edge:
* Distance To Edge based on:
*
* - https://www.shadertoy.com/view/llG3zy
* - https://www.iquilezles.org/www/articles/voronoilines/voronoilines.htm
* - https://www.shadertoy.com/view/ldl3W8
*
* With optimization to change -2..2 scan window to -1..1 for better performance,
* as explained in https://www.shadertoy.com/view/llG3zy.
*/
/* **** 1D Voronoi **** */

View File

@ -17,14 +17,19 @@
CCL_NAMESPACE_BEGIN
/*
* Original code is under the MIT License, Copyright (c) 2013 Inigo Quilez.
*
* Smooth Voronoi:
*
* - https://wiki.blender.org/wiki/User:OmarSquircleArt/GSoC2019/Documentation/Smooth_Voronoi
*
* Distance To Edge:
* Distance To Edge based on:
*
* - https://www.shadertoy.com/view/llG3zy
* - https://www.iquilezles.org/www/articles/voronoilines/voronoilines.htm
* - https://www.shadertoy.com/view/ldl3W8
*
* With optimization to change -2..2 scan window to -1..1 for better performance,
* as explained in https://www.shadertoy.com/view/llG3zy.
*/
/* **** 1D Voronoi **** */

View File

@ -20,6 +20,7 @@
#include "render/mesh.h"
#include "util/util_foreach.h"
#include "util/util_logging.h"
#include "util/util_transform.h"
CCL_NAMESPACE_BEGIN
@ -208,6 +209,7 @@ size_t Attribute::element_size(Geometry *geom, AttributePrimitive prim) const
case ATTR_ELEMENT_VERTEX_MOTION:
if (geom->geometry_type == Geometry::MESH) {
Mesh *mesh = static_cast<Mesh *>(geom);
DCHECK_GT(mesh->get_motion_steps(), 0);
size = (mesh->get_verts().size() + mesh->get_num_ngons()) * (mesh->get_motion_steps() - 1);
if (prim == ATTR_PRIM_SUBD) {
size -= mesh->get_num_subd_verts() * (mesh->get_motion_steps() - 1);
@ -252,6 +254,7 @@ size_t Attribute::element_size(Geometry *geom, AttributePrimitive prim) const
case ATTR_ELEMENT_CURVE_KEY_MOTION:
if (geom->geometry_type == Geometry::HAIR) {
Hair *hair = static_cast<Hair *>(geom);
DCHECK_GT(hair->get_motion_steps(), 0);
size = hair->get_curve_keys().size() * (hair->get_motion_steps() - 1);
}
break;

View File

@ -322,15 +322,6 @@ bool RenderBuffers::get_pass_rect(
pixels[0] = saturate(f * scale_exposure);
}
}
#ifdef WITH_CYCLES_DEBUG
else if (type == PASS_BVH_TRAVERSED_NODES || type == PASS_BVH_TRAVERSED_INSTANCES ||
type == PASS_BVH_INTERSECTIONS || type == PASS_RAY_BOUNCES) {
for (int i = 0; i < size; i++, in += pass_stride, pixels++) {
float f = *in;
pixels[0] = f * scale;
}
}
#endif
else {
for (int i = 0; i < size; i++, in += pass_stride, pixels++) {
float f = *in;

View File

@ -51,12 +51,6 @@ static NodeEnum *get_pass_type_enum()
pass_type_enum.insert("material_id", PASS_MATERIAL_ID);
pass_type_enum.insert("motion", PASS_MOTION);
pass_type_enum.insert("motion_weight", PASS_MOTION_WEIGHT);
#ifdef __KERNEL_DEBUG__
pass_type_enum.insert("traversed_nodes", PASS_BVH_TRAVERSED_NODES);
pass_type_enum.insert("traverse_instances", PASS_BVH_TRAVERSED_INSTANCES);
pass_type_enum.insert("bvh_intersections", PASS_BVH_INTERSECTIONS);
pass_type_enum.insert("ray_bounces", PASS_RAY_BOUNCES);
#endif
pass_type_enum.insert("render_time", PASS_RENDER_TIME);
pass_type_enum.insert("cryptomatte", PASS_CRYPTOMATTE);
pass_type_enum.insert("aov_color", PASS_AOV_COLOR);
@ -200,15 +194,6 @@ void Pass::add(PassType type, vector<Pass> &passes, const char *name)
*/
pass.components = 0;
break;
#ifdef WITH_CYCLES_DEBUG
case PASS_BVH_TRAVERSED_NODES:
case PASS_BVH_TRAVERSED_INSTANCES:
case PASS_BVH_INTERSECTIONS:
case PASS_RAY_BOUNCES:
pass.components = 1;
pass.exposure = false;
break;
#endif
case PASS_RENDER_TIME:
/* This pass is handled entirely on the host side. */
pass.components = 0;
@ -570,20 +555,6 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
kfilm->pass_bake_differential = kfilm->pass_stride;
break;
#ifdef WITH_CYCLES_DEBUG
case PASS_BVH_TRAVERSED_NODES:
kfilm->pass_bvh_traversed_nodes = kfilm->pass_stride;
break;
case PASS_BVH_TRAVERSED_INSTANCES:
kfilm->pass_bvh_traversed_instances = kfilm->pass_stride;
break;
case PASS_BVH_INTERSECTIONS:
kfilm->pass_bvh_intersections = kfilm->pass_stride;
break;
case PASS_RAY_BOUNCES:
kfilm->pass_ray_bounces = kfilm->pass_stride;
break;
#endif
case PASS_RENDER_TIME:
break;
case PASS_CRYPTOMATTE:

View File

@ -356,7 +356,7 @@ class ShaderGraph : public NodeOwner {
/* This function is used to create a node of a specified type instead of
* calling 'new', and sets the graph as the owner of the node.
*/
template<typename T, typename... Args> T *create_node(Args &&... args)
template<typename T, typename... Args> T *create_node(Args &&...args)
{
T *node = new T(args...);
node->set_owner(this);

View File

@ -299,7 +299,7 @@ class Scene : public NodeOwner {
* node array (e.g. Scene::geometry for Geometry nodes) and tag the appropriate
* manager for an update.
*/
template<typename T, typename... Args> T *create_node(Args &&... args)
template<typename T, typename... Args> T *create_node(Args &&...args)
{
T *node = new T(args...);
node->set_owner(this);

View File

@ -57,7 +57,7 @@ struct avxb {
: m256(_mm256_insertf128_ps(_mm256_castps128_ps256(a), b, 1))
{
}
__forceinline operator const __m256 &(void)const
__forceinline operator const __m256 &(void) const
{
return m256;
}

View File

@ -54,7 +54,7 @@ struct avxi {
__forceinline avxi(const __m256i a) : m256(a)
{
}
__forceinline operator const __m256i &(void)const
__forceinline operator const __m256i &(void) const
{
return m256;
}

View File

@ -26,9 +26,9 @@
CCL_NAMESPACE_BEGIN
#ifdef WITH_CYCLES_LOGGING
static bool is_verbosity_set()
{
#ifdef WITH_CYCLES_LOGGING
using CYCLES_GFLAGS_NAMESPACE::GetCommandLineOption;
std::string verbosity;
@ -36,10 +36,8 @@ static bool is_verbosity_set()
return false;
}
return verbosity != "0";
#else
return false;
#endif
}
#endif
void util_logging_init(const char *argv0)
{

View File

@ -40,7 +40,7 @@ class LogMessageVoidify {
LogMessageVoidify()
{
}
void operator&(StubStream &)
void operator&(const StubStream &)
{
}
};
@ -49,6 +49,36 @@ class LogMessageVoidify {
# define LOG(severity) LOG_SUPPRESS()
# define VLOG(severity) LOG_SUPPRESS()
# define VLOG_IF(severity, condition) LOG_SUPPRESS()
# define CHECK(expression) LOG_SUPPRESS()
# define CHECK_NOTNULL(expression) LOG_SUPPRESS()
# define CHECK_NULL(expression) LOG_SUPPRESS()
# define CHECK_NEAR(actual, expected, eps) LOG_SUPPRESS()
# define CHECK_GE(a, b) LOG_SUPPRESS()
# define CHECK_NE(a, b) LOG_SUPPRESS()
# define CHECK_EQ(a, b) LOG_SUPPRESS()
# define CHECK_GT(a, b) LOG_SUPPRESS()
# define CHECK_LT(a, b) LOG_SUPPRESS()
# define CHECK_LE(a, b) LOG_SUPPRESS()
# define DCHECK(expression) LOG_SUPPRESS()
# define DCHECK_NOTNULL(expression) LOG_SUPPRESS()
# define DCHECK_NULL(expression) LOG_SUPPRESS()
# define DCHECK_NEAR(actual, expected, eps) LOG_SUPPRESS()
# define DCHECK_GE(a, b) LOG_SUPPRESS()
# define DCHECK_NE(a, b) LOG_SUPPRESS()
# define DCHECK_EQ(a, b) LOG_SUPPRESS()
# define DCHECK_GT(a, b) LOG_SUPPRESS()
# define DCHECK_LT(a, b) LOG_SUPPRESS()
# define DCHECK_LE(a, b) LOG_SUPPRESS()
# define LOG_ASSERT(expression) LOG_SUPPRESS()
#endif
#define VLOG_ONCE(level, flag) \

View File

@ -57,7 +57,7 @@ struct sseb {
__forceinline sseb(const __m128 input) : m128(input)
{
}
__forceinline operator const __m128 &(void)const
__forceinline operator const __m128 &(void) const
{
return m128;
}

View File

@ -57,7 +57,7 @@ struct ssei {
__forceinline ssei(const __m128i a) : m128(a)
{
}
__forceinline operator const __m128i &(void)const
__forceinline operator const __m128i &(void) const
{
return m128;
}

View File

@ -402,7 +402,9 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
if (!EGL_CHK(::eglInitialize(m_display, &egl_major, &egl_minor)))
goto error;
#ifdef WITH_GHOST_DEBUG
fprintf(stderr, "EGL Version %d.%d\n", egl_major, egl_minor);
#endif
if (!EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)))
goto error;

View File

@ -32,7 +32,7 @@
#include <cstdio>
#include <cstring>
/* needed for intel drivers (works w/ mesa-swrast & nvidia) */
/* Needed for Intel drivers (works with MESA-software-rasterizer (`swrast`) & NVIDIA). */
#define USE_GLXEW_INIT_WORKAROUND
#ifdef USE_GLXEW_INIT_WORKAROUND

View File

@ -475,16 +475,15 @@ int GHOST_ContextWGL::choose_pixel_format(bool stereoVisual, bool needAlpha)
PIXELFORMATDESCRIPTOR preferredPFD = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
1, /* version */
(DWORD)(
PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW |
PFD_DOUBLEBUFFER | /* support double-buffering */
(stereoVisual ? PFD_STEREO : 0) | /* support stereo */
(
(DWORD)(PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW |
PFD_DOUBLEBUFFER | /* support double-buffering */
(stereoVisual ? PFD_STEREO : 0) | /* support stereo */
(
#ifdef WIN32_COMPOSITING
needAlpha ?
PFD_SUPPORT_COMPOSITION : /* support composition for transparent background */
/* Support composition for transparent background. */
needAlpha ? PFD_SUPPORT_COMPOSITION :
#endif
0)),
0)),
PFD_TYPE_RGBA, /* color type */
(BYTE)(needAlpha ? 32 : 24), /* preferred color depth */
0,

View File

@ -1587,7 +1587,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
{
NSTimeInterval timestamp = [event timestamp];
if (timestamp < m_last_warp_timestamp) {
/* After warping we can still receive older unwarped mouse events,
/* After warping we can still receive older unwrapped mouse events,
* ignore those. */
break;
}

View File

@ -2111,10 +2111,9 @@ GHOST_TSuccess GHOST_SystemWin32::showMessageBox(const char *title,
config.cbSize = sizeof(config);
config.hInstance = 0;
config.dwCommonButtons = 0;
config.pszMainIcon = (dialog_options & GHOST_DialogError ?
TD_ERROR_ICON :
dialog_options & GHOST_DialogWarning ? TD_WARNING_ICON :
TD_INFORMATION_ICON);
config.pszMainIcon = (dialog_options & GHOST_DialogError ? TD_ERROR_ICON :
dialog_options & GHOST_DialogWarning ? TD_WARNING_ICON :
TD_INFORMATION_ICON);
config.pszWindowTitle = L"Blender";
config.pszMainInstruction = title_16;
config.pszContent = message_16;

View File

@ -1189,9 +1189,9 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
else {
printf("Bad keycode lookup. Keysym 0x%x Status: %s\n",
(unsigned int)key_sym,
(status == XLookupNone ?
"XLookupNone" :
status == XLookupKeySym ? "XLookupKeySym" : "Unknown status"));
(status == XLookupNone ? "XLookupNone" :
status == XLookupKeySym ? "XLookupKeySym" :
"Unknown status"));
printf("'%.*s' %p %p\n", len, utf8_buf, xic, m_xim);
}

View File

@ -299,9 +299,9 @@ template<class T> class MEM_CacheLimiter {
if (!can_destroy_element(elem))
continue;
/* by default 0 means highest priority element */
/* casting a size type to int is questionable,
but unlikely to cause problems */
/* By default 0 means highest priority element. */
/* Casting a size type to int is questionable,
* but unlikely to cause problems. */
int priority = -((int)(queue.size()) - i - 1);
priority = item_priority_func(elem->get()->get_data(), priority);

View File

@ -33,20 +33,20 @@ OpenVDBLevelSet::~OpenVDBLevelSet()
}
void OpenVDBLevelSet::mesh_to_level_set(const float *vertices,
const unsigned int *faces,
const unsigned int totvertices,
const unsigned int totfaces,
const int *faces,
const int totvertices,
const int totfaces,
const openvdb::math::Transform::Ptr &xform)
{
std::vector<openvdb::Vec3s> points(totvertices);
std::vector<openvdb::Vec3I> triangles(totfaces);
std::vector<openvdb::Vec4I> quads;
for (unsigned int i = 0; i < totvertices; i++) {
for (int i = 0; i < totvertices; i++) {
points[i] = openvdb::Vec3s(vertices[i * 3], vertices[i * 3 + 1], vertices[i * 3 + 2]);
}
for (unsigned int i = 0; i < totfaces; i++) {
for (int i = 0; i < totfaces; i++) {
triangles[i] = openvdb::Vec3I(faces[i * 3], faces[i * 3 + 1], faces[i * 3 + 2]);
}
@ -69,14 +69,11 @@ void OpenVDBLevelSet::volume_to_mesh(OpenVDBVolumeToMeshData *mesh,
isovalue,
adaptivity,
relax_disoriented_triangles);
mesh->vertices = (float *)MEM_malloc_arrayN(
out_points.size(), 3 * sizeof(float), "openvdb remesher out verts");
mesh->quads = (unsigned int *)MEM_malloc_arrayN(
out_quads.size(), 4 * sizeof(unsigned int), "openvdb remesh out quads");
mesh->vertices = (float *)MEM_malloc_arrayN(out_points.size(), sizeof(float[3]), __func__);
mesh->quads = (int *)MEM_malloc_arrayN(out_quads.size(), sizeof(int[4]), __func__);
mesh->triangles = NULL;
if (out_tris.size() > 0) {
mesh->triangles = (unsigned int *)MEM_malloc_arrayN(
out_tris.size(), 3 * sizeof(unsigned int), "openvdb remesh out tris");
mesh->triangles = (int *)MEM_malloc_arrayN(out_tris.size(), sizeof(int[3]), __func__);
}
mesh->totvertices = out_points.size();

View File

@ -39,9 +39,9 @@ struct OpenVDBLevelSet {
void set_grid(const openvdb::FloatGrid::Ptr &grid);
void mesh_to_level_set(const float *vertices,
const unsigned int *faces,
const unsigned int totvertices,
const unsigned int totfaces,
const int *faces,
const int totvertices,
const int totfaces,
const openvdb::math::Transform::Ptr &transform);
void volume_to_mesh(struct OpenVDBVolumeToMeshData *mesh,

View File

@ -63,9 +63,9 @@ void OpenVDBLevelSet_free(OpenVDBLevelSet *level_set)
void OpenVDBLevelSet_mesh_to_level_set(struct OpenVDBLevelSet *level_set,
const float *vertices,
const unsigned int *faces,
const unsigned int totvertices,
const unsigned int totfaces,
const int *faces,
const int totvertices,
const int totfaces,
OpenVDBTransform *xform)
{
level_set->mesh_to_level_set(vertices, faces, totvertices, totfaces, xform->get_transform());
@ -73,9 +73,9 @@ void OpenVDBLevelSet_mesh_to_level_set(struct OpenVDBLevelSet *level_set,
void OpenVDBLevelSet_mesh_to_level_set_transform(struct OpenVDBLevelSet *level_set,
const float *vertices,
const unsigned int *faces,
const unsigned int totvertices,
const unsigned int totfaces,
const int *faces,
const int totvertices,
const int totfaces,
OpenVDBTransform *transform)
{
level_set->mesh_to_level_set(vertices, faces, totvertices, totfaces, transform->get_transform());

View File

@ -67,19 +67,19 @@ struct OpenVDBVolumeToMeshData {
int totvertices;
float *vertices;
unsigned int *quads;
unsigned int *triangles;
int *quads;
int *triangles;
};
struct OpenVDBRemeshData {
float *verts;
unsigned int *faces;
int *faces;
int totfaces;
int totverts;
float *out_verts;
unsigned int *out_faces;
unsigned int *out_tris;
int *out_faces;
int *out_tris;
int out_totverts;
int out_totfaces;
int out_tottris;
@ -112,15 +112,15 @@ struct OpenVDBLevelSet *OpenVDBLevelSet_create(bool initGrid, struct OpenVDBTran
void OpenVDBLevelSet_free(struct OpenVDBLevelSet *level_set);
void OpenVDBLevelSet_mesh_to_level_set(struct OpenVDBLevelSet *level_set,
const float *vertices,
const unsigned int *faces,
const unsigned int totvertices,
const unsigned int totfaces,
const int *faces,
const int totvertices,
const int totfaces,
struct OpenVDBTransform *xform);
void OpenVDBLevelSet_mesh_to_level_set_transform(struct OpenVDBLevelSet *level_set,
const float *vertices,
const unsigned int *faces,
const unsigned int totvertices,
const unsigned int totfaces,
const int *faces,
const int totvertices,
const int totfaces,
struct OpenVDBTransform *transform);
void OpenVDBLevelSet_volume_to_mesh(struct OpenVDBLevelSet *level_set,
struct OpenVDBVolumeToMeshData *mesh,

View File

@ -20,12 +20,12 @@
#include "MEM_guardedalloc.h"
#include "quadriflow_capi.hpp"
#include "config.hpp"
#include "field-math.hpp"
#include "loader.hpp"
#include "optimizer.hpp"
#include "parametrizer.hpp"
#include "loader.hpp"
#include "quadriflow_capi.hpp"
using namespace qflow;
@ -217,10 +217,8 @@ void QFLOW_quadriflow_remesh(QuadriflowRemeshData *qrd,
qrd->out_totverts = field.O_compact.size();
qrd->out_totfaces = field.F_compact.size();
qrd->out_verts = (float *)MEM_malloc_arrayN(
qrd->out_totverts, 3 * sizeof(float), "quadriflow remesher out verts");
qrd->out_faces = (unsigned int *)MEM_malloc_arrayN(
qrd->out_totfaces, 4 * sizeof(unsigned int), "quadriflow remesh out quads");
qrd->out_verts = (float *)MEM_malloc_arrayN(qrd->out_totverts, sizeof(float[3]), __func__);
qrd->out_faces = (int *)MEM_malloc_arrayN(qrd->out_totfaces, sizeof(int[4]), __func__);
for (int i = 0; i < qrd->out_totverts; i++) {
auto t = field.O_compact[i] * field.normalize_scale + field.normalize_offset;

View File

@ -25,12 +25,12 @@ extern "C" {
typedef struct QuadriflowRemeshData {
float *verts;
unsigned int *faces;
int *faces;
int totfaces;
int totverts;
float *out_verts;
unsigned int *out_faces;
int *out_faces;
int out_totverts;
int out_totfaces;

View File

@ -638,7 +638,7 @@ const bTheme U_theme_default = {
.sub_back = RGBA(0x0000003e),
},
.shade1 = RGBA(0xa0a0a000),
.grid = RGBA(0x404040ff),
.grid = RGBA(0x212121ff),
.vertex_select = RGBA(0xff8500ff),
.bone_pose = RGBA(0x50c8ff50),
.cframe = RGBA(0x5680c2ff),

View File

@ -163,12 +163,12 @@ def import_from_id(template_id, *, ignore_not_found=False):
return import_from_path(path, ignore_not_found=ignore_not_found)
def activate(*, template_id=None):
def activate(*, template_id=None, reload_scripts=False):
template_id_prev = _app_template["id"]
# not needed but may as well avoids redundant
# disable/enable for all add-ons on 'File -> New'
if template_id_prev == template_id:
if not reload_scripts and template_id_prev == template_id:
return
if template_id_prev:
@ -188,6 +188,4 @@ def reset(*, reload_scripts=False):
if _bpy.app.debug_python:
print("bl_app_template_utils.reset('%s')" % template_id)
# TODO reload_scripts
activate(template_id=template_id)
activate(template_id=template_id, reload_scripts=reload_scripts)

View File

@ -105,6 +105,10 @@ class OUTLINER_MT_context_menu(Menu):
@staticmethod
def draw_common_operators(layout):
layout.menu_contents("OUTLINER_MT_asset")
layout.separator()
layout.menu("OUTLINER_MT_context_menu_view")
layout.separator()
@ -306,6 +310,22 @@ class OUTLINER_MT_object(Menu):
OUTLINER_MT_context_menu.draw_common_operators(layout)
class OUTLINER_MT_asset(Menu):
bl_label = "Assets"
@classmethod
def poll(cls, context):
return context.preferences.experimental.use_asset_browser
def draw(self, context):
layout = self.layout
space = context.space_data
layout.operator("asset.mark")
layout.operator("asset.clear")
class OUTLINER_PT_filter(Panel):
bl_space_type = 'OUTLINER'
bl_region_type = 'HEADER'
@ -451,6 +471,7 @@ classes = (
OUTLINER_MT_collection_visibility,
OUTLINER_MT_collection_view_layer,
OUTLINER_MT_object,
OUTLINER_MT_asset,
OUTLINER_MT_context_menu,
OUTLINER_MT_context_menu_view,
OUTLINER_PT_filter,

View File

@ -263,6 +263,7 @@ class SEQUENCER_PT_sequencer_overlay(Panel):
layout.prop(st, "show_strip_offset", text="Offsets")
layout.prop(st, "show_fcurves", text="F-Curves")
layout.prop(st, "show_grid", text="Grid")
layout.separator()

View File

@ -619,7 +619,7 @@ class USERPREF_PT_system_os_settings(SystemPanel, CenterAlignMixIn, Panel):
split = layout.split(factor=0.4)
split.alignment = 'RIGHT'
split.label(text="")
split.operator("file.associate_blend", text="Make Default")
split.operator("preferences.associate_blend", text="Make Default")
class USERPREF_PT_system_memory(SystemPanel, CenterAlignMixIn, Panel):

View File

@ -53,6 +53,8 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
void BLF_unload(const char *name) ATTR_NONNULL();
void BLF_unload_id(int fontid);
char *BLF_display_name_from_file(const char *filename);
/* Check if font supports a particular glyph. */
bool BLF_has_glyph(int fontid, unsigned int unicode);

View File

@ -915,6 +915,17 @@ void BLF_draw_buffer(int fontid, const char *str, size_t len)
BLF_draw_buffer_ex(fontid, str, len, NULL);
}
char *BLF_display_name_from_file(const char *filename)
{
FontBLF *font = blf_font_new("font_name", filename);
if (!font) {
return NULL;
}
char *name = blf_display_name(font);
blf_font_free(font);
return name;
}
#ifdef DEBUG
void BLF_state_print(int fontid)
{

View File

@ -1465,3 +1465,11 @@ float blf_font_ascender(FontBLF *font)
blf_glyph_cache_release(font);
return ascender;
}
char *blf_display_name(FontBLF *font)
{
if (!font->face->family_name) {
return NULL;
}
return BLI_sprintfN("%s %s", font->face->family_name, font->face->style_name);
}

View File

@ -99,6 +99,8 @@ int blf_font_width_max(struct FontBLF *font);
float blf_font_descender(struct FontBLF *font);
float blf_font_ascender(struct FontBLF *font);
char *blf_display_name(struct FontBLF *font);
void blf_font_boundbox_foreach_glyph(struct FontBLF *font,
const char *str,
size_t len,

View File

@ -19,6 +19,8 @@
* \ingroup bli
*/
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 13
#define BLENDER_FILE_SUBVERSION 15
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file

View File

@ -249,7 +249,10 @@ int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge,
((CHECK_TYPE_ANY( \
_tri, unsigned int *, int *, int[3], const unsigned int *, const int *, const int[3]), \
CHECK_TYPE_ANY(_v, unsigned int, const unsigned int, int, const int)), \
(((_tri)[0] == _v) ? 0 : ((_tri)[1] == _v) ? 1 : ((_tri)[2] == _v) ? 2 : -1))
(((_tri)[0] == _v) ? 0 : \
((_tri)[1] == _v) ? 1 : \
((_tri)[2] == _v) ? 2 : \
-1))
#ifdef __cplusplus
}

View File

@ -33,33 +33,23 @@ extern "C" {
struct Mesh;
/* OpenVDB Voxel Remesher */
#ifdef WITH_OPENVDB
struct OpenVDBLevelSet *BKE_mesh_remesh_voxel_ovdb_mesh_to_level_set_create(
struct Mesh *mesh, struct OpenVDBTransform *transform);
struct Mesh *BKE_mesh_remesh_voxel_ovdb_volume_to_mesh_nomain(struct OpenVDBLevelSet *level_set,
double isovalue,
double adaptivity,
bool relax_disoriented_triangles);
#endif
struct Mesh *BKE_mesh_remesh_voxel_fix_poles(struct Mesh *mesh);
struct Mesh *BKE_mesh_remesh_voxel_to_mesh_nomain(struct Mesh *mesh,
float voxel_size,
float adaptivity,
float isovalue);
struct Mesh *BKE_mesh_remesh_quadriflow_to_mesh_nomain(struct Mesh *mesh,
int target_faces,
int seed,
bool preserve_sharp,
bool preserve_boundary,
bool adaptive_scale,
void *update_cb,
void *update_cb_data);
struct Mesh *BKE_mesh_remesh_voxel_fix_poles(const struct Mesh *mesh);
struct Mesh *BKE_mesh_remesh_voxel(const struct Mesh *mesh,
float voxel_size,
float adaptivity,
float isovalue);
struct Mesh *BKE_mesh_remesh_quadriflow(const struct Mesh *mesh,
int target_faces,
int seed,
bool preserve_sharp,
bool preserve_boundary,
bool adaptive_scale,
void (*update_cb)(void *, float progress, int *cancel),
void *update_cb_data);
/* Data reprojection functions */
void BKE_mesh_remesh_reproject_paint_mask(struct Mesh *target, struct Mesh *source);
void BKE_remesh_reproject_vertex_paint(struct Mesh *target, struct Mesh *source);
void BKE_remesh_reproject_vertex_paint(struct Mesh *target, const struct Mesh *source);
void BKE_remesh_reproject_sculpt_face_sets(struct Mesh *target, struct Mesh *source);
void BKE_remesh_reproject_materials(struct Mesh *target, struct Mesh *source);
void BKE_mesh_remesh_sculpt_array_update(struct Object *ob, struct Mesh *target, struct Mesh *source);

View File

@ -118,7 +118,7 @@ void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C,
struct Object *ob_source,
struct Object *ob_target);
/* Used in object_remesh.c to preserve the details and volume in the voxel remesher */
/* Used in object_remesh.cc to preserve the details and volume in the voxel remesher */
void BKE_shrinkwrap_remesh_target_project(struct Mesh *src_me,
struct Mesh *target_me,
struct Object *ob_target);

View File

@ -194,7 +194,7 @@ set(SRC
intern/mesh_mirror.c
intern/mesh_normals.cc
intern/mesh_remap.c
intern/mesh_remesh_voxel.c
intern/mesh_remesh_voxel.cc
intern/mesh_runtime.c
intern/mesh_sample.cc
intern/mesh_tangent.c

View File

@ -148,8 +148,11 @@ KeyingSet *BKE_keyingset_add(
/* allocate new KeyingSet */
ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet");
BLI_strncpy(
ks->idname, (idname) ? idname : (name) ? name : DATA_("KeyingSet"), sizeof(ks->idname));
BLI_strncpy(ks->idname,
(idname) ? idname :
(name) ? name :
DATA_("KeyingSet"),
sizeof(ks->idname));
BLI_strncpy(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set"), sizeof(ks->name));
ks->flag = flag;

View File

@ -736,10 +736,12 @@ bool BKE_blendfile_userdef_write_all(ReportList *reports)
if (ok_write) {
printf("ok\n");
BKE_report(reports, RPT_INFO, "Preferences saved");
}
else {
printf("fail\n");
ok = false;
BKE_report(reports, RPT_ERROR, "Saving preferences failed");
}
}
else {

View File

@ -1809,125 +1809,6 @@ bool BKE_collection_objects_select(ViewLayer *view_layer, Collection *collection
/** \name Collection move (outliner drag & drop)
* \{ */
/* Local temporary storage for layer collection flags. */
typedef struct LayerCollectionFlag {
struct LayerCollectionFlag *next, *prev;
/** The view layer for the collections being moved, NULL for their children. */
ViewLayer *view_layer;
/** The original #LayerCollection's collection field. */
Collection *collection;
/** The original #LayerCollection's flag. */
int flag;
/** Corresponds to #LayerCollection->layer_collections. */
ListBase children;
} LayerCollectionFlag;
static void layer_collection_flags_store_recursive(const LayerCollection *layer_collection,
LayerCollectionFlag *flag)
{
flag->collection = layer_collection->collection;
flag->flag = layer_collection->flag;
LISTBASE_FOREACH (const LayerCollection *, child, &layer_collection->layer_collections) {
LayerCollectionFlag *child_flag = MEM_callocN(sizeof(LayerCollectionFlag), __func__);
BLI_addtail(&flag->children, child_flag);
layer_collection_flags_store_recursive(child, child_flag);
}
}
/**
* For every view layer, find the \a collection and save flags
* for it and its children in a temporary tree structure.
*/
static void layer_collection_flags_store(Main *bmain,
const Collection *collection,
ListBase *r_layer_level_list)
{
BLI_listbase_clear(r_layer_level_list);
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
view_layer, collection);
/* Skip this view layer if the collection isn't found for some reason. */
if (layer_collection == NULL) {
continue;
}
/* Store the flags for the collection and all of its children. */
LayerCollectionFlag *flag = MEM_callocN(sizeof(LayerCollectionFlag), __func__);
flag->view_layer = view_layer;
/* Recursively save flags from collection children. */
layer_collection_flags_store_recursive(layer_collection, flag);
BLI_addtail(r_layer_level_list, flag);
}
}
}
static void layer_collection_flags_free_recursive(LayerCollectionFlag *flag)
{
LISTBASE_FOREACH (LayerCollectionFlag *, child, &flag->children) {
layer_collection_flags_free_recursive(child);
}
BLI_freelistN(&flag->children);
}
static void layer_collection_flags_restore_recursive(LayerCollection *layer_collection,
LayerCollectionFlag *flag)
{
/* There should be a flag struct for every layer collection. */
BLI_assert(BLI_listbase_count(&layer_collection->layer_collections) ==
BLI_listbase_count(&flag->children));
/* The flag and the layer collection should actually correspond. */
BLI_assert(flag->collection == layer_collection->collection);
LayerCollectionFlag *child_flag = flag->children.first;
LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
layer_collection_flags_restore_recursive(child, child_flag);
child_flag = child_flag->next;
}
/* We treat exclude as a special case.
*
* If in a different view layer the parent collection was disabled (e.g., background)
* and now we moved a new collection to be part of the background this collection should
* probably be disabled.
*
* NOTE: If we were to also keep the exclude flag we would need to re-sync the collections.
*/
layer_collection->flag = flag->flag | (layer_collection->flag & LAYER_COLLECTION_EXCLUDE);
}
/**
* Restore a collection's (and its children's) flags for each view layer
* from the structure built in #layer_collection_flags_store.
*/
static void layer_collection_flags_restore(ListBase *flags, const Collection *collection)
{
LISTBASE_FOREACH (LayerCollectionFlag *, flag, flags) {
ViewLayer *view_layer = flag->view_layer;
/* The top level of flag structs must have this set. */
BLI_assert(view_layer != NULL);
LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
view_layer, collection);
/* Check that the collection is still in the scene (and therefore its view layers). In most
* cases this is true, but if we move a sub-collection shared by several scenes to a collection
* local to the target scene, it is effectively removed from every other scene's hierarchy
* (e.g. moving into current scene's master collection). Then the other scene's view layers
* won't contain a matching layer collection anymore, so there is nothing to restore to. */
if (layer_collection != NULL) {
layer_collection_flags_restore_recursive(layer_collection, flag);
}
layer_collection_flags_free_recursive(flag);
}
BLI_freelistN(flags);
}
bool BKE_collection_move(Main *bmain,
Collection *to_parent,
Collection *from_parent,
@ -1968,26 +1849,7 @@ bool BKE_collection_move(Main *bmain,
}
}
/* Make sure we store the flag of the layer collections before we remove and re-create them.
* Otherwise they will get lost and everything will be copied from the new parent collection.
* Don't use flag syncing when moving a collection to a different scene, as it no longer exists
* in the same view layers anyway. */
const bool do_flag_sync = BKE_scene_find_from_collection(bmain, to_parent) ==
BKE_scene_find_from_collection(bmain, collection);
ListBase layer_flags;
if (do_flag_sync) {
layer_collection_flags_store(bmain, collection, &layer_flags);
}
/* Create and remove layer collections. */
BKE_main_collection_sync(bmain);
/* Restore the original layer collection flags and free their temporary storage. */
if (do_flag_sync) {
layer_collection_flags_restore(&layer_flags, collection);
}
/* We need to sync it again to pass the correct flags to the collections objects. */
/* Update layer collections. */
BKE_main_collection_sync(bmain);
return true;

View File

@ -903,6 +903,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
Mesh *modified = nullptr;
float(*vertCos)[3] = nullptr;
int totvert = 0;
for (; md; md = md->next) {
const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
@ -929,7 +930,6 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
if (mti->type == eModifierTypeType_OnlyDeform ||
(mti->type == eModifierTypeType_DeformOrConstruct && !modified)) {
if (modified) {
int totvert = 0;
if (!vertCos) {
vertCos = BKE_mesh_vert_coords_alloc(modified, &totvert);
}
@ -939,7 +939,6 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
mti->deformVerts(md, &mectx_deform, modified, vertCos, totvert);
}
else {
int totvert = 0;
if (!vertCos) {
vertCos = displist_vert_coords_alloc(dispbase, &totvert);
}
@ -1668,7 +1667,7 @@ void BKE_displist_minmax(const ListBase *dispbase, float min[3], float max[3])
LISTBASE_FOREACH (const DispList *, dl, dispbase) {
const int tot = (dl->type == DL_INDEX3) ? dl->nr : dl->nr * dl->parts;
for (const int i : IndexRange(tot)) {
minmax_v3v3_v3(min, max, &dl->verts[i]);
minmax_v3v3_v3(min, max, &dl->verts[i * 3]);
}
if (tot != 0) {
doit = true;

View File

@ -23,7 +23,10 @@
#include <string.h>
#include "CLG_log.h"
#include "BLI_listbase.h"
#include "BLI_mempool.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_string_utils.h"
@ -63,6 +66,8 @@
#include "BLO_read_write.h"
static CLG_LogRef LOG = {"bke.layercollection"};
/* Set of flags which are dependent on a collection settings. */
static const short g_base_collection_flags = (BASE_VISIBLE_DEPSGRAPH | BASE_VISIBLE_VIEWLAYER |
BASE_SELECTABLE | BASE_ENABLED_VIEWPORT |
@ -174,8 +179,8 @@ static ViewLayer *view_layer_add(const char *name)
BLI_strncpy_utf8(view_layer->name, name, sizeof(view_layer->name));
/* Pure rendering pipeline settings. */
view_layer->layflag = 0x7FFF; /* solid ztra halo edge strand */
view_layer->passflag = SCE_PASS_COMBINED | SCE_PASS_Z;
view_layer->layflag = SCE_LAY_FLAG_DEFAULT;
view_layer->passflag = SCE_PASS_COMBINED;
view_layer->pass_alpha_threshold = 0.5f;
view_layer->cryptomatte_levels = 6;
view_layer->cryptomatte_flag = VIEW_LAYER_CRYPTOMATTE_ACCURATE;
@ -748,6 +753,11 @@ int BKE_layer_collection_findindex(ViewLayer *view_layer, const LayerCollection
*
* WARNING: This is not threadsafe at all, only use from main thread.
*
* NOTE: It is probably needed to use #BKE_main_collection_sync_remap instead
* of just #BKE_main_collection_sync after disabling LayerCollection resync,
* unless it is absolutely certain that no ID remapping (or any other process
* that may invalidate the caches) will happen while it is disabled.
*
* NOTE: This is a quick and safe band-aid around the long-known issue
* regarding this resync process.
* Proper fix would be to make resync itself lazy, i.e. only happen
@ -766,6 +776,194 @@ void BKE_layer_collection_resync_allow(void)
no_resync = false;
}
typedef struct LayerCollectionResync {
struct LayerCollectionResync *prev, *next;
/* Temp data used to generate a queue during valid layer search. See
* #layer_collection_resync_find. */
struct LayerCollectionResync *queue_next;
/* LayerCollection and Collection wrapped by this data. */
LayerCollection *layer;
Collection *collection;
/* Hierarchical relationships in the old, existing ViewLayer state (except for newly created
* layers). */
struct LayerCollectionResync *parent_layer_resync;
ListBase children_layer_resync;
/* This layer still points to a valid collection. */
bool is_usable;
/* This layer is still valid as a parent, i.e. at least one of its original layer children is
* usable and matches one of its current children collections. */
bool is_valid_as_parent;
/* This layer is still valid as a child, i.e. its original layer parent is usable and matches one
* of its current parents collections. */
bool is_valid_as_child;
/* This layer is still fully valid in the new collection hierarchy, i.e. itself and all of its
* parents fully match the current collection hierarchy.
* OR
* This layer has already been re-used to match the new collections hierarchy. */
bool is_used;
} LayerCollectionResync;
static LayerCollectionResync *layer_collection_resync_create_recurse(
LayerCollectionResync *parent_layer_resync, LayerCollection *layer, BLI_mempool *mempool)
{
LayerCollectionResync *layer_resync = BLI_mempool_calloc(mempool);
layer_resync->layer = layer;
layer_resync->collection = layer->collection;
layer_resync->parent_layer_resync = parent_layer_resync;
if (parent_layer_resync != NULL) {
BLI_addtail(&parent_layer_resync->children_layer_resync, layer_resync);
}
layer_resync->is_usable = (layer->collection != NULL);
layer_resync->is_valid_as_child =
layer_resync->is_usable && (parent_layer_resync == NULL ||
(parent_layer_resync->is_usable &&
BLI_findptr(&parent_layer_resync->layer->collection->children,
layer->collection,
offsetof(CollectionChild, collection)) != NULL));
if (layer_resync->is_valid_as_child) {
layer_resync->is_used = parent_layer_resync != NULL ? parent_layer_resync->is_used : true;
}
else {
layer_resync->is_used = false;
}
if (BLI_listbase_is_empty(&layer->layer_collections)) {
layer_resync->is_valid_as_parent = layer_resync->is_usable;
}
else {
LISTBASE_FOREACH (LayerCollection *, child_layer, &layer->layer_collections) {
LayerCollectionResync *child_layer_resync = layer_collection_resync_create_recurse(
layer_resync, child_layer, mempool);
if (layer_resync->is_usable && child_layer_resync->is_valid_as_child) {
layer_resync->is_valid_as_parent = true;
}
}
}
CLOG_INFO(&LOG,
4,
"Old LayerCollection for %s is...\n\tusable: %d\n\tvalid parent: %d\n\tvalid child: "
"%d\n\tused: %d\n",
layer_resync->collection ? layer_resync->collection->id.name : "<NONE>",
layer_resync->is_usable,
layer_resync->is_valid_as_parent,
layer_resync->is_valid_as_child,
layer_resync->is_used);
return layer_resync;
}
static LayerCollectionResync *layer_collection_resync_find(LayerCollectionResync *layer_resync,
Collection *child_collection)
{
/* Given the given parent, valid layer collection, find in the old hierarchy the best possible
* unused layer matching the given child collection.
*
* This uses the following heuristics:
* - Prefer a layer descendant of the given parent one if possible.
* - Prefer a layer as closely related as possible from the given parent.
* - Do not used layers that are not head (highest possible ancestor) of a local valid hierarchy
* branch, since we can assume we could then re-use its ancestor instead.
*
* A queue is used to ensure this order of preferences.
*/
BLI_assert(layer_resync->collection != child_collection);
BLI_assert(child_collection != NULL);
LayerCollectionResync *current_layer_resync = NULL;
LayerCollectionResync *root_layer_resync = layer_resync;
LayerCollectionResync *queue_head = layer_resync, *queue_tail = layer_resync;
layer_resync->queue_next = NULL;
while (queue_head != NULL) {
current_layer_resync = queue_head;
queue_head = current_layer_resync->queue_next;
if (current_layer_resync->collection == child_collection &&
(current_layer_resync->parent_layer_resync == layer_resync ||
(!current_layer_resync->is_used && !current_layer_resync->is_valid_as_child))) {
/* This layer is a valid candidate, because its collection matches the seeked one, AND:
* - It is a direct child of the initial given parent ('unchanged hierarchy' case), OR
* - It is not currently used, and not part of a valid hierarchy (sub-)chain.
*/
break;
}
/* Else, add all its direct children for further searching. */
LISTBASE_FOREACH (LayerCollectionResync *,
child_layer_resync,
&current_layer_resync->children_layer_resync) {
/* Add to tail of the queue. */
queue_tail->queue_next = child_layer_resync;
child_layer_resync->queue_next = NULL;
queue_tail = child_layer_resync;
if (queue_head == NULL) {
queue_head = queue_tail;
}
}
/* If all descendants from current layer have been processed, go one step higher and
* process all of its other siblings. */
if (queue_head == NULL && root_layer_resync->parent_layer_resync != NULL) {
LISTBASE_FOREACH (LayerCollectionResync *,
sibling_layer_resync,
&root_layer_resync->parent_layer_resync->children_layer_resync) {
if (sibling_layer_resync == root_layer_resync) {
continue;
}
/* Add to tail of the queue. */
queue_tail->queue_next = sibling_layer_resync;
sibling_layer_resync->queue_next = NULL;
queue_tail = sibling_layer_resync;
if (queue_head == NULL) {
queue_head = queue_tail;
}
}
root_layer_resync = root_layer_resync->parent_layer_resync;
}
current_layer_resync = NULL;
}
return current_layer_resync;
}
static void layer_collection_resync_unused_layers_free(ViewLayer *view_layer,
LayerCollectionResync *layer_resync)
{
LISTBASE_FOREACH (
LayerCollectionResync *, child_layer_resync, &layer_resync->children_layer_resync) {
layer_collection_resync_unused_layers_free(view_layer, child_layer_resync);
}
if (!layer_resync->is_used) {
CLOG_INFO(&LOG,
4,
"Freeing unused LayerCollection for %s",
layer_resync->collection != NULL ? layer_resync->collection->id.name :
"<Deleted Collection>");
if (layer_resync->layer == view_layer->active_collection) {
view_layer->active_collection = NULL;
}
/* We do not want to go recursive here, this is handled through the LayerCollectionResync data
* wrapper. */
MEM_freeN(layer_resync->layer);
layer_resync->layer = NULL;
layer_resync->collection = NULL;
layer_resync->is_usable = false;
}
}
static void layer_collection_objects_sync(ViewLayer *view_layer,
LayerCollection *layer,
ListBase *r_lb_new_object_bases,
@ -834,55 +1032,91 @@ static void layer_collection_objects_sync(ViewLayer *view_layer,
}
static void layer_collection_sync(ViewLayer *view_layer,
const ListBase *lb_children_collections,
ListBase *r_lb_children_layers,
LayerCollectionResync *layer_resync,
BLI_mempool *layer_resync_mempool,
ListBase *r_lb_new_object_bases,
const short parent_layer_flag,
const short parent_collection_restrict,
const short parent_layer_restrict,
const ushort parent_local_collections_bits)
{
/* TODO: support recovery after removal of intermediate collections, reordering, ..
* For local edits we can make editing operating do the appropriate thing, but for
* linking we can only sync after the fact. */
/* This function assumes current 'parent' layer collection is already fully (re)synced and valid
* regarding current Collection hierarchy.
*
* It will process all the children collections of the collection from the given 'parent' layer,
* re-use or create layer collections for each of them, and ensure orders also match.
*
* Then it will ensure that the objects owned by the given parent collection have a proper base.
*
* NOTE: This process is recursive.
*/
/* Remove layer collections that no longer have a corresponding scene collection. */
LISTBASE_FOREACH_MUTABLE (LayerCollection *, child_layer, r_lb_children_layers) {
/* Note that ID remap can set child_layer->collection to NULL when deleting collections. */
Collection *child_collection = (child_layer->collection != NULL) ?
BLI_findptr(lb_children_collections,
child_layer->collection,
offsetof(CollectionChild, collection)) :
NULL;
/* Temporary storage for all valid (new or reused) children layers. */
ListBase new_lb_layer = {NULL, NULL};
if (child_collection == NULL) {
if (child_layer == view_layer->active_collection) {
view_layer->active_collection = NULL;
BLI_assert(layer_resync->is_used);
LISTBASE_FOREACH (CollectionChild *, child, &layer_resync->collection->children) {
Collection *child_collection = child->collection;
LayerCollectionResync *child_layer_resync = layer_collection_resync_find(layer_resync,
child_collection);
if (child_layer_resync != NULL) {
BLI_assert(child_layer_resync->collection != NULL);
BLI_assert(child_layer_resync->layer != NULL);
BLI_assert(child_layer_resync->is_usable);
if (child_layer_resync->is_used) {
CLOG_INFO(&LOG,
4,
"Found same existing LayerCollection for %s as child of %s",
child_collection->id.name,
layer_resync->collection->id.name);
}
else {
CLOG_INFO(&LOG,
4,
"Found a valid unused LayerCollection for %s as child of %s, re-using it",
child_collection->id.name,
layer_resync->collection->id.name);
}
/* Free recursively. */
layer_collection_free(view_layer, child_layer);
BLI_freelinkN(r_lb_children_layers, child_layer);
}
}
child_layer_resync->is_used = true;
/* Add layer collections for any new scene collections, and ensure order is the same. */
ListBase lb_new_children_layers = {NULL, NULL};
LISTBASE_FOREACH (const CollectionChild *, child, lb_children_collections) {
Collection *child_collection = child->collection;
LayerCollection *child_layer = BLI_findptr(
r_lb_children_layers, child_collection, offsetof(LayerCollection, collection));
if (child_layer) {
BLI_remlink(r_lb_children_layers, child_layer);
BLI_addtail(&lb_new_children_layers, child_layer);
/* NOTE: Do not move the resync wrapper to match the new layer hierarchy, so that the old
* parenting info remains available. In case a search for a valid layer in the children of
* the current is required again, the old parenting hierarchy is needed as reference, not the
* new one.
*/
BLI_remlink(&child_layer_resync->parent_layer_resync->layer->layer_collections,
child_layer_resync->layer);
BLI_addtail(&new_lb_layer, child_layer_resync->layer);
}
else {
child_layer = layer_collection_add(&lb_new_children_layers, child_collection);
CLOG_INFO(&LOG,
4,
"No available LayerCollection for %s as child of %s, creating a new one",
child_collection->id.name,
layer_resync->collection->id.name);
LayerCollection *child_layer = layer_collection_add(&new_lb_layer, child_collection);
child_layer->flag = parent_layer_flag;
child_layer_resync = BLI_mempool_calloc(layer_resync_mempool);
child_layer_resync->collection = child_collection;
child_layer_resync->layer = child_layer;
child_layer_resync->is_usable = true;
child_layer_resync->is_used = true;
child_layer_resync->is_valid_as_child = true;
child_layer_resync->is_valid_as_parent = true;
/* NOTE: Needs to be added to the layer_resync hierarchy so that the resync wrapper gets
* freed at the end. */
child_layer_resync->parent_layer_resync = layer_resync;
BLI_addtail(&layer_resync->children_layer_resync, child_layer_resync);
}
LayerCollection *child_layer = child_layer_resync->layer;
const ushort child_local_collections_bits = parent_local_collections_bits &
child_layer->local_collections_bits;
@ -900,16 +1134,15 @@ static void layer_collection_sync(ViewLayer *view_layer,
/* Sync child collections. */
layer_collection_sync(view_layer,
&child_collection->children,
&child_layer->layer_collections,
child_layer_resync,
layer_resync_mempool,
r_lb_new_object_bases,
child_layer->flag,
child_collection_restrict,
child_layer_restrict,
child_local_collections_bits);
/* Layer collection exclude is not inherited, we can skip the remaining process, including
* object bases synchronization. */
/* Layer collection exclude is not inherited. */
child_layer->runtime_flag = 0;
if (child_layer->flag & LAYER_COLLECTION_EXCLUDE) {
continue;
@ -925,34 +1158,20 @@ static void layer_collection_sync(ViewLayer *view_layer,
((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0)) {
child_layer->runtime_flag |= LAYER_COLLECTION_VISIBLE_VIEW_LAYER;
}
layer_collection_objects_sync(view_layer,
child_layer,
r_lb_new_object_bases,
child_collection_restrict,
child_layer_restrict,
child_local_collections_bits);
}
/* Free potentially remaining unused layer collections in old list.
* NOTE: While this does not happen in typical situations, some corner cases (like remapping
* several different collections to a single one) can lead to this list having extra unused
* items. */
LISTBASE_FOREACH_MUTABLE (LayerCollection *, lc, r_lb_children_layers) {
if (lc == view_layer->active_collection) {
view_layer->active_collection = NULL;
}
/* Free recursively. */
layer_collection_free(view_layer, lc);
BLI_freelinkN(r_lb_children_layers, lc);
}
BLI_assert(BLI_listbase_is_empty(r_lb_children_layers));
/* Replace layer collection list with new one. */
*r_lb_children_layers = lb_new_children_layers;
BLI_assert(BLI_listbase_count(lb_children_collections) ==
BLI_listbase_count(r_lb_children_layers));
layer_resync->layer->layer_collections = new_lb_layer;
BLI_assert(BLI_listbase_count(&layer_resync->collection->children) ==
BLI_listbase_count(&new_lb_layer));
/* Update bases etc. for objects. */
layer_collection_objects_sync(view_layer,
layer_resync->layer,
r_lb_new_object_bases,
parent_collection_restrict,
parent_layer_restrict,
parent_local_collections_bits);
}
/**
@ -971,6 +1190,12 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
return;
}
/* In some cases (from older files) we do have a master collection, yet no matching layer. Create
* the master one here, so that the rest of the code can work as expected. */
if (BLI_listbase_is_empty(&view_layer->layer_collections)) {
layer_collection_add(&view_layer->layer_collections, scene->master_collection);
}
/* Free cache. */
MEM_SAFE_FREE(view_layer->object_bases_array);
@ -985,21 +1210,29 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
base->flag_from_collection &= ~g_base_collection_flags;
}
/* Generate new layer connections and object bases when collections changed. */
CollectionChild child = {.next = NULL, .prev = NULL, .collection = scene->master_collection};
const ListBase collections = {.first = &child, .last = &child};
ListBase new_object_bases = {.first = NULL, .last = NULL};
/* Generate temporary data representing the old layers hierarchy, and how well it matches the
* new collections hierarchy. */
BLI_mempool *layer_resync_mempool = BLI_mempool_create(
sizeof(LayerCollectionResync), 1024, 1024, BLI_MEMPOOL_NOP);
LayerCollectionResync *master_layer_resync = layer_collection_resync_create_recurse(
NULL, view_layer->layer_collections.first, layer_resync_mempool);
/* Generate new layer connections and object bases when collections changed. */
ListBase new_object_bases = {.first = NULL, .last = NULL};
const short parent_exclude = 0, parent_restrict = 0, parent_layer_restrict = 0;
layer_collection_sync(view_layer,
&collections,
&view_layer->layer_collections,
master_layer_resync,
layer_resync_mempool,
&new_object_bases,
parent_exclude,
parent_restrict,
parent_layer_restrict,
~(0));
layer_collection_resync_unused_layers_free(view_layer, master_layer_resync);
BLI_mempool_destroy(layer_resync_mempool);
master_layer_resync = NULL;
/* Any remaining object bases are to be removed. */
LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (view_layer->basact == base) {

View File

@ -772,7 +772,11 @@ static void lib_override_library_create_post_process(Main *bmain,
/* NOTE: We only care about local IDs here, if a linked object is not instantiated in any way we
* do not do anything about it. */
BKE_main_collection_sync(bmain);
/* We need to use the `_remap` version here as we prevented any LayerCollection resync during the
* whole liboverride resyncing, which involves a lot of ID remapping.
*
* Otherwise, cached Base GHash e.g. can contain invalid stale data. */
BKE_main_collection_sync_remap(bmain);
/* We create a set of all objects referenced into the scene by its hierarchy of collections.
* NOTE: This is different that the list of bases, since objects in excluded collections etc.

View File

@ -157,7 +157,7 @@ void BKE_main_idmap_insert_id(struct IDNameLib_Map *id_map, ID *id)
const short id_type = GS(id->name);
struct IDNameLib_TypeMap *type_map = main_idmap_from_idcode(id_map, id_type);
/* No need to do anything if map has not been lazyly created yet. */
/* No need to do anything if map has not been lazily created yet. */
if (LIKELY(type_map != NULL) && type_map->map != NULL) {
BLI_assert(id_map->type_maps_keys_pool != NULL);
@ -187,7 +187,7 @@ void BKE_main_idmap_remove_id(struct IDNameLib_Map *id_map, ID *id)
const short id_type = GS(id->name);
struct IDNameLib_TypeMap *type_map = main_idmap_from_idcode(id_map, id_type);
/* No need to do anything if map has not been lazyly created yet. */
/* No need to do anything if map has not been lazily created yet. */
if (LIKELY(type_map != NULL) && type_map->map != NULL) {
BLI_assert(id_map->type_maps_keys_pool != NULL);

View File

@ -21,22 +21,22 @@
* \ingroup bke
*/
#include <ctype.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <cctype>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_array.hh"
#include "BLI_float3.hh"
#include "BLI_index_range.hh"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "BKE_bvhutils.h"
#include "BKE_customdata.h"
@ -57,50 +57,181 @@
# include "quadriflow_capi.hpp"
#endif
#ifdef WITH_OPENVDB
struct OpenVDBLevelSet *BKE_mesh_remesh_voxel_ovdb_mesh_to_level_set_create(
Mesh *mesh, struct OpenVDBTransform *transform)
using blender::Array;
using blender::float3;
using blender::IndexRange;
#ifdef WITH_QUADRIFLOW
static Mesh *remesh_quadriflow(const Mesh *input_mesh,
int target_faces,
int seed,
bool preserve_sharp,
bool preserve_boundary,
bool adaptive_scale,
void (*update_cb)(void *, float progress, int *cancel),
void *update_cb_data)
{
/* Ensure that the triangulated mesh data is up to data */
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(input_mesh);
/* Gather the required data for export to the internal quadiflow mesh format */
MVertTri *verttri = (MVertTri *)MEM_callocN(
sizeof(*verttri) * BKE_mesh_runtime_looptri_len(input_mesh), "remesh_looptri");
BKE_mesh_runtime_verttri_from_looptri(
verttri, input_mesh->mloop, looptri, BKE_mesh_runtime_looptri_len(input_mesh));
const int totfaces = BKE_mesh_runtime_looptri_len(input_mesh);
const int totverts = input_mesh->totvert;
Array<float3> verts(totverts);
Array<int> faces(totfaces * 3);
for (const int i : IndexRange(totverts)) {
verts[i] = input_mesh->mvert[i].co;
}
for (const int i : IndexRange(totfaces)) {
MVertTri &vt = verttri[i];
faces[i * 3] = vt.tri[0];
faces[i * 3 + 1] = vt.tri[1];
faces[i * 3 + 2] = vt.tri[2];
}
/* Fill out the required input data */
QuadriflowRemeshData qrd;
qrd.totfaces = totfaces;
qrd.totverts = totverts;
qrd.verts = (float *)verts.data();
qrd.faces = faces.data();
qrd.target_faces = target_faces;
qrd.preserve_sharp = preserve_sharp;
qrd.preserve_boundary = preserve_boundary;
qrd.adaptive_scale = adaptive_scale;
qrd.minimum_cost_flow = false;
qrd.aggresive_sat = false;
qrd.rng_seed = seed;
qrd.out_faces = nullptr;
/* Run the remesher */
QFLOW_quadriflow_remesh(&qrd, update_cb, update_cb_data);
MEM_freeN(verttri);
if (qrd.out_faces == nullptr) {
/* The remeshing was canceled */
return nullptr;
}
if (qrd.out_totfaces == 0) {
/* Meshing failed */
MEM_freeN(qrd.out_faces);
MEM_freeN(qrd.out_verts);
return nullptr;
}
/* Construct the new output mesh */
Mesh *mesh = BKE_mesh_new_nomain(qrd.out_totverts, 0, 0, qrd.out_totfaces * 4, qrd.out_totfaces);
for (const int i : IndexRange(qrd.out_totverts)) {
copy_v3_v3(mesh->mvert[i].co, &qrd.out_verts[i * 3]);
}
for (const int i : IndexRange(qrd.out_totfaces)) {
MPoly &poly = mesh->mpoly[i];
const int loopstart = i * 4;
poly.loopstart = loopstart;
poly.totloop = 4;
mesh->mloop[loopstart].v = qrd.out_faces[loopstart];
mesh->mloop[loopstart + 1].v = qrd.out_faces[loopstart + 1];
mesh->mloop[loopstart + 2].v = qrd.out_faces[loopstart + 2];
mesh->mloop[loopstart + 3].v = qrd.out_faces[loopstart + 3];
}
BKE_mesh_calc_edges(mesh, false, false);
BKE_mesh_calc_normals(mesh);
MEM_freeN(qrd.out_faces);
MEM_freeN(qrd.out_verts);
return mesh;
}
#endif
Mesh *BKE_mesh_remesh_quadriflow(const Mesh *mesh,
int target_faces,
int seed,
bool preserve_sharp,
bool preserve_boundary,
bool adaptive_scale,
void (*update_cb)(void *, float progress, int *cancel),
void *update_cb_data)
{
#ifdef WITH_QUADRIFLOW
if (target_faces <= 0) {
target_faces = -1;
}
return remesh_quadriflow(mesh,
target_faces,
seed,
preserve_sharp,
preserve_boundary,
adaptive_scale,
update_cb,
update_cb_data);
#else
UNUSED_VARS(mesh,
target_faces,
seed,
preserve_sharp,
preserve_boundary,
adaptive_scale,
update_cb,
update_cb_data);
return nullptr;
#endif
}
#ifdef WITH_OPENVDB
static struct OpenVDBLevelSet *remesh_voxel_level_set_create(const Mesh *mesh,
struct OpenVDBTransform *transform)
{
BKE_mesh_runtime_looptri_recalc(mesh);
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(mesh);
MVertTri *verttri = MEM_callocN(sizeof(*verttri) * BKE_mesh_runtime_looptri_len(mesh),
"remesh_looptri");
MVertTri *verttri = (MVertTri *)MEM_callocN(
sizeof(*verttri) * BKE_mesh_runtime_looptri_len(mesh), "remesh_looptri");
BKE_mesh_runtime_verttri_from_looptri(
verttri, mesh->mloop, looptri, BKE_mesh_runtime_looptri_len(mesh));
uint totfaces = BKE_mesh_runtime_looptri_len(mesh);
uint totverts = mesh->totvert;
float *verts = (float *)MEM_malloc_arrayN(totverts * 3, sizeof(float), "remesh_input_verts");
uint *faces = (uint *)MEM_malloc_arrayN(totfaces * 3, sizeof(uint), "remesh_input_faces");
const int totfaces = BKE_mesh_runtime_looptri_len(mesh);
const int totverts = mesh->totvert;
Array<float3> verts(totverts);
Array<int> faces(totfaces * 3);
for (uint i = 0; i < totverts; i++) {
MVert *mvert = &mesh->mvert[i];
verts[i * 3] = mvert->co[0];
verts[i * 3 + 1] = mvert->co[1];
verts[i * 3 + 2] = mvert->co[2];
for (const int i : IndexRange(totverts)) {
verts[i] = mesh->mvert[i].co;
}
for (uint i = 0; i < totfaces; i++) {
MVertTri *vt = &verttri[i];
faces[i * 3] = vt->tri[0];
faces[i * 3 + 1] = vt->tri[1];
faces[i * 3 + 2] = vt->tri[2];
for (const int i : IndexRange(totfaces)) {
MVertTri &vt = verttri[i];
faces[i * 3] = vt.tri[0];
faces[i * 3 + 1] = vt.tri[1];
faces[i * 3 + 2] = vt.tri[2];
}
struct OpenVDBLevelSet *level_set = OpenVDBLevelSet_create(false, NULL);
OpenVDBLevelSet_mesh_to_level_set(level_set, verts, faces, totverts, totfaces, transform);
struct OpenVDBLevelSet *level_set = OpenVDBLevelSet_create(false, nullptr);
OpenVDBLevelSet_mesh_to_level_set(
level_set, (const float *)verts.data(), faces.data(), totverts, totfaces, transform);
MEM_freeN(verts);
MEM_freeN(faces);
MEM_freeN(verttri);
return level_set;
}
Mesh *BKE_mesh_remesh_voxel_ovdb_volume_to_mesh_nomain(struct OpenVDBLevelSet *level_set,
double isovalue,
double adaptivity,
bool relax_disoriented_triangles)
static Mesh *remesh_voxel_volume_to_mesh(struct OpenVDBLevelSet *level_set,
double isovalue,
double adaptivity,
bool relax_disoriented_triangles)
{
struct OpenVDBVolumeToMeshData output_mesh;
OpenVDBLevelSet_volume_to_mesh(
@ -112,29 +243,31 @@ Mesh *BKE_mesh_remesh_voxel_ovdb_volume_to_mesh_nomain(struct OpenVDBLevelSet *l
(output_mesh.totquads * 4) + (output_mesh.tottriangles * 3),
output_mesh.totquads + output_mesh.tottriangles);
for (int i = 0; i < output_mesh.totvertices; i++) {
for (const int i : IndexRange(output_mesh.totvertices)) {
copy_v3_v3(mesh->mvert[i].co, &output_mesh.vertices[i * 3]);
}
MPoly *mp = mesh->mpoly;
MLoop *ml = mesh->mloop;
for (int i = 0; i < output_mesh.totquads; i++, mp++, ml += 4) {
mp->loopstart = (int)(ml - mesh->mloop);
mp->totloop = 4;
ml[0].v = output_mesh.quads[i * 4 + 3];
ml[1].v = output_mesh.quads[i * 4 + 2];
ml[2].v = output_mesh.quads[i * 4 + 1];
ml[3].v = output_mesh.quads[i * 4];
for (const int i : IndexRange(output_mesh.totquads)) {
MPoly &poly = mesh->mpoly[i];
const int loopstart = i * 4;
poly.loopstart = loopstart;
poly.totloop = 4;
mesh->mloop[loopstart].v = output_mesh.quads[loopstart];
mesh->mloop[loopstart + 1].v = output_mesh.quads[loopstart + 1];
mesh->mloop[loopstart + 2].v = output_mesh.quads[loopstart + 2];
mesh->mloop[loopstart + 3].v = output_mesh.quads[loopstart + 3];
}
for (int i = 0; i < output_mesh.tottriangles; i++, mp++, ml += 3) {
mp->loopstart = (int)(ml - mesh->mloop);
mp->totloop = 3;
ml[0].v = output_mesh.triangles[i * 3 + 2];
ml[1].v = output_mesh.triangles[i * 3 + 1];
ml[2].v = output_mesh.triangles[i * 3];
const int triangle_poly_start = output_mesh.totquads;
const int triangle_loop_start = output_mesh.totquads * 4;
for (const int i : IndexRange(output_mesh.tottriangles)) {
MPoly &poly = mesh->mpoly[triangle_poly_start + i];
const int loopstart = triangle_loop_start + i * 3;
poly.loopstart = loopstart;
poly.totloop = 3;
mesh->mloop[loopstart].v = output_mesh.triangles[i * 3 + 2];
mesh->mloop[loopstart + 1].v = output_mesh.triangles[i * 3 + 1];
mesh->mloop[loopstart + 2].v = output_mesh.triangles[i * 3];
}
BKE_mesh_calc_edges(mesh, false, false);
@ -151,192 +284,48 @@ Mesh *BKE_mesh_remesh_voxel_ovdb_volume_to_mesh_nomain(struct OpenVDBLevelSet *l
}
#endif
#ifdef WITH_QUADRIFLOW
static Mesh *BKE_mesh_remesh_quadriflow(Mesh *input_mesh,
int target_faces,
int seed,
bool preserve_sharp,
bool preserve_boundary,
bool adaptive_scale,
void *update_cb,
void *update_cb_data)
Mesh *BKE_mesh_remesh_voxel(const Mesh *mesh,
const float voxel_size,
const float adaptivity,
const float isovalue)
{
/* Ensure that the triangulated mesh data is up to data */
BKE_mesh_runtime_looptri_recalc(input_mesh);
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(input_mesh);
/* Gather the required data for export to the internal quadiflow mesh format */
MVertTri *verttri = MEM_callocN(sizeof(*verttri) * BKE_mesh_runtime_looptri_len(input_mesh),
"remesh_looptri");
BKE_mesh_runtime_verttri_from_looptri(
verttri, input_mesh->mloop, looptri, BKE_mesh_runtime_looptri_len(input_mesh));
uint totfaces = BKE_mesh_runtime_looptri_len(input_mesh);
uint totverts = input_mesh->totvert;
float *verts = (float *)MEM_malloc_arrayN(totverts * 3, sizeof(float), "remesh_input_verts");
uint *faces = (uint *)MEM_malloc_arrayN(totfaces * 3, sizeof(uint), "remesh_input_faces");
for (uint i = 0; i < totverts; i++) {
MVert *mvert = &input_mesh->mvert[i];
verts[i * 3] = mvert->co[0];
verts[i * 3 + 1] = mvert->co[1];
verts[i * 3 + 2] = mvert->co[2];
}
for (uint i = 0; i < totfaces; i++) {
MVertTri *vt = &verttri[i];
faces[i * 3] = vt->tri[0];
faces[i * 3 + 1] = vt->tri[1];
faces[i * 3 + 2] = vt->tri[2];
}
/* Fill out the required input data */
QuadriflowRemeshData qrd;
qrd.totfaces = totfaces;
qrd.totverts = totverts;
qrd.verts = verts;
qrd.faces = faces;
qrd.target_faces = target_faces;
qrd.preserve_sharp = preserve_sharp;
qrd.preserve_boundary = preserve_boundary;
qrd.adaptive_scale = adaptive_scale;
qrd.minimum_cost_flow = 0;
qrd.aggresive_sat = 0;
qrd.rng_seed = seed;
qrd.out_faces = NULL;
/* Run the remesher */
QFLOW_quadriflow_remesh(&qrd, update_cb, update_cb_data);
MEM_freeN(verts);
MEM_freeN(faces);
MEM_freeN(verttri);
if (qrd.out_faces == NULL) {
/* The remeshing was canceled */
return NULL;
}
if (qrd.out_totfaces == 0) {
/* Meshing failed */
MEM_freeN(qrd.out_faces);
MEM_freeN(qrd.out_verts);
return NULL;
}
/* Construct the new output mesh */
Mesh *mesh = BKE_mesh_new_nomain(
qrd.out_totverts, 0, 0, (qrd.out_totfaces * 4), qrd.out_totfaces);
for (int i = 0; i < qrd.out_totverts; i++) {
copy_v3_v3(mesh->mvert[i].co, &qrd.out_verts[i * 3]);
}
MPoly *mp = mesh->mpoly;
MLoop *ml = mesh->mloop;
for (int i = 0; i < qrd.out_totfaces; i++, mp++, ml += 4) {
mp->loopstart = (int)(ml - mesh->mloop);
mp->totloop = 4;
ml[0].v = qrd.out_faces[i * 4];
ml[1].v = qrd.out_faces[i * 4 + 1];
ml[2].v = qrd.out_faces[i * 4 + 2];
ml[3].v = qrd.out_faces[i * 4 + 3];
}
BKE_mesh_calc_edges(mesh, false, false);
BKE_mesh_calc_normals(mesh);
MEM_freeN(qrd.out_faces);
MEM_freeN(qrd.out_verts);
return mesh;
}
#endif
Mesh *BKE_mesh_remesh_quadriflow_to_mesh_nomain(Mesh *mesh,
int target_faces,
int seed,
bool preserve_sharp,
bool preserve_boundary,
bool adaptive_scale,
void *update_cb,
void *update_cb_data)
{
Mesh *new_mesh = NULL;
#ifdef WITH_QUADRIFLOW
if (target_faces <= 0) {
target_faces = -1;
}
new_mesh = BKE_mesh_remesh_quadriflow(mesh,
target_faces,
seed,
preserve_sharp,
preserve_boundary,
adaptive_scale,
update_cb,
update_cb_data);
#else
UNUSED_VARS(mesh,
target_faces,
seed,
preserve_sharp,
preserve_boundary,
adaptive_scale,
update_cb,
update_cb_data);
#endif
return new_mesh;
}
Mesh *BKE_mesh_remesh_voxel_to_mesh_nomain(Mesh *mesh,
float voxel_size,
float adaptivity,
float isovalue)
{
Mesh *new_mesh = NULL;
#ifdef WITH_OPENVDB
struct OpenVDBLevelSet *level_set;
struct OpenVDBTransform *xform = OpenVDBTransform_create();
OpenVDBTransform_create_linear_transform(xform, (double)voxel_size);
level_set = BKE_mesh_remesh_voxel_ovdb_mesh_to_level_set_create(mesh, xform);
new_mesh = BKE_mesh_remesh_voxel_ovdb_volume_to_mesh_nomain(
struct OpenVDBLevelSet *level_set = remesh_voxel_level_set_create(mesh, xform);
Mesh *new_mesh = remesh_voxel_volume_to_mesh(
level_set, (double)isovalue, (double)adaptivity, false);
OpenVDBLevelSet_free(level_set);
OpenVDBTransform_free(xform);
return new_mesh;
#else
UNUSED_VARS(mesh, voxel_size, adaptivity, isovalue);
return nullptr;
#endif
return new_mesh;
}
void BKE_mesh_remesh_reproject_paint_mask(Mesh *target, Mesh *source)
{
BVHTreeFromMesh bvhtree = {
.nearest_callback = NULL,
};
BVHTreeFromMesh bvhtree = {{nullptr}};
BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_VERTS, 2);
MVert *target_verts = CustomData_get_layer(&target->vdata, CD_MVERT);
MVert *target_verts = (MVert *)CustomData_get_layer(&target->vdata, CD_MVERT);
float *target_mask;
if (CustomData_has_layer(&target->vdata, CD_PAINT_MASK)) {
target_mask = CustomData_get_layer(&target->vdata, CD_PAINT_MASK);
target_mask = (float *)CustomData_get_layer(&target->vdata, CD_PAINT_MASK);
}
else {
target_mask = CustomData_add_layer(
&target->vdata, CD_PAINT_MASK, CD_CALLOC, NULL, target->totvert);
target_mask = (float *)CustomData_add_layer(
&target->vdata, CD_PAINT_MASK, CD_CALLOC, nullptr, target->totvert);
}
float *source_mask;
if (CustomData_has_layer(&source->vdata, CD_PAINT_MASK)) {
source_mask = CustomData_get_layer(&source->vdata, CD_PAINT_MASK);
source_mask = (float *)CustomData_get_layer(&source->vdata, CD_PAINT_MASK);
}
else {
source_mask = CustomData_add_layer(
&source->vdata, CD_PAINT_MASK, CD_CALLOC, NULL, source->totvert);
source_mask = (float *)CustomData_add_layer(
&source->vdata, CD_PAINT_MASK, CD_CALLOC, nullptr, source->totvert);
}
for (int i = 0; i < target->totvert; i++) {
@ -371,18 +360,18 @@ void BKE_mesh_remesh_sculpt_array_update(Object *ob, Mesh *target, Mesh *source)
.nearest_callback = NULL,
};
BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_VERTS, 2);
MVert *target_verts = CustomData_get_layer(&target->vdata, CD_MVERT);
MVert *target_verts = (MVert *)CustomData_get_layer(&target->vdata, CD_MVERT);
const int target_totvert = target->totvert;
int *target_copy_index = MEM_malloc_arrayN(sizeof(int), target_totvert, "target_copy_index");
int *target_symmertry = MEM_malloc_arrayN(sizeof(int), target_totvert, "target_copy_index");
float (*target_orco)[3] = MEM_malloc_arrayN(target->totvert, sizeof(float) * 3, "array orco");
int *target_copy_index = (int *)MEM_malloc_arrayN(sizeof(int), target_totvert, "target_copy_index");
int *target_symmertry = (int *)MEM_malloc_arrayN(sizeof(int), target_totvert, "target_copy_index");
float (*target_orco)[3] = (float (*)[3])MEM_malloc_arrayN(target->totvert, sizeof(float) * 3, "array orco");
for (int i = 0; i < target_totvert; i++) {
target_copy_index[i] = -1;
target_symmertry[i] = 0;
copy_v3_v3(target_orco, target->mvert[i].co);
copy_v3_v3(target_orco[i], target->mvert[i].co);
}
for (int i = 0; i < target->totvert; i++) {
@ -428,30 +417,28 @@ void BKE_mesh_remesh_sculpt_array_update(Object *ob, Mesh *target, Mesh *source)
void BKE_remesh_reproject_sculpt_face_sets(Mesh *target, Mesh *source)
{
BVHTreeFromMesh bvhtree = {
.nearest_callback = NULL,
};
BVHTreeFromMesh bvhtree = {{nullptr}};
const MPoly *target_polys = CustomData_get_layer(&target->pdata, CD_MPOLY);
const MVert *target_verts = CustomData_get_layer(&target->vdata, CD_MVERT);
const MLoop *target_loops = CustomData_get_layer(&target->ldata, CD_MLOOP);
const MPoly *target_polys = (const MPoly *)CustomData_get_layer(&target->pdata, CD_MPOLY);
const MVert *target_verts = (const MVert *)CustomData_get_layer(&target->vdata, CD_MVERT);
const MLoop *target_loops = (const MLoop *)CustomData_get_layer(&target->ldata, CD_MLOOP);
int *target_face_sets;
if (CustomData_has_layer(&target->pdata, CD_SCULPT_FACE_SETS)) {
target_face_sets = CustomData_get_layer(&target->pdata, CD_SCULPT_FACE_SETS);
target_face_sets = (int *)CustomData_get_layer(&target->pdata, CD_SCULPT_FACE_SETS);
}
else {
target_face_sets = CustomData_add_layer(
&target->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, target->totpoly);
target_face_sets = (int *)CustomData_add_layer(
&target->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, nullptr, target->totpoly);
}
int *source_face_sets;
const int *source_face_sets;
if (CustomData_has_layer(&source->pdata, CD_SCULPT_FACE_SETS)) {
source_face_sets = CustomData_get_layer(&source->pdata, CD_SCULPT_FACE_SETS);
source_face_sets = (const int *)CustomData_get_layer(&source->pdata, CD_SCULPT_FACE_SETS);
}
else {
source_face_sets = CustomData_add_layer(
&source->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, source->totpoly);
source_face_sets = (const int *)CustomData_add_layer(
&source->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, nullptr, source->totpoly);
}
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(source);
@ -481,9 +468,9 @@ void BKE_remesh_reproject_materials(Mesh *target, Mesh *source)
.nearest_callback = NULL,
};
const MPoly *target_polys = CustomData_get_layer(&target->pdata, CD_MPOLY);
const MVert *target_verts = CustomData_get_layer(&target->vdata, CD_MVERT);
const MLoop *target_loops = CustomData_get_layer(&target->ldata, CD_MLOOP);
const MPoly *target_polys = (MPoly *)CustomData_get_layer(&target->pdata, CD_MPOLY);
const MVert *target_verts = (MVert *)CustomData_get_layer(&target->vdata, CD_MVERT);
const MLoop *target_loops = (MLoop *)CustomData_get_layer(&target->ldata, CD_MLOOP);
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(source);
BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_LOOPTRI, 2);
@ -503,11 +490,9 @@ void BKE_remesh_reproject_materials(Mesh *target, Mesh *source)
free_bvhtree_from_mesh(&bvhtree);
}
void BKE_remesh_reproject_vertex_paint(Mesh *target, Mesh *source)
void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source)
{
BVHTreeFromMesh bvhtree = {
.nearest_callback = NULL,
};
BVHTreeFromMesh bvhtree = {{nullptr}};
BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_VERTS, 2);
int tot_color_layer = CustomData_number_of_layers(&source->vdata, CD_PROP_COLOR);
@ -515,11 +500,13 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, Mesh *source)
for (int layer_n = 0; layer_n < tot_color_layer; layer_n++) {
const char *layer_name = CustomData_get_layer_name(&source->vdata, CD_PROP_COLOR, layer_n);
CustomData_add_layer_named(
&target->vdata, CD_PROP_COLOR, CD_CALLOC, NULL, target->totvert, layer_name);
&target->vdata, CD_PROP_COLOR, CD_CALLOC, nullptr, target->totvert, layer_name);
MPropCol *target_color = CustomData_get_layer_n(&target->vdata, CD_PROP_COLOR, layer_n);
MVert *target_verts = CustomData_get_layer(&target->vdata, CD_MVERT);
MPropCol *source_color = CustomData_get_layer_n(&source->vdata, CD_PROP_COLOR, layer_n);
MPropCol *target_color = (MPropCol *)CustomData_get_layer_n(
&target->vdata, CD_PROP_COLOR, layer_n);
MVert *target_verts = (MVert *)CustomData_get_layer(&target->vdata, CD_MVERT);
const MPropCol *source_color = (const MPropCol *)CustomData_get_layer_n(
&source->vdata, CD_PROP_COLOR, layer_n);
for (int i = 0; i < target->totvert; i++) {
BVHTreeNearest nearest;
nearest.index = -1;
@ -534,20 +521,16 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, Mesh *source)
free_bvhtree_from_mesh(&bvhtree);
}
struct Mesh *BKE_mesh_remesh_voxel_fix_poles(struct Mesh *mesh)
struct Mesh *BKE_mesh_remesh_voxel_fix_poles(const Mesh *mesh)
{
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
BMesh *bm;
bm = BM_mesh_create(&allocsize,
&((struct BMeshCreateParams){
.use_toolflags = true,
}));
BM_mesh_bm_from_me(bm,
mesh,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
}));
const BMeshCreateParams bmesh_create_params = {true};
BMesh *bm = BM_mesh_create(&allocsize, &bmesh_create_params);
BMeshFromMeshParams bmesh_from_mesh_params{};
bmesh_from_mesh_params.calc_face_normal = true;
BM_mesh_bm_from_me(bm, mesh, &bmesh_from_mesh_params);
BMVert *v;
BMEdge *ed, *ed_next;
@ -558,8 +541,8 @@ struct Mesh *BKE_mesh_remesh_voxel_fix_poles(struct Mesh *mesh)
BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
BM_ITER_MESH_MUTABLE (f, f_next, &iter_a, bm, BM_FACES_OF_MESH) {
BMVert *v1, *v2;
v1 = NULL;
v2 = NULL;
v1 = nullptr;
v2 = nullptr;
BM_ITER_ELEM (v, &iter_b, f, BM_VERTS_OF_FACE) {
if (BM_vert_edge_count(v) == 3) {
if (v1) {
@ -572,7 +555,7 @@ struct Mesh *BKE_mesh_remesh_voxel_fix_poles(struct Mesh *mesh)
}
if (v1 && v2 && (v1 != v2) && !BM_edge_exists(v1, v2)) {
BM_face_kill(bm, f);
BMEdge *e = BM_edge_create(bm, v1, v2, NULL, BM_CREATE_NOP);
BMEdge *e = BM_edge_create(bm, v1, v2, nullptr, BM_CREATE_NOP);
BM_elem_flag_set(e, BM_ELEM_TAG, true);
}
}
@ -634,13 +617,10 @@ struct Mesh *BKE_mesh_remesh_voxel_fix_poles(struct Mesh *mesh)
BM_ELEM_TAG);
BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
Mesh *result = BKE_mesh_from_bmesh_nomain(bm,
(&(struct BMeshToMeshParams){
.calc_object_remap = false,
}),
mesh);
BMeshToMeshParams bmesh_to_mesh_params{};
bmesh_to_mesh_params.calc_object_remap = false;
Mesh *result = BKE_mesh_from_bmesh_nomain(bm, &bmesh_to_mesh_params, mesh);
BKE_id_free(NULL, mesh);
BM_mesh_free(bm);
return result;
}

View File

@ -2504,6 +2504,22 @@ bool nodeLinkIsHidden(const bNodeLink *link)
return nodeSocketIsHidden(link->fromsock) || nodeSocketIsHidden(link->tosock);
}
/* Adjust the indices of links connected to the given multi input socket after deleting the link at
* `deleted_index`. This function also works if the link has not yet been deleted. */
static void adjust_multi_input_indices_after_removed_link(bNodeTree *ntree,
bNodeSocket *sock,
int deleted_index)
{
LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
/* We only need to adjust those with a greater index, because the others will have the same
* index. */
if (link->tosock != sock || link->multi_input_socket_index <= deleted_index) {
continue;
}
link->multi_input_socket_index -= 1;
}
}
void nodeInternalRelink(bNodeTree *ntree, bNode *node)
{
/* store link pointers in output sockets, for efficient lookup */
@ -2537,10 +2553,18 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node)
ntree->update |= NTREE_UPDATE_LINKS;
}
else {
if (link->tosock->flag & SOCK_MULTI_INPUT) {
adjust_multi_input_indices_after_removed_link(
ntree, link->tosock, link->multi_input_socket_index);
}
nodeRemLink(ntree, link);
}
}
else {
if (link->tosock->flag & SOCK_MULTI_INPUT) {
adjust_multi_input_indices_after_removed_link(
ntree, link->tosock, link->multi_input_socket_index);
};
nodeRemLink(ntree, link);
}
}
@ -2991,6 +3015,11 @@ void nodeUnlinkNode(bNodeTree *ntree, bNode *node)
}
if (lb) {
/* Only bother adjusting if the socket is not on the node we're deleting. */
if (link->tonode != node && link->tosock->flag & SOCK_MULTI_INPUT) {
adjust_multi_input_indices_after_removed_link(
ntree, link->tosock, link->multi_input_socket_index);
}
LISTBASE_FOREACH (bNodeSocket *, sock, lb) {
if (link->fromsock == sock || link->tosock == sock) {
nodeRemLink(ntree, link);

View File

@ -231,7 +231,6 @@ static void scene_init_data(ID *id)
/* Sequencer */
scene->toolsettings->sequencer_tool_settings = SEQ_tool_settings_init();
scene->toolsettings->snap_flag |= SCE_SNAP_SEQ;
for (size_t i = 0; i < ARRAY_SIZE(scene->orientation_slots); i++) {
scene->orientation_slots[i].index_custom = -1;

View File

@ -28,9 +28,9 @@
#if defined(__GNUC__) || defined(__clang__)
# if defined(__cplusplus) && (__cplusplus > 199711L)
# define BLI_array_alloca(arr, realsize) (decltype(arr)) alloca(sizeof(*arr) * (realsize))
# define BLI_array_alloca(arr, realsize) (decltype(arr))alloca(sizeof(*arr) * (realsize))
# else
# define BLI_array_alloca(arr, realsize) (typeof(arr)) alloca(sizeof(*arr) * (realsize))
# define BLI_array_alloca(arr, realsize) (typeof(arr))alloca(sizeof(*arr) * (realsize))
# endif
#else
# define BLI_array_alloca(arr, realsize) alloca(sizeof(*arr) * (realsize))

View File

@ -33,8 +33,8 @@ namespace blender {
template<
/* Type of the elements in the underlying array. */
typename T,
/* Binary function that takes two `const T &` inputs and returns true, when the first input has
greater priority than the second. */
/* Binary function that takes two `const T &` inputs and returns true,
* when the first input has greater priority than the second. */
typename FirstHasHigherPriority = std::greater<T>>
class InplacePriorityQueue {
private:

View File

@ -121,7 +121,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
* You must not call `delete` on the returned value.
* Instead, only the destructor has to be called.
*/
template<typename T, typename... Args> destruct_ptr<T> construct(Args &&... args)
template<typename T, typename... Args> destruct_ptr<T> construct(Args &&...args)
{
void *buffer = this->allocate(sizeof(T), alignof(T));
T *value = new (buffer) T(std::forward<Args>(args)...);
@ -134,7 +134,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
* the constructed elements.
*/
template<typename T, typename... Args>
MutableSpan<T> construct_array(int64_t size, Args &&... args)
MutableSpan<T> construct_array(int64_t size, Args &&...args)
{
MutableSpan<T> array = this->allocate_array<T>(size);
for (const int64_t i : IndexRange(size)) {
@ -186,7 +186,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
}
template<typename T, typename... Args>
Span<T *> construct_elements_and_pointer_array(int64_t n, Args &&... args)
Span<T *> construct_elements_and_pointer_array(int64_t n, Args &&...args)
{
MutableSpan<void *> void_pointers = this->allocate_elements_and_pointer_array(
n, sizeof(T), alignof(T));

View File

@ -248,7 +248,7 @@ class Map {
this->add_new_as(std::move(key), std::move(value));
}
template<typename ForwardKey, typename... ForwardValue>
void add_new_as(ForwardKey &&key, ForwardValue &&... value)
void add_new_as(ForwardKey &&key, ForwardValue &&...value)
{
this->add_new__impl(
std::forward<ForwardKey>(key), hash_(key), std::forward<ForwardValue>(value)...);
@ -278,7 +278,7 @@ class Map {
return this->add_as(std::move(key), std::move(value));
}
template<typename ForwardKey, typename... ForwardValue>
bool add_as(ForwardKey &&key, ForwardValue &&... value)
bool add_as(ForwardKey &&key, ForwardValue &&...value)
{
return this->add__impl(
std::forward<ForwardKey>(key), hash_(key), std::forward<ForwardValue>(value)...);
@ -308,7 +308,7 @@ class Map {
return this->add_overwrite_as(std::move(key), std::move(value));
}
template<typename ForwardKey, typename... ForwardValue>
bool add_overwrite_as(ForwardKey &&key, ForwardValue &&... value)
bool add_overwrite_as(ForwardKey &&key, ForwardValue &&...value)
{
return this->add_overwrite__impl(
std::forward<ForwardKey>(key), hash_(key), std::forward<ForwardValue>(value)...);
@ -414,7 +414,7 @@ class Map {
return this->pop_default_as(key, std::move(default_value));
}
template<typename ForwardKey, typename... ForwardValue>
Value pop_default_as(const ForwardKey &key, ForwardValue &&... default_value)
Value pop_default_as(const ForwardKey &key, ForwardValue &&...default_value)
{
Slot *slot = this->lookup_slot_ptr(key, hash_(key));
if (slot == nullptr) {
@ -526,7 +526,7 @@ class Map {
return this->lookup_default_as(key, default_value);
}
template<typename ForwardKey, typename... ForwardValue>
Value lookup_default_as(const ForwardKey &key, ForwardValue &&... default_value) const
Value lookup_default_as(const ForwardKey &key, ForwardValue &&...default_value) const
{
const Value *ptr = this->lookup_ptr_as(key);
if (ptr != nullptr) {
@ -558,7 +558,7 @@ class Map {
return this->lookup_or_add_as(std::move(key), std::move(value));
}
template<typename ForwardKey, typename... ForwardValue>
Value &lookup_or_add_as(ForwardKey &&key, ForwardValue &&... value)
Value &lookup_or_add_as(ForwardKey &&key, ForwardValue &&...value)
{
return this->lookup_or_add__impl(
std::forward<ForwardKey>(key), hash_(key), std::forward<ForwardValue>(value)...);
@ -1058,7 +1058,7 @@ class Map {
}
template<typename ForwardKey, typename... ForwardValue>
void add_new__impl(ForwardKey &&key, uint64_t hash, ForwardValue &&... value)
void add_new__impl(ForwardKey &&key, uint64_t hash, ForwardValue &&...value)
{
BLI_assert(!this->contains_as(key));
@ -1075,7 +1075,7 @@ class Map {
}
template<typename ForwardKey, typename... ForwardValue>
bool add__impl(ForwardKey &&key, uint64_t hash, ForwardValue &&... value)
bool add__impl(ForwardKey &&key, uint64_t hash, ForwardValue &&...value)
{
this->ensure_can_add();
@ -1148,7 +1148,7 @@ class Map {
}
template<typename ForwardKey, typename... ForwardValue>
Value &lookup_or_add__impl(ForwardKey &&key, uint64_t hash, ForwardValue &&... value)
Value &lookup_or_add__impl(ForwardKey &&key, uint64_t hash, ForwardValue &&...value)
{
this->ensure_can_add();
@ -1166,7 +1166,7 @@ class Map {
}
template<typename ForwardKey, typename... ForwardValue>
bool add_overwrite__impl(ForwardKey &&key, uint64_t hash, ForwardValue &&... value)
bool add_overwrite__impl(ForwardKey &&key, uint64_t hash, ForwardValue &&...value)
{
auto create_func = [&](Value *ptr) {
new (static_cast<void *>(ptr)) Value(std::forward<ForwardValue>(value)...);
@ -1283,13 +1283,13 @@ template<typename Key, typename Value> class StdUnorderedMapWrapper {
}
template<typename ForwardKey, typename... ForwardValue>
void add_new(ForwardKey &&key, ForwardValue &&... value)
void add_new(ForwardKey &&key, ForwardValue &&...value)
{
map_.insert({std::forward<ForwardKey>(key), Value(std::forward<ForwardValue>(value)...)});
}
template<typename ForwardKey, typename... ForwardValue>
bool add(ForwardKey &&key, ForwardValue &&... value)
bool add(ForwardKey &&key, ForwardValue &&...value)
{
return map_
.insert({std::forward<ForwardKey>(key), Value(std::forward<ForwardValue>(value)...)})

View File

@ -196,7 +196,7 @@ template<typename Key, typename Value> class SimpleMapSlot {
* constructed by calling the constructor with the given key/value as parameter.
*/
template<typename ForwardKey, typename... ForwardValue>
void occupy(ForwardKey &&key, uint64_t hash, ForwardValue &&... value)
void occupy(ForwardKey &&key, uint64_t hash, ForwardValue &&...value)
{
BLI_assert(!this->is_occupied());
new (&value_buffer_) Value(std::forward<ForwardValue>(value)...);
@ -316,7 +316,7 @@ template<typename Key, typename Value, typename KeyInfo> class IntrusiveMapSlot
}
template<typename ForwardKey, typename... ForwardValue>
void occupy(ForwardKey &&key, uint64_t hash, ForwardValue &&... value)
void occupy(ForwardKey &&key, uint64_t hash, ForwardValue &&...value)
{
BLI_assert(!this->is_occupied());
BLI_assert(KeyInfo::is_not_empty_or_removed(key));

View File

@ -148,7 +148,7 @@ class ResourceScope : NonCopyable, NonMovable {
/**
* Utility method to construct an instance of type T that will be owned by the ResourceScope.
*/
template<typename T, typename... Args> T &construct(const char *name, Args &&... args)
template<typename T, typename... Args> T &construct(const char *name, Args &&...args)
{
destruct_ptr<T> value_ptr = m_allocator.construct<T>(std::forward<Args>(args)...);
T &value_ref = *value_ptr;

View File

@ -233,7 +233,7 @@ class Stack {
this->push_as(std::move(value));
}
/* This is similar to `std::stack::emplace`. */
template<typename... ForwardT> void push_as(ForwardT &&... value)
template<typename... ForwardT> void push_as(ForwardT &&...value)
{
if (top_ == top_chunk_->capacity_end) {
this->activate_next_chunk(1);

View File

@ -445,7 +445,7 @@ class Vector {
this->append_as(std::move(value));
}
/* This is similar to `std::vector::emplace_back`. */
template<typename... ForwardValue> void append_as(ForwardValue &&... value)
template<typename... ForwardValue> void append_as(ForwardValue &&...value)
{
this->ensure_space_for_one();
this->append_unchecked_as(std::forward<ForwardValue>(value)...);
@ -487,7 +487,7 @@ class Vector {
{
this->append_unchecked_as(std::move(value));
}
template<typename... ForwardT> void append_unchecked_as(ForwardT &&... value)
template<typename... ForwardT> void append_unchecked_as(ForwardT &&...value)
{
BLI_assert(end_ < capacity_end_);
new (end_) T(std::forward<ForwardT>(value)...);

View File

@ -1436,8 +1436,8 @@ BArrayStore *BLI_array_store_create(uint stride, uint chunk_count)
bs->info.accum_steps = BCHUNK_HASH_TABLE_ACCUMULATE_STEPS - 1;
/* Triangle number, identifying now much read-ahead we need:
* https://en.wikipedia.org/wiki/Triangular_number (+ 1) */
bs->info.accum_read_ahead_len = (uint)(
(((bs->info.accum_steps * (bs->info.accum_steps + 1))) / 2) + 1);
bs->info.accum_read_ahead_len =
(uint)((((bs->info.accum_steps * (bs->info.accum_steps + 1))) / 2) + 1);
bs->info.accum_read_ahead_bytes = bs->info.accum_read_ahead_len * stride;
#else
bs->info.accum_read_ahead_bytes = BCHUNK_HASH_LEN * stride;

View File

@ -919,8 +919,8 @@ static int delete_soft(const char *file, const char **error_message)
Class NSStringClass = objc_getClass("NSString");
SEL stringWithUTF8StringSel = sel_registerName("stringWithUTF8String:");
id pathString = ((id(*)(Class, SEL, const char *))objc_msgSend)(
NSStringClass, stringWithUTF8StringSel, file);
id pathString = ((
id(*)(Class, SEL, const char *))objc_msgSend)(NSStringClass, stringWithUTF8StringSel, file);
Class NSFileManagerClass = objc_getClass("NSFileManager");
SEL defaultManagerSel = sel_registerName("defaultManager");
@ -931,8 +931,8 @@ static int delete_soft(const char *file, const char **error_message)
id nsurl = ((id(*)(Class, SEL, id))objc_msgSend)(NSURLClass, fileURLWithPathSel, pathString);
SEL trashItemAtURLSel = sel_registerName("trashItemAtURL:resultingItemURL:error:");
BOOL deleteSuccessful = ((BOOL(*)(id, SEL, id, id, id))objc_msgSend)(
fileManager, trashItemAtURLSel, nsurl, nil, nil);
BOOL deleteSuccessful = ((
BOOL(*)(id, SEL, id, id, id))objc_msgSend)(fileManager, trashItemAtURLSel, nsurl, nil, nil);
if (deleteSuccessful) {
ret = 0;

View File

@ -807,9 +807,9 @@ MINLINE unsigned char unit_float_to_uchar_clamp(float val)
MINLINE unsigned short unit_float_to_ushort_clamp(float val)
{
return (unsigned short)((val >= 1.0f - 0.5f / 65535) ?
65535 :
(val <= 0.0f) ? 0 : (val * 65535.0f + 0.5f));
return (unsigned short)((val >= 1.0f - 0.5f / 65535) ? 65535 :
(val <= 0.0f) ? 0 :
(val * 65535.0f + 0.5f));
}
#define unit_float_to_ushort_clamp(val) \
((CHECK_TYPE_INLINE(val, float)), unit_float_to_ushort_clamp(val))

View File

@ -685,10 +685,12 @@ static void blackbody_temperature_to_rgb(float rgb[3], float t)
rgb[2] = 0.0f;
}
else {
int i = (t >= 6365.0f) ?
5 :
(t >= 3315.0f) ? 4 :
(t >= 1902.0f) ? 3 : (t >= 1449.0f) ? 2 : (t >= 1167.0f) ? 1 : 0;
int i = (t >= 6365.0f) ? 5 :
(t >= 3315.0f) ? 4 :
(t >= 1902.0f) ? 3 :
(t >= 1449.0f) ? 2 :
(t >= 1167.0f) ? 1 :
0;
const float *r = blackbody_table_r[i];
const float *g = blackbody_table_g[i];

View File

@ -322,16 +322,14 @@ MINLINE int compare_rgb_uchar(const unsigned char col_a[3],
/* Return triangle noise in [-0.5..1.5[ range */
MINLINE float dither_random_value(float s, float t)
{
/* Original code from https://www.shadertoy.com/view/4t2SDh */
/* The noise reshaping technique does not work on CPU.
* We generate and merge two distribution instead */
/* Uniform noise in [0..1[ range */
float nrnd0 = sinf(s * 12.9898f + t * 78.233f) * 43758.5453f;
float nrnd1 = sinf(s * 19.9898f + t * 119.233f) * 43798.5453f;
nrnd0 -= floorf(nrnd0);
nrnd1 -= floorf(nrnd1);
/* Uniform noise in [0..1[ range, using common GLSL hash function.
* https://stackoverflow.com/questions/12964279/whats-the-origin-of-this-glsl-rand-one-liner. */
float hash0 = sinf(s * 12.9898f + t * 78.233f) * 43758.5453f;
float hash1 = sinf(s * 19.9898f + t * 119.233f) * 43798.5453f;
hash0 -= floorf(hash0);
hash1 -= floorf(hash1);
/* Convert uniform distribution into triangle-shaped distribution. */
return nrnd0 + nrnd1 - 0.5f;
return hash0 + hash0 - 0.5f;
}
MINLINE void float_to_byte_dither_v3(

View File

@ -180,14 +180,9 @@ static void task_parallel_iterator_no_threads(const TaskParallelSettings *settin
{
/* Prepare user's TLS data. */
void *userdata_chunk = settings->userdata_chunk;
const size_t userdata_chunk_size = settings->userdata_chunk_size;
void *userdata_chunk_local = NULL;
const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != NULL);
if (use_userdata_chunk) {
userdata_chunk_local = MALLOCA(userdata_chunk_size);
memcpy(userdata_chunk_local, userdata_chunk, userdata_chunk_size);
if (userdata_chunk) {
if (settings->func_init != NULL) {
settings->func_init(state->userdata, userdata_chunk_local);
settings->func_init(state->userdata, userdata_chunk);
}
}
@ -196,12 +191,11 @@ static void task_parallel_iterator_no_threads(const TaskParallelSettings *settin
parallel_iterator_func_do(state, userdata_chunk);
if (use_userdata_chunk) {
if (userdata_chunk) {
if (settings->func_free != NULL) {
/* `func_free` should only free data that was created during execution of `func`. */
settings->func_free(state->userdata, userdata_chunk_local);
settings->func_free(state->userdata, userdata_chunk);
}
MALLOCA_FREE(userdata_chunk_local, userdata_chunk_size);
}
}
@ -415,19 +409,16 @@ void BLI_task_parallel_mempool(BLI_mempool *mempool,
void *userdata_chunk = settings->userdata_chunk;
const size_t userdata_chunk_size = settings->userdata_chunk_size;
void *userdata_chunk_local = NULL;
void *userdata_chunk_array = NULL;
const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != NULL);
if (!settings->use_threading) {
TaskParallelTLS tls = {NULL};
if (use_userdata_chunk) {
userdata_chunk_local = MALLOCA(userdata_chunk_size);
memcpy(userdata_chunk_local, userdata_chunk, userdata_chunk_size);
if (settings->func_init != NULL) {
settings->func_init(userdata, userdata_chunk_local);
settings->func_init(userdata, userdata_chunk);
}
tls.userdata_chunk = userdata_chunk_local;
tls.userdata_chunk = userdata_chunk;
}
BLI_mempool_iter iter;
@ -438,12 +429,13 @@ void BLI_task_parallel_mempool(BLI_mempool *mempool,
func(userdata, item, &tls);
}
if (settings->func_free != NULL) {
/* `func_free` should only free data that was created during execution of `func`. */
settings->func_free(userdata, userdata_chunk_local);
if (use_userdata_chunk) {
if (settings->func_free != NULL) {
/* `func_free` should only free data that was created during execution of `func`. */
settings->func_free(userdata, userdata_chunk);
}
}
MALLOCA_FREE(userdata_chunk_local, userdata_chunk_size);
return;
}
@ -468,6 +460,7 @@ void BLI_task_parallel_mempool(BLI_mempool *mempool,
mempool, (size_t)num_tasks);
for (int i = 0; i < num_tasks; i++) {
void *userdata_chunk_local = NULL;
if (use_userdata_chunk) {
userdata_chunk_local = (char *)userdata_chunk_array + (userdata_chunk_size * i);
memcpy(userdata_chunk_local, userdata_chunk, userdata_chunk_size);

View File

@ -115,7 +115,7 @@ size_t BLI_timecode_string_from_time(char *str,
str, maxncpy, "%s%02d:%02d+%02d", neg, minutes, seconds, frames);
}
else {
rlen = BLI_snprintf_rlen(str, maxncpy, "%s%d+%02d", neg, seconds, frames);
rlen = BLI_snprintf_rlen(str, maxncpy, "%s00:%02d+%02d", neg, seconds, frames);
}
}
else {

View File

@ -1939,7 +1939,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
ViewLayer *view_layer;
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
view_layer->flag |= VIEW_LAYER_FREESTYLE;
view_layer->layflag = 0x7FFF; /* solid ztra halo edge strand */
view_layer->layflag = 0x7FFF; /* solid Z-transparency halo edge strand. */
view_layer->passflag = SCE_PASS_COMBINED | SCE_PASS_Z;
view_layer->pass_alpha_threshold = 0.5f;
BKE_freestyle_config_init(&view_layer->freestyle_config);

View File

@ -583,11 +583,6 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
sizeof(scene->master_collection->id.name) - 2);
}
}
LISTBASE_FOREACH (Material *, mat, &bmain->materials) {
if (!(mat->lineart.flags & LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS)) {
mat->lineart.mat_occlusion = 1;
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 300, 9)) {
@ -618,6 +613,11 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
tool_settings->snap_uv_mode &= ~(1 << 4);
}
}
LISTBASE_FOREACH (Material *, mat, &bmain->materials) {
if (!(mat->lineart.flags & LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS)) {
mat->lineart.mat_occlusion = 1;
}
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 300, 13)) {
@ -671,6 +671,26 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 300, 14)) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
ToolSettings *tool_settings = scene->toolsettings;
tool_settings->snap_flag &= ~SCE_SNAP_SEQ;
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 300, 15)) {
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = (SpaceSeq *)sl;
sseq->flag |= SEQ_SHOW_GRID;
}
}
}
}
}
/**
* Versioning code until next subversion bump goes here.
*

View File

@ -183,7 +183,8 @@ static void blo_update_defaults_screen(bScreen *screen,
else if (area->spacetype == SPACE_SEQ) {
SpaceSeq *seq = area->spacedata.first;
seq->flag |= SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES | SEQ_ZOOM_TO_FIT | SEQ_SHOW_STRIP_OVERLAY |
SEQ_SHOW_STRIP_SOURCE | SEQ_SHOW_STRIP_NAME | SEQ_SHOW_STRIP_DURATION;
SEQ_SHOW_STRIP_SOURCE | SEQ_SHOW_STRIP_NAME | SEQ_SHOW_STRIP_DURATION |
SEQ_SHOW_GRID;
seq->render_size = SEQ_RENDER_SIZE_PROXY_100;
seq->flag |= SEQ_USE_PROXIES;
@ -318,6 +319,11 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
/* Rename render layers. */
BKE_view_layer_rename(bmain, scene, scene->view_layers.first, "View Layer");
/* Disable Z pass by default. */
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
view_layer->passflag &= ~SCE_PASS_Z;
}
/* New EEVEE defaults. */
scene->eevee.bloom_intensity = 0.05f;
scene->eevee.bloom_clamp = 0.0f;

View File

@ -286,6 +286,11 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
FROM_DEFAULT_V4_UCHAR(space_spreadsheet.selected_highlight);
}
if (!USER_VERSION_ATLEAST(300, 15)) {
copy_v4_uchar(btheme->space_sequencer.grid, 33);
btheme->space_sequencer.grid[3] = 255;
}
/**
* Versioning code until next subversion bump goes here.
*

View File

@ -209,8 +209,7 @@ static void vs_add(
/* This edge stores a direct path back to the original vertex so we can
* backtrack without having to store an array of previous verts. */
/* WARNING - setting the edge is not common practice
* but currently harmless, take care. */
/* WARNING: Setting the edge is not common practice but currently harmless, take care. */
BLI_assert(BM_vert_in_edge(e_prev, v));
v->e = e_prev;

View File

@ -89,7 +89,7 @@ extern const char bm_iter_itype_htype_map[BM_ITYPE_MAX];
# define BM_ITER_MESH_MUTABLE(ele, ele_next, iter, bm, itype) \
for (BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_new(iter, bm, itype, NULL); \
ele ? ((void)((iter)->count = BM_iter_mesh_count(itype, bm)), \
(void)(ele_next = BM_iter_step(iter)), \
(void)(BM_CHECK_TYPE_ELEM_ASSIGN(ele_next) = BM_iter_step(iter)), \
1) : \
0; \
BM_CHECK_TYPE_ELEM_ASSIGN(ele) = ele_next)

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