Merge branch 'blender-v4.3-release'

This commit is contained in:
Sebastian Parborg
2024-10-15 18:27:04 +02:00
6 changed files with 26 additions and 8 deletions

View File

@@ -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<bke::greasepencil::Layer>(__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<int> 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<bke::greasepencil::Layer>(__func__,
duplicate_layer);
root_group().add_node(new_layer->as_node());

View File

@@ -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 &&

View File

@@ -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;
}

View File

@@ -545,13 +545,17 @@ struct PaintOperationExecutor {
"cyclic", bke::AttrDomain::Curve);
bke::SpanAttributeWriter<float> softness = attributes.lookup_or_add_for_write_span<float>(
"softness", bke::AttrDomain::Curve);
bke::SpanAttributeWriter<float> u_scale = attributes.lookup_or_add_for_write_span<float>(
"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<float> rotations = attributes.lookup_or_add_for_write_span<float>(

View File

@@ -112,11 +112,13 @@ static Array<int> point_counts_to_keep_concurrent(const bke::CurvesGeometry &cur
{
const int stroke_count = curves.curves_num();
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
const VArray<bool> 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<int> 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);