GPv3: Support crazyspace in selection code

This adds `GreasePencilEditHints` and correctly implements
`crazyspace::get_evaluated_grease_pencil_drawing_deformation`
to support querying the deformation of points after evaluation.
This is needed for users to properly select points in edit mode while
seeing the effects of the modifiers.

Pull Request: https://projects.blender.org/blender/blender/pulls/113586
This commit is contained in:
Falk David
2023-10-12 15:42:04 +02:00
committed by Falk David
parent 7501a686c2
commit 49b21eba11
21 changed files with 218 additions and 109 deletions

View File

@@ -29,6 +29,7 @@ class ComponentAttributeProviders;
class CurvesEditHints;
class Instances;
class GeometryComponent;
class GreasePencilEditHints;
} // namespace blender::bke
namespace blender::bke {
@@ -668,6 +669,10 @@ class GeometryComponentEditData final : public GeometryComponent {
* example, when the curves have been converted to a mesh.
*/
std::unique_ptr<CurvesEditHints> curves_edit_hints_;
/**
* Information about how drawings on the grease pencil layers are manipulated during evaluation.
*/
std::unique_ptr<GreasePencilEditHints> grease_pencil_edit_hints_;
GeometryComponentEditData();
@@ -683,7 +688,7 @@ class GeometryComponentEditData final : public GeometryComponent {
* lost, which would make curves sculpt mode fall back to using original curve positions instead
* of deformed ones.
*/
static void remember_deformed_curve_positions_if_necessary(GeometrySet &geometry);
static void remember_deformed_positions_if_necessary(GeometrySet &geometry);
static constexpr inline GeometryComponent::Type static_type = GeometryComponent::Type::Edit;
};

View File

@@ -666,6 +666,30 @@ class GreasePencilRuntime {
~GreasePencilRuntime() {}
};
class GreasePencilDrawingEditHints {
public:
std::optional<Array<float3>> positions;
};
/**
* Used to propagate deformation data through modifier evaluation.
*/
class GreasePencilEditHints {
public:
/**
* Original data that the edit hints below are meant to be used for.
*/
const GreasePencil &grease_pencil_id_orig;
GreasePencilEditHints(const GreasePencil &grease_pencil_id_orig) : grease_pencil_id_orig(grease_pencil_id_orig) {}
/**
* Array of #GreasePencilDrawingEditHints. There is one edit hint for each evaluated drawing.
* Note: The index for each element is the layer index.
*/
std::optional<Array<GreasePencilDrawingEditHints>> drawing_hints;
};
} // namespace blender::bke
inline blender::bke::greasepencil::Drawing &GreasePencilDrawing::wrap()

View File

@@ -670,34 +670,73 @@ GeometryDeformation get_evaluated_curves_deformation(const Depsgraph &depsgraph,
GeometryDeformation get_evaluated_grease_pencil_drawing_deformation(const Object *ob_eval,
const Object &ob_orig,
const int drawing_index)
const int layer_index)
{
BLI_assert(ob_orig.type == OB_GREASE_PENCIL);
const GreasePencil &grease_pencil = *static_cast<const GreasePencil *>(ob_eval->data);
const GreasePencil &grease_pencil_orig = *static_cast<const GreasePencil *>(ob_orig.data);
const int eval_frame = grease_pencil.runtime->eval_frame;
const int drawing_index = grease_pencil_orig.layers()[layer_index]->drawing_index_at(eval_frame);
if (drawing_index == -1) {
return {};
}
const GreasePencilDrawingBase *drawing_base = grease_pencil_orig.drawing(drawing_index);
if (drawing_base->type != GP_DRAWING) {
return {};
}
const bke::greasepencil::Drawing &drawing_orig =
reinterpret_cast<const GreasePencilDrawing *>(drawing_base)->wrap();
GeometryDeformation deformation;
if (drawing_base->type == GP_DRAWING) {
const auto *drawing = reinterpret_cast<const GreasePencilDrawing *>(drawing_base);
/* Use the undeformed positions by default. */
deformation.positions = drawing->wrap().strokes().positions();
}
else if (drawing_base->type == GP_DRAWING_REFERENCE) {
/* TODO */
}
/* Use the undeformed positions by default. */
deformation.positions = drawing_orig.strokes().positions();
if (ob_eval == nullptr) {
return deformation;
}
const GeometrySet *geometry_eval = ob_eval->runtime.geometry_set_eval;
if (geometry_eval == nullptr) {
if (geometry_eval == nullptr || !geometry_eval->has<GeometryComponentEditData>()) {
return deformation;
}
/* TODO: Read `GeometryComponentEditData` from `geometry_eval` and populate deformation with it.
*/
/* If there are edit hints, use the positions of those. */
const GeometryComponentEditData &edit_component_eval =
*geometry_eval->get_component<GeometryComponentEditData>();
const GreasePencilEditHints *edit_hints = edit_component_eval.grease_pencil_edit_hints_.get();
if (edit_hints != nullptr && &edit_hints->grease_pencil_id_orig == &grease_pencil_orig &&
edit_hints->drawing_hints.has_value())
{
BLI_assert(edit_hints->drawing_hints->size() == grease_pencil_orig.layers().size());
const GreasePencilDrawingEditHints &drawing_hints =
edit_hints->drawing_hints.value()[layer_index];
if (drawing_hints.positions.has_value()) {
deformation.positions = *drawing_hints.positions;
}
}
/* Otherwise use the positions of the evaluated drawing if the number of points match. */
if (const GreasePencilComponent *grease_pencil_component_eval =
geometry_eval->get_component<GreasePencilComponent>())
{
if (const GreasePencil *grease_pencil_eval = grease_pencil_component_eval->get()) {
Span<const bke::greasepencil::Layer *> layers_eval = grease_pencil_eval->layers();
const bke::greasepencil::Layer *layer_eval = layers_eval[layer_index];
const int drawing_index_eval = layer_eval->drawing_index_at(eval_frame);
if (drawing_index_eval != -1) {
const GreasePencilDrawingBase *drawing_base_eval = grease_pencil_eval->drawing(
drawing_index_eval);
if (drawing_base_eval->type != GP_DRAWING) {
return {};
}
const bke::greasepencil::Drawing &drawing_eval =
reinterpret_cast<const GreasePencilDrawing *>(drawing_base_eval)->wrap();
if (drawing_eval.strokes().points_num() == drawing_orig.strokes().points_num()) {
deformation.positions = drawing_eval.strokes().positions();
}
}
}
}
return deformation;
}

View File

@@ -4,6 +4,7 @@
#include "BKE_curves.hh"
#include "BKE_geometry_set.hh"
#include "BKE_grease_pencil.hh"
namespace blender::bke {
@@ -15,6 +16,10 @@ GeometryComponent *GeometryComponentEditData::copy() const
if (curves_edit_hints_) {
new_component->curves_edit_hints_ = std::make_unique<CurvesEditHints>(*curves_edit_hints_);
}
if (grease_pencil_edit_hints_) {
new_component->grease_pencil_edit_hints_ = std::make_unique<GreasePencilEditHints>(
*grease_pencil_edit_hints_);
}
return new_component;
}
@@ -32,24 +37,18 @@ void GeometryComponentEditData::clear()
{
BLI_assert(this->is_mutable() || this->is_expired());
curves_edit_hints_.reset();
grease_pencil_edit_hints_.reset();
}
void GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(
GeometrySet &geometry)
static void remember_deformed_curve_positions_if_necessary(
const Curves *curves_id, GeometryComponentEditData &edit_component)
{
/* This component should be created at the start of object evaluation if it's necessary. */
if (!geometry.has<GeometryComponentEditData>()) {
return;
}
GeometryComponentEditData &edit_component =
geometry.get_component_for_write<GeometryComponentEditData>();
if (!edit_component.curves_edit_hints_) {
return;
}
if (edit_component.curves_edit_hints_->positions.has_value()) {
return;
}
const Curves *curves_id = geometry.get_curves();
if (curves_id == nullptr) {
return;
}
@@ -62,4 +61,57 @@ void GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(
edit_component.curves_edit_hints_->positions->as_mutable_span().copy_from(curves.positions());
}
static void remember_deformed_grease_pencil_if_necessary(const GreasePencil *grease_pencil,
GeometryComponentEditData &edit_component)
{
if (!edit_component.grease_pencil_edit_hints_) {
return;
}
if (edit_component.grease_pencil_edit_hints_->drawing_hints.has_value()) {
return;
}
if (grease_pencil == nullptr) {
return;
}
const GreasePencil &orig_grease_pencil =
edit_component.grease_pencil_edit_hints_->grease_pencil_id_orig;
const Span<const bke::greasepencil::Layer *> layers = grease_pencil->layers();
const Span<const bke::greasepencil::Layer *> orig_layers = orig_grease_pencil.layers();
const int layers_num = layers.size();
if (layers_num != orig_layers.size()) {
return;
}
edit_component.grease_pencil_edit_hints_->drawing_hints.emplace(layers_num);
MutableSpan<GreasePencilDrawingEditHints> all_hints =
*edit_component.grease_pencil_edit_hints_->drawing_hints;
for (const int layer_index : layers.index_range()) {
const bke::greasepencil::Drawing *drawing = greasepencil::get_eval_grease_pencil_layer_drawing(
*grease_pencil, layer_index);
const bke::greasepencil::Layer &orig_layer = *orig_layers[layer_index];
const bke::greasepencil::Drawing *orig_drawing = orig_grease_pencil.get_drawing_at(
&orig_layer, grease_pencil->runtime->eval_frame);
GreasePencilDrawingEditHints &drawing_hints = all_hints[layer_index];
if (!drawing || !orig_drawing) {
continue;
}
if (drawing->strokes().points_num() != orig_drawing->strokes().points_num()) {
continue;
}
drawing_hints.positions->as_mutable_span().copy_from(drawing->strokes().positions());
}
}
void GeometryComponentEditData::remember_deformed_positions_if_necessary(GeometrySet &geometry)
{
/* This component should be created at the start of object evaluation if it's necessary. */
if (!geometry.has<GeometryComponentEditData>()) {
return;
}
GeometryComponentEditData &edit_component =
geometry.get_component_for_write<GeometryComponentEditData>();
remember_deformed_curve_positions_if_necessary(geometry.get_curves(), edit_component);
remember_deformed_grease_pencil_if_necessary(geometry.get_grease_pencil(), edit_component);
}
} // namespace blender::bke

View File

@@ -1183,6 +1183,14 @@ void BKE_grease_pencil_data_update(Depsgraph *depsgraph, Scene *scene, Object *o
grease_pencil->runtime->eval_frame = int(DEG_get_ctime(depsgraph));
GeometrySet geometry_set = GeometrySet::from_grease_pencil(grease_pencil,
GeometryOwnershipType::ReadOnly);
/* Only add the edit hint component in edit mode for now so users can properly select deformed
* drawings. */
if (object->mode == OB_MODE_EDIT) {
GeometryComponentEditData &edit_component =
geometry_set.get_component_for_write<GeometryComponentEditData>();
edit_component.grease_pencil_edit_hints_ = std::make_unique<GreasePencilEditHints>(
*static_cast<const GreasePencil *>(DEG_get_original_object(object)->data));
}
grease_pencil_evaluate_modifiers(depsgraph, scene, object, geometry_set);
if (!geometry_set.has_grease_pencil()) {
@@ -1760,57 +1768,18 @@ enum ForeachDrawingMode {
EDITABLE,
};
static void foreach_drawing_ex(
GreasePencil &grease_pencil,
const int frame,
const ForeachDrawingMode mode,
blender::FunctionRef<void(int, blender::bke::greasepencil::Drawing &)> function)
{
using namespace blender::bke::greasepencil;
blender::Span<GreasePencilDrawingBase *> drawings = grease_pencil.drawings();
for (const Layer *layer : grease_pencil.layers()) {
switch (mode) {
case VISIBLE: {
if (!layer->is_visible()) {
continue;
}
break;
}
case EDITABLE: {
if (!layer->is_editable()) {
continue;
}
break;
}
}
int index = layer->drawing_index_at(frame);
if (index == -1) {
continue;
}
GreasePencilDrawingBase *drawing_base = drawings[index];
if (drawing_base->type == GP_DRAWING) {
GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(drawing_base);
function(index, drawing->wrap());
}
else if (drawing_base->type == GP_DRAWING_REFERENCE) {
/* TODO: Drawing references are not implemented yet. */
BLI_assert_unreachable();
}
}
}
static void foreach_drawing_ex(
const GreasePencil &grease_pencil,
const int frame,
const ForeachDrawingMode mode,
blender::FunctionRef<void(int, const blender::bke::greasepencil::Drawing &)> function)
blender::FunctionRef<void(const int, const blender::bke::greasepencil::Drawing &)> function)
{
using namespace blender::bke::greasepencil;
blender::Span<const GreasePencilDrawingBase *> drawings = grease_pencil.drawings();
for (const Layer *layer : grease_pencil.layers()) {
blender::Span<const Layer *> layers = grease_pencil.layers();
for (const int layer_i : layers.index_range()) {
const Layer *layer = layers[layer_i];
switch (mode) {
case VISIBLE: {
if (!layer->is_visible()) {
@@ -1834,7 +1803,7 @@ static void foreach_drawing_ex(
if (drawing_base->type == GP_DRAWING) {
const GreasePencilDrawing *drawing = reinterpret_cast<const GreasePencilDrawing *>(
drawing_base);
function(index, drawing->wrap());
function(layer_i, drawing->wrap());
}
else if (drawing_base->type == GP_DRAWING_REFERENCE) {
/* TODO: Drawing references are not implemented yet. */
@@ -1845,23 +1814,38 @@ static void foreach_drawing_ex(
void GreasePencil::foreach_visible_drawing(
const int frame,
blender::FunctionRef<void(int, blender::bke::greasepencil::Drawing &)> function)
blender::FunctionRef<void(const int, blender::bke::greasepencil::Drawing &)> function)
{
foreach_drawing_ex(*this, frame, VISIBLE, function);
foreach_drawing_ex(
*this,
frame,
VISIBLE,
[&](const int layer_index, const blender::bke::greasepencil::Drawing &drawing) {
/* We const_cast here to be able to implement `foreach_drawing_ex` only once. */
function(layer_index, const_cast<blender::bke::greasepencil::Drawing &>(drawing));
});
}
void GreasePencil::foreach_visible_drawing(
const int frame,
blender::FunctionRef<void(int, const blender::bke::greasepencil::Drawing &)> function) const
blender::FunctionRef<void(const int, const blender::bke::greasepencil::Drawing &)> function)
const
{
foreach_drawing_ex(*this, frame, VISIBLE, function);
}
void GreasePencil::foreach_editable_drawing(
const int frame,
blender::FunctionRef<void(int, blender::bke::greasepencil::Drawing &)> function)
blender::FunctionRef<void(const int, blender::bke::greasepencil::Drawing &)> function)
{
foreach_drawing_ex(*this, frame, EDITABLE, function);
foreach_drawing_ex(
*this,
frame,
EDITABLE,
[&](const int layer_index, const blender::bke::greasepencil::Drawing &drawing) {
/* We const_cast here to be able to implement `foreach_drawing_ex` only once. */
function(layer_index, const_cast<blender::bke::greasepencil::Drawing &>(drawing));
});
}
std::optional<blender::Bounds<blender::float3>> GreasePencil::bounds_min_max() const
@@ -1870,7 +1854,7 @@ std::optional<blender::Bounds<blender::float3>> GreasePencil::bounds_min_max() c
std::optional<Bounds<float3>> bounds;
this->foreach_visible_drawing(
this->runtime->eval_frame,
[&](int /*drawing_index*/, const bke::greasepencil::Drawing &drawing) {
[&](const int /*layer_index*/, const bke::greasepencil::Drawing &drawing) {
const bke::CurvesGeometry &curves = drawing.strokes();
bounds = bounds::merge(bounds, curves.bounds_min_max());
});

View File

@@ -205,7 +205,7 @@ static void grease_pencil_geom_batch_ensure(GreasePencil &grease_pencil, int cfr
/* Get the visible drawings. */
Vector<Drawing *> drawings;
grease_pencil.foreach_visible_drawing(
cfra, [&](int /*drawing_index*/, Drawing &drawing) { drawings.append(&drawing); });
cfra, [&](const int /*layer_index*/, Drawing &drawing) { drawings.append(&drawing); });
/* First, count how many vertices and triangles are needed for the whole object. Also record the
* offsets into the curves for the vertices and triangles. */

View File

@@ -306,7 +306,7 @@ static int grease_pencil_stroke_smooth_exec(bContext *C, wmOperator *op)
}
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int /*drawing_index*/, bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [&](const int /*layer_index*/, bke::greasepencil::Drawing &drawing) {
bke::CurvesGeometry &curves = drawing.strokes_for_write();
if (curves.points_num() == 0) {
return;
@@ -454,7 +454,7 @@ static int grease_pencil_stroke_simplify_exec(bContext *C, wmOperator *op)
bool changed = false;
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int /*drawing_index*/, bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [&](const int /*layer_index*/, bke::greasepencil::Drawing &drawing) {
bke::CurvesGeometry &curves = drawing.strokes_for_write();
if (curves.points_num() == 0) {
return;
@@ -661,7 +661,7 @@ static int grease_pencil_dissolve_exec(bContext *C, wmOperator *op)
bool changed = false;
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int /*drawing_index*/, bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [&](const int /*layer_index*/, bke::greasepencil::Drawing &drawing) {
bke::CurvesGeometry &curves = drawing.strokes_for_write();
if (curves.points_num() == 0) {
return;

View File

@@ -37,7 +37,7 @@ static int select_all_exec(bContext *C, wmOperator *op)
eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int /*drawing_index*/, blender::bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [&](const int /*layer_index*/, blender::bke::greasepencil::Drawing &drawing) {
blender::ed::curves::select_all(drawing.strokes_for_write(), selection_domain, action);
});
@@ -70,7 +70,7 @@ static int select_more_exec(bContext *C, wmOperator * /*op*/)
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [](int /*drawing_index*/, blender::bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [](const int /*layer_index*/, blender::bke::greasepencil::Drawing &drawing) {
blender::ed::curves::select_adjacent(drawing.strokes_for_write(), false);
});
@@ -101,7 +101,7 @@ static int select_less_exec(bContext *C, wmOperator * /*op*/)
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [](int /*drawing_index*/, blender::bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [](const int /*layer_index*/, blender::bke::greasepencil::Drawing &drawing) {
blender::ed::curves::select_adjacent(drawing.strokes_for_write(), true);
});
@@ -132,7 +132,7 @@ static int select_linked_exec(bContext *C, wmOperator * /*op*/)
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [](int /*drawing_index*/, blender::bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [](const int /*layer_index*/, blender::bke::greasepencil::Drawing &drawing) {
blender::ed::curves::select_linked(drawing.strokes_for_write());
});
@@ -167,14 +167,14 @@ static int select_random_exec(bContext *C, wmOperator *op)
eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int drawing_index, bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [&](const int layer_index, bke::greasepencil::Drawing &drawing) {
bke::CurvesGeometry &curves = drawing.strokes_for_write();
IndexMaskMemory memory;
const IndexMask random_elements = ed::curves::random_mask(
curves,
selection_domain,
blender::get_default_hash_2<int>(seed, drawing_index),
blender::get_default_hash_2<int>(seed, layer_index),
ratio,
memory);
@@ -219,7 +219,7 @@ static int select_alternate_exec(bContext *C, wmOperator *op)
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int /*drawing_index*/, blender::bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [&](const int /*layer_index*/, blender::bke::greasepencil::Drawing &drawing) {
blender::ed::curves::select_alternate(drawing.strokes_for_write(), deselect_ends);
});
@@ -258,7 +258,7 @@ static int select_ends_exec(bContext *C, wmOperator *op)
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int /*drawing_index*/, blender::bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [&](const int /*layer_index*/, blender::bke::greasepencil::Drawing &drawing) {
bke::CurvesGeometry &curves = drawing.strokes_for_write();
IndexMaskMemory memory;

View File

@@ -747,13 +747,13 @@ struct EraseOperationExecutor {
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(obact->data);
bool changed = false;
const auto execute_eraser_on_drawing = [&](int drawing_index, Drawing &drawing) {
const auto execute_eraser_on_drawing = [&](const int layer_index, Drawing &drawing) {
const bke::CurvesGeometry &src = drawing.strokes();
/* Evaluated geometry. */
bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation(
ob_eval, *obact, drawing_index);
ob_eval, *obact, layer_index);
/* Compute screen space positions. */
Array<float2> screen_space_positions(src.points_num());

View File

@@ -1192,10 +1192,10 @@ static bool do_lasso_select_grease_pencil(ViewContext *vc,
bool changed = false;
grease_pencil.foreach_editable_drawing(
vc->scene->r.cfra, [&](int drawing_index, blender::bke::greasepencil::Drawing &drawing) {
vc->scene->r.cfra, [&](const int layer_index, blender::bke::greasepencil::Drawing &drawing) {
bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation(
ob_eval, *vc->obedit, drawing_index);
ob_eval, *vc->obedit, layer_index);
changed = ed::curves::select_lasso(
*vc,
@@ -3171,11 +3171,11 @@ static bool ed_grease_pencil_select_pick(bContext *C,
const Object *ob_eval = DEG_get_evaluated_object(vc.depsgraph, const_cast<Object *>(vc.obedit));
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(vc.obedit->data);
Vector<blender::bke::greasepencil::Drawing *> drawings;
Vector<int> drawing_indices;
Vector<int> layer_indices;
grease_pencil.foreach_editable_drawing(
vc.scene->r.cfra, [&](int drawing_index, blender::bke::greasepencil::Drawing &drawing) {
vc.scene->r.cfra, [&](const int layer_index, blender::bke::greasepencil::Drawing &drawing) {
drawings.append(&drawing);
drawing_indices.append(drawing_index);
layer_indices.append(layer_index);
});
/* Get selection domain from tool settings. */
@@ -3191,7 +3191,7 @@ static bool ed_grease_pencil_select_pick(bContext *C,
/* Get deformation by modifiers. */
bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation(
ob_eval, *vc.obedit, drawing_indices[i]);
ob_eval, *vc.obedit, layer_indices[i]);
std::optional<ed::curves::FindClosestData> new_closest_elem =
ed::curves::closest_elem_find_screen_space(vc,
*vc.obedit,
@@ -4194,10 +4194,10 @@ static bool do_grease_pencil_box_select(ViewContext *vc, const rcti *rect, const
bool changed = false;
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int drawing_index, blender::bke::greasepencil::Drawing &drawing) {
scene->r.cfra, [&](const int layer_index, blender::bke::greasepencil::Drawing &drawing) {
bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation(
ob_eval, *vc->obedit, drawing_index);
ob_eval, *vc->obedit, layer_index);
changed |= ed::curves::select_box(*vc,
drawing.strokes_for_write(),
deformation.positions,
@@ -5042,10 +5042,10 @@ static bool grease_pencil_circle_select(ViewContext *vc,
bool changed = false;
grease_pencil.foreach_editable_drawing(
vc->scene->r.cfra, [&](int drawing_index, blender::bke::greasepencil::Drawing &drawing) {
vc->scene->r.cfra, [&](const int layer_index, blender::bke::greasepencil::Drawing &drawing) {
bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation(
ob_eval, *vc->obedit, drawing_index);
ob_eval, *vc->obedit, layer_index);
changed = ed::curves::select_circle(*vc,
drawing.strokes_for_write(),

View File

@@ -561,13 +561,17 @@ typedef struct GreasePencil {
void foreach_visible_drawing(
const int frame,
blender::FunctionRef<void(int, blender::bke::greasepencil::Drawing &)> function);
blender::FunctionRef<void(const int /*layer_index*/,
blender::bke::greasepencil::Drawing & /*drawing*/)> function);
void foreach_visible_drawing(
const int frame,
blender::FunctionRef<void(int, const blender::bke::greasepencil::Drawing &)> function) const;
blender::FunctionRef<void(const int /*layer_index*/,
const blender::bke::greasepencil::Drawing & /*drawing*/)> function)
const;
void foreach_editable_drawing(
const int frame,
blender::FunctionRef<void(int, blender::bke::greasepencil::Drawing &)> function);
blender::FunctionRef<void(const int /*layer_index*/,
blender::bke::greasepencil::Drawing & /*drawing*/)> function);
std::optional<blender::Bounds<blender::float3>> bounds_min_max() const;

View File

@@ -66,7 +66,7 @@ static void node_geo_exec(GeoNodeExecParams params)
const Field<bool> selection = params.extract_input<Field<bool>>("Selection");
GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set);
GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry_set);
switch (mode) {
case GEO_NODE_CURVE_RESAMPLE_COUNT: {

View File

@@ -21,7 +21,7 @@ static void node_geo_exec(GeoNodeExecParams params)
{
GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve");
GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set);
GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry_set);
geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
if (!geometry_set.has_curves()) {

View File

@@ -85,9 +85,10 @@ static void node_geo_exec(GeoNodeExecParams params)
{
GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve");
Field<int> cuts_field = params.extract_input<Field<int>>("Cuts");
GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry_set);
const AnonymousAttributePropagationInfo &propagation_info = params.get_output_propagation_info(
"Curve");
GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set);
geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
if (geometry_set.has_curves()) {

View File

@@ -35,7 +35,7 @@ static void geometry_set_curve_to_mesh(GeometrySet &geometry_set,
const Curves &curves = *geometry_set.get_curves();
const Curves *profile_curves = profile_set.get_curves();
bke::GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set);
bke::GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry_set);
if (profile_curves == nullptr) {
Mesh *mesh = bke::curve_to_wire_mesh(curves.geometry.wrap(), propagation_info);

View File

@@ -137,7 +137,7 @@ static void node_geo_exec(GeoNodeExecParams params)
const GeometryNodeCurveResampleMode mode = (GeometryNodeCurveResampleMode)storage.mode;
GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve");
GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set);
GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry_set);
AnonymousAttributeIDPtr rotation_anonymous_id =
params.get_output_anonymous_attribute_id_if_needed("Rotation");

View File

@@ -207,7 +207,7 @@ static void node_geo_exec(GeoNodeExecParams params)
const GeometryNodeCurveSampleMode mode = (GeometryNodeCurveSampleMode)storage.mode;
GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve");
GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set);
GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry_set);
const AnonymousAttributePropagationInfo &propagation_info = params.get_output_propagation_info(
"Curve");

View File

@@ -291,7 +291,7 @@ static void duplicate_curves(GeometrySet &geometry_set,
return;
}
geometry_set.keep_only_during_modify({GeometryComponent::Type::Curve});
GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set);
GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry_set);
const Curves &curves_id = *geometry_set.get_curves();
const bke::CurvesGeometry &curves = curves_id.geometry.wrap();

View File

@@ -838,7 +838,7 @@ static void node_geo_exec(GeoNodeExecParams params)
index_attribute_id,
weight_attribute_id);
GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(guide_curves_geometry);
GeometryComponentEditData::remember_deformed_positions_if_necessary(guide_curves_geometry);
if (const auto *curve_edit_data =
guide_curves_geometry.get_component<GeometryComponentEditData>()) {
new_curves.add(*curve_edit_data);

View File

@@ -24,7 +24,7 @@ static void node_geo_exec(GeoNodeExecParams params)
"Geometry");
for (GeometrySet &geometry : geometry_sets) {
GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry);
GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry);
}
GeometrySet geometry_set_result = geometry::join_geometries(geometry_sets, propagation_info);

View File

@@ -20,7 +20,7 @@ static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
{
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(geometry_set);
GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry_set);
geometry::RealizeInstancesOptions options;
options.keep_original_ids = false;
options.realize_instance_attributes = true;