diff options
-rw-r--r-- | release/scripts/startup/bl_ui/properties_animviz.py | 46 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_armature.py | 14 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/properties_object.py | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 4 | ||||
-rw-r--r-- | source/blender/editors/armature/poseobject.c | 72 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 36 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_animviz.c | 14 |
8 files changed, 149 insertions, 51 deletions
diff --git a/release/scripts/startup/bl_ui/properties_animviz.py b/release/scripts/startup/bl_ui/properties_animviz.py index 93feb8adc7a..3f25006766e 100644 --- a/release/scripts/startup/bl_ui/properties_animviz.py +++ b/release/scripts/startup/bl_ui/properties_animviz.py @@ -31,16 +31,18 @@ class MotionPathButtonsPanel(): bl_label = "Motion Paths" bl_options = {'DEFAULT_CLOSED'} - def draw_settings(self, context, avs, bones=False): + def draw_settings(self, context, avs, mpath, bones=False): layout = self.layout mps = avs.motion_path - + + # Display Range layout.prop(mps, "type", expand=True) split = layout.split() col = split.column() + col.label(text="Display Range:") sub = col.column(align=True) if (mps.type == 'CURRENT_FRAME'): sub.prop(mps, "frame_before", text="Before") @@ -48,18 +50,46 @@ class MotionPathButtonsPanel(): elif (mps.type == 'RANGE'): sub.prop(mps, "frame_start", text="Start") sub.prop(mps, "frame_end", text="End") - + sub.prop(mps, "frame_step", text="Step") + + col = split.column() if bones: - col.row().prop(mps, "bake_location", expand=True) - + col.label(text="Cache for Bone:") + else: + col.label(text="Cache:") + + if mpath: + sub = col.column(align=True) + sub.enabled = False + sub.prop(mpath, "frame_start", text="From") + sub.prop(mpath, "frame_end", text="To") + + sub = col.column() # align=True + sub.operator_context = 'EXEC_DEFAULT' + if bones: + col.operator("pose.paths_calculate", text="Update", icon='BONE_DATA') + else: + col.operator("object.paths_calculate", text="Update", icon='OBJECT_DATA') + else: + col.label(text="Not available yet...", icon='ERROR') + col.label(text="Calculate Paths first", icon='INFO') + + + # Display Settings + split = layout.split() + col = split.column() - col.label(text="Display:") + col.label(text="Show:") col.prop(mps, "show_frame_numbers", text="Frame Numbers") + + col = split.column() col.prop(mps, "show_keyframe_highlight", text="Keyframes") + sub = col.column() + sub.enabled = mps.show_keyframe_highlight if bones: - col.prop(mps, "show_keyframe_action_all", text="+ Non-Grouped Keyframes") - col.prop(mps, "show_keyframe_numbers", text="Keyframe Numbers") + sub.prop(mps, "show_keyframe_action_all", text="+ Non-Grouped Keyframes") + sub.prop(mps, "show_keyframe_numbers", text="Keyframe Numbers") # FIXME: this panel still needs to be ported so that it will work correctly with animviz diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 08529a0423d..63dc64190bb 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -308,14 +308,12 @@ class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel): layout = self.layout ob = context.object - - self.draw_settings(context, ob.pose.animation_visualisation, bones=True) - - layout.separator() - - split = layout.split() - split.operator("pose.paths_calculate", text="Calculate Paths") - split.operator("pose.paths_clear", text="Clear Paths") + avs = ob.pose.animation_visualisation + + pchan = context.active_pose_bone + mpath = pchan.motion_path if pchan else None + + self.draw_settings(context, avs, mpath, bones=True) class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from panel when ready diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index d7b4b1a2b44..cdef7e703e5 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -299,14 +299,10 @@ class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel): layout = self.layout ob = context.object - - self.draw_settings(context, ob.animation_visualisation) - - layout.separator() - - row = layout.row() - row.operator("object.paths_calculate", text="Calculate Paths") - row.operator("object.paths_clear", text="Clear Paths") + avs = ob.animation_visualisation + mpath = ob.motion_path + + self.draw_settings(context, avs, mpath) class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from panel when ready diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index ce66d828a98..afa4723bc6d 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -198,9 +198,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec } else { /* clear the existing path (as the range has changed), and reallocate below */ - if (mpath->points) - MEM_freeN(mpath->points); - mpath->points = NULL; + animviz_free_motionpath_cache(mpath); } } } diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 1bc6bc0bf07..e0dba30e0b2 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -197,24 +197,54 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob) BLI_freelistN(&targets); } +/* show popup to determine settings */ +static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *evt) +{ + Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + + if (ELEM(NULL, ob, ob->pose)) + return OPERATOR_CANCELLED; + + /* set default settings from existing/stored settings */ + { + bAnimVizSettings *avs = &ob->pose->avs; + PointerRNA avs_ptr; + + RNA_int_set(op->ptr, "start_frame", avs->path_sf); + RNA_int_set(op->ptr, "end_frame", avs->path_ef); + + RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr); + RNA_enum_set(op->ptr, "bake_location", RNA_enum_get(&avs_ptr, "bake_location")); + } + + /* show popup dialog to allow editing of range... */ + // FIXME: hardcoded dimensions here are just arbitrary + return WM_operator_props_dialog_popup(C, op, 200, 200); +} + /* For the object with pose/action: create path curves for selected bones * This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range */ -static int pose_calculate_paths_exec (bContext *C, wmOperator *op) +static int pose_calculate_paths_exec(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); + Object *ob = object_pose_armature_get(CTX_data_active_object(C)); Scene *scene= CTX_data_scene(C); - Object *ob; - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); - else - ob= object_pose_armature_get(CTX_data_active_object(C)); - if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; + /* grab baking settings from operator settings */ + { + bAnimVizSettings *avs = &ob->pose->avs; + PointerRNA avs_ptr; + + avs->path_sf = RNA_int_get(op->ptr, "start_frame"); + avs->path_ef = RNA_int_get(op->ptr, "end_frame"); + + RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr); + RNA_enum_set(&avs_ptr, "bake_location", RNA_enum_get(op->ptr, "bake_location")); + } + /* set up path data for bones being calculated */ CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) { @@ -228,7 +258,7 @@ static int pose_calculate_paths_exec (bContext *C, wmOperator *op) ED_pose_recalculate_paths(scene, ob); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -241,11 +271,22 @@ void POSE_OT_paths_calculate(wmOperatorType *ot) ot->description = "Calculate paths for the selected bones"; /* api callbacks */ + ot->invoke = pose_calculate_paths_invoke; ot->exec = pose_calculate_paths_exec; ot->poll = ED_operator_posemode; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", + "First frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0); + RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", + "Last frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0); + + RNA_def_enum(ot->srna, "bake_location", motionpath_bake_location_items, 0, + "Bake Location", + "Which point on the bones is used when calculating paths"); } /* --------- */ @@ -279,14 +320,7 @@ static void ED_pose_clear_paths(Object *ob) /* operator callback for this */ static int pose_clear_paths_exec (bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); - else - ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ELEM(NULL, ob, ob->pose)) @@ -296,7 +330,7 @@ static int pose_clear_paths_exec (bContext *C, wmOperator *UNUSED(op)) ED_pose_clear_paths(ob); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 8ab1d1372b7..9561a5972ff 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1125,14 +1125,43 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) BLI_freelistN(&targets); } +/* show popup to determine settings */ +static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *evt) +{ + Object *ob = CTX_data_active_object(C); + + if (ob == NULL) + return OPERATOR_CANCELLED; + + /* set default settings from existing/stored settings */ + { + bAnimVizSettings *avs = &ob->avs; + + RNA_int_set(op->ptr, "start_frame", avs->path_sf); + RNA_int_set(op->ptr, "end_frame", avs->path_ef); + } + + /* show popup dialog to allow editing of range... */ + // FIXME: hardcoded dimensions here are just arbitrary + return WM_operator_props_dialog_popup(C, op, 200, 200); +} + /* Calculate/recalculate whole paths (avs.path_sf to avs.path_ef) */ static int object_calculate_paths_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); + int start = RNA_int_get(op->ptr, "start_frame"); + int end = RNA_int_get(op->ptr, "end_frame"); /* set up path data for bones being calculated */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { + bAnimVizSettings *avs = &ob->avs; + + /* grab baking settings from operator settings */ + avs->path_sf = start; + avs->path_ef = end; + /* verify that the selected object has the appropriate settings */ animviz_verify_motionpaths(op->reports, scene, ob, NULL); } @@ -1155,11 +1184,18 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot) ot->description = "Calculate motion paths for the selected objects"; /* api callbacks */ + ot->invoke = object_calculate_paths_invoke; ot->exec = object_calculate_paths_exec; ot->poll = ED_operator_object_active_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", + "First frame to calculate object paths on", MINFRAME, MAXFRAME/2.0); + RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", + "Last frame to calculate object paths on", MINFRAME, MAXFRAME/2.0); } /* --------- */ diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index afa6a6e9608..1b8772ffbcd 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -70,6 +70,8 @@ extern EnumPropertyItem fmodifier_type_items[]; extern EnumPropertyItem nla_mode_extend_items[]; extern EnumPropertyItem nla_mode_blend_items[]; +extern EnumPropertyItem motionpath_bake_location_items[]; + extern EnumPropertyItem event_value_items[]; extern EnumPropertyItem event_type_items[]; extern EnumPropertyItem operator_return_items[]; diff --git a/source/blender/makesrna/intern/rna_animviz.c b/source/blender/makesrna/intern/rna_animviz.c index f7065307d87..167eb23c023 100644 --- a/source/blender/makesrna/intern/rna_animviz.c +++ b/source/blender/makesrna/intern/rna_animviz.c @@ -39,6 +39,14 @@ #include "WM_types.h" +/* Which part of bone(s) get baked */ +// TODO: icons? +EnumPropertyItem motionpath_bake_location_items[] = { + {MOTIONPATH_BAKE_HEADS, "HEADS", 0, "Heads", "Calculate bone paths from heads"}, + {0, "TAILS", 0, "Tails", "Calculate bone paths from tails"}, + //{MOTIONPATH_BAKE_CENTERS, "CENTROID", 0, "Centers", "Calculate bone paths from center of mass"}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME static PointerRNA rna_AnimViz_onion_skinning_get(PointerRNA *ptr) @@ -241,10 +249,6 @@ static void rna_def_animviz_paths(BlenderRNA *brna) "Display Paths of poses within a fixed number of frames around the current frame"}, {MOTIONPATH_TYPE_RANGE, "RANGE", 0, "In Range", "Display Paths of poses within specified range"}, {0, NULL, 0, NULL, NULL}}; - static const EnumPropertyItem prop_location_items[] = { - {MOTIONPATH_BAKE_HEADS, "HEADS", 0, "Heads", "Calculate bone paths from heads"}, - {0, "TAILS", 0, "Tails", "Calculate bone paths from tails"}, - {0, NULL, 0, NULL, NULL}}; srna = RNA_def_struct(brna, "AnimVizMotionPaths", NULL); RNA_def_struct_sdna(srna, "bAnimVizSettings"); @@ -260,7 +264,7 @@ static void rna_def_animviz_paths(BlenderRNA *brna) prop = RNA_def_property(srna, "bake_location", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "path_bakeflag"); - RNA_def_property_enum_items(prop, prop_location_items); + RNA_def_property_enum_items(prop, motionpath_bake_location_items); RNA_def_property_ui_text(prop, "Bake Location", "When calculating Bone Paths, use Head or Tips"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ |