Cleanup: Rename grease pencil function to access layer at index
The plural was confusing when only one layer was returned.
This commit is contained in:
@@ -741,11 +741,11 @@ inline const blender::bke::greasepencil::LayerGroup &GreasePencilLayerTreeGroup:
|
||||
return *reinterpret_cast<const blender::bke::greasepencil::LayerGroup *>(this);
|
||||
}
|
||||
|
||||
inline const GreasePencilDrawingBase *GreasePencil::drawings(int64_t index) const
|
||||
inline const GreasePencilDrawingBase *GreasePencil::drawing(int64_t index) const
|
||||
{
|
||||
return this->drawings()[index];
|
||||
}
|
||||
inline GreasePencilDrawingBase *GreasePencil::drawings(int64_t index)
|
||||
inline GreasePencilDrawingBase *GreasePencil::drawing(int64_t index)
|
||||
{
|
||||
return this->drawings()[index];
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ GeometryDeformation get_evaluated_grease_pencil_drawing_deformation(const Object
|
||||
BLI_assert(ob_orig.type == OB_GREASE_PENCIL);
|
||||
const GreasePencil &grease_pencil_orig = *static_cast<const GreasePencil *>(ob_orig.data);
|
||||
|
||||
const GreasePencilDrawingBase *drawing_base = grease_pencil_orig.drawings(drawing_index);
|
||||
const GreasePencilDrawingBase *drawing_base = grease_pencil_orig.drawing(drawing_index);
|
||||
|
||||
GeometryDeformation deformation;
|
||||
if (drawing_base->type == GP_DRAWING) {
|
||||
|
||||
@@ -1412,7 +1412,7 @@ bool GreasePencil::insert_duplicate_frame(blender::bke::greasepencil::Layer &lay
|
||||
|
||||
dst_frame->type = src_frame.type;
|
||||
|
||||
const GreasePencilDrawingBase *src_drawing_base = this->drawings(src_frame.drawing_index);
|
||||
const GreasePencilDrawingBase *src_drawing_base = this->drawing(src_frame.drawing_index);
|
||||
switch (src_drawing_base->type) {
|
||||
case GP_DRAWING: {
|
||||
const Drawing &src_drawing =
|
||||
@@ -1458,7 +1458,7 @@ bool GreasePencil::remove_frames(blender::bke::greasepencil::Layer &layer,
|
||||
/* Null frames don't reference a drawing, continue. */
|
||||
continue;
|
||||
}
|
||||
GreasePencilDrawingBase *drawing_base = this->drawings(drawing_index_to_remove);
|
||||
GreasePencilDrawingBase *drawing_base = this->drawing(drawing_index_to_remove);
|
||||
if (drawing_base->type != GP_DRAWING) {
|
||||
/* If the drawing is referenced from another object, we don't track it's users because we
|
||||
* cannot delete drawings from another object. */
|
||||
@@ -1522,7 +1522,7 @@ static void remove_drawings_unchecked(GreasePencil &grease_pencil,
|
||||
|
||||
/* Free the last drawings. */
|
||||
for (const int64_t drawing_index : last_drawings_range) {
|
||||
GreasePencilDrawingBase *drawing_base_to_remove = grease_pencil.drawings(drawing_index);
|
||||
GreasePencilDrawingBase *drawing_base_to_remove = grease_pencil.drawing(drawing_index);
|
||||
switch (drawing_base_to_remove->type) {
|
||||
case GP_DRAWING: {
|
||||
GreasePencilDrawing *drawing_to_remove = reinterpret_cast<GreasePencilDrawing *>(
|
||||
@@ -1549,7 +1549,7 @@ void GreasePencil::remove_drawings_with_no_users()
|
||||
using namespace blender;
|
||||
Vector<int64_t> drawings_to_be_removed;
|
||||
for (const int64_t drawing_i : this->drawings().index_range()) {
|
||||
GreasePencilDrawingBase *drawing_base = this->drawings(drawing_i);
|
||||
GreasePencilDrawingBase *drawing_base = this->drawing(drawing_i);
|
||||
if (drawing_base->type != GP_DRAWING) {
|
||||
continue;
|
||||
}
|
||||
@@ -1605,7 +1605,7 @@ void GreasePencil::move_duplicate_frames(
|
||||
/* Add and overwrite the frame at the destination number. */
|
||||
if (layer.frames().contains(dst_frame_number)) {
|
||||
GreasePencilFrame frame_to_overwrite = layer.frames().lookup(dst_frame_number);
|
||||
GreasePencilDrawingBase *drawing_base = this->drawings(frame_to_overwrite.drawing_index);
|
||||
GreasePencilDrawingBase *drawing_base = this->drawing(frame_to_overwrite.drawing_index);
|
||||
if (drawing_base->type == GP_DRAWING) {
|
||||
reinterpret_cast<GreasePencilDrawing *>(drawing_base)->wrap().remove_user();
|
||||
}
|
||||
@@ -1631,7 +1631,7 @@ blender::bke::greasepencil::Drawing *GreasePencil::get_editable_drawing_at(
|
||||
/* No drawing found. */
|
||||
return nullptr;
|
||||
}
|
||||
GreasePencilDrawingBase *drawing_base = this->drawings(drawing_index);
|
||||
GreasePencilDrawingBase *drawing_base = this->drawing(drawing_index);
|
||||
if (drawing_base->type != GP_DRAWING) {
|
||||
/* Drawing references are not editable. */
|
||||
return nullptr;
|
||||
@@ -1997,7 +1997,7 @@ void GreasePencil::remove_layer(blender::bke::greasepencil::Layer &layer)
|
||||
|
||||
/* Remove drawings. */
|
||||
for (GreasePencilFrame frame : layer.frames_for_write().values()) {
|
||||
GreasePencilDrawingBase *drawing_base = this->drawings(frame.drawing_index);
|
||||
GreasePencilDrawingBase *drawing_base = this->drawing(frame.drawing_index);
|
||||
if (drawing_base->type != GP_DRAWING) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ TEST(greasepencil, remove_drawings)
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(BKE_id_new(ctx.bmain, ID_GP, "GP"));
|
||||
grease_pencil.add_empty_drawings(3);
|
||||
|
||||
GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(
|
||||
grease_pencil.drawings(1));
|
||||
GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(grease_pencil.drawing(1));
|
||||
drawing->wrap().strokes_for_write().resize(0, 10);
|
||||
|
||||
Layer &layer1 = grease_pencil.root_group().add_layer("Layer1");
|
||||
|
||||
@@ -1225,7 +1225,7 @@ void create_stroke(Main &bmain, Object &object, float4x4 matrix, const int frame
|
||||
grease_pencil.insert_blank_frame(layer_color, frame_number, 0, BEZT_KEYTYPE_KEYFRAME);
|
||||
|
||||
GreasePencilDrawing &drawing = *reinterpret_cast<GreasePencilDrawing *>(
|
||||
grease_pencil.drawings(1));
|
||||
grease_pencil.drawing(1));
|
||||
drawing.geometry.wrap() = create_drawing_data(
|
||||
stroke_positions, stroke_radii, stroke_opacities, {0, 175}, {material_index}, {75}, matrix);
|
||||
}
|
||||
@@ -1286,7 +1286,7 @@ void create_suzanne(Main &bmain, Object &object, float4x4 matrix, const int fram
|
||||
grease_pencil.insert_blank_frame(layer_fills, frame_number, 0, BEZT_KEYTYPE_KEYFRAME);
|
||||
|
||||
GreasePencilDrawing *drawing_lines = reinterpret_cast<GreasePencilDrawing *>(
|
||||
grease_pencil.drawings(0));
|
||||
grease_pencil.drawing(0));
|
||||
drawing_lines->geometry.wrap() = create_drawing_data(monkey_line_positions,
|
||||
monkey_line_radii,
|
||||
monkey_line_opacities,
|
||||
@@ -1296,7 +1296,7 @@ void create_suzanne(Main &bmain, Object &object, float4x4 matrix, const int fram
|
||||
matrix);
|
||||
|
||||
GreasePencilDrawing *drawing_fills = reinterpret_cast<GreasePencilDrawing *>(
|
||||
grease_pencil.drawings(1));
|
||||
grease_pencil.drawing(1));
|
||||
drawing_fills->geometry.wrap() = create_drawing_data(monkey_fill_positions,
|
||||
monkey_fill_radii,
|
||||
monkey_fill_opacities,
|
||||
|
||||
@@ -90,7 +90,7 @@ void PaintOperation::on_stroke_done(const bContext &C)
|
||||
int index_orig = active_layer_orig.drawing_index_at(scene->r.cfra);
|
||||
|
||||
bke::greasepencil::Drawing &drawing_orig =
|
||||
reinterpret_cast<GreasePencilDrawing *>(grease_pencil_orig.drawings(index_orig))->wrap();
|
||||
reinterpret_cast<GreasePencilDrawing *>(grease_pencil_orig.drawing(index_orig))->wrap();
|
||||
|
||||
const Span<bke::greasepencil::StrokePoint> stroke_points =
|
||||
grease_pencil_eval.runtime->stroke_buffer();
|
||||
|
||||
@@ -177,8 +177,7 @@ static bool grease_pencil_layer_apply_trans_data(GreasePencil &grease_pencil,
|
||||
if (canceled && duplicate) {
|
||||
/* Duplicates were done, so we need to delete the corresponding duplicate drawings. */
|
||||
for (const GreasePencilFrame &duplicate_frame : trans_data.temp_frames_buffer.values()) {
|
||||
GreasePencilDrawingBase *drawing_base = grease_pencil.drawings(
|
||||
duplicate_frame.drawing_index);
|
||||
GreasePencilDrawingBase *drawing_base = grease_pencil.drawing(duplicate_frame.drawing_index);
|
||||
if (drawing_base->type == GP_DRAWING) {
|
||||
reinterpret_cast<GreasePencilDrawing *>(drawing_base)->wrap().remove_user();
|
||||
}
|
||||
|
||||
@@ -432,8 +432,8 @@ typedef struct GreasePencil {
|
||||
/* Drawings read/write access. */
|
||||
blender::Span<const GreasePencilDrawingBase *> drawings() const;
|
||||
blender::MutableSpan<GreasePencilDrawingBase *> drawings();
|
||||
const GreasePencilDrawingBase *drawings(int64_t index) const;
|
||||
GreasePencilDrawingBase *drawings(int64_t index);
|
||||
const GreasePencilDrawingBase *drawing(int64_t index) const;
|
||||
GreasePencilDrawingBase *drawing(int64_t index);
|
||||
|
||||
blender::Span<const blender::bke::greasepencil::TreeNode *> nodes() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user