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:
authorJoshua Leung <aligorith@gmail.com>2010-01-19 14:31:49 +0300
committerJoshua Leung <aligorith@gmail.com>2010-01-19 14:31:49 +0300
commit7759fc2983422ef234b1d9a2bcdbc4c7e6265071 (patch)
tree4b4fbac13821dc33cef421623db2ef45287f08af /source/blender/editors/object
parented578c27c821a146ca684137d5eb1ac986858599 (diff)
Motion Paths - (Part 3) Operators, Drawing, and Fixes
This commit makes the new-style Motion Paths work for Objects and Bones. Motion Paths can either be added for Objects (Object buttons) or for Selected Bones in PoseMode (Armature Buttons), and/or removed from these panels too. Changes: * Changed the way the baking code worked, since it was better to be able to bake a bunch of objects at once, instead of doing it per object * Fixed a variety of bugs regarding initialising defaults and reading old files * Added operators for Objects (like for bones), and replaced the existing code for bones. * Fixed bug with baking code that was causing it to bake the wrong ranges Todos: * Frame number drawing is currently messed up, since the "cached" text drawing takes into account the object transforms. * The new MotionPath panels currently appear as the first panels in the respective contexts, probably due to the order in which the files are included. This needs some fixing, though not sure what the best way is yet.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_edit.c112
-rw-r--r--source/blender/editors/object/object_intern.h2
-rw-r--r--source/blender/editors/object/object_ops.c2
3 files changed, 116 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 54fa3f51eb6..e2d714fac0d 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1610,6 +1610,118 @@ void copy_attr_menu(Scene *scene, View3D *v3d)
copy_attr(scene, v3d, event);
}
+/* ********************************************** */
+/* Motion Paths */
+
+/* For the object with pose/action: update paths for those that have got them
+ * This should selectively update paths that exist...
+ *
+ * To be called from various tools that do incremental updates
+ */
+void ED_objects_recalculate_paths(bContext *C, Scene *scene)
+{
+ ListBase targets = {NULL, NULL};
+
+ /* loop over objects in scene */
+ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
+ {
+ /* set flag to force recalc, then grab the relevant bones to target */
+ ob->avs.recalc |= ANIMVIZ_RECALC_PATHS;
+ animviz_get_object_motionpaths(ob, &targets);
+ }
+ CTX_DATA_END;
+
+ /* recalculate paths, then free */
+ animviz_calc_motionpaths(scene, &targets);
+ BLI_freelistN(&targets);
+}
+
+/* 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 object_calculate_paths_exec (bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+
+ /* set up path data for bones being calculated */
+ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
+ {
+ /* verify makes sure that the selected bone has a bone with the appropriate settings */
+ animviz_verify_motionpaths(scene, ob, NULL);
+ }
+ CTX_DATA_END;
+
+ /* calculate the bones that now have motionpaths... */
+ // TODO: only make for the selected bones?
+ ED_objects_recalculate_paths(C, scene);
+
+ /* notifiers for updates */
+ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_paths_calculate (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Calculate Object Paths";
+ ot->idname= "OBJECT_OT_paths_calculate";
+ ot->description= "Calculate paths for the selected bones.";
+
+ /* api callbacks */
+ ot->exec= object_calculate_paths_exec;
+ ot->poll= ED_operator_object_active_editable;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* --------- */
+
+/* for the object with pose/action: clear path curves for selected bones only */
+void ED_objects_clear_paths(bContext *C, Scene *scene)
+{
+ /* loop over objects in scene */
+ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
+ {
+ if (ob->mpath) {
+ animviz_free_motionpath(ob->mpath);
+ ob->mpath= NULL;
+ }
+ }
+ CTX_DATA_END;
+}
+
+/* operator callback for this */
+static int object_clear_paths_exec (bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+
+ /* use the backend function for this */
+ ED_objects_clear_paths(C, scene);
+
+ /* notifiers for updates */
+ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_paths_clear (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Clear Object Paths";
+ ot->idname= "OBJECT_OT_paths_clear";
+ ot->description= "Clear path caches for selected bones.";
+
+ /* api callbacks */
+ ot->exec= object_clear_paths_exec;
+ ot->poll= ED_operator_object_active_editable;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+
/********************** Smooth/Flat *********************/
static int shade_smooth_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index cfb4cda2460..a11ead1fe9d 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -79,6 +79,8 @@ void OBJECT_OT_restrictview_clear(struct wmOperatorType *ot);
void OBJECT_OT_proxy_make(struct wmOperatorType *ot);
void OBJECT_OT_shade_smooth(struct wmOperatorType *ot);
void OBJECT_OT_shade_flat(struct wmOperatorType *ot);
+void OBJECT_OT_paths_calculate(struct wmOperatorType *ot);
+void OBJECT_OT_paths_clear(struct wmOperatorType *ot);
/* object_select.c */
void OBJECT_OT_select_all(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 8b29e2ca2ae..80992887e97 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -81,6 +81,8 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_restrictview_set);
WM_operatortype_append(OBJECT_OT_shade_smooth);
WM_operatortype_append(OBJECT_OT_shade_flat);
+ WM_operatortype_append(OBJECT_OT_paths_calculate);
+ WM_operatortype_append(OBJECT_OT_paths_clear);
WM_operatortype_append(OBJECT_OT_parent_set);
WM_operatortype_append(OBJECT_OT_parent_no_inverse_set);