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 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()); 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; } 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( 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);