From 715a37b662133b4314732ec7373881c6e9928c79 Mon Sep 17 00:00:00 2001 From: Falk David Date: Tue, 15 Oct 2024 13:47:24 +0200 Subject: [PATCH 1/5] Fix #129049: Solid mode doesn't render strokes correctly Caused by 364d62e59b15aeb60f13e7b9f389e5c077aebd7e. In draw mode, we want to make sure to show vertex colors by default because users can draw with them. Otherwise this can lead to unexpected behavior in solid shading mode when vertex colors used to not be rendered in draw mode. The previous fix tried to do this by enforcing the `V3D_SHADING_VERTEX_COLOR` mode in draw mode. But this has the side effect that the material stroke and fill color are overriden with pure white. To fix the issue correctly, simply ensure that `vert_col_opacity` in `grease_pencil_layer_cache_add` is set to 1.0f. This means that vertex colors and material colors are shown just like in the render. Also resolves #128680. Pull Request: https://projects.blender.org/blender/blender/pulls/129054 --- source/blender/draw/engines/gpencil/gpencil_cache_utils.cc | 5 ++++- source/blender/draw/engines/gpencil/gpencil_engine_c.cc | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc index 2abbc12cc3b..375d0112c8e 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc @@ -543,8 +543,11 @@ GPENCIL_tLayer *grease_pencil_layer_cache_add(GPENCIL_PrivateData *pd, const bool is_in_front = (ob->dtx & OB_DRAW_IN_FRONT); const bool override_vertcol = (pd->v3d_color_type != -1); + /* In draw mode and vertex paint mode it's possible to draw vertex colors so we want to make sure + * to render them. Otherwise this can lead to unexpected behavior. */ const bool is_vert_col_mode = (pd->v3d_color_type == V3D_SHADING_VERTEX_COLOR) || - (ob->mode == OB_MODE_VERTEX_PAINT) || pd->is_render; + (ob->mode & OB_MODE_VERTEX_PAINT) != 0 || + (ob->mode & OB_MODE_PAINT_GREASE_PENCIL) != 0 || pd->is_render; const bool is_viewlayer_render = pd->is_render && !layer.view_layer_name().is_empty() && STREQ(pd->view_layer->name, layer.view_layer_name().c_str()); const bool disable_masks_render = is_viewlayer_render && diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc index 842bdfeb0cb..ad32d3f242b 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc @@ -117,9 +117,9 @@ void GPENCIL_engine_init(void *ved) use_scene_world = V3D_USES_SCENE_WORLD(v3d); stl->pd->v3d_color_type = (v3d->shading.type == OB_SOLID) ? v3d->shading.color_type : -1; - /* Special case: If we're in Draw or Vertex Paint mode, show vertex colors. */ + /* Special case: If we're in Vertex Paint mode, enforce V3D_SHADING_VERTEX_COLOR setting.*/ if (v3d->shading.type == OB_SOLID && ctx->obact && - ELEM(ctx->obact->mode, OB_MODE_PAINT_GREASE_PENCIL, OB_MODE_VERTEX_GREASE_PENCIL)) + (ctx->obact->mode & OB_MODE_VERTEX_GREASE_PENCIL) != 0) { stl->pd->v3d_color_type = V3D_SHADING_VERTEX_COLOR; } From 5be60642adba9d40bd860aeb5c93e32c68b6aa6f Mon Sep 17 00:00:00 2001 From: sean-murray Date: Tue, 15 Oct 2024 14:17:05 +0200 Subject: [PATCH 2/5] Fix: GPv3: Crash when using build modifier with cyclic curves The build modifier crashes when getting lengths of cyclic curves because `evaluated_points_by_curve` was previously always called with `cyclic` parameter set to `false`. The `cyclic` parameter necessary for `curves::segments_num` to return correct number of segments. Pull Request: https://projects.blender.org/blender/blender/pulls/128955 --- .../blender/modifiers/intern/MOD_grease_pencil_build.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_build.cc b/source/blender/modifiers/intern/MOD_grease_pencil_build.cc index 4e93e712b75..ba8b071fd61 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_build.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_build.cc @@ -112,11 +112,13 @@ static Array point_counts_to_keep_concurrent(const bke::CurvesGeometry &cur { const int stroke_count = curves.curves_num(); const OffsetIndices points_by_curve = curves.points_by_curve(); + const VArray cyclic = curves.cyclic(); curves.ensure_evaluated_lengths(); float max_length = 0; for (const int stroke : curves.curves_range()) { - const float len = curves.evaluated_length_total_for_curve(stroke, false); + const bool stroke_cyclic = cyclic[stroke]; + const float len = curves.evaluated_length_total_for_curve(stroke, stroke_cyclic); max_length = math::max(max_length, len); } @@ -128,7 +130,9 @@ static Array point_counts_to_keep_concurrent(const bke::CurvesGeometry &cur } auto get_stroke_factor = [&](const float factor, const int index) { - const float max_factor = max_length / curves.evaluated_length_total_for_curve(index, false); + const bool stroke_cyclic = cyclic[index]; + const float max_factor = max_length / + curves.evaluated_length_total_for_curve(index, stroke_cyclic); if (time_alignment == MOD_GREASE_PENCIL_BUILD_TIMEALIGN_START) { if (clamp_points) { return std::clamp(factor * max_factor, 0.0f, 1.0f); From 5f84f934a89ad30bf6e3fae32d5abfe15ad9084e Mon Sep 17 00:00:00 2001 From: Thomas Lachmann Date: Tue, 15 Oct 2024 15:08:09 +0200 Subject: [PATCH 3/5] Fix #127087: GPv3: Initialize/copy attributes when adding/duplicating layers - set default values for attributes on new GP layer - copy attributes when duplicating GP layer Pull Request: https://projects.blender.org/blender/blender/pulls/128344 --- source/blender/blenkernel/intern/grease_pencil.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index 44afcfc9eb2..5d048a6bf5d 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -3243,7 +3243,7 @@ blender::bke::greasepencil::Layer &GreasePencil::add_layer(const blender::String using namespace blender; std::string unique_name = check_name_is_unique ? unique_layer_name(*this, name) : name.c_str(); const int numLayers = layers().size(); - CustomData_realloc(&layers_data, numLayers, numLayers + 1); + CustomData_realloc(&layers_data, numLayers, numLayers + 1, CD_SET_DEFAULT); bke::greasepencil::Layer *new_layer = MEM_new(__func__, unique_name); /* Hide masks by default. */ new_layer->base.flag |= GP_LAYER_TREE_NODE_HIDE_MASKS; @@ -3288,8 +3288,15 @@ blender::bke::greasepencil::Layer &GreasePencil::duplicate_layer( { using namespace blender; std::string unique_name = unique_layer_name(*this, duplicate_layer.name()); + std::optional duplicate_layer_idx = get_layer_index(duplicate_layer); const int numLayers = layers().size(); CustomData_realloc(&layers_data, numLayers, numLayers + 1); + if (duplicate_layer_idx.has_value()) { + for (const int layer_index : IndexRange(layers_data.totlayer)) { + CustomData_copy_data_layer( + &layers_data, &layers_data, layer_index, layer_index, *duplicate_layer_idx, numLayers, 1); + } + } bke::greasepencil::Layer *new_layer = MEM_new(__func__, duplicate_layer); root_group().add_node(new_layer->as_node()); From 1e2e90e2d4185e21570a2d53159dd1d9b445c7b5 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Tue, 15 Oct 2024 16:39:17 +0200 Subject: [PATCH 4/5] Fix #129051: GPv3: Write default `u_scale` in draw tool The `u_scale` should be given a default value of `1.0f` so that newly drawn strokes with the drawing already having `u_scale` attributes will have correct texture mapping size instead of a default of `0.0f`. Pull Request: https://projects.blender.org/blender/blender/pulls/129060 --- source/blender/editors/sculpt_paint/grease_pencil_paint.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc index a67d7c82611..cdd32eb4433 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc @@ -545,13 +545,17 @@ struct PaintOperationExecutor { "cyclic", bke::AttrDomain::Curve); bke::SpanAttributeWriter softness = attributes.lookup_or_add_for_write_span( "softness", bke::AttrDomain::Curve); + bke::SpanAttributeWriter u_scale = attributes.lookup_or_add_for_write_span( + "u_scale", bke::AttrDomain::Curve); cyclic.span[active_curve] = false; materials.span[active_curve] = material_index; softness.span[active_curve] = softness_; - curve_attributes_to_skip.add_multiple({"material_index", "cyclic", "softness"}); + u_scale.span[active_curve] = 1.0f; + curve_attributes_to_skip.add_multiple({"material_index", "cyclic", "softness", "u_scale"}); cyclic.finish(); materials.finish(); softness.finish(); + u_scale.finish(); if (settings_->uv_random > 0.0f || attributes.contains("rotation")) { bke::SpanAttributeWriter rotations = attributes.lookup_or_add_for_write_span( From 1458ba1d6c81d776a2d92b2a1bb54dcec1f49c2d Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Tue, 15 Oct 2024 18:26:31 +0200 Subject: [PATCH 5/5] Bump Linux libs --- lib/linux_x64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linux_x64 b/lib/linux_x64 index 5991f23cb28..3296c27ab0c 160000 --- a/lib/linux_x64 +++ b/lib/linux_x64 @@ -1 +1 @@ -Subproject commit 5991f23cb2876cd8359bff51ef1507630517f50e +Subproject commit 3296c27ab0c715872f3e610bad454b69b0182249