[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19486] branches/blender2.5/blender/source /blender: Animato - Support for 'BuiltIn' and 'Relative' Keying Sets
Joshua Leung
aligorith at gmail.com
Wed Apr 1 00:36:13 CEST 2009
Revision: 19486
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19486
Author: aligorith
Date: 2009-04-01 00:36:13 +0200 (Wed, 01 Apr 2009)
Log Message:
-----------
Animato - Support for 'BuiltIn' and 'Relative' Keying Sets
When inserting keyframes in the 3D-View (support will be extended to other editors in due course) using the IKEY hotkey, the menu which appears will now consist of 3 parts:
* 'Active Keying Set' - this option allows you to use the user-defined KeyingSet which is active for the current scene (i.e. the one seen in the TimeLine/Outliner headers)
* User defined Keying Sets - a list of all such available KeyingSets is included, and entries can be chosen from there
* Built-In Keying Sets - see later...
To achieve this, several changes needed to be made first:
* Added support for 'relative' in addition to 'absolute' Keying Sets. Relative Keying Sets are Keying Sets which operate on data from the current context (i.e. a 'location' KeyingSet will add location keyframes for selected objects/bones/nodes as opposed to location keyframes for some particular object). The is a tentative 'templates' requirement system here, which still needs to be fully fleshed out.
* Added support for builtin Keying Sets (i.e. 'Location', 'Rotation', 'Scaling', and 'LocRot' as a few initial demonstrations), which replaces the temporary Insert Keyframe operator for the 3D-View (IKEY). These are effectively relative Keying Set definitions which are included in Blender by default and stored in a list separate from user-defined ones. Volunteer help in defining a few more of these for other editors will be welcome soon.
* Removed/replaced much of the crappy temporary Keyframing operator code, though a few tweaks could still be done.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/BKE_constraint.h
branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c
branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c
branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h
branches/blender2.5/blender/source/blender/editors/object/object_ops.c
branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c
branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_init_exit.c
Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_constraint.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_constraint.h 2009-03-31 22:34:34 UTC (rev 19485)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_constraint.h 2009-03-31 22:36:13 UTC (rev 19486)
@@ -110,11 +110,13 @@
/* Constraint function prototypes */
void unique_constraint_name(struct bConstraint *con, struct ListBase *list);
-void free_constraints(struct ListBase *conlist);
+void free_constraints(struct ListBase *list);
void copy_constraints(struct ListBase *dst, struct ListBase *src);
void relink_constraints(struct ListBase *list);
void free_constraint_data(struct bConstraint *con);
+struct bConstraint *constraints_get_active(struct ListBase *list);
+
/* Constraints + Proxies function prototypes */
void extract_proxylocal_constraints(struct ListBase *dst, struct ListBase *src);
short proxylocked_constraints_owner(struct Object *ob, struct bPoseChannel *pchan);
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c 2009-03-31 22:34:34 UTC (rev 19485)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c 2009-03-31 22:36:13 UTC (rev 19486)
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <string.h>
+#include <stddef.h>
#include "MEM_guardedalloc.h"
@@ -238,6 +239,9 @@
/* add KeyingSet to list */
BLI_addtail(list, ks);
+ /* make sure KeyingSet has a unique name (this helps with identification) */
+ BLI_uniquename(list, ks, "Keying Set", offsetof(KeyingSet, name), 64);
+
/* return new KeyingSet for further editing */
return ks;
}
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c 2009-03-31 22:34:34 UTC (rev 19485)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/constraint.c 2009-03-31 22:36:13 UTC (rev 19486)
@@ -3203,17 +3203,16 @@
}
/* Free all constraints from a constraint-stack */
-void free_constraints (ListBase *conlist)
+void free_constraints (ListBase *list)
{
bConstraint *con;
/* Free constraint data and also any extra data */
- for (con= conlist->first; con; con= con->next) {
+ for (con= list->first; con; con= con->next)
free_constraint_data(con);
- }
/* Free the whole list */
- BLI_freelistN(conlist);
+ BLI_freelistN(list);
}
/* Reassign links that constraints have to other data (called during file loading?) */
@@ -3266,6 +3265,23 @@
}
}
+/* finds the 'active' constraint in a constraint stack */
+bConstraint *constraints_get_active (ListBase *list)
+{
+ bConstraint *con;
+
+ /* search for the first constraint with the 'active' flag set */
+ if (list) {
+ for (con= list->first; con; con= con->next) {
+ if (con->flag & CONSTRAINT_ACTIVE)
+ return con;
+ }
+ }
+
+ /* no active constraint found */
+ return NULL;
+}
+
/* -------- Constraints and Proxies ------- */
/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c 2009-03-31 22:34:34 UTC (rev 19485)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c 2009-03-31 22:36:13 UTC (rev 19486)
@@ -177,7 +177,7 @@
float xminv=999999999.0f, xmaxv=-999999999.0f;
float yminv=999999999.0f, ymaxv=-999999999.0f;
short foundvert=0;
- int i;
+ unsigned int i;
if (fcu->totvert) {
if (fcu->bezt) {
@@ -418,7 +418,7 @@
void testhandles_fcurve (FCurve *fcu)
{
BezTriple *bezt;
- int a;
+ unsigned int a;
/* only beztriples have handles (bpoints don't though) */
if ELEM(NULL, fcu, fcu->bezt)
@@ -475,7 +475,7 @@
/* currently, will only be needed when there are beztriples */
if (fcu->bezt) {
BezTriple *bezt;
- int a;
+ unsigned int a;
/* loop over ALL points to adjust position in array and recalculate handles */
for (a=0, bezt=fcu->bezt; a < fcu->totvert; a++, bezt++) {
@@ -509,7 +509,7 @@
/* This function tests if any BezTriples are out of order, thus requiring a sort */
short test_time_fcurve (FCurve *fcu)
{
- int a;
+ unsigned int a;
/* sanity checks */
if (fcu == NULL)
@@ -895,7 +895,8 @@
{
BezTriple *bezt, *prevbezt, *lastbezt;
float v1[2], v2[2], v3[2], v4[2], opl[32], dx, fac;
- int a, b;
+ unsigned int a;
+ int b;
float cvalue = 0.0f;
/* get pointers */
Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c 2009-03-31 22:34:34 UTC (rev 19485)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c 2009-03-31 22:36:13 UTC (rev 19486)
@@ -380,8 +380,9 @@
// XXX this is used all over... maybe for screen instead?
WM_operatortype_append(ANIM_OT_insert_keyframe);
WM_operatortype_append(ANIM_OT_delete_keyframe);
- WM_operatortype_append(ANIM_OT_insert_keyframe_old);
- WM_operatortype_append(ANIM_OT_delete_keyframe_old);
+ WM_operatortype_append(ANIM_OT_insert_keyframe_menu);
+ //WM_operatortype_append(ANIM_OT_delete_keyframe_menu);
+ WM_operatortype_append(ANIM_OT_delete_keyframe_old); // xxx remove?
WM_operatortype_append(ANIM_OT_keyingset_add_new);
WM_operatortype_append(ANIM_OT_keyingset_add_destination);
Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-03-31 22:34:34 UTC (rev 19485)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-03-31 22:36:13 UTC (rev 19486)
@@ -61,10 +61,10 @@
/* general data/destination-source settings */
ID *id; /* id-block this comes from */
- char *rna_path; /* base path to use */ // xxx.... maybe we don't need this?
/* specific cases */
- bPoseChannel *pchan; /* only needed when doing recalcs... */
+ bPoseChannel *pchan;
+ bConstraint *con;
} bCommonKeySrc;
/* ******************************************* */
@@ -867,7 +867,7 @@
}
/* ******************************************* */
-/* KEYINGSETS */
+/* KEYING SETS - EDITING API */
/* Operators ------------------------------------------- */
@@ -1042,16 +1042,9 @@
}
-
/* ******************************************* */
-/* KEYFRAME MODIFICATION */
+/* KEYING SETS - BUILTIN */
-/* mode for commonkey_modifykey */
-enum {
- COMMONKEY_MODE_INSERT = 0,
- COMMONKEY_MODE_DELETE,
-} eCommonModifyKey_Modes;
-
#if 0 // XXX old keyingsets code based on adrcodes... to be restored in due course
/* --------- KeyingSet Adrcode Getters ------------ */
@@ -1570,229 +1563,319 @@
} eKS_Contexts;
-/* ---------------- KeyingSet Tools ------------------- */
+#endif // XXX old keyingsets code based on adrcodes... to be restored in due course
-/* helper for commonkey_context_get() - get keyingsets for 3d-view */
-static void commonkey_context_getv3d (const bContext *C, ListBase *sources, bKeyingContext **ksc)
+/* Macros for Declaring KeyingSets ------------------- */
+
+/* A note about this system for declaring built-in Keying Sets:
+ * One may ask, "What is the purpose of all of these macros and static arrays?" and
+ * "Why not call the KeyingSets API defined in BKE_animsys.h?". The answer is two-fold.
+ *
+ * 1) Firstly, we use static arrays of struct definitions instead of function calls, as
+ * it reduces the start-up overhead and allocated-memory footprint of Blender. If we called
+ * the KeyingSets API to build these sets, the overhead of checking for unique names, allocating
+ * memory for each and every path and KeyingSet, scattered around in RAM, all of which would increase
+ * the startup time (which is totally unacceptable) and could lead to fragmentation+slower access times.
+ * 2) Since we aren't using function calls, we need a nice way of defining these KeyingSets in a way which
+ * is easily readable and less prone to breakage from changes to the underlying struct definitions. Further,
+ * adding additional entries SHOULD NOT require custom code to be written to access these new entries/sets.
+ * Therefore, here we have a system with nice, human-readable statements via macros, and static arrays which
+ * are linked together using more special macros + struct definitions, allowing for such a generic + simple
+ * initialisation function (init_builtin_keyingsets()) compared with that of something like the Nodes system.
+ */
+
+/* Struct type for declaring builtin KeyingSets in as entries in static arrays*/
+typedef struct bBuiltinKeyingSet {
+ KeyingSet ks; /* the KeyingSet to build */
+ int tot; /* the total number of paths defined */
+ KS_Path paths[64]; /* the paths for the KeyingSet to use */
+} bBuiltinKeyingSet;
+
+ /* WARNING: the following macros must be kept in sync with the
+ * struct definitions in DNA_anim_types.h!
+ */
+
+/* macro for defining a builtin KeyingSet */
+#define BI_KS_DEFINE(name, keyingflag) \
+ {NULL, NULL, {NULL, NULL}, name, KEYINGSET_BUILTIN, keyingflag}
+
+/* macro to start defining paths for a builtin KeyingSet */
+#define BI_KS_PATHS_BEGIN(tot) \
+ tot, {
+
+/* macro to finish defining paths for a builtin KeyingSet */
+#define BI_KS_PATHS_END \
+ }
+
+/* macro for defining a builtin KeyingSet's path */
+#define BI_KSP_DEFINE(id_type, templates, prop_path, array_index, flag, groupflag) \
+ {NULL, NULL, NULL, "", id_type, templates, prop_path, array_index, flag, groupflag}
+
+/* ---- */
+
+/* Struct type for finding all the arrays of builtin KeyingSets */
+typedef struct bBuiltinKSContext {
+ bBuiltinKeyingSet *bks; /* array of KeyingSet definitions */
+ int tot; /* number of KeyingSets in this array */
+} bBuiltinKSContext;
+
+/* macro for defining builtin KeyingSet sets
+ * NOTE: all the arrays of sets must follow this naming convention!
+ */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list