[Bf-blender-cvs] [1558b270e9f] master: Animation: Sensible frame range for motion paths

Colin Marmont noreply at git.blender.org
Mon Feb 28 12:28:29 CET 2022


Commit: 1558b270e9fcbc2e23fa248b0e7e770dddae155c
Author: Colin Marmont
Date:   Mon Feb 28 12:23:56 2022 +0100
Branches: master
https://developer.blender.org/rB1558b270e9fcbc2e23fa248b0e7e770dddae155c

Animation: Sensible frame range for motion paths

Motion paths can now be initialised to more sensible frame ranges,
rather than simply 1-250:

- Scene Frame Range
- Selected Keyframes
- All Keyframes

The Motion Paths operators are now also added to the Object context menu
and the Dopesheet context menu.

The scene range operator was removed, because the operators now
automatically find the range when baking the motion paths.

The clear operator now appears separated in "Selected Only" and "All",
because it was not clear for the user what the button was doing.

Reviewed By: sybren, looch

Maniphest Tasks: T93047

Differential Revision: https://developer.blender.org/D13687

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

M	release/scripts/startup/bl_ui/properties_animviz.py
M	release/scripts/startup/bl_ui/space_dopesheet.py
M	release/scripts/startup/bl_ui/space_graph.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/intern/anim_visualization.c
M	source/blender/draw/engines/overlay/overlay_motion_path.c
M	source/blender/editors/animation/anim_motion_paths.c
M	source/blender/editors/animation/keyframes_keylist.cc
M	source/blender/editors/armature/pose_edit.c
M	source/blender/editors/include/ED_anim_api.h
M	source/blender/editors/include/ED_keyframes_keylist.h
M	source/blender/editors/object/object_edit.c
M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_ops.c
M	source/blender/editors/space_nla/nla_draw.c
M	source/blender/makesdna/DNA_action_types.h
M	source/blender/makesrna/RNA_enum_items.h
M	source/blender/makesrna/intern/rna_animviz.c

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

diff --git a/release/scripts/startup/bl_ui/properties_animviz.py b/release/scripts/startup/bl_ui/properties_animviz.py
index 548ce72c429..629399084ba 100644
--- a/release/scripts/startup/bl_ui/properties_animviz.py
+++ b/release/scripts/startup/bl_ui/properties_animviz.py
@@ -24,55 +24,55 @@ class MotionPathButtonsPanel:
         layout.use_property_split = True
         layout.use_property_decorate = False
 
-        row = layout.row(align=True)
-        row.prop(mps, "type")
-        if mps.type == 'RANGE':
-            if bones:
-                row.operator("pose.paths_range_update", text="", icon='TIME')
-            else:
-                row.operator("object.paths_range_update", text="", icon='TIME')
-
+        # Display Range
+        col = layout.column(align=True)
+        col.prop(mps, "type")
+        col = layout.column(align=True)
         if mps.type == 'CURRENT_FRAME':
-            col = layout.column(align=True)
             col.prop(mps, "frame_before", text="Frame Range Before")
             col.prop(mps, "frame_after", text="After")
-            col.prop(mps, "frame_step", text="Step")
-        elif mps.type == 'RANGE':
-            col = layout.column(align=True)
-            col.prop(mps, "frame_start", text="Frame Range Start")
-            col.prop(mps, "frame_end", text="End")
-            col.prop(mps, "frame_step", text="Step")
+        col.prop(mps, "frame_step", text="Step")
+
+        # Calculation Range
+        col = layout.column(align=True)
+        row = col.row(align=True)
+        row.prop(mps, "range", text="Calculation Range")
 
         if mpath:
             col = layout.column(align=True)
-            col.enabled = False
-            if bones:
-                col.prop(mpath, "frame_start", text="Bone Cache From")
-            else:
-                col.prop(mpath, "frame_start", text="Cache From")
-            col.prop(mpath, "frame_end", text="To")
+            row = col.row(align=True)
+            row.enabled = False
+            row.prop(mpath, "frame_start", text="Cached Range")
+            row.prop(mpath, "frame_end", text="")
 
             col = layout.column(align=True)
-
+            row = col.row(align=True)
             if bones:
-                col.operator("pose.paths_update", text="Update Paths", icon='BONE_DATA')
+                row.operator("pose.paths_update", text="Update Paths", icon='BONE_DATA')
+                row.operator("pose.paths_clear", text="", icon='X').only_selected = True
+                row = col.row(align=True)
+                row.operator("object.paths_update_visible", text="Update All Paths", icon='WORLD')
+                row.operator("pose.paths_clear", text="", icon='X').only_selected = False
             else:
-                col.operator("object.paths_update", text="Update Paths", icon='OBJECT_DATA')
+                row.operator("object.paths_update", text="Update Paths", icon='OBJECT_DATA')
+                row.operator("object.paths_clear", text="", icon='X').only_selected = True
+                row = col.row(align=True)
+                row.operator("object.paths_update_visible", text="Update All Paths", icon='WORLD')
+                row.operator("object.paths_clear", text="", icon='X').only_selected = False
         else:
             col = layout.column(align=True)
-            col.label(text="Nothing to show yet...", icon='ERROR')
+            col.label(text="No Motion Path generated yet", icon='ERROR')
 
+            # Don't invoke settings popup because settings are right above
+            col.operator_context = 'EXEC_REGION_WIN'
             if bones:
-                col.operator("pose.paths_calculate", text="Calculate...", icon='BONE_DATA')
+                col.operator(
+                    "pose.paths_calculate", text="Generate for selected bones", icon='BONE_DATA')
             else:
-                col.operator("object.paths_calculate", text="Calculate...", icon='OBJECT_DATA')
-
-        row = col.row(align=True)
-        row.operator("object.paths_update_visible", text="Update All Paths", icon='WORLD')
-        if bones:
-            row.operator("pose.paths_clear", text="", icon='X')
-        else:
-            row.operator("object.paths_clear", text="", icon='X')
+                col.operator("object.paths_calculate", text="Generate", icon='OBJECT_DATA')
+            row = col.row(align=True)
+            row.operator("object.paths_update_visible", text="Update All Paths", icon='WORLD')
+            row.operator("object.paths_clear", text="", icon='X').only_selected = False
 
 
 class MotionPathButtonsPanel_display:
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 8e328e7cf2b..7b7fc9dcf77 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -663,6 +663,10 @@ class DOPESHEET_MT_context_menu(Menu):
         layout.operator_menu_enum("action.mirror", "type", text="Mirror")
         layout.operator_menu_enum("action.snap", "type", text="Snap")
 
+        if st.mode == 'DOPESHEET':
+            layout.separator()
+            layout.menu("VIEW3D_MT_motion_path")
+
 
 class DOPESHEET_MT_channel_context_menu(Menu):
     bl_label = "Dope Sheet Channel Context Menu"
diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index 6f9ef12c3b7..6bc11d51ca0 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -390,6 +390,9 @@ class GRAPH_MT_context_menu(Menu):
         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
         layout.operator_menu_enum("graph.snap", "type", text="Snap")
 
+        layout.separator()
+        layout.menu("VIEW3D_MT_motion_path")
+
 
 class GRAPH_MT_pivot_pie(Menu):
     bl_label = "Pivot Point"
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 2ac6358bd9c..5dedb3c4029 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2383,6 +2383,25 @@ class VIEW3D_MT_object_clear(Menu):
         layout.operator("object.origin_clear", text="Origin")
 
 
+class VIEW3D_MT_motion_path(Menu):
+    bl_label = "Motion Paths"
+
+    def draw(self, _context):
+        layout = self.layout
+        ob = _context.object
+        if ob.mode == 'OBJECT':
+            layout.operator("object.paths_calculate")
+            layout.operator("object.paths_update")
+            layout.operator("object.paths_update_visible")
+            layout.operator("object.paths_clear", text="Clear all").only_selected = False
+            layout.operator("object.paths_clear", text="Clear selected").only_selected = True
+        elif ob.mode == 'POSE':
+            layout.operator("pose.paths_calculate")
+            layout.operator("pose.paths_update")
+            layout.operator("pose.paths_clear", text="Clear all").only_selected = False
+            layout.operator("pose.paths_clear", text="Clear selected").only_selected = True
+
+
 class VIEW3D_MT_object_context_menu(Menu):
     bl_label = "Object Context Menu"
 
@@ -2584,6 +2603,7 @@ class VIEW3D_MT_object_context_menu(Menu):
         layout.menu("VIEW3D_MT_mirror")
         layout.menu("VIEW3D_MT_snap")
         layout.menu("VIEW3D_MT_object_parent")
+        layout.menu("VIEW3D_MT_motion_path")
         layout.operator_context = 'INVOKE_REGION_WIN'
 
         if view and view.local_view:
@@ -3631,10 +3651,10 @@ class VIEW3D_MT_pose_context_menu(Menu):
 
         layout.separator()
 
-        layout.operator("pose.paths_calculate", text="Calculate Motion Paths")
-        layout.operator("pose.paths_clear", text="Clear Motion Paths")
-        layout.operator("pose.paths_update", text="Update Armature Motion Paths")
-        layout.operator("object.paths_update_visible", text="Update All Motion Paths")
+        layout.operator("pose.paths_calculate")
+        layout.operator("pose.paths_update")
+        layout.operator("pose.paths_clear", text="Clear all").only_selected = False
+        layout.operator("pose.paths_clear", text="Clear selected").only_selected = True
 
         layout.separator()
 
@@ -7623,6 +7643,7 @@ classes = (
     VIEW3D_MT_object_quick_effects,
     VIEW3D_MT_object_showhide,
     VIEW3D_MT_object_cleanup,
+    VIEW3D_MT_motion_path,
     VIEW3D_MT_make_single_user,
     VIEW3D_MT_make_links,
     VIEW3D_MT_brush_paint_modes,
diff --git a/source/blender/blenkernel/intern/anim_visualization.c b/source/blender/blenkernel/intern/anim_visualization.c
index 53a3a7e3712..f4c6a29c252 100644
--- a/source/blender/blenkernel/intern/anim_visualization.c
+++ b/source/blender/blenkernel/intern/anim_visualization.c
@@ -153,6 +153,11 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports,
     if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) {
       /* outer check ensures that we have some curve data for this path */
       if (mpath->length == expected_length) {
+        /* The length might be the same, but the start and end could be different */
+        if (mpath->start_frame != avs->path_sf) {
+          mpath->start_frame = avs->path_sf;
+          mpath->end_frame = avs->path_ef;
+        }
         /* return/use this as it is already valid length */
         return mpath;
       }
diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.c
index 58825923f37..aeba721e7ac 100644
--- a/source/blender/draw/engines/overlay/overlay_motion_path.c
+++ b/source/blender/draw/engines/overlay/overlay_motion_path.c
@@ -90,8 +90,8 @@ static void motion_path_get_frame_range_to_draw(bAnimVizSettings *avs,
     end = current_frame + avs->path_ac + 1;
   }
   else {
-    start = avs->path_sf;
-    end = avs->path_ef;
+    start = mpath->start_frame;
+    end = mpath->end_frame;
   }
 
   if (start > end) {
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c
index 539227933cf..2c99cd1cc1f 100644
--- a/source/blender/editors/animation/anim_motion_paths.c
+++ b/source

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list