Fix #127073: GPv3: Auto keying in edit mode

GPv3 didn't handle auto keyframe insertion in edit mode transformation,
now corrected by using `insert_duplicate_frame` when target frame doesn't
exist.

Pull Request: https://projects.blender.org/blender/blender/pulls/127078
This commit is contained in:
YimingWu
2024-09-04 06:06:21 +02:00
committed by YimingWu
parent 0ef35bc475
commit fe4bd519f3

View File

@@ -6,6 +6,8 @@
* \ingroup edtransform
*/
#include "ANIM_keyframing.hh"
#include "BKE_context.hh"
#include "DEG_depsgraph_query.hh"
@@ -45,8 +47,23 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t)
TransDataContainer &tc = trans_data_contrainers[i];
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(tc.obedit->data);
const Vector<ed::greasepencil::MutableDrawingInfo> drawings =
Vector<ed::greasepencil::MutableDrawingInfo> drawings =
ed::greasepencil::retrieve_editable_drawings(*scene, grease_pencil);
if (blender::animrig::is_autokey_on(scene)) {
for (const int info_i : drawings.index_range()) {
blender::bke::greasepencil::Layer &target_layer = *grease_pencil.layer(
drawings[info_i].layer_index);
const int current_frame = scene->r.cfra;
std::optional<int> start_frame = target_layer.start_frame_at(current_frame);
if (start_frame.has_value() && (start_frame.value() != current_frame)) {
grease_pencil.insert_duplicate_frame(
target_layer, *target_layer.start_frame_at(current_frame), current_frame, false);
}
}
drawings = ed::greasepencil::retrieve_editable_drawings(*scene, grease_pencil);
}
all_drawings.append(drawings);
total_number_of_drawings += drawings.size();
}