Report/confirm overwrite of 'asset library' blendfiles. #117346

Merged
Bastien Montagne merged 5 commits from mont29/blender:bap-open-warning into brush-assets-project 2024-01-25 17:10:39 +01:00
692 changed files with 14674 additions and 12176 deletions
Showing only changes of commit 5327a7e98e - Show all commits

View File

@ -236,6 +236,10 @@ ifndef PYTHON
ifeq (, $(shell command -v $(PYTHON)))
PYTHON:=python
endif
else
# Don't generate __pycache__ files in lib folder, they
# can interfere with updates.
PYTHON:=$(PYTHON) -B
endif
endif
@ -566,14 +570,10 @@ source_archive_complete: .FORCE
# This assumes CMake is still using a default `PACKAGE_DIR` variable:
@$(PYTHON) ./build_files/utils/make_source_archive.py --include-packages "$(BUILD_DIR)/source_archive/packages"
INKSCAPE_BIN?="inkscape"
icons: .FORCE
@BLENDER_BIN=$(BLENDER_BIN) INKSCAPE_BIN=$(INKSCAPE_BIN) \
"$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
@INKSCAPE_BIN=$(INKSCAPE_BIN) \
"$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
@INKSCAPE_BIN=$(INKSCAPE_BIN) \
"$(BLENDER_DIR)/release/datafiles/alert_icons_update.py"
@BLENDER_BIN=$(BLENDER_BIN) "$(BLENDER_DIR)/release/datafiles/blender_icons_update.py"
"$(BLENDER_DIR)/release/datafiles/prvicons_update.py"
"$(BLENDER_DIR)/release/datafiles/alert_icons_update.py"
icons_geom: .FORCE
@BLENDER_BIN=$(BLENDER_BIN) \

View File

@ -26,8 +26,8 @@
#
##################################################################################################
project("BlenderDependencies")
cmake_minimum_required(VERSION 3.5)
project("BlenderDependencies")
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW) # CMake 3.24+ Set the date/time for extracted files to time of extraction
endif()

View File

@ -14,6 +14,7 @@ if(NOT APPLE)
${OIDN_EXTRA_ARGS}
-DOIDN_DEVICE_SYCL=ON
-DOIDN_DEVICE_SYCL_AOT=OFF
-DOIDN_DEVICE_CUDA=ON
-DOIDN_DEVICE_HIP=ON
-DLEVEL_ZERO_ROOT=${LIBDIR}/level-zero
)

View File

@ -140,7 +140,12 @@ if(WIN32)
ExternalProject_Add_Step(external_openimageio after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/include ${HARVEST_TARGET}/OpenImageIO/include
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/lib ${HARVEST_TARGET}/OpenImageIO/lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/iconvert.exe ${HARVEST_TARGET}/OpenImageIO/bin/iconvert.exe
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/idiff.exe ${HARVEST_TARGET}/OpenImageIO/bin/idiff.exe
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/igrep.exe ${HARVEST_TARGET}/OpenImageIO/bin/igrep.exe
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/iinfo.exe ${HARVEST_TARGET}/OpenImageIO/bin/iinfo.exe
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/maketx.exe ${HARVEST_TARGET}/OpenImageIO/bin/maketx.exe
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/oiiotool.exe ${HARVEST_TARGET}/OpenImageIO/bin/oiiotool.exe
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/OpenImageIO.dll ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/OpenImageIO_Util.dll ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO_Util.dll
DEPENDEES install

View File

@ -12,7 +12,7 @@
# This can also be an environment variable.
# OPENIMAGEIO_FOUND, If false, do not try to use OpenImageIO.
# OPENIMAGEIO_PUGIXML_FOUND, Indicates whether OIIO has biltin PuguXML parser.
# OPENIMAGEIO_IDIFF, full path to idiff application if found.
# OPENIMAGEIO_TOOL, full path to oiiotool application if found.
#
# also defined, but not for general use are
# OPENIMAGEIO_LIBRARY, where to find the OpenImageIO library.
@ -51,9 +51,9 @@ find_library(OPENIMAGEIO_LIBRARY
set(_openimageio_LIBRARIES ${OPENIMAGEIO_LIBRARY})
find_file(OPENIMAGEIO_IDIFF
find_file(OPENIMAGEIO_TOOL
NAMES
idiff
oiiotool
HINTS
${_openimageio_SEARCH_DIRS}
PATH_SUFFIXES
@ -115,7 +115,7 @@ mark_as_advanced(
OPENIMAGEIO_INCLUDE_DIR
OPENIMAGEIO_LIBRARY
OPENIMAGEIO_UTIL_LIBRARY
OPENIMAGEIO_IDIFF
OPENIMAGEIO_TOOL
)
unset(_openimageio_SEARCH_DIRS)

View File

@ -27,7 +27,7 @@ CHECKER_IGNORE_PREFIX = [
# To add files use a relative path.
CHECKER_EXCLUDE_SOURCE_FILES = set(os.path.join(*f.split("/")) for f in (
# "source/blender/example.c",
"source/blender/draw/engines/eevee_next/eevee_lut.cc",
))
CHECKER_ARGS = [

View File

@ -684,7 +684,7 @@ if(NOT OpenImageIO_FOUND)
set(OIIO_OPTIMIZED optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO.lib optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util.lib)
set(OIIO_DEBUG debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_d.lib debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util_d.lib)
set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG})
set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe")
set(OPENIMAGEIO_TOOL "${OPENIMAGEIO}/bin/oiiotool.exe")
endif()
if(WITH_LLVM)

View File

@ -43,7 +43,7 @@ template<bool is_subd> struct MikkMeshWrapper {
const Mesh *mesh,
float3 *tangent,
float *tangent_sign)
: mesh(mesh), texface(NULL), orco(NULL), tangent(tangent), tangent_sign(tangent_sign)
: mesh(mesh), uv(NULL), orco(NULL), tangent(tangent), tangent_sign(tangent_sign)
{
const AttributeSet &attributes = is_subd ? mesh->subd_attributes : mesh->attributes;
@ -63,7 +63,7 @@ template<bool is_subd> struct MikkMeshWrapper {
else {
Attribute *attr_uv = attributes.find(ustring(layer_name));
if (attr_uv != NULL) {
texface = attr_uv->data_float2();
uv = attr_uv->data_float2();
}
}
}
@ -120,9 +120,9 @@ template<bool is_subd> struct MikkMeshWrapper {
{
/* TODO: Check whether introducing a template boolean in order to
* turn this into a constexpr is worth it. */
if (texface != NULL) {
if (uv != NULL) {
const int corner_index = CornerIndex(face_num, vert_num);
float2 tfuv = texface[corner_index];
float2 tfuv = uv[corner_index];
return mikk::float3(tfuv.x, tfuv.y, 1.0f);
}
else if (orco != NULL) {
@ -175,6 +175,7 @@ template<bool is_subd> struct MikkMeshWrapper {
float3 *vertex_normal;
float2 *texface;
float2 *uv;
float3 *orco;
float3 orco_loc, inv_orco_size;
@ -825,11 +826,11 @@ static void create_mesh(Scene *scene,
const blender::OffsetIndices faces = b_mesh.faces();
const blender::Span<int> corner_verts = b_mesh.corner_verts();
const blender::bke::AttributeAccessor b_attributes = b_mesh.attributes();
const blender::bke::MeshNormalDomain normals_domain = b_mesh.normals_domain();
const blender::bke::MeshNormalDomain normals_domain = b_mesh.normals_domain(true);
int numfaces = (!subdivision) ? b_mesh.corner_tris().size() : faces.size();
bool use_loop_normals = normals_domain == blender::bke::MeshNormalDomain::Corner &&
(mesh->get_subdivision_type() != Mesh::SUBDIVISION_CATMULL_CLARK);
bool use_corner_normals = normals_domain == blender::bke::MeshNormalDomain::Corner &&
(mesh->get_subdivision_type() != Mesh::SUBDIVISION_CATMULL_CLARK);
/* If no faces, create empty mesh. */
if (faces.is_empty()) {
@ -841,7 +842,7 @@ static void create_mesh(Scene *scene,
const blender::VArraySpan sharp_faces = *b_attributes.lookup<bool>(
"sharp_face", blender::bke::AttrDomain::Face);
blender::Span<blender::float3> corner_normals;
if (use_loop_normals) {
if (use_corner_normals) {
corner_normals = b_mesh.corner_normals();
}
@ -872,7 +873,7 @@ static void create_mesh(Scene *scene,
Attribute *attr_N = attributes.add(ATTR_STD_VERTEX_NORMAL);
float3 *N = attr_N->data_float3();
if (subdivision || !(use_loop_normals && !corner_normals.is_empty())) {
if (subdivision || !(use_corner_normals && !corner_normals.is_empty())) {
const blender::Span<blender::float3> vert_normals = b_mesh.vert_normals();
for (const int i : vert_normals.index_range()) {
N[i] = make_float3(vert_normals[i][0], vert_normals[i][1], vert_normals[i][2]);
@ -940,7 +941,7 @@ static void create_mesh(Scene *scene,
std::fill(shader, shader + numtris, 0);
}
if (!sharp_faces.is_empty() && !(use_loop_normals && !corner_normals.is_empty())) {
if (!sharp_faces.is_empty() && !(use_corner_normals && !corner_normals.is_empty())) {
const blender::Span<int> tri_faces = b_mesh.corner_tri_faces();
for (const int i : corner_tris.index_range()) {
smooth[i] = !sharp_faces[tri_faces[i]];
@ -951,7 +952,7 @@ static void create_mesh(Scene *scene,
std::fill(smooth, smooth + numtris, normals_domain != blender::bke::MeshNormalDomain::Face);
}
if (use_loop_normals && !corner_normals.is_empty()) {
if (use_corner_normals && !corner_normals.is_empty()) {
for (const int i : corner_tris.index_range()) {
const blender::int3 &tri = corner_tris[i];
for (int i = 0; i < 3; i++) {
@ -975,7 +976,7 @@ static void create_mesh(Scene *scene,
int *subd_ptex_offset = mesh->get_subd_ptex_offset().data();
int *subd_face_corners = mesh->get_subd_face_corners().data();
if (!sharp_faces.is_empty() && !use_loop_normals) {
if (!sharp_faces.is_empty() && !use_corner_normals) {
for (int i = 0; i < numfaces; i++) {
subd_smooth[i] = !sharp_faces[i];
}

View File

@ -88,15 +88,16 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
BL::Mesh mesh = (b_ob_info.object_data.is_a(&RNA_Mesh)) ? BL::Mesh(b_ob_info.object_data) :
BL::Mesh(PointerRNA_NULL);
const bool split_faces = (mesh) && (subdivision_type == Mesh::SUBDIVISION_NONE) &&
(static_cast<const ::Mesh *>(mesh.ptr.data)->normals_domain(true) ==
blender::bke::MeshNormalDomain::Corner);
if (b_ob_info.is_real_object_data()) {
if (mesh) {
/* Make a copy to split faces if we use auto-smooth, otherwise not needed.
* Also in edit mode do we need to make a copy, to ensure data layers like
* UV are not empty. */
if (mesh.is_editmode() || (mesh.normals_domain() == BL::Mesh::normals_domain_CORNER &&
subdivision_type == Mesh::SUBDIVISION_NONE))
{
if (mesh.is_editmode() || split_faces) {
BL::Depsgraph depsgraph(PointerRNA_NULL);
mesh = b_ob_info.real_object.to_mesh(false, depsgraph);
}
@ -119,12 +120,14 @@ static inline BL::Mesh object_to_mesh(BL::BlendData & /*data*/,
}
#endif
if ((bool)mesh && subdivision_type == Mesh::SUBDIVISION_NONE) {
if (mesh.normals_domain() == BL::Mesh::normals_domain_CORNER) {
if (mesh) {
if (split_faces) {
mesh.split_faces();
}
mesh.calc_loop_triangles();
if (subdivision_type == Mesh::SUBDIVISION_NONE) {
mesh.calc_loop_triangles();
}
}
return mesh;

View File

@ -10,6 +10,8 @@
# include "device/cuda/device_impl.h"
# include "device/device.h"
# include "integrator/denoiser_oidn_gpu.h"
# include "util/string.h"
# include "util/windows.h"
#endif /* WITH_CUDA */
@ -162,6 +164,12 @@ void device_cuda_info(vector<DeviceInfo> &devices)
(unsigned int)pci_location[1],
(unsigned int)pci_location[2]);
# if defined(WITH_OPENIMAGEDENOISE)
if (OIDNDenoiserGPU::is_device_supported(info)) {
info.denoisers |= DENOISER_OPENIMAGEDENOISE;
}
# endif
/* If device has a kernel timeout and no compute preemption, we assume
* it is connected to a display and will freeze the display while doing
* computations. */

View File

@ -8,6 +8,8 @@
#include "device/cuda/device.h"
#include "device/optix/device_impl.h"
#include "integrator/denoiser_oidn_gpu.h"
#include "util/log.h"
#ifdef WITH_OSL
@ -74,6 +76,11 @@ void device_optix_info(const vector<DeviceInfo> &cuda_devices, vector<DeviceInfo
info.has_osl = true;
# endif
info.denoisers |= DENOISER_OPTIX;
# if defined(WITH_OPENIMAGEDENOISE)
if (OIDNDenoiserGPU::is_device_supported(info)) {
info.denoisers |= DENOISER_OPENIMAGEDENOISE;
}
# endif
devices.push_back(info);
}

View File

@ -111,6 +111,10 @@ uint OIDNDenoiserGPU::get_device_type_mask() const
# ifdef OIDN_DEVICE_SYCL
device_mask |= DEVICE_MASK_ONEAPI;
# endif
# ifdef OIDN_DEVICE_CUDA
device_mask |= DEVICE_MASK_CUDA;
device_mask |= DEVICE_MASK_OPTIX;
# endif
# ifdef OIDN_DEVICE_HIP
device_mask |= DEVICE_MASK_HIP;
# endif
@ -155,9 +159,17 @@ bool OIDNDenoiserGPU::denoise_create_if_needed(DenoiseContext &context)
oidn_device_ = oidnNewSYCLDevice(
(const sycl::queue *)reinterpret_cast<OneapiDevice *>(denoiser_device_)->sycl_queue(),
1);
denoiser_queue_->init_execution();
break;
# endif
# if defined(OIDN_DEVICE_CUDA) && defined(WITH_CUDA)
case DEVICE_CUDA:
case DEVICE_OPTIX: {
/* Directly using the stream from the DeviceQueue returns "invalid resource handle". */
cudaStream_t stream = nullptr;
oidn_device_ = oidnNewCUDADevice(&denoiser_device_->info.num, &stream, 1);
break;
}
# endif
# if defined(OIDN_DEVICE_HIP) && defined(WITH_HIP)
case DEVICE_HIP: {
hipStream_t stream = nullptr;

View File

@ -627,7 +627,7 @@ if(WITH_CYCLES_HIP_BINARIES AND WITH_CYCLES_DEVICE_HIP)
set(hip_flags
${hip_flags}
--amdgpu-target=${arch}
--offload-arch=${arch}
${HIP_HIPCC_FLAGS}
--genco
${CMAKE_CURRENT_SOURCE_DIR}${hip_kernel_src}
@ -639,7 +639,6 @@ if(WITH_CYCLES_HIP_BINARIES AND WITH_CYCLES_DEVICE_HIP)
-I ${CMAKE_CURRENT_SOURCE_DIR}/device/hip
-Wno-parentheses-equality
-Wno-unused-value
--hipcc-func-supp
-ffast-math
${hip_opt_flags}
-o ${CMAKE_CURRENT_BINARY_DIR}/${hip_file})
@ -715,7 +714,6 @@ if(WITH_CYCLES_DEVICE_HIPRT AND WITH_CYCLES_HIP_BINARIES)
-I ${HIPRT_INCLUDE_DIR}
-Wno-parentheses-equality
-Wno-unused-value
--hipcc-func-supp
-ffast-math
-o ${bitcode_file})
if(WITH_CYCLES_DEBUG)

View File

@ -19,7 +19,7 @@ CCL_NAMESPACE_BEGIN
ccl_device_inline void motion_curve_keys_for_step_linear(KernelGlobals kg,
int offset,
int numkeys,
int numverts,
int numsteps,
int step,
int k0,
@ -36,7 +36,7 @@ ccl_device_inline void motion_curve_keys_for_step_linear(KernelGlobals kg,
if (step > numsteps)
step--;
offset += step * numkeys;
offset += step * numverts;
keys[0] = kernel_data_fetch(attributes_float4, offset + k0);
keys[1] = kernel_data_fetch(attributes_float4, offset + k1);
@ -48,8 +48,8 @@ ccl_device_inline void motion_curve_keys_linear(
KernelGlobals kg, int object, int prim, float time, int k0, int k1, float4 keys[2])
{
/* get motion info */
int numsteps, numkeys;
object_motion_info(kg, object, &numsteps, NULL, &numkeys);
const int numsteps = kernel_data_fetch(objects, object).numsteps;
const int numverts = kernel_data_fetch(objects, object).numverts;
/* figure out which steps we need to fetch and their interpolation factor */
const int maxstep = numsteps * 2;
@ -63,8 +63,8 @@ ccl_device_inline void motion_curve_keys_linear(
/* fetch key coordinates */
float4 next_keys[2];
motion_curve_keys_for_step_linear(kg, offset, numkeys, numsteps, step, k0, k1, keys);
motion_curve_keys_for_step_linear(kg, offset, numkeys, numsteps, step + 1, k0, k1, next_keys);
motion_curve_keys_for_step_linear(kg, offset, numverts, numsteps, step, k0, k1, keys);
motion_curve_keys_for_step_linear(kg, offset, numverts, numsteps, step + 1, k0, k1, next_keys);
/* interpolate between steps */
keys[0] = (1.0f - t) * keys[0] + t * next_keys[0];
@ -73,7 +73,7 @@ ccl_device_inline void motion_curve_keys_linear(
ccl_device_inline void motion_curve_keys_for_step(KernelGlobals kg,
int offset,
int numkeys,
int numverts,
int numsteps,
int step,
int k0,
@ -94,7 +94,7 @@ ccl_device_inline void motion_curve_keys_for_step(KernelGlobals kg,
if (step > numsteps)
step--;
offset += step * numkeys;
offset += step * numverts;
keys[0] = kernel_data_fetch(attributes_float4, offset + k0);
keys[1] = kernel_data_fetch(attributes_float4, offset + k1);
@ -115,8 +115,8 @@ ccl_device_inline void motion_curve_keys(KernelGlobals kg,
float4 keys[4])
{
/* get motion info */
int numsteps, numkeys;
object_motion_info(kg, object, &numsteps, NULL, &numkeys);
const int numsteps = kernel_data_fetch(objects, object).numsteps;
const int numverts = kernel_data_fetch(objects, object).numverts;
/* figure out which steps we need to fetch and their interpolation factor */
const int maxstep = numsteps * 2;
@ -130,8 +130,8 @@ ccl_device_inline void motion_curve_keys(KernelGlobals kg,
/* fetch key coordinates */
float4 next_keys[4];
motion_curve_keys_for_step(kg, offset, numkeys, numsteps, step, k0, k1, k2, k3, keys);
motion_curve_keys_for_step(kg, offset, numkeys, numsteps, step + 1, k0, k1, k2, k3, next_keys);
motion_curve_keys_for_step(kg, offset, numverts, numsteps, step, k0, k1, k2, k3, keys);
motion_curve_keys_for_step(kg, offset, numverts, numsteps, step + 1, k0, k1, k2, k3, next_keys);
/* interpolate between steps */
keys[0] = (1.0f - t) * keys[0] + t * next_keys[0];

View File

@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN
#ifdef __POINTCLOUD__
ccl_device_inline float4
motion_point_for_step(KernelGlobals kg, int offset, int numkeys, int numsteps, int step, int prim)
motion_point_for_step(KernelGlobals kg, int offset, int numverts, int numsteps, int step, int prim)
{
if (step == numsteps) {
/* center step: regular key location */
@ -27,7 +27,7 @@ motion_point_for_step(KernelGlobals kg, int offset, int numkeys, int numsteps, i
if (step > numsteps)
step--;
offset += step * numkeys;
offset += step * numverts;
return kernel_data_fetch(attributes_float4, offset + prim);
}
@ -37,8 +37,8 @@ motion_point_for_step(KernelGlobals kg, int offset, int numkeys, int numsteps, i
ccl_device_inline float4 motion_point(KernelGlobals kg, int object, int prim, float time)
{
/* get motion info */
int numsteps, numkeys;
object_motion_info(kg, object, &numsteps, NULL, &numkeys);
const int numsteps = kernel_data_fetch(objects, object).numsteps;
const int numverts = kernel_data_fetch(objects, object).numverts;
/* figure out which steps we need to fetch and their interpolation factor */
int maxstep = numsteps * 2;
@ -50,8 +50,8 @@ ccl_device_inline float4 motion_point(KernelGlobals kg, int object, int prim, fl
kernel_assert(offset != ATTR_STD_NOT_FOUND);
/* fetch key coordinates */
float4 point = motion_point_for_step(kg, offset, numkeys, numsteps, step, prim);
float4 next_point = motion_point_for_step(kg, offset, numkeys, numsteps, step + 1, prim);
float4 point = motion_point_for_step(kg, offset, numverts, numsteps, step, prim);
float4 next_point = motion_point_for_step(kg, offset, numverts, numsteps, step + 1, prim);
/* interpolate between steps */
return (1.0f - t) * point + t * next_point;

View File

@ -83,12 +83,11 @@ ccl_device_inline void motion_triangle_compute_info(KernelGlobals kg,
int prim,
ccl_private uint3 *tri_vindex,
ccl_private int *numsteps,
ccl_private int *numverts,
ccl_private int *step,
ccl_private float *t)
{
/* Get object motion info. */
object_motion_info(kg, object, numsteps, numverts, NULL);
*numsteps = kernel_data_fetch(objects, object).numsteps;
/* Figure out which steps we need to fetch and their interpolation factor. */
int maxstep = *numsteps * 2;
@ -126,12 +125,12 @@ ccl_device_inline void motion_triangle_vertices(KernelGlobals kg,
ccl_device_inline void motion_triangle_vertices(
KernelGlobals kg, int object, int prim, float time, float3 verts[3])
{
int numsteps, numverts, step;
int numsteps, step;
float t;
uint3 tri_vindex;
motion_triangle_compute_info(
kg, object, time, prim, &tri_vindex, &numsteps, &numverts, &step, &t);
motion_triangle_compute_info(kg, object, time, prim, &tri_vindex, &numsteps, &step, &t);
const int numverts = kernel_data_fetch(objects, object).numverts;
motion_triangle_vertices(kg, object, tri_vindex, numsteps, numverts, step, t, verts);
}
@ -163,12 +162,12 @@ ccl_device_inline void motion_triangle_normals(KernelGlobals kg,
ccl_device_inline void motion_triangle_vertices_and_normals(
KernelGlobals kg, int object, int prim, float time, float3 verts[3], float3 normals[3])
{
int numsteps, numverts, step;
int numsteps, step;
float t;
uint3 tri_vindex;
motion_triangle_compute_info(
kg, object, time, prim, &tri_vindex, &numsteps, &numverts, &step, &t);
motion_triangle_compute_info(kg, object, time, prim, &tri_vindex, &numsteps, &step, &t);
const int numverts = kernel_data_fetch(objects, object).numverts;
motion_triangle_vertices(kg, object, tri_vindex, numsteps, numverts, step, t, verts);
motion_triangle_normals(kg, object, tri_vindex, numsteps, numverts, step, t, normals);
}
@ -178,13 +177,13 @@ ccl_device_inline float3 motion_triangle_smooth_normal(KernelGlobals kg,
int object,
uint3 tri_vindex,
int numsteps,
int numverts,
int step,
float t,
float u,
float v)
{
float3 normals[3];
const int numverts = kernel_data_fetch(objects, object).numverts;
motion_triangle_normals(kg, object, tri_vindex, numsteps, numverts, step, t, normals);
/* Interpolate between normals. */
@ -197,14 +196,12 @@ ccl_device_inline float3 motion_triangle_smooth_normal(KernelGlobals kg,
ccl_device_inline float3 motion_triangle_smooth_normal(
KernelGlobals kg, float3 Ng, int object, int prim, float u, float v, float time)
{
int numsteps, numverts, step;
int numsteps, step;
float t;
uint3 tri_vindex;
motion_triangle_compute_info(
kg, object, time, prim, &tri_vindex, &numsteps, &numverts, &step, &t);
motion_triangle_compute_info(kg, object, time, prim, &tri_vindex, &numsteps, &step, &t);
return motion_triangle_smooth_normal(
kg, Ng, object, tri_vindex, numsteps, numverts, step, t, u, v);
return motion_triangle_smooth_normal(kg, Ng, object, tri_vindex, numsteps, step, t, u, v);
}
CCL_NAMESPACE_END

View File

@ -35,13 +35,14 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals kg,
sd->shader = kernel_data_fetch(tri_shader, sd->prim);
/* Compute motion info. */
int numsteps, numverts, step;
int numsteps, step;
float t;
uint3 tri_vindex;
motion_triangle_compute_info(
kg, sd->object, sd->time, sd->prim, &tri_vindex, &numsteps, &numverts, &step, &t);
kg, sd->object, sd->time, sd->prim, &tri_vindex, &numsteps, &step, &t);
float3 verts[3];
const int numverts = kernel_data_fetch(objects, sd->object).numverts;
motion_triangle_vertices(kg, sd->object, tri_vindex, numsteps, numverts, step, t, verts);
/* Compute refined position. */
@ -64,7 +65,7 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals kg,
/* Compute smooth normal. */
if (sd->shader & SHADER_SMOOTH_NORMAL) {
sd->N = motion_triangle_smooth_normal(
kg, Ng, sd->object, tri_vindex, numsteps, numverts, step, t, sd->u, sd->v);
kg, Ng, sd->object, tri_vindex, numsteps, step, t, sd->u, sd->v);
}
}

View File

@ -368,24 +368,6 @@ ccl_device_inline float3 object_dupli_uv(KernelGlobals kg, int object)
return make_float3(kobject->dupli_uv[0], kobject->dupli_uv[1], 0.0f);
}
/* Information about mesh for motion blurred triangles and curves */
ccl_device_inline void object_motion_info(KernelGlobals kg,
int object,
ccl_private int *numsteps,
ccl_private int *numverts,
ccl_private int *numkeys)
{
if (numkeys) {
*numkeys = kernel_data_fetch(objects, object).numkeys;
}
if (numsteps)
*numsteps = kernel_data_fetch(objects, object).numsteps;
if (numverts)
*numverts = kernel_data_fetch(objects, object).numverts;
}
/* Offset to an objects patch map */
ccl_device_inline uint object_patch_map_offset(KernelGlobals kg, int object)

View File

@ -302,13 +302,12 @@ ccl_device_forceinline float4 primitive_motion_vector(KernelGlobals kg,
if (desc.offset != ATTR_STD_NOT_FOUND) {
/* get motion info */
int numverts, numkeys;
object_motion_info(kg, sd->object, NULL, &numverts, &numkeys);
const int numverts = kernel_data_fetch(objects, sd->object).numverts;
#if defined(__HAIR__) || defined(__POINTCLOUD__)
if (is_curve_or_point) {
motion_pre = float4_to_float3(curve_attribute_float4(kg, sd, desc, NULL, NULL));
desc.offset += numkeys;
desc.offset += numverts;
motion_post = float4_to_float3(curve_attribute_float4(kg, sd, desc, NULL, NULL));
/* Curve */

View File

@ -571,11 +571,6 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
kobject.dupli_generated[0] = ob->dupli_generated[0];
kobject.dupli_generated[1] = ob->dupli_generated[1];
kobject.dupli_generated[2] = ob->dupli_generated[2];
kobject.numkeys = (geom->geometry_type == Geometry::HAIR) ?
static_cast<Hair *>(geom)->get_curve_keys().size() :
(geom->geometry_type == Geometry::POINTCLOUD) ?
static_cast<PointCloud *>(geom)->num_points() :
0;
kobject.dupli_uv[0] = ob->dupli_uv[0];
kobject.dupli_uv[1] = ob->dupli_uv[1];
int totalsteps = geom->get_motion_steps();
@ -583,6 +578,10 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
kobject.numverts = (geom->geometry_type == Geometry::MESH ||
geom->geometry_type == Geometry::VOLUME) ?
static_cast<Mesh *>(geom)->get_verts().size() :
(geom->geometry_type == Geometry::HAIR) ?
static_cast<Hair *>(geom)->get_curve_keys().size() :
(geom->geometry_type == Geometry::POINTCLOUD) ?
static_cast<PointCloud *>(geom)->num_points() :
0;
kobject.patch_map_offset = 0;
kobject.attribute_map_offset = 0;

View File

@ -4317,10 +4317,8 @@ static void tablet_tool_handle_tilt(void *data,
CLOG_INFO(LOG, 2, "tilt (x=%.4f, y=%.4f)", UNPACK2(tilt_unit));
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(data);
GHOST_TabletData &td = tablet_tool->data;
td.Xtilt = tilt_unit[0];
td.Ytilt = tilt_unit[1];
CLAMP(td.Xtilt, -1.0f, 1.0f);
CLAMP(td.Ytilt, -1.0f, 1.0f);
td.Xtilt = std::clamp(tilt_unit[0], -1.0f, 1.0f);
td.Ytilt = std::clamp(tilt_unit[1], -1.0f, 1.0f);
gwl_tablet_tool_frame_event_add(tablet_tool, GWL_TabletTool_EventTypes::Tilt);
}

View File

@ -104,113 +104,6 @@
/** \} */
/* -------------------------------------------------------------------- */
/** \name Clamp Macros
* \{ */
#define CLAMPIS(a, b, c) ((a) < (b) ? (b) : (a) > (c) ? (c) : (a))
#define CLAMP(a, b, c) \
{ \
if ((a) < (b)) { \
(a) = (b); \
} \
else if ((a) > (c)) { \
(a) = (c); \
} \
} \
(void)0
#define CLAMP_MAX(a, c) \
{ \
if ((a) > (c)) { \
(a) = (c); \
} \
} \
(void)0
#define CLAMP_MIN(a, b) \
{ \
if ((a) < (b)) { \
(a) = (b); \
} \
} \
(void)0
#define CLAMP2(vec, b, c) \
{ \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
} \
(void)0
#define CLAMP2_MIN(vec, b) \
{ \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
} \
(void)0
#define CLAMP2_MAX(vec, b) \
{ \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
} \
(void)0
#define CLAMP3(vec, b, c) \
{ \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
CLAMP((vec)[2], b, c); \
} \
(void)0
#define CLAMP3_MIN(vec, b) \
{ \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
CLAMP_MIN((vec)[2], b); \
} \
(void)0
#define CLAMP3_MAX(vec, b) \
{ \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
CLAMP_MAX((vec)[2], b); \
} \
(void)0
#define CLAMP4(vec, b, c) \
{ \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
CLAMP((vec)[2], b, c); \
CLAMP((vec)[3], b, c); \
} \
(void)0
#define CLAMP4_MIN(vec, b) \
{ \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
CLAMP_MIN((vec)[2], b); \
CLAMP_MIN((vec)[3], b); \
} \
(void)0
#define CLAMP4_MAX(vec, b) \
{ \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
CLAMP_MAX((vec)[2], b); \
CLAMP_MAX((vec)[3], b); \
} \
(void)0
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Macros
* \{ */

View File

@ -10,12 +10,11 @@ import sys
BASEDIR = os.path.abspath(os.path.dirname(__file__))
inkscape_bin = os.environ.get("INKSCAPE_BIN", "inkscape")
if sys.platform == 'darwin':
inkscape_app_path = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
if os.path.exists(inkscape_app_path):
inkscape_bin = inkscape_app_path
if not (inkscape_bin := os.environ.get("INKSCAPE_BIN")):
if sys.platform == 'darwin':
inkscape_bin = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
else:
inkscape_bin = "inkscape"
cmd = (
inkscape_bin,

View File

@ -8,13 +8,21 @@ import os
import subprocess
import sys
from typing import (
Dict,
Generator,
Optional,
Sequence,
Tuple,
)
def run(cmd, *, env=None):
def run(cmd: Sequence[str], *, env: Optional[Dict[str, str]] = None) -> None:
print(" ", " ".join(cmd))
subprocess.check_call(cmd, env=env)
def edit_text_file(filename, marker_begin, marker_end, content):
def edit_text_file(filename: str, marker_begin: str, marker_end: str, content: str) -> None:
with open(filename, 'r', encoding='utf-8') as f:
data = f.read()
marker_begin_index = data.find(marker_begin)
@ -53,7 +61,7 @@ icons_blend = (
)
def names_and_time_from_path(path):
def names_and_time_from_path(path: str) -> Generator[Tuple[str, float], None, None]:
for entry in os.scandir(path):
name = entry.name
if name.endswith(".dat"):

View File

@ -8,8 +8,16 @@ import os
import subprocess
import sys
from typing import (
Dict,
List,
Optional,
Sequence,
Tuple,
)
def run(cmd, *, env=None):
def run(cmd: Sequence[str], *, env: Optional[Dict[str, str]] = None) -> None:
print(" ", " ".join(cmd))
subprocess.check_call(cmd, env=env)
@ -26,23 +34,15 @@ if sys.platform[:3] == "win":
env["SystemDrive"] = os.environ.get("SystemDrive", "")
env["SystemRoot"] = os.environ.get("SystemRoot", "")
inkscape_bin = "inkscape"
blender_bin = "blender"
if sys.platform == 'darwin':
inkscape_app_path = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
if os.path.exists(inkscape_app_path):
inkscape_bin = inkscape_app_path
blender_app_path = '/Applications/Blender.app/Contents/MacOS/Blender'
if os.path.exists(blender_app_path):
blender_bin = blender_app_path
if not (inkscape_bin := os.environ.get("INKSCAPE_BIN")):
if sys.platform == 'darwin':
inkscape_bin = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
else:
blender_bin = "Blender"
inkscape_bin = "inkscape"
inkscape_bin = os.environ.get("INKSCAPE_BIN", inkscape_bin)
blender_bin = os.environ.get("BLENDER_BIN", blender_bin)
blender_bin = os.environ.get("BLENDER_BIN", "blender")
cmd = (
cmd: Tuple[str, ...] = (
inkscape_bin,
os.path.join(BASEDIR, "blender_icons.svg"),
"--export-width=602",

View File

@ -24,17 +24,18 @@ except:
sys.stdout.write("Unable to open input %s\n" % argv[1])
sys.exit(1)
data = fpin.read().rsplit("{")[-1].split("}")[0]
data = data.replace(",", " ")
data = data.split()
data = [int(v) for v in data]
data_as_str = fpin.read().rsplit("{")[-1].split("}")[0]
data_as_str = data_as_str.replace(",", " ")
data_as_list = [int(v) for v in data_as_str.split()]
del data_as_str
if strip_byte:
# String data gets trailing byte.
last = data.pop()
last = data_as_list.pop()
assert last == 0
data = bytes(data)
data = bytes(data_as_list)
del data_as_list
dname = filename + ".ctodata"

View File

@ -10,12 +10,12 @@ import sys
BASEDIR = os.path.abspath(os.path.dirname(__file__))
inkscape_bin = os.environ.get("INKSCAPE_BIN", "inkscape")
if not (inkscape_bin := os.environ.get("INKSCAPE_BIN")):
if sys.platform == 'darwin':
inkscape_bin = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
else:
inkscape_bin = "inkscape"
if sys.platform == 'darwin':
inkscape_app_path = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
if os.path.exists(inkscape_app_path):
inkscape_bin = inkscape_app_path
cmd = (
inkscape_bin,

View File

@ -6,6 +6,7 @@ __all__ = (
"paths",
"modules",
"check",
"check_extension",
"enable",
"disable",
"disable_all",
@ -32,6 +33,8 @@ def _initialize_once():
for addon in _preferences.addons:
enable(addon.module)
_initialize_ensure_extensions_addon()
def paths():
return [
@ -66,7 +69,7 @@ def _paths_with_extension_repos():
for repo in _preferences.filepaths.extension_repos:
if not repo.enabled:
continue
dirpath = repo.directory
dirpath = repo.directory_or_default
if not os.path.isdir(dirpath):
continue
addon_paths.append((dirpath, "%s.%s" % (_ext_base_pkg_idname, repo.module)))
@ -80,6 +83,10 @@ def _fake_module(mod_name, mod_path, speedy=True, force_support=None):
if _bpy.app.debug_python:
print("fake_module", mod_path, mod_name)
if mod_name.startswith(_ext_base_pkg_idname_with_dot):
return _fake_module_from_extension(mod_name, mod_path, force_support=force_support)
import ast
ModuleType = type(ast)
try:
@ -266,6 +273,14 @@ def check(module_name):
return loaded_default, loaded_state
def check_extension(module_name):
"""
Return true if the module is an extension.
"""
return module_name.startswith(_ext_base_pkg_idname_with_dot)
# utility functions
@ -378,8 +393,8 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
print("Add-on not loaded: \"%s\", cause: %s" % (module_name, str(ex)))
# Issue with an add-on from an extension repository, report a useful message.
elif module_name.startswith(ex.name + ".") and module_name.startswith(_ext_base_pkg_idname + "."):
repo_id = module_name[len(_ext_base_pkg_idname) + 1:].rpartition(".")[0]
elif module_name.startswith(ex.name + ".") and module_name.startswith(_ext_base_pkg_idname_with_dot):
repo_id = module_name[len(_ext_base_pkg_idname_with_dot):].rpartition(".")[0]
repo = next(
(repo for repo in _preferences.filepaths.extension_repos if repo.module == repo_id),
None,
@ -406,14 +421,6 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
_addon_remove(module_name)
return None
# 1.1) Fail when add-on is too old.
# This is a temporary 2.8x migration check, so we can manage addons that are supported.
if mod.bl_info.get("blender", (0, 0, 0)) < (2, 80, 0):
if _bpy.app.debug:
print("Warning: Add-on '%s' was not upgraded for 2.80, ignoring" % module_name)
return None
# 2) Try register collected modules.
# Removed register_module, addons need to handle their own registration now.
@ -559,21 +566,25 @@ def _blender_manual_url_prefix():
return "https://docs.blender.org/manual/%s/%d.%d" % (_bpy.utils.manual_language_code(), *_bpy.app.version[:2])
def _bl_info_basis():
return {
"name": "",
"author": "",
"version": (),
"blender": (),
"location": "",
"description": "",
"doc_url": "",
"support": 'COMMUNITY',
"category": "",
"warning": "",
"show_expanded": False,
}
def module_bl_info(mod, *, info_basis=None):
if info_basis is None:
info_basis = {
"name": "",
"author": "",
"version": (),
"blender": (),
"location": "",
"description": "",
"doc_url": "",
"support": 'COMMUNITY',
"category": "",
"warning": "",
"show_expanded": False,
}
info_basis = _bl_info_basis()
addon_info = getattr(mod, "bl_info", {})
@ -603,9 +614,65 @@ def module_bl_info(mod, *, info_basis=None):
return addon_info
# -----------------------------------------------------------------------------
# Extension Utilities
def _fake_module_from_extension(mod_name, mod_path, force_support=None):
# Extract the `bl_info` from an extensions manifest.
# This is returned as a module which has a `bl_info` variable.
# When support for non-extension add-ons is dropped (Blender v5.0 perhaps)
# this can be updated not to use a fake module.
import os
import tomllib
bl_info = _bl_info_basis()
filepath = os.path.join(os.path.dirname(mod_path), _ext_manifest_filename_toml)
try:
with open(filepath, "rb") as fh:
data = tomllib.load(fh)
bl_info["name"] = data["name"]
bl_info["version"] = data["version"]
bl_info["author"] = data["author"]
bl_info["category"] = "Development" # Dummy, will be removed.
except BaseException as ex:
print("Error:", str(ex), "in", filepath)
return None
# Full validation must be done on install.
try:
assert type(bl_info["name"]) is str
assert type(bl_info["version"]) is str
assert type(bl_info["author"]) is str
assert type(bl_info["category"]) is str
except BaseException as ex:
print("Error:", str(ex), "in", filepath)
return None
if force_support is not None:
bl_info["support"] = force_support
ModuleType = type(os)
mod = ModuleType(mod_name)
mod.bl_info = bl_info
# TODO: implement a way to update based on the time of the TOML file.
mod.__file__ = mod_path
mod.__time__ = os.path.getmtime(mod_path)
return mod
# -----------------------------------------------------------------------------
# Extensions
def _initialize_ensure_extensions_addon():
if _preferences.experimental.use_extension_repos:
module_name = "bl_pkg"
if module_name not in _preferences.addons:
enable(module_name, default_set=True, persistent=True)
# Module-like class, store singletons.
class _ext_global:
__slots__ = ()
@ -623,6 +690,8 @@ class _ext_global:
# The name (in `sys.modules`) keep this short because it's stored as part of add-on modules name.
_ext_base_pkg_idname = "bl_ext"
_ext_base_pkg_idname_with_dot = _ext_base_pkg_idname + "."
_ext_manifest_filename_toml = "bl_manifest.toml"
def _extension_preferences_idmap():
@ -643,7 +712,7 @@ def _extension_dirpath_from_preferences():
for repo in _preferences.filepaths.extension_repos:
if not repo.enabled:
continue
repos_dict[repo.module] = repo.directory
repos_dict[repo.module] = repo.directory_or_default
return repos_dict
@ -683,12 +752,11 @@ def _initialize_extension_repos_post_addons_prepare(
# All preferences info.
# Map: `repo_id -> {submodule_id -> addon, ...}`.
addon_userdef_info = {}
module_prefix = _ext_base_pkg_idname + "."
for addon in _preferences.addons:
module = addon.module
if not module.startswith(module_prefix):
if not module.startswith(_ext_base_pkg_idname_with_dot):
continue
module_id, submodule_id = module[len(module_prefix):].partition(".")[0::2]
module_id, submodule_id = module[len(_ext_base_pkg_idname_with_dot):].partition(".")[0::2]
try:
addon_userdef_info[module_id][submodule_id] = addon
except KeyError:
@ -805,6 +873,10 @@ def _initialize_extension_repos_pre(*_):
@_bpy.app.handlers.persistent
def _initialize_extension_repos_post(*_, is_first=False):
# When enabling extensions for the first time, ensure the add-on is enabled.
_initialize_ensure_extensions_addon()
do_addons = not is_first
# Map `module_id` -> `dirpath`.

View File

@ -1307,6 +1307,19 @@ class RenderEngine(StructRNA, metaclass=RNAMeta):
__slots__ = ()
class UserExtensionRepo(StructRNA):
__slots__ = ()
@property
def directory_or_default(self):
"""Return ``directory`` or a default path derived from the users scripts path."""
if directory := self.directory:
return directory
import os
import bpy
return os.path.join(bpy.utils.user_resource('SCRIPTS', path="extensions"), self.module)
class HydraRenderEngine(RenderEngine):
__slots__ = ()

View File

@ -584,7 +584,7 @@ class ARMATURE_OT_collection_show_all(Operator):
class ARMATURE_OT_collection_remove_unused(Operator):
"""Remove all bone collections that have neither bones nor children.\n""" \
"""Remove all bone collections that have neither bones nor children. """ \
"""This is done recursively, so bone collections that only have unused children are also removed"""
bl_idname = "armature.collection_remove_unused"

View File

@ -75,7 +75,7 @@ class OBJECT_MT_modifier_add(ModifierAddMenu, Menu):
layout.menu("OBJECT_MT_modifier_add_edit")
if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE', 'VOLUME', 'GREASEPENCIL'}:
layout.menu("OBJECT_MT_modifier_add_generate")
if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE', 'LATTICE', 'VOLUME'}:
if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE', 'LATTICE', 'VOLUME', 'GREASEPENCIL'}:
layout.menu("OBJECT_MT_modifier_add_deform")
if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE', 'LATTICE'}:
layout.menu("OBJECT_MT_modifier_add_physics")
@ -150,7 +150,7 @@ class OBJECT_MT_modifier_add_generate(ModifierAddMenu, Menu):
if ob_type == 'MESH':
self.operator_modifier_add(layout, 'WIREFRAME')
if ob_type == 'GREASEPENCIL':
self.operator_modifier_add(layout, 'GREASEPENCIL_SUBDIV')
self.operator_modifier_add(layout, 'GREASE_PENCIL_SUBDIV')
layout.template_modifier_asset_menu_items(catalog_path=self.bl_label)
@ -187,6 +187,9 @@ class OBJECT_MT_modifier_add_deform(ModifierAddMenu, Menu):
self.operator_modifier_add(layout, 'WAVE')
if ob_type == 'VOLUME':
self.operator_modifier_add(layout, 'VOLUME_DISPLACE')
if ob_type == 'GREASEPENCIL':
self.operator_modifier_add(layout, 'GREASE_PENCIL_OFFSET')
self.operator_modifier_add(layout, 'GREASE_PENCIL_SMOOTH')
layout.template_modifier_asset_menu_items(catalog_path=self.bl_label)

View File

@ -943,7 +943,6 @@ def brush_settings_advanced(layout, context, brush, popover=False):
use_frontface = False
if mode == 'SCULPT':
sculpt = context.tool_settings.sculpt
capabilities = brush.sculpt_capabilities
use_accumulate = capabilities.has_accumulate
use_frontface = True
@ -1000,16 +999,16 @@ def brush_settings_advanced(layout, context, brush, popover=False):
col.prop(brush, "use_automasking_view_occlusion", text="Occlusion")
subcol = col.column(align=True)
subcol.active = not brush.use_automasking_view_occlusion
subcol.prop(sculpt, "automasking_view_normal_limit", text="Limit")
subcol.prop(sculpt, "automasking_view_normal_falloff", text="Falloff")
subcol.prop(brush, "automasking_view_normal_limit", text="Limit")
subcol.prop(brush, "automasking_view_normal_falloff", text="Falloff")
col = layout.column()
col.prop(brush, "use_automasking_start_normal", text="Area Normal")
if brush.use_automasking_start_normal:
col = layout.column(align=True)
col.prop(sculpt, "automasking_start_normal_limit", text="Limit")
col.prop(sculpt, "automasking_start_normal_falloff", text="Falloff")
col.prop(brush, "automasking_start_normal_limit", text="Limit")
col.prop(brush, "automasking_start_normal_falloff", text="Falloff")
layout.separator()

View File

@ -77,6 +77,7 @@ class TOPBAR_PT_tool_settings_extra(Panel):
bl_region_type = 'HEADER'
bl_space_type = 'TOPBAR'
bl_label = "Extra Options"
bl_description = "Extra options"
def draw(self, context):
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper

View File

@ -2021,10 +2021,9 @@ class USERPREF_PT_extensions(ExtensionsPanel, Panel):
layout = self.layout
row = layout.row()
row.label(text="The add-on to use extensions is disabled! See:")
row.operator(
"wm.url_open", text="Extension Add-on Repository", icon='URL',
).url = "https://projects.blender.org/ideasman42/bl_ext"
row.label(text="The add-on to use extensions is disabled!")
row = layout.row()
row.label(text="Enable \"Blender Extensions\" add-on in Testing to use extensions.")
class USERPREF_PT_extensions_repos(ExtensionsPanel, Panel):
@ -2254,132 +2253,141 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
if show_enabled_only:
is_visible = is_visible and is_enabled
if is_visible:
if search and not (
(search in info["name"].lower() or
search in iface_(info["name"]).lower()) or
(info["author"] and (search in info["author"].lower())) or
((filter == "All") and (search in info["category"].lower() or
search in iface_(info["category"]).lower()))
):
continue
if not is_visible:
continue
# Addon UI Code
col_box = col.column()
box = col_box.box()
colsub = box.column()
row = colsub.row(align=True)
if search and not (
(search in info["name"].lower() or
search in iface_(info["name"]).lower()) or
(info["author"] and (search in info["author"].lower())) or
((filter == "All") and (search in info["category"].lower() or
search in iface_(info["category"]).lower()))
):
continue
# Addon UI Code
col_box = col.column()
box = col_box.box()
colsub = box.column()
row = colsub.row(align=True)
is_extension = addon_utils.check_extension(module_name)
row.operator(
"preferences.addon_expand",
icon='DISCLOSURE_TRI_DOWN' if info["show_expanded"] else 'DISCLOSURE_TRI_RIGHT',
emboss=False,
).module = module_name
if not use_extension_repos:
row.operator(
"preferences.addon_expand",
icon='DISCLOSURE_TRI_DOWN' if info["show_expanded"] else 'DISCLOSURE_TRI_RIGHT',
"preferences.addon_disable" if is_enabled else "preferences.addon_enable",
icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
emboss=False,
).module = module_name
if not use_extension_repos:
row.operator(
"preferences.addon_disable" if is_enabled else "preferences.addon_enable",
icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
emboss=False,
).module = module_name
sub = row.row()
sub.active = is_enabled
if use_extension_repos:
sub.label(text=iface_(info["name"]))
else:
sub.label(text="%s: %s" % (iface_(info["category"]), iface_(info["name"])))
sub = row.row()
sub.active = is_enabled
if use_extension_repos:
sub.label(text=iface_(info["name"]))
else:
sub.label(text="%s: %s" % (iface_(info["category"]), iface_(info["name"])))
if info["warning"]:
sub.label(icon='ERROR')
if info["warning"]:
sub.label(icon='ERROR')
# icon showing support level.
if not use_extension_repos:
sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
# icon showing support level.
if not use_extension_repos:
sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
# Expanded UI (only if additional info is available)
if info["show_expanded"]:
if value := info["description"]:
split = colsub.row().split(factor=0.15)
split.label(text="Description:")
split.label(text=iface_(value))
if value := info["location"]:
split = colsub.row().split(factor=0.15)
split.label(text="Location:")
split.label(text=iface_(value))
if mod:
split = colsub.row().split(factor=0.15)
split.label(text="File:")
split.label(text=mod.__file__, translate=False)
if value := info["author"]:
split = colsub.row().split(factor=0.15)
split.label(text="Author:")
split.label(text=value, translate=False)
if value := info["version"]:
split = colsub.row().split(factor=0.15)
split.label(text="Version:")
# Extensions use SEMVER.
if is_extension:
split.label(text=value, translate=False)
else:
split.label(text=".".join(str(x) for x in value), translate=False)
if value := info["warning"]:
split = colsub.row().split(factor=0.15)
split.label(text="Warning:")
split.label(text=" " + iface_(value), icon='ERROR')
del value
# Expanded UI (only if additional info is available)
if info["show_expanded"]:
if info["description"]:
split = colsub.row().split(factor=0.15)
split.label(text="Description:")
split.label(text=iface_(info["description"]))
if info["location"]:
split = colsub.row().split(factor=0.15)
split.label(text="Location:")
split.label(text=iface_(info["location"]))
if mod:
split = colsub.row().split(factor=0.15)
split.label(text="File:")
split.label(text=mod.__file__, translate=False)
if info["author"]:
split = colsub.row().split(factor=0.15)
split.label(text="Author:")
split.label(text=info["author"], translate=False)
if info["version"]:
split = colsub.row().split(factor=0.15)
split.label(text="Version:")
split.label(text=".".join(str(x) for x in info["version"]), translate=False)
if info["warning"]:
split = colsub.row().split(factor=0.15)
split.label(text="Warning:")
split.label(text=" " + iface_(info["warning"]), icon='ERROR')
user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
if info["doc_url"] or info.get("tracker_url"):
split = colsub.row().split(factor=0.15)
split.label(text="Internet:")
sub = split.row()
if info["doc_url"]:
sub.operator(
"wm.url_open", text="Documentation", icon='HELP',
).url = info["doc_url"]
# Only add "Report a Bug" button if tracker_url is set
# or the add-on is bundled (use official tracker then).
if info.get("tracker_url"):
sub.operator(
"wm.url_open", text="Report a Bug", icon='URL',
).url = info["tracker_url"]
elif not user_addon:
addon_info = (
"Name: %s %s\n"
"Author: %s\n"
) % (info["name"], str(info["version"]), info["author"])
props = sub.operator(
"wm.url_open_preset", text="Report a Bug", icon='URL',
)
props.type = 'BUG_ADDON'
props.id = addon_info
user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
if info["doc_url"] or info.get("tracker_url"):
split = colsub.row().split(factor=0.15)
split.label(text="Internet:")
sub = split.row()
if info["doc_url"]:
sub.operator(
"wm.url_open", text="Documentation", icon='HELP',
).url = info["doc_url"]
# Only add "Report a Bug" button if tracker_url is set
# or the add-on is bundled (use official tracker then).
if info.get("tracker_url"):
sub.operator(
"wm.url_open", text="Report a Bug", icon='URL',
).url = info["tracker_url"]
elif not user_addon:
addon_info = (
"Name: %s %s\n"
"Author: %s\n"
) % (info["name"], str(info["version"]), info["author"])
props = sub.operator(
"wm.url_open_preset", text="Report a Bug", icon='URL',
)
props.type = 'BUG_ADDON'
props.id = addon_info
if user_addon:
split = colsub.row().split(factor=0.15)
split.label(text="User:")
split.operator(
"preferences.addon_remove", text="Remove", icon='CANCEL',
).module = mod.__name__
if user_addon:
split = colsub.row().split(factor=0.15)
split.label(text="User:")
split.operator(
"preferences.addon_remove", text="Remove", icon='CANCEL',
).module = mod.__name__
# Show addon user preferences
if is_enabled:
addon_preferences = prefs.addons[module_name].preferences
if addon_preferences is not None:
draw = getattr(addon_preferences, "draw", None)
if draw is not None:
addon_preferences_class = type(addon_preferences)
box_prefs = col_box.box()
box_prefs.label(text="Preferences:")
addon_preferences_class.layout = box_prefs
try:
draw(context)
except BaseException:
import traceback
traceback.print_exc()
box_prefs.label(text="Error (see console)", icon='ERROR')
del addon_preferences_class.layout
if use_extension_repos:
row.operator(
"preferences.addon_disable" if is_enabled else "preferences.addon_enable",
icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
emboss=False,
).module = module_name
# Show addon user preferences
if is_enabled:
addon_preferences = prefs.addons[module_name].preferences
if addon_preferences is not None:
draw = getattr(addon_preferences, "draw", None)
if draw is not None:
addon_preferences_class = type(addon_preferences)
box_prefs = col_box.box()
box_prefs.label(text="Preferences:")
addon_preferences_class.layout = box_prefs
try:
draw(context)
except BaseException:
import traceback
traceback.print_exc()
box_prefs.label(text="Error (see console)", icon='ERROR')
del addon_preferences_class.layout
if use_extension_repos:
row.operator(
"preferences.addon_disable" if is_enabled else "preferences.addon_enable",
icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
emboss=False,
).module = module_name
# Append missing scripts
# First collect scripts that are used but have no script file.

View File

@ -1081,19 +1081,6 @@ class VIEW3D_HT_header(Header):
sub.popover(panel="VIEW3D_PT_shading", text="")
class VIEW3D_AST_brush_asset_shelf(bpy.types.AssetShelf):
bl_space_type = "VIEW_3D"
bl_options = {'NO_ASSET_DRAG'}
@classmethod
def poll(cls, context):
return context.object and context.object.mode == 'SCULPT_CURVES'
@classmethod
def asset_poll(cls, asset):
return asset.id_type == 'BRUSH' and asset.metadata.get("use_paint_sculpt_curves", False)
class VIEW3D_MT_editor_menus(Menu):
bl_label = ""
@ -8769,28 +8756,73 @@ class VIEW3D_PT_viewport_debug(Panel):
layout.prop(overlay, "use_debug_freeze_view_culling")
class VIEW3D_AST_sculpt_brushes(bpy.types.AssetShelf):
# Experimental: Asset shelf for sculpt brushes, only shows up if both the
# "Asset Shelf" and the "Extended Asset Browser" experimental features are
# enabled.
bl_space_type = 'VIEW_3D'
class BrushAssetShelf:
bl_space_type = "VIEW_3D"
bl_options = {'NO_ASSET_DRAG'}
@classmethod
def poll(cls, context):
prefs = context.preferences
if not prefs.experimental.use_extended_asset_browser:
return False
return context.mode == 'SCULPT'
return context.object and context.object.mode == cls.mode
@classmethod
def asset_poll(cls, asset):
return asset.id_type == 'BRUSH'
if asset.id_type != 'BRUSH':
return False
return asset.metadata.get(cls.mode_prop, False)
class VIEW3D_AST_brush_sculpt(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'SCULPT'
mode_prop = "use_paint_sculpt"
class VIEW3D_AST_brush_sculpt_curves(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'SCULPT_CURVES'
mode_prop = "use_paint_sculpt_curves"
class VIEW3D_AST_brush_vertex_paint(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'VERTEX_PAINT'
mode_prop = "use_paint_vertex"
class VIEW3D_AST_brush_weight_paint(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'WEIGHT_PAINT'
mode_prop = "use_paint_weight"
class VIEW3D_AST_brush_texture_paint(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'TEXTURE_PAINT'
mode_prop = "use_paint_image"
class VIEW3D_AST_brush_gpencil_paint(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'PAINT_GPENCIL'
mode_prop = "use_paint_grease_pencil"
class VIEW3D_AST_brush_grease_pencil_paint(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'PAINT_GREASE_PENCIL'
mode_prop = "use_paint_grease_pencil"
class VIEW3D_AST_brush_gpencil_sculpt(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'SCULPT_GPENCIL'
mode_prop = "use_sculpt_grease_pencil"
class VIEW3D_AST_brush_gpencil_vertex(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'VERTEX_GPENCIL'
mode_prop = "use_vertex_grease_pencil"
class VIEW3D_AST_brush_gpencil_weight(BrushAssetShelf, bpy.types.AssetShelf):
mode = 'WEIGHT_GPENCIL'
mode_prop = "use_weight_grease_pencil"
classes = (
VIEW3D_AST_brush_asset_shelf,
VIEW3D_HT_header,
VIEW3D_HT_tool_header,
VIEW3D_MT_editor_menus,
@ -9048,7 +9080,16 @@ classes = (
VIEW3D_PT_curves_sculpt_parameter_falloff,
VIEW3D_PT_curves_sculpt_grow_shrink_scaling,
VIEW3D_PT_viewport_debug,
VIEW3D_AST_sculpt_brushes,
VIEW3D_AST_brush_sculpt,
VIEW3D_AST_brush_sculpt_curves,
VIEW3D_AST_brush_vertex_paint,
VIEW3D_AST_brush_weight_paint,
VIEW3D_AST_brush_texture_paint,
VIEW3D_AST_brush_gpencil_paint,
VIEW3D_AST_brush_grease_pencil_paint,
VIEW3D_AST_brush_gpencil_sculpt,
VIEW3D_AST_brush_gpencil_vertex,
VIEW3D_AST_brush_gpencil_weight,
)

View File

@ -9,7 +9,7 @@
#include "BKE_animsys.h"
#include "BKE_context.hh"
#include "BKE_fcurve.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_object.hh"
#include "BKE_scene.h"

View File

@ -17,11 +17,9 @@ namespace blender::asset_system {
StringRefNull essentials_directory_path()
{
static std::string path = []() {
const char *datafiles_path = BKE_appdir_folder_id(BLENDER_DATAFILES, "assets");
if (datafiles_path == nullptr) {
return "";
}
return datafiles_path;
const std::optional<std::string> datafiles_path = BKE_appdir_folder_id(BLENDER_DATAFILES,
"assets");
return datafiles_path.value_or("");
}();
return path;
}

View File

@ -23,8 +23,9 @@
static int blf_load_font_default(const char *filename, const bool unique)
{
const char *dir = BKE_appdir_folder_id(BLENDER_DATAFILES, BLF_DATAFILES_FONTS_DIR);
if (dir == nullptr) {
const std::optional<std::string> dir = BKE_appdir_folder_id(BLENDER_DATAFILES,
BLF_DATAFILES_FONTS_DIR);
if (!dir.has_value()) {
fprintf(stderr,
"%s: 'fonts' data path not found for '%s', will not be able to display text\n",
__func__,
@ -33,7 +34,7 @@ static int blf_load_font_default(const char *filename, const bool unique)
}
char filepath[FILE_MAX];
BLI_path_join(filepath, sizeof(filepath), dir, filename);
BLI_path_join(filepath, sizeof(filepath), dir->c_str(), filename);
return (unique) ? BLF_load_unique(filepath) : BLF_load(filepath);
}
@ -55,18 +56,15 @@ int BLF_load_mono_default(const bool unique)
static void blf_load_datafiles_dir()
{
const char *datafiles_fonts_dir = BLF_DATAFILES_FONTS_DIR SEP_STR;
const char *path = BKE_appdir_folder_id(BLENDER_DATAFILES, datafiles_fonts_dir);
if (UNLIKELY(!path)) {
const std::optional<std::string> path = BKE_appdir_folder_id(BLENDER_DATAFILES,
datafiles_fonts_dir);
if (!path.has_value()) {
fprintf(stderr, "Font data directory \"%s\" could not be detected!\n", datafiles_fonts_dir);
return;
}
if (UNLIKELY(!BLI_exists(path))) {
fprintf(stderr, "Font data directory \"%s\" does not exist!\n", path);
return;
}
direntry *file_list;
uint file_list_num = BLI_filelist_dir_contents(path, &file_list);
uint file_list_num = BLI_filelist_dir_contents(path->c_str(), &file_list);
for (int i = 0; i < file_list_num; i++) {
if (S_ISDIR(file_list[i].s.st_mode)) {
continue;

View File

@ -12,6 +12,9 @@
#include <stddef.h>
#include <optional>
#include <string>
#include "BLI_compiler_attrs.h"
struct ListBase;
@ -76,25 +79,26 @@ bool BKE_appdir_folder_id_ex(int folder_id,
const char *subfolder,
char *path,
size_t path_maxncpy);
const char *BKE_appdir_folder_id(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT;
std::optional<std::string> BKE_appdir_folder_id(int folder_id,
const char *subfolder) ATTR_WARN_UNUSED_RESULT;
/**
* Returns the path to a folder in the user area, creating it if it doesn't exist.
*/
const char *BKE_appdir_folder_id_create(int folder_id,
const char *subfolder) ATTR_WARN_UNUSED_RESULT;
std::optional<std::string> BKE_appdir_folder_id_create(int folder_id, const char *subfolder)
ATTR_WARN_UNUSED_RESULT;
/**
* Returns the path to a folder in the user area without checking that it actually exists first.
*/
const char *BKE_appdir_folder_id_user_notest(int folder_id,
const char *subfolder) ATTR_WARN_UNUSED_RESULT;
std::optional<std::string> BKE_appdir_folder_id_user_notest(int folder_id, const char *subfolder)
ATTR_WARN_UNUSED_RESULT;
/**
* Returns the path of the top-level version-specific local, user or system directory.
* If check_is_dir, then the result will be NULL if the directory doesn't exist.
*/
const char *BKE_appdir_resource_path_id_with_version(int folder_id,
bool check_is_dir,
int version);
const char *BKE_appdir_resource_path_id(int folder_id, bool check_is_dir);
std::optional<std::string> BKE_appdir_resource_path_id_with_version(int folder_id,
bool check_is_dir,
int version);
std::optional<std::string> BKE_appdir_resource_path_id(int folder_id, bool check_is_dir);
/**
* Check if this is an install with user files kept together

View File

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 13
#define BLENDER_FILE_SUBVERSION 14
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@ -8,16 +8,14 @@
* \ingroup bke
*/
#include "BLI_vector.hh"
#include "BKE_collection.h"
#include "DNA_layer_types.h"
#include "DNA_listBase.h"
#include "DNA_object_enums.h"
#ifdef __cplusplus
extern "C" {
#endif
struct Base;
struct BlendDataReader;
struct BlendLibReader;
@ -32,32 +30,32 @@ struct Scene;
struct View3D;
struct ViewLayer;
typedef enum eViewLayerCopyMethod {
enum eViewLayerCopyMethod {
VIEWLAYER_ADD_NEW = 0,
VIEWLAYER_ADD_EMPTY = 1,
VIEWLAYER_ADD_COPY = 2,
} eViewLayerCopyMethod;
};
/**
* Returns the default view layer to view in work-spaces if there is
* none linked to the workspace yet.
*/
struct ViewLayer *BKE_view_layer_default_view(const struct Scene *scene);
ViewLayer *BKE_view_layer_default_view(const Scene *scene);
/**
* Returns the default view layer to render if we need to render just one.
*/
struct ViewLayer *BKE_view_layer_default_render(const struct Scene *scene);
ViewLayer *BKE_view_layer_default_render(const Scene *scene);
/**
* Returns view layer with matching name, or NULL if not found.
*/
struct ViewLayer *BKE_view_layer_find(const struct Scene *scene, const char *layer_name);
ViewLayer *BKE_view_layer_find(const Scene *scene, const char *layer_name);
/**
* Add a new view layer by default, a view layer has the master collection.
*/
struct ViewLayer *BKE_view_layer_add(struct Scene *scene,
const char *name,
struct ViewLayer *view_layer_source,
int type);
ViewLayer *BKE_view_layer_add(Scene *scene,
const char *name,
ViewLayer *view_layer_source,
int type);
/* DEPRECATED */
/**
@ -65,26 +63,24 @@ struct ViewLayer *BKE_view_layer_add(struct Scene *scene,
* for the Workspace changes. Never use this, you should typically get the
* active layer from the context or window.
*/
struct ViewLayer *BKE_view_layer_context_active_PLACEHOLDER(const struct Scene *scene);
ViewLayer *BKE_view_layer_context_active_PLACEHOLDER(const Scene *scene);
void BKE_view_layer_free(struct ViewLayer *view_layer);
void BKE_view_layer_free(ViewLayer *view_layer);
/**
* Free (or release) any data used by this #ViewLayer.
*/
void BKE_view_layer_free_ex(struct ViewLayer *view_layer, bool do_id_user);
void BKE_view_layer_free_ex(ViewLayer *view_layer, bool do_id_user);
/**
* Free the bases of this #ViewLayer, and what they reference.
* This includes baseact, object_bases, object_bases_hash, and layer_collections.
*/
void BKE_view_layer_free_object_content(struct ViewLayer *view_layer);
void BKE_view_layer_free_object_content(ViewLayer *view_layer);
/**
* Tag all the selected objects of a render-layer.
*/
void BKE_view_layer_selected_objects_tag(const struct Scene *scene,
struct ViewLayer *view_layer,
int tag);
void BKE_view_layer_selected_objects_tag(const Scene *scene, ViewLayer *view_layer, int tag);
/**
* Fallback for when a Scene has no camera to use.
@ -93,63 +89,58 @@ void BKE_view_layer_selected_objects_tag(const struct Scene *scene,
* If rendering you pass the scene active layer, when viewing in the viewport
* you want to get #ViewLayer from context.
*/
struct Object *BKE_view_layer_camera_find(const struct Scene *scene, struct ViewLayer *view_layer);
Object *BKE_view_layer_camera_find(const Scene *scene, ViewLayer *view_layer);
/**
* Find the #ViewLayer a #LayerCollection belongs to.
*/
struct ViewLayer *BKE_view_layer_find_from_collection(const struct Scene *scene,
struct LayerCollection *lc);
struct Base *BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob);
void BKE_view_layer_base_deselect_all(const struct Scene *scene, struct ViewLayer *view_layer);
ViewLayer *BKE_view_layer_find_from_collection(const Scene *scene, LayerCollection *lc);
Base *BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob);
void BKE_view_layer_base_deselect_all(const Scene *scene, ViewLayer *view_layer);
void BKE_view_layer_base_select_and_set_active(struct ViewLayer *view_layer, struct Base *selbase);
void BKE_view_layer_base_select_and_set_active(ViewLayer *view_layer, Base *selbase);
/**
* Only copy internal data of #ViewLayer from source to already allocated/initialized destination.
*
* \param flag: Copying options (see BKE_lib_id.hh's LIB_ID_COPY_... flags for more).
*/
void BKE_view_layer_copy_data(struct Scene *scene_dst,
const struct Scene *scene_src,
struct ViewLayer *view_layer_dst,
const struct ViewLayer *view_layer_src,
void BKE_view_layer_copy_data(Scene *scene_dst,
const Scene *scene_src,
ViewLayer *view_layer_dst,
const ViewLayer *view_layer_src,
int flag);
void BKE_view_layer_rename(struct Main *bmain,
struct Scene *scene,
struct ViewLayer *view_layer,
const char *name);
void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, const char *name);
/**
* Get the active collection
*/
struct LayerCollection *BKE_layer_collection_get_active(struct ViewLayer *view_layer);
LayerCollection *BKE_layer_collection_get_active(ViewLayer *view_layer);
/**
* Activate collection
*/
bool BKE_layer_collection_activate(struct ViewLayer *view_layer, struct LayerCollection *lc);
bool BKE_layer_collection_activate(ViewLayer *view_layer, LayerCollection *lc);
/**
* Activate first parent collection.
*/
struct LayerCollection *BKE_layer_collection_activate_parent(struct ViewLayer *view_layer,
struct LayerCollection *lc);
LayerCollection *BKE_layer_collection_activate_parent(ViewLayer *view_layer, LayerCollection *lc);
/**
* Get the total number of collections (including all the nested collections)
*/
int BKE_layer_collection_count(const struct ViewLayer *view_layer);
int BKE_layer_collection_count(const ViewLayer *view_layer);
/**
* Get the collection for a given index.
*/
struct LayerCollection *BKE_layer_collection_from_index(struct ViewLayer *view_layer, int index);
LayerCollection *BKE_layer_collection_from_index(ViewLayer *view_layer, int index);
/**
* \return -1 if not found.
*/
int BKE_layer_collection_findindex(struct ViewLayer *view_layer, const struct LayerCollection *lc);
int BKE_layer_collection_findindex(ViewLayer *view_layer, const LayerCollection *lc);
void BKE_layer_collection_resync_forbid(void);
void BKE_layer_collection_resync_allow(void);
void BKE_layer_collection_resync_forbid();
void BKE_layer_collection_resync_allow();
/**
* Helper to fix older pre-2.80 blend-files.
@ -157,40 +148,37 @@ void BKE_layer_collection_resync_allow(void);
* Ensures the given `view_layer` as a valid first-level layer collection, i.e. a single one
* matching the scene's master collection. This is a requirement for `BKE_layer_collection_sync`.
*/
void BKE_layer_collection_doversion_2_80(const struct Scene *scene, struct ViewLayer *view_layer);
void BKE_layer_collection_doversion_2_80(const Scene *scene, ViewLayer *view_layer);
void BKE_main_collection_sync(const struct Main *bmain);
void BKE_scene_collection_sync(const struct Scene *scene);
void BKE_main_collection_sync(const Main *bmain);
void BKE_scene_collection_sync(const Scene *scene);
/**
* Update view layer collection tree from collections used in the scene.
* This is used when collections are removed or added, both while editing
* and on file loaded in case linked data changed or went missing.
*/
void BKE_layer_collection_sync(const struct Scene *scene, struct ViewLayer *view_layer);
void BKE_layer_collection_local_sync(const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d);
void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer);
void BKE_layer_collection_local_sync(const Scene *scene, ViewLayer *view_layer, const View3D *v3d);
/**
* Sync the local collection for all the 3D Viewports.
*/
void BKE_layer_collection_local_sync_all(const struct Main *bmain);
void BKE_layer_collection_local_sync_all(const Main *bmain);
void BKE_main_collection_sync_remap(const struct Main *bmain);
void BKE_main_collection_sync_remap(const Main *bmain);
/**
* Return the first matching #LayerCollection in the #ViewLayer for the Collection.
*/
struct LayerCollection *BKE_layer_collection_first_from_scene_collection(
const struct ViewLayer *view_layer, const struct Collection *collection);
LayerCollection *BKE_layer_collection_first_from_scene_collection(const ViewLayer *view_layer,
const Collection *collection);
/**
* See if view layer has the scene collection linked directly, or indirectly (nested).
*/
bool BKE_view_layer_has_collection(const struct ViewLayer *view_layer,
const struct Collection *collection);
bool BKE_view_layer_has_collection(const ViewLayer *view_layer, const Collection *collection);
/**
* See if the object is in any of the scene layers of the scene.
*/
bool BKE_scene_has_object(struct Scene *scene, struct Object *ob);
bool BKE_scene_has_object(Scene *scene, Object *ob);
/* Selection and hiding. */
@ -200,25 +188,22 @@ bool BKE_scene_has_object(struct Scene *scene, struct Object *ob);
* It also select the objects that are in nested collections.
* \note Recursive.
*/
bool BKE_layer_collection_objects_select(const struct Scene *scene,
struct ViewLayer *view_layer,
struct LayerCollection *lc,
bool BKE_layer_collection_objects_select(const Scene *scene,
ViewLayer *view_layer,
LayerCollection *lc,
bool deselect);
bool BKE_layer_collection_has_selected_objects(const struct Scene *scene,
struct ViewLayer *view_layer,
struct LayerCollection *lc);
bool BKE_layer_collection_has_layer_collection(struct LayerCollection *lc_parent,
struct LayerCollection *lc_child);
bool BKE_layer_collection_has_selected_objects(const Scene *scene,
ViewLayer *view_layer,
LayerCollection *lc);
bool BKE_layer_collection_has_layer_collection(LayerCollection *lc_parent,
LayerCollection *lc_child);
/**
* Update after toggling visibility of an object base.
*/
void BKE_base_set_visible(struct Scene *scene,
struct ViewLayer *view_layer,
struct Base *base,
bool extend);
bool BKE_base_is_visible(const struct View3D *v3d, const struct Base *base);
bool BKE_object_is_visible_in_viewport(const struct View3D *v3d, const struct Object *ob);
void BKE_base_set_visible(Scene *scene, ViewLayer *view_layer, Base *base, bool extend);
bool BKE_base_is_visible(const View3D *v3d, const Base *base);
bool BKE_object_is_visible_in_viewport(const View3D *v3d, const Object *ob);
/**
* Isolate the collection - hide all other collections but this one.
* Make sure to show all the direct parents and all children of the layer collection as well.
@ -227,31 +212,28 @@ bool BKE_object_is_visible_in_viewport(const struct View3D *v3d, const struct Ob
* If the collection or any of its parents is disabled, make it enabled.
* Don't change the children disable state though.
*/
void BKE_layer_collection_isolate_global(struct Scene *scene,
struct ViewLayer *view_layer,
struct LayerCollection *lc,
void BKE_layer_collection_isolate_global(Scene *scene,
ViewLayer *view_layer,
LayerCollection *lc,
bool extend);
/**
* Isolate the collection locally
*
* Same as #BKE_layer_collection_isolate_local but for a viewport
*/
void BKE_layer_collection_isolate_local(const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d,
struct LayerCollection *lc,
void BKE_layer_collection_isolate_local(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
LayerCollection *lc,
bool extend);
/**
* Hide/show all the elements of a collection.
* Don't change the collection children enable/disable state,
* but it may change it for the collection itself.
*/
void BKE_layer_collection_set_visible(const struct Scene *scene,
struct ViewLayer *view_layer,
struct LayerCollection *lc,
bool visible,
bool hierarchy);
void BKE_layer_collection_set_flag(struct LayerCollection *lc, int flag, bool value);
void BKE_layer_collection_set_visible(
const Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool visible, bool hierarchy);
void BKE_layer_collection_set_flag(LayerCollection *lc, int flag, bool value);
/* Evaluation. */
@ -260,28 +242,24 @@ void BKE_layer_collection_set_flag(struct LayerCollection *lc, int flag, bool va
* and stores those in `base->flag`. #BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT ignores viewport
* flags visibility (i.e., restriction and local collection).
*/
void BKE_base_eval_flags(struct Base *base);
void BKE_base_eval_flags(Base *base);
void BKE_layer_eval_view_layer_indexed(struct Depsgraph *depsgraph,
struct Scene *scene,
int view_layer_index);
void BKE_layer_eval_view_layer_indexed(Depsgraph *depsgraph, Scene *scene, int view_layer_index);
/* .blend file I/O */
void BKE_view_layer_blend_write(struct BlendWriter *writer,
const struct Scene *scene,
struct ViewLayer *view_layer);
void BKE_view_layer_blend_read_data(struct BlendDataReader *reader, struct ViewLayer *view_layer);
void BKE_view_layer_blend_read_after_liblink(struct BlendLibReader *reader,
struct ID *self_id,
struct ViewLayer *view_layer);
void BKE_view_layer_blend_write(BlendWriter *writer, const Scene *scene, ViewLayer *view_layer);
void BKE_view_layer_blend_read_data(BlendDataReader *reader, ViewLayer *view_layer);
void BKE_view_layer_blend_read_after_liblink(BlendLibReader *reader,
ID *self_id,
ViewLayer *view_layer);
/* iterators */
typedef struct ObjectsVisibleIteratorData {
struct ViewLayer *view_layer;
const struct View3D *v3d;
} ObjectsVisibleIteratorData;
struct ObjectsVisibleIteratorData {
ViewLayer *view_layer;
const View3D *v3d;
};
void BKE_view_layer_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
void BKE_view_layer_selected_objects_iterator_next(BLI_Iterator *iter);
@ -298,9 +276,9 @@ void BKE_view_layer_selected_editable_objects_iterator_end(BLI_Iterator *iter);
struct ObjectsInModeIteratorData {
int object_mode;
int object_type;
struct ViewLayer *view_layer;
const struct View3D *v3d;
struct Base *base_active;
ViewLayer *view_layer;
const View3D *v3d;
Base *base_active;
};
void BKE_view_layer_bases_in_mode_iterator_begin(BLI_Iterator *iter, void *data_in);
@ -317,7 +295,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
#define FOREACH_SELECTED_OBJECT_BEGIN(_view_layer, _v3d, _instance) \
{ \
struct ObjectsVisibleIteratorData data_ = {NULL}; \
ObjectsVisibleIteratorData data_ = {NULL}; \
data_.view_layer = _view_layer; \
data_.v3d = _v3d; \
ITER_BEGIN (BKE_view_layer_selected_objects_iterator_begin, \
@ -334,7 +312,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
#define FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN(_view_layer, _v3d, _instance) \
{ \
struct ObjectsVisibleIteratorData data_ = {NULL}; \
ObjectsVisibleIteratorData data_ = {NULL}; \
data_.view_layer = _view_layer; \
data_.v3d = _v3d; \
ITER_BEGIN (BKE_view_layer_selected_editable_objects_iterator_begin, \
@ -351,7 +329,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
#define FOREACH_VISIBLE_OBJECT_BEGIN(_view_layer, _v3d, _instance) \
{ \
struct ObjectsVisibleIteratorData data_ = {NULL}; \
ObjectsVisibleIteratorData data_ = {NULL}; \
data_.view_layer = _view_layer; \
data_.v3d = _v3d; \
ITER_BEGIN (BKE_view_layer_visible_objects_iterator_begin, \
@ -369,7 +347,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
#define FOREACH_BASE_IN_MODE_BEGIN( \
_scene, _view_layer, _v3d, _object_type, _object_mode, _instance) \
{ \
struct ObjectsInModeIteratorData data_; \
ObjectsInModeIteratorData data_; \
memset(&data_, 0, sizeof(data_)); \
data_.object_mode = _object_mode; \
data_.object_type = _object_type; \
@ -423,7 +401,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
#define FOREACH_VISIBLE_BASE_BEGIN(_scene, _view_layer, _v3d, _instance) \
{ \
struct ObjectsVisibleIteratorData data_ = {NULL}; \
ObjectsVisibleIteratorData data_ = {NULL}; \
data_.view_layer = _view_layer; \
data_.v3d = _v3d; \
BKE_view_layer_synced_ensure(_scene, _view_layer); \
@ -460,11 +438,11 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
IteratorCb func_next, func_end; \
void *data_in; \
\
struct ObjectsVisibleIteratorData data_select_ = {NULL}; \
ObjectsVisibleIteratorData data_select_ = {NULL}; \
data_select_.view_layer = _view_layer; \
data_select_.v3d = _v3d; \
\
struct SceneObjectsIteratorExData data_flag_ = {NULL}; \
SceneObjectsIteratorExData data_flag_ = {NULL}; \
data_flag_.scene = scene; \
data_flag_.flag = flag; \
\
@ -498,15 +476,12 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
struct ObjectsInViewLayerParams {
uint no_dup_data : 1;
bool (*filter_fn)(const struct Object *ob, void *user_data);
bool (*filter_fn)(const Object *ob, void *user_data);
void *filter_userdata;
};
struct Object **BKE_view_layer_array_selected_objects_params(
struct ViewLayer *view_layer,
const struct View3D *v3d,
uint *r_len,
const struct ObjectsInViewLayerParams *params);
blender::Vector<Object *> BKE_view_layer_array_selected_objects_params(
ViewLayer *view_layer, const View3D *v3d, const ObjectsInViewLayerParams *params);
/**
* Use this in rare cases we need to detect a pair of objects (active, selected).
@ -515,83 +490,67 @@ struct Object **BKE_view_layer_array_selected_objects_params(
* Returns NULL with it finds multiple other selected objects
* as behavior in this case would be random from the user perspective.
*/
struct Object *BKE_view_layer_non_active_selected_object(const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d);
Object *BKE_view_layer_non_active_selected_object(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d);
struct ObjectsInModeParams {
int object_mode;
uint no_dup_data : 1;
bool (*filter_fn)(const struct Object *ob, void *user_data);
bool (*filter_fn)(const Object *ob, void *user_data);
void *filter_userdata;
};
struct Base **BKE_view_layer_array_from_bases_in_mode_params(
const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d,
uint *r_len,
const struct ObjectsInModeParams *params);
blender::Vector<Base *> BKE_view_layer_array_from_bases_in_mode_params(
const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
const ObjectsInModeParams *params);
struct Object **BKE_view_layer_array_from_objects_in_mode_params(
const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d,
uint *len,
const struct ObjectsInModeParams *params);
blender::Vector<Object *> BKE_view_layer_array_from_objects_in_mode_params(
const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
const ObjectsInModeParams *params);
bool BKE_view_layer_filter_edit_mesh_has_uvs(const struct Object *ob, void *user_data);
bool BKE_view_layer_filter_edit_mesh_has_edges(const struct Object *ob, void *user_data);
bool BKE_view_layer_filter_edit_mesh_has_uvs(const Object *ob, void *user_data);
bool BKE_view_layer_filter_edit_mesh_has_edges(const Object *ob, void *user_data);
/* Utility functions that wrap common arguments (add more as needed). */
struct Object **BKE_view_layer_array_from_objects_in_edit_mode(const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d,
uint *r_len);
struct Base **BKE_view_layer_array_from_bases_in_edit_mode(const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d,
uint *r_len);
struct Object **BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d,
uint *r_len);
blender::Vector<Object *> BKE_view_layer_array_from_objects_in_edit_mode(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d);
blender::Vector<Base *> BKE_view_layer_array_from_bases_in_edit_mode(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d);
blender::Vector<Object *> BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
const Scene *scene, ViewLayer *view_layer, const View3D *v3d);
struct Base **BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d,
uint *r_len);
struct Object **BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d,
uint *r_len);
struct Object **BKE_view_layer_array_from_objects_in_mode_unique_data(const struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d,
uint *r_len,
eObjectMode mode);
struct Object *BKE_view_layer_active_object_get(const struct ViewLayer *view_layer);
struct Object *BKE_view_layer_edit_object_get(const struct ViewLayer *view_layer);
blender::Vector<Base *> BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
const Scene *scene, ViewLayer *view_layer, const View3D *v3d);
blender::Vector<Object *> BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
const Scene *scene, ViewLayer *view_layer, const View3D *v3d);
blender::Vector<Object *> BKE_view_layer_array_from_objects_in_mode_unique_data(
const Scene *scene, ViewLayer *view_layer, const View3D *v3d, eObjectMode mode);
Object *BKE_view_layer_active_object_get(const ViewLayer *view_layer);
Object *BKE_view_layer_edit_object_get(const ViewLayer *view_layer);
struct ListBase *BKE_view_layer_object_bases_get(struct ViewLayer *view_layer);
struct Base *BKE_view_layer_active_base_get(struct ViewLayer *view_layer);
ListBase *BKE_view_layer_object_bases_get(ViewLayer *view_layer);
Base *BKE_view_layer_active_base_get(ViewLayer *view_layer);
struct LayerCollection *BKE_view_layer_active_collection_get(struct ViewLayer *view_layer);
LayerCollection *BKE_view_layer_active_collection_get(ViewLayer *view_layer);
void BKE_view_layer_need_resync_tag(struct ViewLayer *view_layer);
void BKE_view_layer_synced_ensure(const struct Scene *scene, struct ViewLayer *view_layer);
void BKE_view_layer_need_resync_tag(ViewLayer *view_layer);
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer);
void BKE_scene_view_layers_synced_ensure(const struct Scene *scene);
void BKE_main_view_layers_synced_ensure(const struct Main *bmain);
void BKE_scene_view_layers_synced_ensure(const Scene *scene);
void BKE_main_view_layers_synced_ensure(const Main *bmain);
struct ViewLayerAOV *BKE_view_layer_add_aov(struct ViewLayer *view_layer);
void BKE_view_layer_remove_aov(struct ViewLayer *view_layer, struct ViewLayerAOV *aov);
void BKE_view_layer_set_active_aov(struct ViewLayer *view_layer, struct ViewLayerAOV *aov);
ViewLayerAOV *BKE_view_layer_add_aov(ViewLayer *view_layer);
void BKE_view_layer_remove_aov(ViewLayer *view_layer, ViewLayerAOV *aov);
void BKE_view_layer_set_active_aov(ViewLayer *view_layer, ViewLayerAOV *aov);
/**
* Update the naming and conflicts of the AOVs.
*
@ -600,33 +559,23 @@ void BKE_view_layer_set_active_aov(struct ViewLayer *view_layer, struct ViewLaye
* engine or activating a render pass could lead to other conflicts that wouldn't be that clear
* for the user.
*/
void BKE_view_layer_verify_aov(struct RenderEngine *engine,
struct Scene *scene,
struct ViewLayer *view_layer);
void BKE_view_layer_verify_aov(RenderEngine *engine, Scene *scene, ViewLayer *view_layer);
/**
* Check if the given view layer has at least one valid AOV.
*/
bool BKE_view_layer_has_valid_aov(struct ViewLayer *view_layer);
struct ViewLayer *BKE_view_layer_find_with_aov(struct Scene *scene,
struct ViewLayerAOV *view_layer_aov);
bool BKE_view_layer_has_valid_aov(ViewLayer *view_layer);
ViewLayer *BKE_view_layer_find_with_aov(Scene *scene, ViewLayerAOV *view_layer_aov);
struct ViewLayerLightgroup *BKE_view_layer_add_lightgroup(struct ViewLayer *view_layer,
const char *name);
void BKE_view_layer_remove_lightgroup(struct ViewLayer *view_layer,
struct ViewLayerLightgroup *lightgroup);
void BKE_view_layer_set_active_lightgroup(struct ViewLayer *view_layer,
struct ViewLayerLightgroup *lightgroup);
struct ViewLayer *BKE_view_layer_find_with_lightgroup(
struct Scene *scene, struct ViewLayerLightgroup *view_layer_lightgroup);
void BKE_view_layer_rename_lightgroup(struct Scene *scene,
ViewLayerLightgroup *BKE_view_layer_add_lightgroup(ViewLayer *view_layer, const char *name);
void BKE_view_layer_remove_lightgroup(ViewLayer *view_layer, ViewLayerLightgroup *lightgroup);
void BKE_view_layer_set_active_lightgroup(ViewLayer *view_layer, ViewLayerLightgroup *lightgroup);
ViewLayer *BKE_view_layer_find_with_lightgroup(Scene *scene,
ViewLayerLightgroup *view_layer_lightgroup);
void BKE_view_layer_rename_lightgroup(Scene *scene,
ViewLayer *view_layer,
ViewLayerLightgroup *lightgroup,
const char *name);
int BKE_lightgroup_membership_get(const struct LightgroupMembership *lgm, char *name);
int BKE_lightgroup_membership_length(const struct LightgroupMembership *lgm);
void BKE_lightgroup_membership_set(struct LightgroupMembership **lgm, const char *name);
#ifdef __cplusplus
}
#endif
int BKE_lightgroup_membership_get(const LightgroupMembership *lgm, char *name);
int BKE_lightgroup_membership_length(const LightgroupMembership *lgm);
void BKE_lightgroup_membership_set(LightgroupMembership **lgm, const char *name);

View File

@ -335,7 +335,7 @@ void BKE_mask_clipboard_paste_to_layer(struct Main *bmain, struct MaskLayer *mas
/* `mask_evaluate.cc` */
unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height);
int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height);
unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height);
int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, unsigned int resol);

View File

@ -1,16 +1,15 @@
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "BLI_span.hh"
/** \file
* \ingroup bke
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Base;
struct Depsgraph;
struct Main;
@ -19,30 +18,30 @@ struct MetaElem;
struct Object;
struct Scene;
struct MetaBall *BKE_mball_add(struct Main *bmain, const char *name);
MetaBall *BKE_mball_add(Main *bmain, const char *name);
bool BKE_mball_is_any_selected(const struct MetaBall *mb);
bool BKE_mball_is_any_selected_multi(struct Base **bases, int bases_len);
bool BKE_mball_is_any_unselected(const struct MetaBall *mb);
bool BKE_mball_is_any_selected(const MetaBall *mb);
bool BKE_mball_is_any_selected_multi(blender::Span<Base *> bases);
bool BKE_mball_is_any_unselected(const MetaBall *mb);
/**
* Return `true` if `ob1` and `ob2` are part of the same metaBall group.
*
* \note Currently checks whether their two base names (without numerical suffix) is the same.
*/
bool BKE_mball_is_same_group(const struct Object *ob1, const struct Object *ob2);
bool BKE_mball_is_same_group(const Object *ob1, const Object *ob2);
/**
* Return `true` if `ob1` and `ob2` are part of the same metaBall group, and `ob1` is its
* basis.
*/
bool BKE_mball_is_basis_for(const struct Object *ob1, const struct Object *ob2);
bool BKE_mball_is_basis_for(const Object *ob1, const Object *ob2);
/**
* Test, if \a ob is a basis meta-ball.
*
* It test last character of Object ID name.
* If last character is digit it return 0, else it return 1.
*/
bool BKE_mball_is_basis(const struct Object *ob);
bool BKE_mball_is_basis(const Object *ob);
/**
* This function finds the basis meta-ball.
*
@ -52,7 +51,7 @@ bool BKE_mball_is_basis(const struct Object *ob);
*
* \warning #BKE_mball_is_basis() can fail on returned object, see function docs for details.
*/
struct Object *BKE_mball_basis_find(struct Scene *scene, struct Object *ob);
Object *BKE_mball_basis_find(Scene *scene, Object *ob);
/**
* Copy some properties from a meta-ball obdata to all other meta-ball obdata belonging to the same
@ -63,41 +62,37 @@ struct Object *BKE_mball_basis_find(struct Scene *scene, struct Object *ob);
* `MBall`, `MBall.001`, `MBall.002`, etc). The most important is to copy properties to the base
* meta-ball, because this meta-ball influences polygonization of meta-balls.
*/
void BKE_mball_properties_copy(struct Main *bmain, struct MetaBall *metaball_src);
void BKE_mball_properties_copy(Main *bmain, MetaBall *metaball_src);
bool BKE_mball_minmax_ex(
const struct MetaBall *mb, float min[3], float max[3], const float obmat[4][4], short flag);
const MetaBall *mb, float min[3], float max[3], const float obmat[4][4], short flag);
/* Basic vertex data functions. */
bool BKE_mball_minmax(const struct MetaBall *mb, float min[3], float max[3]);
bool BKE_mball_center_median(const struct MetaBall *mb, float r_cent[3]);
bool BKE_mball_center_bounds(const struct MetaBall *mb, float r_cent[3]);
void BKE_mball_transform(struct MetaBall *mb, const float mat[4][4], bool do_props);
void BKE_mball_translate(struct MetaBall *mb, const float offset[3]);
bool BKE_mball_minmax(const MetaBall *mb, float min[3], float max[3]);
bool BKE_mball_center_median(const MetaBall *mb, float r_cent[3]);
bool BKE_mball_center_bounds(const MetaBall *mb, float r_cent[3]);
void BKE_mball_transform(MetaBall *mb, const float mat[4][4], bool do_props);
void BKE_mball_translate(MetaBall *mb, const float offset[3]);
/**
* Most simple meta-element adding function.
*
* \note don't do context manipulation here (rna uses).
*/
struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, int type);
MetaElem *BKE_mball_element_add(MetaBall *mb, int type);
/* *** Select functions *** */
int BKE_mball_select_count(const struct MetaBall *mb);
int BKE_mball_select_count_multi(struct Base **bases, int bases_len);
bool BKE_mball_select_all(struct MetaBall *mb);
bool BKE_mball_select_all_multi_ex(struct Base **bases, int bases_len);
bool BKE_mball_deselect_all(struct MetaBall *mb);
bool BKE_mball_deselect_all_multi_ex(struct Base **bases, int bases_len);
bool BKE_mball_select_swap(struct MetaBall *mb);
bool BKE_mball_select_swap_multi_ex(struct Base **bases, int bases_len);
int BKE_mball_select_count(const MetaBall *mb);
int BKE_mball_select_count_multi(blender::Span<Base *> bases);
bool BKE_mball_select_all(MetaBall *mb);
bool BKE_mball_select_all_multi_ex(blender::Span<Base *> bases);
bool BKE_mball_deselect_all(MetaBall *mb);
bool BKE_mball_deselect_all_multi_ex(blender::Span<Base *> bases);
bool BKE_mball_select_swap(MetaBall *mb);
bool BKE_mball_select_swap_multi_ex(blender::Span<Base *> bases);
/* **** Depsgraph evaluation **** */
void BKE_mball_data_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
#ifdef __cplusplus
}
#endif
void BKE_mball_data_update(Depsgraph *depsgraph, Scene *scene, Object *ob);

View File

@ -1,27 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup bke
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Depsgraph;
struct Object;
struct Scene;
struct Mesh;
struct Mesh *BKE_mball_polygonize(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
void BKE_mball_cubeTable_free(void);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,17 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup bke
*/
struct Depsgraph;
struct Object;
struct Scene;
struct Mesh;
Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob);
void BKE_mball_cubeTable_free();

View File

@ -15,6 +15,7 @@
#include "BLI_compiler_attrs.h"
#include "BLI_math_vector_types.hh"
#include "BLI_sys_types.h"
#include "BLI_vector.hh"
#include "DNA_object_enums.h"
#include "DNA_userdef_enums.h"
@ -292,33 +293,27 @@ Object *BKE_object_pose_armature_get_visible(Object *ob,
/**
* Access pose array with special check to get pose object when in weight paint mode.
*/
Object **BKE_object_pose_array_get_ex(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
unsigned int *r_objects_len,
bool unique);
Object **BKE_object_pose_array_get_unique(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
unsigned int *r_objects_len);
Object **BKE_object_pose_array_get(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
unsigned int *r_objects_len);
blender::Vector<Object *> BKE_object_pose_array_get_ex(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
bool unique);
blender::Vector<Object *> BKE_object_pose_array_get_unique(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d);
blender::Vector<Object *> BKE_object_pose_array_get(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d);
Base **BKE_object_pose_base_array_get_ex(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
unsigned int *r_bases_len,
bool unique);
Base **BKE_object_pose_base_array_get_unique(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
unsigned int *r_bases_len);
Base **BKE_object_pose_base_array_get(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
unsigned int *r_bases_len);
blender::Vector<Base *> BKE_object_pose_base_array_get_ex(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
bool unique);
blender::Vector<Base *> BKE_object_pose_base_array_get_unique(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d);
blender::Vector<Base *> BKE_object_pose_base_array_get(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d);
void BKE_object_get_parent_matrix(Object *ob, Object *par, float r_parentmat[4][4]);

View File

@ -95,7 +95,7 @@ enum eUndoPushReturn {
};
ENUM_OPERATORS(eUndoPushReturn, UNDO_PUSH_RET_OVERRIDE_CHANGED)
using UndoTypeForEachIDRefFn = void (*)(void *user_data, struct UndoRefID *id_ref);
using UndoTypeForEachIDRefFn = void (*)(void *user_data, UndoRefID *id_ref);
struct UndoType {
UndoType *next, *prev;
@ -116,11 +116,10 @@ struct UndoType {
* Note that 'step_encode_init' is optional,
* some undo types need to perform operations before undo push finishes.
*/
void (*step_encode_init)(struct bContext *C, UndoStep *us);
void (*step_encode_init)(bContext *C, UndoStep *us);
bool (*step_encode)(struct bContext *C, struct Main *bmain, UndoStep *us);
void (*step_decode)(
struct bContext *C, struct Main *bmain, UndoStep *us, eUndoStepDir dir, bool is_final);
bool (*step_encode)(bContext *C, Main *bmain, UndoStep *us);
void (*step_decode)(bContext *C, Main *bmain, UndoStep *us, eUndoStepDir dir, bool is_final);
/**
* \note When freeing all steps,

View File

@ -417,7 +417,7 @@ set(SRC
BKE_key.h
BKE_keyconfig.h
BKE_lattice.hh
BKE_layer.h
BKE_layer.hh
BKE_lib_id.hh
BKE_lib_override.hh
BKE_lib_query.hh
@ -432,8 +432,8 @@ set(SRC
BKE_main_namemap.hh
BKE_mask.h
BKE_material.h
BKE_mball.h
BKE_mball_tessellate.h
BKE_mball.hh
BKE_mball_tessellate.hh
BKE_mesh.h
BKE_mesh.hh
BKE_mesh_boolean_convert.hh

View File

@ -40,7 +40,7 @@
#include "BKE_geometry_set.hh"
#include "BKE_geometry_set_instances.hh"
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_material.h"
#include "BKE_mesh.hh"

View File

@ -685,19 +685,20 @@ bool BKE_appdir_folder_id_ex(const int folder_id,
return true;
}
const char *BKE_appdir_folder_id(const int folder_id, const char *subfolder)
std::optional<std::string> BKE_appdir_folder_id(const int folder_id, const char *subfolder)
{
static char path[FILE_MAX] = "";
char path[FILE_MAX] = "";
if (BKE_appdir_folder_id_ex(folder_id, subfolder, path, sizeof(path))) {
return path;
}
return nullptr;
return std::nullopt;
}
const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char *subfolder)
std::optional<std::string> BKE_appdir_folder_id_user_notest(const int folder_id,
const char *subfolder)
{
const int version = BLENDER_VERSION;
static char path[FILE_MAX] = "";
char path[FILE_MAX] = "";
const bool check_is_dir = false;
switch (folder_id) {
@ -739,15 +740,13 @@ const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char *su
}
if ('\0' == path[0]) {
return nullptr;
return std::nullopt;
}
return path;
}
const char *BKE_appdir_folder_id_create(const int folder_id, const char *subfolder)
std::optional<std::string> BKE_appdir_folder_id_create(const int folder_id, const char *subfolder)
{
const char *path;
/* Only for user folders. */
if (!ELEM(folder_id,
BLENDER_USER_DATAFILES,
@ -756,26 +755,26 @@ const char *BKE_appdir_folder_id_create(const int folder_id, const char *subfold
BLENDER_USER_AUTOSAVE))
{
BLI_assert_unreachable();
return nullptr;
return std::nullopt;
}
path = BKE_appdir_folder_id(folder_id, subfolder);
std::optional<std::string> path = BKE_appdir_folder_id(folder_id, subfolder);
if (!path) {
if (!path.has_value()) {
path = BKE_appdir_folder_id_user_notest(folder_id, subfolder);
if (path) {
BLI_dir_create_recursive(path);
if (path.has_value()) {
BLI_dir_create_recursive(path->c_str());
}
}
return path;
}
const char *BKE_appdir_resource_path_id_with_version(const int folder_id,
const bool check_is_dir,
const int version)
std::optional<std::string> BKE_appdir_resource_path_id_with_version(const int folder_id,
const bool check_is_dir,
const int version)
{
static char path[FILE_MAX] = "";
char path[FILE_MAX] = "";
bool ok;
switch (folder_id) {
case BLENDER_RESOURCE_PATH_USER:
@ -793,10 +792,14 @@ const char *BKE_appdir_resource_path_id_with_version(const int folder_id,
BLI_assert_msg(0, "incorrect ID");
break;
}
return ok ? path : nullptr;
if (!ok) {
return std::nullopt;
}
return path;
}
const char *BKE_appdir_resource_path_id(const int folder_id, const bool check_is_dir)
std::optional<std::string> BKE_appdir_resource_path_id(const int folder_id,
const bool check_is_dir)
{
return BKE_appdir_resource_path_id_with_version(folder_id, check_is_dir, BLENDER_VERSION);
}
@ -964,11 +967,13 @@ bool BKE_appdir_program_python_search(char *program_filepath,
SNPRINTF(python_version, "%s%d.%d", basename, version_major, version_minor);
{
const char *python_bin_dir = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, "bin");
if (python_bin_dir) {
const std::optional<std::string> python_bin_dir = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON,
"bin");
if (python_bin_dir.has_value()) {
for (int i = 0; i < ARRAY_SIZE(python_names); i++) {
BLI_path_join(program_filepath, program_filepath_maxncpy, python_bin_dir, python_names[i]);
BLI_path_join(
program_filepath, program_filepath_maxncpy, python_bin_dir->c_str(), python_names[i]);
if (
#ifdef _WIN32

View File

@ -6,6 +6,8 @@
* \ingroup bke
*/
#include <algorithm>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
@ -665,7 +667,7 @@ static void splineik_evaluate_bone(
}
if (bulge < 1.0f) {
if (ik_data->flag & CONSTRAINT_SPLINEIK_USE_BULGE_MIN) {
float bulge_min = CLAMPIS(ik_data->bulge_min, 0.0f, 1.0f);
float bulge_min = std::clamp(ik_data->bulge_min, 0.0f, 1.0f);
float hard = max_ff(bulge, bulge_min);
float range = 1.0f - bulge_min;

View File

@ -32,7 +32,7 @@
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_image.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_main.hh"
#include "BKE_node.h"
#include "BKE_report.h"

View File

@ -29,7 +29,7 @@
#include "BKE_blendfile_link_append.hh"
#include "BKE_context.hh"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_scene.h"

View File

@ -41,7 +41,7 @@
#include "BKE_idtype.hh"
#include "BKE_ipo.h"
#include "BKE_keyconfig.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_override.hh"
#include "BKE_lib_query.hh"
@ -1092,7 +1092,8 @@ static void setup_app_data(bContext *C,
bmain->filepath[0] = '\0';
}
else if (recover) {
/* In case of auto-save or quit.blend, use original filepath instead. */
/* In case of auto-save or quit.blend, use original filepath instead (see also #read_global in
* `readfile.cc`). */
bmain->recovered = true;
STRNCPY(bmain->filepath, bfd->filepath);
}
@ -1463,13 +1464,13 @@ bool BKE_blendfile_userdef_write_app_template(const char *filepath, ReportList *
bool BKE_blendfile_userdef_write_all(ReportList *reports)
{
char filepath[FILE_MAX];
const char *cfgdir;
std::optional<std::string> cfgdir;
bool ok = true;
const bool use_template_userpref = BKE_appdir_app_template_has_userpref(U.app_template);
if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, nullptr))) {
bool ok_write;
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE);
BLI_path_join(filepath, sizeof(filepath), cfgdir->c_str(), BLENDER_USERPREF_FILE);
printf("Writing userprefs: \"%s\" ", filepath);
if (use_template_userpref) {
@ -1496,7 +1497,7 @@ bool BKE_blendfile_userdef_write_all(ReportList *reports)
if (use_template_userpref) {
if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) {
/* Also save app-template preferences. */
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE);
BLI_path_join(filepath, sizeof(filepath), cfgdir->c_str(), BLENDER_USERPREF_FILE);
printf("Writing userprefs app-template: \"%s\" ", filepath);
if (BKE_blendfile_userdef_write(filepath, reports) != 0) {

View File

@ -38,7 +38,7 @@
#include "BKE_idtype.hh"
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_override.hh"
#include "BKE_lib_query.hh"

View File

@ -394,14 +394,20 @@ static void brush_asset_metadata_ensure(void *asset_ptr, AssetMetaData *asset_da
Brush *brush = reinterpret_cast<Brush *>(asset_ptr);
BLI_assert(GS(brush->id.name) == ID_BR);
/* Most names copied from brush RNA (not all are available there though). */
constexpr std::array mode_map{
std::pair{"use_paint_sculpt", OB_MODE_SCULPT},
std::pair{"use_paint_uv_sculpt", OB_MODE_EDIT},
std::pair{"use_paint_vertex", OB_MODE_VERTEX_PAINT},
std::pair{"use_paint_weight", OB_MODE_WEIGHT_PAINT},
std::pair{"use_paint_image", OB_MODE_TEXTURE_PAINT},
/* Sculpt UVs in the image editor while in edit mode. */
std::pair{"use_paint_uv_sculpt", OB_MODE_EDIT},
std::pair{"use_paint_grease_pencil", OB_MODE_PAINT_GPENCIL_LEGACY},
std::pair{"use_paint_grease_pencil", OB_MODE_PAINT_GREASE_PENCIL},
/* Note: Not defined in brush RNA, own name. */
std::pair{"use_sculpt_grease_pencil", OB_MODE_SCULPT_GPENCIL_LEGACY},
std::pair{"use_vertex_grease_pencil", OB_MODE_VERTEX_GPENCIL_LEGACY},
std::pair{"use_weight_grease_pencil", OB_MODE_WEIGHT_GPENCIL_LEGACY},
std::pair{"use_paint_sculpt_curves", OB_MODE_SCULPT_CURVES},
};

View File

@ -33,7 +33,7 @@
#include "BKE_camera.h"
#include "BKE_idprop.h"
#include "BKE_idtype.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_main.hh"

View File

@ -24,7 +24,7 @@
#include "BKE_collection.h"
#include "BKE_idprop.h"
#include "BKE_idtype.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_lib_remap.hh"

View File

@ -28,7 +28,7 @@
#include "BKE_cloth.hh"
#include "BKE_collection.h"
#include "BKE_effect.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_modifier.hh"
#include "BKE_scene.h"

View File

@ -9,6 +9,7 @@
/* Allow using deprecated functionality for .blend file I/O. */
#define DNA_DEPRECATED_ALLOW
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstddef>
@ -3552,7 +3553,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
}
if (bulge < 1.0f) {
if (data->flag & STRETCHTOCON_USE_BULGE_MIN) {
float bulge_min = CLAMPIS(data->bulge_min, 0.0f, 1.0f);
float bulge_min = std::clamp(data->bulge_min, 0.0f, 1.0f);
float hard = max_ff(bulge, bulge_min);
float range = 1.0f - bulge_min;

View File

@ -33,7 +33,7 @@
#include "BLT_translation.h"
#include "BKE_context.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_main.hh"
#include "BKE_scene.h"
#include "BKE_screen.hh"

View File

@ -1060,7 +1060,9 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
dst_data = static_cast<float3 *>(CustomData_add_layer(
&me_dst->corner_data, CD_NORMAL, CD_SET_DEFAULT, me_dst->corners_num));
}
MutableSpan(dst_data, me_dst->corners_num).copy_from(me_dst->corner_normals());
if (mix_factor != 1.0f) {
MutableSpan(dst_data, me_dst->corners_num).copy_from(me_dst->corner_normals());
}
/* Post-process will convert it back to CD_CUSTOMLOOPNORMAL. */
data_transfer_layersmapping_add_item_cd(r_map,
CD_NORMAL,

View File

@ -36,7 +36,7 @@
#include "BKE_geometry_set.hh"
#include "BKE_key.h"
#include "BKE_lib_id.hh"
#include "BKE_mball.h"
#include "BKE_mball.hh"
#include "BKE_mesh.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"

View File

@ -45,7 +45,7 @@
#include "BKE_effect.h"
#include "BKE_fluid.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_mesh.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"
@ -524,7 +524,7 @@ static float eff_calc_visibility(ListBase *colliders,
absorption = col->ob->pd->absorption;
/* visibility is only between 0 and 1, calculated from 1-absorption */
visibility *= CLAMPIS(1.0f - absorption, 0.0f, 1.0f);
visibility *= std::clamp(1.0f - absorption, 0.0f, 1.0f);
if (visibility <= 0.0f) {
break;

View File

@ -30,7 +30,7 @@
#include "BKE_effect.h"
#include "BKE_fluid.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_modifier.hh"
#include "BKE_pointcache.h"

View File

@ -561,7 +561,7 @@ static bool BKE_gpencil_stroke_extra_points(bGPDstroke *gps,
MDeformVert *new_dv = (MDeformVert *)MEM_mallocN(sizeof(MDeformVert) * new_count, __func__);
for (int i = 0; i < new_count; i++) {
MDeformVert *dv = &gps->dvert[CLAMPIS(i - count_before, 0, gps->totpoints - 1)];
MDeformVert *dv = &gps->dvert[std::clamp(i - count_before, 0, gps->totpoints - 1)];
int inew = i;
new_dv[inew].flag = dv->flag;
new_dv[inew].totweight = dv->totweight;

View File

@ -1420,9 +1420,19 @@ bool BKE_image_memorypack(Image *ima)
ima->views_format = R_IMF_VIEWS_INDIVIDUAL;
}
if (ok && ima->source == IMA_SRC_GENERATED) {
ima->source = IMA_SRC_FILE;
ima->type = IMA_TYPE_IMAGE;
/* Images which were "generated" before packing should now be
* treated as if they were saved as real files. */
if (ok) {
if (ima->source == IMA_SRC_GENERATED) {
ima->source = IMA_SRC_FILE;
ima->type = IMA_TYPE_IMAGE;
}
/* Clear the per-tile generated flag if all tiles were ok.
* Mirrors similar processing inside #BKE_image_save. */
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
tile->gen_flag &= ~IMA_GEN_TILE;
}
}
return ok;

View File

@ -8,6 +8,7 @@
* Deform coordinates by a lattice object (used by modifier).
*/
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
@ -210,13 +211,13 @@ void BKE_lattice_deform_data_eval_co(LatticeDeformData *lattice_deform_data,
for (ww = wi - 1; ww <= wi + 2; ww++) {
w = weight * tw[ww - wi + 1];
idx_w = CLAMPIS(ww * w_stride, 0, idx_w_max);
idx_w = std::clamp(ww * w_stride, 0, idx_w_max);
for (vv = vi - 1; vv <= vi + 2; vv++) {
v = w * tv[vv - vi + 1];
idx_v = CLAMPIS(vv * v_stride, 0, idx_v_max);
idx_v = std::clamp(vv * v_stride, 0, idx_v_max);
for (uu = ui - 1; uu <= ui + 2; uu++) {
u = v * tu[uu - ui + 1];
idx_u = CLAMPIS(uu, 0, idx_u_max);
idx_u = std::clamp(uu, 0, idx_u_max);
const int idx = idx_w + idx_v + idx_u;
#if BLI_HAVE_SSE2
{

View File

@ -25,7 +25,7 @@
#include "BKE_collection.h"
#include "BKE_freestyle.h"
#include "BKE_idprop.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_node.hh"

View File

@ -7,7 +7,7 @@
#include "BKE_appdir.hh"
#include "BKE_idtype.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BLI_string.h"

View File

@ -13,7 +13,7 @@
#include "BKE_collection.h"
#include "BKE_customdata.hh"
#include "BKE_editmesh.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "DNA_ID.h"
#include "DNA_layer_types.h"
@ -27,10 +27,10 @@
/** \name Selected Object Array
* \{ */
Object **BKE_view_layer_array_selected_objects_params(ViewLayer *view_layer,
const View3D *v3d,
uint *r_len,
const ObjectsInViewLayerParams *params)
using blender::Vector;
Vector<Object *> BKE_view_layer_array_selected_objects_params(
ViewLayer *view_layer, const View3D *v3d, const ObjectsInViewLayerParams *params)
{
if (params->no_dup_data) {
FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob_iter) {
@ -42,8 +42,7 @@ Object **BKE_view_layer_array_selected_objects_params(ViewLayer *view_layer,
FOREACH_SELECTED_OBJECT_END;
}
Object **object_array = nullptr;
BLI_array_declare(object_array);
Vector<Object *> objects;
FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob_iter) {
if (params->filter_fn) {
@ -64,19 +63,11 @@ Object **BKE_view_layer_array_selected_objects_params(ViewLayer *view_layer,
}
}
BLI_array_append(object_array, ob_iter);
objects.append(ob_iter);
}
FOREACH_SELECTED_OBJECT_END;
if (object_array != nullptr) {
BLI_array_trim(object_array);
}
else {
/* We always need a valid allocation (prevent crash on free). */
object_array = static_cast<Object **>(MEM_mallocN(0, __func__));
}
*r_len = BLI_array_len(object_array);
return object_array;
return objects;
}
/** \} */
@ -85,11 +76,10 @@ Object **BKE_view_layer_array_selected_objects_params(ViewLayer *view_layer,
/** \name Objects in Mode Array
* \{ */
Base **BKE_view_layer_array_from_bases_in_mode_params(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
uint *r_len,
const ObjectsInModeParams *params)
Vector<Base *> BKE_view_layer_array_from_bases_in_mode_params(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
const ObjectsInModeParams *params)
{
if (params->no_dup_data) {
FOREACH_BASE_IN_MODE_BEGIN (scene, view_layer, v3d, -1, params->object_mode, base_iter) {
@ -101,8 +91,7 @@ Base **BKE_view_layer_array_from_bases_in_mode_params(const Scene *scene,
FOREACH_BASE_IN_MODE_END;
}
Base **base_array = nullptr;
BLI_array_declare(base_array);
Vector<Base *> bases;
FOREACH_BASE_IN_MODE_BEGIN (scene, view_layer, v3d, -1, params->object_mode, base_iter) {
if (params->filter_fn) {
@ -121,101 +110,84 @@ Base **BKE_view_layer_array_from_bases_in_mode_params(const Scene *scene,
}
}
}
BLI_array_append(base_array, base_iter);
bases.append(base_iter);
}
FOREACH_BASE_IN_MODE_END;
/* We always need a valid allocation (prevent crash on free). */
if (base_array != nullptr) {
BLI_array_trim(base_array);
}
else {
base_array = static_cast<Base **>(MEM_mallocN(0, __func__));
}
*r_len = BLI_array_len(base_array);
return base_array;
return bases;
}
Object **BKE_view_layer_array_from_objects_in_mode_params(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
uint *r_len,
const ObjectsInModeParams *params)
Vector<Object *> BKE_view_layer_array_from_objects_in_mode_params(
const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
const ObjectsInModeParams *params)
{
Base **base_array = BKE_view_layer_array_from_bases_in_mode_params(
scene, view_layer, v3d, r_len, params);
if (base_array != nullptr) {
for (uint i = 0; i < *r_len; i++) {
((Object **)base_array)[i] = base_array[i]->object;
}
}
return (Object **)base_array;
const Vector<Base *> bases = BKE_view_layer_array_from_bases_in_mode_params(
scene, view_layer, v3d, params);
Vector<Object *> objects(bases.size());
std::transform(
bases.begin(), bases.end(), objects.begin(), [](Base *base) { return base->object; });
return objects;
}
Object **BKE_view_layer_array_from_objects_in_edit_mode(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
uint *r_len)
{
ObjectsInModeParams params = {0};
params.object_mode = OB_MODE_EDIT;
return BKE_view_layer_array_from_objects_in_mode_params(scene, view_layer, v3d, r_len, &params);
}
Base **BKE_view_layer_array_from_bases_in_edit_mode(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
uint *r_len)
{
ObjectsInModeParams params = {0};
params.object_mode = OB_MODE_EDIT;
return BKE_view_layer_array_from_bases_in_mode_params(scene, view_layer, v3d, r_len, &params);
}
Object **BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
uint *r_len)
{
ObjectsInModeParams params = {0};
params.object_mode = OB_MODE_EDIT;
params.no_dup_data = true;
return BKE_view_layer_array_from_objects_in_mode_params(scene, view_layer, v3d, r_len, &params);
}
Base **BKE_view_layer_array_from_bases_in_edit_mode_unique_data(const Scene *scene,
Vector<Object *> BKE_view_layer_array_from_objects_in_edit_mode(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
uint *r_len)
const View3D *v3d)
{
ObjectsInModeParams params = {0};
params.object_mode = OB_MODE_EDIT;
return BKE_view_layer_array_from_objects_in_mode_params(scene, view_layer, v3d, &params);
}
Vector<Base *> BKE_view_layer_array_from_bases_in_edit_mode(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d)
{
ObjectsInModeParams params = {0};
params.object_mode = OB_MODE_EDIT;
return BKE_view_layer_array_from_bases_in_mode_params(scene, view_layer, v3d, &params);
}
Vector<Object *> BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d)
{
ObjectsInModeParams params = {0};
params.object_mode = OB_MODE_EDIT;
params.no_dup_data = true;
return BKE_view_layer_array_from_bases_in_mode_params(scene, view_layer, v3d, r_len, &params);
return BKE_view_layer_array_from_objects_in_mode_params(scene, view_layer, v3d, &params);
}
Object **BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
uint *r_len)
Vector<Base *> BKE_view_layer_array_from_bases_in_edit_mode_unique_data(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d)
{
ObjectsInModeParams params = {0};
params.object_mode = OB_MODE_EDIT;
params.no_dup_data = true;
return BKE_view_layer_array_from_bases_in_mode_params(scene, view_layer, v3d, &params);
}
Vector<Object *> BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
{
ObjectsInModeParams params = {0};
params.object_mode = OB_MODE_EDIT;
params.no_dup_data = true;
params.filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs;
return BKE_view_layer_array_from_objects_in_mode_params(scene, view_layer, v3d, r_len, &params);
return BKE_view_layer_array_from_objects_in_mode_params(scene, view_layer, v3d, &params);
}
Object **BKE_view_layer_array_from_objects_in_mode_unique_data(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
uint *r_len,
const eObjectMode mode)
Vector<Object *> BKE_view_layer_array_from_objects_in_mode_unique_data(const Scene *scene,
ViewLayer *view_layer,
const View3D *v3d,
const eObjectMode mode)
{
ObjectsInModeParams params = {0};
params.object_mode = mode;
params.no_dup_data = true;
return BKE_view_layer_array_from_objects_in_mode_params(scene, view_layer, v3d, r_len, &params);
return BKE_view_layer_array_from_objects_in_mode_params(scene, view_layer, v3d, &params);
}
ListBase *BKE_view_layer_object_bases_get(ViewLayer *view_layer)

View File

@ -27,7 +27,7 @@
#include "BKE_idprop.h"
#include "BKE_idtype.hh"
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_override.hh"
#include "BKE_lib_remap.hh"

View File

@ -33,7 +33,7 @@
#include "BKE_global.h"
#include "BKE_idtype.hh"
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_override.hh"
#include "BKE_lib_query.hh"

View File

@ -20,13 +20,13 @@
#include "BKE_armature.hh"
#include "BKE_collection.h"
#include "BKE_curve.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_lib_remap.hh"
#include "BKE_main.hh"
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mball.hh"
#include "BKE_modifier.hh"
#include "BKE_multires.hh"
#include "BKE_node.h"

View File

@ -17,7 +17,7 @@
#include "BLI_string.h"
#include "BKE_collection.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_report.h"

View File

@ -29,10 +29,10 @@
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
uint BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
{
float max_segment = 0.01f;
uint i, resol = 1;
int i, resol = 1;
if (width != 0 && height != 0) {
max_segment = 1.0f / float(max_ii(width, height));
@ -42,7 +42,7 @@ uint BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
MaskSplinePoint *point = &spline->points[i];
BezTriple *bezt_curr, *bezt_next;
float a, b, c, len;
uint cur_resol;
int cur_resol;
bezt_curr = &point->bezt;
bezt_next = BKE_mask_spline_point_next_bezt(spline, spline->points, point);
@ -65,13 +65,13 @@ uint BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
}
}
return CLAMPIS(resol, 1, MASK_RESOL_MAX);
return std::clamp(resol, 1, MASK_RESOL_MAX);
}
uint BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int height)
{
const float max_segment = 0.005;
uint resol = BKE_mask_spline_resolution(spline, width, height);
int resol = BKE_mask_spline_resolution(spline, width, height);
float max_jump = 0.0f;
/* Avoid checking the feather if we already hit the maximum value. */
@ -104,7 +104,7 @@ uint BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int heigh
resol += max_jump / max_segment;
return CLAMPIS(resol, 1, MASK_RESOL_MAX);
return std::clamp(resol, 1, MASK_RESOL_MAX);
}
int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const uint resol)
@ -183,7 +183,7 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline,
float (*BKE_mask_spline_differentiate(
MaskSpline *spline, int width, int height, uint *r_tot_diff_point))[2]
{
uint resol = BKE_mask_spline_resolution(spline, width, height);
int resol = BKE_mask_spline_resolution(spline, width, height);
return BKE_mask_spline_differentiate_with_resolution(spline, resol, r_tot_diff_point);
}

View File

@ -630,9 +630,9 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
float(*diff_feather_points_flip)[2];
uint tot_diff_feather_points;
const uint resol_a = BKE_mask_spline_resolution(spline, width, height) / 4;
const uint resol_a = uint(BKE_mask_spline_resolution(spline, width, height) / 4);
const uint resol_b = BKE_mask_spline_feather_resolution(spline, width, height) / 4;
const uint resol = CLAMPIS(std::max(resol_a, resol_b), 4, 512);
const uint resol = std::clamp(std::max(resol_a, resol_b), 4u, 512u);
diff_points = BKE_mask_spline_differentiate_with_resolution(spline, resol, &tot_diff_point);

View File

@ -45,12 +45,12 @@
#include "BKE_geometry_set.hh"
#include "BKE_idtype.hh"
#include "BKE_lattice.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mball_tessellate.h"
#include "BKE_mball.hh"
#include "BKE_mball_tessellate.hh"
#include "BKE_mesh.hh"
#include "BKE_object.hh"
#include "BKE_object_types.hh"
@ -60,6 +60,8 @@
#include "BLO_read_write.hh"
using blender::Span;
static void metaball_init_data(ID *id)
{
MetaBall *metaball = (MetaBall *)id;
@ -280,10 +282,10 @@ bool BKE_mball_is_any_selected(const MetaBall *mb)
return false;
}
bool BKE_mball_is_any_selected_multi(Base **bases, int bases_len)
bool BKE_mball_is_any_selected_multi(const Span<Base *> bases)
{
for (uint base_index = 0; base_index < bases_len; base_index++) {
Object *obedit = bases[base_index]->object;
for (Base *base : bases) {
Object *obedit = base->object;
MetaBall *mb = (MetaBall *)obedit->data;
if (BKE_mball_is_any_selected(mb)) {
return true;
@ -540,11 +542,11 @@ int BKE_mball_select_count(const MetaBall *mb)
return sel;
}
int BKE_mball_select_count_multi(Base **bases, int bases_len)
int BKE_mball_select_count_multi(const Span<Base *> bases)
{
int sel = 0;
for (uint ob_index = 0; ob_index < bases_len; ob_index++) {
const Object *obedit = bases[ob_index]->object;
for (Base *base : bases) {
Object *obedit = base->object;
const MetaBall *mb = (MetaBall *)obedit->data;
sel += BKE_mball_select_count(mb);
}
@ -563,11 +565,11 @@ bool BKE_mball_select_all(MetaBall *mb)
return changed;
}
bool BKE_mball_select_all_multi_ex(Base **bases, int bases_len)
bool BKE_mball_select_all_multi_ex(const Span<Base *> bases)
{
bool changed_multi = false;
for (uint ob_index = 0; ob_index < bases_len; ob_index++) {
Object *obedit = bases[ob_index]->object;
for (Base *base : bases) {
Object *obedit = base->object;
MetaBall *mb = static_cast<MetaBall *>(obedit->data);
changed_multi |= BKE_mball_select_all(mb);
}
@ -586,11 +588,11 @@ bool BKE_mball_deselect_all(MetaBall *mb)
return changed;
}
bool BKE_mball_deselect_all_multi_ex(Base **bases, int bases_len)
bool BKE_mball_deselect_all_multi_ex(const Span<Base *> bases)
{
bool changed_multi = false;
for (uint ob_index = 0; ob_index < bases_len; ob_index++) {
Object *obedit = bases[ob_index]->object;
for (Base *base : bases) {
Object *obedit = base->object;
MetaBall *mb = static_cast<MetaBall *>(obedit->data);
changed_multi |= BKE_mball_deselect_all(mb);
DEG_id_tag_update(&mb->id, ID_RECALC_SELECT);
@ -608,11 +610,11 @@ bool BKE_mball_select_swap(MetaBall *mb)
return changed;
}
bool BKE_mball_select_swap_multi_ex(Base **bases, int bases_len)
bool BKE_mball_select_swap_multi_ex(const Span<Base *> bases)
{
bool changed_multi = false;
for (uint ob_index = 0; ob_index < bases_len; ob_index++) {
Object *obedit = bases[ob_index]->object;
for (Base *base : bases) {
Object *obedit = base->object;
MetaBall *mb = (MetaBall *)obedit->data;
changed_multi |= BKE_mball_select_swap(mb);
}

View File

@ -32,7 +32,7 @@
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BKE_lib_id.hh"
#include "BKE_mball_tessellate.h" /* own include */
#include "BKE_mball_tessellate.hh" /* own include */
#include "BKE_mesh.hh"
#include "BKE_object.hh"
#include "BKE_scene.h"

View File

@ -869,7 +869,7 @@ Mesh *BKE_mesh_from_bmesh_for_eval_nomain(BMesh *bm,
const Mesh *me_settings)
{
Mesh *mesh = static_cast<Mesh *>(BKE_id_new_nomain(ID_ME, nullptr));
BM_mesh_bm_to_me_for_eval(bm, mesh, cd_mask_extra);
BM_mesh_bm_to_me_for_eval(*bm, *mesh, cd_mask_extra);
BKE_mesh_copy_parameters_for_eval(mesh, me_settings);
return mesh;
}

View File

@ -38,7 +38,7 @@
#include "BKE_lib_query.hh"
#include "BKE_main.hh"
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mball.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_mesh_wrapper.hh"

View File

@ -198,7 +198,7 @@ void normals_calc_verts(const Span<float3> vert_positions,
/** \name Mesh Normal Calculation
* \{ */
blender::bke::MeshNormalDomain Mesh::normals_domain() const
blender::bke::MeshNormalDomain Mesh::normals_domain(const bool support_sharp_face) const
{
using namespace blender;
using namespace blender::bke;
@ -227,7 +227,7 @@ blender::bke::MeshNormalDomain Mesh::normals_domain() const
}
if (edge_mix == array_utils::BooleanMix::AllFalse &&
face_mix == array_utils::BooleanMix::AllFalse)
(face_mix == array_utils::BooleanMix::AllFalse || support_sharp_face))
{
return MeshNormalDomain::Point;
}

View File

@ -297,6 +297,7 @@ void BKE_mesh_runtime_clear_geometry(Mesh *mesh)
mesh->runtime->corner_to_face_map_cache.tag_dirty();
mesh->runtime->vert_normals_cache.tag_dirty();
mesh->runtime->face_normals_cache.tag_dirty();
mesh->runtime->corner_normals_cache.tag_dirty();
mesh->runtime->loose_edges_cache.tag_dirty();
mesh->runtime->loose_verts_cache.tag_dirty();
mesh->runtime->verts_no_face_cache.tag_dirty();

View File

@ -111,7 +111,7 @@ void BKE_mesh_wrapper_ensure_mdata(Mesh *mesh)
BLI_assert(mesh->runtime->edit_data != nullptr);
BMEditMesh *em = mesh->edit_mesh;
BM_mesh_bm_to_me_for_eval(em->bm, mesh, &mesh->runtime->cd_mask_extra);
BM_mesh_bm_to_me_for_eval(*em->bm, *mesh, &mesh->runtime->cd_mask_extra);
/* Adding original index layers here assumes that all BMesh Mesh wrappers are created from
* original edit mode meshes (the only case where adding original indices makes sense).

View File

@ -358,11 +358,11 @@ void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl)
mmd->totlvl = lvl;
if (ob->mode != OB_MODE_SCULPT) {
mmd->lvl = CLAMPIS(std::max<char>(mmd->lvl, lvl), 0, mmd->totlvl);
mmd->lvl = std::clamp<char>(std::max<char>(mmd->lvl, lvl), 0, mmd->totlvl);
}
mmd->sculptlvl = CLAMPIS(std::max<char>(mmd->sculptlvl, lvl), 0, mmd->totlvl);
mmd->renderlvl = CLAMPIS(std::max<char>(mmd->renderlvl, lvl), 0, mmd->totlvl);
mmd->sculptlvl = std::clamp<char>(std::max<char>(mmd->sculptlvl, lvl), 0, mmd->totlvl);
mmd->renderlvl = std::clamp<char>(std::max<char>(mmd->renderlvl, lvl), 0, mmd->totlvl);
}
static void multires_ccg_mark_as_modified(SubdivCCG *subdiv_ccg, MultiresModifiedFlags flags)
@ -934,7 +934,7 @@ static void multires_disp_run_cb(void *__restrict userdata,
case CALC_DISPLACEMENTS:
/* Copy mask from DM to gpm */
mask = *CCG_grid_elem_mask(key, grid, x, y);
gpm->data[y * gridSize + x] = CLAMPIS(mask, 0, 1);
gpm->data[y * gridSize + x] = std::clamp(mask, 0.0f, 1.0f);
break;
case ADD_DISPLACEMENTS:
/* Add mask displacement to gpm */

View File

@ -99,7 +99,7 @@
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_lattice.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_lib_remap.hh"
@ -108,7 +108,7 @@
#include "BKE_linestyle.h"
#include "BKE_main.hh"
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mball.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_wrapper.hh"
#include "BKE_modifier.hh"
@ -153,6 +153,7 @@ using blender::Bounds;
using blender::float3;
using blender::MutableSpan;
using blender::Span;
using blender::Vector;
static CLG_LogRef LOG = {"bke.object"};
@ -2443,55 +2444,47 @@ Object *BKE_object_pose_armature_get_visible(Object *ob,
return nullptr;
}
Object **BKE_object_pose_array_get_ex(
const Scene *scene, ViewLayer *view_layer, View3D *v3d, uint *r_objects_len, bool unique)
Vector<Object *> BKE_object_pose_array_get_ex(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
bool unique)
{
BKE_view_layer_synced_ensure(scene, view_layer);
Object *ob_active = BKE_view_layer_active_object_get(view_layer);
Object *ob_pose = BKE_object_pose_armature_get(ob_active);
Object **objects = nullptr;
if (ob_pose == ob_active) {
ObjectsInModeParams ob_params{};
ob_params.object_mode = OB_MODE_POSE;
ob_params.no_dup_data = unique;
objects = BKE_view_layer_array_from_objects_in_mode_params(
scene, view_layer, v3d, r_objects_len, &ob_params);
return BKE_view_layer_array_from_objects_in_mode_params(scene, view_layer, v3d, &ob_params);
}
else if (ob_pose != nullptr) {
*r_objects_len = 1;
objects = (Object **)MEM_mallocN(sizeof(*objects), __func__);
objects[0] = ob_pose;
if (ob_pose != nullptr) {
return {ob_pose};
}
else {
*r_objects_len = 0;
objects = (Object **)MEM_mallocN(0, __func__);
}
return objects;
return {};
}
Object **BKE_object_pose_array_get_unique(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
uint *r_objects_len)
Vector<Object *> BKE_object_pose_array_get_unique(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d)
{
return BKE_object_pose_array_get_ex(scene, view_layer, v3d, r_objects_len, true);
return BKE_object_pose_array_get_ex(scene, view_layer, v3d, true);
}
Object **BKE_object_pose_array_get(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
uint *r_objects_len)
Vector<Object *> BKE_object_pose_array_get(const Scene *scene, ViewLayer *view_layer, View3D *v3d)
{
return BKE_object_pose_array_get_ex(scene, view_layer, v3d, r_objects_len, false);
return BKE_object_pose_array_get_ex(scene, view_layer, v3d, false);
}
Base **BKE_object_pose_base_array_get_ex(
const Scene *scene, ViewLayer *view_layer, View3D *v3d, uint *r_bases_len, bool unique)
blender::Vector<Base *> BKE_object_pose_base_array_get_ex(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
bool unique)
{
BKE_view_layer_synced_ensure(scene, view_layer);
Base *base_active = BKE_view_layer_active_base_get(view_layer);
Object *ob_pose = base_active ? BKE_object_pose_armature_get(base_active->object) : nullptr;
Base *base_pose = nullptr;
Base **bases = nullptr;
if (base_active) {
if (ob_pose == base_active->object) {
@ -2507,33 +2500,25 @@ Base **BKE_object_pose_base_array_get_ex(
ob_params.object_mode = OB_MODE_POSE;
ob_params.no_dup_data = unique;
bases = BKE_view_layer_array_from_bases_in_mode_params(
scene, view_layer, v3d, r_bases_len, &ob_params);
return BKE_view_layer_array_from_bases_in_mode_params(scene, view_layer, v3d, &ob_params);
}
else if (base_pose != nullptr) {
*r_bases_len = 1;
bases = (Base **)MEM_mallocN(sizeof(*bases), __func__);
bases[0] = base_pose;
if (base_pose != nullptr) {
return {base_pose};
}
else {
*r_bases_len = 0;
bases = (Base **)MEM_mallocN(0, __func__);
}
return bases;
return {};
}
Base **BKE_object_pose_base_array_get_unique(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
uint *r_bases_len)
Vector<Base *> BKE_object_pose_base_array_get_unique(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d)
{
return BKE_object_pose_base_array_get_ex(scene, view_layer, v3d, r_bases_len, true);
return BKE_object_pose_base_array_get_ex(scene, view_layer, v3d, true);
}
Base **BKE_object_pose_base_array_get(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d,
uint *r_bases_len)
Vector<Base *> BKE_object_pose_base_array_get(const Scene *scene,
ViewLayer *view_layer,
View3D *v3d)
{
return BKE_object_pose_base_array_get_ex(scene, view_layer, v3d, r_bases_len, false);
return BKE_object_pose_base_array_get_ex(scene, view_layer, v3d, false);
}
void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)

View File

@ -38,10 +38,10 @@
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_lattice.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_light.h"
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mball.hh"
#include "BKE_mesh.hh"
#include "BKE_object.hh"
#include "BKE_object_types.hh"

View File

@ -50,7 +50,7 @@
#include "BKE_idtype.hh"
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_material.h"

View File

@ -60,7 +60,7 @@
#include "BKE_idtype.hh"
#include "BKE_key.h"
#include "BKE_lattice.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_main.hh"

View File

@ -7,10 +7,9 @@
* \ingroup bke
*/
#include <cstddef>
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <cstring>
@ -3398,7 +3397,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim,
mul_m4_m4m4(root_mat, sim->ob->object_to_world, hairmat);
normalize_m4(root_mat);
bending_stiffness = CLAMPIS(
bending_stiffness = std::clamp(
1.0f - part->bending_random * psys_frand(psys, p + 666), 0.0f, 1.0f);
for (k = 0, key = pa->hair; k < pa->totkey; k++, key++) {

View File

@ -39,7 +39,7 @@
#include "BKE_collection.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_main.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_runtime.hh"

View File

@ -72,7 +72,7 @@
#include "BKE_idtype.hh"
#include "BKE_image.h"
#include "BKE_image_format.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_lib_remap.hh"

View File

@ -57,7 +57,7 @@
#include "BKE_deform.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_mesh.hh"
#include "BKE_modifier.hh"
#include "BKE_pointcache.h"

View File

@ -609,13 +609,13 @@ static void studiolight_add_files_from_datafolder(const int folder_id,
const char *subfolder,
int flag)
{
const char *folder = BKE_appdir_folder_id(folder_id, subfolder);
const std::optional<std::string> folder = BKE_appdir_folder_id(folder_id, subfolder);
if (!folder) {
return;
}
direntry *dirs;
const uint dirs_num = BLI_filelist_dir_contents(folder, &dirs);
const uint dirs_num = BLI_filelist_dir_contents(folder->c_str(), &dirs);
int i;
for (i = 0; i < dirs_num; i++) {
if (dirs[i].type & S_IFREG) {

View File

@ -39,7 +39,7 @@
#include "BLT_translation.h"
#include "BKE_fcurve.h"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_movieclip.h"
#include "BKE_object.hh"

View File

@ -219,8 +219,6 @@ inline constexpr int64_t power_of_2_max(const int64_t x)
/** \name Clamp Macros
* \{ */
#define CLAMPIS(a, b, c) ((a) < (b) ? (b) : (a) > (c) ? (c) : (a))
#define CLAMP(a, b, c) \
{ \
if ((a) < (b)) { \
@ -248,27 +246,6 @@ inline constexpr int64_t power_of_2_max(const int64_t x)
} \
(void)0
#define CLAMP2(vec, b, c) \
{ \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
} \
(void)0
#define CLAMP2_MIN(vec, b) \
{ \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
} \
(void)0
#define CLAMP2_MAX(vec, b) \
{ \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
} \
(void)0
#define CLAMP3(vec, b, c) \
{ \
CLAMP((vec)[0], b, c); \
@ -285,23 +262,6 @@ inline constexpr int64_t power_of_2_max(const int64_t x)
} \
(void)0
#define CLAMP3_MAX(vec, b) \
{ \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
CLAMP_MAX((vec)[2], b); \
} \
(void)0
#define CLAMP4(vec, b, c) \
{ \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
CLAMP((vec)[2], b, c); \
CLAMP((vec)[3], b, c); \
} \
(void)0
#define CLAMP4_MIN(vec, b) \
{ \
CLAMP_MIN((vec)[0], b); \
@ -311,15 +271,6 @@ inline constexpr int64_t power_of_2_max(const int64_t x)
} \
(void)0
#define CLAMP4_MAX(vec, b) \
{ \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
CLAMP_MAX((vec)[2], b); \
CLAMP_MAX((vec)[3], b); \
} \
(void)0
/** \} */
/* -------------------------------------------------------------------- */

View File

@ -665,7 +665,7 @@ float perlin_ridged_multi_fractal(T p,
for (int i = 1; i <= int(detail); i++) {
p *= lacunarity;
weight = CLAMPIS(signal * gain, 0.0f, 1.0f);
weight = std::clamp(signal * gain, 0.0f, 1.0f);
signal = offset - std::abs(perlin_signed(p));
signal *= signal;
signal *= weight;

View File

@ -10,18 +10,16 @@
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <random>
#include "MEM_guardedalloc.h"
#include "BLI_bitmap.h"
#include "BLI_compiler_compat.h"
#include "BLI_math_vector.h"
#include "BLI_rand.h"
#include "BLI_rand.hh"
#include "BLI_threads.h"
#include "BLI_time.h"
/* defines BLI_INLINE */
#include "BLI_compiler_compat.h"
#include "BLI_strict_flags.h"
#include "BLI_sys_types.h"
@ -366,8 +364,11 @@ namespace blender {
RandomNumberGenerator RandomNumberGenerator::from_random_seed()
{
const double time = BLI_check_seconds_timer() * 1000000.0;
return RandomNumberGenerator(*reinterpret_cast<const uint32_t *>(&time));
std::random_device rd;
std::mt19937 e{rd()};
std::uniform_int_distribution<uint32_t> dist;
const uint32_t seed = dist(e);
return RandomNumberGenerator(seed);
}
void RandomNumberGenerator::seed_random(uint32_t seed)

View File

@ -57,6 +57,11 @@ typedef struct BlendFileData {
int fileflags;
int globalf;
/** Typically the actual filepath of the read blendfile, except when recovering
* save-on-exit/autosave files. In the latter case, it will be the path of the file that
* generated the auto-saved one being recovered.
*
* NOTE: Currently expected to be the same path as #BlendFileData.filepath. */
char filepath[1024]; /* 1024 = FILE_MAX */
/** TODO: think this isn't needed anymore? */

View File

@ -68,7 +68,7 @@
#include "BKE_global.h" /* for G */
#include "BKE_idprop.h"
#include "BKE_idtype.hh"
#include "BKE_layer.h"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_override.hh"
#include "BKE_lib_query.hh"
@ -3109,25 +3109,21 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
bfd->fileflags = fg->fileflags;
bfd->globalf = fg->globalf;
STRNCPY(bfd->filepath, fg->filepath);
/* Error in 2.65 and older: `main->filepath` was not set if you save from startup
* (not after loading file). */
if (bfd->filepath[0] == 0) {
if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1)) {
if ((G.fileflags & G_FILE_RECOVER_READ) == 0) {
STRNCPY(bfd->filepath, BKE_main_blendfile_path(bfd->main));
}
}
/* early 2.50 version patch - filepath not in FileGlobal struct at all */
if (fd->fileversion <= 250) {
STRNCPY(bfd->filepath, BKE_main_blendfile_path(bfd->main));
}
}
/* Note: since 88b24bc6bb, `fg->filepath` is only written for crash recovery and autosave files,
* so only overwrite `fd->relabase` if it is not empty, in case a regular blendfile is opened
* through one of the 'recover' operators.
*
* In all other cases, the path is just set to the current path of the blendfile being read, so
* there is no need to handle anymore older files (pre-2.65) that did not store (correctly) their
* path. */
if (G.fileflags & G_FILE_RECOVER_READ) {
STRNCPY(fd->relabase, fg->filepath);
if (fg->filepath[0] != '\0') {
STRNCPY(fd->relabase, fg->filepath);
/* Used to set expected original filepath in read Main, instead of the path of the recovery
* file itself. */
STRNCPY(bfd->filepath, fg->filepath);
}
}
bfd->curscreen = fg->curscreen;
@ -3589,6 +3585,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
bfd->main = BKE_main_new();
bfd->main->versionfile = fd->fileversion;
STRNCPY(bfd->filepath, filepath);
bfd->type = BLENFILETYPE_BLEND;

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