Revision: 19699
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19699
Author:   aligorith
Date:     2009-04-13 04:40:56 +0200 (Mon, 13 Apr 2009)

Log Message:
-----------
2.5 - Separated Keying Sets code out into its own file

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/keyframing.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/animation/anim_intern.h
    branches/blender2.5/blender/source/blender/editors/animation/keyingsets.c

Added: 
branches/blender2.5/blender/source/blender/editors/animation/anim_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_intern.h  
                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_intern.h  
2009-04-13 02:40:56 UTC (rev 19699)
@@ -0,0 +1,40 @@
+/* Testing code for 2.5 animation system 
+ * Copyright 2009, Joshua Leung
+ */
+ 
+#ifndef ANIM_INTERN_H
+#define ANIM_INTERN_H
+
+/* ----------- Common Keyframe Destination Sources ------------ */
+/* (used as part of KeyingSets/Keyframing interface as separation from 
context) */
+
+/* temporary struct to gather data combos to keyframe */
+typedef struct bCommonKeySrc {
+       struct bCommonKeySrc *next, *prev;
+               
+               /* general data/destination-source settings */
+       ID *id;                                 /* id-block this comes from */
+       
+               /* specific cases */
+       bPoseChannel *pchan;    
+       bConstraint *con;
+} bCommonKeySrc;
+
+/* KeyingSets/Keyframing Interface ------------- */
+
+/* list of builtin KeyingSets (defined in keyingsets.c) */
+extern ListBase builtin_keyingsets;
+
+/* mode for modify_keyframes */
+enum {
+       MODIFYKEY_MODE_INSERT = 0,
+       MODIFYKEY_MODE_DELETE,
+} eModifyKey_Modes;
+
+short keyingset_context_ok_poll(bContext *C, KeyingSet *ks);
+
+short modifykey_get_context_data (bContext *C, ListBase *dsources, KeyingSet 
*ks);
+
+int modify_keyframes(bContext *C, ListBase *dsources, KeyingSet *ks, short 
mode, float cfra);
+
+#endif // ANIM_INTERN_H

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframing.c   
2009-04-13 00:49:22 UTC (rev 19698)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframing.c   
2009-04-13 02:40:56 UTC (rev 19699)
@@ -50,23 +50,8 @@
 #include "RNA_define.h"
 #include "RNA_types.h"
 
-/* ************************************************** */
-/* LOCAL TYPES AND DEFINES */
+#include "anim_intern.h"
 
-/* ----------- Common KeyData Sources ------------ */
-
-/* temporary struct to gather data combos to keyframe */
-typedef struct bCommonKeySrc {
-       struct bCommonKeySrc *next, *prev;
-               
-               /* general data/destination-source settings */
-       ID *id;                                 /* id-block this comes from */
-       
-               /* specific cases */
-       bPoseChannel *pchan;    
-       bConstraint *con;
-} bCommonKeySrc;
-
 /* ******************************************* */
 /* Animation Data Validation */
 
@@ -867,879 +852,6 @@
 }
 
 /* ******************************************* */
-/* KEYING SETS - EDITING API  */
-
-/* Operators ------------------------------------------- */
-
-/* These operators are only provided for scripting/macro usage, not for direct
- * calling from the UI since they wrap some of the data-access API code for 
these
- * (defined in blenkernel) which have quite a few properties.
- */
-
-/* ----- */
-
-static int keyingset_add_destination_exec (bContext *C, wmOperator *op)
-{
-       PointerRNA ptr;
-       KeyingSet *ks= NULL;
-       ID *id= NULL;
-       char rna_path[256], group_name[64]; // xxx
-       short groupmode=0, flag=0;
-       int array_index=0;
-       
-       /* get settings from operator properties */
-       ptr = RNA_pointer_get(op->ptr, "keyingset");
-       if (ptr.data) 
-               ks= (KeyingSet *)ptr.data;
-       
-       ptr = RNA_pointer_get(op->ptr, "id");
-       if (ptr.data)
-               id= (ID *)ptr.data;
-       
-       groupmode= RNA_enum_get(op->ptr, "grouping_method");
-       RNA_string_get(op->ptr, "group_name", group_name);              
-       
-       RNA_string_get(op->ptr, "rna_path", rna_path);
-       array_index= RNA_int_get(op->ptr, "array_index");
-       
-       if (RNA_boolean_get(op->ptr, "entire_array"))
-               flag |= KSP_FLAG_WHOLE_ARRAY;
-       
-       /* if enough args are provided, call API method */
-       if (ks) {
-               BKE_keyingset_add_destination(ks, id, group_name, rna_path, 
array_index, flag, groupmode);
-               return OPERATOR_FINISHED;
-       }
-       else {
-               BKE_report(op->reports, RPT_ERROR, "Keying Set could not be 
added.");
-               return OPERATOR_CANCELLED;
-       }       
-}
-
-void ANIM_OT_keyingset_add_destination (wmOperatorType *ot)
-{
-       // XXX: this is also defined in rna_animation.c
-       static EnumPropertyItem prop_mode_grouping_items[] = {
-               {KSP_GROUP_NAMED, "NAMED", "Named Group", ""},
-               {KSP_GROUP_NONE, "NONE", "None", ""},
-               {KSP_GROUP_KSNAME, "KEYINGSET", "Keying Set Name", ""},
-               {0, NULL, NULL, NULL}};
-       
-       /* identifiers */
-       ot->name= "Add Keying Set Destination";
-       ot->idname= "ANIM_OT_keyingset_add_destination";
-       
-       /* callbacks */
-       ot->exec= keyingset_add_destination_exec;
-       ot->poll= ED_operator_scene_editable;
-       
-       /* props */
-               /* pointers */ // xxx - do we want to directly expose these?
-       RNA_def_pointer_runtime(ot->srna, "keyingset", &RNA_KeyingSet, "Keying 
Set", "Keying Set to add destination to.");
-       RNA_def_pointer_runtime(ot->srna, "id", &RNA_ID, "ID", "ID-block for 
the destination.");
-               /* grouping */
-       RNA_def_enum(ot->srna, "grouping_method", prop_mode_grouping_items, 
KSP_GROUP_NAMED, "Grouping Method", "Method used to define which Group-name to 
use.");
-       RNA_def_string(ot->srna, "group_name", "", 64, "Group Name", "Name of 
Action Group to assign destination to (only if grouping mode is to use this 
name).");
-               /* rna-path */
-       RNA_def_string(ot->srna, "rna_path", "", 256, "RNA-Path", "RNA-Path to 
destination property."); // xxx hopefully this is long enough
-       RNA_def_int(ot->srna, "array_index", 0, 0, INT_MAX, "Array Index", "If 
applicable, the index ", 0, INT_MAX);
-               /* flags */
-       RNA_def_boolean(ot->srna, "entire_array", 1, "Entire Array", "hen an 
'array/vector' type is chosen (Location, Rotation, Color, etc.), entire array 
is to be used.");
-       
-}
- 
-/* ----- */
-
-static int keyingset_add_new_exec (bContext *C, wmOperator *op)
-{
-       Scene *sce= CTX_data_scene(C);
-       KeyingSet *ks= NULL;
-       short flag=0, keyingflag=0;
-       char name[64];
-       
-       /* get settings from operator properties */
-       RNA_string_get(op->ptr, "name", name);
-       
-       if (RNA_boolean_get(op->ptr, "absolute"))
-               flag |= KEYINGSET_ABSOLUTE;
-       if (RNA_boolean_get(op->ptr, "insertkey_needed"))
-               keyingflag |= INSERTKEY_NEEDED;
-       if (RNA_boolean_get(op->ptr, "insertkey_visual"))
-               keyingflag |= INSERTKEY_MATRIX;
-               
-       /* call the API func, and set the active keyingset index */
-       ks= BKE_keyingset_add(&sce->keyingsets, name, flag, keyingflag);
-       
-       if (ks) {
-               sce->active_keyingset= BLI_countlist(&sce->keyingsets);
-               return OPERATOR_FINISHED;
-       }
-       else {
-               BKE_report(op->reports, RPT_ERROR, "Keying Set could not be 
added.");
-               return OPERATOR_CANCELLED;
-       }
-}
-
-void ANIM_OT_keyingset_add_new (wmOperatorType *ot)
-{
-       /* identifiers */
-       ot->name= "Add Keying Set";
-       ot->idname= "ANIM_OT_keyingset_add_new";
-       
-       /* callbacks */
-       ot->exec= keyingset_add_new_exec;
-       ot->poll= ED_operator_scene_editable;
-       
-       /* props */
-               /* name */
-       RNA_def_string(ot->srna, "name", "KeyingSet", 64, "Name", "Name of 
Keying Set");
-               /* flags */
-       RNA_def_boolean(ot->srna, "absolute", 1, "Absolute", "Keying Set 
defines specific paths/settings to be keyframed (i.e. is not reliant on context 
info)");
-               /* keying flags */
-       RNA_def_boolean(ot->srna, "insertkey_needed", 0, "Insert Keyframes - 
Only Needed", "Only insert keyframes where they're needed in the relevant 
F-Curves.");
-       RNA_def_boolean(ot->srna, "insertkey_visual", 0, "Insert Keyframes - 
Visual", "Insert keyframes based on 'visual transforms'.");
-}
-
-/* UI API --------------------------------------------- */
-
-/* Build menu-string of available keying-sets (allocates memory for string)
- * NOTE: mode must not be longer than 64 chars
- */
-char *ANIM_build_keyingsets_menu (ListBase *list, short for_edit)
-{
-       DynStr *pupds= BLI_dynstr_new();
-       KeyingSet *ks;
-       char buf[64];
-       char *str;
-       int i;
-       
-       /* add title first */
-       BLI_dynstr_append(pupds, "Keying Sets%t|");
-       
-       /* add dummy entries for none-active */
-       if (for_edit) { 
-               BLI_dynstr_append(pupds, "Add New%x-1|");
-               BLI_dynstr_append(pupds, " %x0|");
-       }
-       else
-               BLI_dynstr_append(pupds, "<No Keying Set Active>%x0|");
-       
-       /* loop through keyingsets, adding them */
-       for (ks=list->first, i=1; ks; ks=ks->next, i++) {
-               if (for_edit == 0)
-                       BLI_dynstr_append(pupds, "KS: ");
-               
-               BLI_dynstr_append(pupds, ks->name);
-               BLI_snprintf( buf, 64, "%%x%d%s", i, ((ks->next)?"|":"") );
-               BLI_dynstr_append(pupds, buf);
-       }
-       
-       /* convert to normal MEM_malloc'd string */
-       str= BLI_dynstr_get_cstring(pupds);
-       BLI_dynstr_free(pupds);
-       
-       return str;
-}
-
-
-/* ******************************************* */
-/* KEYING SETS - BUILTIN */
-
-#if 0 // XXX old keyingsets code based on adrcodes... to be restored in due 
course
-
-/* --------- KeyingSet Adrcode Getters ------------ */
-
-/* initialise a channel-getter storage */
-static void ks_adrcodegetter_init (bKS_AdrcodeGetter *kag, bKeyingSet *ks, 
bCommonKeySrc *cks)
-{
-       /* error checking */
-       if (kag == NULL)
-               return;
-       
-       if (ELEM(NULL, ks, cks)) {
-               /* set invalid settings that won't cause harm */
-               kag->ks= NULL;
-               kag->cks= NULL;
-               kag->index= -2;
-               kag->tot= 0;
-       }
-       else {
-               /* store settings */
-               kag->ks= ks;
-               kag->cks= cks;
-               
-               /* - index is -1, as that allows iterators to return first 
element
-                * - tot is chan_num by default, but may get overriden if -1 is 
encountered (for extension-type getters)
-                */
-               kag->index= -1;
-               kag->tot= ks->chan_num;
-       }
-}
-
-/* 'default' channel-getter that will be used when iterating through 
keyingset's channels 
- *      - iteration will stop when adrcode <= 0 is encountered, so we use that 
as escape
- */
-static short ks_getnextadrcode_default (bKS_AdrcodeGetter *kag)
-{      
-       bKeyingSet *ks= (kag)? kag->ks : NULL;
-       
-       /* error checking */
-       if (ELEM(NULL, kag, ks)) return 0;
-       if (kag->tot <= 0) return 0;
-       
-       kag->index++;
-       if ((kag->index < 0) || (kag->index >= kag->tot)) return 0;
-       
-       /* return the adrcode stored at index then */
-       return ks->adrcodes[kag->index];
-}
-
-/* add map flag (for MTex channels, as certain ones need special offset) */
-static short ks_getnextadrcode_addmap (bKS_AdrcodeGetter *kag)
-{
-       short adrcode= ks_getnextadrcode_default(kag);
-       
-       /* if there was an adrcode returned, assume that kag stuff is set ok */
-       if (adrcode) {
-               bCommonKeySrc *cks= kag->cks;
-               bKeyingSet *ks= kag->ks;
-               
-               if (ELEM3(ks->blocktype, ID_MA, ID_LA, ID_WO)) {
-                       switch (adrcode) {
-                               case MAP_OFS_X: case MAP_OFS_Y: case MAP_OFS_Z:
-                               case MAP_SIZE_X: case MAP_SIZE_Y: case 
MAP_SIZE_Z:

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to