[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18289] branches/blender2.5/blender/source /blender: 2.5

Joshua Leung aligorith at gmail.com
Sat Jan 3 12:35:40 CET 2009


Revision: 18289
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18289
Author:   aligorith
Date:     2009-01-03 12:35:39 +0100 (Sat, 03 Jan 2009)

Log Message:
-----------
2.5

* Start of Action/Pose syncing code (in anim_deps.c) This is currently not hooked up yet, as we still need to figure out where these should get called (due to a few dependencies they have - i.e. visibility syncing of channels is turned on/off by setting in appropriate views).

* Also added assorted comments/changes to rna/dna

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/anim_deps.c
    branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_action_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c

Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_deps.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_deps.c	2009-01-03 10:03:26 UTC (rev 18288)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_deps.c	2009-01-03 11:35:39 UTC (rev 18289)
@@ -32,6 +32,8 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_action_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
@@ -41,6 +43,7 @@
 
 #include "BLI_blenlib.h"
 
+#include "BKE_action.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_global.h"
@@ -52,6 +55,7 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
+#include "ED_anim_api.h"
 
 /* ***************** depsgraph calls and anim updates ************* */
 
@@ -84,7 +88,7 @@
 
 /* results in fully updated anim system */
 /* in future sound should be on WM level, only 1 sound can play! */
-void ED_update_for_newframe(bContext *C, int mute)
+void ED_update_for_newframe(const bContext *C, int mute)
 {
 	bScreen *screen= CTX_wm_screen(C);
 	Scene *scene= screen->scene;
@@ -118,3 +122,96 @@
 	}
 }
 
+/* **************************** pose <-> action syncing ******************************** */
+/* Summary of what needs to be synced between poses and actions:
+ *	1) Flags
+ *		a) Visibility (only for pose to action) 
+ *		b) Selection status (both ways)
+ *	2) Group settings  (only for pose to action) - do we also need to make sure same groups exist?
+ *	3) Grouping (only for pose to action for now)
+ */
+
+/* Notifier from Action/Dopesheet (this may be extended to include other things such as Python...)
+ * Channels in action changed, so update pose channels/groups to reflect changes.
+ *
+ * An object (usually 'active' Object) needs to be supplied, so that its Pose-Channels can be synced with
+ * the channels in its active Action.
+ */
+void ANIM_action_to_pose_sync (Object *ob)
+{
+	bAction *act= (bAction *)ob->action;
+	bActionChannel *achan;
+	bPoseChannel *pchan;
+	
+	/* error checking */
+	if ((ob == NULL) || (ob->type != OB_ARMATURE) || ELEM(NULL, act, ob->pose))
+		return;
+	
+	/* 1b) loop through all Action-Channels (there should be fewer channels to search through here in general) */
+	for (achan= act->chanbase.first; achan; achan= achan->next) {
+		/* find matching pose-channel */
+		pchan= get_pose_channel(ob->pose, achan->name);
+		
+		/* sync active and selected flags */
+		if (pchan && pchan->bone) {
+			/* selection */
+			if (achan->flag & ACHAN_SELECTED)
+				pchan->bone->flag |= BONE_SELECTED;
+			else
+				pchan->bone->flag &= ~BONE_SELECTED;
+			
+			/* active */
+			if (achan->flag & ACHAN_HILIGHTED)
+				pchan->bone->flag |= BONE_ACTIVE;
+			else
+				pchan->bone->flag &= ~BONE_ACTIVE;
+		}
+	}
+	
+	// TODO: add grouping changes too? For now, these tools aren't exposed to users in animation editors yet...
+} 
+ 
+/* Notifier from 3D-View/Outliner (this is likely to include other sources too...)
+ * Pose channels/groups changed, so update action channels
+ *
+ * An object (usually 'active' Object) needs to be supplied, so that its Pose-Channels can be synced with
+ * the channels in its active Action.
+ */
+void ANIM_pose_to_action_sync (Object *ob)
+{
+	bArmature *arm= (bArmature *)ob->data;
+	bAction *act= (bAction *)ob->action;
+	bActionChannel *achan;
+	//bActionGroup *agrp, *bgrp;
+	bPoseChannel *pchan;
+	
+	/* error checking */
+	if ((ob == NULL) || (ob->type != OB_ARMATURE) || ELEM3(NULL, arm, act, ob->pose))
+		return;
+		
+	/* 1) loop through all Action-Channels (there should be fewer channels to search through here in general) */
+	for (achan= act->chanbase.first; achan; achan= achan->next) {
+		/* find matching pose-channel */
+		pchan= get_pose_channel(ob->pose, achan->name);
+		
+		/* sync selection and visibility settings */
+		if (pchan && pchan->bone) {
+			/* visibility - if layer is hidden, or if bone itself is hidden */
+			// XXX we may not want this happening though! (maybe we need some extra flags from context or so)
+			// only if SACTION_NOHIDE==0, and saction->pin == 0, when in Action Editor mode
+			if (!(pchan->bone->layer & arm->layer) || (pchan->bone->flag & BONE_HIDDEN_P))
+				achan->flag |= ACHAN_HIDDEN;
+			else
+				achan->flag &= ~ACHAN_HIDDEN;
+				
+			/* selection */
+			if (pchan->bone->flag & BONE_SELECTED)
+				achan->flag |= ACHAN_SELECTED;
+			else
+				achan->flag &= ~ACHAN_SELECTED;
+		}
+	}
+	
+	// XXX step 2 needs to be coded still... currently missing action/bone group API to do any more work here...	
+	// XXX step 3 needs to be coded still... it's a messy case to deal with (we'll use the temp indices for this?)
+}

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h	2009-01-03 10:03:26 UTC (rev 18288)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h	2009-01-03 11:35:39 UTC (rev 18289)
@@ -322,6 +322,10 @@
 void ED_anim_dag_flush_update(const struct bContext *C);
 void ED_update_for_newframe(const struct bContext *C, int mute);
 
+/* pose <-> action syncing */
+void ANIM_action_to_pose_sync(struct Object *ob);
+void ANIM_pose_to_action_sync(struct Object *ob);
+
 /* ************************************************* */
 /* OPERATORS */
 	

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_action_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_action_types.h	2009-01-03 10:03:26 UTC (rev 18288)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_action_types.h	2009-01-03 11:35:39 UTC (rev 18289)
@@ -157,7 +157,7 @@
 	
 	int		flag;			/* settings accessed via bitmapping */
 	char	name[32];		/* channel name */
-	int		reserved1;
+	int		temp;			/* temporary setting - may be used to indicate group that channel belongs to during syncing  */
 } bActionChannel;
 
 /* Action. A recyclable block that contains a series of Action Channels (ipo), which define 

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c	2009-01-03 10:03:26 UTC (rev 18288)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c	2009-01-03 11:35:39 UTC (rev 18289)
@@ -741,12 +741,12 @@
 	/* action / pose / nla */
 
 	prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE);
-	RNA_def_property_struct_type(prop, "UnknownType");
+	RNA_def_property_struct_type(prop, "UnknownType"); //action
 	RNA_def_property_ui_text(prop, "Action", "Action used by object to define Ipo curves.");
 
 	prop= RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "poselib");
-	RNA_def_property_struct_type(prop, "UnknownType");
+	RNA_def_property_struct_type(prop, "UnknownType"); // action
 	RNA_def_property_ui_text(prop, "Pose Library", "Action used as a pose library for armatures.");
 
 	prop= RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);





More information about the Bf-blender-cvs mailing list