[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19731] branches/blender2.5/blender/source /blender/blenkernel: Action Constraint: Optimisation attempt

Joshua Leung aligorith at gmail.com
Wed Apr 15 14:59:49 CEST 2009


Revision: 19731
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19731
Author:   aligorith
Date:     2009-04-15 14:59:49 +0200 (Wed, 15 Apr 2009)

Log Message:
-----------
Action Constraint: Optimisation attempt

Following on from the methods added specially for PoseLib to only execute the F-Curves in a given Action Group, I've attempted to use this for evaluating Action Constraints on Pose Channels. This does rely on the F-Curves being in groups named according to name of the Pose Channel of interest, hence, we may need some way to be able to fine tune this later. 

Preliminary tests seem to be promising, with rigs with quite a few action constraints being slightly more responsive (subjective test though). Please test thoroughly.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/action.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h	2009-04-15 12:38:04 UTC (rev 19730)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h	2009-04-15 12:59:49 UTC (rev 19731)
@@ -134,7 +134,7 @@
 void framechange_poses_clear_unkeyed(void);
 
 /* Used for the Action Constraint */
-void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, float cframe);
+void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe);
 
 /* exported for game engine */
 void blend_poses(struct bPose *dst, struct bPose *src, float srcweight, short mode);

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/action.c	2009-04-15 12:38:04 UTC (rev 19730)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/action.c	2009-04-15 12:59:49 UTC (rev 19731)
@@ -65,6 +65,9 @@
 #include "BLI_blenlib.h"
 #include "BLI_ghash.h"
 
+#include "RNA_access.h"
+#include "RNA_types.h"
+
 //XXX #include "nla.h"
 
 /* *********************** NOTE ON POSE AND ACTION **********************
@@ -875,13 +878,12 @@
 /* For the calculation of the effects of an Action at the given frame on an object 
  * This is currently only used for the Action Constraint 
  */
-void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose, bAction *act, float cframe)
+void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe)
 {
-	AnimData adt;
+	bActionGroup *agrp= action_groups_find_named(act, groupname);
 	
-	/* clear workob and animdata */
+	/* clear workob */
 	clear_workob(workob);
-	memset(&adt, 0, sizeof(AnimData));
 	
 	/* init workob */
 	Mat4CpyMat4(workob->obmat, ob->obmat);
@@ -906,14 +908,30 @@
 	strcpy(workob->parsubstr, ob->parsubstr);
 	strcpy(workob->id.name, "OB<ConstrWorkOb>"); /* we don't use real object name, otherwise RNA screws with the real thing */
 	
-	/* init animdata, and attach to workob */
-	workob->adt= &adt;
-	
-	adt.recalc= ADT_RECALC_ANIM;
-	adt.action= act;
-	
-	/* execute effects of Action on to workob (or it's PoseChannels) */
-	BKE_animsys_evaluate_animdata(&workob->id, &adt, cframe, ADT_RECALC_ANIM);
+	/* if we're given a group to use, it's likely to be more efficient (though a bit more dangerous) */
+	if (agrp) {
+		/* specifically evaluate this group only */
+		PointerRNA id_ptr;
+		
+		/* get RNA-pointer for the workob's ID */
+		RNA_id_pointer_create(&workob->id, &id_ptr);
+		
+		/* execute action for this group only */
+		animsys_evaluate_action_group(&id_ptr, act, agrp, NULL, cframe);
+	}
+	else {
+		AnimData adt;
+		
+		/* init animdata, and attach to workob */
+		memset(&adt, 0, sizeof(AnimData));
+		workob->adt= &adt;
+		
+		adt.recalc= ADT_RECALC_ANIM;
+		adt.action= act;
+		
+		/* execute effects of Action on to workob (or it's PoseChannels) */
+		BKE_animsys_evaluate_animdata(&workob->id, &adt, cframe, ADT_RECALC_ANIM);
+	}
 }
 
 /* ********** NLA with non-poses works with ipo channels ********** */

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c	2009-04-15 12:38:04 UTC (rev 19730)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c	2009-04-15 12:59:49 UTC (rev 19731)
@@ -34,7 +34,6 @@
 #include <float.h>
 
 #include "MEM_guardedalloc.h"
-//XXX #include "nla.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
@@ -1904,8 +1903,7 @@
 			tchan= verify_pose_channel(pose, pchan->name);
 			
 			/* evaluate action using workob (it will only set the PoseChannel in question) */
-			// XXX we need some flags to prevent evaluation from setting disabled flags on all other settings
-			what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, t);
+			what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, pchan->name, t);
 			
 			/* convert animation to matrices for use here */
 			chan_calc_mat(tchan);
@@ -1918,7 +1916,8 @@
 			Object workob;
 			
 			/* evaluate using workob */
-			what_does_obaction(cob->scene, cob->ob, &workob, NULL, data->act, t);
+			// FIXME: we don't have any consistent standards on limiting effects on object...
+			what_does_obaction(cob->scene, cob->ob, &workob, NULL, data->act, NULL, t);
 			object_to_mat4(&workob, ct->matrix);
 		}
 		else {





More information about the Bf-blender-cvs mailing list