GPv3: Add get_editable_drawing_at function
This function returns an editable drawing for a given layer at a specific scene time. Pull Request: https://projects.blender.org/blender/blender/pulls/110295
This commit is contained in:
@@ -1331,6 +1331,27 @@ void GreasePencil::remove_drawing(const int index_to_remove)
|
||||
shrink_array<GreasePencilDrawingBase *>(&this->drawing_array, &this->drawing_array_num, 1);
|
||||
}
|
||||
|
||||
blender::bke::greasepencil::Drawing *GreasePencil::get_editable_drawing_at(
|
||||
const blender::bke::greasepencil::Layer *layer, const int frame_number) const
|
||||
{
|
||||
if (layer == nullptr || !layer->is_editable()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int drawing_index = layer->drawing_index_at(frame_number);
|
||||
if (drawing_index == -1) {
|
||||
/* No drawing found. */
|
||||
return nullptr;
|
||||
}
|
||||
GreasePencilDrawingBase *drawing_base = this->drawings()[drawing_index];
|
||||
if (drawing_base->type != GP_DRAWING) {
|
||||
/* Drawing references are not editable. */
|
||||
return nullptr;
|
||||
}
|
||||
GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(drawing_base);
|
||||
return &drawing->wrap();
|
||||
}
|
||||
|
||||
enum ForeachDrawingMode {
|
||||
VISIBLE,
|
||||
EDITABLE,
|
||||
|
||||
@@ -494,6 +494,13 @@ typedef struct GreasePencil {
|
||||
|
||||
void remove_drawing(int index);
|
||||
|
||||
/**
|
||||
* Returns an editable drawing on \a layer at frame \a frame_number or `nullptr` if no such
|
||||
* drawing exists.
|
||||
*/
|
||||
blender::bke::greasepencil::Drawing *get_editable_drawing_at(
|
||||
const blender::bke::greasepencil::Layer *layer, int frame_number) const;
|
||||
|
||||
void foreach_visible_drawing(
|
||||
int frame, blender::FunctionRef<void(int, blender::bke::greasepencil::Drawing &)> function);
|
||||
void foreach_editable_drawing(
|
||||
|
||||
Reference in New Issue
Block a user