[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21849] branches/blender2.5/blender/source /blender/editors: 2.5 - Restored Bone Paths Operators
Joshua Leung
aligorith at gmail.com
Fri Jul 24 14:27:43 CEST 2009
Revision: 21849
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21849
Author: aligorith
Date: 2009-07-24 14:27:42 +0200 (Fri, 24 Jul 2009)
Log Message:
-----------
2.5 - Restored Bone Paths Operators
* A number-counter cursor is now used while sampling the curve
* Fixed some of the drawing errors with the paths. Unfortunately, when the armature is rotated, the path text is drawn in the wrong places still...
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
branches/blender2.5/blender/source/blender/editors/space_view3d/drawarmature.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h 2009-07-24 12:20:39 UTC (rev 21848)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h 2009-07-24 12:27:42 UTC (rev 21849)
@@ -67,6 +67,9 @@
void POSE_OT_copy(struct wmOperatorType *ot);
void POSE_OT_paste(struct wmOperatorType *ot);
+void POSE_OT_paths_calculate(struct wmOperatorType *ot);
+void POSE_OT_paths_clear(struct wmOperatorType *ot);
+
void POSE_OT_select_all_toggle(struct wmOperatorType *ot);
void POSE_OT_select_inverse(struct wmOperatorType *ot);
void POSE_OT_select_parent(struct wmOperatorType *ot);
Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c 2009-07-24 12:20:39 UTC (rev 21848)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c 2009-07-24 12:27:42 UTC (rev 21849)
@@ -150,6 +150,9 @@
WM_operatortype_append(POSE_OT_copy);
WM_operatortype_append(POSE_OT_paste);
+ WM_operatortype_append(POSE_OT_paths_calculate);
+ WM_operatortype_append(POSE_OT_paths_clear);
+
WM_operatortype_append(POSE_OT_select_all_toggle);
WM_operatortype_append(POSE_OT_select_inverse);
Modified: branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poseobject.c 2009-07-24 12:20:39 UTC (rev 21848)
+++ branches/blender2.5/blender/source/blender/editors/armature/poseobject.c 2009-07-24 12:27:42 UTC (rev 21849)
@@ -21,6 +21,7 @@
* All rights reserved.
*
* Contributor(s): Ton Roosendaal, Blender Foundation '05, full recode.
+ * Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
* support for animation modes - Reevan McKay
@@ -50,6 +51,7 @@
#include "DNA_view3d_types.h"
#include "DNA_userdef_types.h"
+#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_blender.h"
@@ -89,7 +91,6 @@
/* ************* XXX *************** */
static int movetolayer_short_buts() {return 1;}
static int pupmenu() {return 0;}
-static void waitcursor() {};
static void error() {};
static void BIF_undo_push() {}
static void countall() {}
@@ -201,10 +202,12 @@
/* ********************************************** */
-/* 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
+/* 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 pose_calculate_path(bContext *C, Scene *scene, Object *ob)
+void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
{
bArmature *arm;
bPoseChannel *pchan;
@@ -213,30 +216,29 @@
int cfra;
int sfra, efra;
- if (ob==NULL || ob->pose==NULL)
+ /* sanity checks */
+ if ELEM(NULL, ob, ob->pose)
return;
arm= ob->data;
- /* version patch for older files here (do_versions patch too complicated) */
- if ((arm->pathsf == 0) || (arm->pathef == 0)) {
- arm->pathsf = SFRA;
- arm->pathef = EFRA;
- }
- if (arm->pathsize == 0) {
- arm->pathsize = 1;
- }
-
/* set frame values */
- cfra= CFRA;
- sfra = arm->pathsf;
- efra = arm->pathef;
- if (efra <= sfra) {
- error("Can't calculate paths when pathlen <= 0");
- return;
+ cfra = CFRA;
+ sfra = efra = cfra;
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if ((pchan->bone) && (arm->layer & pchan->bone->layer)) {
+ if (pchan->path) {
+ /* if the pathsf and pathef aren't initialised, abort! */
+ if (ELEM(0, pchan->pathsf, pchan->pathef))
+ return;
+
+ /* try to increase area to do (only as much as needed) */
+ sfra= MIN2(sfra, pchan->pathsf);
+ efra= MAX2(efra, pchan->pathef);
+ }
+ }
}
+ if (efra <= sfra) return;
- waitcursor(1);
-
/* hack: for unsaved files, set OB_RECALC so that paths can get calculated */
if ((ob->recalc & OB_RECALC)==0) {
ob->recalc |= OB_RECALC;
@@ -245,35 +247,30 @@
else
ED_anim_object_flush_update(C, ob);
-
- /* malloc the path blocks */
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
- if (arm->layer & pchan->bone->layer) {
- pchan->pathlen= efra-sfra+1;
- pchan->pathsf= sfra;
- pchan->pathef= efra+1;
- if (pchan->path)
- MEM_freeN(pchan->path);
- pchan->path= MEM_callocN(3*pchan->pathlen*sizeof(float), "pchan path");
- }
- }
- }
-
+ /* calculate path over requested range */
for (CFRA=sfra; CFRA<=efra; CFRA++) {
/* do all updates */
for (base= FIRSTBASE; base; base= base->next) {
if (base->object->recalc) {
int temp= base->object->recalc;
+
+ if (base->object->adt)
+ BKE_animsys_evaluate_animdata(&base->object->id, base->object->adt, (float)CFRA, ADT_RECALC_ALL);
+
+ /* update object */
object_handle_update(scene, base->object);
base->object->recalc= temp;
}
}
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
- if (arm->layer & pchan->bone->layer) {
- if (pchan->path) {
+ if ((pchan->bone) && (arm->layer & pchan->bone->layer)) {
+ if (pchan->path) {
+ /* only update if:
+ * - in range of this pchan's existing path
+ * - ... insert evil filtering/optimising conditions here...
+ */
+ if (IN_RANGE(CFRA, pchan->pathsf, pchan->pathef)) {
fp= pchan->path+3*(CFRA-sfra);
if (arm->pathflag & ARM_PATH_HEADS) {
@@ -290,16 +287,35 @@
}
}
- waitcursor(0);
+ /* reset flags */
+ CFRA= cfra;
+ ob->pose->flag &= ~POSE_RECALCPATHS;
- CFRA= cfra;
+ /* flush one final time - to restore to the original state */
+ for (base= FIRSTBASE; base; base= base->next) {
+ if (base->object->recalc) {
+ int temp= base->object->recalc;
+
+ if (base->object->adt)
+ BKE_animsys_evaluate_animdata(&base->object->id, base->object->adt, (float)CFRA, ADT_RECALC_ALL);
+
+ object_handle_update(scene, base->object);
+ base->object->recalc= temp;
+ }
+ }
}
-/* For the object with pose/action: update paths for those that have got them
- * This should selectively update paths that exist...
+/* --------- */
+
+/* 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
*/
-void pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
+static int pose_calculate_paths_exec (bContext *C, wmOperator *op)
{
+ wmWindow *win= CTX_wm_window(C);
+ ScrArea *sa= CTX_wm_area(C);
+ Scene *scene= CTX_data_scene(C);
+ Object *ob;
bArmature *arm;
bPoseChannel *pchan;
Base *base;
@@ -307,30 +323,36 @@
int cfra;
int sfra, efra;
- if (ob==NULL || ob->pose==NULL)
- return;
+ /* 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= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ else
+ ob= CTX_data_active_object(C);
+
+ /* only continue if there's an object */
+ if ELEM(NULL, ob, ob->pose)
+ return OPERATOR_CANCELLED;
arm= ob->data;
- /* set frame values */
- cfra = CFRA;
- sfra = efra = cfra;
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- if ((pchan->bone) && (arm->layer & pchan->bone->layer)) {
- if (pchan->path) {
- /* if the pathsf and pathef aren't initialised, abort! */
- if (ELEM(0, pchan->pathsf, pchan->pathef))
- return;
-
- /* try to increase area to do (only as much as needed) */
- sfra= MIN2(sfra, pchan->pathsf);
- efra= MAX2(efra, pchan->pathef);
- }
- }
+ /* version patch for older files here (do_versions patch too complicated) */
+ if ((arm->pathsf == 0) || (arm->pathef == 0)) {
+ arm->pathsf = SFRA;
+ arm->pathef = EFRA;
}
- if (efra <= sfra) return;
+ if (arm->pathsize == 0) {
+ arm->pathsize = 1;
+ }
- waitcursor(1);
+ /* get frame values to use */
+ cfra= CFRA;
+ sfra = arm->pathsf;
+ efra = arm->pathef;
+ if (efra <= sfra) {
+ BKE_report(op->reports, RPT_ERROR, "Can't calculate paths when pathlen <= 0");
+ return OPERATOR_CANCELLED;
+ }
+
/* hack: for unsaved files, set OB_RECALC so that paths can get calculated */
if ((ob->recalc & OB_RECALC)==0) {
ob->recalc |= OB_RECALC;
@@ -339,24 +361,42 @@
else
ED_anim_object_flush_update(C, ob);
+ /* alloc the path cache arrays */
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
+ if (arm->layer & pchan->bone->layer) {
+ pchan->pathlen= efra-sfra+1;
+ pchan->pathsf= sfra;
+ pchan->pathef= efra+1;
+ if (pchan->path)
+ MEM_freeN(pchan->path);
+ pchan->path= MEM_callocN(3*pchan->pathlen*sizeof(float), "pchan path");
+ }
+ }
+ }
+
+ /* step through frame range sampling the values */
for (CFRA=sfra; CFRA<=efra; CFRA++) {
+ /* for each frame we calculate, update time-cursor... (may be too slow) */
+ WM_timecursor(win, CFRA);
+
/* do all updates */
for (base= FIRSTBASE; base; base= base->next) {
if (base->object->recalc) {
int temp= base->object->recalc;
+
+ if (base->object->adt)
+ BKE_animsys_evaluate_animdata(&base->object->id, base->object->adt, (float)CFRA, ADT_RECALC_ALL);
+
object_handle_update(scene, base->object);
base->object->recalc= temp;
}
}
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- if ((pchan->bone) && (arm->layer & pchan->bone->layer)) {
- if (pchan->path) {
- /* only update if:
- * - in range of this pchan's existing path
- * - ... insert evil filtering/optimising conditions here...
- */
- if (IN_RANGE(CFRA, pchan->pathsf, pchan->pathef)) {
+ if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
+ if (arm->layer & pchan->bone->layer) {
+ if (pchan->path) {
fp= pchan->path+3*(CFRA-sfra);
if (arm->pathflag & ARM_PATH_HEADS) {
@@ -373,18 +413,55 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list