Commit: 60bf40577e23211f8554d3078358da373766f27d
Author: Antonio Vazquez
Date:   Wed Apr 1 15:39:44 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB60bf40577e23211f8554d3078358da373766f27d

GPencil: Rename operator and add to menu

Also changed end frame to length

===================================================================

M       release/scripts/startup/bl_ui/space_view3d.py
M       source/blender/editors/gpencil/gpencil_convert.c
M       source/blender/editors/gpencil/gpencil_intern.h
M       source/blender/editors/gpencil/gpencil_ops.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index c3245b943da..2cfac8eadd0 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2371,6 +2371,10 @@ class VIEW3D_MT_object_animation(Menu):
 
         layout.operator("nla.bake", text="Bake Action...")
 
+        layout.separator()
+
+        layout.operator("gpencil.bake_mesh_animation", text="Bake Mesh to 
Grease Pencil")
+
 
 class VIEW3D_MT_object_rigid_body(Menu):
     bl_label = "Rigid Body"
diff --git a/source/blender/editors/gpencil/gpencil_convert.c 
b/source/blender/editors/gpencil/gpencil_convert.c
index df542142127..244e89e3b7b 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1859,7 +1859,7 @@ void GPENCIL_OT_image_to_grease_pencil(wmOperatorType *ot)
 }
 
 /* Extract mesh animation to Grease Pencil. */
-static bool gp_extract_mesh_animation_poll(bContext *C)
+static bool gp_bake_mesh_animation_poll(bContext *C)
 {
   if (CTX_data_mode_enum(C) != CTX_MODE_OBJECT) {
     return false;
@@ -1870,7 +1870,7 @@ static bool gp_extract_mesh_animation_poll(bContext *C)
   return (sa && sa->spacetype);
 }
 
-static int gp_extract_mesh_animation_exec(bContext *C, wmOperator *op)
+static int gp_bake_mesh_animation_exec(bContext *C, wmOperator *op)
 {
   Main *bmain = CTX_data_main(C);
   Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
@@ -1896,9 +1896,9 @@ static int gp_extract_mesh_animation_exec(bContext *C, 
wmOperator *op)
                               scene->r.sfra :
                               RNA_int_get(op->ptr, "start_frame");
 
-  const int end_frame = (scene->r.efra < RNA_int_get(op->ptr, "end_frame")) ?
+  const int end_frame = (scene->r.efra < start_frame + RNA_int_get(op->ptr, 
"length")) ?
                             scene->r.efra :
-                            RNA_int_get(op->ptr, "end_frame");
+                            start_frame + RNA_int_get(op->ptr, "length");
 
   const float angle = RNA_float_get(op->ptr, "angle");
   const int thickness = RNA_int_get(op->ptr, "thickness");
@@ -1969,18 +1969,18 @@ static int gp_extract_mesh_animation_exec(bContext *C, 
wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
-void GPENCIL_OT_extract_mesh_animation(wmOperatorType *ot)
+void GPENCIL_OT_bake_mesh_animation(wmOperatorType *ot)
 {
   PropertyRNA *prop;
 
   /* identifiers */
-  ot->name = "Extract Mesh Animation to Grease Pencil";
-  ot->idname = "GPENCIL_OT_extract_mesh_animation";
-  ot->description = "Convert all animation of mesh in Grease Pencil strokes";
+  ot->name = "Bake Mesh Animation to Grease Pencil";
+  ot->idname = "GPENCIL_OT_bake_mesh_animation";
+  ot->description = "Bake Mesh Animation to Grease Pencil strokes";
 
   /* callbacks */
-  ot->exec = gp_extract_mesh_animation_exec;
-  ot->poll = gp_extract_mesh_animation_poll;
+  ot->exec = gp_bake_mesh_animation_exec;
+  ot->poll = gp_bake_mesh_animation_poll;
 
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1989,9 +1989,7 @@ void GPENCIL_OT_extract_mesh_animation(wmOperatorType *ot)
   ot->prop = RNA_def_int(
       ot->srna, "start_frame", 1, 1, 100000, "Start Frame", "The start frame", 
1, 100000);
 
-  prop = RNA_def_int(
-      ot->srna, "end_frame", 250, 1, 100000, "End Frame", "The end frame", 1, 
100000);
-  RNA_def_property_update_runtime(prop, gp_convert_set_end_frame);
+  prop = RNA_def_int(ot->srna, "length", 10, 1, 100, "Length", "Number of 
frames to bake", 1, 100);
 
   prop = RNA_def_int(ot->srna, "step", 1, 1, 100, "Step", "Step between 
generated frames", 1, 100);
 
diff --git a/source/blender/editors/gpencil/gpencil_intern.h 
b/source/blender/editors/gpencil/gpencil_intern.h
index 340882da7a9..30434a47c86 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -466,7 +466,7 @@ void GPENCIL_OT_frame_clean_fill(struct wmOperatorType *ot);
 void GPENCIL_OT_frame_clean_loose(struct wmOperatorType *ot);
 
 void GPENCIL_OT_convert(struct wmOperatorType *ot);
-void GPENCIL_OT_extract_mesh_animation(struct wmOperatorType *ot);
+void GPENCIL_OT_bake_mesh_animation(struct wmOperatorType *ot);
 
 void GPENCIL_OT_image_to_grease_pencil(struct wmOperatorType *ot);
 
diff --git a/source/blender/editors/gpencil/gpencil_ops.c 
b/source/blender/editors/gpencil/gpencil_ops.c
index f7bbe2cf69c..847c44d96d8 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -603,7 +603,7 @@ void ED_operatortypes_gpencil(void)
   WM_operatortype_append(GPENCIL_OT_frame_clean_loose);
 
   WM_operatortype_append(GPENCIL_OT_convert);
-  WM_operatortype_append(GPENCIL_OT_extract_mesh_animation);
+  WM_operatortype_append(GPENCIL_OT_bake_mesh_animation);
 
   WM_operatortype_append(GPENCIL_OT_image_to_grease_pencil);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to