Cleanup: GPv3: Remove uses of layers.first_index
Remove uses of `GreasePencil::layers().first_index(...)`. Use `GreasePencil::get_layer_index` instead.
This commit is contained in:
@@ -2694,7 +2694,7 @@ blender::Span<blender::bke::greasepencil::TreeNode *> GreasePencil::nodes_for_wr
|
||||
std::optional<int> GreasePencil::get_layer_index(
|
||||
const blender::bke::greasepencil::Layer &layer) const
|
||||
{
|
||||
const int index = this->layers().first_index_try(&layer);
|
||||
const int index = int(this->layers().first_index_try(&layer));
|
||||
if (index == -1) {
|
||||
return {};
|
||||
}
|
||||
@@ -3142,7 +3142,7 @@ static void update_active_node(GreasePencil &grease_pencil,
|
||||
grease_pencil.set_active_layer(layers[1]);
|
||||
}
|
||||
else {
|
||||
int64_t active_index = layers.first_index(&active_node.as_layer());
|
||||
const int active_index = *grease_pencil.get_layer_index(active_node.as_layer());
|
||||
grease_pencil.set_active_layer(layers[active_index - 1]);
|
||||
}
|
||||
}
|
||||
@@ -3155,7 +3155,7 @@ void GreasePencil::remove_layer(blender::bke::greasepencil::Layer &layer)
|
||||
update_active_node(*this, layer.as_node());
|
||||
|
||||
/* Remove all the layer attributes and shrink the `CustomData`. */
|
||||
const int64_t layer_index = this->layers().first_index(&layer);
|
||||
const int layer_index = *this->get_layer_index(layer);
|
||||
shrink_customdata(this->layers_data, layer_index, this->layers().size());
|
||||
|
||||
/* Unlink the layer from the parent group. */
|
||||
|
||||
@@ -1986,7 +1986,8 @@ static bool grease_pencil_separate_layer(bContext &C,
|
||||
GreasePencil &grease_pencil_src = *static_cast<GreasePencil *>(object_src.data);
|
||||
|
||||
/* Create a new object for each layer. */
|
||||
for (const Layer *layer_src : grease_pencil_src.layers()) {
|
||||
for (const int layer_i : grease_pencil_src.layers().index_range()) {
|
||||
Layer *layer_src = grease_pencil_src.layer(layer_i);
|
||||
if (layer_src->is_selected() || layer_src->is_locked()) {
|
||||
continue;
|
||||
}
|
||||
@@ -1995,7 +1996,7 @@ static bool grease_pencil_separate_layer(bContext &C,
|
||||
&bmain, &scene, &view_layer, &base_prev, grease_pencil_src);
|
||||
GreasePencil &grease_pencil_dst = *static_cast<GreasePencil *>(object_dst->data);
|
||||
Layer &layer_dst = find_or_create_layer_in_dst_by_name(
|
||||
grease_pencil_src.layers().first_index(layer_src), grease_pencil_src, grease_pencil_dst);
|
||||
layer_i, grease_pencil_src, grease_pencil_dst);
|
||||
|
||||
/* Iterate through all the drawings at current frame. */
|
||||
const Vector<MutableDrawingInfo> drawings_src = retrieve_editable_drawings_from_layer(
|
||||
|
||||
Reference in New Issue
Block a user