Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2021-01-24 19:19:03 +0300
committerAntonio Vazquez <blendergit@gmail.com>2021-01-24 19:22:44 +0300
commite747c07156cce226dde25309b4346f8354103a24 (patch)
treeb7f3a57dd67fa27a6004e7e150e52370c8b9f2ca /source/blender
parentb449da3a7d4836362a720a0072fad3e0a02f185a (diff)
GPencil: New option to trace current frame
Instead to trace the image of the sequence starting in first frame, now it uses the current frame by default.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/gpencil/gpencil_trace_ops.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/gpencil_trace_ops.c b/source/blender/editors/gpencil/gpencil_trace_ops.c
index 0be9d74278e..8d3ae9567cf 100644
--- a/source/blender/editors/gpencil/gpencil_trace_ops.c
+++ b/source/blender/editors/gpencil/gpencil_trace_ops.c
@@ -87,6 +87,7 @@ typedef struct TraceJob {
bGPDlayer *gpl;
bool was_ob_created;
+ bool use_current_frame;
int32_t frame_target;
float threshold;
@@ -228,15 +229,17 @@ static void trace_start_job(void *customdata, short *stop, short *do_update, flo
trace_job->do_update = do_update;
trace_job->progress = progress;
trace_job->was_canceled = false;
+ const int init_frame = max_ii((trace_job->use_current_frame) ? trace_job->frame_target : 0, 0);
G.is_break = false;
/* Single Image. */
-
if ((trace_job->image->source == IMA_SRC_FILE) ||
(trace_job->mode == GPENCIL_TRACE_MODE_SINGLE)) {
void *lock;
- ImBuf *ibuf = BKE_image_acquire_ibuf(trace_job->image, NULL, &lock);
+ ImageUser *iuser = trace_job->ob_active->iuser;
+ iuser->framenr = init_frame;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(trace_job->image, iuser, &lock);
if (ibuf) {
/* Create frame. */
bGPDframe *gpf = BKE_gpencil_layer_frame_get(
@@ -249,7 +252,7 @@ static void trace_start_job(void *customdata, short *stop, short *do_update, flo
/* Image sequence. */
else if (trace_job->image->type == IMA_TYPE_IMAGE) {
ImageUser *iuser = trace_job->ob_active->iuser;
- for (int i = 0; i < iuser->frames; i++) {
+ for (int i = init_frame; i < iuser->frames; i++) {
if (G.is_break) {
trace_job->was_canceled = true;
break;
@@ -320,6 +323,7 @@ static int gpencil_trace_image_exec(bContext *C, wmOperator *op)
job->ob_active = job->base_active->object;
job->image = (Image *)job->ob_active->data;
job->frame_target = CFRA;
+ job->use_current_frame = RNA_boolean_get(op->ptr, "use_current_frame");
/* Create a new grease pencil object or reuse selected. */
eGP_TargetObjectMode target = RNA_enum_get(op->ptr, "target");
@@ -493,4 +497,9 @@ void GPENCIL_OT_trace_image(wmOperatorType *ot)
GPENCIL_TRACE_MODE_SINGLE,
"Mode",
"Determines if trace simple image or full sequence");
+ RNA_def_boolean(ot->srna,
+ "use_current_frame",
+ true,
+ "Start At Current Frame",
+ "Trace Image starting in current image frame");
}