diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-15 15:23:59 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-15 15:23:59 +0300 |
commit | 9034351b8def3c3fd3b8d001a559dd91e2f28c14 (patch) | |
tree | d0228d217bd9f1eafbeeba973bd5e61ab782c840 | |
parent | b5c67c2ec146c86e362d030781c48066e8502fe8 (diff) | |
parent | 44bb73e765a6f79bc14a46449368f83e572d8bad (diff) |
Merge branch 'master' into tmp-eevee-glsl-cleanuptmp-eevee-glsl-cleanup
283 files changed, 2841 insertions, 1309 deletions
diff --git a/.clang-tidy b/.clang-tidy index df5fc05bfd1..ad8a89cab87 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -14,7 +14,6 @@ Checks: > -readability-else-after-return, -readability-inconsistent-declaration-parameter-name, - -readability-non-const-parameter, -readability-redundant-preprocessor, -readability-function-size, -readability-function-size, diff --git a/CMakeLists.txt b/CMakeLists.txt index e03ebb578fa..149b7d93aed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -416,7 +416,7 @@ option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_ass mark_as_advanced(WITH_ASSERT_ABORT) if(UNIX AND NOT APPLE) - option(WITH_CLANG_TIDY "Use Clang Tidy to analyze the source code (only enable for development on Limux using Clang)" OFF) + option(WITH_CLANG_TIDY "Use Clang Tidy to analyze the source code (only enable for development on Linux using Clang)" OFF) mark_as_advanced(WITH_CLANG_TIDY) endif() diff --git a/build_files/utils/make_test.py b/build_files/utils/make_test.py index 309ab36ecdd..15bd6dde352 100755 --- a/build_files/utils/make_test.py +++ b/build_files/utils/make_test.py @@ -40,7 +40,8 @@ if make_utils.command_missing(git_command): # Test if we are building a specific release version. branch = make_utils.git_branch(git_command) -release_version = make_utils.git_branch_release_version(branch) +tag = make_utils.git_tag(git_command) +release_version = make_utils.git_branch_release_version(branch, tag) lib_tests_dirpath = os.path.join('..', 'lib', "tests") if not os.path.exists(lib_tests_dirpath): diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py index b6157107c23..324bb6944bf 100755 --- a/build_files/utils/make_update.py +++ b/build_files/utils/make_update.py @@ -197,7 +197,8 @@ if __name__ == "__main__": # Test if we are building a specific release version. branch = make_utils.git_branch(args.git_command) - release_version = make_utils.git_branch_release_version(branch) + tag = make_utils.git_tag(args.git_command) + release_version = make_utils.git_branch_release_version(branch, tag) if not args.no_libraries: svn_update(args, release_version) diff --git a/build_files/utils/make_utils.py b/build_files/utils/make_utils.py index 7b21bc607a4..9a3d25f4952 100755 --- a/build_files/utils/make_utils.py +++ b/build_files/utils/make_utils.py @@ -36,7 +36,7 @@ def check_output(cmd, exit_on_error=True): return output.strip() def git_branch(git_command): - # Test if we are building a specific release version. + # Get current branch name. try: branch = subprocess.check_output([git_command, "rev-parse", "--abbrev-ref", "HEAD"]) except subprocess.CalledProcessError as e: @@ -45,10 +45,23 @@ def git_branch(git_command): return branch.strip().decode('utf8') -def git_branch_release_version(branch): +def git_tag(git_command): + # Get current tag name. + try: + tag = subprocess.check_output([git_command, "describe", "--exact-match"]) + except subprocess.CalledProcessError as e: + return None + + return tag.strip().decode('utf8') + +def git_branch_release_version(branch, tag): release_version = re.search("^blender-v(.*)-release$", branch) if release_version: release_version = release_version.group(1) + elif tag: + release_version = re.search("^v([0-9]*\.[0-9]*).*", tag) + if release_version: + release_version = release_version.group(1) return release_version def svn_libraries_base_url(release_version): diff --git a/extern/mantaflow/helper/util/vectorbase.h b/extern/mantaflow/helper/util/vectorbase.h index 41584663a0f..9ccf445f42c 100644 --- a/extern/mantaflow/helper/util/vectorbase.h +++ b/extern/mantaflow/helper/util/vectorbase.h @@ -248,12 +248,14 @@ template<class S> class Vector3D { protected: }; -//! helper to check whether float/double value is non-zero -inline bool notZero(Real f) +//! helper to check whether value is non-zero +template<class S> inline bool notZero(S v) { - if (std::abs(f) > VECTOR_EPSILON) - return true; - return false; + return (std::abs(v) > VECTOR_EPSILON); +} +template<class S> inline bool notZero(Vector3D<S> v) +{ + return (std::abs(norm(v)) > VECTOR_EPSILON); } //************************************************************************ diff --git a/extern/mantaflow/preprocessed/fileio/iomeshes.cpp b/extern/mantaflow/preprocessed/fileio/iomeshes.cpp index 1c50376de77..b5e51625077 100644 --- a/extern/mantaflow/preprocessed/fileio/iomeshes.cpp +++ b/extern/mantaflow/preprocessed/fileio/iomeshes.cpp @@ -315,10 +315,14 @@ int readObjFile(const std::string &name, Mesh *mesh, bool append) return 0; } + const Real dx = mesh->getParent()->getDx(); + const Vec3 gs = toVec3(mesh->getParent()->getGridSize()); + if (!append) mesh->clear(); int nodebase = mesh->numNodes(); - int cnt = nodebase; + int cntNodes = nodebase, cntNormals = nodebase; + while (ifs.good() && !ifs.eof()) { string id; ifs >> id; @@ -333,19 +337,23 @@ int readObjFile(const std::string &name, Mesh *mesh, bool append) } else if (id == "vn") { // normals - if (!mesh->numNodes()) { + if (mesh->numNodes() != cntNodes) { errMsg("invalid amount of nodes"); return 0; } - Node n = mesh->nodes(cnt); - ifs >> n.normal.x >> n.normal.y >> n.normal.z; - cnt++; + Node *n = &mesh->nodes(cntNormals); + ifs >> n->normal.x >> n->normal.y >> n->normal.z; + cntNormals++; } else if (id == "v") { // vertex Node n; ifs >> n.pos.x >> n.pos.y >> n.pos.z; + // convert to grid space + n.pos /= dx; + n.pos += gs * 0.5; mesh->addNode(n); + cntNodes++; } else if (id == "g") { // group @@ -408,7 +416,6 @@ int writeObjFile(const string &name, Mesh *mesh) // write normals for (int i = 0; i < numVerts; i++) { Vector3D<float> n = toVec3f(mesh->nodes(i).normal); - // normalize to unit cube around 0 ofs << "vn " << n.value[0] << " " << n.value[1] << " " << n.value[2] << " " << "\n"; } diff --git a/extern/mantaflow/preprocessed/gitinfo.h b/extern/mantaflow/preprocessed/gitinfo.h index 73ff70b10a0..03dcbb3d9c5 100644 --- a/extern/mantaflow/preprocessed/gitinfo.h +++ b/extern/mantaflow/preprocessed/gitinfo.h @@ -1,3 +1,3 @@ -#define MANTA_GIT_VERSION "commit d80d3c821de74315ab26b5efd153d41477b976c4" +#define MANTA_GIT_VERSION "commit 7395d36e3f504edbdabe34b30edc855b422c7baa" diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 6d28c14e12a..45d25720aff 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -212,7 +212,7 @@ def enum_denoiser(self, context): items += enum_openimagedenoise_denoiser(self, context) return items -enum_denoising_optix_input_passes = ( +enum_denoising_input_passes = ( ('RGB', "Color", "Use only color as input", 1), ('RGB_ALBEDO', "Color + Albedo", "Use color and albedo data as input", 2), ('RGB_ALBEDO_NORMAL', "Color + Albedo + Normal", "Use color, albedo and normal data as input", 3), @@ -1451,11 +1451,18 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup): denoising_optix_input_passes: EnumProperty( name="Input Passes", - description="Passes handed over to the OptiX denoiser (this can have different effects on the denoised image)", - items=enum_denoising_optix_input_passes, + description="Passes used by the denoiser to distinguish noise from shader and geometry detail", + items=enum_denoising_input_passes, default='RGB_ALBEDO', ) + denoising_openimagedenoise_input_passes: EnumProperty( + name="Input Passes", + description="Passes used by the denoiser to distinguish noise from shader and geometry detail", + items=enum_denoising_input_passes, + default='RGB_ALBEDO_NORMAL', + ) + use_pass_crypto_object: BoolProperty( name="Cryptomatte Object", description="Render cryptomatte object pass, for isolating objects in compositing", diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 3d0b2f721b4..03b1675c309 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1008,6 +1008,7 @@ class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel): col.prop(cycles_view_layer, "denoising_optix_input_passes") return elif denoiser == 'OPENIMAGEDENOISE': + col.prop(cycles_view_layer, "denoising_openimagedenoise_input_passes") return col.prop(cycles_view_layer, "denoising_radius", text="Radius") diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 19d2730dc93..33e73b5a4b9 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -815,9 +815,10 @@ static ShaderNode *add_node(Scene *scene, sky->ground_albedo = b_sky_node.ground_albedo(); sky->sun_disc = b_sky_node.sun_disc(); sky->sun_size = b_sky_node.sun_size(); + sky->sun_intensity = b_sky_node.sun_intensity(); sky->sun_elevation = b_sky_node.sun_elevation(); sky->sun_rotation = b_sky_node.sun_rotation(); - sky->altitude = b_sky_node.altitude(); + sky->altitude = 1000.0f * b_sky_node.altitude(); sky->air_density = b_sky_node.air_density(); sky->dust_density = b_sky_node.dust_density(); sky->ozone_density = b_sky_node.ozone_density(); diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index ee2445e44c4..d509f2fc786 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -954,7 +954,13 @@ DenoiseParams BlenderSync::get_denoise_params(BL::Scene &b_scene, denoising.strength = get_float(clayer, "denoising_strength"); denoising.feature_strength = get_float(clayer, "denoising_feature_strength"); denoising.relative_pca = get_boolean(clayer, "denoising_relative_pca"); - denoising.optix_input_passes = get_enum(clayer, "denoising_optix_input_passes"); + + denoising.input_passes = (DenoiserInput)get_enum( + clayer, + (denoising.type == DENOISER_OPTIX) ? "denoising_optix_input_passes" : + "denoising_openimagedenoise_input_passes", + DENOISER_INPUT_NUM, + DENOISER_INPUT_RGB_ALBEDO_NORMAL); denoising.store_passes = get_boolean(clayer, "denoising_store_passes"); } diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index af8db5b75b8..ee3a3ddea64 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -951,12 +951,13 @@ class CPUDevice : public Device { void denoise_openimagedenoise_buffer(DeviceTask &task, float *buffer, - size_t offset, - size_t stride, - size_t x, - size_t y, - size_t w, - size_t h) + const size_t offset, + const size_t stride, + const size_t x, + const size_t y, + const size_t w, + const size_t h, + const float scale) { #ifdef WITH_OPENIMAGEDENOISE assert(openimagedenoise_supported()); @@ -982,31 +983,65 @@ class CPUDevice : public Device { } /* Set images with appropriate stride for our interleaved pass storage. */ - const struct { + struct { const char *name; - int offset; - } passes[] = {{"color", task.pass_denoising_data + DENOISING_PASS_COLOR}, - {"normal", task.pass_denoising_data + DENOISING_PASS_NORMAL}, - {"albedo", task.pass_denoising_data + DENOISING_PASS_ALBEDO}, - {"output", 0}, + const int offset; + const bool scale; + const bool use; + array<float> scaled_buffer; + } passes[] = {{"color", task.pass_denoising_data + DENOISING_PASS_COLOR, false, true}, + {"albedo", + task.pass_denoising_data + DENOISING_PASS_ALBEDO, + true, + task.denoising.input_passes >= DENOISER_INPUT_RGB_ALBEDO}, + {"normal", + task.pass_denoising_data + DENOISING_PASS_NORMAL, + true, + task.denoising.input_passes >= DENOISER_INPUT_RGB_ALBEDO_NORMAL}, + {"output", 0, false, true}, { NULL, 0 }}; for (int i = 0; passes[i].name; i++) { + if (!passes[i].use) { + continue; + } + const int64_t pixel_offset = offset + x + y * stride; - const int64_t buffer_offset = (pixel_offset * task.pass_stride + passes[i].offset) * - sizeof(float); - const int64_t pixel_stride = task.pass_stride * sizeof(float); + const int64_t buffer_offset = (pixel_offset * task.pass_stride + passes[i].offset); + const int64_t pixel_stride = task.pass_stride; const int64_t row_stride = stride * pixel_stride; - oidn_filter.setImage(passes[i].name, - (char *)buffer + buffer_offset, - oidn::Format::Float3, - w, - h, - 0, - pixel_stride, - row_stride); + if (passes[i].scale && scale != 1.0f) { + /* Normalize albedo and normal passes as they are scaled by the number of samples. + * For the color passes OIDN will perform auto-exposure making it unnecessary. */ + array<float> &scaled_buffer = passes[i].scaled_buffer; + scaled_buffer.resize(w * h * 3); + + for (int y = 0; y < h; y++) { + const float *pass_row = buffer + buffer_offset + y * row_stride; + float *scaled_row = scaled_buffer.data() + y * w * 3; + + for (int x = 0; x < w; x++) { + scaled_row[x * 3 + 0] = pass_row[x * pixel_stride + 0] * scale; + scaled_row[x * 3 + 1] = pass_row[x * pixel_stride + 1] * scale; + scaled_row[x * 3 + 2] = pass_row[x * pixel_stride + 2] * scale; + } + } + + oidn_filter.setImage( + passes[i].name, scaled_buffer.data(), oidn::Format::Float3, w, h, 0, 0, 0); + } + else { + oidn_filter.setImage(passes[i].name, + buffer + buffer_offset, + oidn::Format::Float3, + w, + h, + 0, + pixel_stride * sizeof(float), + row_stride * sizeof(float)); + } } /* Execute filter. */ @@ -1021,6 +1056,7 @@ class CPUDevice : public Device { (void)y; (void)w; (void)h; + (void)scale; #endif } @@ -1037,7 +1073,8 @@ class CPUDevice : public Device { rtile.x, rtile.y, rtile.w, - rtile.h); + rtile.h, + 1.0f / rtile.sample); /* todo: it may be possible to avoid this copy, but we have to ensure that * when other code copies data from the device it doesn't overwrite the @@ -1047,6 +1084,9 @@ class CPUDevice : public Device { else { /* Per-tile denoising. */ rtile.sample = rtile.start_sample + rtile.num_samples; + const float scale = 1.0f / rtile.sample; + const float invscale = rtile.sample; + const size_t pass_stride = task.pass_stride; /* Map neighboring tiles into one buffer for denoising. */ RenderTileNeighbors neighbors(rtile); @@ -1075,22 +1115,24 @@ class CPUDevice : public Device { const int ymax = min(ntile.y + ntile.h, rect.w); const size_t tile_offset = ntile.offset + xmin + ymin * ntile.stride; - const float *tile_buffer = (float *)ntile.buffer + tile_offset * task.pass_stride; + const float *tile_buffer = (float *)ntile.buffer + tile_offset * pass_stride; const size_t merged_stride = rect_size.x; const size_t merged_offset = (xmin - rect.x) + (ymin - rect.y) * merged_stride; - float *merged_buffer = merged.data() + merged_offset * task.pass_stride; + float *merged_buffer = merged.data() + merged_offset * pass_stride; for (int y = ymin; y < ymax; y++) { - memcpy(merged_buffer, tile_buffer, sizeof(float) * task.pass_stride * (xmax - xmin)); - tile_buffer += ntile.stride * task.pass_stride; - merged_buffer += merged_stride * task.pass_stride; + for (int x = 0; x < pass_stride * (xmax - xmin); x++) { + merged_buffer[x] = tile_buffer[x] * scale; + } + tile_buffer += ntile.stride * pass_stride; + merged_buffer += merged_stride * pass_stride; } } /* Denoise */ denoise_openimagedenoise_buffer( - task, merged.data(), 0, rect_size.x, 0, 0, rect_size.x, rect_size.y); + task, merged.data(), 0, rect_size.x, 0, 0, rect_size.x, rect_size.y, 1.0f); /* Copy back result from merged buffer. */ RenderTile &ntile = neighbors.target; @@ -1101,16 +1143,20 @@ class CPUDevice : public Device { const int ymax = min(ntile.y + ntile.h, rect.w); const size_t tile_offset = ntile.offset + xmin + ymin * ntile.stride; - float *tile_buffer = (float *)ntile.buffer + tile_offset * task.pass_stride; + float *tile_buffer = (float *)ntile.buffer + tile_offset * pass_stride; const size_t merged_stride = rect_size.x; const size_t merged_offset = (xmin - rect.x) + (ymin - rect.y) * merged_stride; - const float *merged_buffer = merged.data() + merged_offset * task.pass_stride; + const float *merged_buffer = merged.data() + merged_offset * pass_stride; for (int y = ymin; y < ymax; y++) { - memcpy(tile_buffer, merged_buffer, sizeof(float) * task.pass_stride * (xmax - xmin)); - tile_buffer += ntile.stride * task.pass_stride; - merged_buffer += merged_stride * task.pass_stride; + for (int x = 0; x < pass_stride * (xmax - xmin); x += pass_stride) { + tile_buffer[x + 0] = merged_buffer[x + 0] * invscale; + tile_buffer[x + 1] = merged_buffer[x + 1] * invscale; + tile_buffer[x + 2] = merged_buffer[x + 2] * invscale; + } + tile_buffer += ntile.stride * pass_stride; + merged_buffer += merged_stride * pass_stride; } } diff --git a/intern/cycles/device/device_optix.cpp b/intern/cycles/device/device_optix.cpp index 35856f48213..1cc45983565 100644 --- a/intern/cycles/device/device_optix.cpp +++ b/intern/cycles/device/device_optix.cpp @@ -877,7 +877,7 @@ class OptiXDevice : public CUDADevice { # if OPTIX_DENOISER_NO_PIXEL_STRIDE device_only_memory<float> input_rgb(this, "denoiser input rgb"); - input_rgb.alloc_to_device(rect_size.x * rect_size.y * 3 * task.denoising.optix_input_passes); + input_rgb.alloc_to_device(rect_size.x * rect_size.y * 3 * task.denoising.input_passes); void *input_args[] = {&input_rgb.device_pointer, &input_ptr, @@ -886,7 +886,7 @@ class OptiXDevice : public CUDADevice { &input_stride, &task.pass_stride, const_cast<int *>(pass_offset), - &task.denoising.optix_input_passes, + &task.denoising.input_passes, &rtile.sample}; launch_filter_kernel( "kernel_cuda_filter_convert_to_rgb", rect_size.x, rect_size.y, input_args); @@ -897,7 +897,7 @@ class OptiXDevice : public CUDADevice { # endif const bool recreate_denoiser = (denoiser == NULL) || - (task.denoising.optix_input_passes != denoiser_input_passes); + (task.denoising.input_passes != denoiser_input_passes); if (recreate_denoiser) { // Destroy existing handle before creating new one if (denoiser != NULL) { @@ -906,9 +906,9 @@ class OptiXDevice : public CUDADevice { // Create OptiX denoiser handle on demand when it is first used OptixDenoiserOptions denoiser_options; - assert(task.denoising.optix_input_passes >= 1 && task.denoising.optix_input_passes <= 3); + assert(task.denoising.input_passes >= 1 && task.denoising.input_passes <= 3); denoiser_options.inputKind = static_cast<OptixDenoiserInputKind>( - OPTIX_DENOISER_INPUT_RGB + (task.denoising.optix_input_passes - 1)); + OPTIX_DENOISER_INPUT_RGB + (task.denoising.input_passes - 1)); # if OPTIX_ABI_VERSION < 28 denoiser_options.pixelFormat = OPTIX_PIXEL_FORMAT_FLOAT3; # endif @@ -917,7 +917,7 @@ class OptiXDevice : public CUDADevice { optixDenoiserSetModel(denoiser, OPTIX_DENOISER_MODEL_KIND_HDR, NULL, 0)); // OptiX denoiser handle was created with the requested number of input passes - denoiser_input_passes = task.denoising.optix_input_passes; + denoiser_input_passes = task.denoising.input_passes; } OptixDenoiserSizes sizes = {}; @@ -992,7 +992,7 @@ class OptiXDevice : public CUDADevice { denoiser_state.device_pointer, scratch_offset, input_layers, - task.denoising.optix_input_passes, + task.denoising.input_passes, overlap_offset.x, overlap_offset.y, output_layers, diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h index 21da55d50d4..fd380788282 100644 --- a/intern/cycles/device/device_task.h +++ b/intern/cycles/device/device_task.h @@ -42,6 +42,14 @@ enum DenoiserType { DENOISER_ALL = ~0, }; +enum DenoiserInput { + DENOISER_INPUT_RGB = 1, + DENOISER_INPUT_RGB_ALBEDO = 2, + DENOISER_INPUT_RGB_ALBEDO_NORMAL = 3, + + DENOISER_INPUT_NUM, +}; + typedef int DenoiserTypeMask; class DenoiseParams { @@ -73,10 +81,10 @@ class DenoiseParams { /* Clamp the input to the range of +-1e8. Should be enough for any legitimate data. */ bool clamp_input; - /** Optix Denoiser **/ + /** OIDN/Optix Denoiser **/ - /* Passes handed over to the OptiX denoiser (default to color + albedo). */ - int optix_input_passes; + /* Passes handed over to the OIDN/OptiX denoiser (default to color + albedo). */ + DenoiserInput input_passes; DenoiseParams() { @@ -92,7 +100,7 @@ class DenoiseParams { neighbor_frames = 2; clamp_input = true; - optix_input_passes = 2; + input_passes = DENOISER_INPUT_RGB_ALBEDO_NORMAL; start_sample = 0; } diff --git a/intern/cycles/kernel/shaders/node_sky_texture.osl b/intern/cycles/kernel/shaders/node_sky_texture.osl index 20d379939ab..acb198a9852 100644 --- a/intern/cycles/kernel/shaders/node_sky_texture.osl +++ b/intern/cycles/kernel/shaders/node_sky_texture.osl @@ -127,12 +127,13 @@ float precise_angle(vector a, vector b) return 2.0 * atan2(length(a - b), length(a + b)); } -color sky_radiance_nishita(vector dir, float nishita_data[9], string filename) +color sky_radiance_nishita(vector dir, float nishita_data[10], string filename) { /* definitions */ float sun_elevation = nishita_data[6]; float sun_rotation = nishita_data[7]; float angular_diameter = nishita_data[8]; + float sun_intensity = nishita_data[9]; int sun_disc = angular_diameter > 0; float alpha = 1.0; color xyz; @@ -149,7 +150,7 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename) /* if ray inside sun disc render it, otherwise render sky */ if (sun_dir_angle < half_angular && sun_disc == 1) { - /* get 3 pixels data */ + /* get 2 pixels data */ color pixel_bottom = color(nishita_data[0], nishita_data[1], nishita_data[2]); color pixel_top = color(nishita_data[3], nishita_data[4], nishita_data[5]); float y; @@ -158,13 +159,13 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename) if (sun_elevation - half_angular > 0.0) { if ((sun_elevation + half_angular) > 0.0) { y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5; - xyz = mix(pixel_bottom, pixel_top, y); + xyz = mix(pixel_bottom, pixel_top, y) * sun_intensity; } } else { if (sun_elevation + half_angular > 0.0) { y = dir_elevation / (sun_elevation + half_angular); - xyz = mix(pixel_bottom, pixel_top, y); + xyz = mix(pixel_bottom, pixel_top, y) * sun_intensity; } } /* limb darkening, coefficient is 0.6f */ @@ -176,7 +177,8 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename) else { /* sky interpolation */ float x = (direction[1] + M_PI + sun_rotation) / M_2PI; - float y = 1.0 - (dir_elevation / M_PI_2); + /* more pixels toward horizon compensation */ + float y = 1.0 - sqrt(dir_elevation / M_PI_2); if (x > 1.0) { x = x - 1.0; } @@ -206,19 +208,20 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename) return xyz_to_rgb(xyz[0], xyz[1], xyz[2]) * 120000.0; } -shader node_sky_texture(int use_mapping = 0, - matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - vector Vector = P, - string type = "hosek_wilkie", - float theta = 0.0, - float phi = 0.0, - string filename = "", - color radiance = color(0.0, 0.0, 0.0), - float config_x[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - float config_y[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - float config_z[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - float nishita_data[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - output color Color = color(0.0, 0.0, 0.0)) +shader node_sky_texture( + int use_mapping = 0, + matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), + vector Vector = P, + string type = "hosek_wilkie", + float theta = 0.0, + float phi = 0.0, + string filename = "", + color radiance = color(0.0, 0.0, 0.0), + float config_x[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + float config_y[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + float config_z[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + float nishita_data[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + output color Color = color(0.0, 0.0, 0.0)) { vector p = Vector; diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h index 214c0cd1a9a..be2c8ccdacf 100644 --- a/intern/cycles/kernel/svm/svm_sky.h +++ b/intern/cycles/kernel/svm/svm_sky.h @@ -136,6 +136,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, float sun_elevation = nishita_data[6]; float sun_rotation = nishita_data[7]; float angular_diameter = nishita_data[8]; + float sun_intensity = nishita_data[9]; bool sun_disc = (angular_diameter > 0.0f); float3 xyz; /* convert dir to spherical coordinates */ @@ -151,7 +152,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, /* if ray inside sun disc render it, otherwise render sky */ if (sun_disc && sun_dir_angle < half_angular) { - /* get 3 pixels data */ + /* get 2 pixels data */ float3 pixel_bottom = make_float3(nishita_data[0], nishita_data[1], nishita_data[2]); float3 pixel_top = make_float3(nishita_data[3], nishita_data[4], nishita_data[5]); float y; @@ -160,13 +161,13 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, if (sun_elevation - half_angular > 0.0f) { if (sun_elevation + half_angular > 0.0f) { y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5f; - xyz = interp(pixel_bottom, pixel_top, y); + xyz = interp(pixel_bottom, pixel_top, y) * sun_intensity; } } else { if (sun_elevation + half_angular > 0.0f) { y = dir_elevation / (sun_elevation + half_angular); - xyz = interp(pixel_bottom, pixel_top, y); + xyz = interp(pixel_bottom, pixel_top, y) * sun_intensity; } } /* limb darkening, coefficient is 0.6f */ @@ -178,7 +179,8 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, else { /* sky interpolation */ float x = (direction.y + M_PI_F + sun_rotation) / M_2PI_F; - float y = dir_elevation / M_PI_2_F; + /* more pixels toward horizon compensation */ + float y = safe_sqrtf(dir_elevation / M_PI_2_F); if (x > 1.0f) { x -= 1.0f; } @@ -301,7 +303,7 @@ ccl_device void svm_node_tex_sky( /* Nishita */ else { /* Define variables */ - float nishita_data[9]; + float nishita_data[10]; float4 data = read_node_float(kg, offset); nishita_data[0] = data.x; @@ -317,7 +319,8 @@ ccl_device void svm_node_tex_sky( data = read_node_float(kg, offset); nishita_data[8] = data.x; - uint texture_id = __float_as_uint(data.y); + nishita_data[9] = data.y; + uint texture_id = __float_as_uint(data.z); /* Compute Sky */ f = sky_radiance_nishita(kg, dir, nishita_data, texture_id); diff --git a/intern/cycles/render/image_sky.cpp b/intern/cycles/render/image_sky.cpp index 24d4834c2fa..0560907c63e 100644 --- a/intern/cycles/render/image_sky.cpp +++ b/intern/cycles/render/image_sky.cpp @@ -25,8 +25,11 @@ CCL_NAMESPACE_BEGIN -SkyLoader::SkyLoader( - float sun_elevation, int altitude, float air_density, float dust_density, float ozone_density) +SkyLoader::SkyLoader(float sun_elevation, + float altitude, + float air_density, + float dust_density, + float ozone_density) : sun_elevation(sun_elevation), altitude(altitude), air_density(air_density), @@ -57,7 +60,6 @@ bool SkyLoader::load_pixels(const ImageMetaData &metadata, int width = metadata.width; int height = metadata.height; float *pixel_data = (float *)pixels; - float altitude_f = (float)altitude; /* precompute sky texture */ const int rows_per_task = divide_up(1024, width); @@ -70,7 +72,7 @@ bool SkyLoader::load_pixels(const ImageMetaData &metadata, width, height, sun_elevation, - altitude_f, + altitude, air_density, dust_density, ozone_density); diff --git a/intern/cycles/render/image_sky.h b/intern/cycles/render/image_sky.h index cf4a3e8942c..686f4e5b885 100644 --- a/intern/cycles/render/image_sky.h +++ b/intern/cycles/render/image_sky.h @@ -21,14 +21,14 @@ CCL_NAMESPACE_BEGIN class SkyLoader : public ImageLoader { private: float sun_elevation; - int altitude; + float altitude; float air_density; float dust_density; float ozone_density; public: SkyLoader(float sun_elevation, - int altitude, + float altitude, float air_density, float dust_density, float ozone_density); diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index c0615c6217b..183c02cb6b9 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -625,13 +625,19 @@ void LightManager::device_update_background(Device *device, } } + /* Determine sun direction from lat/long and texture mapping. */ float latitude = sky->sun_elevation; float longitude = M_2PI_F - sky->sun_rotation + M_PI_2_F; + float3 sun_direction = make_float3( + cosf(latitude) * cosf(longitude), cosf(latitude) * sinf(longitude), sinf(latitude)); + Transform sky_transform = transform_inverse(sky->tex_mapping.compute_transform()); + sun_direction = transform_direction(&sky_transform, sun_direction); + + /* Pack sun direction and size. */ float half_angle = sky->sun_size * 0.5f; - kbackground->sun = make_float4(cosf(latitude) * cosf(longitude), - cosf(latitude) * sinf(longitude), - sinf(latitude), - half_angle); + kbackground->sun = make_float4( + sun_direction.x, sun_direction.y, sun_direction.z, half_angle); + kbackground->sun_weight = 4.0f; environment_res.x = max(environment_res.x, 512); environment_res.y = max(environment_res.y, 256); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 1e09b71b340..1a29663ec5e 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -632,7 +632,7 @@ typedef struct SunSky { /* Parameter */ float radiance_x, radiance_y, radiance_z; - float config_x[9], config_y[9], config_z[9], nishita_data[9]; + float config_x[9], config_y[9], config_z[9], nishita_data[10]; } SunSky; /* Preetham model */ @@ -749,18 +749,24 @@ static void sky_texture_precompute_hosek(SunSky *sunsky, static void sky_texture_precompute_nishita(SunSky *sunsky, bool sun_disc, float sun_size, + float sun_intensity, float sun_elevation, float sun_rotation, - int altitude, + float altitude, float air_density, float dust_density) { /* sample 2 sun pixels */ float pixel_bottom[3]; float pixel_top[3]; - float altitude_f = (float)altitude; SKY_nishita_skymodel_precompute_sun( - sun_elevation, sun_size, altitude_f, air_density, dust_density, pixel_bottom, pixel_top); + sun_elevation, sun_size, altitude, air_density, dust_density, pixel_bottom, pixel_top); + /* limit sun rotation between 0 and 360 degrees */ + sun_rotation = fmodf(sun_rotation, M_2PI_F); + if (sun_rotation < 0.0f) { + sun_rotation += M_2PI_F; + } + sun_rotation = M_2PI_F - sun_rotation; /* send data to svm_sky */ sunsky->nishita_data[0] = pixel_bottom[0]; sunsky->nishita_data[1] = pixel_bottom[1]; @@ -769,8 +775,9 @@ static void sky_texture_precompute_nishita(SunSky *sunsky, sunsky->nishita_data[4] = pixel_top[1]; sunsky->nishita_data[5] = pixel_top[2]; sunsky->nishita_data[6] = sun_elevation; - sunsky->nishita_data[7] = M_2PI_F - sun_rotation; + sunsky->nishita_data[7] = sun_rotation; sunsky->nishita_data[8] = sun_disc ? sun_size : 0.0f; + sunsky->nishita_data[9] = sun_intensity; } NODE_DEFINE(SkyTextureNode) @@ -790,9 +797,10 @@ NODE_DEFINE(SkyTextureNode) SOCKET_FLOAT(ground_albedo, "Ground Albedo", 0.3f); SOCKET_BOOLEAN(sun_disc, "Sun Disc", true); SOCKET_FLOAT(sun_size, "Sun Size", 0.009512f); + SOCKET_FLOAT(sun_intensity, "Sun Intensity", 1.0f); SOCKET_FLOAT(sun_elevation, "Sun Elevation", M_PI_2_F); SOCKET_FLOAT(sun_rotation, "Sun Rotation", 0.0f); - SOCKET_INT(altitude, "Altitude", 0); + SOCKET_FLOAT(altitude, "Altitude", 1.0f); SOCKET_FLOAT(air_density, "Air", 1.0f); SOCKET_FLOAT(dust_density, "Dust", 1.0f); SOCKET_FLOAT(ozone_density, "Ozone", 1.0f); @@ -820,12 +828,17 @@ void SkyTextureNode::compile(SVMCompiler &compiler) else if (type == NODE_SKY_HOSEK) sky_texture_precompute_hosek(&sunsky, sun_direction, turbidity, ground_albedo); else if (type == NODE_SKY_NISHITA) { + /* Clamp altitude to reasonable values. + * Below 1m causes numerical issues and above 60km is space. */ + float clamped_altitude = clamp(altitude, 1.0f, 59999.0f); + sky_texture_precompute_nishita(&sunsky, sun_disc, sun_size, + sun_intensity, sun_elevation, sun_rotation, - altitude, + clamped_altitude, air_density, dust_density); /* precomputed texture image parameters */ @@ -837,7 +850,7 @@ void SkyTextureNode::compile(SVMCompiler &compiler) /* precompute sky texture */ if (handle.empty()) { SkyLoader *loader = new SkyLoader( - sun_elevation, altitude, air_density, dust_density, ozone_density); + sun_elevation, clamped_altitude, air_density, dust_density, ozone_density); handle = image_manager->add_image(loader, impar); } } @@ -892,7 +905,10 @@ void SkyTextureNode::compile(SVMCompiler &compiler) __float_as_uint(sunsky.nishita_data[5]), __float_as_uint(sunsky.nishita_data[6]), __float_as_uint(sunsky.nishita_data[7])); - compiler.add_node(__float_as_uint(sunsky.nishita_data[8]), handle.svm_slot(), 0, 0); + compiler.add_node(__float_as_uint(sunsky.nishita_data[8]), + __float_as_uint(sunsky.nishita_data[9]), + handle.svm_slot(), + 0); } tex_mapping.compile_end(compiler, vector_in, vector_offset); @@ -908,12 +924,17 @@ void SkyTextureNode::compile(OSLCompiler &compiler) else if (type == NODE_SKY_HOSEK) sky_texture_precompute_hosek(&sunsky, sun_direction, turbidity, ground_albedo); else if (type == NODE_SKY_NISHITA) { + /* Clamp altitude to reasonable values. + * Below 1m causes numerical issues and above 60km is space. */ + float clamped_altitude = clamp(altitude, 1.0f, 59999.0f); + sky_texture_precompute_nishita(&sunsky, sun_disc, sun_size, + sun_intensity, sun_elevation, sun_rotation, - altitude, + clamped_altitude, air_density, dust_density); /* precomputed texture image parameters */ @@ -925,7 +946,7 @@ void SkyTextureNode::compile(OSLCompiler &compiler) /* precompute sky texture */ if (handle.empty()) { SkyLoader *loader = new SkyLoader( - sun_elevation, altitude, air_density, dust_density, ozone_density); + sun_elevation, clamped_altitude, air_density, dust_density, ozone_density); handle = image_manager->add_image(loader, impar); } } @@ -940,7 +961,7 @@ void SkyTextureNode::compile(OSLCompiler &compiler) compiler.parameter_array("config_x", sunsky.config_x, 9); compiler.parameter_array("config_y", sunsky.config_y, 9); compiler.parameter_array("config_z", sunsky.config_z, 9); - compiler.parameter_array("nishita_data", sunsky.nishita_data, 9); + compiler.parameter_array("nishita_data", sunsky.nishita_data, 10); /* nishita texture */ if (type == NODE_SKY_NISHITA) { compiler.parameter_texture("filename", handle.svm_slot()); diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 846ba7423e5..326f1d14168 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -170,9 +170,10 @@ class SkyTextureNode : public TextureNode { float ground_albedo; bool sun_disc; float sun_size; + float sun_intensity; float sun_elevation; float sun_rotation; - int altitude; + float altitude; float air_density; float dust_density; float ozone_density; diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index c7737392e7b..92061f55128 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -362,8 +362,8 @@ extern GHOST_TSuccess GHOST_HasCursorShape(GHOST_WindowHandle windowhandle, * \param mask The mask data for the cursor. * \param sizex The width of the cursor * \param sizey The height of the cursor - * \param hotX The X coordinate of the cursor hotspot. - * \param hotY The Y coordinate of the cursor hotspot. + * \param hotX The X coordinate of the cursor hot-spot. + * \param hotY The Y coordinate of the cursor hot-spot. * \param canInvertColor Let macOS invert cursor color to match platform convention. * \return Indication of success. */ diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h index 62290d20f1c..9c72b6f07f9 100644 --- a/intern/ghost/GHOST_IWindow.h +++ b/intern/ghost/GHOST_IWindow.h @@ -287,8 +287,8 @@ class GHOST_IWindow { * Set the shape of the cursor to a custom cursor. * \param bitmap The bitmap data for the cursor. * \param mask The mask data for the cursor. - * \param hotX The X coordinate of the cursor hotspot. - * \param hotY The Y coordinate of the cursor hotspot. + * \param hotX The X coordinate of the cursor hot-spot. + * \param hotY The Y coordinate of the cursor hot-spot. * \return Indication of success. */ virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap, diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h index 6738aa850ce..7cfea5110c5 100644 --- a/intern/ghost/intern/GHOST_Window.h +++ b/intern/ghost/intern/GHOST_Window.h @@ -124,8 +124,8 @@ class GHOST_Window : public GHOST_IWindow { * Set the shape of the cursor to a custom cursor. * \param bitmap The bitmap data for the cursor. * \param mask The mask data for the cursor. - * \param hotX The X coordinate of the cursor hotspot. - * \param hotY The Y coordinate of the cursor hotspot. + * \param hotX The X coordinate of the cursor hot-spot. + * \param hotY The Y coordinate of the cursor hot-spot. * \return Indication of success. */ GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap, diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index 43121f08f2d..676a2fd785e 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -870,9 +870,9 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd) mRNAMap["GUIDING_ALPHA"] = to_string(fds->guide_alpha); mRNAMap["GUIDING_BETA"] = to_string(fds->guide_beta); mRNAMap["GUIDING_FACTOR"] = to_string(fds->guide_vel_factor); - mRNAMap["GRAVITY_X"] = to_string(fds->gravity[0]); - mRNAMap["GRAVITY_Y"] = to_string(fds->gravity[1]); - mRNAMap["GRAVITY_Z"] = to_string(fds->gravity[2]); + mRNAMap["GRAVITY_X"] = to_string(fds->gravity_final[0]); + mRNAMap["GRAVITY_Y"] = to_string(fds->gravity_final[1]); + mRNAMap["GRAVITY_Z"] = to_string(fds->gravity_final[2]); mRNAMap["CACHE_DIR"] = cacheDirectory; mRNAMap["COMPRESSION_OPENVDB"] = vdbCompressionMethod; mRNAMap["PRECISION_OPENVDB"] = vdbPrecisionHalf; @@ -1256,6 +1256,7 @@ bool MANTA::readData(FluidModifierData *fmd, int framenr, bool resumable) << ", '" << volume_format << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); result &= runPythonString(pythonCommands); + return (mSmokeFromFile = result); } if (mUsingLiquid) { ss.str(""); @@ -1263,6 +1264,7 @@ bool MANTA::readData(FluidModifierData *fmd, int framenr, bool resumable) << ", '" << volume_format << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); result &= runPythonString(pythonCommands); + return (mFlipFromFile = result); } return result; } @@ -1296,7 +1298,7 @@ bool MANTA::readNoise(FluidModifierData *fmd, int framenr, bool resumable) << ", '" << volume_format << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); - return runPythonString(pythonCommands); + return (mNoiseFromFile = runPythonString(pythonCommands)); } bool MANTA::readMesh(FluidModifierData *fmd, int framenr) @@ -1331,7 +1333,7 @@ bool MANTA::readMesh(FluidModifierData *fmd, int framenr) pythonCommands.push_back(ss.str()); } - return runPythonString(pythonCommands); + return (mMeshFromFile = runPythonString(pythonCommands)); } bool MANTA::readParticles(FluidModifierData *fmd, int framenr, bool resumable) @@ -1365,7 +1367,7 @@ bool MANTA::readParticles(FluidModifierData *fmd, int framenr, bool resumable) << framenr << ", '" << volume_format << "', " << resumable_cache << ")"; pythonCommands.push_back(ss.str()); - return runPythonString(pythonCommands); + return (mParticlesFromFile = runPythonString(pythonCommands)); } bool MANTA::readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain) diff --git a/intern/mantaflow/intern/strings/fluid_script.h b/intern/mantaflow/intern/strings/fluid_script.h index 977b99e7759..4ee3ae59957 100644 --- a/intern/mantaflow/intern/strings/fluid_script.h +++ b/intern/mantaflow/intern/strings/fluid_script.h @@ -146,19 +146,19 @@ mantaMsg('1 Mantaflow cell is ' + str(ratioMetersToRes_s$ID$) + ' Blender length ratioResToBLength_s$ID$ = float(res_s$ID$) / float(domainSize_s$ID$) # [cells / blength] (blength: cm, m, or km, ... )\n\ mantaMsg('1 Blender length unit is ' + str(ratioResToBLength_s$ID$) + ' Mantaflow cells long.')\n\ \n\ -ratioBTimeToTimstep_s$ID$ = float(1) / float(frameLengthRaw_s$ID$) # the time within 1 blender time unit, see also fluid.c\n\ -mantaMsg('1 Blender time unit is ' + str(ratioBTimeToTimstep_s$ID$) + ' Mantaflow time units long.')\n\ +ratioBTimeToTimestep_s$ID$ = float(1) / float(frameLengthRaw_s$ID$) # the time within 1 blender time unit, see also fluid.c\n\ +mantaMsg('1 Blender time unit is ' + str(ratioBTimeToTimestep_s$ID$) + ' Mantaflow time units long.')\n\ \n\ ratioFrameToFramelength_s$ID$ = float(1) / float(frameLengthUnscaled_s$ID$ ) # the time within 1 frame\n\ mantaMsg('frame / frameLength is ' + str(ratioFrameToFramelength_s$ID$) + ' Mantaflow time units long.')\n\ \n\ -scaleAcceleration_s$ID$ = ratioResToBLength_s$ID$ * (ratioBTimeToTimstep_s$ID$**2)# [meters/btime^2] to [cells/timestep^2] (btime: sec, min, or h, ...)\n\ +scaleAcceleration_s$ID$ = ratioResToBLength_s$ID$ * (ratioBTimeToTimestep_s$ID$**2)# [meters/btime^2] to [cells/timestep^2] (btime: sec, min, or h, ...)\n\ mantaMsg('scaleAcceleration is ' + str(scaleAcceleration_s$ID$))\n\ \n\ scaleSpeedFrames_s$ID$ = ratioResToBLength_s$ID$ * ratioFrameToFramelength_s$ID$ # [blength/frame] to [cells/frameLength]\n\ mantaMsg('scaleSpeed is ' + str(scaleSpeedFrames_s$ID$))\n\ \n\ -scaleSpeedTime_s$ID$ = ratioResToBLength_s$ID$ * ratioBTimeToTimstep_s$ID$ # [blength/btime] to [cells/frameLength]\n\ +scaleSpeedTime_s$ID$ = ratioResToBLength_s$ID$ * ratioBTimeToTimestep_s$ID$ # [blength/btime] to [cells/frameLength]\n\ mantaMsg('scaleSpeedTime is ' + str(scaleSpeedTime_s$ID$))\n\ \n\ gravity_s$ID$ *= scaleAcceleration_s$ID$ # scale from world acceleration to cell based acceleration\n\ diff --git a/intern/sky/include/sky_model.h b/intern/sky/include/sky_model.h index 9e7700f3042..021086e1e02 100644 --- a/intern/sky/include/sky_model.h +++ b/intern/sky/include/sky_model.h @@ -356,8 +356,8 @@ typedef struct SKY_ArHosekSkyModelState { ---------------------------------------------------------------------------- */ SKY_ArHosekSkyModelState *SKY_arhosekskymodelstate_alloc_init(const double solar_elevation, - const double atmospheric_turbidity, - const double ground_albedo); + const double atmospheric_turbidity, + const double ground_albedo); /* ---------------------------------------------------------------------------- @@ -398,56 +398,55 @@ SKY_ArHosekSkyModelState *SKY_arhosekskymodelstate_alienworld_alloc_init( void SKY_arhosekskymodelstate_free(SKY_ArHosekSkyModelState *state); double SKY_arhosekskymodel_radiance(SKY_ArHosekSkyModelState *state, - double theta, - double gamma, - double wavelength); + double theta, + double gamma, + double wavelength); // CIE XYZ and RGB versions SKY_ArHosekSkyModelState *SKY_arhosek_xyz_skymodelstate_alloc_init(const double turbidity, - const double albedo, - const double elevation); + const double albedo, + const double elevation); SKY_ArHosekSkyModelState *SKY_arhosek_rgb_skymodelstate_alloc_init(const double turbidity, - const double albedo, - const double elevation); + const double albedo, + const double elevation); double SKY_arhosek_tristim_skymodel_radiance(SKY_ArHosekSkyModelState *state, - double theta, - double gamma, - int channel); + double theta, + double gamma, + int channel); // Delivers the complete function: sky + sun, including limb darkening. // Please read the above description before using this - there are several // caveats! double SKY_arhosekskymodel_solar_radiance(SKY_ArHosekSkyModelState *state, - double theta, - double gamma, - double wavelength); - + double theta, + double gamma, + double wavelength); /* Nishita improved sky model */ void SKY_nishita_skymodel_precompute_texture(float *pixels, - int stride, - int start_y, - int end_y, - int width, - int height, - float sun_elevation, + int stride, + int start_y, + int end_y, + int width, + int height, + float sun_elevation, + float altitude, + float air_density, + float dust_density, + float ozone_density); + +void SKY_nishita_skymodel_precompute_sun(float sun_elevation, + float angular_diameter, float altitude, float air_density, float dust_density, - float ozone_density); - -void SKY_nishita_skymodel_precompute_sun(float sun_elevation, - float angular_diameter, - float altitude, - float air_density, - float dust_density, - float *pixel_bottom, - float *pixel_top); + float *r_pixel_bottom, + float *r_pixel_top); #ifdef __cplusplus } diff --git a/intern/sky/source/sky_model.cpp b/intern/sky/source/sky_model.cpp index 3eca68e076c..64cf14ec030 100644 --- a/intern/sky/source/sky_model.cpp +++ b/intern/sky/source/sky_model.cpp @@ -292,9 +292,9 @@ void SKY_arhosekskymodelstate_free(SKY_ArHosekSkyModelState *state) } double SKY_arhosekskymodel_radiance(SKY_ArHosekSkyModelState *state, - double theta, - double gamma, - double wavelength) + double theta, + double gamma, + double wavelength) { int low_wl = (int)((wavelength - 320.0) / 40.0); @@ -323,8 +323,8 @@ double SKY_arhosekskymodel_radiance(SKY_ArHosekSkyModelState *state, // xyz and rgb versions SKY_ArHosekSkyModelState *SKY_arhosek_xyz_skymodelstate_alloc_init(const double turbidity, - const double albedo, - const double elevation) + const double albedo, + const double elevation) { SKY_ArHosekSkyModelState *state = ALLOC(SKY_ArHosekSkyModelState); diff --git a/intern/sky/source/sky_nishita.cpp b/intern/sky/source/sky_nishita.cpp index 27286ddecac..eae95dc73fe 100644 --- a/intern/sky/source/sky_nishita.cpp +++ b/intern/sky/source/sky_nishita.cpp @@ -14,19 +14,23 @@ * limitations under the License. */ -#include "sky_model.h" #include "sky_float3.h" +#include "sky_model.h" /* Constants */ static const float rayleigh_scale = 8000.0f; // Rayleigh scale height (m) static const float mie_scale = 1200.0f; // Mie scale height (m) static const float mie_coeff = 2e-5f; // Mie scattering coefficient static const float mie_G = 0.76f; // aerosols anisotropy +static const float sqr_G = mie_G * mie_G; // squared aerosols anisotropy static const float earth_radius = 6360000.0f; // radius of Earth (m) static const float atmosphere_radius = 6420000.0f; // radius of atmosphere (m) static const int steps = 32; // segments per primary ray static const int steps_light = 16; // segments per sun connection ray static const int num_wavelengths = 21; // number of wavelengths +static const int max_luminous_efficacy = 683; // maximum luminous efficacy +static const float step_lambda = (num_wavelengths - 1) * + 1e-9f; // step between each sampled wavelength /* irradiance at top of atmosphere */ static const float irradiance[] = { 1.45756829855592995315f, 1.56596305559738380175f, 1.65148449067670455293f, @@ -90,7 +94,7 @@ static float3 spec_to_xyz(float *spectrum) xyz.y += cmf_xyz[i][1] * spectrum[i]; xyz.z += cmf_xyz[i][2] * spectrum[i]; } - return xyz * (20 * 683 * 1e-9f); + return xyz * step_lambda * max_luminous_efficacy; } /* Atmosphere volume models */ @@ -122,8 +126,6 @@ static float phase_rayleigh(float mu) static float phase_mie(float mu) { - static const float sqr_G = mie_G * mie_G; - return (3.0f * (1.0f - sqr_G) * (1.0f + sqr(mu))) / (8.0f * M_PI_F * (2.0f + sqr_G) * powf((1.0f + sqr_G - 2.0f * mie_G * mu), 1.5)); } @@ -167,6 +169,7 @@ static float3 ray_optical_depth(float3 ray_origin, float3 ray_dir) /* The density of each segment is evaluated at its middle. */ float3 P = ray_origin + 0.5f * segment; + for (int i = 0; i < steps_light; i++) { /* Compute height above sea level. */ float height = len(P) - earth_radius; @@ -174,13 +177,13 @@ static float3 ray_optical_depth(float3 ray_origin, float3 ray_dir) /* Accumulate optical depth of this segment (density is assumed to be constant along it). */ float3 density = make_float3( density_rayleigh(height), density_mie(height), density_ozone(height)); - optical_depth += segment_length * density; + optical_depth += density; /* Advance along ray. */ P += segment; } - return optical_depth; + return optical_depth * segment_length; } /* Single Scattering implementation */ @@ -219,6 +222,7 @@ static void single_scattering(float3 ray_dir, /* The density and in-scattering of each segment is evaluated at its middle. */ float3 P = ray_origin + 0.5f * segment; + for (int i = 0; i < steps; i++) { /* Compute height above sea level. */ float height = len(P) - earth_radius; @@ -268,16 +272,16 @@ static void single_scattering(float3 ray_dir, /* calculate texture array */ void SKY_nishita_skymodel_precompute_texture(float *pixels, - int stride, - int start_y, - int end_y, - int width, - int height, - float sun_elevation, - float altitude, - float air_density, - float dust_density, - float ozone_density) + int stride, + int start_y, + int end_y, + int width, + int height, + float sun_elevation, + float altitude, + float air_density, + float dust_density, + float ozone_density) { /* calculate texture pixels */ float spectrum[num_wavelengths]; @@ -287,11 +291,13 @@ void SKY_nishita_skymodel_precompute_texture(float *pixels, float latitude_step = M_PI_2_F / height; float longitude_step = M_2PI_F / width; + float half_lat_step = latitude_step / 2.0f; for (int y = start_y; y < end_y; y++) { - float latitude = latitude_step * y; + /* sample more pixels toward the horizon */ + float latitude = (M_PI_2_F + half_lat_step) * sqr((float)y / height); - float *pixel_row = pixels + (y * width) * stride; + float *pixel_row = pixels + (y * width * stride); for (int x = 0; x < half_width; x++) { float longitude = longitude_step * x - M_PI_F; @@ -299,13 +305,15 @@ void SKY_nishita_skymodel_precompute_texture(float *pixels, single_scattering(dir, sun_dir, cam_pos, air_density, dust_density, ozone_density, spectrum); float3 xyz = spec_to_xyz(spectrum); - pixel_row[x * stride + 0] = xyz.x; - pixel_row[x * stride + 1] = xyz.y; - pixel_row[x * stride + 2] = xyz.z; - int mirror_x = width - x - 1; - pixel_row[mirror_x * stride + 0] = xyz.x; - pixel_row[mirror_x * stride + 1] = xyz.y; - pixel_row[mirror_x * stride + 2] = xyz.z; + int pos_x = x * stride; + pixel_row[pos_x] = xyz.x; + pixel_row[pos_x + 1] = xyz.y; + pixel_row[pos_x + 2] = xyz.z; + /* mirror sky */ + int mirror_x = (width - x - 1) * stride; + pixel_row[mirror_x] = xyz.x; + pixel_row[mirror_x + 1] = xyz.y; + pixel_row[mirror_x + 2] = xyz.z; } } } @@ -326,17 +334,17 @@ static void sun_radiation(float3 cam_dir, /* Combine spectra and the optical depth into transmittance. */ float transmittance = rayleigh_coeff[i] * optical_depth.x * air_density + 1.11f * mie_coeff * optical_depth.y * dust_density; - r_spectrum[i] = (irradiance[i] / solid_angle) * expf(-transmittance); + r_spectrum[i] = irradiance[i] * expf(-transmittance) / solid_angle; } } void SKY_nishita_skymodel_precompute_sun(float sun_elevation, - float angular_diameter, - float altitude, - float air_density, - float dust_density, - float *pixel_bottom, - float *pixel_top) + float angular_diameter, + float altitude, + float air_density, + float dust_density, + float *r_pixel_bottom, + float *r_pixel_top) { /* definitions */ float half_angular = angular_diameter / 2.0f; @@ -358,10 +366,10 @@ void SKY_nishita_skymodel_precompute_sun(float sun_elevation, pix_top = spec_to_xyz(spectrum); /* store pixels */ - pixel_bottom[0] = pix_bottom.x; - pixel_bottom[1] = pix_bottom.y; - pixel_bottom[2] = pix_bottom.z; - pixel_top[0] = pix_top.x; - pixel_top[1] = pix_top.y; - pixel_top[2] = pix_top.z; + r_pixel_bottom[0] = pix_bottom.x; + r_pixel_bottom[1] = pix_bottom.y; + r_pixel_bottom[2] = pix_bottom.z; + r_pixel_top[0] = pix_top.x; + r_pixel_top[1] = pix_top.y; + r_pixel_top[2] = pix_top.z; } diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index e522ec3fcf9..a6101474aa9 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -601,8 +601,11 @@ class I18nSettings: return json.dumps(export_dict) def load(self, fname, reset=False): + reset = reset or fname is None if reset: self.__dict__ = {uid: data for uid, data in globals().items() if not uid.startswith("_")} + if fname is None: + return if isinstance(fname, str): if not os.path.isfile(fname): # Assume it is already real JSon string... diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py index a8e04eb2f24..02bfebbdc0c 100644 --- a/release/scripts/startup/bl_operators/view3d.py +++ b/release/scripts/startup/bl_operators/view3d.py @@ -159,6 +159,33 @@ class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator): return self.execute(context) +class VIEW3D_OT_edit_mesh_extrude_manifold_normal(Operator): + """Extrude manifold region along normals""" + bl_label = "Extrude Manifold Along Normals" + bl_idname = "view3d.edit_mesh_extrude_manifold_normal" + + @classmethod + def poll(cls, context): + obj = context.active_object + return (obj is not None and obj.mode == 'EDIT') + + def execute(self, context): + bpy.ops.mesh.extrude_manifold( + 'INVOKE_REGION_WIN', + MESH_OT_extrude_region={ + "use_dissolve_ortho_edges": True, + }, + TRANSFORM_OT_translate={ + "orient_type": 'NORMAL', + "constraint_axis": (False, False, True), + }, + ) + return {'FINISHED'} + + def invoke(self, context, _event): + return self.execute(context) + + class VIEW3D_OT_transform_gizmo_set(Operator): """Set the current transform gizmo""" bl_label = "Transform Gizmo Set" @@ -208,5 +235,6 @@ classes = ( VIEW3D_OT_edit_mesh_extrude_individual_move, VIEW3D_OT_edit_mesh_extrude_move, VIEW3D_OT_edit_mesh_extrude_shrink_fatten, + VIEW3D_OT_edit_mesh_extrude_manifold_normal, VIEW3D_OT_transform_gizmo_set, ) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index a543ea6685c..fc11e4a0a87 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1466,8 +1466,7 @@ class WM_OT_properties_edit(Operator): row = layout.row() row.prop(self, "use_soft_limits") - if bpy.app.use_override_library: - row.prop(self, "is_overridable_library") + row.prop(self, "is_overridable_library") row = layout.row(align=True) row.enabled = self.use_soft_limits diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index 209231cacb0..004bcaf819b 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -192,6 +192,10 @@ class ColorPalettePanel(BrushPanel): elif context.vertex_paint_object: capabilities = brush.vertex_paint_capabilities return capabilities.has_color + + elif context.sculpt_object: + capabilities = brush.sculpt_capabilities + return capabilities.has_color return False def draw(self, context): @@ -678,6 +682,10 @@ def brush_settings(layout, context, brush, popover=False): col.prop(brush, "tip_roundness") col.prop(brush, "tip_scale_x") + if brush.sculpt_tool == 'SMEAR': + col = layout.column() + col.prop(brush, "smear_deform_type") + if brush.sculpt_tool == 'MULTIPLANE_SCRAPE': col = layout.column() col.prop(brush, "multiplane_scrape_angle") diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index df2b3fcdbeb..e4d0423cd76 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2256,8 +2256,7 @@ class VIEW3D_MT_object_relations(Menu): layout.operator("object.proxy_make", text="Make Proxy...") - if bpy.app.use_override_library: - layout.operator("object.make_override_library", text="Make Library Override...") + layout.operator("object.make_override_library", text="Make Library Override...") layout.operator("object.make_dupli_face") @@ -3877,6 +3876,8 @@ class VIEW3D_MT_edit_mesh_extrude(Menu): layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"), 'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"), + 'MANIFOLD': lambda layout: + layout.operator("view3d.edit_mesh_extrude_manifold_normal", text="Extrude Manifold"), } @staticmethod @@ -3887,7 +3888,7 @@ class VIEW3D_MT_edit_mesh_extrude(Menu): menu = [] if mesh.total_face_sel: - menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE'] + menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE', 'MANIFOLD'] if mesh.total_edge_sel and (select_mode[0] or select_mode[1]): menu += ['EDGE'] if mesh.total_vert_sel and select_mode[0]: diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 3286209bd63..39e4ee2beac 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -812,7 +812,7 @@ class VIEW3D_PT_sculpt_voxel_remesh(Panel, View3DPaintPanel): col.prop(mesh, "use_remesh_preserve_volume", text="Volume") col.prop(mesh, "use_remesh_preserve_paint_mask", text="Paint Mask") col.prop(mesh, "use_remesh_preserve_sculpt_face_sets", text="Face Sets") - if preferences.experimental.use_preserver_vertex_colors: + if context.preferences.experimental.use_sculpt_vertex_colors: col.prop(mesh, "use_remesh_preserve_vertex_colors", text="Vertex Colors") diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 2dc6c6cd409..50c1a2e4e4e 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -484,6 +484,7 @@ simulation_node_categories = [ NodeItem("SimulationNodeTime"), NodeItem("SimulationNodeParticleAttribute"), NodeItem("FunctionNodeGroupInstanceID"), + NodeItem("ShaderNodeValue"), ]), SimulationNodeCategory("SIM_EMITTERS", "Emitters", items=[ NodeItem("SimulationNodeParticleMeshEmitter"), diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index d32ab474229..ca41e51984b 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -140,7 +140,7 @@ void BKE_curve_nurbs_vert_coords_apply(struct ListBase *lb, float (*BKE_curve_nurbs_key_vert_coords_alloc(struct ListBase *lb, float *key, int *r_vert_len))[3]; -void BKE_curve_nurbs_key_vert_tilts_apply(struct ListBase *lb, float *key); +void BKE_curve_nurbs_key_vert_tilts_apply(struct ListBase *lb, const float *key); void BKE_curve_editNurb_keyIndex_delCV(struct GHash *keyindex, const void *cv); void BKE_curve_editNurb_keyIndex_free(struct GHash **keyindex); diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 04b85aebb39..f59e796c98c 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -111,7 +111,7 @@ void BKE_defvert_sync_mapped(struct MDeformVert *dvert_dst, const int *flip_map, const int flip_map_len, const bool use_ensure); -void BKE_defvert_remap(struct MDeformVert *dvert, int *map, const int map_len); +void BKE_defvert_remap(struct MDeformVert *dvert, const int *map, const int map_len); void BKE_defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len); void BKE_defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index c3a597e29b9..ddd0cc286ab 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -271,7 +271,7 @@ void testhandles_fcurve(struct FCurve *fcu, eBezTriple_Flag sel_flag, const bool void sort_time_fcurve(struct FCurve *fcu); short test_time_fcurve(struct FCurve *fcu); -void correct_bezpart(float v1[2], float v2[2], float v3[2], float v4[2]); +void correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]); /* -------- Evaluation -------- */ diff --git a/source/blender/blenkernel/BKE_fluid.h b/source/blender/blenkernel/BKE_fluid.h index c958afb212e..2392263181d 100644 --- a/source/blender/blenkernel/BKE_fluid.h +++ b/source/blender/blenkernel/BKE_fluid.h @@ -37,7 +37,7 @@ struct Main; struct Scene; typedef float (*BKE_Fluid_BresenhamFn)( - float *result, float *input, int res[3], int *pixel, float *tRay, float correct); + float *result, const float *input, int res[3], int *pixel, float *tRay, float correct); struct Mesh *BKE_fluid_modifier_do(struct FluidModifierData *fmd, struct Depsgraph *depsgraph, @@ -56,9 +56,9 @@ bool BKE_fluid_reallocate_fluid(struct FluidDomainSettings *fds, int res[3], int void BKE_fluid_reallocate_copy_fluid(struct FluidDomainSettings *fds, int o_res[3], int n_res[3], - int o_min[3], - int n_min[3], - int o_max[3], + const int o_min[3], + const int n_min[3], + const int o_max[3], int o_shift[3], int n_shift[3]); void BKE_fluid_cache_free_all(struct FluidDomainSettings *fds, struct Object *ob); diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h index 411df66fe36..8f6603e28ae 100644 --- a/source/blender/blenkernel/BKE_lib_override.h +++ b/source/blender/blenkernel/BKE_lib_override.h @@ -51,9 +51,6 @@ struct Main; struct PointerRNA; struct PropertyRNA; -void BKE_lib_override_library_enable(const bool do_enable); -bool BKE_lib_override_library_is_enabled(void); - struct IDOverrideLibrary *BKE_lib_override_library_init(struct ID *local_id, struct ID *reference_id); void BKE_lib_override_library_copy(struct ID *dst_id, @@ -66,6 +63,10 @@ struct ID *BKE_lib_override_library_create_from_id(struct Main *bmain, struct ID *reference_id, const bool do_tagged_remap); bool BKE_lib_override_library_create_from_tag(struct Main *bmain); +void BKE_lib_override_library_dependencies_tag(struct Main *bmain, + struct ID *id_root, + const uint tag, + const bool do_create_main_relashionships); struct IDOverrideLibraryProperty *BKE_lib_override_library_property_find( struct IDOverrideLibrary *override, const char *rna_path); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 7d989bfcf69..b2510be656e 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -513,13 +513,13 @@ void BKE_mesh_loops_to_mface_corners(struct CustomData *fdata, void BKE_mesh_loops_to_tessdata(struct CustomData *fdata, struct CustomData *ldata, struct MFace *mface, - int *polyindices, + const int *polyindices, unsigned int (*loopindices)[4], const int num_faces); void BKE_mesh_tangent_loops_to_tessdata(struct CustomData *fdata, struct CustomData *ldata, struct MFace *mface, - int *polyindices, + const int *polyindices, unsigned int (*loopindices)[4], const int num_faces, const char *layer_name); diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index 9864cc4d28d..5ad5238bbb5 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -199,7 +199,7 @@ void BKE_mesh_loop_islands_clear(MeshIslandStore *island_store); void BKE_mesh_loop_islands_free(MeshIslandStore *island_store); void BKE_mesh_loop_islands_add(MeshIslandStore *islands, const int item_num, - int *item_indices, + const int *item_indices, const int num_island_items, int *island_item_indices, const int num_innercut_items, diff --git a/source/blender/blenkernel/BKE_node_tree_multi_function.hh b/source/blender/blenkernel/BKE_node_tree_multi_function.hh index 33810b331dc..dcbd551591f 100644 --- a/source/blender/blenkernel/BKE_node_tree_multi_function.hh +++ b/source/blender/blenkernel/BKE_node_tree_multi_function.hh @@ -80,6 +80,11 @@ class MFNetworkTreeMap { return network_; } + fn::MFNetwork &network() + { + return network_; + } + void add(const DSocket &dsocket, fn::MFSocket &socket) { BLI_assert(dsocket.is_input() == socket.is_input()); diff --git a/source/blender/blenkernel/BKE_object_deform.h b/source/blender/blenkernel/BKE_object_deform.h index 410cb862aa7..e4813aa2288 100644 --- a/source/blender/blenkernel/BKE_object_deform.h +++ b/source/blender/blenkernel/BKE_object_deform.h @@ -33,7 +33,7 @@ struct Object; struct bDeformGroup; /* General vgroup operations */ -void BKE_object_defgroup_remap_update_users(struct Object *ob, int *map); +void BKE_object_defgroup_remap_update_users(struct Object *ob, const int *map); bool BKE_object_defgroup_array_get(struct ID *id, struct MDeformVert **dvert_arr, int *dvert_tot); diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index f5e2ea51927..da9280148fd 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -224,7 +224,7 @@ void BKE_pbvh_bounding_box(const PBVH *pbvh, float min[3], float max[3]); unsigned int **BKE_pbvh_grid_hidden(const PBVH *pbvh); int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden, - int *grid_indices, + const int *grid_indices, int totgrid, int gridsize); diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index f919a31c165..a9abe2d0f6d 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -147,7 +147,7 @@ typedef struct PTCacheID { /* copies point data to cache data */ int (*write_point)(int index, void *calldata, void **data, int cfra); /* copies cache cata to point data */ - void (*read_point)(int index, void *calldata, void **data, float cfra, float *old_data); + void (*read_point)(int index, void *calldata, void **data, float cfra, const float *old_data); /* interpolated between previously read point data and cache data */ void (*interpolate_point)(int index, void *calldata, @@ -155,7 +155,7 @@ typedef struct PTCacheID { float cfra, float cfra1, float cfra2, - float *old_data); + const float *old_data); /* copies point data to cache data */ int (*write_stream)(PTCacheFile *pf, void *calldata); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index a50f9b24c61..107a27b00ab 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -285,6 +285,11 @@ void BKE_sequence_reload_new_file(struct Main *bmain, struct Scene *scene, struct Sequence *seq, const bool lock_range); +void BKE_sequence_movie_reload_if_needed(struct Main *bmain, + struct Scene *scene, + struct Sequence *seq, + bool *r_was_reloaded, + bool *r_can_produce_frames); int BKE_sequencer_evaluate_frame(struct Scene *scene, int cfra); int BKE_sequencer_get_shown_sequences(struct ListBase *seqbasep, int cfra, diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index 58337bcf488..2cc715464ad 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -56,7 +56,7 @@ # ifdef WITH_BINRELOC # include "binreloc.h" # endif -/* mkdtemp on OSX (and probably all *BSD?), not worth making specific check for this OS. */ +/* #mkdtemp on OSX (and probably all *BSD?), not worth making specific check for this OS. */ # include <unistd.h> #endif /* WIN32 */ @@ -120,7 +120,7 @@ static char *blender_version_decimal(const int ver) } /** - * Concatenates path_base, (optional) path_sep and (optional) folder_name into targetpath, + * Concatenates path_base, (optional) path_sep and (optional) folder_name into \a targetpath, * returning true if result points to a directory. */ static bool test_path(char *targetpath, @@ -138,14 +138,14 @@ static bool test_path(char *targetpath, BLI_strncpy(tmppath, path_base, sizeof(tmppath)); } - /* rare cases folder_name is omitted (when looking for ~/.config/blender/2.xx dir only) */ + /* Rare cases folder_name is omitted (when looking for `~/.config/blender/2.xx` dir only). */ if (folder_name) { BLI_join_dirfile(targetpath, targetpath_len, tmppath, folder_name); } else { BLI_strncpy(targetpath, tmppath, targetpath_len); } - /* FIXME: why is "//" on front of tmppath expanded to "/" (by BLI_join_dirfile) + /* FIXME: why is "//" on front of \a tmppath expanded to "/" (by BLI_join_dirfile) * if folder_name is specified but not otherwise? */ if (BLI_is_dir(targetpath)) { @@ -190,7 +190,7 @@ static bool test_env_path(char *path, const char *envvar) /** * Constructs in \a targetpath the name of a directory relative to a version-specific - * subdirectory in the parent directory of the Blender executable. + * sub-directory in the parent directory of the Blender executable. * * \param targetpath: String to return path * \param folder_name: Optional folder name within version-specific directory @@ -307,7 +307,7 @@ static bool get_path_environment_notest(char *targetpath, * \param targetpath: String to return path * \param folder_name: default name of folder within user area * \param subfolder_name: optional name of subfolder within folder - * \param ver: Blender version, used to construct a subdirectory name + * \param ver: Blender version, used to construct a sub-directory name * \return true if it was able to construct such a path. */ static bool get_path_user(char *targetpath, @@ -350,8 +350,8 @@ static bool get_path_user(char *targetpath, * * \param targetpath: String to return path * \param folder_name: default name of folder within installation area - * \param subfolder_name: optional name of subfolder within folder - * \param ver: Blender version, used to construct a subdirectory name + * \param subfolder_name: optional name of sub-folder within folder + * \param ver: Blender version, used to construct a sub-directory name * \return true if it was able to construct such a path. */ static bool get_path_system(char *targetpath, @@ -635,7 +635,7 @@ const char *BKE_appdir_folder_id_version(const int folder_id, const int ver, con * adds the correct extension (.com .exe etc) from * $PATHEXT if necessary. Also on Windows it translates * the name to its 8.3 version to prevent problems with - * spaces and stuff. Final result is returned in fullname. + * spaces and stuff. Final result is returned in \a fullname. * * \param fullname: The full path and full name of the executable * (must be FILE_MAX minimum) @@ -975,7 +975,7 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c /** * Sets btempdir_base to userdir if specified and is a valid directory, otherwise * chooses a suitable OS-specific temporary directory. - * Sets btempdir_session to a mkdtemp-generated sub-dir of btempdir_base. + * Sets btempdir_session to a #mkdtemp generated sub-dir of btempdir_base. * * \note On Window userdir will be set to the temporary directory! */ @@ -1019,7 +1019,11 @@ void BKE_tempdir_session_purge(void) } /* Gets a good default directory for fonts */ -bool BKE_appdir_font_folder_default(char *dir) + +bool BKE_appdir_font_folder_default( + /* This parameter can only be `const` on non-windows platforms. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + char *dir) { bool success = false; #ifdef WIN32 diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 7c8c1cf6653..f45cd5b679a 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -1037,7 +1037,7 @@ static void cloth_free_errorsprings(Cloth *cloth, } BLI_INLINE void cloth_bend_poly_dir( - ClothVertex *verts, int i, int j, int *inds, int len, float r_dir[3]) + ClothVertex *verts, int i, int j, const int *inds, int len, float r_dir[3]) { float cent[3] = {0}; float fact = 1.0f / len; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index c894534c504..e9e44ac05e5 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1157,7 +1157,7 @@ void BKE_nurb_knot_calc_v(Nurb *nu) } static void basisNurb( - float t, short order, int pnts, float *knots, float *basis, int *start, int *end) + float t, short order, int pnts, const float *knots, float *basis, int *start, int *end) { float d, e; int i, i1 = 0, i2 = 0, j, orderpluspnts, opp2, o2; @@ -3560,8 +3560,13 @@ static void free_arrays(void *buffer) } /* computes in which direction to change h[i] to satisfy conditions better */ -static float bezier_relax_direction( - float *a, float *b, float *c, float *d, float *h, int i, int count) +static float bezier_relax_direction(const float *a, + const float *b, + const float *c, + const float *d, + const float *h, + int i, + int count) { /* current deviation between sides of the equation */ float state = a[i] * h[(i + count - 1) % count] + b[i] * h[i] + c[i] * h[(i + 1) % count] - d[i]; @@ -3577,8 +3582,15 @@ static void bezier_lock_unknown(float *a, float *b, float *c, float *d, int i, f d[i] = value; } -static void bezier_restore_equation( - float *a, float *b, float *c, float *d, float *a0, float *b0, float *c0, float *d0, int i) +static void bezier_restore_equation(float *a, + float *b, + float *c, + float *d, + const float *a0, + const float *b0, + const float *c0, + const float *d0, + int i) { a[i] = a0[i]; b[i] = b0[i]; @@ -3586,8 +3598,14 @@ static void bezier_restore_equation( d[i] = d0[i]; } -static bool tridiagonal_solve_with_limits( - float *a, float *b, float *c, float *d, float *h, float *hmin, float *hmax, int solve_count) +static bool tridiagonal_solve_with_limits(float *a, + float *b, + float *c, + float *d, + float *h, + const float *hmin, + const float *hmax, + int solve_count) { float *a0, *b0, *c0, *d0; float **arrays[] = {&a0, &b0, &c0, &d0, NULL}; @@ -3726,7 +3744,7 @@ static bool tridiagonal_solve_with_limits( /* clang-format on */ static void bezier_eq_continuous( - float *a, float *b, float *c, float *d, float *dy, float *l, int i) + float *a, float *b, float *c, float *d, const float *dy, const float *l, int i) { a[i] = l[i] * l[i]; b[i] = 2.0f * (l[i] + 1); @@ -3735,7 +3753,7 @@ static void bezier_eq_continuous( } static void bezier_eq_noaccel_right( - float *a, float *b, float *c, float *d, float *dy, float *l, int i) + float *a, float *b, float *c, float *d, const float *dy, const float *l, int i) { a[i] = 0.0f; b[i] = 2.0f; @@ -3744,7 +3762,7 @@ static void bezier_eq_noaccel_right( } static void bezier_eq_noaccel_left( - float *a, float *b, float *c, float *d, float *dy, float *l, int i) + float *a, float *b, float *c, float *d, const float *dy, const float *l, int i) { a[i] = l[i] * l[i]; b[i] = 2.0f * l[i]; @@ -4823,7 +4841,7 @@ float (*BKE_curve_nurbs_key_vert_coords_alloc(ListBase *lb, float *key, int *r_v return cos; } -void BKE_curve_nurbs_key_vert_tilts_apply(ListBase *lb, float *key) +void BKE_curve_nurbs_key_vert_tilts_apply(ListBase *lb, const float *key) { Nurb *nu; int i; diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c index 48e0ee50d43..9bdd80fd668 100644 --- a/source/blender/blenkernel/intern/data_transfer.c +++ b/source/blender/blenkernel/intern/data_transfer.c @@ -562,7 +562,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map CustomData *cd_dst, const bool use_dupref_dst, const int tolayers, - bool *use_layers_src, + const bool *use_layers_src, const int num_layers_src, cd_datatransfer_interp interp, void *interp_data) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index b97935d57f2..98fc5f9a23a 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -249,7 +249,7 @@ void BKE_defvert_sync_mapped(MDeformVert *dvert_dst, /** * be sure all flip_map values are valid */ -void BKE_defvert_remap(MDeformVert *dvert, int *map, const int map_len) +void BKE_defvert_remap(MDeformVert *dvert, const int *map, const int map_len) { MDeformWeight *dw = dvert->dw; unsigned int i; @@ -1184,7 +1184,7 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map, CustomData *cd_dst, const bool UNUSED(use_dupref_dst), const int tolayers, - bool *use_layers_src, + const bool *use_layers_src, const int num_layers_src) { int idx_src; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 2e1fa519284..b9279ace39f 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -588,7 +588,7 @@ static bool boundsIntersectDist(Bounds3D *b1, Bounds3D *b2, const float dist) } /* check whether bounds intersects a point with given radius */ -static bool boundIntersectPoint(Bounds3D *b, float point[3], const float radius) +static bool boundIntersectPoint(Bounds3D *b, const float point[3], const float radius) { if (!b->valid) { return false; @@ -4780,13 +4780,16 @@ static void dynamic_paint_paint_single_point_cb_ex(void *__restrict userdata, } } -static int dynamicPaint_paintSinglePoint(Depsgraph *depsgraph, - DynamicPaintSurface *surface, - float *pointCoord, - DynamicPaintBrushSettings *brush, - Object *brushOb, - Scene *scene, - float timescale) +static int dynamicPaint_paintSinglePoint( + Depsgraph *depsgraph, + DynamicPaintSurface *surface, + /* Cannot be const, because it is assigned to non-const variable. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + float *pointCoord, + DynamicPaintBrushSettings *brush, + Object *brushOb, + Scene *scene, + float timescale) { PaintSurfaceData *sData = surface->data; float brush_radius = brush->paint_distance * surface->radius_scale; @@ -5456,11 +5459,14 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata, } } -static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, - float *force, - PaintPoint *prevPoint, - float timescale, - float steps) +static void dynamicPaint_doEffectStep( + DynamicPaintSurface *surface, + /* Cannot be const, because it is assigned to non-const variable. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + float *force, + PaintPoint *prevPoint, + float timescale, + float steps) { PaintSurfaceData *sData = surface->data; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index bc14f525c2c..746aff1697c 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1277,7 +1277,7 @@ short test_time_fcurve(FCurve *fcu) * than the horizontal distance between (v1-v4). * This is to prevent curve loops. */ -void correct_bezpart(float v1[2], float v2[2], float v3[2], float v4[2]) +void correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]) { float h1[2], h2[2], len1, len2, len, fac; diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 1f748487841..52a3521189b 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -137,9 +137,9 @@ bool BKE_fluid_reallocate_fluid(FluidDomainSettings *fds, int res[3], int free_o void BKE_fluid_reallocate_copy_fluid(FluidDomainSettings *fds, int o_res[3], int n_res[3], - int o_min[3], - int n_min[3], - int o_max[3], + const int o_min[3], + const int n_min[3], + const int o_max[3], int o_shift[3], int n_shift[3]) { @@ -491,6 +491,17 @@ static void manta_set_domain_from_mesh(FluidDomainSettings *fds, fds->cell_size[2] /= (float)fds->base_res[2]; } +static void update_final_gravity(FluidDomainSettings *fds, Scene *scene) +{ + if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { + copy_v3_v3(fds->gravity_final, scene->physics_settings.gravity); + } + else { + copy_v3_v3(fds->gravity_final, fds->gravity); + } + mul_v3_fl(fds->gravity_final, fds->effector_weights->global_gravity); +} + static bool BKE_fluid_modifier_init( FluidModifierData *fmd, Depsgraph *depsgraph, Object *ob, Scene *scene, Mesh *me) { @@ -502,10 +513,7 @@ static bool BKE_fluid_modifier_init( /* Set domain dimensions from mesh. */ manta_set_domain_from_mesh(fds, ob, me, true); /* Set domain gravity, use global gravity if enabled. */ - if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { - copy_v3_v3(fds->gravity, scene->physics_settings.gravity); - } - mul_v3_fl(fds->gravity, fds->effector_weights->global_gravity); + update_final_gravity(fds, scene); /* Reset domain values. */ zero_v3_int(fds->shift); zero_v3(fds->shift_f); @@ -559,7 +567,7 @@ static bool BKE_fluid_modifier_init( // forward declaration static void manta_smoke_calc_transparency(FluidDomainSettings *fds, ViewLayer *view_layer); static float calc_voxel_transp( - float *result, float *input, int res[3], int *pixel, float *t_ray, float correct); + float *result, const float *input, int res[3], int *pixel, float *t_ray, float correct); static void update_distances(int index, float *fesh_distances, BVHTreeFromMesh *tree_data, @@ -594,8 +602,8 @@ static int get_light(ViewLayer *view_layer, float *light) static void clamp_bounds_in_domain(FluidDomainSettings *fds, int min[3], int max[3], - float *min_vel, - float *max_vel, + const float *min_vel, + const float *max_vel, int margin, float dt) { @@ -1830,7 +1838,7 @@ static void sample_mesh(FluidFlowSettings *ffs, float *velocity_map, int index, const int base_res[3], - float flow_center[3], + const float flow_center[3], BVHTreeFromMesh *tree_data, const float ray_start[3], const float *vert_vel, @@ -3328,17 +3336,13 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds, Mesh *orgmesh, Obj mverts->co[1] = manta_liquid_get_vertex_y_at(fds->fluid, i); mverts->co[2] = manta_liquid_get_vertex_z_at(fds->fluid, i); - /* If reading raw data directly from manta, normalize now (e.g. during replay mode). - * If reading data from files from disk, omit this normalization. */ - if (!manta_liquid_mesh_from_file(fds->fluid)) { - // normalize to unit cube around 0 - mverts->co[0] -= ((float)fds->res[0] * fds->mesh_scale) * 0.5f; - mverts->co[1] -= ((float)fds->res[1] * fds->mesh_scale) * 0.5f; - mverts->co[2] -= ((float)fds->res[2] * fds->mesh_scale) * 0.5f; - mverts->co[0] *= fds->dx / fds->mesh_scale; - mverts->co[1] *= fds->dx / fds->mesh_scale; - mverts->co[2] *= fds->dx / fds->mesh_scale; - } + /* Adjust coordinates from Mantaflow to match viewport scaling. */ + float tmp[3] = {(float)fds->res[0], (float)fds->res[1], (float)fds->res[2]}; + /* Scale to unit cube around 0. */ + mul_v3_fl(tmp, fds->mesh_scale * 0.5f); + sub_v3_v3(mverts->co, tmp); + /* Apply scaling of domain object. */ + mul_v3_fl(mverts->co, fds->dx / fds->mesh_scale); mul_v3_v3(mverts->co, co_scale); add_v3_v3(mverts->co, co_offset); @@ -3808,10 +3812,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd, fds->time_per_frame = 0; /* Ensure that gravity is copied over every frame (could be keyframed). */ - if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { - copy_v3_v3(fds->gravity, scene->physics_settings.gravity); - mul_v3_fl(fds->gravity, fds->effector_weights->global_gravity); - } + update_final_gravity(fds, scene); int next_frame = scene_framenr + 1; int prev_frame = scene_framenr - 1; @@ -4118,43 +4119,47 @@ static void BKE_fluid_modifier_process( struct Mesh *BKE_fluid_modifier_do( FluidModifierData *fmd, Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *me) { - /* Lock so preview render does not read smoke data while it gets modified. */ - if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) { - BLI_rw_mutex_lock(fmd->domain->fluid_mutex, THREAD_LOCK_WRITE); - } - - BKE_fluid_modifier_process(fmd, depsgraph, scene, ob, me); - - if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) { - BLI_rw_mutex_unlock(fmd->domain->fluid_mutex); - } - /* Optimization: Do not update viewport during bakes (except in replay mode) * Reason: UI is locked and updated liquid / smoke geometry is not visible anyways. */ bool needs_viewport_update = false; - if (fmd->domain) { - FluidDomainSettings *fds = fmd->domain; - /* Always update viewport in cache replay mode. */ - if (fds->cache_type == FLUID_DOMAIN_CACHE_REPLAY || - fds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) { - needs_viewport_update = true; + /* Optimization: Only process modifier if object is not being altered. */ + if (!G.moving) { + /* Lock so preview render does not read smoke data while it gets modified. */ + if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) { + BLI_rw_mutex_lock(fmd->domain->fluid_mutex, THREAD_LOCK_WRITE); } - /* In other cache modes, only update the viewport when no bake is going on. */ - else { - bool with_mesh; - with_mesh = fds->flags & FLUID_DOMAIN_USE_MESH; - bool baking_data, baking_noise, baking_mesh, baking_particles, baking_guide; - baking_data = fds->cache_flag & FLUID_DOMAIN_BAKING_DATA; - baking_noise = fds->cache_flag & FLUID_DOMAIN_BAKING_NOISE; - baking_mesh = fds->cache_flag & FLUID_DOMAIN_BAKING_MESH; - baking_particles = fds->cache_flag & FLUID_DOMAIN_BAKING_PARTICLES; - baking_guide = fds->cache_flag & FLUID_DOMAIN_BAKING_GUIDE; - - if (with_mesh && !baking_data && !baking_noise && !baking_mesh && !baking_particles && - !baking_guide) { + + BKE_fluid_modifier_process(fmd, depsgraph, scene, ob, me); + + if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) { + BLI_rw_mutex_unlock(fmd->domain->fluid_mutex); + } + + if (fmd->domain) { + FluidDomainSettings *fds = fmd->domain; + + /* Always update viewport in cache replay mode. */ + if (fds->cache_type == FLUID_DOMAIN_CACHE_REPLAY || + fds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) { needs_viewport_update = true; } + /* In other cache modes, only update the viewport when no bake is going on. */ + else { + bool with_mesh; + with_mesh = fds->flags & FLUID_DOMAIN_USE_MESH; + bool baking_data, baking_noise, baking_mesh, baking_particles, baking_guide; + baking_data = fds->cache_flag & FLUID_DOMAIN_BAKING_DATA; + baking_noise = fds->cache_flag & FLUID_DOMAIN_BAKING_NOISE; + baking_mesh = fds->cache_flag & FLUID_DOMAIN_BAKING_MESH; + baking_particles = fds->cache_flag & FLUID_DOMAIN_BAKING_PARTICLES; + baking_guide = fds->cache_flag & FLUID_DOMAIN_BAKING_GUIDE; + + if (with_mesh && !baking_data && !baking_noise && !baking_mesh && !baking_particles && + !baking_guide) { + needs_viewport_update = true; + } + } } } @@ -4196,7 +4201,7 @@ struct Mesh *BKE_fluid_modifier_do( } static float calc_voxel_transp( - float *result, float *input, int res[3], int *pixel, float *t_ray, float correct) + float *result, const float *input, int res[3], int *pixel, float *t_ray, float correct) { const size_t index = manta_get_index(pixel[0], res[0], pixel[1], res[1], pixel[2]); diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index dfb0fff1239..b92f86d7aea 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -1146,7 +1146,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const bGPDspoint *ref_points, static void gpencil_calc_stroke_fill_uv(const float (*points2d)[2], bGPDstroke *gps, const float minv[2], - float maxv[2], + const float maxv[2], float (*r_uv)[2]) { const float s = sin(gps->uv_rotation); diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index af8ab22e14b..46a41df0391 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -529,7 +529,13 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl) return 0; } -static void flerp(int tot, float *in, float *f0, float *f1, float *f2, float *f3, float *t) +static void flerp(int tot, + float *in, + const float *f0, + const float *f1, + const float *f2, + const float *f3, + const float *t) { int a; @@ -538,7 +544,7 @@ static void flerp(int tot, float *in, float *f0, float *f1, float *f2, float *f3 } } -static void rel_flerp(int tot, float *in, float *ref, float *out, float fac) +static void rel_flerp(int tot, float *in, const float *ref, const float *out, float fac) { int a; diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 457d096f983..58856729f24 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -38,6 +38,7 @@ #include "BKE_key.h" #include "BKE_lib_id.h" #include "BKE_lib_override.h" +#include "BKE_lib_query.h" #include "BKE_lib_remap.h" #include "BKE_main.h" @@ -66,20 +67,6 @@ static void lib_override_library_property_clear(IDOverrideLibraryProperty *op); static void lib_override_library_property_operation_clear( IDOverrideLibraryPropertyOperation *opop); -/* Temp, for until library override is ready and tested enough to go 'public', - * we hide it by default in UI and such. */ -static bool _lib_override_library_enabled = true; - -void BKE_lib_override_library_enable(const bool do_enable) -{ - _lib_override_library_enabled = do_enable; -} - -bool BKE_lib_override_library_is_enabled() -{ - return _lib_override_library_enabled; -} - /** Initialize empty overriding of \a reference_id by \a local_id. */ IDOverrideLibrary *BKE_lib_override_library_init(ID *local_id, ID *reference_id) { @@ -368,6 +355,56 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain) return success; } +static bool lib_override_hierarchy_recursive_tag(Main *bmain, ID *id) +{ + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->id_user_to_used, id); + + /* This way we won't process again that ID should we encounter it again through another + * relationship hierarchy. + * Note that this does not free any memory from relations, so we can still use the entries. + */ + BKE_main_relations_ID_remove(bmain, id); + + for (; entry != NULL; entry = entry->next) { + /* We only consider IDs from the same library. */ + if (entry->id_pointer != NULL && (*entry->id_pointer)->lib == id->lib) { + if (lib_override_hierarchy_recursive_tag(bmain, *entry->id_pointer)) { + id->tag |= LIB_TAG_DOIT; + } + } + } + + return (id->tag & LIB_TAG_DOIT) != 0; +} + +/** + * Tag all IDs in given \a bmain that use (depends on) given \a id_root ID. + * + * This will include all local IDs, and all IDs from the same library as the \a id_root. + * + * \param id_root The root of the hierarchy of dependencies to be tagged. + * \param do_create_main_relashionships Whether main relations needs to be created or already exist + * (in any case, they will be freed by this function). + */ +void BKE_lib_override_library_dependencies_tag(struct Main *bmain, + struct ID *id_root, + const uint tag, + const bool do_create_main_relashionships) +{ + id_root->tag |= tag; + + if (do_create_main_relashionships) { + BKE_main_relations_create(bmain, 0); + } + + /* Then we tag all intermediary data-blocks in-between two overridden ones (e.g. if a shapekey + * has a driver using an armature object's bone, we need to override the shapekey/obdata, the + * objects using them, etc.) */ + lib_override_hierarchy_recursive_tag(bmain, id_root); + + BKE_main_relations_free(bmain); +} + /* We only build override GHash on request. */ BLI_INLINE IDOverrideLibraryRuntime *override_library_rna_path_mapping_ensure( IDOverrideLibrary *override) diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 49c909850de..7e859799a4e 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -624,7 +624,7 @@ void BKE_mask_point_segment_co(MaskSpline *spline, MaskSplinePoint *point, float co, bezt->vec[1], bezt->vec[2], bezt_next->vec[0], bezt_next->vec[1], u); } -BLI_INLINE void orthogonal_direction_get(float vec[2], float result[2]) +BLI_INLINE void orthogonal_direction_get(const float vec[2], float result[2]) { result[0] = -vec[1]; result[1] = vec[0]; diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 412ccd3ab39..7f98266becc 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -1256,7 +1256,7 @@ static float maskrasterize_layer_z_depth_quad( return w[2] + w[3]; /* we can make this assumption for small speedup */ } -static float maskrasterize_layer_isect(unsigned int *face, +static float maskrasterize_layer_isect(const unsigned int *face, float (*cos)[3], const float dist_orig, const float xy[2]) @@ -1489,6 +1489,8 @@ static void maskrasterize_buffer_cb(void *__restrict userdata, void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, const unsigned int width, const unsigned int height, + /* Cannot be const, because it is assigned to non-const variable. + * NOLINTNEXTLINE: readability-non-const-parameter. */ float *buffer) { const float x_inv = 1.0f / (float)width; diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index b298a6a2787..49957b584ad 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -2888,7 +2888,7 @@ void BKE_mesh_loops_to_mface_corners( void BKE_mesh_loops_to_tessdata(CustomData *fdata, CustomData *ldata, MFace *mface, - int *polyindices, + const int *polyindices, unsigned int (*loopindices)[4], const int num_faces) { @@ -2981,7 +2981,7 @@ void BKE_mesh_loops_to_tessdata(CustomData *fdata, void BKE_mesh_tangent_loops_to_tessdata(CustomData *fdata, CustomData *ldata, MFace *mface, - int *polyindices, + const int *polyindices, unsigned int (*loopindices)[4], const int num_faces, const char *layer_name) diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c index 4ed9b31dbb5..686f58a0ceb 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.c +++ b/source/blender/blenkernel/intern/mesh_mapping.c @@ -953,7 +953,7 @@ void BKE_mesh_loop_islands_free(MeshIslandStore *island_store) void BKE_mesh_loop_islands_add(MeshIslandStore *island_store, const int item_num, - int *items_indices, + const int *items_indices, const int num_island_items, int *island_item_indices, const int num_innercut_items, diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c index 404d6a581ae..a4991675d2d 100644 --- a/source/blender/blenkernel/intern/mesh_remap.c +++ b/source/blender/blenkernel/intern/mesh_remap.c @@ -1071,7 +1071,7 @@ static void mesh_island_to_astar_graph_edge_process(MeshIslandStore *islands, BLI_bitmap *done_edges, MeshElemMap *edge_to_poly_map, const bool is_edge_innercut, - int *poly_island_index_map, + const int *poly_island_index_map, float (*poly_centers)[3], unsigned char *poly_status) { diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 7e78be6d66e..71d49dd1c19 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -175,7 +175,7 @@ static BLI_bitmap *multires_mdisps_upsample_hidden(BLI_bitmap *lo_hidden, return subd; } -static BLI_bitmap *multires_mdisps_downsample_hidden(BLI_bitmap *old_hidden, +static BLI_bitmap *multires_mdisps_downsample_hidden(const BLI_bitmap *old_hidden, int old_level, int new_level) { diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c b/source/blender/blenkernel/intern/multires_unsubdivide.c index 6bd7b6b6a98..fa1a53f946e 100644 --- a/source/blender/blenkernel/intern/multires_unsubdivide.c +++ b/source/blender/blenkernel/intern/multires_unsubdivide.c @@ -80,7 +80,7 @@ /** * Used to check if a vertex is in a disconnected element ID. */ -static bool is_vertex_in_id(BMVert *v, int *elem_id, int elem) +static bool is_vertex_in_id(BMVert *v, const int *elem_id, int elem) { const int v_index = BM_elem_index_get(v); return elem_id[v_index] == elem; diff --git a/source/blender/blenkernel/intern/node_tree_multi_function.cc b/source/blender/blenkernel/intern/node_tree_multi_function.cc index 02437d98732..4e505db9b9d 100644 --- a/source/blender/blenkernel/intern/node_tree_multi_function.cc +++ b/source/blender/blenkernel/intern/node_tree_multi_function.cc @@ -16,6 +16,8 @@ #include "BKE_node_tree_multi_function.hh" +#include "BLI_float3.hh" + namespace blender { namespace bke { @@ -136,11 +138,72 @@ static fn::MFOutputSocket *try_find_origin(CommonMFNetworkBuilderData &common, } if (from_dsockets.size() == 1) { - return &common.network_map.lookup(*from_dsockets[0]); + if (is_multi_function_data_socket(from_dsockets[0]->bsocket())) { + return &common.network_map.lookup(*from_dsockets[0]); + } + else { + return nullptr; + } + } + else { + if (is_multi_function_data_socket(from_group_inputs[0]->bsocket())) { + return &common.network_map.lookup(*from_group_inputs[0]); + } + else { + return nullptr; + } + } +} + +static const fn::MultiFunction *try_get_conversion_function(fn::MFDataType from, fn::MFDataType to) +{ + if (from == fn::MFDataType::ForSingle<float>()) { + if (to == fn::MFDataType::ForSingle<int32_t>()) { + static fn::CustomMF_Convert<float, int32_t> function; + return &function; + } + if (to == fn::MFDataType::ForSingle<float3>()) { + static fn::CustomMF_Convert<float, float3> function; + return &function; + } + } + if (from == fn::MFDataType::ForSingle<float3>()) { + if (to == fn::MFDataType::ForSingle<float>()) { + static fn::CustomMF_SI_SO<float3, float> function{"Vector Length", + [](float3 a) { return a.length(); }}; + return &function; + } + } + if (from == fn::MFDataType::ForSingle<int32_t>()) { + if (to == fn::MFDataType::ForSingle<float>()) { + static fn::CustomMF_Convert<int32_t, float> function; + return &function; + } + if (to == fn::MFDataType::ForSingle<float3>()) { + static fn::CustomMF_SI_SO<int32_t, float3> function{ + "int32 to float3", [](int32_t a) { return float3((float)a); }}; + return &function; + } + } + + return nullptr; +} + +static fn::MFOutputSocket &insert_default_value_for_type(CommonMFNetworkBuilderData &common, + fn::MFDataType type) +{ + const fn::MultiFunction *default_fn; + if (type.is_single()) { + default_fn = &common.resources.construct<fn::CustomMF_GenericConstant>( + AT, type.single_type(), type.single_type().default_value()); } else { - return &common.network_map.lookup(*from_group_inputs[0]); + default_fn = &common.resources.construct<fn::CustomMF_GenericConstantArray>( + AT, fn::GSpan(type.vector_base_type())); } + + fn::MFNode &node = common.network.add_function(*default_fn); + return node.output(0); } static void insert_links(CommonMFNetworkBuilderData &common) @@ -149,24 +212,34 @@ static void insert_links(CommonMFNetworkBuilderData &common) if (!to_dsocket->is_available()) { continue; } - - if (!is_multi_function_data_socket(to_dsocket->bsocket())) { + if (!to_dsocket->is_linked()) { continue; } - - fn::MFOutputSocket *from_socket = try_find_origin(common, *to_dsocket); - if (from_socket == nullptr) { + if (!is_multi_function_data_socket(to_dsocket->bsocket())) { continue; } Span<fn::MFInputSocket *> to_sockets = common.network_map.lookup(*to_dsocket); BLI_assert(to_sockets.size() >= 1); + fn::MFDataType to_type = to_sockets[0]->data_type(); + + fn::MFOutputSocket *from_socket = try_find_origin(common, *to_dsocket); + if (from_socket == nullptr) { + from_socket = &insert_default_value_for_type(common, to_type); + } fn::MFDataType from_type = from_socket->data_type(); - fn::MFDataType to_type = to_sockets[0]->data_type(); if (from_type != to_type) { - /* Todo: Try inserting implicit conversion. */ + const fn::MultiFunction *conversion_fn = try_get_conversion_function(from_type, to_type); + if (conversion_fn != nullptr) { + fn::MFNode &node = common.network.add_function(*conversion_fn); + common.network.add_link(*from_socket, node.input(0)); + from_socket = &node.output(0); + } + else { + from_socket = &insert_default_value_for_type(common, to_type); + } } for (fn::MFInputSocket *to_socket : to_sockets) { diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c index 6ca1442497a..51ec89cf77d 100644 --- a/source/blender/blenkernel/intern/object_deform.c +++ b/source/blender/blenkernel/intern/object_deform.c @@ -68,7 +68,7 @@ static Lattice *object_defgroup_lattice_get(ID *id) * * \param map: an array mapping old indices to new indices. */ -void BKE_object_defgroup_remap_update_users(Object *ob, int *map) +void BKE_object_defgroup_remap_update_users(Object *ob, const int *map) { ModifierData *md; ParticleSystem *psys; diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 609c5c1e580..f94ef946851 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -147,19 +147,19 @@ static void init_complex(fftw_complex cmpl, float real, float image) cmpl[1] = image; } -static void add_comlex_c(fftw_complex res, fftw_complex cmpl1, fftw_complex cmpl2) +static void add_comlex_c(fftw_complex res, const fftw_complex cmpl1, const fftw_complex cmpl2) { res[0] = cmpl1[0] + cmpl2[0]; res[1] = cmpl1[1] + cmpl2[1]; } -static void mul_complex_f(fftw_complex res, fftw_complex cmpl, float f) +static void mul_complex_f(fftw_complex res, const fftw_complex cmpl, float f) { res[0] = cmpl[0] * (double)f; res[1] = cmpl[1] * (double)f; } -static void mul_complex_c(fftw_complex res, fftw_complex cmpl1, fftw_complex cmpl2) +static void mul_complex_c(fftw_complex res, const fftw_complex cmpl1, const fftw_complex cmpl2) { fftwf_complex temp; temp[0] = cmpl1[0] * cmpl2[0] - cmpl1[1] * cmpl2[1]; @@ -178,7 +178,7 @@ static float image_c(fftw_complex cmpl) return cmpl[1]; } -static void conj_complex(fftw_complex res, fftw_complex cmpl1) +static void conj_complex(fftw_complex res, const fftw_complex cmpl1) { res[0] = cmpl1[0]; res[1] = -cmpl1[1]; diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c index 7b9b2484dbe..e0dccd4d14a 100644 --- a/source/blender/blenkernel/intern/particle_distribute.c +++ b/source/blender/blenkernel/intern/particle_distribute.c @@ -433,7 +433,7 @@ static void psys_uv_to_w(float u, float v, int quad, float *w) } /* Find the index in "sum" array before "value" is crossed. */ -static int distribute_binary_search(float *sum, int n, float value) +static int distribute_binary_search(const float *sum, int n, float value) { int mid, low = 0, high = n - 1; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index cd821077292..bf9aea81181 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4966,6 +4966,7 @@ void particle_system_update(struct Depsgraph *depsgraph, psys_orig->flag = (psys->flag & ~PSYS_SHARED_CACHES); psys_orig->cfra = psys->cfra; psys_orig->recalc = psys->recalc; + psys_orig->part->totpart = part->totpart; } } diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 870a1f3d673..67988427bd2 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -358,7 +358,7 @@ static void update_vb(PBVH *pbvh, PBVHNode *node, BBC *prim_bbc, int offset, int /* Returns the number of visible quads in the nodes' grids. */ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden, - int *grid_indices, + const int *grid_indices, int totgrid, int gridsize) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index ce5402551b6..9a9d8dc215b 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -206,7 +206,7 @@ static int ptcache_softbody_write(int index, void *soft_v, void **data, int UNUS return 1; } static void ptcache_softbody_read( - int index, void *soft_v, void **data, float UNUSED(cfra), float *old_data) + int index, void *soft_v, void **data, float UNUSED(cfra), const float *old_data) { SoftBody *soft = soft_v; BodyPoint *bp = soft->bpoint + index; @@ -220,8 +220,13 @@ static void ptcache_softbody_read( PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, 0, bp->vec); } } -static void ptcache_softbody_interpolate( - int index, void *soft_v, void **data, float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_softbody_interpolate(int index, + void *soft_v, + void **data, + float cfra, + float cfra1, + float cfra2, + const float *old_data) { SoftBody *soft = soft_v; BodyPoint *bp = soft->bpoint + index; @@ -316,7 +321,7 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfra return 1 + (pa->state.time >= pa->time && pa->prev_state.time <= pa->time); } static void ptcache_particle_read( - int index, void *psys_v, void **data, float cfra, float *old_data) + int index, void *psys_v, void **data, float cfra, const float *old_data) { ParticleSystem *psys = psys_v; ParticleData *pa; @@ -383,8 +388,13 @@ static void ptcache_particle_read( unit_qt(pa->state.rot); } } -static void ptcache_particle_interpolate( - int index, void *psys_v, void **data, float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_particle_interpolate(int index, + void *psys_v, + void **data, + float cfra, + float cfra1, + float cfra2, + const float *old_data) { ParticleSystem *psys = psys_v; ParticleData *pa; @@ -528,7 +538,7 @@ static int ptcache_cloth_write(int index, void *cloth_v, void **data, int UNUSED return 1; } static void ptcache_cloth_read( - int index, void *cloth_v, void **data, float UNUSED(cfra), float *old_data) + int index, void *cloth_v, void **data, float UNUSED(cfra), const float *old_data) { ClothModifierData *clmd = cloth_v; Cloth *cloth = clmd->clothObject; @@ -545,8 +555,13 @@ static void ptcache_cloth_read( PTCACHE_DATA_TO(data, BPHYS_DATA_XCONST, 0, vert->xconst); } } -static void ptcache_cloth_interpolate( - int index, void *cloth_v, void **data, float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_cloth_interpolate(int index, + void *cloth_v, + void **data, + float cfra, + float cfra1, + float cfra2, + const float *old_data) { ClothModifierData *clmd = cloth_v; Cloth *cloth = clmd->clothObject; @@ -1509,7 +1524,7 @@ static int ptcache_rigidbody_write(int index, void *rb_v, void **data, int UNUSE return 1; } static void ptcache_rigidbody_read( - int index, void *rb_v, void **data, float UNUSED(cfra), float *old_data) + int index, void *rb_v, void **data, float UNUSED(cfra), const float *old_data) { RigidBodyWorld *rbw = rb_v; Object *ob = NULL; @@ -1534,8 +1549,13 @@ static void ptcache_rigidbody_read( } } } -static void ptcache_rigidbody_interpolate( - int index, void *rb_v, void **data, float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_rigidbody_interpolate(int index, + void *rb_v, + void **data, + float cfra, + float cfra1, + float cfra2, + const float *old_data) { RigidBodyWorld *rbw = rb_v; Object *ob = NULL; @@ -1887,7 +1907,7 @@ static int ptcache_sim_particle_write(int index, void *state_v, void **data, int return 1; } static void ptcache_sim_particle_read( - int index, void *state_v, void **data, float UNUSED(cfra), float *UNUSED(old_data)) + int index, void *state_v, void **data, float UNUSED(cfra), const float *UNUSED(old_data)) { ParticleSimulationState *state = (ParticleSimulationState *)state_v; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index de233a8d473..4a2ad88bb28 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2668,7 +2668,7 @@ static void RVAddBitmaps_float(float *a, float *b, float *c, int width, int heig } static void RVIsolateHighlights_float( - float *in, float *out, int width, int height, float threshold, float boost, float clamp) + const float *in, float *out, int width, int height, float threshold, float boost, float clamp) { int x, y, index; float intensity; @@ -3423,7 +3423,7 @@ static void do_gaussian_blur_effect_byte_x(Sequence *seq, int y, int frame_width, int UNUSED(frame_height), - unsigned char *rect, + const unsigned char *rect, unsigned char *out) { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) @@ -3473,7 +3473,7 @@ static void do_gaussian_blur_effect_byte_y(Sequence *seq, int y, int UNUSED(frame_width), int frame_height, - unsigned char *rect, + const unsigned char *rect, unsigned char *out) { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index 604cbf476a8..a630170d6d5 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -57,7 +57,7 @@ typedef void (*modifier_apply_threaded_cb)(int width, unsigned char *rect, float *rect_float, unsigned char *mask_rect, - float *mask_rect_float, + const float *mask_rect_float, void *data_v); typedef struct ModifierInitData { @@ -223,7 +223,7 @@ static void whiteBalance_apply_threaded(int width, unsigned char *rect, float *rect_float, unsigned char *mask_rect, - float *mask_rect_float, + const float *mask_rect_float, void *data_v) { int x, y; @@ -331,7 +331,7 @@ static void curves_apply_threaded(int width, unsigned char *rect, float *rect_float, unsigned char *mask_rect, - float *mask_rect_float, + const float *mask_rect_float, void *data_v) { CurveMapping *curve_mapping = (CurveMapping *)data_v; @@ -461,7 +461,7 @@ static void hue_correct_apply_threaded(int width, unsigned char *rect, float *rect_float, unsigned char *mask_rect, - float *mask_rect_float, + const float *mask_rect_float, void *data_v) { CurveMapping *curve_mapping = (CurveMapping *)data_v; @@ -556,7 +556,7 @@ static void brightcontrast_apply_threaded(int width, unsigned char *rect, float *rect_float, unsigned char *mask_rect, - float *mask_rect_float, + const float *mask_rect_float, void *data_v) { BrightContrastThreadData *data = (BrightContrastThreadData *)data_v; @@ -658,7 +658,7 @@ static void maskmodifier_apply_threaded(int width, unsigned char *rect, float *rect_float, unsigned char *mask_rect, - float *mask_rect_float, + const float *mask_rect_float, void *UNUSED(data_v)) { int x, y; @@ -755,7 +755,7 @@ static void tonemapmodifier_apply_threaded_simple(int width, unsigned char *rect, float *rect_float, unsigned char *mask_rect, - float *mask_rect_float, + const float *mask_rect_float, void *data_v) { AvgLogLum *avg = (AvgLogLum *)data_v; @@ -814,7 +814,7 @@ static void tonemapmodifier_apply_threaded_photoreceptor(int width, unsigned char *rect, float *rect_float, unsigned char *mask_rect, - float *mask_rect_float, + const float *mask_rect_float, void *data_v) { AvgLogLum *avg = (AvgLogLum *)data_v; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 01d2176ba30..7339c887151 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1090,6 +1090,64 @@ void BKE_sequence_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, cons BKE_sequence_calc(scene, seq); } +void BKE_sequence_movie_reload_if_needed(struct Main *bmain, + struct Scene *scene, + struct Sequence *seq, + bool *r_was_reloaded, + bool *r_can_produce_frames) +{ + BLI_assert(seq->type == SEQ_TYPE_MOVIE || + !"This function is only implemented for movie strips."); + + bool must_reload = false; + + /* The Sequence struct allows for multiple anim structs to be associated with one strip. This + * function will return true only if there is at least one 'anim' AND all anims can produce + * frames. */ + + if (BLI_listbase_is_empty(&seq->anims)) { + /* No anim present, so reloading is always necessary. */ + must_reload = true; + } + else { + LISTBASE_FOREACH (StripAnim *, sanim, &seq->anims) { + if (!IMB_anim_can_produce_frames(sanim->anim)) { + /* Anim cannot produce frames, try reloading. */ + must_reload = true; + break; + } + }; + } + + if (!must_reload) { + /* There are one or more anims, and all can produce frames. */ + *r_was_reloaded = false; + *r_can_produce_frames = true; + return; + } + + BKE_sequence_reload_new_file(bmain, scene, seq, true); + *r_was_reloaded = true; + + if (BLI_listbase_is_empty(&seq->anims)) { + /* No anims present after reloading => no frames can be produced. */ + *r_can_produce_frames = false; + return; + } + + /* Check if there are still anims that cannot produce frames. */ + LISTBASE_FOREACH (StripAnim *, sanim, &seq->anims) { + if (!IMB_anim_can_produce_frames(sanim->anim)) { + /* There still is an anim that cannot produce frames. */ + *r_can_produce_frames = false; + return; + } + }; + + /* There are one or more anims, and all can produce frames. */ + *r_can_produce_frames = true; +} + void BKE_sequencer_sort(Scene *scene) { /* all strips together per kind, and in order of y location ("machine") */ @@ -2390,7 +2448,7 @@ static void color_balance_byte_float(StripColorBalance *cb_, static void color_balance_float_float(StripColorBalance *cb_, float *rect_float, - float *mask_rect_float, + const float *mask_rect_float, int width, int height, float mul) diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc index 35ef664dce3..e163bb8da8d 100644 --- a/source/blender/blenkernel/intern/simulation.cc +++ b/source/blender/blenkernel/intern/simulation.cc @@ -176,6 +176,10 @@ static void ensure_attributes_exist(ParticleSimulationState *state) CustomData_add_layer_named( &state->attributes, CD_LOCATION, CD_CALLOC, nullptr, state->tot_particles, "Velocity"); } + if (CustomData_get_layer_named(&state->attributes, CD_PROP_INT32, "ID") == nullptr) { + CustomData_add_layer_named( + &state->attributes, CD_PROP_INT32, CD_CALLOC, nullptr, state->tot_particles, "ID"); + } } static void copy_states_to_cow(Simulation *simulation_orig, Simulation *simulation_cow) @@ -211,11 +215,8 @@ static void copy_states_to_cow(Simulation *simulation_orig, Simulation *simulati } } -using AttributeNodeMap = Map<fn::MFDummyNode *, std::pair<std::string, fn::MFDataType>>; - -static AttributeNodeMap deduplicate_attribute_nodes(fn::MFNetwork &network, - MFNetworkTreeMap &network_map, - const DerivedNodeTree &tree) +static Map<const fn::MFOutputSocket *, std::string> deduplicate_attribute_nodes( + fn::MFNetwork &network, MFNetworkTreeMap &network_map, const DerivedNodeTree &tree) { Span<const DNode *> attribute_dnodes = tree.nodes_by_type("SimulationNodeParticleAttribute"); uint amount = attribute_dnodes.size(); @@ -247,11 +248,11 @@ static AttributeNodeMap deduplicate_attribute_nodes(fn::MFNetwork &network, attribute_nodes_by_name_and_type; for (uint i : IndexRange(amount)) { attribute_nodes_by_name_and_type - .lookup_or_add_default({attribute_names[i], name_sockets[i]->data_type()}) + .lookup_or_add_default({attribute_names[i], name_sockets[i]->node().output(0).data_type()}) .append(&name_sockets[i]->node()); } - AttributeNodeMap final_attribute_nodes; + Map<const fn::MFOutputSocket *, std::string> attribute_inputs; for (auto item : attribute_nodes_by_name_and_type.items()) { StringRef attribute_name = item.key.first; fn::MFDataType data_type = item.key.second; @@ -264,10 +265,10 @@ static AttributeNodeMap deduplicate_attribute_nodes(fn::MFNetwork &network, } network.remove(nodes); - final_attribute_nodes.add_new(&new_attribute_socket.node().as_dummy(), item.key); + attribute_inputs.add_new(&new_attribute_socket, attribute_name); } - return final_attribute_nodes; + return attribute_inputs; } class CustomDataAttributesRef { @@ -282,7 +283,16 @@ class CustomDataAttributesRef { fn::AttributesInfoBuilder builder; for (const CustomDataLayer &layer : Span(custom_data.layers, custom_data.totlayer)) { buffers_.append(layer.data); - builder.add<float3>(layer.name, {0, 0, 0}); + switch (layer.type) { + case CD_PROP_INT32: { + builder.add<int32_t>(layer.name, 0); + break; + } + case CD_LOCATION: { + builder.add<float3>(layer.name, {0, 0, 0}); + break; + } + } } info_ = std::make_unique<fn::AttributesInfo>(builder); size_ = size; @@ -386,6 +396,322 @@ static void update_simulation_state_list(Simulation *simulation, const DerivedNo add_missing_particle_states(simulation, state_names); } +class ParticleFunctionInput { + public: + virtual ~ParticleFunctionInput() = default; + virtual void add_input(fn::AttributesRef attributes, + fn::MFParamsBuilder ¶ms, + ResourceCollector &resources) const = 0; +}; + +class ParticleFunction { + private: + const fn::MultiFunction *global_fn_; + const fn::MultiFunction *per_particle_fn_; + Array<const ParticleFunctionInput *> global_inputs_; + Array<const ParticleFunctionInput *> per_particle_inputs_; + Array<bool> output_is_global_; + Vector<uint> global_output_indices_; + Vector<uint> per_particle_output_indices_; + Vector<fn::MFDataType> output_types_; + Vector<StringRefNull> output_names_; + + friend class ParticleFunctionEvaluator; + + public: + ParticleFunction(const fn::MultiFunction *global_fn, + const fn::MultiFunction *per_particle_fn, + Span<const ParticleFunctionInput *> global_inputs, + Span<const ParticleFunctionInput *> per_particle_inputs, + Span<bool> output_is_global) + : global_fn_(global_fn), + per_particle_fn_(per_particle_fn), + global_inputs_(global_inputs), + per_particle_inputs_(per_particle_inputs), + output_is_global_(output_is_global) + { + for (uint i : output_is_global_.index_range()) { + if (output_is_global_[i]) { + uint param_index = global_inputs_.size() + global_output_indices_.size(); + fn::MFParamType param_type = global_fn_->param_type(param_index); + BLI_assert(param_type.is_output()); + output_types_.append(param_type.data_type()); + output_names_.append(global_fn_->param_name(param_index)); + global_output_indices_.append(i); + } + else { + uint param_index = per_particle_inputs_.size() + per_particle_output_indices_.size(); + fn::MFParamType param_type = per_particle_fn_->param_type(param_index); + BLI_assert(param_type.is_output()); + output_types_.append(param_type.data_type()); + output_names_.append(per_particle_fn_->param_name(param_index)); + per_particle_output_indices_.append(i); + } + } + } +}; + +class ParticleFunctionEvaluator { + private: + ResourceCollector resources_; + const ParticleFunction &particle_fn_; + IndexMask mask_; + fn::MFContextBuilder global_context_; + fn::MFContextBuilder per_particle_context_; + fn::AttributesRef particle_attributes_; + Vector<void *> outputs_; + bool is_computed_ = false; + + public: + ParticleFunctionEvaluator(const ParticleFunction &particle_fn, + IndexMask mask, + fn::AttributesRef particle_attributes) + : particle_fn_(particle_fn), + mask_(mask), + particle_attributes_(particle_attributes), + outputs_(particle_fn_.output_types_.size(), nullptr) + { + } + + ~ParticleFunctionEvaluator() + { + for (uint output_index : outputs_.index_range()) { + void *buffer = outputs_[output_index]; + fn::MFDataType data_type = particle_fn_.output_types_[output_index]; + BLI_assert(data_type.is_single()); /* For now. */ + const fn::CPPType &type = data_type.single_type(); + + if (particle_fn_.output_is_global_[output_index]) { + type.destruct(buffer); + } + else { + type.destruct_indices(outputs_[0], mask_); + } + } + } + + void compute() + { + BLI_assert(!is_computed_); + this->compute_globals(); + this->compute_per_particle(); + is_computed_ = true; + } + + template<typename T> fn::VSpan<T> get(uint output_index, StringRef expected_name) const + { + return this->get(output_index, expected_name).typed<T>(); + } + + fn::GVSpan get(uint output_index, StringRef expected_name) const + { +#ifdef DEBUG + StringRef real_name = particle_fn_.output_names_[output_index]; + BLI_assert(expected_name == real_name); + BLI_assert(is_computed_); +#endif + UNUSED_VARS_NDEBUG(expected_name); + const void *buffer = outputs_[output_index]; + const fn::CPPType &type = particle_fn_.output_types_[output_index].single_type(); + if (particle_fn_.output_is_global_[output_index]) { + return fn::GVSpan::FromSingleWithMaxSize(type, buffer); + } + else { + return fn::GVSpan(fn::GSpan(type, buffer, mask_.min_array_size())); + } + } + + private: + void compute_globals() + { + if (particle_fn_.global_fn_ == nullptr) { + return; + } + + fn::MFParamsBuilder params(*particle_fn_.global_fn_, mask_.min_array_size()); + + /* Add input parameters. */ + for (const ParticleFunctionInput *input : particle_fn_.global_inputs_) { + input->add_input(particle_attributes_, params, resources_); + } + + /* Add output parameters. */ + for (uint output_index : particle_fn_.global_output_indices_) { + fn::MFDataType data_type = particle_fn_.output_types_[output_index]; + BLI_assert(data_type.is_single()); /* For now. */ + + const fn::CPPType &type = data_type.single_type(); + void *buffer = resources_.linear_allocator().allocate(type.size(), type.alignment()); + params.add_uninitialized_single_output(fn::GMutableSpan(type, buffer, 1)); + outputs_[output_index] = buffer; + } + + particle_fn_.global_fn_->call({0}, params, global_context_); + } + + void compute_per_particle() + { + if (particle_fn_.per_particle_fn_ == nullptr) { + return; + } + + fn::MFParamsBuilder params(*particle_fn_.per_particle_fn_, mask_.min_array_size()); + + /* Add input parameters. */ + for (const ParticleFunctionInput *input : particle_fn_.per_particle_inputs_) { + input->add_input(particle_attributes_, params, resources_); + } + + /* Add output parameters. */ + for (uint output_index : particle_fn_.per_particle_output_indices_) { + fn::MFDataType data_type = particle_fn_.output_types_[output_index]; + BLI_assert(data_type.is_single()); /* For now. */ + + const fn::CPPType &type = data_type.single_type(); + void *buffer = resources_.linear_allocator().allocate(type.size() * mask_.min_array_size(), + type.alignment()); + params.add_uninitialized_single_output( + fn::GMutableSpan(type, buffer, mask_.min_array_size())); + outputs_[output_index] = buffer; + } + + particle_fn_.per_particle_fn_->call(mask_, params, global_context_); + } +}; + +class ParticleAttributeInput : public ParticleFunctionInput { + private: + std::string attribute_name_; + const fn::CPPType &attribute_type_; + + public: + ParticleAttributeInput(std::string attribute_name, const fn::CPPType &attribute_type) + : attribute_name_(std::move(attribute_name)), attribute_type_(attribute_type) + { + } + + void add_input(fn::AttributesRef attributes, + fn::MFParamsBuilder ¶ms, + ResourceCollector &UNUSED(resources)) const override + { + std::optional<fn::GSpan> span = attributes.try_get(attribute_name_, attribute_type_); + if (span.has_value()) { + params.add_readonly_single_input(*span); + } + else { + params.add_readonly_single_input(fn::GVSpan::FromDefault(attribute_type_)); + } + } +}; + +static const ParticleFunction *create_particle_function_for_inputs( + Span<const fn::MFInputSocket *> sockets_to_compute, + ResourceCollector &resources, + const Map<const fn::MFOutputSocket *, std::string> &attribute_inputs) +{ + BLI_assert(sockets_to_compute.size() >= 1); + const fn::MFNetwork &network = sockets_to_compute[0]->node().network(); + + VectorSet<const fn::MFOutputSocket *> dummy_deps; + VectorSet<const fn::MFInputSocket *> unlinked_input_deps; + network.find_dependencies(sockets_to_compute, dummy_deps, unlinked_input_deps); + BLI_assert(unlinked_input_deps.size() == 0); + + Vector<const ParticleFunctionInput *> per_particle_inputs; + for (const fn::MFOutputSocket *socket : dummy_deps) { + StringRef attribute_name = attribute_inputs.lookup(socket); + per_particle_inputs.append(&resources.construct<ParticleAttributeInput>( + AT, attribute_name, socket->data_type().single_type())); + } + + const fn::MultiFunction &per_particle_fn = resources.construct<fn::MFNetworkEvaluator>( + AT, dummy_deps.as_span(), sockets_to_compute); + + Array<bool> output_is_global(sockets_to_compute.size(), false); + + const ParticleFunction &particle_fn = resources.construct<ParticleFunction>( + AT, + nullptr, + &per_particle_fn, + Span<const ParticleFunctionInput *>(), + per_particle_inputs.as_span(), + output_is_global.as_span()); + + return &particle_fn; +} + +class ParticleForce { + public: + virtual ~ParticleForce() = default; + virtual void add_force(fn::AttributesRef attributes, + MutableSpan<float3> r_combined_force) const = 0; +}; + +class ParticleFunctionForce : public ParticleForce { + private: + const ParticleFunction &particle_fn_; + + public: + ParticleFunctionForce(const ParticleFunction &particle_fn) : particle_fn_(particle_fn) + { + } + + void add_force(fn::AttributesRef attributes, MutableSpan<float3> r_combined_force) const override + { + IndexMask mask = IndexRange(attributes.size()); + ParticleFunctionEvaluator evaluator{particle_fn_, mask, attributes}; + evaluator.compute(); + fn::VSpan<float3> forces = evaluator.get<float3>(0, "Force"); + for (uint i : mask) { + r_combined_force[i] += forces[i]; + } + } +}; + +static Vector<const ParticleForce *> create_forces_for_particle_simulation( + const DNode &simulation_node, + MFNetworkTreeMap &network_map, + ResourceCollector &resources, + const Map<const fn::MFOutputSocket *, std::string> &attribute_inputs) +{ + Vector<const ParticleForce *> forces; + for (const DOutputSocket *origin_socket : simulation_node.input(2, "Forces").linked_sockets()) { + const DNode &origin_node = origin_socket->node(); + if (origin_node.idname() != "SimulationNodeForce") { + continue; + } + + const fn::MFInputSocket &force_socket = network_map.lookup_dummy( + origin_node.input(0, "Force")); + + const ParticleFunction *particle_fn = create_particle_function_for_inputs( + {&force_socket}, resources, attribute_inputs); + + if (particle_fn == nullptr) { + continue; + } + + const ParticleForce &force = resources.construct<ParticleFunctionForce>(AT, *particle_fn); + forces.append(&force); + } + return forces; +} + +static Map<std::string, Vector<const ParticleForce *>> collect_forces( + MFNetworkTreeMap &network_map, + ResourceCollector &resources, + const Map<const fn::MFOutputSocket *, std::string> &attribute_inputs) +{ + Map<std::string, Vector<const ParticleForce *>> forces_by_simulation; + for (const DNode *dnode : network_map.tree().nodes_by_type("SimulationNodeParticleSimulation")) { + std::string name = dnode_to_path(*dnode); + Vector<const ParticleForce *> forces = create_forces_for_particle_simulation( + *dnode, network_map, resources, attribute_inputs); + forces_by_simulation.add_new(std::move(name), std::move(forces)); + } + return forces_by_simulation; +} + static void simulation_data_update(Depsgraph *depsgraph, Scene *scene, Simulation *simulation_cow) { int current_frame = scene->r.cfra; @@ -406,12 +732,15 @@ static void simulation_data_update(Depsgraph *depsgraph, Scene *scene, Simulatio fn::MFNetwork network; ResourceCollector resources; MFNetworkTreeMap network_map = insert_node_tree_into_mf_network(network, tree, resources); - AttributeNodeMap attribute_node_map = deduplicate_attribute_nodes(network, network_map, tree); + // WM_clipboard_text_set(tree.to_dot().c_str(), false); + Map<const fn::MFOutputSocket *, std::string> attribute_inputs = deduplicate_attribute_nodes( + network, network_map, tree); fn::mf_network_optimization::constant_folding(network, resources); fn::mf_network_optimization::common_subnetwork_elimination(network); fn::mf_network_optimization::dead_node_removal(network); - UNUSED_VARS(attribute_node_map); - // WM_clipboard_text_set(network.to_dot().c_str(), false); + + Map<std::string, Vector<const ParticleForce *>> forces_by_simulation = collect_forces( + network_map, resources, attribute_inputs); if (current_frame == 1) { reinitialize_empty_simulation_states(simulation_orig, tree); @@ -420,7 +749,7 @@ static void simulation_data_update(Depsgraph *depsgraph, Scene *scene, Simulatio simulation_orig->current_frame = 1; LISTBASE_FOREACH (ParticleSimulationState *, state, &simulation_orig->states) { - state->tot_particles = 100; + state->tot_particles = 1000; CustomData_realloc(&state->attributes, state->tot_particles); ensure_attributes_exist(state); @@ -430,10 +759,12 @@ static void simulation_data_update(Depsgraph *depsgraph, Scene *scene, Simulatio fn::MutableAttributesRef attributes = custom_data_attributes; MutableSpan<float3> positions = attributes.get<float3>("Position"); MutableSpan<float3> velocities = attributes.get<float3>("Velocity"); + MutableSpan<int32_t> ids = attributes.get<int32_t>("ID"); for (uint i : positions.index_range()) { - positions[i] = {i / 10.0f, 0, 0}; + positions[i] = {i / 100.0f, 0, 0}; velocities[i] = {0, BLI_rng_get_float(rng), BLI_rng_get_float(rng) * 2 + 1}; + ids[i] = i; } } @@ -456,8 +787,14 @@ static void simulation_data_update(Depsgraph *depsgraph, Scene *scene, Simulatio MutableSpan<float3> positions = attributes.get<float3>("Position"); MutableSpan<float3> velocities = attributes.get<float3>("Velocity"); + Array<float3> force_vectors{(uint)state->tot_particles, {0, 0, 0}}; + Span<const ParticleForce *> forces = forces_by_simulation.lookup_as(state->head.name); + for (const ParticleForce *force : forces) { + force->add_force(attributes, force_vectors); + } + for (uint i : positions.index_range()) { - velocities[i].z += -1.0f * time_step; + velocities[i] += force_vectors[i] * time_step; positions[i] += velocities[i] * time_step; } } diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index e155dedeef0..0809e8dda6d 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -507,9 +507,7 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, /* Might not be final place for this to be called - probably only want to call it from some * undo handlers, not all of them? */ - if (BKE_lib_override_library_is_enabled()) { - BKE_lib_override_library_main_operations_create(G_MAIN, false); - } + BKE_lib_override_library_main_operations_create(G_MAIN, false); /* Remove all undos after (also when 'ustack->step_active == NULL'). */ while (ustack->steps.last != ustack->step_active) { diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh index c7a9c49c972..c411fc50f15 100644 --- a/source/blender/blenlib/BLI_array.hh +++ b/source/blender/blenlib/BLI_array.hh @@ -105,6 +105,10 @@ class Array { { } + Array(const std::initializer_list<T> &values) : Array(Span<T>(values)) + { + } + /** * Create a new array with the given size. All values will be default constructed. For trivial * types like int, default construction does nothing. diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h index 6dd1abacf78..4ebef814337 100644 --- a/source/blender/blenlib/BLI_blenlib.h +++ b/source/blender/blenlib/BLI_blenlib.h @@ -28,7 +28,7 @@ * a call to a BLI function that is not prototyped here, please add a * prototype here. The library offers mathematical operations (mainly * vector and matrix calculus), an abstraction layer for file i/o, - * functions for calculating Perlin noise, scanfilling services for + * functions for calculating Perlin noise, scan-filling services for * triangles, and a system for guarded memory * allocation/deallocation. There is also a patch to make MS Windows * behave more or less Posix-compliant. diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index ba95da4092e..48f8e7d31d9 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -148,8 +148,12 @@ void blackbody_temperature_to_rgb_table(float *r_table, int width, float min, fl /********* lift/gamma/gain / ASC-CDL conversion ***********/ -void lift_gamma_gain_to_asc_cdl( - float *lift, float *gamma, float *gain, float *offset, float *slope, float *power); +void lift_gamma_gain_to_asc_cdl(const float *lift, + const float *gamma, + const float *gain, + float *offset, + float *slope, + float *power); #if BLI_MATH_DO_INLINE # include "intern/math_color_inline.c" diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 2d11797bc34..33fcd750aee 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -64,7 +64,7 @@ void swap_m3m3(float A[3][3], float B[3][3]); void swap_m4m4(float A[4][4], float B[4][4]); /* Build index shuffle matrix */ -void shuffle_m4(float R[4][4], int index[4]); +void shuffle_m4(float R[4][4], const int index[4]); /******************************** Arithmetic *********************************/ diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh index 133615f0f31..b73e0e95312 100644 --- a/source/blender/blenlib/BLI_memory_utils.hh +++ b/source/blender/blenlib/BLI_memory_utils.hh @@ -194,10 +194,6 @@ template<typename T> void initialized_move_n(T *src, uint n, T *dst) */ template<typename T> void uninitialized_move_n(T *src, uint n, T *dst) { - static_assert(std::is_nothrow_move_constructible_v<T>, - "Ideally, all types should have this property. We might have to remove this " - "limitation of a real reason comes up."); - uint current = 0; try { for (; current < n; current++) { diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h index ae78ea3af16..c55bbd26db5 100644 --- a/source/blender/blenlib/BLI_rand.h +++ b/source/blender/blenlib/BLI_rand.h @@ -105,12 +105,12 @@ int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) ATTR_WARN_UNUSED_R /** Return the _n_th number of the given low-discrepancy sequence. */ void BLI_halton_1d(unsigned int prime, double offset, int n, double *r); -void BLI_halton_2d(unsigned int prime[2], double offset[2], int n, double *r); -void BLI_halton_3d(unsigned int prime[3], double offset[3], int n, double *r); +void BLI_halton_2d(const unsigned int prime[2], double offset[2], int n, double *r); +void BLI_halton_3d(const unsigned int prime[3], double offset[3], int n, double *r); void BLI_hammersley_1d(unsigned int n, double *r); /** Return the whole low-discrepancy sequence up to _n_. */ -void BLI_halton_2d_sequence(unsigned int prime[2], double offset[2], int n, double *r); +void BLI_halton_2d_sequence(const unsigned int prime[2], double offset[2], int n, double *r); void BLI_hammersley_2d_sequence(unsigned int n, double *r); #ifdef __cplusplus diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh index 5c841787520..57ef9ce9eb6 100644 --- a/source/blender/blenlib/BLI_span.hh +++ b/source/blender/blenlib/BLI_span.hh @@ -440,21 +440,6 @@ template<typename T> class MutableSpan { { } - /** - * Reference an initializer_list. Note that the data in the initializer_list is only valid until - * the expression containing it is fully computed. - * - * Do: - * call_function_with_array({1, 2, 3, 4}); - * - * Don't: - * MutableSpan<int> span = {1, 2, 3, 4}; - * call_function_with_array(span); - */ - MutableSpan(std::initializer_list<T> &list) : MutableSpan(list.begin(), list.size()) - { - } - MutableSpan(std::vector<T> &vector) : MutableSpan(vector.data(), vector.size()) { } diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh index df885588d9b..1fe38464ad0 100644 --- a/source/blender/blenlib/BLI_vector.hh +++ b/source/blender/blenlib/BLI_vector.hh @@ -167,6 +167,10 @@ class Vector { { } + Vector(const std::initializer_list<T> &values) : Vector(Span<T>(values)) + { + } + template<typename U, size_t N, typename std::enable_if_t<std::is_convertible_v<U, T>> * = nullptr> diff --git a/source/blender/blenlib/BLI_voxel.h b/source/blender/blenlib/BLI_voxel.h index 220ab9b3705..82854c57928 100644 --- a/source/blender/blenlib/BLI_voxel.h +++ b/source/blender/blenlib/BLI_voxel.h @@ -35,10 +35,13 @@ extern "C" { (int64_t)(z) * (int64_t)(res)[0] * (int64_t)(res)[1]) /* all input coordinates must be in bounding box 0.0 - 1.0 */ -float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]); -float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3]); -float BLI_voxel_sample_triquadratic(float *data, const int res[3], const float co[3]); -float BLI_voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline); +float BLI_voxel_sample_nearest(const float *data, const int res[3], const float co[3]); +float BLI_voxel_sample_trilinear(const float *data, const int res[3], const float co[3]); +float BLI_voxel_sample_triquadratic(const float *data, const int res[3], const float co[3]); +float BLI_voxel_sample_tricubic(const float *data, + const int res[3], + const float co[3], + int bspline); #ifdef __cplusplus } diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index e9946d81f75..a3f93ccc753 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -1441,13 +1441,13 @@ int *BLI_bvhtree_intersect_plane(BVHTree *tree, float plane[4], uint *r_intersec int *intersect = NULL; size_t total = 0; - BVHNode *root = tree->nodes[tree->totleaf]; - if (root != NULL) { + if (tree->totleaf) { BVHIntersectPlaneData data; data.tree = tree; copy_v4_v4(data.plane, plane); data.intersect = BLI_stack_new(sizeof(int), __func__); + BVHNode *root = tree->nodes[tree->totleaf]; bvhtree_intersect_plane_dfs_recursive(&data, root); total = BLI_stack_count(data.intersect); diff --git a/source/blender/blenlib/intern/delaunay_2d.c b/source/blender/blenlib/intern/delaunay_2d.c index ad6d824be9b..5f663dcb2e1 100644 --- a/source/blender/blenlib/intern/delaunay_2d.c +++ b/source/blender/blenlib/intern/delaunay_2d.c @@ -4320,7 +4320,7 @@ static void exactinit(void) */ static int fast_expansion_sum_zeroelim( - int elen, double *e, int flen, double *f, double *h) /* h cannot be e or f. */ + int elen, const double *e, int flen, const double *f, double *h) /* h cannot be e or f. */ { double Q; INEXACT double Qnew; @@ -4405,7 +4405,7 @@ static int fast_expansion_sum_zeroelim( */ static int scale_expansion_zeroelim(int elen, - double *e, + const double *e, double b, double *h) /* e and h cannot be the same. */ { @@ -4451,7 +4451,7 @@ static int scale_expansion_zeroelim(int elen, * See either version of my paper for details. */ -static double estimate(int elen, double *e) +static double estimate(int elen, const double *e) { double Q; int eindex; diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 625849c01df..651a062e3d5 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -503,8 +503,12 @@ int constrain_rgb(float *r, float *g, float *b) /* ********************** lift/gamma/gain / ASC-CDL conversion ********************************* */ -void lift_gamma_gain_to_asc_cdl( - float *lift, float *gamma, float *gain, float *offset, float *slope, float *power) +void lift_gamma_gain_to_asc_cdl(const float *lift, + const float *gamma, + const float *gain, + float *offset, + float *slope, + float *power) { int c; for (c = 0; c < 3; c++) { diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 92cfd09f191..fadd7d83444 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -248,7 +248,7 @@ void swap_m4m4(float m1[4][4], float m2[4][4]) } } -void shuffle_m4(float R[4][4], int index[4]) +void shuffle_m4(float R[4][4], const int index[4]) { zero_m4(R); for (int k = 0; k < 4; k++) { diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 42b5ba28f5a..1ae1c91a3bd 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -27,7 +27,7 @@ #include "BLI_noise.h" /* local */ -static float noise3_perlin(float vec[3]); +static float noise3_perlin(const float vec[3]); // static float turbulence_perlin(const float point[3], float lofreq, float hifreq); // static float turbulencep(float noisesize, float x, float y, float z, int nr); @@ -779,7 +779,7 @@ static const float g_perlin_data_v3[512 + 2][3] = { } \ (void)0 -static float noise3_perlin(float vec[3]) +static float noise3_perlin(const float vec[3]) { const char *p = g_perlin_data_ub; const float(*g)[3] = g_perlin_data_v3; diff --git a/source/blender/blenlib/intern/rand.cc b/source/blender/blenlib/intern/rand.cc index 3dbe33764a9..279682ea171 100644 --- a/source/blender/blenlib/intern/rand.cc +++ b/source/blender/blenlib/intern/rand.cc @@ -302,7 +302,7 @@ void BLI_halton_1d(unsigned int prime, double offset, int n, double *r) } } -void BLI_halton_2d(unsigned int prime[2], double offset[2], int n, double *r) +void BLI_halton_2d(const unsigned int prime[2], double offset[2], int n, double *r) { const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]}; @@ -315,7 +315,7 @@ void BLI_halton_2d(unsigned int prime[2], double offset[2], int n, double *r) } } -void BLI_halton_3d(unsigned int prime[3], double offset[3], int n, double *r) +void BLI_halton_3d(const unsigned int prime[3], double offset[3], int n, double *r) { const double invprimes[3] = { 1.0 / (double)prime[0], 1.0 / (double)prime[1], 1.0 / (double)prime[2]}; @@ -329,7 +329,7 @@ void BLI_halton_3d(unsigned int prime[3], double offset[3], int n, double *r) } } -void BLI_halton_2d_sequence(unsigned int prime[2], double offset[2], int n, double *r) +void BLI_halton_2d_sequence(const unsigned int prime[2], double offset[2], int n, double *r) { const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]}; diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 96a7445462d..d3191148c90 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -53,9 +53,9 @@ # include "BLI_string_utf8.h" # include "BLI_winstuff.h" # include "utfconv.h" +# include <ShObjIdl.h> # include <direct.h> # include <io.h> -# include <shobjidl_core.h> # include <stdbool.h> #else # include <pwd.h> @@ -290,7 +290,11 @@ eFileAttributes BLI_file_attributes(const char *path) /* Return alias/shortcut file target. Apple version is defined in storage_apple.mm */ #ifndef __APPLE__ -bool BLI_file_alias_target(char target[FILE_MAXDIR], const char *filepath) +bool BLI_file_alias_target( + /* This parameter can only be const on non-windows platforms. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + char target[FILE_MAXDIR], + const char *filepath) { # ifdef WIN32 if (!BLI_path_extension_check(filepath, ".lnk")) { diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c index 53db49aa59c..20edbb97561 100644 --- a/source/blender/blenlib/intern/system.c +++ b/source/blender/blenlib/intern/system.c @@ -111,7 +111,11 @@ void BLI_system_backtrace(FILE *fp) /* NOTE: The code for CPU brand string is adopted from Cycles. */ #if !defined(_WIN32) || defined(FREE_WINDOWS) -static void __cpuid(int data[4], int selector) +static void __cpuid( + /* Cannot be const, because it is modified below. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + int data[4], + int selector) { # if defined(__x86_64__) asm("cpuid" : "=a"(data[0]), "=b"(data[1]), "=c"(data[2]), "=d"(data[3]) : "a"(selector)); diff --git a/source/blender/blenlib/intern/voronoi_2d.c b/source/blender/blenlib/intern/voronoi_2d.c index 59270c58341..bc11a2c7a1c 100644 --- a/source/blender/blenlib/intern/voronoi_2d.c +++ b/source/blender/blenlib/intern/voronoi_2d.c @@ -213,7 +213,7 @@ static void voronoiParabola_setRight(VoronoiParabola *parabola, VoronoiParabola right->parent = parabola; } -static float voronoi_getY(VoronoiProcess *process, float p[2], float x) +static float voronoi_getY(VoronoiProcess *process, const float p[2], float x) { float ly = process->current_y; diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index c7c794957c2..2c8eb9f5a13 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -26,7 +26,7 @@ #include "BLI_strict_flags.h" -BLI_INLINE float D(float *data, const int res[3], int x, int y, int z) +BLI_INLINE float D(const float *data, const int res[3], int x, int y, int z) { CLAMP(x, 0, res[0] - 1); CLAMP(y, 0, res[1] - 1); @@ -36,7 +36,7 @@ BLI_INLINE float D(float *data, const int res[3], int x, int y, int z) /* *** nearest neighbor *** */ /* input coordinates must be in bounding box 0.0 - 1.0 */ -float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]) +float BLI_voxel_sample_nearest(const float *data, const int res[3], const float co[3]) { int xi, yi, zi; @@ -65,7 +65,7 @@ BLI_INLINE int64_t _clamp(int a, int b, int c) return (a < b) ? b : ((a > c) ? c : a); } -float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3]) +float BLI_voxel_sample_trilinear(const float *data, const int res[3], const float co[3]) { if (data) { @@ -106,7 +106,7 @@ float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3 return 0.f; } -float BLI_voxel_sample_triquadratic(float *data, const int res[3], const float co[3]) +float BLI_voxel_sample_triquadratic(const float *data, const int res[3], const float co[3]) { if (data) { @@ -161,7 +161,10 @@ float BLI_voxel_sample_triquadratic(float *data, const int res[3], const float c return 0.f; } -float BLI_voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline) +float BLI_voxel_sample_tricubic(const float *data, + const int res[3], + const float co[3], + int bspline) { if (data) { diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 09e2f4bf417..7eab0651d97 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -63,8 +63,8 @@ set(SRC BLO_blend_defs.h BLO_blend_validate.h - BLO_readfile.h BLO_read_write.h + BLO_readfile.h BLO_undofile.h BLO_writefile.h intern/readfile.h diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 0d16b58d28f..ba92e11cc2a 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -21,6 +21,7 @@ #define DNA_DEPRECATED_ALLOW #include "BLI_listbase.h" +#include "BLI_math.h" #include "BLI_utildefines.h" #include "DNA_brush_types.h" @@ -36,6 +37,7 @@ #include "BKE_colortools.h" #include "BKE_lib_id.h" #include "BKE_main.h" +#include "BKE_node.h" #include "BLO_readfile.h" #include "readfile.h" @@ -255,6 +257,28 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + /* Initialize parameters of the new Nishita sky model. */ + if (!DNA_struct_elem_find(fd->filesdna, "NodeTexSky", "float", "sun_size")) { + FOREACH_NODETREE_BEGIN (bmain, ntree, id) { + if (ntree->type == NTREE_SHADER) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == SH_NODE_TEX_SKY && node->storage) { + NodeTexSky *tex = (NodeTexSky *)node->storage; + tex->sun_disc = true; + tex->sun_size = DEG2RADF(0.545); + tex->sun_elevation = M_PI_2; + tex->sun_rotation = 0.0f; + tex->altitude = 0.0f; + tex->air_density = 1.0f; + tex->dust_density = 1.0f; + tex->ozone_density = 1.0f; + } + } + } + } + FOREACH_NODETREE_END; + } } if (!MAIN_VERSION_ATLEAST(bmain, 290, 6)) { @@ -365,5 +389,21 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) */ { /* Keep this block, even when empty. */ + + /* Initialize additional parameter of the Nishita sky model and change altitude unit. */ + if (!DNA_struct_elem_find(fd->filesdna, "NodeTexSky", "float", "sun_intensity")) { + FOREACH_NODETREE_BEGIN (bmain, ntree, id) { + if (ntree->type == NTREE_SHADER) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == SH_NODE_TEX_SKY && node->storage) { + NodeTexSky *tex = (NodeTexSky *)node->storage; + tex->sun_intensity = 1.0f; + tex->altitude *= 0.001f; + } + } + } + } + FOREACH_NODETREE_END; + } } } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 1217b69f1b5..7f75c0100b8 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -315,7 +315,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) copy_v2_fl2(scene->safe_areas.title, 0.1f, 0.05f); copy_v2_fl2(scene->safe_areas.action, 0.035f, 0.035f); - /* Change default cubemap quality. */ + /* Change default cube-map quality. */ scene->eevee.gi_filter_quality = 3.0f; /* Enable Soft Shadows by default. */ diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index 43d12e8eeed..0943b4a9c2a 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -117,9 +117,9 @@ set(SRC intern/bmesh_private.h intern/bmesh_query.c intern/bmesh_query.h + intern/bmesh_query_inline.h intern/bmesh_query_uv.c intern/bmesh_query_uv.h - intern/bmesh_query_inline.h intern/bmesh_structure.c intern/bmesh_structure.h intern/bmesh_structure_inline.h diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 3c63f4a60d6..eee31969971 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -572,6 +572,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) f = BM_face_create_verts(bm, f_verts, 4, NULL, BM_CREATE_NOP, true); #endif + bm_extrude_copy_face_loop_attributes(bm, f); if (join_face) { BMVert *v1 = e->v1; BMVert *v2 = e->v2; @@ -583,11 +584,11 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, v2, EXT_TAG); dissolve_verts[dissolve_verts_len++] = v2; } + /* Tag the edges that can collapse. */ + BMO_elem_flag_enable(bm, f_edges[0], EXT_TAG); + BMO_elem_flag_enable(bm, f_edges[1], EXT_TAG); bmesh_kernel_join_face_kill_edge(bm, join_face, f, e); } - else { - bm_extrude_copy_face_loop_attributes(bm, f); - } } /* link isolated vert */ @@ -613,7 +614,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) BMEdge *e_other = BM_DISK_EDGE_NEXT(e, v); if ((e_other == e) || (BM_DISK_EDGE_NEXT(e_other, v) == e)) { /* Lose edge or BMVert is edge pair. */ - BM_edge_collapse(bm, e, v, true, false); + BM_edge_collapse(bm, BMO_elem_flag_test(bm, e, EXT_TAG) ? e : e_other, v, true, false); } else { BLI_assert(!BM_vert_is_edge_pair(v)); diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index b109dc3199a..626d58f75f8 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -1353,8 +1353,9 @@ static void offset_meet(EdgeHalf *e1, /** * Calculate the meeting point between e1 and e2 (one of which should have zero offsets), - * where e1 precedes e2 in CCW order around their common vertex v (viewed from normal side). - * If r_angle is provided, return the angle between e and emeet in *r_angle. + * where \a e1 precedes \a e2 in CCW order around their common vertex \a v + * (viewed from normal side). + * If \a r_angle is provided, return the angle between \a e and \a meetco in `*r_angle`. * If the angle is 0, or it is 180 degrees or larger, there will be no meeting point; * return false in that case, else true. */ diff --git a/source/blender/bmesh/tools/bmesh_region_match.c b/source/blender/bmesh/tools/bmesh_region_match.c index 8de23b696bf..d222ea214c4 100644 --- a/source/blender/bmesh/tools/bmesh_region_match.c +++ b/source/blender/bmesh/tools/bmesh_region_match.c @@ -1299,7 +1299,9 @@ static UUIDFashMatch *bm_vert_fasthash_create(BMesh *bm, const uint depth) return id_curr; } -static void bm_vert_fasthash_edge_order(UUIDFashMatch *fm, const BMEdge *e, UUIDFashMatch e_fm[2]) +static void bm_vert_fasthash_edge_order(const UUIDFashMatch *fm, + const BMEdge *e, + UUIDFashMatch e_fm[2]) { e_fm[0] = fm[BM_elem_index_get(e->v1)]; e_fm[1] = fm[BM_elem_index_get(e->v2)]; diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index ae6f49bffcd..84f7fe2d225 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -26,8 +26,8 @@ // this part has been copied from the double edge mask static void do_adjacentKeepBorders(unsigned int t, unsigned int rw, - unsigned int *limask, - unsigned int *lomask, + const unsigned int *limask, + const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize) @@ -196,8 +196,8 @@ static void do_adjacentKeepBorders(unsigned int t, static void do_adjacentBleedBorders(unsigned int t, unsigned int rw, - unsigned int *limask, - unsigned int *lomask, + const unsigned int *limask, + const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize) @@ -417,8 +417,8 @@ static void do_adjacentBleedBorders(unsigned int t, static void do_allKeepBorders(unsigned int t, unsigned int rw, - unsigned int *limask, - unsigned int *lomask, + const unsigned int *limask, + const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize) @@ -579,8 +579,8 @@ static void do_allKeepBorders(unsigned int t, static void do_allBleedBorders(unsigned int t, unsigned int rw, - unsigned int *limask, - unsigned int *lomask, + const unsigned int *limask, + const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize) @@ -793,8 +793,8 @@ static void do_allBleedBorders(unsigned int t, static void do_allEdgeDetection(unsigned int t, unsigned int rw, - unsigned int *limask, - unsigned int *lomask, + const unsigned int *limask, + const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, @@ -863,8 +863,8 @@ static void do_allEdgeDetection(unsigned int t, static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, - unsigned int *limask, - unsigned int *lomask, + const unsigned int *limask, + const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, @@ -935,7 +935,7 @@ static void do_adjacentEdgeDetection(unsigned int t, static void do_createEdgeLocationBuffer(unsigned int t, unsigned int rw, - unsigned int *lres, + const unsigned int *lres, float *res, unsigned short *gbuf, unsigned int *innerEdgeOffset, @@ -1060,7 +1060,7 @@ static void do_createEdgeLocationBuffer(unsigned int t, static void do_fillGradientBuffer(unsigned int rw, float *res, - unsigned short *gbuf, + const unsigned short *gbuf, unsigned int isz, unsigned int osz, unsigned int gsz, diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp index b43b94af06a..0087c720ac0 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp @@ -198,7 +198,7 @@ static void FHT2D( //------------------------------------------------------------------------------ /* 2D convolution calc, d1 *= d2, M/N - > log2 of width/height */ -static void fht_convolve(fREAL *d1, fREAL *d2, unsigned int M, unsigned int N) +static void fht_convolve(fREAL *d1, const fREAL *d2, unsigned int M, unsigned int N) { fREAL a, b; unsigned int i, j, k, L, mj, mL; diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp index 56caa68fd35..56e0ab9b93f 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp @@ -514,7 +514,7 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove) /* we make this into 3 points, center point is (0, 0) */ /* and offset the center point just enough to make curve go through midpoint */ -static void quad_bezier_2d(float *result, float *v1, float *v2, float *ipodata) +static void quad_bezier_2d(float *result, const float *v1, const float *v2, const float *ipodata) { float p1[2], p2[2], p3[2]; diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index 8c48ae65d9b..f6e74c6822c 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -486,7 +486,7 @@ void EEVEE_downsample_buffer(EEVEE_Data *vedata, GPUTexture *texture_src, int le } /** - * Simple down-sampling algorithm for cubemap. Reconstruct mip chain up to mip level. + * Simple down-sampling algorithm for cube-map. Reconstruct mip chain up to mip level. */ void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, GPUTexture *texture_src, int level) { diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index eeb5aafb66d..78fcd28eb5d 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -110,7 +110,7 @@ typedef struct EEVEE_LightBake { float samples_ct, invsamples_ct; /** Sampling bias during convolution step. */ float lod_factor; - /** Max cubemap LOD to sample when convolving. */ + /** Max cube-map LOD to sample when convolving. */ float lod_max; /** Number of probes to render + world probe. */ int cube_len, grid_len; @@ -118,7 +118,7 @@ typedef struct EEVEE_LightBake { /* Irradiance grid */ /** Current probe being rendered (UBO data). */ EEVEE_LightGrid *grid; - /** Target cubemap at MIP 0. */ + /** Target cube-map at MIP 0. */ int irr_cube_res; /** Size of the irradiance texture. */ int irr_size[3]; @@ -142,7 +142,7 @@ typedef struct EEVEE_LightBake { /* Reflection probe */ /** Current probe being rendered (UBO data). */ EEVEE_LightProbe *cube; - /** Target cubemap at MIP 0. */ + /** Target cube-map at MIP 0. */ int ref_cube_res; /** Index of the current cube. */ int cube_offset; diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index 7a4e2eb1cb4..403a8e2af55 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -106,9 +106,9 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, EEVEE_EffectsInfo *effects = stl->effects; EEVEE_PrivateData *g_data = stl->g_data; const DRWContextState *draw_ctx = DRW_context_state_get(); - View3D *v3d = draw_ctx->v3d; - View3DShading *shading = &v3d->shading; - Scene *scene = draw_ctx->scene; + /* The view will be NULL when rendering previews. */ + const View3D *v3d = draw_ctx->v3d; + const Scene *scene = draw_ctx->scene; const bool probe_render = pinfo != NULL; @@ -149,6 +149,7 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, } if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) { + const View3DShading *shading = &v3d->shading; StudioLight *sl = BKE_studiolight_find(shading->lookdev_light, STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE); if (sl == NULL || (sl->flag & STUDIOLIGHT_TYPE_WORLD) == 0) { diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index c3d4a829d17..725f1ea32ba 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -83,8 +83,8 @@ void EEVEE_material_bind_resources(DRWShadingGroup *shgrp, GPUMaterial *gpumat, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, - int *ssr_id, - float *refract_depth, + const int *ssr_id, + const float *refract_depth, bool use_ssrefraction, bool use_alpha_blend) { diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index c23678fadf9..383916e2232 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -1007,8 +1007,8 @@ void EEVEE_material_bind_resources(DRWShadingGroup *shgrp, struct GPUMaterial *gpumat, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, - int *ssr_id, - float *refract_depth, + const int *ssr_id, + const float *refract_depth, bool use_ssrefraction, bool use_alpha_blend); /* eevee_lights.c */ diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c index 714481c39f1..997f9a5be9d 100644 --- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c @@ -96,7 +96,7 @@ static void invert_cdf(const float cdf[FILTER_CDF_TABLE_SIZE], } /* Evaluate a discrete function table with linear interpolation. */ -static float eval_table(float *table, float x) +static float eval_table(const float *table, float x) { CLAMP(x, 0.0f, 1.0f); x = x * (FILTER_CDF_TABLE_SIZE - 1); @@ -240,9 +240,9 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data view_is_valid = view_is_valid && (ED_screen_animation_no_scrub(wm) == NULL); } - effects->taa_total_sample = EEVEE_renderpasses_only_first_sample_pass_active(vedata) ? - 1 : - scene_eval->eevee.taa_samples; + const bool first_sample_only = EEVEE_renderpasses_only_first_sample_pass_active(vedata); + view_is_valid = view_is_valid && !first_sample_only; + effects->taa_total_sample = first_sample_only ? 1 : scene_eval->eevee.taa_samples; MAX2(effects->taa_total_sample, 0); DRW_view_persmat_get(NULL, persmat, false); diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index 7ccb5d5a753..daf83e11e17 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -2118,7 +2118,7 @@ static void armature_context_setup(ArmatureDrawContext *ctx, const bool do_envelope_dist, const bool is_edit_mode, const bool is_pose_mode, - float *const_color) + const float *const_color) { const bool is_object_mode = !do_envelope_dist; const bool is_xray = (ob->dtx & OB_DRAWXRAY) != 0 || (pd->armature.do_pose_xray && is_pose_mode); diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index c0407345729..f096c9657c7 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -1356,7 +1356,7 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, Object *ob, ModifierData *md, Scene *scene, - float *color) + const float *color) { FluidModifierData *fmd = (FluidModifierData *)md; FluidDomainSettings *fds = fmd->domain; diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index d356dec4555..7a889d9399e 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -632,7 +632,7 @@ void DRW_render_object_iter(void *vedata, struct RenderEngine *engine, struct Depsgraph *depsgraph)); void DRW_render_instance_buffer_finish(void); -void DRW_render_viewport_size_set(int size[2]); +void DRW_render_viewport_size_set(const int size[2]); void DRW_custom_pipeline(DrawEngineType *draw_engine_type, struct Depsgraph *depsgraph, diff --git a/source/blender/draw/intern/draw_cache_extract.h b/source/blender/draw/intern/draw_cache_extract.h index 302f9a0d3a8..f05e8e2f9d6 100644 --- a/source/blender/draw/intern/draw_cache_extract.h +++ b/source/blender/draw/intern/draw_cache_extract.h @@ -60,6 +60,10 @@ typedef struct DRW_MeshCDMask { * modifiers could remove it. (see T68857) */ uint32_t edit_uv : 1; } DRW_MeshCDMask; +/* Keep `DRW_MeshCDMask` struct within an `uint64_t`. + * bit-wise and atomic operations are used to compare and update the struct. + * See `mesh_cd_layers_type_*` functions. */ +BLI_STATIC_ASSERT(sizeof(DRW_MeshCDMask) <= sizeof(uint64_t), "DRW_MeshCDMask exceeds 64 bits") typedef enum eMRIterType { MR_ITER_LOOPTRI = 1 << 0, diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index a22e0014bf5..40de0794b9e 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -74,22 +74,25 @@ static void mesh_batch_cache_clear(Mesh *me); /* Return true is all layers in _b_ are inside _a_. */ BLI_INLINE bool mesh_cd_layers_type_overlap(DRW_MeshCDMask a, DRW_MeshCDMask b) { - return (*((uint32_t *)&a) & *((uint32_t *)&b)) == *((uint32_t *)&b); + return (*((uint64_t *)&a) & *((uint64_t *)&b)) == *((uint64_t *)&b); } BLI_INLINE bool mesh_cd_layers_type_equal(DRW_MeshCDMask a, DRW_MeshCDMask b) { - return *((uint32_t *)&a) == *((uint32_t *)&b); + return *((uint64_t *)&a) == *((uint64_t *)&b); } BLI_INLINE void mesh_cd_layers_type_merge(DRW_MeshCDMask *a, DRW_MeshCDMask b) { - atomic_fetch_and_or_uint32((uint32_t *)a, *(uint32_t *)&b); + uint32_t *a_p = (uint32_t *)a; + uint32_t *b_p = (uint32_t *)&b; + atomic_fetch_and_or_uint32(a_p, *b_p); + atomic_fetch_and_or_uint32(a_p + 1, *(b_p + 1)); } BLI_INLINE void mesh_cd_layers_type_clear(DRW_MeshCDMask *a) { - *((uint32_t *)a) = 0; + *((uint64_t *)a) = 0; } static void mesh_cd_calc_edit_uv_layer(const Mesh *UNUSED(me), DRW_MeshCDMask *cd_used) diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 3e42c4cdb23..5359f649d6b 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -369,7 +369,7 @@ void DRW_engine_viewport_data_size_get( } /* WARNING: only use for custom pipeline. 99% of the time, you don't want to use this. */ -void DRW_render_viewport_size_set(int size[2]) +void DRW_render_viewport_size_set(const int size[2]) { DST.size[0] = size[0]; DST.size[1] = size[1]; diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 5d3d404ab8f..a448a94185a 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -584,7 +584,7 @@ void drw_state_set(DRWState state); void drw_debug_draw(void); void drw_debug_init(void); -eDRWCommandType command_type_get(uint64_t *command_type_bits, int index); +eDRWCommandType command_type_get(const uint64_t *command_type_bits, int index); void drw_batch_cache_validate(Object *ob); void drw_batch_cache_generate_requested(struct Object *ob); diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 41f442adec9..5dc40bcdc76 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -623,7 +623,7 @@ static void command_type_set(uint64_t *command_type_bits, int index, eDRWCommand command_type_bits[index / 16] |= ((uint64_t)type) << ((index % 16) * 4); } -eDRWCommandType command_type_get(uint64_t *command_type_bits, int index) +eDRWCommandType command_type_get(const uint64_t *command_type_bits, int index) { return ((command_type_bits[index / 16] >> ((index % 16) * 4)) & 0xF); } diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index 486cbb2397c..0bb20631537 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -91,10 +91,13 @@ static void drw_deferred_shader_queue_free(ListBase *queue) } } -static void drw_deferred_shader_compilation_exec(void *custom_data, - short *stop, - short *do_update, - float *progress) +static void drw_deferred_shader_compilation_exec( + void *custom_data, + /* Cannot be const, this function implements wm_jobs_start_callback. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + short *stop, + short *do_update, + float *progress) { DRWShaderCompiler *comp = (DRWShaderCompiler *)custom_data; void *gl_context = comp->gl_context; diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index d823b976a47..bcdbf4c74f0 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -540,7 +540,7 @@ static void draw_markers_background(rctf *rect) immUnbindProgram(); } -static bool marker_is_in_frame_range(TimeMarker *marker, int frame_range[2]) +static bool marker_is_in_frame_range(TimeMarker *marker, const int frame_range[2]) { if (marker->frame < frame_range[0]) { return false; diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 23fb6c0ab27..11066595e2e 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -655,7 +655,7 @@ void heat_bone_weighting(Object *ob, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], - int *selected, + const int *selected, const char **err_str) { LaplacianSystem *sys; @@ -1236,7 +1236,7 @@ static float meshdeform_boundary_phi(const MeshDeformBind *mdb, } static float meshdeform_interp_w(MeshDeformBind *mdb, - float *gridvec, + const float *gridvec, float *UNUSED(vec), int UNUSED(cagevert)) { diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h index ef4759eab4a..0a9e6e878e4 100644 --- a/source/blender/editors/armature/meshlaplacian.h +++ b/source/blender/editors/armature/meshlaplacian.h @@ -56,7 +56,7 @@ void heat_bone_weighting(struct Object *ob, struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], - int *selected, + const int *selected, const char **error); #ifdef RIGID_DEFORM diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 38ab917ba72..3e428eaffc2 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5498,6 +5498,7 @@ static int ed_editcurve_addvert(Curve *cu, if (nu) { nurb_new = BKE_nurb_copy(nu, 1, 1); + memcpy(nurb_new->bezt, nu->bezt, sizeof(BezTriple)); } else { nurb_new = MEM_callocN(sizeof(Nurb), "BLI_editcurve_addvert new_bezt_nurb 2"); diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index fd24149e9ea..85f84af5f14 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -637,7 +637,7 @@ static void gizmo_cage2d_draw_intern(wmGizmo *gz, } if (select) { - /* expand for hotspot */ + /* Expand for hot-spot. */ const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE) { @@ -694,7 +694,7 @@ static void gizmo_cage2d_draw_intern(wmGizmo *gz, bool show = false; if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { /* Only show if we're drawing the center handle - * otherwise the entire rectangle is the hotspot. */ + * otherwise the entire rectangle is the hot-spot. */ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { show = true; } @@ -805,7 +805,7 @@ static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2]) return -1; } - /* expand for hotspot */ + /* Expand for hots-pot. */ const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; const int transform_flag = RNA_enum_get(gz->ptr, "transform"); diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index b0af8641767..8955a666e22 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -314,7 +314,7 @@ static void gizmo_cage3d_draw_intern( } if (select) { - /* expand for hotspot */ + /* Expand for hot-spot. */ #if 0 const float size[3] = { size_real[0] + margin[0] / 2, diff --git a/source/blender/editors/gpencil/gpencil_mesh.c b/source/blender/editors/gpencil/gpencil_mesh.c index 763f5687edf..68ab5100bf4 100644 --- a/source/blender/editors/gpencil/gpencil_mesh.c +++ b/source/blender/editors/gpencil/gpencil_mesh.c @@ -82,7 +82,7 @@ static bool gpencil_bake_mesh_animation_poll(bContext *C) } typedef struct GpBakeOb { - struct GPBakelist *next, *prev; + struct GpBakeOb *next, *prev; Object *ob; } GpBakeOb; diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index dd5e16a9d9b..a695d2e4cf2 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -2245,7 +2245,7 @@ static void gpencil_copy_points( } static void gpencil_insert_point( - bGPDstroke *gps, bGPDspoint *a_pt, bGPDspoint *b_pt, const float co_a[3], float co_b[3]) + bGPDstroke *gps, bGPDspoint *a_pt, bGPDspoint *b_pt, const float co_a[3], const float co_b[3]) { bGPDspoint *temp_points; int totnewpoints, oldtotpoints; @@ -2764,7 +2764,7 @@ void ED_gpencil_init_random_settings(Brush *brush, } static void gpencil_sbuffer_vertex_color_random( - bGPdata *gpd, Brush *brush, tGPspoint *tpt, float random_color[3], float pen_pressure) + bGPdata *gpd, Brush *brush, tGPspoint *tpt, const float random_color[3], float pen_pressure) { BrushGpencilSettings *brush_settings = brush->gpencil_settings; if (brush_settings->flag & GP_BRUSH_GROUP_RANDOM) { @@ -2895,7 +2895,7 @@ void ED_gpencil_sbuffer_vertex_color_set(Depsgraph *depsgraph, /* Check if the stroke collides with brush. */ bool ED_gpencil_stroke_check_collision(GP_SpaceConversion *gsc, bGPDstroke *gps, - float mouse[2], + const float mouse[2], const int radius, const float diff_mat[4][4]) { diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c index 5f8ff228d4d..c36bc4388d7 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_paint.c +++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c @@ -348,7 +348,7 @@ static void gpencil_grid_cell_average_color_idx_get(tGP_BrushVertexpaintData *gs } } -static int gpencil_grid_cell_index_get(tGP_BrushVertexpaintData *gso, int pc[2]) +static int gpencil_grid_cell_index_get(tGP_BrushVertexpaintData *gso, const int pc[2]) { float bottom[2], top[2]; diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index a523e924e54..8a239559627 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -106,7 +106,7 @@ struct FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile); short ED_fileselect_set_params(struct SpaceFile *sfile); void ED_fileselect_set_params_from_userdef(struct SpaceFile *sfile); void ED_fileselect_params_to_userdef(struct SpaceFile *sfile, - int temp_win_size[], + const int temp_win_size[], const bool is_maximized); void ED_fileselect_reset_params(struct SpaceFile *sfile); diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index f961f835f12..64276706759 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -351,7 +351,7 @@ void ED_gpencil_init_random_settings(struct Brush *brush, bool ED_gpencil_stroke_check_collision(struct GP_SpaceConversion *gsc, struct bGPDstroke *gps, - float mouse[2], + const float mouse[2], const int radius, const float diff_mat[4][4]); bool ED_gpencil_stroke_point_is_inside(struct bGPDstroke *gps, diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index a8476e3d1ca..e8343fbbc19 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -125,8 +125,8 @@ void ED_image_draw_info(struct Scene *scene, const unsigned char cp[4], const float fp[4], const float linearcol[4], - int *zp, - float *zpf); + const int *zp, + const float *zpf); bool ED_space_image_show_cache(struct SpaceImage *sima); diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 47ccc0788c2..382902cd2de 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -121,7 +121,7 @@ void ED_operatormacros_node(void); bool ED_space_node_color_sample(struct Main *bmain, struct SpaceNode *snode, struct ARegion *region, - int mval[2], + const int mval[2], float r_col[3]); #ifdef __cplusplus diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index bc6a4b23609..71b7d35908b 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -349,6 +349,7 @@ bool ED_operator_console_active(struct bContext *C); bool ED_operator_object_active(struct bContext *C); bool ED_operator_object_active_editable_ex(struct bContext *C, const Object *ob); bool ED_operator_object_active_editable(struct bContext *C); +bool ED_operator_object_active_local_editable(struct bContext *C); bool ED_operator_object_active_editable_mesh(struct bContext *C); bool ED_operator_object_active_editable_font(struct bContext *C); bool ED_operator_editable_mesh(struct bContext *C); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 5e706856738..f8a4884c594 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -150,7 +150,7 @@ void ED_view3d_cursor3d_update(struct bContext *C, struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d); void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist); -void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float *dist); +void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], const float *dist); void ED_view3d_from_object( const struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens); @@ -502,7 +502,7 @@ bool ED_view3d_autodist_simple(struct ARegion *region, const int mval[2], float mouse_worldloc[3], int margin, - float *force_depth); + const float *force_depth); bool ED_view3d_autodist_depth(struct ARegion *region, const int mval[2], int margin, float *depth); bool ED_view3d_autodist_depth_seg(struct ARegion *region, const int mval_sta[2], diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d93e8809ed2..7ce74a87ea0 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1506,7 +1506,7 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, short width, short height, short *keypoin, - short *modkeypoin, + const short *modkeypoin, const char *tip); uiBut *uiDefSearchBut(uiBlock *block, diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index f4207d83e11..ca89c5f606f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -6262,7 +6262,7 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, short width, short height, short *keypoin, - short *modkeypoin, + const short *modkeypoin, const char *tip) { uiBut *but = ui_def_but(block, diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index d735c9d55fc..3c0b5bd3027 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -559,7 +559,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) case UI_ID_LOCAL: if (id) { Main *bmain = CTX_data_main(C); - if (BKE_lib_override_library_is_enabled() && CTX_wm_window(C)->eventstate->shift) { + if (CTX_wm_window(C)->eventstate->shift) { if (ID_IS_OVERRIDABLE_LIBRARY(id)) { /* Only remap that specific ID usage to overriding local data-block. */ ID *override_id = BKE_lib_override_library_create_from_id(bmain, id, false); @@ -569,6 +569,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) /* Assign new pointer, takes care of updates/notifiers */ RNA_id_pointer_create(override_id, &idptr); } + undo_push_label = "Make Library Override"; } } else { @@ -577,11 +578,13 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) /* reassign to get get proper updates/notifiers */ idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); + undo_push_label = "Make Local"; } } - RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL); - RNA_property_update(C, &template_ui->ptr, template_ui->prop); - undo_push_label = "Make Local"; + if (undo_push_label != NULL) { + RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL); + RNA_property_update(C, &template_ui->ptr, template_ui->prop); + } } break; case UI_ID_OVERRIDE: @@ -931,10 +934,8 @@ static void template_ID(const bContext *C, 0, 0, 0, - BKE_lib_override_library_is_enabled() ? - TIP_("Direct linked library data-block, click to make local, " - "Shift + Click to create a library override") : - TIP_("Direct linked library data-block, click to make local")); + TIP_("Direct linked library data-block, click to make local, " + "Shift + Click to create a library override")); if (disabled) { UI_but_flag_enable(but, UI_BUT_DISABLED); } @@ -4848,6 +4849,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp /* Preset selector */ /* There is probably potential to use simpler "uiItemR" functions here, but automatic updating * after a preset is selected would be more complicated. */ + row = uiLayoutRow(layout, true); bt = uiDefBlockBut( block, CurveProfile_buttons_presets, profile, "Preset", 0, 0, UI_UNIT_X, UI_UNIT_X, ""); UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c index 0b62934d190..49cf4779496 100644 --- a/source/blender/editors/lattice/editlattice_select.c +++ b/source/blender/editors/lattice/editlattice_select.c @@ -268,7 +268,7 @@ void LATTICE_OT_select_mirror(wmOperatorType *ot) * \{ */ static bool lattice_test_bitmap_uvw( - Lattice *lt, BLI_bitmap *selpoints, int u, int v, int w, const bool selected) + Lattice *lt, const BLI_bitmap *selpoints, int u, int v, int w, const bool selected) { if ((u < 0 || u >= lt->pntsu) || (v < 0 || v >= lt->pntsv) || (w < 0 || w >= lt->pntsw)) { return false; diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index b7fd661d8e6..c19a5b8ef68 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -439,7 +439,7 @@ static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer, /* Convert coordinate from normalized space to pixel one. * TODO(sergey): Make the function more generally available. */ static void mask_point_make_pixel_space(bContext *C, - float point_normalized[2], + const float point_normalized[2], float point_pixel[2]) { ScrArea *area = CTX_wm_area(C); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index e9223af12ff..0394874e8c1 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -102,7 +102,7 @@ typedef struct KnifeVert { ListBase edges; ListBase faces; - float co[3], cageco[3], sco[2]; /* sco is screen coordinates for cageco */ + float co[3], cageco[3]; bool is_face, in_space; bool is_cut; /* along a cut created by user input (will draw too) */ } KnifeVert; @@ -429,8 +429,6 @@ static KnifeVert *new_knife_vert(KnifeTool_OpData *kcd, const float co[3], const copy_v3_v3(kfv->co, co); copy_v3_v3(kfv->cageco, cageco); - knife_project_v2(kcd, kfv->cageco, kfv->sco); - return kfv; } @@ -1926,10 +1924,11 @@ static int knife_sample_screen_density(KnifeTool_OpData *kcd, const float radius for (i = 0; i < 2; i++) { KnifeVert *kfv = i ? kfe->v2 : kfe->v1; + float kfv_sco[2]; - knife_project_v2(kcd, kfv->cageco, kfv->sco); + knife_project_v2(kcd, kfv->cageco, kfv_sco); - dis_sq = len_squared_v2v2(kfv->sco, sco); + dis_sq = len_squared_v2v2(kfv_sco, sco); if (dis_sq < radius_sq) { if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { @@ -1991,20 +1990,19 @@ static KnifeEdge *knife_find_closest_edge_of_face(KnifeTool_OpData *kcd, lst = knife_get_face_kedges(kcd, f); for (ref = lst->first; ref; ref = ref->next) { KnifeEdge *kfe = ref->ref; - float test_cagep[3]; + float kfv1_sco[2], kfv2_sco[2], test_cagep[3]; float lambda; /* project edge vertices into screen space */ - knife_project_v2(kcd, kfe->v1->cageco, kfe->v1->sco); - knife_project_v2(kcd, kfe->v2->cageco, kfe->v2->sco); + knife_project_v2(kcd, kfe->v1->cageco, kfv1_sco); + knife_project_v2(kcd, kfe->v2->cageco, kfv2_sco); /* check if we're close enough and calculate 'lambda' */ if (kcd->is_angle_snapping) { /* if snapping, check we're in bounds */ float sco_snap[2]; - isect_line_line_v2_point( - kfe->v1->sco, kfe->v2->sco, kcd->prev.mval, kcd->curr.mval, sco_snap); - lambda = line_point_factor_v2(sco_snap, kfe->v1->sco, kfe->v2->sco); + isect_line_line_v2_point(kfv1_sco, kfv2_sco, kcd->prev.mval, kcd->curr.mval, sco_snap); + lambda = line_point_factor_v2(sco_snap, kfv1_sco, kfv2_sco); /* be strict about angle-snapping within edge */ if ((lambda < 0.0f - KNIFE_FLT_EPSBIG) || (lambda > 1.0f + KNIFE_FLT_EPSBIG)) { @@ -2020,9 +2018,9 @@ static KnifeEdge *knife_find_closest_edge_of_face(KnifeTool_OpData *kcd, } } else { - dis_sq = dist_squared_to_line_segment_v2(sco, kfe->v1->sco, kfe->v2->sco); + dis_sq = dist_squared_to_line_segment_v2(sco, kfv1_sco, kfv2_sco); if (dis_sq < curdis_sq && dis_sq < maxdist_sq) { - lambda = line_point_factor_v2(sco, kfe->v1->sco, kfe->v2->sco); + lambda = line_point_factor_v2(sco, kfv1_sco, kfv2_sco); } else { continue; @@ -2061,8 +2059,7 @@ static KnifeEdge *knife_find_closest_edge_of_face(KnifeTool_OpData *kcd, /* update mouse coordinates to the snapped-to edge's screen coordinates * this is important for angle snap, which uses the previous mouse position */ edgesnap = new_knife_vert(kcd, p, cagep); - kcd->curr.mval[0] = edgesnap->sco[0]; - kcd->curr.mval[1] = edgesnap->sco[1]; + knife_project_v2(kcd, edgesnap->cageco, kcd->curr.mval); } else { return NULL; @@ -2095,6 +2092,7 @@ static KnifeVert *knife_find_closest_vert_of_face(KnifeTool_OpData *kcd, ListBase *lst; Ref *ref; KnifeVert *curv = NULL; + float cur_kfv_sco[2]; float dis_sq, curdis_sq = FLT_MAX; knife_project_v2(kcd, cagep, sco); @@ -2106,29 +2104,26 @@ static KnifeVert *knife_find_closest_vert_of_face(KnifeTool_OpData *kcd, for (i = 0; i < 2; i++) { KnifeVert *kfv = i ? kfe->v2 : kfe->v1; + float kfv_sco[2]; - knife_project_v2(kcd, kfv->cageco, kfv->sco); + knife_project_v2(kcd, kfv->cageco, kfv_sco); /* be strict about angle snapping, the vertex needs to be very close to the angle, * or we ignore */ if (kcd->is_angle_snapping) { - if (dist_squared_to_line_segment_v2(kfv->sco, kcd->prev.mval, kcd->curr.mval) > + if (dist_squared_to_line_segment_v2(kfv_sco, kcd->prev.mval, kcd->curr.mval) > KNIFE_FLT_EPSBIG) { continue; } } - dis_sq = len_squared_v2v2(kfv->sco, sco); + dis_sq = len_squared_v2v2(kfv_sco, sco); if (dis_sq < curdis_sq && dis_sq < maxdist_sq) { - if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { - if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { - curv = kfv; - curdis_sq = dis_sq; - } - } - else { + if (!RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d) || + !ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true)) { curv = kfv; curdis_sq = dis_sq; + copy_v2_v2(cur_kfv_sco, kfv_sco); } } } @@ -2141,8 +2136,7 @@ static KnifeVert *knife_find_closest_vert_of_face(KnifeTool_OpData *kcd, /* update mouse coordinates to the snapped-to vertex's screen coordinates * this is important for angle snap, which uses the previous mouse position */ - kcd->curr.mval[0] = curv->sco[0]; - kcd->curr.mval[1] = curv->sco[1]; + copy_v2_v2(kcd->curr.mval, cur_kfv_sco); } return curv; diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index b60e0074512..0cc4dcef442 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -778,6 +778,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, UvElement *newvlist = NULL, *vlist = element_map->vert[i]; UvElement *iterv, *v, *lastv, *next; float *uv, *uv2, uvdiff[2]; + bool uv_vert_sel, uv2_vert_sel; while (vlist) { v = vlist; @@ -788,6 +789,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, l = v->l; luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv = luv->uv; + uv_vert_sel = luv->flag & MLOOPUV_VERTSEL; lastv = NULL; iterv = vlist; @@ -798,12 +800,17 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, l = iterv->l; luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv2 = luv->uv; + uv2_vert_sel = luv->flag & MLOOPUV_VERTSEL; sub_v2_v2v2(uvdiff, uv2, uv); - if (fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT && fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT && - (!use_winding || - winding[BM_elem_index_get(iterv->l->f)] == winding[BM_elem_index_get(v->l->f)])) { + /* Check if the uv loops share the same selection state (if not, they are not connected as + * they have been ripped or other edit commands have seperated them). */ + bool connected = uv_vert_sel == uv2_vert_sel && fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT && + fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT; + + if (connected && (!use_winding || winding[BM_elem_index_get(iterv->l->f)] == + winding[BM_elem_index_get(v->l->f)])) { if (lastv) { lastv->next = next; } @@ -1029,7 +1036,7 @@ bool EDBM_vert_color_check(BMEditMesh *em) /** \name Mirror Cache API * \{ */ -static BMVert *cache_mirr_intptr_as_bmvert(intptr_t *index_lookup, int index) +static BMVert *cache_mirr_intptr_as_bmvert(const intptr_t *index_lookup, int index) { intptr_t eve_i = index_lookup[index]; return (eve_i == -1) ? NULL : (BMVert *)eve_i; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index a0de4fe7b02..90ea71ae5c5 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1683,7 +1683,7 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) /* callbacks */ ot->exec = object_constraints_clear_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; } /** \} */ diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ac41028089c..945c7e87eb1 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2242,28 +2242,6 @@ void OBJECT_OT_make_local(wmOperatorType *ot) /** \name Make Library Override Operator * \{ */ -static bool make_override_hierarchy_recursive_tag(Main *bmain, ID *id) -{ - MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->id_user_to_used, id); - - /* This way we won't process again that ID should we encounter it again through another - * relationship hierarchy. - * Note that this does not free any memory from relations, so we can still use the entries. - */ - BKE_main_relations_ID_remove(bmain, id); - - for (; entry != NULL; entry = entry->next) { - /* We only consider IDs from the same library. */ - if (entry->id_pointer != NULL && (*entry->id_pointer)->lib == id->lib) { - if (make_override_hierarchy_recursive_tag(bmain, *entry->id_pointer)) { - id->tag |= LIB_TAG_DOIT; - } - } - } - - return (id->tag & LIB_TAG_DOIT) != 0; -} - static int make_override_tag_ids_cb(LibraryIDLinkCallbackData *cb_data) { if (cb_data->cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_LOOPBACK)) { @@ -2315,14 +2293,9 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve return OPERATOR_CANCELLED; } - /* Get object to work on - use a menu if we need to... */ - if (!ID_IS_LINKED(obact) && obact->instance_collection != NULL && - ID_IS_LINKED(obact->instance_collection)) { - /* Gives menu with list of objects in group. */ - WM_enum_search_invoke(C, op, event); - return OPERATOR_CANCELLED; - } - if (ID_IS_LINKED(obact)) { + if ((!ID_IS_LINKED(obact) && obact->instance_collection != NULL && + ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)) || + ID_IS_OVERRIDABLE_LIBRARY(obact)) { uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION); uiLayout *layout = UI_popup_menu_layout(pup); @@ -2337,6 +2310,11 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve /* This invoke just calls another instance of this operator... */ return OPERATOR_INTERFACE; } + else if (ID_IS_LINKED(obact)) { + /* Show menu with list of directly linked collections containing the active object. */ + WM_enum_search_invoke(C, op, event); + return OPERATOR_CANCELLED; + } /* Error.. cannot continue. */ BKE_report(op->reports, @@ -2366,11 +2344,28 @@ static int make_override_library_exec(bContext *C, wmOperator *op) id_root = &obact->instance_collection->id; } else if (!ID_IS_OVERRIDABLE_LIBRARY(obact)) { - BKE_reportf(op->reports, - RPT_ERROR_INVALID_INPUT, - "Active object '%s' is not overridable", - obact->id.name + 2); - return OPERATOR_CANCELLED; + const int i = RNA_property_enum_get(op->ptr, op->type->prop); + const uint collection_session_uuid = *((uint *)&i); + if (collection_session_uuid == MAIN_ID_SESSION_UUID_UNSET) { + BKE_reportf(op->reports, + RPT_ERROR_INVALID_INPUT, + "Active object '%s' is not overridable", + obact->id.name + 2); + return OPERATOR_CANCELLED; + } + + Collection *collection = BLI_listbase_bytes_find(&bmain->collections, + &collection_session_uuid, + sizeof(collection_session_uuid), + offsetof(ID, session_uuid)); + if (!ID_IS_OVERRIDABLE_LIBRARY(collection)) { + BKE_reportf(op->reports, + RPT_ERROR_INVALID_INPUT, + "Could not find an overridable collection containing object '%s'", + obact->id.name + 2); + return OPERATOR_CANCELLED; + } + id_root = &collection->id; } /* Else, poll func ensures us that ID_IS_LINKED(obact) is true. */ else { @@ -2399,12 +2394,8 @@ static int make_override_library_exec(bContext *C, wmOperator *op) } } - /* Then we tag all intermediary data-blocks in-between two overridden ones (e.g. if a shapekey - * has a driver using an armature object's bone, we need to override the shapekey/obdata, the - * objects using them, etc.) */ - make_override_hierarchy_recursive_tag(bmain, id_root); - - BKE_main_relations_free(bmain); + /* Note that this call will also free the main relations data we created above. */ + BKE_lib_override_library_dependencies_tag(bmain, id_root, LIB_TAG_DOIT, false); ID *id; FOREACH_MAIN_ID_BEGIN (bmain, id) { @@ -2523,10 +2514,40 @@ static bool make_override_library_poll(bContext *C) Object *obact = CTX_data_active_object(C); /* Object must be directly linked to be overridable. */ - return (BKE_lib_override_library_is_enabled() && ED_operator_objectmode(C) && obact != NULL && - ((ID_IS_LINKED(obact) && obact->id.tag & LIB_TAG_EXTERN) || - (!ID_IS_LINKED(obact) && obact->instance_collection != NULL && - ID_IS_LINKED(obact->instance_collection)))); + return (ED_operator_objectmode(C) && obact != NULL && + (ID_IS_LINKED(obact) || (obact->instance_collection != NULL && + ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)))); +} + +static const EnumPropertyItem *make_override_collections_of_linked_object_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +{ + EnumPropertyItem item_tmp = {0}, *item = NULL; + int totitem = 0; + + Object *object = ED_object_active_context(C); + Main *bmain = CTX_data_main(C); + + if (!object || !ID_IS_LINKED(object)) { + return DummyRNA_DEFAULT_items; + } + + LISTBASE_FOREACH (Collection *, collection, &bmain->collections) { + /* Only check for directly linked collections. */ + if (!ID_IS_LINKED(&collection->id) || (collection->id.tag & LIB_TAG_INDIRECT) != 0) { + continue; + } + if (BKE_collection_has_object_recursive(collection, object)) { + item_tmp.identifier = item_tmp.name = collection->id.name + 2; + item_tmp.value = *((int *)&collection->id.session_uuid); + RNA_enum_item_add(&item, &totitem, &item_tmp); + } + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; } void OBJECT_OT_make_override_library(wmOperatorType *ot) @@ -2547,12 +2568,13 @@ void OBJECT_OT_make_override_library(wmOperatorType *ot) /* properties */ PropertyRNA *prop; prop = RNA_def_enum(ot->srna, - "object", + "collection", DummyRNA_DEFAULT_items, - 0, - "Override Object", - "Name of lib-linked/collection object to make an override from"); - RNA_def_enum_funcs(prop, proxy_collection_object_itemf); + MAIN_ID_SESSION_UUID_UNSET, + "Override Collection", + "Name of directly linked collection containing the selected object, to make " + "an override from"); + RNA_def_enum_funcs(prop, make_override_collections_of_linked_object_itemf); RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); ot->prop = prop; } diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 6922a03b12f..381bf317bee 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -102,7 +102,7 @@ void DPAINT_OT_surface_slot_add(wmOperatorType *ot) /* api callbacks */ ot->exec = surface_slot_add_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -151,7 +151,7 @@ void DPAINT_OT_surface_slot_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = surface_slot_remove_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -203,7 +203,7 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec = type_toggle_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -286,7 +286,7 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec = output_toggle_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -538,5 +538,5 @@ void DPAINT_OT_bake(wmOperatorType *ot) /* api callbacks */ ot->exec = dynamicpaint_bake_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; } diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index e75169a476b..41e30adf724 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -104,7 +104,7 @@ void OBJECT_OT_particle_system_add(wmOperatorType *ot) ot->description = "Add a particle system"; /* api callbacks */ - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; ot->exec = particle_system_add_exec; /* flags */ @@ -151,7 +151,7 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot) ot->description = "Remove the selected particle system"; /* api callbacks */ - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; ot->exec = particle_system_remove_exec; /* flags */ @@ -1210,7 +1210,7 @@ static bool copy_particle_systems_to_object(const bContext *C, static bool copy_particle_systems_poll(bContext *C) { Object *ob; - if (!ED_operator_object_active_editable(C)) { + if (!ED_operator_object_active_local_editable(C)) { return false; } @@ -1311,7 +1311,7 @@ void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot) static bool duplicate_particle_systems_poll(bContext *C) { - if (!ED_operator_object_active_editable(C)) { + if (!ED_operator_object_active_local_editable(C)) { return false; } Object *ob = ED_object_active_context(C); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 583c68cb284..26b5f7fb2af 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -546,6 +546,7 @@ static int fluid_bake_exec(struct bContext *C, struct wmOperator *op) return OPERATOR_CANCELLED; } if (!fluid_validatepaths(job, op->reports)) { + fluid_bake_free(job); return OPERATOR_CANCELLED; } WM_report_banners_cancel(job->bmain); @@ -574,6 +575,7 @@ static int fluid_bake_invoke(struct bContext *C, } if (!fluid_validatepaths(job, op->reports)) { + fluid_bake_free(job); return OPERATOR_CANCELLED; } @@ -651,6 +653,7 @@ static int fluid_free_exec(struct bContext *C, struct wmOperator *op) job->name = op->type->name; if (!fluid_validatepaths(job, op->reports)) { + fluid_bake_free(job); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 754f8226684..149bae718a0 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -162,7 +162,7 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot) /* api callbacks */ ot->exec = material_slot_add_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -207,7 +207,7 @@ void OBJECT_OT_material_slot_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = material_slot_remove_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -310,7 +310,7 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot) /* api callbacks */ ot->exec = material_slot_assign_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -564,6 +564,7 @@ void OBJECT_OT_material_slot_move(wmOperatorType *ot) ot->description = "Move the active material up/down in the list"; /* api callbacks */ + ot->poll = ED_operator_object_active_local_editable; ot->exec = material_slot_move_exec; /* flags */ @@ -638,7 +639,7 @@ void OBJECT_OT_material_slot_remove_unused(wmOperatorType *ot) /* api callbacks */ ot->exec = material_slot_remove_unused_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_object_active_local_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -707,6 +708,7 @@ void MATERIAL_OT_new(wmOperatorType *ot) ot->description = "Add a new material"; /* api callbacks */ + ot->poll = ED_operator_object_active_local_editable; ot->exec = new_material_exec; /* flags */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f32dd0c8703..b034fb186d2 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -360,6 +360,13 @@ bool ED_operator_object_active_editable(bContext *C) return ED_operator_object_active_editable_ex(C, ob); } +/** Object must be editable and fully local (i.e. not an override). */ +bool ED_operator_object_active_local_editable(bContext *C) +{ + Object *ob = ED_object_active_context(C); + return ED_operator_object_active_editable_ex(C, ob) && !ID_IS_OVERRIDE_LIBRARY(ob); +} + bool ED_operator_object_active_editable_mesh(bContext *C) { Object *ob = ED_object_active_context(C); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 892aea6048f..be7b824fc3e 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -875,8 +875,12 @@ static bool paint_draw_alpha_overlay(UnifiedPaintSettings *ups, return alpha_overlay_active; } -BLI_INLINE void draw_tri_point( - uint pos, const float sel_col[4], float pivot_col[4], float *co, float width, bool selected) +BLI_INLINE void draw_tri_point(uint pos, + const float sel_col[4], + const float pivot_col[4], + float *co, + float width, + bool selected) { immUniformColor4fv(selected ? sel_col : pivot_col); @@ -905,8 +909,12 @@ BLI_INLINE void draw_tri_point( immEnd(); } -BLI_INLINE void draw_rect_point( - uint pos, const float sel_col[4], float handle_col[4], float *co, float width, bool selected) +BLI_INLINE void draw_rect_point(uint pos, + const float sel_col[4], + const float handle_col[4], + const float *co, + float width, + bool selected) { immUniformColor4fv(selected ? sel_col : handle_col); diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 16ccfaf8286..a7f09390a3d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -257,7 +257,7 @@ static ushort *brush_painter_mask_ibuf_new(BrushPainter *painter, const int size /* update rectangular section of the brush image */ static void brush_painter_mask_imbuf_update(BrushPainter *painter, ImagePaintTile *tile, - ushort *tex_mask_old, + const ushort *tex_mask_old, int origx, int origy, int w, @@ -1052,7 +1052,7 @@ static void paint_2d_lift_soften(ImagePaintState *s, ImagePaintTile *tile, ImBuf *ibuf, ImBuf *ibufb, - int *pos, + const int *pos, const short paint_tile) { bool sharpen = (tile->cache.invert ^ ((s->brush->flag & BRUSH_DIR_IN) != 0)); @@ -1255,7 +1255,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short paint } } -static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos) +static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, const int *pos) { /* note: allocImbuf returns zero'd memory, so regions outside image will * have zero alpha, and hence not be blended onto the image */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index be545600e6e..d65f158174f 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -246,7 +246,11 @@ static int palette_color_add_exec(bContext *C, wmOperator *UNUSED(op)) color = BKE_palette_color_add(palette); palette->active_color = BLI_listbase_count(&palette->colors) - 1; - if (ELEM(mode, PAINT_MODE_TEXTURE_3D, PAINT_MODE_TEXTURE_2D, PAINT_MODE_VERTEX)) { + if (ELEM(mode, + PAINT_MODE_TEXTURE_3D, + PAINT_MODE_TEXTURE_2D, + PAINT_MODE_VERTEX, + PAINT_MODE_SCULPT)) { copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush)); color->value = 0.0; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c index 048f11c92d7..d05b1673c9a 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c @@ -206,7 +206,7 @@ void PAINT_OT_vertex_color_from_weight(wmOperatorType *ot) /** \name Smooth Vertex Colors Operator * \{ */ -static void vertex_color_smooth_looptag(Mesh *me, bool *mlooptag) +static void vertex_color_smooth_looptag(Mesh *me, const bool *mlooptag) { const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; const MPoly *mp; diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index 6ca45ee0fb8..6a2137b6626 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -437,13 +437,16 @@ static void do_cloth_brush_solve_simulation_task_cb_ex( BKE_pbvh_vertex_iter_end; } -static void cloth_brush_build_nodes_constraints(Sculpt *sd, - Object *ob, - PBVHNode **nodes, - int totnode, - SculptClothSimulation *cloth_sim, - float initial_location[3], - const float radius) +static void cloth_brush_build_nodes_constraints( + Sculpt *sd, + Object *ob, + PBVHNode **nodes, + int totnode, + SculptClothSimulation *cloth_sim, + /* Cannot be const, because it is assigned to a non-const variable. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + float initial_location[3], + const float radius) { Brush *brush = BKE_paint_brush(&sd->paint); diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c index 5cf6a053382..608ba1b934e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c @@ -388,7 +388,17 @@ static void do_smear_brush_task_cb_exec(void *__restrict userdata, float interp_color[4]; copy_v4_v4(interp_color, ss->cache->prev_colors[vd.index]); - sub_v3_v3v3(current_disp, ss->cache->location, ss->cache->last_location); + switch (brush->smear_deform_type) { + case BRUSH_SMEAR_DEFORM_DRAG: + sub_v3_v3v3(current_disp, ss->cache->location, ss->cache->last_location); + break; + case BRUSH_SMEAR_DEFORM_PINCH: + sub_v3_v3v3(current_disp, ss->cache->location, vd.co); + break; + case BRUSH_SMEAR_DEFORM_EXPAND: + sub_v3_v3v3(current_disp, vd.co, ss->cache->location); + break; + } normalize_v3_v3(current_disp_norm, current_disp); mul_v3_v3fl(current_disp, current_disp_norm, ss->cache->bstrength); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index a69601316ef..9da75ab7e3c 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1403,6 +1403,8 @@ static void do_sequence_proxy(void *pjv, int build_count, int *build_undistort_sizes, int build_undistort_count, + /* Cannot be const, because it is assigned to a non-const variable. + * NOLINTNEXTLINE: readability-non-const-parameter. */ short *stop, short *do_update, float *progress) diff --git a/source/blender/editors/space_clip/tracking_ops_track.c b/source/blender/editors/space_clip/tracking_ops_track.c index cec7b371457..afbca48bd45 100644 --- a/source/blender/editors/space_clip/tracking_ops_track.c +++ b/source/blender/editors/space_clip/tracking_ops_track.c @@ -214,7 +214,13 @@ static bool track_markers_initjob(bContext *C, TrackMarkersJob *tmj, bool backwa return true; } -static void track_markers_startjob(void *tmv, short *stop, short *do_update, float *progress) +static void track_markers_startjob( + void *tmv, + /* Cannot be const, this function implements wm_jobs_start_callback. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + short *stop, + short *do_update, + float *progress) { TrackMarkersJob *tmj = (TrackMarkersJob *)tmv; int framenr = tmj->sfra; diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 81cc858c69f..b6f9ca9589f 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -731,7 +731,9 @@ void CLIP_OT_select_lasso(wmOperatorType *ot) /********************** circle select operator *********************/ -static int point_inside_ellipse(float point[2], float offset[2], float ellipse[2]) +static int point_inside_ellipse(const float point[2], + const float offset[2], + const float ellipse[2]) { /* normalized ellipse: ell[0] = scaleX, ell[1] = scaleY */ float x, y; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index cb785495ad5..3ce80c11160 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -2660,9 +2660,9 @@ static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist) if (filelist->dir[0] == 0) { /* make directories */ # ifdef WITH_FREESTYLE - filelist->filelist.nbr_entries = 27; + filelist->filelist.nbr_entries = 27; # else - filelist->filelist.nbr_entries = 26; + filelist->filelist.nbr_entries = 26; # endif filelist_resize(filelist, filelist->filelist.nbr_entries); @@ -2693,11 +2693,11 @@ static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist) filelist->filelist.entries[20].entry->relpath = BLI_strdup("Action"); filelist->filelist.entries[21].entry->relpath = BLI_strdup("NodeTree"); filelist->filelist.entries[22].entry->relpath = BLI_strdup("Speaker"); - filelist->filelist.entries[23].entry->relpath = BLI_strdup("Hair"); - filelist->filelist.entries[24].entry->relpath = BLI_strdup("Point Cloud"); - filelist->filelist.entries[25].entry->relpath = BLI_strdup("Volume"); + filelist->filelist.entries[23].entry->relpath = BLI_strdup("Hair"); + filelist->filelist.entries[24].entry->relpath = BLI_strdup("Point Cloud"); + filelist->filelist.entries[25].entry->relpath = BLI_strdup("Volume"); # ifdef WITH_FREESTYLE - filelist->filelist.entries[26].entry->relpath = BLI_strdup("FreestyleLineStyle"); + filelist->filelist.entries[26].entry->relpath = BLI_strdup("FreestyleLineStyle"); # endif } else { @@ -2809,7 +2809,7 @@ static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist) static void filelist_readjob_do(const bool do_lib, FileList *filelist, const char *main_name, - short *stop, + const short *stop, short *do_update, float *progress, ThreadMutex *lock) diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index e6c40dce9c8..88c8c6b2939 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -374,7 +374,7 @@ void ED_fileselect_set_params_from_userdef(SpaceFile *sfile) * pass its size here so we can store that in the preferences. Otherwise NULL. */ void ED_fileselect_params_to_userdef(SpaceFile *sfile, - int temp_win_size[2], + const int temp_win_size[2], const bool is_maximized) { UserDef_FileSpaceData *sfile_udata_new = &U.file_space_data; diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index d1f26dd37c9..4b329ab4524 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -1129,10 +1129,13 @@ int fsmenu_get_active_indices(struct FSMenu *fsmenu, enum FSMenuCategory categor * before being defined as unreachable by the OS, we need to validate the bookmarks in an async * job... */ -static void fsmenu_bookmark_validate_job_startjob(void *fsmenuv, - short *stop, - short *do_update, - float *UNUSED(progress)) +static void fsmenu_bookmark_validate_job_startjob( + void *fsmenuv, + /* Cannot be const, this function implements wm_jobs_start_callback. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + short *stop, + short *do_update, + float *UNUSED(progress)) { FSMenu *fsmenu = fsmenuv; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 24ec2393b69..1f8dd7cfe44 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -572,8 +572,12 @@ static void image_multiview_cb(bContext *C, void *rnd_pt, void *UNUSED(arg_v)) WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL); } -static void uiblock_layer_pass_buttons( - uiLayout *layout, Image *image, RenderResult *rr, ImageUser *iuser, int w, short *render_slot) +static void uiblock_layer_pass_buttons(uiLayout *layout, + Image *image, + RenderResult *rr, + ImageUser *iuser, + int w, + const short *render_slot) { struct ImageUI_Data rnd_pt_local, *rnd_pt = NULL; uiBlock *block = uiLayoutGetBlock(layout); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 9040ca5e79c..a7fa7709c51 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -150,8 +150,8 @@ void ED_image_draw_info(Scene *scene, const uchar cp[4], const float fp[4], const float linearcol[4], - int *zp, - float *zpf) + const int *zp, + const float *zpf) { rcti color_rect; char str[256]; @@ -463,7 +463,7 @@ void ED_image_draw_info(Scene *scene, /* image drawing */ static void sima_draw_zbuf_pixels( - float x1, float y1, int rectx, int recty, int *rect, float zoomx, float zoomy) + float x1, float y1, int rectx, int recty, const int *rect, float zoomx, float zoomy) { float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; @@ -489,7 +489,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float y1, int rectx, int recty, - float *rect_float, + const float *rect_float, float zoomx, float zoomy) { diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index f3207f2dc1e..780c3d6a217 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -860,11 +860,13 @@ static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), Poin if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NISHITA) { uiItemR(layout, ptr, "sun_disc", DEFAULT_FLAGS, NULL, 0); + uiLayout *col; if (RNA_boolean_get(ptr, "sun_disc")) { - uiItemR(layout, ptr, "sun_size", DEFAULT_FLAGS, NULL, ICON_NONE); + col = uiLayoutColumn(layout, true); + uiItemR(col, ptr, "sun_size", DEFAULT_FLAGS, NULL, ICON_NONE); + uiItemR(col, ptr, "sun_intensity", DEFAULT_FLAGS, NULL, ICON_NONE); } - uiLayout *col; col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "sun_elevation", DEFAULT_FLAGS, NULL, ICON_NONE); uiItemR(col, ptr, "sun_rotation", DEFAULT_FLAGS, NULL, ICON_NONE); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 11d87148713..7af64e75656 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -238,7 +238,12 @@ static void compo_progressjob(void *cjv, float progress) } /* only this runs inside thread */ -static void compo_startjob(void *cjv, short *stop, short *do_update, float *progress) +static void compo_startjob(void *cjv, + /* Cannot be const, this function implements wm_jobs_start_callback. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + short *stop, + short *do_update, + float *progress) { CompoJob *cj = cjv; bNodeTree *ntree = cj->localtree; diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index b1dbe3bc506..b376c6b29cf 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -419,7 +419,7 @@ static void sample_draw(const bContext *C, ARegion *region, void *arg_info) * And here we've got recursion in the comments tips... */ bool ED_space_node_color_sample( - Main *bmain, SpaceNode *snode, ARegion *region, int mval[2], float r_col[3]) + Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3]) { void *lock; Image *ima; diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 419e25d5dca..f0287984268 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -54,6 +54,7 @@ #include "BKE_context.h" #include "BKE_fcurve.h" #include "BKE_global.h" +#include "BKE_idtype.h" #include "BKE_layer.h" #include "BKE_lib_id.h" #include "BKE_lib_override.h" @@ -739,22 +740,63 @@ static void id_local_cb(bContext *C, } } +typedef struct OutlinerLibOverrideData { + bool do_hierarchy; +} OutlinerLibOverrideData; + static void id_override_library_cb(bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), - TreeElement *UNUSED(te), + TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, - void *UNUSED(user_data)) + void *user_data) { - if (ID_IS_OVERRIDABLE_LIBRARY(tselem->id)) { + BLI_assert(TSE_IS_REAL_ID(tselem)); + ID *id_root = tselem->id; + + if (ID_IS_LINKED(id_root) && + (BKE_idtype_get_info_from_id(id_root)->flags & IDTYPE_FLAGS_NO_LIBLINKING) == 0) { Main *bmain = CTX_data_main(C); + OutlinerLibOverrideData *data = user_data; + const bool do_hierarchy = data->do_hierarchy; + + id_root->tag |= LIB_TAG_DOIT; + + printf("%s: Tagging root id %s\n", __func__, id_root->name); + /* For now, remapp all local usages of linked ID to local override one here. */ - BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, true); - ID *override_id = BKE_lib_override_library_create_from_id(bmain, tselem->id, true); - if (override_id != NULL) { - BKE_main_id_clear_newpoins(bmain); + ID *id_iter; + FOREACH_MAIN_ID_BEGIN (bmain, id_iter) { + if (ID_IS_LINKED(id_iter)) { + id_iter->tag &= ~LIB_TAG_DOIT; + } + else { + id_iter->tag |= LIB_TAG_DOIT; + } + } + FOREACH_MAIN_ID_END; + + if (do_hierarchy) { + /* Tag all linked parents in tree hierarchy to be also overridden. */ + while ((te = te->parent) != NULL) { + if (!TSE_IS_REAL_ID(te->store_elem)) { + continue; + } + if (!ID_IS_LINKED(te->store_elem->id)) { + break; + } + te->store_elem->id->tag |= LIB_TAG_DOIT; + printf("%s: Tagging parent id %s\n", __func__, te->store_elem->id->name); + } + BKE_lib_override_library_dependencies_tag(bmain, id_root, LIB_TAG_DOIT, true); + BKE_lib_override_library_create_from_tag(bmain); } + else if (ID_IS_OVERRIDABLE_LIBRARY(id_root)) { + BKE_lib_override_library_create_from_id(bmain, id_root, true); + } + + BKE_main_id_clear_newpoins(bmain); BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); } } @@ -1326,8 +1368,8 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) } else if (event == OL_OP_REMAP) { outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_remap_cb, NULL); - /* No undo push here, operator does it itself (since it's a modal one, the op_undo_depth trick - * does not work here). */ + /* No undo push here, operator does it itself (since it's a modal one, the op_undo_depth + * trick does not work here). */ } else if (event == OL_OP_LOCALIZED) { /* disabled, see above enum (ton) */ outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, id_local_cb); @@ -1508,6 +1550,7 @@ typedef enum eOutlinerIdOpTypes { OUTLINER_IDOP_UNLINK, OUTLINER_IDOP_LOCAL, OUTLINER_IDOP_OVERRIDE_LIBRARY, + OUTLINER_IDOP_OVERRIDE_LIBRARY_HIERARCHY, OUTLINER_IDOP_SINGLE, OUTLINER_IDOP_DELETE, OUTLINER_IDOP_REMAP, @@ -1531,6 +1574,11 @@ static const EnumPropertyItem prop_id_op_types[] = { 0, "Add Library Override", "Add a local override of this linked data-block"}, + {OUTLINER_IDOP_OVERRIDE_LIBRARY_HIERARCHY, + "OVERRIDE_LIBRARY_HIERARCHY", + 0, + "Add Library Override Hierarchy", + "Add a local override of this linked data-block, and its hierarchy of dependencies"}, {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""}, {OUTLINER_IDOP_DELETE, "DELETE", ICON_X, "Delete", ""}, {OUTLINER_IDOP_REMAP, @@ -1563,7 +1611,7 @@ static bool outliner_id_operation_item_poll(bContext *C, switch (enum_value) { case OUTLINER_IDOP_OVERRIDE_LIBRARY: - return BKE_lib_override_library_is_enabled(); + return true; case OUTLINER_IDOP_SINGLE: if (!soops || ELEM(soops->outlinevis, SO_SCENES, SO_VIEW_LAYER)) { return true; @@ -1677,12 +1725,27 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } case OUTLINER_IDOP_OVERRIDE_LIBRARY: { - if (BKE_lib_override_library_is_enabled()) { - /* make local */ - outliner_do_libdata_operation( - C, op->reports, scene, soops, &soops->tree, id_override_library_cb, NULL); - ED_undo_push(C, "Overridden Data"); - } + /* make local */ + outliner_do_libdata_operation(C, + op->reports, + scene, + soops, + &soops->tree, + id_override_library_cb, + &(OutlinerLibOverrideData){.do_hierarchy = false}); + ED_undo_push(C, "Overridden Data"); + break; + } + case OUTLINER_IDOP_OVERRIDE_LIBRARY_HIERARCHY: { + /* make local */ + outliner_do_libdata_operation(C, + op->reports, + scene, + soops, + &soops->tree, + id_override_library_cb, + &(OutlinerLibOverrideData){.do_hierarchy = true}); + ED_undo_push(C, "Overridden Data"); break; } case OUTLINER_IDOP_SINGLE: { diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index a20d9a2942c..80b1c7a5194 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -50,14 +50,14 @@ static void rgb_to_yuv_normalized(const float rgb[3], float yuv[3]) yuv[2] += 0.5f; } -static void scope_put_pixel(uchar *table, uchar *pos) +static void scope_put_pixel(const uchar *table, uchar *pos) { uchar newval = table[*pos]; pos[0] = pos[1] = pos[2] = newval; pos[3] = 255; } -static void scope_put_pixel_single(uchar *table, uchar *pos, int col) +static void scope_put_pixel_single(const uchar *table, uchar *pos, int col) { char newval = table[pos[col]]; pos[col] = newval; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b7d857fb172..fc763d91e3d 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1572,7 +1572,7 @@ void VIEW3D_OT_select_menu(wmOperatorType *ot) static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, - uint *buffer, + const uint *buffer, int hits, const int mval[2], bool extend, diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index d3e509fe96b..0d121b23c71 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -1028,8 +1028,11 @@ void ED_view3d_autodist_init(Depsgraph *depsgraph, ARegion *region, View3D *v3d, } /* no 4x4 sampling, run #ED_view3d_autodist_init first */ -bool ED_view3d_autodist_simple( - ARegion *region, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) +bool ED_view3d_autodist_simple(ARegion *region, + const int mval[2], + float mouse_worldloc[3], + int margin, + const float *force_depth) { float depth; @@ -1458,7 +1461,7 @@ bool ED_view3d_lock(RegionView3D *rv3d) * \param quat: The view rotation, quaternion normally from RegionView3D.viewquat. * \param dist: The view distance from ofs, normally from RegionView3D.dist. */ -void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float *dist) +void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], const float *dist) { float nmat[3][3]; diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index d68489759fe..70004d27dfc 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -27,6 +27,7 @@ #include "MEM_guardedalloc.h" #include "BLI_kdtree.h" +#include "BLI_linklist_stack.h" #include "BLI_listbase.h" #include "BLI_math.h" @@ -409,59 +410,66 @@ void transform_autoik_update(TransInfo *t, short mode) /** \name Curve Surface * \{ */ -void calc_distanceCurveVerts(TransData *head, TransData *tail) +void calc_distanceCurveVerts(TransData *head, TransData *tail, bool cyclic) { - TransData *td, *td_near = NULL; + TransData *td; + BLI_LINKSTACK_DECLARE(queue, TransData *); + BLI_LINKSTACK_INIT(queue); for (td = head; td <= tail; td++) { if (td->flag & TD_SELECTED) { - td_near = td; td->dist = 0.0f; + BLI_LINKSTACK_PUSH(queue, td); } - else if (td_near) { - float dist; - float vec[3]; + else { + td->dist = FLT_MAX; + } + } + + while ((td = BLI_LINKSTACK_POP(queue))) { + float dist; + float vec[3]; + + TransData *next_td = NULL; - sub_v3_v3v3(vec, td_near->center, td->center); + if (td + 1 <= tail) { + next_td = td + 1; + } + else if (cyclic) { + next_td = head; + } + + if (next_td != NULL && !(next_td->flag & TD_NOTCONNECTED)) { + sub_v3_v3v3(vec, next_td->center, td->center); mul_m3_v3(head->mtx, vec); - dist = len_v3(vec); + dist = len_v3(vec) + td->dist; - if (dist < (td - 1)->dist) { - td->dist = (td - 1)->dist; - } - else { - td->dist = dist; + if (dist < next_td->dist) { + next_td->dist = dist; + BLI_LINKSTACK_PUSH(queue, next_td); } } - else { - td->dist = FLT_MAX; - td->flag |= TD_NOTCONNECTED; + + next_td = NULL; + + if (td - 1 >= head) { + next_td = td - 1; } - } - td_near = NULL; - for (td = tail; td >= head; td--) { - if (td->flag & TD_SELECTED) { - td_near = td; - td->dist = 0.0f; + else if (cyclic) { + next_td = tail; } - else if (td_near) { - float dist; - float vec[3]; - sub_v3_v3v3(vec, td_near->center, td->center); + if (next_td != NULL && !(next_td->flag & TD_NOTCONNECTED)) { + sub_v3_v3v3(vec, next_td->center, td->center); mul_m3_v3(head->mtx, vec); - dist = len_v3(vec); + dist = len_v3(vec) + td->dist; - if (td->flag & TD_NOTCONNECTED || dist < td->dist || (td + 1)->dist < td->dist) { - td->flag &= ~TD_NOTCONNECTED; - if (dist < (td + 1)->dist) { - td->dist = (td + 1)->dist; - } - else { - td->dist = dist; - } + if (dist < next_td->dist) { + next_td->dist = dist; + BLI_LINKSTACK_PUSH(queue, next_td); } } } + BLI_LINKSTACK_FREE(queue); } /* Utility function for getting the handle data from bezier's */ @@ -1270,6 +1278,9 @@ void createTransData(bContext *C, TransInfo *t) set_prop_dist(t, false); } } + else if (convert_type == TC_MESH_UV && t->flag & T_PROP_CONNECTED) { + /* Already calculated by uv_set_connectivity_distance. */ + } else if (convert_type == TC_CURVE_VERTS && t->obedit_type == OB_CURVE) { set_prop_dist(t, false); } diff --git a/source/blender/editors/transform/transform_convert.h b/source/blender/editors/transform/transform_convert.h index f7eea286983..ee478ad8567 100644 --- a/source/blender/editors/transform/transform_convert.h +++ b/source/blender/editors/transform/transform_convert.h @@ -87,7 +87,7 @@ void transform_around_single_fallback_ex(TransInfo *t, int data_len_all); void transform_around_single_fallback(TransInfo *t); void posttrans_fcurve_clean(struct FCurve *fcu, const int sel_flag, const bool use_handle); bool constraints_list_needinv(TransInfo *t, ListBase *list); -void calc_distanceCurveVerts(TransData *head, TransData *tail); +void calc_distanceCurveVerts(TransData *head, TransData *tail, bool cyclic); struct TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTriple *bezt); char transform_convert_frame_side_dir_get(TransInfo *t, float cframe); bool FrameOnMouseSide(char side, float frame, float cframe); diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c index 37e37072ed7..65b2c9f9382 100644 --- a/source/blender/editors/transform/transform_convert_curve.c +++ b/source/blender/editors/transform/transform_convert_curve.c @@ -350,12 +350,14 @@ void createTransCurveVerts(TransInfo *t) (void)hdata; /* quiet warning */ } else if (is_prop_edit && head != tail) { - calc_distanceCurveVerts(head, tail - 1); - head = tail; + tail->flag |= TD_NOTCONNECTED; + td++; + tail++; } } if (is_prop_edit && head != tail) { - calc_distanceCurveVerts(head, tail - 1); + bool cyclic = (nu->flagu & CU_NURB_CYCLIC) != 0; + calc_distanceCurveVerts(head, tail - 1, cyclic); } /* TODO - in the case of tilt and radius we can also avoid allocating the @@ -425,12 +427,14 @@ void createTransCurveVerts(TransInfo *t) } } else if (is_prop_edit && head != tail) { - calc_distanceCurveVerts(head, tail - 1); - head = tail; + tail->flag |= TD_NOTCONNECTED; + td++; + tail++; } } if (is_prop_edit && head != tail) { - calc_distanceCurveVerts(head, tail - 1); + bool cyclic = (nu->flagu & CU_NURB_CYCLIC) != 0; + calc_distanceCurveVerts(head, tail - 1, cyclic); } } } diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c index 22261b9bbd8..0eb12aeabed 100644 --- a/source/blender/editors/transform/transform_convert_gpencil.c +++ b/source/blender/editors/transform/transform_convert_gpencil.c @@ -354,7 +354,7 @@ void createTransGPencil(bContext *C, TransInfo *t) /* March over these points, and calculate the proportional editing distances */ if (is_prop_edit && (head != tail)) { - calc_distanceCurveVerts(head, tail - 1); + calc_distanceCurveVerts(head, tail - 1, false); } } } diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 90e45253afa..f067dd60c19 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -1067,7 +1067,7 @@ static void create_trans_vert_customdata_layer(BMVert *v, BLI_ghash_insert(tcld->origverts, v, r_tcld_vert); } -static void trans_mesh_customdata_correction_init_container(TransInfo *t, TransDataContainer *tc) +static void trans_mesh_customdata_correction_init_container(TransDataContainer *tc) { if (tc->custom.type.data) { /* Custom data correction has initiated before. */ @@ -1075,23 +1075,6 @@ static void trans_mesh_customdata_correction_init_container(TransInfo *t, TransD return; } - if (!ELEM(t->mode, - TFM_TRANSLATION, - TFM_ROTATION, - TFM_RESIZE, - TFM_TOSPHERE, - TFM_SHEAR, - TFM_BEND, - TFM_SHRINKFATTEN, - TFM_TRACKBALL, - TFM_PUSHPULL, - TFM_ALIGN, - TFM_EDGE_SLIDE, - TFM_VERT_SLIDE)) { - /* Currently only modes that change the position of vertices are supported. */ - return; - } - BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); BMesh *bm = em->bm; @@ -1173,13 +1156,63 @@ static void trans_mesh_customdata_correction_init_container(TransInfo *t, TransD void trans_mesh_customdata_correction_init(TransInfo *t) { + if (!ELEM(t->mode, + TFM_TRANSLATION, + TFM_ROTATION, + TFM_RESIZE, + TFM_TOSPHERE, + TFM_SHEAR, + TFM_BEND, + TFM_SHRINKFATTEN, + TFM_TRACKBALL, + TFM_PUSHPULL, + TFM_ALIGN, + TFM_EDGE_SLIDE, + TFM_VERT_SLIDE)) { + /* Currently only modes that change the position of vertices are supported. */ + return; + } + const char uvcalc_correct_flag = ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE) ? UVCALC_TRANSFORM_CORRECT_SLIDE : UVCALC_TRANSFORM_CORRECT; if (t->settings->uvcalc_flag & uvcalc_correct_flag) { FOREACH_TRANS_DATA_CONTAINER (t, tc) { - trans_mesh_customdata_correction_init_container(t, tc); + trans_mesh_customdata_correction_init_container(tc); + } + } +} + +static void trans_mesh_customdata_correction_restore(struct TransDataContainer *tc) +{ + struct TransCustomDataLayer *tcld = tc->custom.type.data; + if (!tcld) { + return; + } + + BMesh *bm = tcld->bm; + struct TransCustomDataLayerVert *tcld_vert_iter = &tcld->data[0]; + for (int i = tcld->data_len; i--; tcld_vert_iter++) { + BMLoop *l; + BMIter liter; + BMVert *v = tcld_vert_iter->v; + BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { + /* Pop the key to not restore the face again. */ + BMFace *f_copy = BLI_ghash_popkey(tcld->origfaces, l->f, NULL); + if (f_copy) { + BMLoop *l_iter_a, *l_first_a; + BMLoop *l_iter_b, *l_first_b; + l_iter_a = l_first_a = BM_FACE_FIRST_LOOP(f_copy); + l_iter_b = l_first_b = BM_FACE_FIRST_LOOP(l->f); + do { + BM_elem_attrs_copy(tcld->bm_origfaces, bm, l_iter_a, l_iter_b); + } while (((l_iter_a = l_iter_a->next) != l_first_a) && + ((l_iter_b = l_iter_b->next) != l_first_b)); + + BM_elem_attrs_copy_ex( + tcld->bm_origfaces, bm, f_copy, l->f, BM_ELEM_SELECT, CD_MASK_NORMAL); + } } } } @@ -1195,7 +1228,7 @@ static const float *trans_vert_orig_co_get(struct TransCustomDataLayer *tcld, BM static void trans_mesh_customdata_correction_apply_vert(struct TransCustomDataLayer *tcld, struct TransCustomDataLayerVert *tcld_vert, - bool is_final) + bool do_loop_mdisps) { BMesh *bm = tcld->bm; BMVert *v = tcld_vert->v; @@ -1295,8 +1328,8 @@ static void trans_mesh_customdata_correction_apply_vert(struct TransCustomDataLa * Interpolate from every other loop (not ideal) * However values will only be taken from loops which overlap other mdisps. * */ - const bool do_loop_mdisps = is_moved && is_final && (tcld->cd_loop_mdisp_offset != -1); - if (do_loop_mdisps) { + const bool update_loop_mdisps = is_moved && do_loop_mdisps && (tcld->cd_loop_mdisp_offset != -1); + if (update_loop_mdisps) { float(*faces_center)[3] = BLI_array_alloca(faces_center, l_num); BMLoop *l; @@ -1332,12 +1365,12 @@ static void trans_mesh_customdata_correction_apply(struct TransDataContainer *tc return; } - const bool has_mdisps = (tcld->cd_loop_mdisp_offset != -1); + const bool do_loop_mdisps = is_final && (tcld->cd_loop_mdisp_offset != -1); struct TransCustomDataLayerVert *tcld_vert_iter = &tcld->data[0]; for (int i = tcld->data_len; i--; tcld_vert_iter++) { - if (tcld_vert_iter->cd_loop_groups || has_mdisps) { - trans_mesh_customdata_correction_apply_vert(tcld, tcld_vert_iter, is_final); + if (tcld_vert_iter->cd_loop_groups || do_loop_mdisps) { + trans_mesh_customdata_correction_apply_vert(tcld, tcld_vert_iter, do_loop_mdisps); } } } @@ -1388,8 +1421,9 @@ static void transform_apply_to_mirror(TransInfo *t) void recalcData_mesh(TransInfo *t) { + bool is_cancelling = t->state == TRANS_CANCEL; /* mirror modifier clipping? */ - if (t->state != TRANS_CANCEL) { + if (!is_cancelling) { /* apply clipping after so we never project past the clip plane [#25423] */ applyProject(t); clipMirrorModifier(t); @@ -1400,7 +1434,12 @@ void recalcData_mesh(TransInfo *t) } FOREACH_TRANS_DATA_CONTAINER (t, tc) { - trans_mesh_customdata_correction_apply(tc, false); + if (is_cancelling) { + trans_mesh_customdata_correction_restore(tc); + } + else { + trans_mesh_customdata_correction_apply(tc, false); + } DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */ BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); @@ -1416,15 +1455,15 @@ void recalcData_mesh(TransInfo *t) void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t) { - const bool canceled = (t->state == TRANS_CANCEL); - const bool use_automerge = !canceled && (t->flag & (T_AUTOMERGE | T_AUTOSPLIT)) != 0; + const bool is_cancelling = (t->state == TRANS_CANCEL); + const bool use_automerge = !is_cancelling && (t->flag & (T_AUTOMERGE | T_AUTOSPLIT)) != 0; - if (TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.type.data != NULL) { + if (!is_cancelling && TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.type.data != NULL) { /* Handle multires re-projection, done * on transform completion since it's * really slow -joeedh. */ FOREACH_TRANS_DATA_CONTAINER (t, tc) { - trans_mesh_customdata_correction_apply(tc, !canceled); + trans_mesh_customdata_correction_apply(tc, true); } } diff --git a/source/blender/editors/transform/transform_convert_mesh_uv.c b/source/blender/editors/transform/transform_convert_mesh_uv.c index 41c09cd8ea2..56fa2d90fb2 100644 --- a/source/blender/editors/transform/transform_convert_mesh_uv.c +++ b/source/blender/editors/transform/transform_convert_mesh_uv.c @@ -26,6 +26,7 @@ #include "MEM_guardedalloc.h" #include "BLI_bitmap.h" +#include "BLI_linklist_stack.h" #include "BLI_math.h" #include "BKE_context.h" @@ -51,12 +52,13 @@ static void UVsToTransData(const float aspect[2], TransData2D *td2d, float *uv, const float *center, + float calc_dist, bool selected) { - /* uv coords are scaled by aspects. this is needed for rotations and - * proportional editing to be consistent with the stretched uv coords - * that are displayed. this also means that for display and numinput, - * and when the uv coords are flushed, these are converted each time */ + /* UV coords are scaled by aspects. this is needed for rotations and + * proportional editing to be consistent with the stretched UV coords + * that are displayed. this also means that for display and number-input, + * and when the UV coords are flushed, these are converted each time. */ td2d->loc[0] = uv[0] * aspect[0]; td2d->loc[1] = uv[1] * aspect[1]; td2d->loc[2] = 0.0f; @@ -79,12 +81,182 @@ static void UVsToTransData(const float aspect[2], td->dist = 0.0; } else { - td->dist = FLT_MAX; + td->dist = calc_dist; } unit_m3(td->mtx); unit_m3(td->smtx); } +/** + * \param dists: Store the closest connected distance to selected vertices. + */ +static void uv_set_connectivity_distance(BMesh *bm, float *dists, const float aspect[2]) +{ + /* Mostly copied from editmesh_set_connectivity_distance. */ + BLI_LINKSTACK_DECLARE(queue, BMLoop *); + + /* Any BM_ELEM_TAG'd loop is added to 'queue_next', this makes sure that we don't add things + * twice. */ + BLI_LINKSTACK_DECLARE(queue_next, BMLoop *); + + BLI_LINKSTACK_INIT(queue); + BLI_LINKSTACK_INIT(queue_next); + + const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); + BMIter fiter, liter; + BMVert *f; + BMLoop *l; + + BM_mesh_elem_index_ensure(bm, BM_LOOP); + + BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { + /* Visable faces was tagged in createTransUVs. */ + if (!BM_elem_flag_test(f, BM_ELEM_TAG)) { + continue; + } + + BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { + float dist; + MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + + bool uv_vert_sel = luv->flag & MLOOPUV_VERTSEL; + + if (uv_vert_sel) { + BLI_LINKSTACK_PUSH(queue, l); + dist = 0.0f; + } + else { + dist = FLT_MAX; + } + + /* Make sure all loops are in a clean tag state. */ + BLI_assert(BM_elem_flag_test(l, BM_ELEM_TAG) == 0); + + int loop_idx = BM_elem_index_get(l); + + dists[loop_idx] = dist; + } + } + + /* Need to be very careful of feedback loops here, store previous dist's to avoid feedback. */ + float *dists_prev = MEM_dupallocN(dists); + + do { + while ((l = BLI_LINKSTACK_POP(queue))) { + BLI_assert(dists[BM_elem_index_get(l)] != FLT_MAX); + + BMLoop *l_other, *l_connected; + BMIter l_connected_iter; + + MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + float l_uv[2]; + + copy_v2_v2(l_uv, luv->uv); + mul_v2_v2(l_uv, aspect); + + BM_ITER_ELEM (l_other, &liter, l->f, BM_LOOPS_OF_FACE) { + if (l_other == l) { + continue; + } + float other_uv[2], edge_vec[2]; + MLoopUV *luv_other = BM_ELEM_CD_GET_VOID_P(l_other, cd_loop_uv_offset); + + copy_v2_v2(other_uv, luv_other->uv); + mul_v2_v2(other_uv, aspect); + + sub_v2_v2v2(edge_vec, l_uv, other_uv); + + const int i = BM_elem_index_get(l); + const int i_other = BM_elem_index_get(l_other); + float dist = len_v2(edge_vec) + dists_prev[i]; + + if (dist < dists[i_other]) { + dists[i_other] = dist; + } + else { + /* The face loop already has a shorter path to it. */ + continue; + } + + float connected_uv[2]; + float uvdiff[2]; + + bool other_vert_sel, connected_vert_sel; + + other_vert_sel = luv_other->flag & MLOOPUV_VERTSEL; + + BM_ITER_ELEM (l_connected, &l_connected_iter, l_other->v, BM_LOOPS_OF_VERT) { + if (l_connected == l_other) { + continue; + } + /* Visable faces was tagged in createTransUVs. */ + if (!BM_elem_flag_test(l_connected->f, BM_ELEM_TAG)) { + continue; + } + + MLoopUV *luv_connected = BM_ELEM_CD_GET_VOID_P(l_connected, cd_loop_uv_offset); + connected_vert_sel = luv_connected->flag & MLOOPUV_VERTSEL; + copy_v2_v2(connected_uv, luv_connected->uv); + mul_v2_v2(connected_uv, aspect); + + sub_v2_v2v2(uvdiff, connected_uv, other_uv); + /* Check if this loop is connected in UV space. + * If the uv loops share the same selection state (if not, they are not connected as + * they have been ripped or other edit commands have separated them). */ + bool connected = other_vert_sel == connected_vert_sel && + fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT && + fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT; + if (!connected) { + continue; + } + + /* The loop vert is occupying the same space, so it has the same distance. */ + const int i_connected = BM_elem_index_get(l_connected); + dists[i_connected] = dist; + + if (BM_elem_flag_test(l_connected, BM_ELEM_TAG) == 0) { + BM_elem_flag_enable(l_connected, BM_ELEM_TAG); + BLI_LINKSTACK_PUSH(queue_next, l_connected); + } + } + } + } + + /* Clear elem flags for the next loop. */ + for (LinkNode *lnk = queue_next; lnk; lnk = lnk->next) { + BMLoop *l_link = lnk->link; + const int i = BM_elem_index_get(l_link); + + BM_elem_flag_disable(l_link, BM_ELEM_TAG); + + /* Store all new dist values. */ + dists_prev[i] = dists[i]; + } + + BLI_LINKSTACK_SWAP(queue, queue_next); + + } while (BLI_LINKSTACK_SIZE(queue)); + +#ifndef NDEBUG + /* Check that we didn't leave any loops tagged */ + BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { + /* Visable faces was tagged in createTransUVs. */ + if (!BM_elem_flag_test(f, BM_ELEM_TAG)) { + continue; + } + + BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { + BLI_assert(BM_elem_flag_test(l, BM_ELEM_TAG) == 0); + } + } +#endif + + BLI_LINKSTACK_FREE(queue); + BLI_LINKSTACK_FREE(queue_next); + + MEM_freeN(dists_prev); +} + void createTransUVs(bContext *C, TransInfo *t) { SpaceImage *sima = CTX_wm_space_image(C); @@ -103,12 +275,11 @@ void createTransUVs(bContext *C, TransInfo *t) BMFace *efa; BMIter iter, liter; UvElementMap *elementmap = NULL; - BLI_bitmap *island_enabled = NULL; struct { float co[2]; int co_num; } *island_center = NULL; - int count = 0, countsel = 0, count_rejected = 0; + int count = 0, countsel = 0; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); if (!ED_space_image_show_uvedit(sima, tc->obedit)) { @@ -116,22 +287,15 @@ void createTransUVs(bContext *C, TransInfo *t) } /* count */ - if (is_prop_connected || is_island_center) { + if (is_island_center) { /* create element map with island information */ const bool use_facesel = (ts->uv_flag & UV_SYNC_SELECTION) == 0; - const bool use_uvsel = !is_prop_connected; - elementmap = BM_uv_element_map_create(em->bm, scene, use_facesel, use_uvsel, false, true); + elementmap = BM_uv_element_map_create(em->bm, scene, use_facesel, true, false, true); if (elementmap == NULL) { continue; } - if (is_prop_connected) { - island_enabled = BLI_BITMAP_NEW(elementmap->totalIslands, "TransIslandData(UV Editing)"); - } - - if (is_island_center) { - island_center = MEM_callocN(sizeof(*island_center) * elementmap->totalIslands, __func__); - } + island_center = MEM_callocN(sizeof(*island_center) * elementmap->totalIslands, __func__); } BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { @@ -147,20 +311,14 @@ void createTransUVs(bContext *C, TransInfo *t) if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { countsel++; - if (is_prop_connected || island_center) { + if (island_center) { UvElement *element = BM_uv_element_get(elementmap, efa, l); - if (is_prop_connected) { - BLI_BITMAP_ENABLE(island_enabled, element->island); - } - - if (is_island_center) { - if (element->flag == false) { - MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - add_v2_v2(island_center[element->island].co, luv->uv); - island_center[element->island].co_num++; - element->flag = true; - } + if (element->flag == false) { + MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + add_v2_v2(island_center[element->island].co, luv->uv); + island_center[element->island].co_num++; + element->flag = true; } } } @@ -198,6 +356,14 @@ void createTransUVs(bContext *C, TransInfo *t) td = tc->data; td2d = tc->data_2d; + float *prop_dists = NULL; + + if (is_prop_connected) { + prop_dists = MEM_callocN(em->bm->totloop * sizeof(float), "TransObPropDists(UV Editing)"); + + uv_set_connectivity_distance(em->bm, prop_dists, t->aspect); + } + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { BMLoop *l; @@ -209,52 +375,41 @@ void createTransUVs(bContext *C, TransInfo *t) const bool selected = uvedit_uv_select_test(scene, l, cd_loop_uv_offset); MLoopUV *luv; const float *center = NULL; + float prop_distance = FLT_MAX; if (!is_prop_edit && !selected) { continue; } - if (is_prop_connected || is_island_center) { + if (is_prop_connected) { + const int idx = BM_elem_index_get(l); + prop_distance = prop_dists[idx]; + } + + if (is_island_center) { UvElement *element = BM_uv_element_get(elementmap, efa, l); if (element) { - if (is_prop_connected) { - if (!BLI_BITMAP_TEST(island_enabled, element->island)) { - count_rejected++; - continue; - } - } - - if (is_island_center) { - center = island_center[element->island].co; - } + center = island_center[element->island].co; } } - BM_elem_flag_enable(l, BM_ELEM_TAG); luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - UVsToTransData(t->aspect, td++, td2d++, luv->uv, center, selected); + UVsToTransData(t->aspect, td++, td2d++, luv->uv, center, prop_distance, selected); } } - if (is_prop_connected) { - tc->data_len -= count_rejected; - } - if (sima->flag & SI_LIVE_UNWRAP) { ED_uvedit_live_unwrap_begin(t->scene, tc->obedit); } finally: - if (is_prop_connected || is_island_center) { + if (is_prop_connected) { + MEM_freeN(prop_dists); + } + if (is_island_center) { BM_uv_element_map_free(elementmap); - if (is_prop_connected) { - MEM_freeN(island_enabled); - } - - if (island_center) { - MEM_freeN(island_center); - } + MEM_freeN(island_center); } } } diff --git a/source/blender/editors/transform/transform_convert_particle.c b/source/blender/editors/transform/transform_convert_particle.c index 3fa722d14cf..fbe9c07ebe9 100644 --- a/source/blender/editors/transform/transform_convert_particle.c +++ b/source/blender/editors/transform/transform_convert_particle.c @@ -183,7 +183,7 @@ void createTransParticleVerts(bContext *C, TransInfo *t) tail++; } if (is_prop_edit && head != tail) { - calc_distanceCurveVerts(head, tail - 1); + calc_distanceCurveVerts(head, tail - 1, false); } } } diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c index aee05197f10..cde06a9eaac 100644 --- a/source/blender/editors/transform/transform_mode_translate.c +++ b/source/blender/editors/transform/transform_mode_translate.c @@ -67,15 +67,27 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ dist = len_v3(t->num.val); } else { + int i = 0; float dvec[3]; - - copy_v3_v3(dvec, vec); - applyAspectRatio(t, dvec); + if (!(t->flag & T_2D_EDIT) && t->con.mode & CON_APPLY) { + zero_v3(dvec); + if (t->con.mode & CON_AXIS0) { + dvec[i++] = vec[0]; + } + if (t->con.mode & CON_AXIS1) { + dvec[i++] = vec[1]; + } + if (t->con.mode & CON_AXIS2) { + dvec[i++] = vec[2]; + } + } + else { + copy_v3_v3(dvec, vec); + applyAspectRatio(t, dvec); + } dist = len_v3(vec); if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) { - int i; - for (i = 0; i < 3; i++) { bUnit_AsString2(&tvec[NUM_STR_REP_LEN * i], NUM_STR_REP_LEN, diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c b/source/blender/editors/transform/transform_mode_vert_slide.c index 9e810b9c629..4bcc4cc6383 100644 --- a/source/blender/editors/transform/transform_mode_vert_slide.c +++ b/source/blender/editors/transform/transform_mode_vert_slide.c @@ -500,6 +500,10 @@ static void doVertSlide(TransInfo *t, float perc) FOREACH_TRANS_DATA_CONTAINER (t, tc) { VertSlideData *sld = tc->custom.mode.data; + if (sld == NULL) { + continue; + } + TransDataVertSlideVert *svlist = sld->sv, *sv; int i; diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 3af176f5aef..6dbf80ed4b9 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -1106,11 +1106,13 @@ static bool raycastObjects(SnapObjectContext *sctx, const float ray_start[3], const float ray_dir[3], /* read/write args */ - float *ray_depth, + /* Parameters below cannot be const, because they are assigned to a + * non-const variable (readability-non-const-parameter). */ + float *ray_depth /* NOLINT */, /* return args */ - float r_loc[3], - float r_no[3], - int *r_index, + float r_loc[3] /* NOLINT */, + float r_no[3] /* NOLINT */, + int *r_index /* NOLINT */, Object **r_ob, float r_obmat[4][4], ListBase *r_hit_list) @@ -2789,11 +2791,13 @@ static short snapObjectsRay(SnapObjectContext *sctx, SnapData *snapdata, const struct SnapObjectParams *params, /* read/write args */ - float *dist_px, + /* Parameters below cannot be const, because they are assigned to a + * non-const variable (readability-non-const-parameter). */ + float *dist_px /* NOLINT */, /* return args */ - float r_loc[3], - float r_no[3], - int *r_index, + float r_loc[3] /* NOLINT */, + float r_no[3] /* NOLINT */, + int *r_index /* NOLINT */, Object **r_ob, float r_obmat[4][4]) { diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 921b96f6023..a4ee9a294fe 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -487,7 +487,7 @@ static void p_chart_uv_scale_xy(PChart *chart, float x, float y) } } -static void p_chart_uv_translate(PChart *chart, float trans[2]) +static void p_chart_uv_translate(PChart *chart, const float trans[2]) { PVert *v; @@ -805,7 +805,7 @@ static PVert *p_vert_copy(PChart *chart, PVert *v) return nv; } -static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys) +static PEdge *p_edge_lookup(PHandle *handle, const PHashKey *vkeys) { PHashKey key = PHASH_edge(vkeys[0], vkeys[1]); PEdge *e = (PEdge *)phash_lookup(handle->hash_edges, key); @@ -1146,14 +1146,14 @@ static PFace *p_face_add(PHandle *handle) static PFace *p_face_add_construct(PHandle *handle, ParamKey key, - ParamKey *vkeys, + const ParamKey *vkeys, float *co[4], float *uv[4], int i1, int i2, int i3, - ParamBool *pin, - ParamBool *select) + const ParamBool *pin, + const ParamBool *select) { PFace *f = p_face_add(handle); PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next; diff --git a/source/blender/editors/uvedit/uvedit_rip.c b/source/blender/editors/uvedit/uvedit_rip.c index cd518e25971..562f0ce84c1 100644 --- a/source/blender/editors/uvedit/uvedit_rip.c +++ b/source/blender/editors/uvedit/uvedit_rip.c @@ -962,7 +962,7 @@ void UV_OT_rip(wmOperatorType *ot) ot->poll = ED_operator_uvedit; /* translation data */ - Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR_DUMMY); + Transform_Properties(ot, P_MIRROR_DUMMY); /* properties */ RNA_def_float_vector( diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index bae097a09bf..ddb276a663a 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -1477,7 +1477,7 @@ void UV_OT_select_all(wmOperatorType *ot) * \{ */ static bool uv_sticky_select( - float *limit, int hitv[], int v, float *hituv[], float *uv, int sticky, int hitlen) + const float *limit, const int hitv[], int v, float *hituv[], float *uv, int sticky, int hitlen) { int i; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 9e85ee296ff..29e10f03e3c 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -534,7 +534,7 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchStateContainer *ssc, StitchState *state, UVVertAverage *uv_average, - uint *uvfinal_map, + const uint *uvfinal_map, IslandStitchData *island_stitch_data) { BMesh *bm = state->em->bm; diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index 0af57e5d728..e1763514e08 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -222,7 +222,7 @@ void BlenderFileLoader::clipTriangle(int numTris, bool em1, bool em2, bool em3, - int clip[3]) + const int clip[3]) { float *v[3], *n[3]; bool em[3]; diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h index ad6379d5f52..d9387b221f8 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h @@ -128,7 +128,7 @@ class BlenderFileLoader { bool em1, bool em2, bool em3, - int clip[3]); + const int clip[3]); void addTriangle(struct LoaderState *ls, float v1[3], float v2[3], diff --git a/source/blender/freestyle/intern/scene_graph/SceneHash.cpp b/source/blender/freestyle/intern/scene_graph/SceneHash.cpp index b5d954664e4..e5f029d28b7 100644 --- a/source/blender/freestyle/intern/scene_graph/SceneHash.cpp +++ b/source/blender/freestyle/intern/scene_graph/SceneHash.cpp @@ -65,7 +65,7 @@ void SceneHash::visitIndexedFaceSet(IndexedFaceSet &ifs) static const int MOD_ADLER = 65521; -void SceneHash::adler32(unsigned char *data, int size) +void SceneHash::adler32(const unsigned char *data, int size) { uint32_t sum1 = _sum & 0xffff; uint32_t sum2 = (_sum >> 16) & 0xffff; diff --git a/source/blender/freestyle/intern/scene_graph/SceneHash.h b/source/blender/freestyle/intern/scene_graph/SceneHash.h index 53d1381da60..05c0880f806 100644 --- a/source/blender/freestyle/intern/scene_graph/SceneHash.h +++ b/source/blender/freestyle/intern/scene_graph/SceneHash.h @@ -67,7 +67,7 @@ class SceneHash : public SceneVisitor { } private: - void adler32(unsigned char *data, int size); + void adler32(const unsigned char *data, int size); uint32_t _sum; uint32_t _prevSum; diff --git a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp index 2df5ecd0867..cb3a297076a 100644 --- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp +++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp @@ -94,7 +94,7 @@ static inline bool crossesProscenium(real proscenium[4], FEdge *fe) return GeomUtils::intersect2dSeg2dArea(min, max, A, B); } -static inline bool insideProscenium(real proscenium[4], const Vec3r &point) +static inline bool insideProscenium(const real proscenium[4], const Vec3r &point) { return !(point[0] < proscenium[0] || point[0] > proscenium[1] || point[1] < proscenium[2] || point[1] > proscenium[3]); diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index b7de3a5b319..8ac272e92b5 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -1084,7 +1084,7 @@ static inline bool crossesProscenium(real proscenium[4], FEdge *fe) return GeomUtils::intersect2dSeg2dArea(min, max, A, B); } -static inline bool insideProscenium(real proscenium[4], const Vec3r &point) +static inline bool insideProscenium(const real proscenium[4], const Vec3r &point) { return !(point[0] < proscenium[0] || point[0] > proscenium[1] || point[1] < proscenium[2] || point[1] > proscenium[3]); diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index 17976c8acb0..7ec60809194 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -70,10 +70,11 @@ #include "BLI_index_mask.hh" #include "BLI_math_base.h" #include "BLI_string_ref.hh" +#include "BLI_utility_mixins.hh" namespace blender::fn { -class CPPType { +class CPPType : NonCopyable, NonMovable { public: using ConstructDefaultF = void (*)(void *ptr); using ConstructDefaultNF = void (*)(void *ptr, uint n); diff --git a/source/blender/functions/FN_multi_function.hh b/source/blender/functions/FN_multi_function.hh index c53959203cb..35f144368ac 100644 --- a/source/blender/functions/FN_multi_function.hh +++ b/source/blender/functions/FN_multi_function.hh @@ -73,6 +73,11 @@ class MultiFunction { return false; } + uint param_amount() const + { + return signature_.param_types.size(); + } + IndexRange param_indices() const { return signature_.param_types.index_range(); diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh index 5905d1cc315..6e7efb21850 100644 --- a/source/blender/functions/FN_multi_function_builder.hh +++ b/source/blender/functions/FN_multi_function_builder.hh @@ -203,6 +203,30 @@ template<typename Mut1> class CustomMF_SM : public MultiFunction { }; /** + * Generates a multi-function that converts between two types. + */ +template<typename From, typename To> class CustomMF_Convert : public MultiFunction { + public: + CustomMF_Convert() + { + std::string name = CPPType::get<From>().name() + " to " + CPPType::get<To>().name(); + MFSignatureBuilder signature = this->get_builder(std::move(name)); + signature.single_input<From>("Input"); + signature.single_output<To>("Output"); + } + + void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override + { + VSpan<From> inputs = params.readonly_single_input<From>(0); + MutableSpan<To> outputs = params.uninitialized_single_output<To>(1); + + for (uint i : mask) { + new ((void *)&outputs[i]) To(inputs[i]); + } + } +}; + +/** * A multi-function that outputs the same value every time. The value is not owned by an instance * of this function. The caller is responsible for destructing and freeing the value. */ diff --git a/source/blender/functions/FN_multi_function_param_type.hh b/source/blender/functions/FN_multi_function_param_type.hh index 0e43e355b53..7c16b8cdf10 100644 --- a/source/blender/functions/FN_multi_function_param_type.hh +++ b/source/blender/functions/FN_multi_function_param_type.hh @@ -144,6 +144,11 @@ class MFParamType { return ELEM(interface_type_, Output, Mutable); } + bool is_output() const + { + return interface_type_ == Output; + } + friend bool operator==(const MFParamType &a, const MFParamType &b); friend bool operator!=(const MFParamType &a, const MFParamType &b); }; diff --git a/source/blender/functions/FN_spans.hh b/source/blender/functions/FN_spans.hh index b2622eab95f..c8c98d66628 100644 --- a/source/blender/functions/FN_spans.hh +++ b/source/blender/functions/FN_spans.hh @@ -339,6 +339,16 @@ class GVSpan : public VSpanBase<void> { return ref; } + static GVSpan FromSingleWithMaxSize(const CPPType &type, const void *value) + { + return GVSpan::FromSingle(type, value, UINT32_MAX); + } + + static GVSpan FromDefault(const CPPType &type) + { + return GVSpan::FromSingleWithMaxSize(type, type.default_value()); + } + static GVSpan FromFullPointerArray(const CPPType &type, const void *const *values, uint size) { GVSpan ref; diff --git a/source/blender/functions/intern/multi_function_network.cc b/source/blender/functions/intern/multi_function_network.cc index 47e3bf4d0b5..11c9c065f51 100644 --- a/source/blender/functions/intern/multi_function_network.cc +++ b/source/blender/functions/intern/multi_function_network.cc @@ -197,6 +197,7 @@ MFInputSocket &MFNetwork::add_output(StringRef name, MFDataType data_type) void MFNetwork::relink(MFOutputSocket &old_output, MFOutputSocket &new_output) { BLI_assert(&old_output != &new_output); + BLI_assert(old_output.data_type_ == new_output.data_type_); for (MFInputSocket *input : old_output.targets()) { input->origin_ = &new_output; } diff --git a/source/blender/functions/intern/multi_function_network_evaluation.cc b/source/blender/functions/intern/multi_function_network_evaluation.cc index b4dce040da6..b59cbc6a1a2 100644 --- a/source/blender/functions/intern/multi_function_network_evaluation.cc +++ b/source/blender/functions/intern/multi_function_network_evaluation.cc @@ -106,30 +106,30 @@ MFNetworkEvaluator::MFNetworkEvaluator(Vector<const MFOutputSocket *> inputs, BLI_assert(outputs_.size() > 0); MFSignatureBuilder signature = this->get_builder("Function Tree"); - for (auto socket : inputs_) { + for (const MFOutputSocket *socket : inputs_) { BLI_assert(socket->node().is_dummy()); MFDataType type = socket->data_type(); switch (type.category()) { case MFDataType::Single: - signature.single_input("Input", type.single_type()); + signature.single_input(socket->name(), type.single_type()); break; case MFDataType::Vector: - signature.vector_input("Input", type.vector_base_type()); + signature.vector_input(socket->name(), type.vector_base_type()); break; } } - for (auto socket : outputs_) { + for (const MFInputSocket *socket : outputs_) { BLI_assert(socket->node().is_dummy()); MFDataType type = socket->data_type(); switch (type.category()) { case MFDataType::Single: - signature.single_output("Output", type.single_type()); + signature.single_output(socket->name(), type.single_type()); break; case MFDataType::Vector: - signature.vector_output("Output", type.vector_base_type()); + signature.vector_output(socket->name(), type.vector_base_type()); break; } } diff --git a/source/blender/functions/intern/multi_function_network_optimization.cc b/source/blender/functions/intern/multi_function_network_optimization.cc index 4fe0b506df8..849b24a318f 100644 --- a/source/blender/functions/intern/multi_function_network_optimization.cc +++ b/source/blender/functions/intern/multi_function_network_optimization.cc @@ -454,8 +454,9 @@ static void relink_duplicate_nodes(MFNetwork &network, } Vector<MFNode *, 16> nodes_to_check = nodes_with_same_hash; - Vector<MFNode *, 16> remaining_nodes; while (nodes_to_check.size() >= 2) { + Vector<MFNode *, 16> remaining_nodes; + MFNode &deduplicated_node = *nodes_to_check[0]; for (MFNode *node : nodes_to_check.as_span().drop_front(1)) { /* This is true with fairly high probability, but hash collisions can happen. So we have to diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 92aacc74190..497cb4a10a5 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -42,7 +42,6 @@ set(INC_SYS ) set(SRC - intern/MOD_gpencil_util.h intern/MOD_gpencil_ui_common.c intern/MOD_gpencil_util.c @@ -65,8 +64,9 @@ set(SRC intern/MOD_gpenciltime.c intern/MOD_gpenciltint.c - intern/MOD_gpencil_ui_common.h MOD_gpencil_modifiertypes.h + intern/MOD_gpencil_ui_common.h + intern/MOD_gpencil_util.h ) set(LIB diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c index 54ed2ffafe1..56d94611b5d 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c @@ -119,7 +119,6 @@ static void gpf_clear_all_strokes(bGPDframe *gpf) /* Reduce the number of points in the stroke * * Note: This won't be called if all points are present/removed - * TODO: Allow blending of growing/shrinking tip (e.g. for more gradual transitions) */ static void reduce_stroke_points(bGPDstroke *gps, const int num_points, @@ -132,7 +131,6 @@ static void reduce_stroke_points(bGPDstroke *gps, } /* Which end should points be removed from */ - // TODO: free stroke weights switch (transition) { case GP_BUILD_TRANSITION_GROW: /* Show in forward order = * Remove ungrown-points from end of stroke. */ @@ -279,7 +277,6 @@ static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa } else { /* Some proportion of stroke is visible */ - /* XXX: Will the transition settings still be valid now? */ if ((first_visible <= cell->start_idx) && (last_visible >= cell->end_idx)) { /* Do nothing - whole stroke is visible */ } @@ -303,8 +300,6 @@ static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa /* --------------------------------------------- */ /* Concurrent - Show multiple strokes at once */ -// TODO: Allow random offsets to start times -// TODO: Allow varying speeds? Scaling of progress? static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, float fac) { bGPDstroke *gps, *gps_next; @@ -342,8 +337,7 @@ static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa /* Build effect occurs over when fac = 0, to fac = relative_len */ if (fac <= relative_len) { /* Scale fac to fit relative_len */ - /* FIXME: prevent potential div by zero (e.g. very short stroke vs one very long one) */ - const float scaled_fac = fac / relative_len; + const float scaled_fac = fac / MAX2(relative_len, PSEUDOINVERSE_EPSILON); if (reverse) { num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints); @@ -371,8 +365,7 @@ static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa const float start_fac = 1.0f - relative_len; if (fac >= start_fac) { - /* FIXME: prevent potential div by zero (e.g. very short stroke vs one very long one) */ - const float scaled_fac = (fac - start_fac) / relative_len; + const float scaled_fac = (fac - start_fac) / MAX2(relative_len, PSEUDOINVERSE_EPSILON); if (reverse) { num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints); @@ -393,8 +386,6 @@ static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa break; } - - /* TODO... */ } /* Modify the stroke geometry */ diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c index 8d4556421eb..1e75c5926cd 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c @@ -83,7 +83,7 @@ static void deformStroke(GpencilModifierData *md, mmd->material, mmd->pass_index, mmd->layer_pass, - mmd->mode == GP_SIMPLIFY_SAMPLE ? 3 : 4, + mmd->mode == GP_SIMPLIFY_SAMPLE ? 2 : 4, gpl, gps, mmd->flag & GP_SIMPLIFY_INVERT_LAYER, diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index 41a29a4d45d..c7e74040568 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -67,7 +67,7 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading); void GPU_pbvh_bmesh_buffers_update_free(GPU_PBVH_Buffers *buffers); void GPU_pbvh_grid_buffers_update_free(GPU_PBVH_Buffers *buffers, const struct DMFlagMat *grid_flag_mats, - int *grid_indices); + const int *grid_indices); /* Update mesh buffers without topology changes. Threaded. */ enum { diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index eeb2d2caef2..c372bfaf218 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -169,8 +169,8 @@ void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link); void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], - short *falloff_type, - float *sharpness); + const short *falloff_type, + const float *sharpness); struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_len, struct GPUTexture **tex_profile); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index bb9720246ca..10d5a860f6a 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -452,7 +452,7 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const MPoly *mpoly, static void gpu_pbvh_grid_fill_index_buffers(GPU_PBVH_Buffers *buffers, SubdivCCG *UNUSED(subdiv_ccg), const int *UNUSED(face_sets), - int *grid_indices, + const int *grid_indices, uint visible_quad_len, int totgrid, int gridsize) @@ -583,7 +583,7 @@ static void gpu_pbvh_grid_fill_index_buffers(GPU_PBVH_Buffers *buffers, void GPU_pbvh_grid_buffers_update_free(GPU_PBVH_Buffers *buffers, const struct DMFlagMat *grid_flag_mats, - int *grid_indices) + const int *grid_indices) { const bool smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 0fd373d37a3..d1c7aba37df 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -348,7 +348,7 @@ void gpu_extensions_init(void) GG.mip_render_workaround = true; } - /* Intel Ivy Bridge GPU's seems to have buggy cubemap array support. (see T75943) */ + /* Intel Ivy Bridge GPU's seems to have buggy cube-map array support. (see T75943) */ if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_OFFICIAL) && (strstr(renderer, "HD Graphics 4000") || strstr(renderer, "HD Graphics 2500"))) { GG.glew_arb_texture_cube_map_array_is_supported = false; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index d2384b9c065..c65c1046b8f 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -497,8 +497,8 @@ static void compute_sss_translucence_kernel(const GPUSssKernelData *kd, void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], - short *falloff_type, - float *sharpness) + const short *falloff_type, + const float *sharpness) { copy_v3_v3(material->sss_radii, radii); material->sss_falloff = (falloff_type) ? *falloff_type : 0.0; diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl index b2f6147b629..b6aad5904ff 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl @@ -14,7 +14,7 @@ float sky_angle_between(float thetav, float phiv, float theta, float phi) vec3 sky_spherical_coordinates(vec3 dir) { - return vec3(acos(dir.z), atan(dir.x, dir.y), 0); + return vec3(M_PI_2 - atan(dir.z, length(dir.xy)), atan(dir.x, dir.y), 0); } /* Preetham */ diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 83ef910d0bb..fc7e03c3073 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -367,6 +367,7 @@ struct anim *IMB_open_anim(const char *name, void IMB_suffix_anim(struct anim *anim, const char *suffix); void IMB_close_anim(struct anim *anim); void IMB_close_anim_proxies(struct anim *anim); +bool IMB_anim_can_produce_frames(const struct anim *anim); /** * @@ -411,7 +412,7 @@ void IMB_free_anim(struct anim *anim); void IMB_filter(struct ImBuf *ibuf); void IMB_mask_filter_extend(char *mask, int width, int height); -void IMB_mask_clear(struct ImBuf *ibuf, char *mask, int val); +void IMB_mask_clear(struct ImBuf *ibuf, const char *mask, int val); void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter); void IMB_makemipmap(struct ImBuf *ibuf, int use_filter); void IMB_remakemipmap(struct ImBuf *ibuf, int use_filter); @@ -599,7 +600,7 @@ void bilinear_interpolation_color_wrap( struct ImBuf *in, unsigned char col[4], float col_float[4], float u, float v); void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[3]); -void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, float backcol[3]); +void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, const float backcol[3]); void IMB_sampleImageAtLocation( struct ImBuf *ibuf, float x, float y, bool make_linear_rgb, float color[4]); diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 11b30a24cde..220801137f5 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -304,6 +304,21 @@ struct anim *IMB_open_anim(const char *name, return (anim); } +bool IMB_anim_can_produce_frames(const struct anim *anim) +{ +#ifdef WITH_AVI + if (anim->avi != NULL) { + return true; + } +#endif +#ifdef WITH_FFMPEG + if (anim->pCodecCtx != NULL) { + return true; + } +#endif + return false; +} + void IMB_suffix_anim(struct anim *anim, const char *suffix) { BLI_strncpy(anim->suffix, suffix, sizeof(anim->suffix)); diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 6341706bede..5c9ebbaba21 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -1723,7 +1723,7 @@ static void *do_display_buffer_apply_thread(void *handle_v) } static void display_buffer_apply_threaded(ImBuf *ibuf, - float *buffer, + const float *buffer, unsigned char *byte_buffer, float *display_buffer, unsigned char *display_buffer_byte, diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp index 4397c1febab..9fd6d71e091 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.cpp +++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp @@ -241,7 +241,7 @@ void BlockDXT1::decodeBlockNV5x(ColorBlock *block) const } } -void BlockDXT1::setIndices(int *idx) +void BlockDXT1::setIndices(const int *idx) { indices = 0; for (uint i = 0; i < 16; i++) { @@ -580,7 +580,7 @@ void BlockCTX1::decodeBlock(ColorBlock *block) const } } -void BlockCTX1::setIndices(int *idx) +void BlockCTX1::setIndices(const int *idx) { indices = 0; for (uint i = 0; i < 16; i++) { diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h index 16937bce042..57430dbaea2 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.h +++ b/source/blender/imbuf/intern/dds/BlockDXT.h @@ -76,7 +76,7 @@ struct BlockDXT1 { void decodeBlock(ColorBlock *block) const; void decodeBlockNV5x(ColorBlock *block) const; - void setIndices(int *idx); + void setIndices(const int *idx); void flip4(); void flip2(); @@ -289,7 +289,7 @@ struct BlockCTX1 { }; void evaluatePalette(Color32 color_array[4]) const; - void setIndices(int *idx); + void setIndices(const int *idx); void decodeBlock(ColorBlock *block) const; diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index e36088f8eac..d8a5096af71 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -363,7 +363,7 @@ void IMB_mask_filter_extend(char *mask, int width, int height) MEM_freeN(temprect); } -void IMB_mask_clear(ImBuf *ibuf, char *mask, int val) +void IMB_mask_clear(ImBuf *ibuf, const char *mask, int val) { int x, y; if (ibuf->rect_float) { diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index 7ebbd1a7409..bf58f047773 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -456,7 +456,7 @@ void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[ } } -void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, float backcol[3]) +void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, const float backcol[3]) { size_t a = ((size_t)x) * y; unsigned char *cp = rect; diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 985a8e977ca..7cc31b99077 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -894,7 +894,7 @@ static void index_rebuild_ffmpeg_proc_decoded_frame(FFmpegIndexBuilderContext *c } static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, - short *stop, + const short *stop, short *do_update, float *progress) { @@ -1090,7 +1090,7 @@ static void index_rebuild_fallback_finish(FallbackIndexBuilderContext *context, } static void index_rebuild_fallback(FallbackIndexBuilderContext *context, - short *stop, + const short *stop, short *do_update, float *progress) { diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index bfcd1ec2cee..2516df22151 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -122,7 +122,7 @@ static int expandrow2( static void interleaverow(uchar *lptr, const uchar *cptr, int z, int n); static void interleaverow2(float *lptr, const uchar *cptr, int z, int n); static int compressrow(uchar *lbuf, uchar *rlebuf, int z, int cnt); -static void lumrow(uchar *rgbptr, uchar *lumptr, int n); +static void lumrow(const uchar *rgbptr, uchar *lumptr, int n); /* * byte order independent read/write of shorts and ints. @@ -900,7 +900,7 @@ static int output_iris(uint *lptr, int xsize, int ysize, int zsize, const char * /* static utility functions for output_iris */ -static void lumrow(uchar *rgbptr, uchar *lumptr, int n) +static void lumrow(const uchar *rgbptr, uchar *lumptr, int n) { lumptr += CHANOFFSET(0); while (n--) { diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 46d07e74ce3..6ed01c73f04 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -176,7 +176,7 @@ static void RGBE2FLOAT(RGBE rgbe, fCOLOR fcol) } /* float color -> rgbe */ -static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe) +static void FLOAT2RGBE(const fCOLOR fcol, RGBE rgbe) { int e; float d = (fcol[RED] > fcol[GRN]) ? fcol[RED] : fcol[GRN]; @@ -308,7 +308,8 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, } /* ImBuf write */ -static int fwritecolrs(FILE *file, int width, int channels, unsigned char *ibufscan, float *fpscan) +static int fwritecolrs( + FILE *file, int width, int channels, const unsigned char *ibufscan, const float *fpscan) { int beg, c2, cnt = 0; fCOLOR fcol; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 309de25db03..715f2aaf621 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -81,14 +81,24 @@ typedef struct ImbTIFFMemFile { * Function implementations. * *****************************/ -static void imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size) +static void imb_tiff_DummyUnmapProc( + thandle_t fd, + tdata_t base, + /* Cannot be const, because this function implements #TIFFUnmapFileProc. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + toff_t size) { (void)fd; (void)base; (void)size; } -static int imb_tiff_DummyMapProc(thandle_t fd, tdata_t *pbase, toff_t *psize) +static int imb_tiff_DummyMapProc( + thandle_t fd, + tdata_t *pbase, + /* Cannot be const, because this function implements #TIFFMapFileProc. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + toff_t *psize) { (void)fd; (void)pbase; @@ -100,7 +110,7 @@ static int imb_tiff_DummyMapProc(thandle_t fd, tdata_t *pbase, toff_t *psize) /** * Reads data from an in-memory TIFF file. * - * \param handle: Handle of the TIFF file (pointer to ImbTIFFMemFile). + * \param handle: Handle of the TIFF file (pointer to #ImbTIFFMemFile). * \param data: Buffer to contain data (treat as (void *)). * \param n: Number of bytes to read. * diff --git a/source/blender/io/alembic/CMakeLists.txt b/source/blender/io/alembic/CMakeLists.txt index da36272b850..681d6d04acd 100644 --- a/source/blender/io/alembic/CMakeLists.txt +++ b/source/blender/io/alembic/CMakeLists.txt @@ -63,8 +63,8 @@ set(SRC exporter/abc_writer_camera.cc exporter/abc_writer_curves.cc exporter/abc_writer_hair.cc - exporter/abc_writer_mesh.cc exporter/abc_writer_mball.cc + exporter/abc_writer_mesh.cc exporter/abc_writer_nurbs.cc exporter/abc_writer_points.cc exporter/abc_writer_transform.cc @@ -89,8 +89,8 @@ set(SRC exporter/abc_writer_camera.h exporter/abc_writer_curves.h exporter/abc_writer_hair.h - exporter/abc_writer_mesh.h exporter/abc_writer_mball.h + exporter/abc_writer_mesh.h exporter/abc_writer_nurbs.h exporter/abc_writer_points.h exporter/abc_writer_transform.h diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc index fbc5b2d5c02..98c551c635c 100644 --- a/source/blender/io/alembic/exporter/abc_export_capi.cc +++ b/source/blender/io/alembic/exporter/abc_export_capi.cc @@ -73,7 +73,12 @@ static void build_depsgraph(Depsgraph *depsgraph, Main *bmain) DEG_graph_build_from_view_layer(depsgraph, bmain, scene, view_layer); } -static void export_startjob(void *customdata, short *stop, short *do_update, float *progress) +static void export_startjob(void *customdata, + /* Cannot be const, this function implements wm_jobs_start_callback. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + short *stop, + short *do_update, + float *progress) { ExportJobData *data = static_cast<ExportJobData *>(customdata); data->was_canceled = false; diff --git a/source/blender/io/avi/intern/avi_mjpeg.c b/source/blender/io/avi/intern/avi_mjpeg.c index 7584649dee2..75059c202e5 100644 --- a/source/blender/io/avi/intern/avi_mjpeg.c +++ b/source/blender/io/avi/intern/avi_mjpeg.c @@ -39,7 +39,9 @@ #include "avi_mjpeg.h" static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, size_t bufsize); -static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, size_t bufsize); +static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, + const unsigned char *buffer, + size_t bufsize); static size_t numbytes; @@ -381,7 +383,10 @@ static void deinterlace(int odd, unsigned char *to, unsigned char *from, int wid } } -void *avi_converter_from_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, size_t *size) +void *avi_converter_from_mjpeg(AviMovie *movie, + int stream, + unsigned char *buffer, + const size_t *size) { int deint; unsigned char *buf; @@ -553,7 +558,9 @@ static void jpegmemsrcmgr_term_source(j_decompress_ptr dinfo) MEM_freeN(dinfo->src); } -static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, size_t bufsize) +static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, + const unsigned char *buffer, + size_t bufsize) { dinfo->src = MEM_mallocN(sizeof(*(dinfo->src)), "avi.jpegmemsrcmgr_build"); diff --git a/source/blender/io/avi/intern/avi_mjpeg.h b/source/blender/io/avi/intern/avi_mjpeg.h index 30e46bf1d0c..13153fa41f0 100644 --- a/source/blender/io/avi/intern/avi_mjpeg.h +++ b/source/blender/io/avi/intern/avi_mjpeg.h @@ -24,7 +24,10 @@ #ifndef __AVI_MJPEG_H__ #define __AVI_MJPEG_H__ -void *avi_converter_from_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, size_t *size); +void *avi_converter_from_mjpeg(AviMovie *movie, + int stream, + unsigned char *buffer, + const size_t *size); void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, size_t *size); #endif /* __AVI_MJPEG_H__ */ diff --git a/source/blender/io/avi/intern/avi_rgb.c b/source/blender/io/avi/intern/avi_rgb.c index 6f4f33d72d1..44542af96ae 100644 --- a/source/blender/io/avi/intern/avi_rgb.c +++ b/source/blender/io/avi/intern/avi_rgb.c @@ -37,7 +37,10 @@ /* implementation */ -void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, size_t *size) +void *avi_converter_from_avi_rgb(AviMovie *movie, + int stream, + unsigned char *buffer, + const size_t *size) { unsigned char *buf; AviBitmapInfoHeader *bi; diff --git a/source/blender/io/avi/intern/avi_rgb.h b/source/blender/io/avi/intern/avi_rgb.h index 7c8ce590d27..3a37fad94e1 100644 --- a/source/blender/io/avi/intern/avi_rgb.h +++ b/source/blender/io/avi/intern/avi_rgb.h @@ -24,7 +24,10 @@ #ifndef __AVI_RGB_H__ #define __AVI_RGB_H__ -void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, size_t *size); +void *avi_converter_from_avi_rgb(AviMovie *movie, + int stream, + unsigned char *buffer, + const size_t *size); void *avi_converter_to_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, size_t *size); #endif /* __AVI_RGB_H__ */ diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp index 3755b71f300..bd5bd913a18 100644 --- a/source/blender/io/collada/ArmatureImporter.cpp +++ b/source/blender/io/collada/ArmatureImporter.cpp @@ -969,8 +969,8 @@ void ArmatureImporter::make_shape_keys(bContext *C) /* insert other shape keys */ for (int i = 0; i < morphTargetIds.getCount(); i++) { - /* better to have a separate map of morph objects, - * This'll do for now since only mesh morphing is imported */ + /* Better to have a separate map of morph objects, + * This will do for now since only mesh morphing is imported. */ Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]); diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index 495af60488b..9fbb7324f8f 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -205,7 +205,7 @@ MeshImporter::MeshImporter( } bool MeshImporter::set_poly_indices( - MPoly *mpoly, MLoop *mloop, int loop_index, unsigned int *indices, int loop_count) + MPoly *mpoly, MLoop *mloop, int loop_index, const unsigned int *indices, int loop_count) { mpoly->loopstart = loop_index; mpoly->totloop = loop_count; diff --git a/source/blender/io/collada/MeshImporter.h b/source/blender/io/collada/MeshImporter.h index 2f2a18ff11a..18e56e8f9df 100644 --- a/source/blender/io/collada/MeshImporter.h +++ b/source/blender/io/collada/MeshImporter.h @@ -105,7 +105,7 @@ class MeshImporter : public MeshImporterBase { std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId> materials_mapped_to_geom; bool set_poly_indices( - MPoly *mpoly, MLoop *mloop, int loop_index, unsigned int *indices, int loop_count); + MPoly *mpoly, MLoop *mloop, int loop_index, const unsigned int *indices, int loop_count); void set_face_uv(MLoopUV *mloopuv, UVDataWrapper &uvs, diff --git a/source/blender/io/collada/TransformWriter.cpp b/source/blender/io/collada/TransformWriter.cpp index 0a66db72cb9..b7455837379 100644 --- a/source/blender/io/collada/TransformWriter.cpp +++ b/source/blender/io/collada/TransformWriter.cpp @@ -129,9 +129,9 @@ void TransformWriter::add_node_transform_identity(COLLADASW::Node &node, } void TransformWriter::add_transform(COLLADASW::Node &node, - float loc[3], - float rot[3], - float scale[3]) + const float loc[3], + const float rot[3], + const float scale[3]) { node.addScale("scale", scale[0], scale[1], scale[2]); node.addRotateZ("rotationZ", RAD2DEGF(rot[2])); diff --git a/source/blender/io/collada/TransformWriter.h b/source/blender/io/collada/TransformWriter.h index 3c71fc9d36e..db8ef3f5ee2 100644 --- a/source/blender/io/collada/TransformWriter.h +++ b/source/blender/io/collada/TransformWriter.h @@ -42,7 +42,10 @@ class TransformWriter { void add_node_transform_identity(COLLADASW::Node &node, BCExportSettings &export_settings); private: - void add_transform(COLLADASW::Node &node, float loc[3], float rot[3], float scale[3]); + void add_transform(COLLADASW::Node &node, + const float loc[3], + const float rot[3], + const float scale[3]); }; #endif diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index e74808df466..2c54a49198a 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -603,7 +603,7 @@ float BoneExtended::get_roll() return this->roll; } -void BoneExtended::set_tail(float vec[]) +void BoneExtended::set_tail(const float vec[]) { this->tail[0] = vec[0]; this->tail[1] = vec[1]; diff --git a/source/blender/io/collada/collada_utils.h b/source/blender/io/collada/collada_utils.h index b1ec2c8b81a..11a9376294b 100644 --- a/source/blender/io/collada/collada_utils.h +++ b/source/blender/io/collada/collada_utils.h @@ -343,7 +343,7 @@ class BoneExtended { bool has_roll(); float get_roll(); - void set_tail(float vec[]); + void set_tail(const float vec[]); float *get_tail(); bool has_tail(); diff --git a/source/blender/io/common/CMakeLists.txt b/source/blender/io/common/CMakeLists.txt index d2be4bbb58f..708f24ca0e2 100644 --- a/source/blender/io/common/CMakeLists.txt +++ b/source/blender/io/common/CMakeLists.txt @@ -31,9 +31,9 @@ set(INC_SYS set(SRC intern/abstract_hierarchy_iterator.cc - intern/object_identifier.cc intern/dupli_parent_finder.cc intern/dupli_persistent_id.cc + intern/object_identifier.cc IO_abstract_hierarchy_iterator.h IO_dupli_persistent_id.hh diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc index 2d3972410a4..98aef62f38e 100644 --- a/source/blender/io/usd/intern/usd_capi.cc +++ b/source/blender/io/usd/intern/usd_capi.cc @@ -59,7 +59,12 @@ struct ExportJobData { bool export_ok; }; -static void export_startjob(void *customdata, short *stop, short *do_update, float *progress) +static void export_startjob(void *customdata, + /* Cannot be const, this function implements wm_jobs_start_callback. + * NOLINTNEXTLINE: readability-non-const-parameter. */ + short *stop, + short *do_update, + float *progress) { ExportJobData *data = static_cast<ExportJobData *>(customdata); data->export_ok = false; diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 4056faf359f..0ad249ef2cd 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -343,6 +343,12 @@ typedef enum eBrushPoseOriginType { BRUSH_POSE_ORIGIN_FACE_SETS_FK = 2, } eBrushPoseOriginType; +typedef enum eBrushSmearDeformType { + BRUSH_SMEAR_DEFORM_DRAG = 0, + BRUSH_SMEAR_DEFORM_PINCH = 1, + BRUSH_SMEAR_DEFORM_EXPAND = 2, +} eBrushSmearDeformType; + /* Gpencilsettings.Vertex_mode */ typedef enum eGp_Vertex_Mode { /* Affect to Stroke only. */ @@ -500,7 +506,7 @@ typedef struct Brush { char gpencil_sculpt_tool; /** Active grease pencil weight tool. */ char gpencil_weight_tool; - char _pad1[2]; + char _pad1[6]; float autosmooth_factor; @@ -555,6 +561,9 @@ typedef struct Brush { /* multiplane scrape */ float multiplane_scrape_angle; + /* smear */ + int smear_deform_type; + /* overlay */ int texture_overlay_alpha; int mask_overlay_alpha; diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h index b54ff7ccc17..909170523a3 100644 --- a/source/blender/makesdna/DNA_fluid_types.h +++ b/source/blender/makesdna/DNA_fluid_types.h @@ -471,9 +471,10 @@ typedef struct FluidDomainSettings { int res_max[3]; /* Cell max. */ int res[3]; /* Data resolution (res_max-res_min). */ int total_cells; - float dx; /* 1.0f / res. */ - float scale; /* Largest domain size. */ - int boundary_width; /* Usually this is just 1. */ + float dx; /* 1.0f / res. */ + float scale; /* Largest domain size. */ + int boundary_width; /* Usually this is just 1. */ + float gravity_final[3]; /* Scene or domain gravity multiplied with gravity weight. */ /* -- User-accesible fields (from here on). -- */ @@ -481,7 +482,6 @@ typedef struct FluidDomainSettings { int adapt_margin; int adapt_res; float adapt_threshold; - char _pad1[4]; /* Unused. */ /* Fluid domain options */ int maxres; /* Longest axis on the BB gets this resolution assigned. */ diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 993aad92564..42ccbc657d8 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -845,14 +845,15 @@ typedef struct NodeTexSky { float turbidity; float ground_albedo; float sun_size; + float sun_intensity; float sun_elevation; float sun_rotation; - int altitude; + float altitude; float air_density; float dust_density; float ozone_density; char sun_disc; - char _pad[3]; + char _pad[7]; } NodeTexSky; typedef struct NodeTexImage { diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 9c2ee00a900..c2f1e204073 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -69,6 +69,7 @@ set(DEFSRC rna_packedfile.c rna_palette.c rna_particle.c + rna_pointcloud.c rna_pose.c rna_render.c rna_rigidbody.c @@ -82,7 +83,6 @@ set(DEFSRC rna_sound.c rna_space.c rna_speaker.c - rna_pointcloud.c rna_test.c rna_text.c rna_texture.c diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 46001f27fef..8d498ab569b 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -518,7 +518,7 @@ static ID *rna_ID_copy(ID *id, Main *bmain) static ID *rna_ID_override_create(ID *id, Main *bmain, bool remap_local_usages) { - if (!BKE_lib_override_library_is_enabled() || !ID_IS_OVERRIDABLE_LIBRARY(id)) { + if (!ID_IS_OVERRIDABLE_LIBRARY(id)) { return NULL; } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 8bf715f93c1..793552c5c34 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -560,7 +560,10 @@ static PropertyRNA *arraytypemap[IDP_NUMTYPES] = { /* This function initializes a PropertyRNAOrID with all required info, from a given PropertyRNA * and PointerRNA data. It deals properly with the three cases (static RNA, runtime RNA, and - * IDProperty). */ + * IDProperty). + * WARNING: given `ptr` PointerRNA is assumed to be a valid data one here, calling code is + * responsible to ensure that. + */ void rna_property_rna_or_id_get(PropertyRNA *prop, PointerRNA *ptr, PropertyRNAOrID *r_prop_rna_or_id) @@ -617,8 +620,8 @@ void rna_property_rna_or_id_get(PropertyRNA *prop, r_prop_rna_or_id->idprop = idprop_evaluated; r_prop_rna_or_id->is_idprop = true; - /* Full IDProperties are always set. */ - r_prop_rna_or_id->is_set = true; + /* Full IDProperties are always set, if it exists. */ + r_prop_rna_or_id->is_set = (idprop_evaluated != NULL); r_prop_rna_or_id->identifier = idprop->name; if (idprop->type == IDP_ARRAY) { diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index a89c8c4667d..1b846fd898c 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -1177,10 +1177,6 @@ eRNAOverrideStatus RNA_property_override_library_status(PointerRNA *ptr, { uint override_status = 0; - if (!BKE_lib_override_library_is_enabled()) { - return override_status; - } - if (!ptr || !prop || !ptr->owner_id || !ID_IS_OVERRIDE_LIBRARY(ptr->owner_id)) { return override_status; } diff --git a/source/blender/makesrna/intern/rna_access_internal.h b/source/blender/makesrna/intern/rna_access_internal.h index ecc9386ca77..a5b554ec7a6 100644 --- a/source/blender/makesrna/intern/rna_access_internal.h +++ b/source/blender/makesrna/intern/rna_access_internal.h @@ -28,10 +28,9 @@ struct IDProperty; struct PropertyRNAOrID; -PropertyRNA *rna_ensure_property(PropertyRNA *prop); void rna_property_rna_or_id_get(PropertyRNA *prop, - PointerRNA *ptr, - PropertyRNAOrID *r_prop_rna_or_id); + PointerRNA *ptr, + PropertyRNAOrID *r_prop_rna_or_id); void rna_idproperty_touch(struct IDProperty *idprop); struct IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index b139e4609cd..b4703ab9aa2 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1997,6 +1997,13 @@ static void rna_def_brush(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem brush_smear_deform_type_items[] = { + {BRUSH_SMEAR_DEFORM_DRAG, "DRAG", 0, "Drag", ""}, + {BRUSH_SMEAR_DEFORM_PINCH, "PINCH", 0, "Pinch", ""}, + {BRUSH_SMEAR_DEFORM_EXPAND, "EXPAND", 0, "Expand", ""}, + {0, NULL, 0, NULL, NULL}, + }; + srna = RNA_def_struct(brna, "Brush", "ID"); RNA_def_struct_ui_text( srna, "Brush", "Brush data-block for storing brush settings for painting and sculpting"); @@ -2117,6 +2124,11 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "smear_deform_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, brush_smear_deform_type_items); + RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "pose_deform_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, brush_pose_deform_type_items); RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush"); diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c index ab0cc6def6f..3387958c2f6 100644 --- a/source/blender/makesrna/intern/rna_fluid.c +++ b/source/blender/makesrna/intern/rna_fluid.c @@ -161,7 +161,7 @@ static void rna_Fluid_flow_reset(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Fluid_update(bmain, scene, ptr); } -static void rna_Fluid_domain_reset(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Fluid_domain_data_reset(Main *bmain, Scene *scene, PointerRNA *ptr) { # ifdef WITH_FLUID FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data; @@ -172,6 +172,39 @@ static void rna_Fluid_domain_reset(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Fluid_update(bmain, scene, ptr); } +static void rna_Fluid_domain_noise_reset(Main *bmain, Scene *scene, PointerRNA *ptr) +{ +# ifdef WITH_FLUID + FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data; + BKE_fluid_modifier_reset(settings->fmd); +# endif + + rna_Fluid_noisecache_reset(bmain, scene, ptr); + rna_Fluid_update(bmain, scene, ptr); +} + +static void rna_Fluid_domain_mesh_reset(Main *bmain, Scene *scene, PointerRNA *ptr) +{ +# ifdef WITH_FLUID + FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data; + BKE_fluid_modifier_reset(settings->fmd); +# endif + + rna_Fluid_meshcache_reset(bmain, scene, ptr); + rna_Fluid_update(bmain, scene, ptr); +} + +static void rna_Fluid_domain_particles_reset(Main *bmain, Scene *scene, PointerRNA *ptr) +{ +# ifdef WITH_FLUID + FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data; + BKE_fluid_modifier_reset(settings->fmd); +# endif + + rna_Fluid_particlescache_reset(bmain, scene, ptr); + rna_Fluid_update(bmain, scene, ptr); +} + static void rna_Fluid_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr) { # ifdef WITH_FLUID @@ -232,7 +265,7 @@ static void rna_Fluid_flip_parts_update(Main *bmain, Scene *scene, PointerRNA *p if (fmd->domain->type != FLUID_DOMAIN_TYPE_LIQUID) { rna_Fluid_parts_delete(ptr, PART_FLUID_FLIP); fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FLIP; - rna_Fluid_domain_reset(bmain, scene, ptr); + rna_Fluid_domain_data_reset(bmain, scene, ptr); return; } @@ -1350,7 +1383,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Adaptive Domain", "Adapt simulation resolution and size to fluid"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset"); /* fluid domain options */ @@ -1364,7 +1397,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) "Resolution used for the fluid domain. Value corresponds to the longest domain side " "(resolution for other domain sides is calculated automatically)"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset"); prop = RNA_def_property(srna, "use_collision_border_front", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "border_collisions", FLUID_DOMAIN_BORDER_FRONT); @@ -1547,7 +1580,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) "The noise simulation is scaled up by this factor (compared to the " "base resolution of the domain)"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_noise_reset"); prop = RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "noise_type"); @@ -1555,7 +1588,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Noise Method", "Noise method which is used during the high-res simulation"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_noise_reset"); prop = RNA_def_property(srna, "use_noise", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_NOISE); @@ -1569,7 +1602,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "simulation_method"); RNA_def_property_enum_items(prop, simulation_methods); RNA_def_property_ui_text(prop, "Simulation Method", "Change the underlying simulation method"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset"); prop = RNA_def_property(srna, "flip_ratio", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 1.0); @@ -1657,7 +1690,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Use Diffusion", "Enable fluid diffusion settings (e.g. viscosity, surface tension)"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset"); prop = RNA_def_property(srna, "surface_tension", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 100.0); @@ -1724,7 +1757,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) "resolution of the domain). For best meshing, it is recommended to " "adjust the mesh particle radius alongside this value"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_mesh_reset"); prop = RNA_def_property(srna, "mesh_generator", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mesh_generator"); @@ -1924,7 +1957,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) "The particle simulation is scaled up by this factor (compared to the " "base resolution of the domain)"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_particles_reset"); prop = RNA_def_property(srna, "use_spray_particles", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "particle_type", FLUID_DOMAIN_PARTICLE_SPRAY); @@ -2081,7 +2114,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, cache_types); RNA_def_property_enum_funcs(prop, NULL, "rna_Fluid_cachetype_set", NULL); RNA_def_property_ui_text(prop, "Type", "Change the cache type of the simulation"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_domain_data_reset"); prop = RNA_def_property(srna, "cache_resumable", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_RESUMABLE_CACHE); @@ -2158,7 +2191,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) "only needed if you plan to analyze the cache (e.g. view grids, velocity vectors, " "particles) in Mantaflow directly (outside of Blender) after baking the simulation"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset"); /* time options */ @@ -2655,7 +2688,7 @@ static void rna_def_fluid_effector_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "use_plane_init", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_EFFECTOR_USE_PLANE_INIT); RNA_def_property_ui_text(prop, "Is Planar", "Treat this object as a planar, unclosed mesh"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset"); prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vel_multi"); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 8e6a360f2c9..a8085c00cb3 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -23,6 +23,8 @@ #include "BLI_utildefines.h" +#include "BLI_compiler_attrs.h" + #include "rna_internal_types.h" #include "UI_resources.h" @@ -478,9 +480,11 @@ extern StructRNA RNA_PropertyGroupItem; extern StructRNA RNA_PropertyGroup; #endif -struct IDProperty *rna_idproperty_check(struct PropertyRNA **prop, struct PointerRNA *ptr); +struct IDProperty *rna_idproperty_check(struct PropertyRNA **prop, + struct PointerRNA *ptr) ATTR_WARN_UNUSED_RESULT; struct PropertyRNA *rna_ensure_property_realdata(struct PropertyRNA **prop, - struct PointerRNA *ptr); + struct PointerRNA *ptr) ATTR_WARN_UNUSED_RESULT; +struct PropertyRNA *rna_ensure_property(struct PropertyRNA *prop) ATTR_WARN_UNUSED_RESULT; /* Override default callbacks. */ /* Default override callbacks for all types. */ diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 20648970bd1..eb1a09f9c76 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1688,6 +1688,17 @@ static void rna_Modifier_show_expanded_set(PointerRNA *ptr, bool value) } } +/** + * Only check the first bit of the expansion flag for the main panel's expansion, + * maintaining compatibility with older versions where there was only one expansion + * value. + */ +static bool rna_Modifier_show_expanded_get(PointerRNA *ptr) +{ + ModifierData *md = ptr->data; + return md->ui_expand_flag & (1 << 0); +} + #else /* NOTE: *MUST* return subdivision_type property. */ @@ -6959,7 +6970,8 @@ void RNA_def_modifier(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Modifier_show_expanded_set"); + RNA_def_property_boolean_funcs( + prop, "rna_Modifier_show_expanded_get", "rna_Modifier_show_expanded_set"); RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); RNA_def_property_boolean_sdna(prop, NULL, "ui_expand_flag", 0); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 86a270ec09d..332108facb3 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4421,7 +4421,7 @@ static void def_sh_tex_sky(StructRNA *srna) RNA_def_property_enum_sdna(prop, NULL, "sky_model"); RNA_def_property_enum_items(prop, prop_sky_type); RNA_def_property_ui_text(prop, "Sky Type", "Which sky model should be used"); - RNA_def_property_update(prop, 0, "rna_Node_update"); + RNA_def_property_update(prop, 0, "rna_ShaderNode_socket_update"); prop = RNA_def_property(srna, "sun_direction", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_ui_text(prop, "Sun Direction", "Direction from where the sun is shining"); @@ -4445,7 +4445,7 @@ static void def_sh_tex_sky(StructRNA *srna) RNA_def_property_ui_text(prop, "Sun Disc", "Include the sun itself in the output"); RNA_def_property_boolean_sdna(prop, NULL, "sun_disc", 1); RNA_def_property_boolean_default(prop, true); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, 0, "rna_ShaderNode_socket_update"); prop = RNA_def_property(srna, "sun_size", PROP_FLOAT, PROP_ANGLE); RNA_def_property_ui_text(prop, "Sun Size", "Size of sun disc (angular diameter)"); @@ -4453,6 +4453,12 @@ static void def_sh_tex_sky(StructRNA *srna) RNA_def_property_float_default(prop, DEG2RADF(0.545)); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "sun_intensity", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Sun Intensity", "Strength of sun"); + RNA_def_property_range(prop, 0.0f, 1000.0f); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "sun_elevation", PROP_FLOAT, PROP_ANGLE); RNA_def_property_ui_text(prop, "Sun Elevation", "Angle between sun and horizon"); RNA_def_property_range(prop, -M_PI_2, M_PI_2); @@ -4461,14 +4467,13 @@ static void def_sh_tex_sky(StructRNA *srna) prop = RNA_def_property(srna, "sun_rotation", PROP_FLOAT, PROP_ANGLE); RNA_def_property_ui_text(prop, "Sun Rotation", "Rotation of sun around zenith"); - RNA_def_property_range(prop, 0.0f, 2.0f * M_PI); RNA_def_property_float_default(prop, 0.0f); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "altitude", PROP_INT, PROP_NONE); - RNA_def_property_ui_text(prop, "Altitude", "Altitude height from sea level in meters"); - RNA_def_property_range(prop, 0, 60000); - RNA_def_property_int_default(prop, 0); + prop = RNA_def_property(srna, "altitude", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Altitude", "Height from sea level in km"); + RNA_def_property_range(prop, 0.0f, 60.0f); + RNA_def_property_float_default(prop, 0.0f); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "air_density", PROP_FLOAT, PROP_FACTOR); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 39949538726..f9f6defb2f1 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -479,7 +479,7 @@ static StructRNA *rna_Property_refine(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); /* XXX ptr? */ + prop = rna_ensure_property(prop); switch (prop->type) { case PROP_BOOLEAN: @@ -504,90 +504,90 @@ static StructRNA *rna_Property_refine(PointerRNA *ptr) static void rna_Property_identifier_get(PointerRNA *ptr, char *value) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); strcpy(value, ((PropertyRNA *)prop)->identifier); } static int rna_Property_identifier_length(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return strlen(prop->identifier); } static void rna_Property_name_get(PointerRNA *ptr, char *value) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); strcpy(value, prop->name ? prop->name : ""); } static int rna_Property_name_length(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return prop->name ? strlen(prop->name) : 0; } static void rna_Property_description_get(PointerRNA *ptr, char *value) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); strcpy(value, prop->description ? prop->description : ""); } static int rna_Property_description_length(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return prop->description ? strlen(prop->description) : 0; } static void rna_Property_translation_context_get(PointerRNA *ptr, char *value) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); strcpy(value, prop->translation_context); } static int rna_Property_translation_context_length(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return strlen(prop->translation_context); } static int rna_Property_type_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return prop->type; } static int rna_Property_subtype_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return prop->subtype; } static PointerRNA rna_Property_srna_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return rna_pointer_inherit_refine(ptr, &RNA_Struct, prop->srna); } static int rna_Property_unit_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return RNA_SUBTYPE_UNIT(prop->subtype); } static int rna_Property_icon_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return prop->icon; } @@ -698,7 +698,7 @@ static const EnumPropertyItem *rna_Property_tags_itemf(bContext *UNUSED(C), static int rna_Property_array_length_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return prop->totarraylength; } @@ -706,7 +706,7 @@ static void rna_Property_array_dimensions_get(PointerRNA *ptr, int dimensions[RNA_MAX_ARRAY_DIMENSION]) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); if (prop->arraydimension > 1) { for (int i = RNA_MAX_ARRAY_DIMENSION; i--;) { @@ -740,14 +740,14 @@ static bool rna_Property_is_runtime_get(PointerRNA *ptr) static bool rna_BoolProperty_default_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((BoolPropertyRNA *)prop)->defaultvalue; } static int rna_IntProperty_default_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((IntPropertyRNA *)prop)->defaultvalue; } /* int/float/bool */ @@ -755,7 +755,7 @@ static int rna_NumberProperty_default_array_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); length[0] = prop->totarraylength; @@ -771,7 +771,7 @@ static bool rna_NumberProperty_is_array_get(PointerRNA *ptr) static void rna_IntProperty_default_array_get(PointerRNA *ptr, int *values) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); if (prop->totarraylength > 0) { PointerRNA null_ptr = PointerRNA_NULL; RNA_property_int_get_default_array(&null_ptr, prop, values); @@ -781,7 +781,7 @@ static void rna_IntProperty_default_array_get(PointerRNA *ptr, int *values) static void rna_BoolProperty_default_array_get(PointerRNA *ptr, bool *values) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); if (prop->totarraylength > 0) { PointerRNA null_ptr = PointerRNA_NULL; RNA_property_boolean_get_default_array(&null_ptr, prop, values); @@ -791,7 +791,7 @@ static void rna_BoolProperty_default_array_get(PointerRNA *ptr, bool *values) static void rna_FloatProperty_default_array_get(PointerRNA *ptr, float *values) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); if (prop->totarraylength > 0) { PointerRNA null_ptr = PointerRNA_NULL; RNA_property_float_get_default_array(&null_ptr, prop, values); @@ -801,103 +801,103 @@ static void rna_FloatProperty_default_array_get(PointerRNA *ptr, float *values) static int rna_IntProperty_hard_min_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((IntPropertyRNA *)prop)->hardmin; } static int rna_IntProperty_hard_max_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((IntPropertyRNA *)prop)->hardmax; } static int rna_IntProperty_soft_min_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((IntPropertyRNA *)prop)->softmin; } static int rna_IntProperty_soft_max_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((IntPropertyRNA *)prop)->softmax; } static int rna_IntProperty_step_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((IntPropertyRNA *)prop)->step; } static float rna_FloatProperty_default_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((FloatPropertyRNA *)prop)->defaultvalue; } static float rna_FloatProperty_hard_min_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((FloatPropertyRNA *)prop)->hardmin; } static float rna_FloatProperty_hard_max_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((FloatPropertyRNA *)prop)->hardmax; } static float rna_FloatProperty_soft_min_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((FloatPropertyRNA *)prop)->softmin; } static float rna_FloatProperty_soft_max_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((FloatPropertyRNA *)prop)->softmax; } static float rna_FloatProperty_step_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((FloatPropertyRNA *)prop)->step; } static int rna_FloatProperty_precision_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((FloatPropertyRNA *)prop)->precision; } static void rna_StringProperty_default_get(PointerRNA *ptr, char *value) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); strcpy(value, ((StringPropertyRNA *)prop)->defaultvalue); } static int rna_StringProperty_default_length(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return strlen(((StringPropertyRNA *)prop)->defaultvalue); } static int rna_StringProperty_max_length_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((StringPropertyRNA *)prop)->maxlength; } @@ -909,7 +909,7 @@ static const EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, PropertyRNA *prop = (PropertyRNA *)ptr->data; EnumPropertyRNA *eprop; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); eprop = (EnumPropertyRNA *)prop; /* incompatible default attributes */ @@ -931,7 +931,7 @@ static const EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, static int rna_EnumProperty_default_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return ((EnumPropertyRNA *)prop)->defaultvalue; } @@ -950,7 +950,7 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point int totitem; bool free; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); /* eprop = (EnumPropertyRNA *)prop; */ RNA_property_enum_items_ex( @@ -1016,14 +1016,14 @@ static int rna_EnumPropertyItem_icon_get(PointerRNA *ptr) static PointerRNA rna_PointerProperty_fixed_type_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((PointerPropertyRNA *)prop)->type); } static PointerRNA rna_CollectionProperty_fixed_type_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - rna_idproperty_check(&prop, ptr); + prop = rna_ensure_property(prop); return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((CollectionPropertyRNA *)prop)->item_type); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index d141e6f3b19..9b98be61cbf 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -6463,7 +6463,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "simplify_gpencil_shader_fx", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_FX); - RNA_def_property_ui_text(prop, "ShadersFX", "Display Shader FX"); + RNA_def_property_ui_text(prop, "Shaders Effects", "Display Shader Effects"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "simplify_gpencil_tint", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 20ae69dc031..ea6421c8d11 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -90,6 +90,12 @@ static bool rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; } +static bool rna_Screen_is_scrubbing_get(PointerRNA *ptr) +{ + bScreen *screen = (bScreen *)ptr->data; + return screen->scrubbing; +} + static int rna_region_alignment_get(PointerRNA *ptr) { ARegion *region = ptr->data; @@ -548,6 +554,12 @@ static void rna_def_screen(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, "rna_Screen_is_animation_playing_get", NULL); RNA_def_property_ui_text(prop, "Animation Playing", "Animation playback is active"); + prop = RNA_def_property(srna, "is_scrubbing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Screen_is_scrubbing_get", NULL); + RNA_def_property_ui_text( + prop, "User is Scrubbing", "True when the user is scrubbing through time"); + prop = RNA_def_property(srna, "is_temporary", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_sdna(prop, NULL, "temp", 1); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 7342879e9e6..de225e3c685 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -749,6 +749,25 @@ static IDProperty *rna_Sequence_idprops(PointerRNA *ptr, bool create) return seq->prop; } +static bool rna_MovieSequence_reload_if_needed(ID *scene_id, Sequence *seq, Main *bmain) +{ + Scene *scene = (Scene *)scene_id; + bool has_reloaded; + bool can_produce_frames; + + BKE_sequence_movie_reload_if_needed(bmain, scene, seq, &has_reloaded, &can_produce_frames); + + if (has_reloaded && can_produce_frames) { + BKE_sequence_calc(scene, seq); + BKE_sequence_invalidate_cache_raw(scene, seq); + + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); + } + + return can_produce_frames; +} + static PointerRNA rna_MovieSequence_metadata_get(Sequence *seq) { if (seq == NULL || seq->anims.first == NULL) { @@ -2385,6 +2404,13 @@ static void rna_def_movie(BlenderRNA *brna) "rna_Sequence_filepath_set"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_filepath_update"); + func = RNA_def_function(srna, "reload_if_needed", "rna_MovieSequence_reload_if_needed"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + /* return type */ + parm = RNA_def_boolean( + func, "can_produce_frames", 0, "True if the strip can produce frames, False otherwise", ""); + RNA_def_function_return(func, parm); + /* metadata */ func = RNA_def_function(srna, "metadata", "rna_MovieSequence_metadata_get"); RNA_def_function_ui_description(func, "Retrieve metadata of the movie file"); diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 0fb582c41fd..4157747455d 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -205,33 +205,28 @@ static Sequence *rna_Sequences_new_image(ID *id, return seq; } -static Sequence *rna_Sequences_new_movie(ID *id, - Editing *ed, - ReportList *reports, - const char *name, - const char *file, - int channel, - int frame_start) +static Sequence *rna_Sequences_new_movie( + ID *id, Editing *ed, const char *name, const char *file, int channel, int frame_start) { Scene *scene = (Scene *)id; Sequence *seq; StripAnim *sanim; - struct anim *an = openanim(file, IB_rect, 0, NULL); + seq = alloc_generic_sequence(ed, name, frame_start, channel, SEQ_TYPE_MOVIE, file); + struct anim *an = openanim(file, IB_rect, 0, NULL); if (an == NULL) { - BKE_report(reports, RPT_ERROR, "Sequences.new_movie: unable to open movie file"); - return NULL; + /* Without anim, the strip gets duration 0, which makes it impossible to select in the UI. */ + seq->len = 1; } + else { + sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim"); + BLI_addtail(&seq->anims, sanim); + sanim->anim = an; - seq = alloc_generic_sequence(ed, name, frame_start, channel, SEQ_TYPE_MOVIE, file); - - sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim"); - BLI_addtail(&seq->anims, sanim); - sanim->anim = an; - - seq->anim_preseek = IMB_anim_get_preseek(an); - seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN); + seq->anim_preseek = IMB_anim_get_preseek(an); + seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN); + } BKE_sequence_calc_disp(scene, seq); BKE_sequence_invalidate_cache_composite(scene, seq); @@ -667,7 +662,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "new_movie", "rna_Sequences_new_movie"); - RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new movie sequence"); parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 80a1ebab64e..cf87e3598b6 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -23,9 +23,9 @@ set(INC intern ../blenfont ../blenkernel - ../blentranslation ../blenlib ../blenloader + ../blentranslation ../bmesh ../depsgraph ../editors/include diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index f6ad25ce282..4e46e135b72 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -254,7 +254,7 @@ static void remap_faces_3_6_9_12(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, - int *vertpa, + const int *vertpa, int i, EdgeHash *eh, int cur, @@ -322,7 +322,7 @@ static void remap_faces_5_10(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, - int *vertpa, + const int *vertpa, int i, EdgeHash *eh, int cur, @@ -378,7 +378,7 @@ static void remap_faces_15(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, - int *vertpa, + const int *vertpa, int i, EdgeHash *eh, int cur, @@ -462,7 +462,7 @@ static void remap_faces_7_11_13_14(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, - int *vertpa, + const int *vertpa, int i, EdgeHash *eh, int cur, @@ -531,7 +531,7 @@ static void remap_faces_19_21_22(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, - int *vertpa, + const int *vertpa, int i, EdgeHash *eh, int cur, @@ -585,7 +585,7 @@ static void remap_faces_23(Mesh *mesh, Mesh *split, MFace *mf, int *facepa, - int *vertpa, + const int *vertpa, int i, EdgeHash *eh, int cur, diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 2c4ca087efa..2381e499eee 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -178,7 +178,7 @@ set(SRC shader/nodes/node_shader_light_path.c shader/nodes/node_shader_map_range.c shader/nodes/node_shader_mapping.c - shader/nodes/node_shader_math.c + shader/nodes/node_shader_math.cc shader/nodes/node_shader_mixRgb.c shader/nodes/node_shader_mix_shader.c shader/nodes/node_shader_normal.c @@ -216,10 +216,10 @@ set(SRC shader/nodes/node_shader_uvAlongStroke.c shader/nodes/node_shader_uvmap.c shader/nodes/node_shader_valToRgb.c - shader/nodes/node_shader_value.c + shader/nodes/node_shader_value.cc shader/nodes/node_shader_vectTransform.c shader/nodes/node_shader_vector_displacement.c - shader/nodes/node_shader_vector_math.c + shader/nodes/node_shader_vector_math.cc shader/nodes/node_shader_vector_rotate.c shader/nodes/node_shader_vertex_color.c shader/nodes/node_shader_volume_absorption.c diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c deleted file mode 100644 index 8abebbf5081..00000000000 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - */ - -/** \file - * \ingroup shdnodes - */ - -#include "node_shader_util.h" - -/* **************** SCALAR MATH ******************** */ -static bNodeSocketTemplate sh_node_math_in[] = { - {SOCK_FLOAT, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, - {SOCK_FLOAT, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, - {SOCK_FLOAT, N_("Value"), 0.0f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, - {-1, ""}}; - -static bNodeSocketTemplate sh_node_math_out[] = {{SOCK_FLOAT, N_("Value")}, {-1, ""}}; - -static int gpu_shader_math(GPUMaterial *mat, - bNode *node, - bNodeExecData *UNUSED(execdata), - GPUNodeStack *in, - GPUNodeStack *out) -{ - static const char *names[] = { - [NODE_MATH_ADD] = "math_add", - [NODE_MATH_SUBTRACT] = "math_subtract", - [NODE_MATH_MULTIPLY] = "math_multiply", - [NODE_MATH_DIVIDE] = "math_divide", - [NODE_MATH_MULTIPLY_ADD] = "math_multiply_add", - - [NODE_MATH_POWER] = "math_power", - [NODE_MATH_LOGARITHM] = "math_logarithm", - [NODE_MATH_EXPONENT] = "math_exponent", - [NODE_MATH_SQRT] = "math_sqrt", - [NODE_MATH_INV_SQRT] = "math_inversesqrt", - [NODE_MATH_ABSOLUTE] = "math_absolute", - [NODE_MATH_RADIANS] = "math_radians", - [NODE_MATH_DEGREES] = "math_degrees", - - [NODE_MATH_MINIMUM] = "math_minimum", - [NODE_MATH_MAXIMUM] = "math_maximum", - [NODE_MATH_LESS_THAN] = "math_less_than", - [NODE_MATH_GREATER_THAN] = "math_greater_than", - [NODE_MATH_SIGN] = "math_sign", - [NODE_MATH_COMPARE] = "math_compare", - [NODE_MATH_SMOOTH_MIN] = "math_smoothmin", - [NODE_MATH_SMOOTH_MAX] = "math_smoothmax", - - [NODE_MATH_ROUND] = "math_round", - [NODE_MATH_FLOOR] = "math_floor", - [NODE_MATH_CEIL] = "math_ceil", - [NODE_MATH_FRACTION] = "math_fraction", - [NODE_MATH_MODULO] = "math_modulo", - [NODE_MATH_TRUNC] = "math_trunc", - [NODE_MATH_SNAP] = "math_snap", - [NODE_MATH_WRAP] = "math_wrap", - [NODE_MATH_PINGPONG] = "math_pingpong", - - [NODE_MATH_SINE] = "math_sine", - [NODE_MATH_COSINE] = "math_cosine", - [NODE_MATH_TANGENT] = "math_tangent", - [NODE_MATH_SINH] = "math_sinh", - [NODE_MATH_COSH] = "math_cosh", - [NODE_MATH_TANH] = "math_tanh", - [NODE_MATH_ARCSINE] = "math_arcsine", - [NODE_MATH_ARCCOSINE] = "math_arccosine", - [NODE_MATH_ARCTANGENT] = "math_arctangent", - [NODE_MATH_ARCTAN2] = "math_arctan2", - }; - - if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { - int ret = GPU_stack_link(mat, node, names[node->custom1], in, out); - - if (ret && node->custom2 & SHD_MATH_CLAMP) { - float min[3] = {0.0f, 0.0f, 0.0f}; - float max[3] = {1.0f, 1.0f, 1.0f}; - GPU_link( - mat, "clamp_value", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link); - } - return ret; - } - else { - return 0; - } -} - -void register_node_type_sh_math(void) -{ - static bNodeType ntype; - - sh_fn_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0); - node_type_socket_templates(&ntype, sh_node_math_in, sh_node_math_out); - node_type_label(&ntype, node_math_label); - node_type_gpu(&ntype, gpu_shader_math); - node_type_update(&ntype, node_math_update); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc new file mode 100644 index 00000000000..a0eb5099f9d --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_math.cc @@ -0,0 +1,196 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup shdnodes + */ + +#include "node_shader_util.h" + +/* **************** SCALAR MATH ******************** */ +static bNodeSocketTemplate sh_node_math_in[] = { + {SOCK_FLOAT, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + {SOCK_FLOAT, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + {SOCK_FLOAT, N_("Value"), 0.0f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + {-1, ""}}; + +static bNodeSocketTemplate sh_node_math_out[] = {{SOCK_FLOAT, N_("Value")}, {-1, ""}}; + +static const char *gpu_shader_get_name(int mode) +{ + switch (mode) { + case NODE_MATH_ADD: + return "math_add"; + case NODE_MATH_SUBTRACT: + return "math_subtract"; + case NODE_MATH_MULTIPLY: + return "math_multiply"; + case NODE_MATH_DIVIDE: + return "math_divide"; + case NODE_MATH_MULTIPLY_ADD: + return "math_multiply_add"; + + case NODE_MATH_POWER: + return "math_power"; + case NODE_MATH_LOGARITHM: + return "math_logarithm"; + case NODE_MATH_EXPONENT: + return "math_exponent"; + case NODE_MATH_SQRT: + return "math_sqrt"; + case NODE_MATH_INV_SQRT: + return "math_inversesqrt"; + case NODE_MATH_ABSOLUTE: + return "math_absolute"; + case NODE_MATH_RADIANS: + return "math_radians"; + case NODE_MATH_DEGREES: + return "math_degrees"; + + case NODE_MATH_MINIMUM: + return "math_minimum"; + case NODE_MATH_MAXIMUM: + return "math_maximum"; + case NODE_MATH_LESS_THAN: + return "math_less_than"; + case NODE_MATH_GREATER_THAN: + return "math_greater_than"; + case NODE_MATH_SIGN: + return "math_sign"; + case NODE_MATH_COMPARE: + return "math_compare"; + case NODE_MATH_SMOOTH_MIN: + return "math_smoothmin"; + case NODE_MATH_SMOOTH_MAX: + return "math_smoothmax"; + + case NODE_MATH_ROUND: + return "math_round"; + case NODE_MATH_FLOOR: + return "math_floor"; + case NODE_MATH_CEIL: + return "math_ceil"; + case NODE_MATH_FRACTION: + return "math_fraction"; + case NODE_MATH_MODULO: + return "math_modulo"; + case NODE_MATH_TRUNC: + return "math_trunc"; + case NODE_MATH_SNAP: + return "math_snap"; + case NODE_MATH_WRAP: + return "math_wrap"; + case NODE_MATH_PINGPONG: + return "math_pingpong"; + + case NODE_MATH_SINE: + return "math_sine"; + case NODE_MATH_COSINE: + return "math_cosine"; + case NODE_MATH_TANGENT: + return "math_tangent"; + case NODE_MATH_SINH: + return "math_sinh"; + case NODE_MATH_COSH: + return "math_cosh"; + case NODE_MATH_TANH: + return "math_tanh"; + case NODE_MATH_ARCSINE: + return "math_arcsine"; + case NODE_MATH_ARCCOSINE: + return "math_arccosine"; + case NODE_MATH_ARCTANGENT: + return "math_arctangent"; + case NODE_MATH_ARCTAN2: + return "math_arctan2"; + } + return nullptr; +} + +static int gpu_shader_math(GPUMaterial *mat, + bNode *node, + bNodeExecData *UNUSED(execdata), + GPUNodeStack *in, + GPUNodeStack *out) +{ + const char *name = gpu_shader_get_name(node->custom1); + if (name != nullptr) { + int ret = GPU_stack_link(mat, node, name, in, out); + + if (ret && node->custom2 & SHD_MATH_CLAMP) { + float min[3] = {0.0f, 0.0f, 0.0f}; + float max[3] = {1.0f, 1.0f, 1.0f}; + GPU_link( + mat, "clamp_value", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link); + } + return ret; + } + else { + return 0; + } +} + +static void sh_node_math_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder) +{ + /* TODO: Implement clamp and other operations. */ + const int mode = builder.bnode().custom1; + switch (mode) { + case NODE_MATH_ADD: { + static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{ + "Add", [](float a, float b) { return a + b; }}; + builder.set_matching_fn(fn); + break; + } + case NODE_MATH_SUBTRACT: { + static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{ + "Subtract", [](float a, float b) { return a - b; }}; + builder.set_matching_fn(fn); + break; + } + case NODE_MATH_MULTIPLY: { + static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{ + "Multiply", [](float a, float b) { return a * b; }}; + builder.set_matching_fn(fn); + break; + } + case NODE_MATH_DIVIDE: { + static blender::fn::CustomMF_SI_SI_SO<float, float, float> fn{ + "Divide", [](float a, float b) { return (b != 0.0f) ? a / b : 0.0f; }}; + builder.set_matching_fn(fn); + break; + } + default: + BLI_assert(false); + break; + } +} + +void register_node_type_sh_math(void) +{ + static bNodeType ntype; + + sh_fn_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0); + node_type_socket_templates(&ntype, sh_node_math_in, sh_node_math_out); + node_type_label(&ntype, node_math_label); + node_type_gpu(&ntype, gpu_shader_math); + node_type_update(&ntype, node_math_update); + ntype.expand_in_mf_network = sh_node_math_expand_in_mf_network; + + nodeRegisterType(&ntype); +} diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c index 70f3f80eb4b..d2c4413b862 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c @@ -44,9 +44,10 @@ static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode *node) tex->ground_albedo = 0.3f; tex->sun_disc = true; tex->sun_size = DEG2RADF(0.545); + tex->sun_intensity = 1.0f; tex->sun_elevation = M_PI_2; tex->sun_rotation = 0.0f; - tex->altitude = 0; + tex->altitude = 0.0f; tex->air_density = 1.0f; tex->dust_density = 1.0f; tex->ozone_density = 1.0f; @@ -64,7 +65,7 @@ typedef struct XYZ_to_RGB /* transposed imbuf_xyz_to_rgb, passed as 3x vec3 */ float r[3], g[3], b[3]; } XYZ_to_RGB; -static float sky_perez_function(float *lam, float theta, float gamma) +static float sky_perez_function(const float *lam, float theta, float gamma) { float ctheta = cosf(theta); float cgamma = cosf(gamma); @@ -73,7 +74,7 @@ static float sky_perez_function(float *lam, float theta, float gamma) (1.0 + lam[2] * expf(lam[3] * gamma) + lam[4] * cgamma * cgamma); } -static void sky_precompute_old(SkyModelPreetham *sunsky, float sun_angles[], float turbidity) +static void sky_precompute_old(SkyModelPreetham *sunsky, const float sun_angles[], float turbidity) { float theta = sun_angles[0]; float theta2 = theta * theta; @@ -214,6 +215,14 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat, } } +static void node_shader_update_sky(bNodeTree *UNUSED(ntree), bNode *node) +{ + bNodeSocket *sockVector = nodeFindSocket(node, SOCK_IN, "Vector"); + + NodeTexSky *tex = (NodeTexSky *)node->storage; + nodeSetSocketAvailability(sockVector, !(tex->sky_model == 2 && tex->sun_disc == 1)); +} + /* node type definition */ void register_node_type_sh_tex_sky(void) { @@ -225,6 +234,8 @@ void register_node_type_sh_tex_sky(void) node_type_init(&ntype, node_shader_init_tex_sky); node_type_storage(&ntype, "NodeTexSky", node_free_standard_storage, node_copy_standard_storage); node_type_gpu(&ntype, node_shader_gpu_tex_sky); + /* remove Vector input for Nishita */ + node_type_update(&ntype, node_shader_update_sky); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_value.c b/source/blender/nodes/shader/nodes/node_shader_value.cc index c32e9e1d581..64701018d63 100644 --- a/source/blender/nodes/shader/nodes/node_shader_value.c +++ b/source/blender/nodes/shader/nodes/node_shader_value.cc @@ -39,13 +39,21 @@ static int gpu_shader_value(GPUMaterial *mat, return GPU_stack_link(mat, node, "set_value", in, out, link); } +static void sh_node_value_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder) +{ + const bNodeSocket *bsocket = builder.dnode().output(0).bsocket(); + const bNodeSocketValueFloat *value = (const bNodeSocketValueFloat *)bsocket->default_value; + builder.construct_and_set_matching_fn<blender::fn::CustomMF_Constant<float>>(value->value); +} + void register_node_type_sh_value(void) { static bNodeType ntype; - sh_node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT, 0); + sh_fn_node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT, 0); node_type_socket_templates(&ntype, NULL, sh_node_value_out); node_type_gpu(&ntype, gpu_shader_value); + ntype.expand_in_mf_network = sh_node_value_expand_in_mf_network; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.c b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc index b719fe03d9b..414d05e996a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc @@ -34,44 +34,74 @@ static bNodeSocketTemplate sh_node_vector_math_in[] = { static bNodeSocketTemplate sh_node_vector_math_out[] = { {SOCK_VECTOR, N_("Vector")}, {SOCK_FLOAT, N_("Value")}, {-1, ""}}; +static const char *gpu_shader_get_name(int mode) +{ + switch (mode) { + case NODE_VECTOR_MATH_ADD: + return "vector_math_add"; + case NODE_VECTOR_MATH_SUBTRACT: + return "vector_math_subtract"; + case NODE_VECTOR_MATH_MULTIPLY: + return "vector_math_multiply"; + case NODE_VECTOR_MATH_DIVIDE: + return "vector_math_divide"; + + case NODE_VECTOR_MATH_CROSS_PRODUCT: + return "vector_math_cross"; + case NODE_VECTOR_MATH_PROJECT: + return "vector_math_project"; + case NODE_VECTOR_MATH_REFLECT: + return "vector_math_reflect"; + case NODE_VECTOR_MATH_DOT_PRODUCT: + return "vector_math_dot"; + + case NODE_VECTOR_MATH_DISTANCE: + return "vector_math_distance"; + case NODE_VECTOR_MATH_LENGTH: + return "vector_math_length"; + case NODE_VECTOR_MATH_SCALE: + return "vector_math_scale"; + case NODE_VECTOR_MATH_NORMALIZE: + return "vector_math_normalize"; + + case NODE_VECTOR_MATH_SNAP: + return "vector_math_snap"; + case NODE_VECTOR_MATH_FLOOR: + return "vector_math_floor"; + case NODE_VECTOR_MATH_CEIL: + return "vector_math_ceil"; + case NODE_VECTOR_MATH_MODULO: + return "vector_math_modulo"; + case NODE_VECTOR_MATH_FRACTION: + return "vector_math_fraction"; + case NODE_VECTOR_MATH_ABSOLUTE: + return "vector_math_absolute"; + case NODE_VECTOR_MATH_MINIMUM: + return "vector_math_minimum"; + case NODE_VECTOR_MATH_MAXIMUM: + return "vector_math_maximum"; + case NODE_VECTOR_MATH_WRAP: + return "vector_math_wrap"; + case NODE_VECTOR_MATH_SINE: + return "vector_math_sine"; + case NODE_VECTOR_MATH_COSINE: + return "vector_math_cosine"; + case NODE_VECTOR_MATH_TANGENT: + return "vector_math_tangent"; + } + + return nullptr; +} + static int gpu_shader_vector_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) { - static const char *names[] = { - [NODE_VECTOR_MATH_ADD] = "vector_math_add", - [NODE_VECTOR_MATH_SUBTRACT] = "vector_math_subtract", - [NODE_VECTOR_MATH_MULTIPLY] = "vector_math_multiply", - [NODE_VECTOR_MATH_DIVIDE] = "vector_math_divide", - - [NODE_VECTOR_MATH_CROSS_PRODUCT] = "vector_math_cross", - [NODE_VECTOR_MATH_PROJECT] = "vector_math_project", - [NODE_VECTOR_MATH_REFLECT] = "vector_math_reflect", - [NODE_VECTOR_MATH_DOT_PRODUCT] = "vector_math_dot", - - [NODE_VECTOR_MATH_DISTANCE] = "vector_math_distance", - [NODE_VECTOR_MATH_LENGTH] = "vector_math_length", - [NODE_VECTOR_MATH_SCALE] = "vector_math_scale", - [NODE_VECTOR_MATH_NORMALIZE] = "vector_math_normalize", - - [NODE_VECTOR_MATH_SNAP] = "vector_math_snap", - [NODE_VECTOR_MATH_FLOOR] = "vector_math_floor", - [NODE_VECTOR_MATH_CEIL] = "vector_math_ceil", - [NODE_VECTOR_MATH_MODULO] = "vector_math_modulo", - [NODE_VECTOR_MATH_FRACTION] = "vector_math_fraction", - [NODE_VECTOR_MATH_ABSOLUTE] = "vector_math_absolute", - [NODE_VECTOR_MATH_MINIMUM] = "vector_math_minimum", - [NODE_VECTOR_MATH_MAXIMUM] = "vector_math_maximum", - [NODE_VECTOR_MATH_WRAP] = "vector_math_wrap", - [NODE_VECTOR_MATH_SINE] = "vector_math_sine", - [NODE_VECTOR_MATH_COSINE] = "vector_math_cosine", - [NODE_VECTOR_MATH_TANGENT] = "vector_math_tangent", - }; - - if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { - return GPU_stack_link(mat, node, names[node->custom1], in, out); + const char *name = gpu_shader_get_name(node->custom1); + if (name != nullptr) { + return GPU_stack_link(mat, node, name, in, out); } else { return 0; @@ -80,8 +110,8 @@ static int gpu_shader_vector_math(GPUMaterial *mat, static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node) { - bNodeSocket *sockB = BLI_findlink(&node->inputs, 1); - bNodeSocket *sockC = BLI_findlink(&node->inputs, 2); + bNodeSocket *sockB = (bNodeSocket *)BLI_findlink(&node->inputs, 1); + bNodeSocket *sockC = (bNodeSocket *)BLI_findlink(&node->inputs, 2); bNodeSocket *sockScale = nodeFindSocket(node, SOCK_IN, "Scale"); bNodeSocket *sockVector = nodeFindSocket(node, SOCK_OUT, "Vector"); @@ -130,6 +160,43 @@ static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node } } +static void sh_node_vector_math_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder) +{ + using blender::float3; + + /* TODO: Implement other operations. */ + const int mode = builder.bnode().custom1; + switch (mode) { + case NODE_VECTOR_MATH_ADD: { + static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{ + "Add", [](float3 a, float3 b) { return a + b; }}; + builder.set_matching_fn(fn); + break; + } + case NODE_VECTOR_MATH_SUBTRACT: { + static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{ + "Subtract", [](float3 a, float3 b) { return a - b; }}; + builder.set_matching_fn(fn); + break; + } + case NODE_VECTOR_MATH_MULTIPLY: { + static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{ + "Multiply", [](float3 a, float3 b) { return a * b; }}; + builder.set_matching_fn(fn); + break; + } + case NODE_VECTOR_MATH_DIVIDE: { + static blender::fn::CustomMF_SI_SI_SO<float3, float3, float3> fn{ + "Divide", [](float3 a, float3 b) { return float3::safe_divide(a, b); }}; + builder.set_matching_fn(fn); + break; + } + default: + BLI_assert(false); + break; + }; +} + void register_node_type_sh_vect_math(void) { static bNodeType ntype; @@ -139,6 +206,7 @@ void register_node_type_sh_vect_math(void) node_type_label(&ntype, node_vector_math_label); node_type_gpu(&ntype, gpu_shader_vector_math); node_type_update(&ntype, node_shader_update_vector_math); + ntype.expand_in_mf_network = sh_node_vector_math_expand_in_mf_network; nodeRegisterType(&ntype); } diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp index 6246bf54f75..1764d0a910c 100644 --- a/source/blender/physics/intern/hair_volume.cpp +++ b/source/blender/physics/intern/hair_volume.cpp @@ -303,7 +303,7 @@ void BPH_hair_volume_grid_clear(HairGrid *grid) } } -BLI_INLINE bool hair_grid_point_valid(const float vec[3], float gmin[3], float gmax[3]) +BLI_INLINE bool hair_grid_point_valid(const float vec[3], const float gmin[3], const float gmax[3]) { return !(vec[0] < gmin[0] || vec[1] < gmin[1] || vec[2] < gmin[2] || vec[0] > gmax[0] || vec[1] > gmax[1] || vec[2] > gmax[2]); diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c index 5ec4c750d5d..54d38f3c10b 100644 --- a/source/blender/physics/intern/implicit_blender.c +++ b/source/blender/physics/intern/implicit_blender.c @@ -90,7 +90,7 @@ typedef struct fmatrix3x3 { /////////////////////////// /* simple vector code */ /* STATUS: verified */ -DO_INLINE void mul_fvector_S(float to[3], float from[3], float scalar) +DO_INLINE void mul_fvector_S(float to[3], const float from[3], float scalar) { to[0] = from[0] * scalar; to[1] = from[1] * scalar; @@ -429,7 +429,7 @@ DO_INLINE void mul_fmatrix_S(float matrix[3][3], float scalar) /* a vector multiplied by a 3x3 matrix */ /* STATUS: verified */ -DO_INLINE void mul_fvector_fmatrix(float *to, float *from, float matrix[3][3]) +DO_INLINE void mul_fvector_fmatrix(float *to, const float *from, float matrix[3][3]) { to[0] = matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2]; to[1] = matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2]; @@ -478,7 +478,7 @@ DO_INLINE void muladd_fmatrix_fvector(float to[3], float matrix[3][3], float fro to[2] += dot_v3v3(matrix[2], from); } -DO_INLINE void muladd_fmatrixT_fvector(float to[3], float matrix[3][3], float from[3]) +DO_INLINE void muladd_fmatrixT_fvector(float to[3], float matrix[3][3], const float from[3]) { to[0] += matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2]; to[1] += matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2]; @@ -1869,7 +1869,7 @@ bool BPH_mass_spring_force_spring_bending( } } -BLI_INLINE void poly_avg(lfVector *data, int *inds, int len, float r_avg[3]) +BLI_INLINE void poly_avg(lfVector *data, const int *inds, int len, float r_avg[3]) { float fact = 1.0f / (float)len; diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 5471fc25f37..2ad2794c76f 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -487,7 +487,7 @@ static int gl_buffer_type_from_py_buffer(Py_buffer *pybuffer) return -1; /* UNKNOWN */ } -static bool compare_dimensions(int ndim, int *dim1, Py_ssize_t *dim2) +static bool compare_dimensions(int ndim, const int *dim1, const Py_ssize_t *dim2) { for (int i = 0; i < ndim; i++) { if (dim1[i] != dim2[i]) { diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 957d49eb04e..4ee936aff91 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -50,7 +50,6 @@ #include "BKE_appdir.h" #include "BKE_blender_version.h" #include "BKE_global.h" -#include "BKE_lib_override.h" #include "DNA_ID.h" @@ -392,29 +391,6 @@ static PyObject *bpy_app_autoexec_fail_message_get(PyObject *UNUSED(self), void return PyC_UnicodeFromByte(G.autoexec_fail); } -PyDoc_STRVAR(bpy_app_use_override_library_doc, - "Boolean, whether library override is exposed in UI or not."); -static PyObject *bpy_app_use_override_library_get(PyObject *UNUSED(self), void *UNUSED(closure)) -{ - return PyBool_FromLong((long)BKE_lib_override_library_is_enabled()); -} - -static int bpy_app_use_override_library_set(PyObject *UNUSED(self), - PyObject *value, - void *UNUSED(closure)) -{ - const int param = PyC_Long_AsBool(value); - - if (param == -1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "bpy.app.use_override_library must be a boolean"); - return -1; - } - - BKE_lib_override_library_enable((const bool)param); - - return 0; -} - static PyGetSetDef bpy_app_getsets[] = { {"debug", bpy_app_debug_get, bpy_app_debug_set, bpy_app_debug_doc, (void *)G_DEBUG}, {"debug_ffmpeg", @@ -485,11 +461,6 @@ static PyGetSetDef bpy_app_getsets[] = { (void *)G_DEBUG_GPU_MEM}, {"debug_io", bpy_app_debug_get, bpy_app_debug_set, bpy_app_debug_doc, (void *)G_DEBUG_IO}, - {"use_override_library", - bpy_app_use_override_library_get, - bpy_app_use_override_library_set, - bpy_app_use_override_library_doc, - NULL}, {"use_event_simulate", bpy_app_global_flag_get, bpy_app_global_flag_set__only_disable, diff --git a/source/blender/python/intern/bpy_capi_utils.h b/source/blender/python/intern/bpy_capi_utils.h index fe086b61097..97344ce1326 100644 --- a/source/blender/python/intern/bpy_capi_utils.h +++ b/source/blender/python/intern/bpy_capi_utils.h @@ -48,6 +48,6 @@ struct bContext *BPy_GetContext(void); void BPy_SetContext(struct bContext *C); extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate); -extern void bpy_context_clear(struct bContext *C, PyGILState_STATE *gilstate); +extern void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate); #endif /* __BPY_CAPI_UTILS_H__ */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 6da1715b02d..be5a92309f2 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -136,7 +136,7 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate) } /* context should be used but not now because it causes some bugs */ -void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate) +void bpy_context_clear(bContext *UNUSED(C), const PyGILState_STATE *gilstate) { py_call_level--; diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 63137e094b7..3e30c81c8c6 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -2526,7 +2526,6 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) } if (mat1 && mat2) { -#ifdef USE_MATHUTILS_ELEM_MUL /* MATRIX * MATRIX */ float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; @@ -2540,7 +2539,6 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) mul_vn_vnvn(mat, mat1->matrix, mat2->matrix, mat1->num_col * mat1->num_row); return Matrix_CreatePyObject(mat, mat2->num_col, mat1->num_row, Py_TYPE(mat1)); -#endif } else if (mat2) { /*FLOAT/INT * MATRIX */ @@ -2584,7 +2582,6 @@ static PyObject *Matrix_imul(PyObject *m1, PyObject *m2) } if (mat1 && mat2) { -#ifdef USE_MATHUTILS_ELEM_MUL /* MATRIX *= MATRIX */ if ((mat1->num_row != mat2->num_row) || (mat1->num_col != mat2->num_col)) { PyErr_SetString(PyExc_ValueError, @@ -2594,14 +2591,6 @@ static PyObject *Matrix_imul(PyObject *m1, PyObject *m2) } mul_vn_vn(mat1->matrix, mat2->matrix, mat1->num_col * mat1->num_row); -#else - PyErr_Format(PyExc_TypeError, - "In place element-wise multiplication: " - "not supported between '%.200s' and '%.200s' types", - Py_TYPE(m1)->tp_name, - Py_TYPE(m2)->tp_name); - return NULL; -#endif } else if (mat1 && (((scalar = PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred()) == 0)) { /* MATRIX *= FLOAT/INT */ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 7ce0ea5f249..2b7761b7678 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -962,11 +962,9 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) } if (quat1 && quat2) { /* QUAT * QUAT (element-wise product) */ -#ifdef USE_MATHUTILS_ELEM_MUL float quat[QUAT_SIZE]; mul_vn_vnvn(quat, quat1->quat, quat2->quat, QUAT_SIZE); return Quaternion_CreatePyObject(quat, Py_TYPE(q1)); -#endif } /* the only case this can happen (for a supported type is "FLOAT * QUAT") */ else if (quat2) { /* FLOAT * QUAT */ @@ -1007,17 +1005,8 @@ static PyObject *Quaternion_imul(PyObject *q1, PyObject *q2) } } - if (quat1 && quat2) { /* QUAT *= QUAT (inplace element-wise product) */ -#ifdef USE_MATHUTILS_ELEM_MUL + if (quat1 && quat2) { /* QUAT *= QUAT (in-place element-wise product). */ mul_vn_vn(quat1->quat, quat2->quat, QUAT_SIZE); -#else - PyErr_Format(PyExc_TypeError, - "In place element-wise multiplication: " - "not supported between '%.200s' and '%.200s' types", - Py_TYPE(q1)->tp_name, - Py_TYPE(q2)->tp_name); - return NULL; -#endif } else if (quat1 && (((scalar = PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred()) == 0)) { /* QUAT *= FLOAT */ diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 15ae811fd91..4b47440a530 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1738,7 +1738,7 @@ static PyObject *vector_mul_float(VectorObject *vec, const float scalar) mul_vn_vn_fl(tvec, vec->vec, vec->size, scalar); return Vector_CreatePyObject_alloc(tvec, vec->size, Py_TYPE(vec)); } -#ifdef USE_MATHUTILS_ELEM_MUL + static PyObject *vector_mul_vec(VectorObject *vec1, VectorObject *vec2) { float *tvec = PyMem_Malloc(vec1->size * sizeof(float)); @@ -1752,7 +1752,7 @@ static PyObject *vector_mul_vec(VectorObject *vec1, VectorObject *vec2) mul_vn_vnvn(tvec, vec1->vec, vec2->vec, vec1->size); return Vector_CreatePyObject_alloc(tvec, vec1->size, Py_TYPE(vec1)); } -#endif + static PyObject *Vector_mul(PyObject *v1, PyObject *v2) { VectorObject *vec1 = NULL, *vec2 = NULL; @@ -1775,7 +1775,6 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) /* make sure v1 is always the vector */ if (vec1 && vec2) { -#ifdef USE_MATHUTILS_ELEM_MUL if (vec1->size != vec2->size) { PyErr_SetString(PyExc_ValueError, "Vector multiplication: " @@ -1785,7 +1784,6 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) /* element-wise product */ return vector_mul_vec(vec1, vec2); -#endif } else if (vec1) { if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* VEC * FLOAT */ @@ -1832,7 +1830,6 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) /* Intentionally don't support (Quaternion, Matrix) here, uses reverse order instead. */ if (vec1 && vec2) { -#ifdef USE_MATHUTILS_ELEM_MUL if (vec1->size != vec2->size) { PyErr_SetString(PyExc_ValueError, "Vector multiplication: " @@ -1840,16 +1837,8 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) return NULL; } - /* element-wise product inplace */ + /* Element-wise product in-place. */ mul_vn_vn(vec1->vec, vec2->vec, vec1->size); -#else - PyErr_Format(PyExc_TypeError, - "In place element-wise multiplication: " - "not supported between '%.200s' and '%.200s' types", - Py_TYPE(v1)->tp_name, - Py_TYPE(v2)->tp_name); - return NULL; -#endif } else if (vec1 && (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0)) { /* VEC *= FLOAT */ diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 59c0021e0f3..93dbac32c19 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1537,9 +1537,9 @@ static PyObject *M_Geometry_convex_hull_2d(PyObject *UNUSED(self), PyObject *poi * to fill values, with start_table and len_table giving the start index * and length of the toplevel_len sub-lists. */ -static PyObject *list_of_lists_from_arrays(int *array, - int *start_table, - int *len_table, +static PyObject *list_of_lists_from_arrays(const int *array, + const int *start_table, + const int *len_table, int toplevel_len) { PyObject *ret, *sublist; diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index 7c301f7d591..b30821a1b73 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -1319,8 +1319,11 @@ static void bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter) } } -static void bake_ibuf_normalize_displacement( - ImBuf *ibuf, float *displacement, char *mask, float displacement_min, float displacement_max) +static void bake_ibuf_normalize_displacement(ImBuf *ibuf, + const float *displacement, + const char *mask, + float displacement_min, + float displacement_max) { int i; const float *current_displacement = displacement; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 9926e08c968..b37eeed3681 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -902,7 +902,7 @@ static void do_2d_mapping( float fx, fy, fac1, area[8]; int ok, proj, areaflag = 0, wrap; - /* mtex variables localized, only cubemap doesn't cooperate yet... */ + /* #MTex variables localized, only cube-map doesn't cooperate yet. */ wrap = mtex->mapping; tex = mtex->tex; diff --git a/source/blender/shader_fx/CMakeLists.txt b/source/blender/shader_fx/CMakeLists.txt index 740f7c126d1..a12f36f9713 100644 --- a/source/blender/shader_fx/CMakeLists.txt +++ b/source/blender/shader_fx/CMakeLists.txt @@ -24,8 +24,8 @@ set(INC intern ../blenfont ../blenkernel - ../blentranslation ../blenlib + ../blentranslation ../bmesh ../depsgraph ../editors/include diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 482589e2ccb..3d4c84805f9 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -744,8 +744,13 @@ void *WM_jobs_customdata_get(struct wmJob *); void WM_jobs_customdata_set(struct wmJob *, void *customdata, void (*free)(void *)); void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote); void WM_jobs_delay_start(struct wmJob *, double delay_time); + +typedef void (*wm_jobs_start_callback)(void *custom_data, + short *stop, + short *do_update, + float *progress); void WM_jobs_callbacks(struct wmJob *, - void (*startjob)(void *, short *, short *, float *), + wm_jobs_start_callback startjob, void (*initjob)(void *), void (*update)(void *), void (*endjob)(void *)); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index d5a240a358e..f431a6f431b 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1027,13 +1027,6 @@ void wm_homefile_read(bContext *C, }, NULL); } - if (BLI_listbase_is_empty(&U.themes)) { - if (G.debug & G_DEBUG) { - printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", - filepath_startup); - } - success = false; - } if (success) { if (update_defaults) { if (use_data) { diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index c10f03f3dab..87a19d832c9 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -86,7 +86,7 @@ struct wmJob { * This performs the actual parallel work. * Executed in worker thread(s). */ - void (*startjob)(void *, short *stop, short *do_update, float *progress); + wm_jobs_start_callback startjob; /** * Called if thread defines so (see `do_update` flag), and max once per timer step. * Executed in main thread. @@ -378,7 +378,7 @@ void WM_jobs_delay_start(wmJob *wm_job, double delay_time) } void WM_jobs_callbacks(wmJob *wm_job, - void (*startjob)(void *, short *, short *, float *), + wm_jobs_start_callback startjob, void (*initjob)(void *), void (*update)(void *), void (*endjob)(void *)) diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index 4aabfb76acb..20a75ebe3b9 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -51,7 +51,6 @@ # include "BKE_global.h" # include "BKE_image.h" # include "BKE_lib_id.h" -# include "BKE_lib_override.h" # include "BKE_main.h" # include "BKE_report.h" # include "BKE_scene.h" @@ -619,7 +618,6 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo printf("Misc Options:\n"); BLI_argsPrintArgDoc(ba, "--app-template"); BLI_argsPrintArgDoc(ba, "--factory-startup"); - BLI_argsPrintArgDoc(ba, "--disable-library-override"); BLI_argsPrintArgDoc(ba, "--enable-event-simulate"); printf("\n"); BLI_argsPrintArgDoc(ba, "--env-system-datafiles"); @@ -1121,17 +1119,6 @@ static int arg_handle_factory_startup_set(int UNUSED(argc), return 0; } -static const char arg_handle_disable_override_library_doc[] = - "\n\t" - "Disable Library Override features in the UI."; -static int arg_handle_disable_override_library(int UNUSED(argc), - const char **UNUSED(argv), - void *UNUSED(data)) -{ - BKE_lib_override_library_enable(false); - return 0; -} - static const char arg_handle_enable_event_simulate_doc[] = "\n\t" "Enable event simulation testing feature 'bpy.types.Window.event_simulate'."; @@ -2225,8 +2212,6 @@ void main_args_setup(bContext *C, bArgs *ba) BLI_argsAdd(ba, 1, NULL, "--app-template", CB(arg_handle_app_template), NULL); BLI_argsAdd(ba, 1, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL); - BLI_argsAdd( - ba, 1, NULL, "--disable-library-override", CB(arg_handle_disable_override_library), NULL); BLI_argsAdd(ba, 1, NULL, "--enable-event-simulate", CB(arg_handle_enable_event_simulate), NULL); /* TODO, add user env vars? */ diff --git a/tests/gtests/blenlib/BLI_span_test.cc b/tests/gtests/blenlib/BLI_span_test.cc index ed3cce6d2cf..ccc63fd80eb 100644 --- a/tests/gtests/blenlib/BLI_span_test.cc +++ b/tests/gtests/blenlib/BLI_span_test.cc @@ -285,4 +285,14 @@ TEST(span, CastLargerSize) EXPECT_EQ(new_a_span.size(), 2u); } +TEST(span, VoidPointerSpan) +{ + int a; + float b; + double c; + + auto func1 = [](Span<void *> span) { EXPECT_EQ(span.size(), 3u); }; + func1({&a, &b, &c}); +} + } // namespace blender diff --git a/tests/gtests/blenlib/BLI_vector_test.cc b/tests/gtests/blenlib/BLI_vector_test.cc index 92fb12fb4e5..25435739a43 100644 --- a/tests/gtests/blenlib/BLI_vector_test.cc +++ b/tests/gtests/blenlib/BLI_vector_test.cc @@ -651,4 +651,13 @@ TEST(vector, OveralignedValues) } } +TEST(vector, ConstructVoidPointerVector) +{ + int a; + float b; + double c; + Vector<void *> vec = {&a, &b, &c}; + EXPECT_EQ(vec.size(), 3u); +} + } // namespace blender diff --git a/tests/gtests/functions/FN_attributes_ref_test.cc b/tests/gtests/functions/FN_attributes_ref_test.cc index fee8c5dc058..1c05bb930db 100644 --- a/tests/gtests/functions/FN_attributes_ref_test.cc +++ b/tests/gtests/functions/FN_attributes_ref_test.cc @@ -65,8 +65,7 @@ TEST(mutable_attributes_ref, ComplexTest) Array<float> sizes(amount); Array<std::string> names(amount); - Array<void *> buffers = { - (void *)positions.data(), (void *)ids.data(), (void *)sizes.data(), (void *)names.data()}; + Array<void *> buffers = {positions.data(), ids.data(), sizes.data(), names.data()}; MutableAttributesRef attributes{info, buffers, IndexRange(1, 3)}; EXPECT_EQ(attributes.size(), 3); EXPECT_EQ(attributes.info().size(), 4); diff --git a/tests/gtests/functions/FN_multi_function_test.cc b/tests/gtests/functions/FN_multi_function_test.cc index 51115e4cd6b..8cc8f91a300 100644 --- a/tests/gtests/functions/FN_multi_function_test.cc +++ b/tests/gtests/functions/FN_multi_function_test.cc @@ -364,4 +364,23 @@ TEST(multi_function, CustomMF_GenericConstantArray) } } +TEST(multi_function, CustomMF_Convert) +{ + CustomMF_Convert<float, int> fn; + + Array<float> inputs = {5.4f, 7.1f, 9.0f}; + Array<int> outputs(inputs.size(), 0); + + MFParamsBuilder params(fn, inputs.size()); + params.add_readonly_single_input(inputs.as_span()); + params.add_uninitialized_single_output(outputs.as_mutable_span()); + + MFContextBuilder context; + fn.call({0, 2}, params, context); + + EXPECT_EQ(outputs[0], 5); + EXPECT_EQ(outputs[1], 0); + EXPECT_EQ(outputs[2], 9); +} + } // namespace blender::fn |