[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16880] trunk/blender/source/blender: Keyframe Checking (i.e.
Joshua Leung
aligorith at gmail.com
Thu Oct 2 10:39:30 CEST 2008
Revision: 16880
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16880
Author: aligorith
Date: 2008-10-02 10:39:30 +0200 (Thu, 02 Oct 2008)
Log Message:
-----------
Keyframe Checking (i.e. does given frame have a keyframe) is now implemented in the keyframing api.
Replaced the method used in to check if there's a keyframe on the current frame, when drawing the active object name / frame number info with this new code.
- It should in theory be faster than the previous code, as it doesn't have to build an entire list everytime of all keyframes, and also uses more efficient search method.
- Added some settings to control what sources of animation data are used (per 3d-view). Can be found in the View Properties panel.
This should be stable... release builders should ignore this commit for now (to avoid having differences between release candidates).
Modified Paths:
--------------
trunk/blender/source/blender/include/BIF_keyframing.h
trunk/blender/source/blender/makesdna/DNA_view3d_types.h
trunk/blender/source/blender/src/drawtime.c
trunk/blender/source/blender/src/drawview.c
trunk/blender/source/blender/src/keyframing.c
Modified: trunk/blender/source/blender/include/BIF_keyframing.h
===================================================================
--- trunk/blender/source/blender/include/BIF_keyframing.h 2008-10-02 06:22:36 UTC (rev 16879)
+++ trunk/blender/source/blender/include/BIF_keyframing.h 2008-10-02 08:39:30 UTC (rev 16880)
@@ -65,7 +65,7 @@
/* -------- */
/* Main Keyframing API calls:
- * Use this to create any necessary animation data,, and then insert a keyframe
+ * Use this to create any necessary animation data, and then insert a keyframe
* using the current value being keyframed, in the relevant place. Returns success.
*/
// TODO: adapt this for new data-api -> this blocktype, etc. stuff is evil!
@@ -104,18 +104,28 @@
/* ************ Keyframe Checking ******************** */
-/* Checks whether a keyframe exists for the given ID-block one the given frame */
-short id_cfra_has_keyframe(struct ID *id, short filter);
+/* Main Keyframe Checking API call:
+ * Checks whether a keyframe exists for the given ID-block one the given frame.
+ * - It is recommended to call this method over the other keyframe-checkers directly,
+ * in case some detail of the implementation changes...
+ * - frame: the value of this is quite often result of frame_to_float(CFRA)
+ */
+short id_frame_has_keyframe(struct ID *id, float frame, short filter);
-/* filter flags fr id_cfra_has_keyframe */
+/* filter flags for id_cfra_has_keyframe
+ *
+ * WARNING: do not alter order of these, as also stored in files
+ * (for v3d->keyflags)
+ */
enum {
/* general */
- ANIMFILTER_ALL = 0, /* include all available animation data */
ANIMFILTER_LOCAL = (1<<0), /* only include locally available anim data */
+ ANIMFILTER_MUTED = (1<<1), /* include muted elements */
+ ANIMFILTER_ACTIVE = (1<<2), /* only include active-subelements */
/* object specific */
- ANIMFILTER_MAT = (1<<1), /* include material keyframes too */
- ANIMFILTER_SKEY = (1<<2), /* shape keys (for geometry) */
+ ANIMFILTER_NOMAT = (1<<9), /* don't include material keyframes */
+ ANIMFILTER_NOSKEY = (1<<10), /* don't include shape keys (for geometry) */
} eAnimFilterFlags;
#endif /* BIF_KEYFRAMING_H */
Modified: trunk/blender/source/blender/makesdna/DNA_view3d_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_view3d_types.h 2008-10-02 06:22:36 UTC (rev 16879)
+++ trunk/blender/source/blender/makesdna/DNA_view3d_types.h 2008-10-02 08:39:30 UTC (rev 16880)
@@ -137,7 +137,7 @@
short gridsubdiv; /* Number of subdivisions in the grid between each highlighted grid line */
- short pad3;
+ short keyflags; /* flags for display of keyframes */
char ndofmode; /* mode of transform for 6DOF devices -1 not found, 0 normal, 1 fly, 2 ob transform */
char ndoffilter; /*filter for 6DOF devices 0 normal, 1 dominant */
Modified: trunk/blender/source/blender/src/drawtime.c
===================================================================
--- trunk/blender/source/blender/src/drawtime.c 2008-10-02 06:22:36 UTC (rev 16879)
+++ trunk/blender/source/blender/src/drawtime.c 2008-10-02 08:39:30 UTC (rev 16880)
@@ -437,21 +437,27 @@
}
/* Materials (only relevant for geometry objects) - some filtering might occur */
+ // err... is this ok?
filter= (stime->flag & TIME_ONLYACTSEL);
- for (a=0; a<ob->totcol; a++) {
- Material *ma= give_current_material(ob, a+1);
+ if (filter) {
+ Material *ma= give_current_material(ob, (ob->actcol + 1));
- /* the only filter we apply right now is only showing the active material */
- if (filter) {
- ok= (ob->actcol==a)? 1 : 0;
- }
- else ok= 1;
-
- if (ma && ma->ipo && ok) {
+ /* we only retrieve the active material... */
+ if (ma && ma->ipo) {
col[0] = 0xDD; col[1] = 0xA7; col[2] = 0x00;
draw_ipo_keys(ma->ipo, col);
}
}
+ else {
+ for (a=0; a<ob->totcol; a++) {
+ Material *ma= give_current_material(ob, a+1);
+
+ if (ma && ma->ipo) {
+ col[0] = 0xDD; col[1] = 0xA7; col[2] = 0x00;
+ draw_ipo_keys(ma->ipo, col);
+ }
+ }
+ }
}
}
Modified: trunk/blender/source/blender/src/drawview.c
===================================================================
--- trunk/blender/source/blender/src/drawview.c 2008-10-02 06:22:36 UTC (rev 16879)
+++ trunk/blender/source/blender/src/drawview.c 2008-10-02 08:39:30 UTC (rev 16880)
@@ -122,6 +122,7 @@
#include "BIF_glutil.h"
#include "BIF_interface.h"
#include "BIF_interface_icons.h"
+#include "BIF_keyframing.h"
#include "BIF_mywindow.h"
#include "BIF_poseobject.h"
#include "BIF_previewrender.h"
@@ -181,7 +182,7 @@
#include "radio.h"
/* locals */
-static void drawname(Object *ob);
+//static void drawname(Object *ob);
static void star_stuff_init_func(void)
{
@@ -1199,6 +1200,7 @@
return index;
}
+#if 0
static void drawname(Object *ob)
{
cpack(0x404040);
@@ -1207,6 +1209,7 @@
BMF_DrawString(G.font, " ");
BMF_DrawString(G.font, ob->id.name+2);
}
+#endif
static char *get_cfra_marker_name()
{
@@ -1217,95 +1220,17 @@
for (m1=markers->first, m2=markers->last; m1 && m2; m1=m1->next, m2=m2->prev) {
if (m1->frame==CFRA)
return m1->name;
- if (m2->frame==CFRA)
- return m2->name;
if (m1 == m2)
- break;
+ break;
+
+ if (m2->frame==CFRA)
+ return m2->name;
}
return NULL;
}
-// TODO: move this func into some keyframing API
-short ob_cfra_has_keyframe (Object *ob)
-{
- // fixme... this is slow!
- if (ob) {
- ListBase keys = {NULL, NULL};
- ActKeyColumn *ak, *akn;
- Key *key= ob_get_key(ob);
- int cfra, found= 0;
-
- /* check active action */
- if (ob->action) {
- /* get keyframes of action */
- action_to_keylist(ob->action, &keys, NULL, NULL);
-
- cfra= frame_to_float(CFRA);
- cfra= get_action_frame(ob, cfra);
-
- /* check if a keyframe occurs on current frame */
- for (ak=keys.first, akn=keys.last; ak && akn; ak=ak->next, akn=akn->prev) {
- if (cfra == ak->cfra) {
- found= 1;
- break;
- }
- else if (cfra == akn->cfra) {
- found= 1;
- break;
- }
-
- if (ak == akn)
- break;
- }
-
- /* free temp list */
- BLI_freelistN(&keys);
- keys.first= keys.last= NULL;
-
- /* return if found */
- if (found) return 1;
- }
-
- /* accumulate keyframes for available ipo's */
- if (ob->ipo)
- ipo_to_keylist(ob->ipo, &keys, NULL, NULL);
- if (key)
- ipo_to_keylist(key->ipo, &keys, NULL, NULL);
-
- if (keys.first) {
- cfra= frame_to_float(CFRA);
- found= 0;
-
- /* check if a keyframe occurs on current frame */
- for (ak=keys.first, akn=keys.last; ak && akn; ak=ak->next, akn=akn->prev) {
- if (IS_EQ(cfra, ak->cfra)) {
- found= 1;
- break;
- }
- else if (IS_EQ(cfra, akn->cfra)) {
- found= 1;
- break;
- }
-
- if (ak == akn)
- break;
- }
-
- /* free temp list */
- BLI_freelistN(&keys);
- keys.first= keys.last= NULL;
-
- /* return if found */
- if (found) return 1;
- }
- }
-
- /* couldn't find a keyframe */
- return 0;
-}
-
/* draw info beside axes in bottom left-corner:
* framenum, object name, bone name (if available), marker name (if available)
*/
@@ -1382,7 +1307,7 @@
}
/* colour depends on whether there is a keyframe */
- if (ob_cfra_has_keyframe(ob))
+ if (id_frame_has_keyframe((ID *)ob, frame_to_float(CFRA), G.vd->keyflags))
BIF_ThemeColor(TH_VERTEX_SELECT);
else
BIF_ThemeColor(TH_TEXT_HI);
@@ -2609,7 +2534,6 @@
uiBlockEndAlign(block);
uiDefBut(block, LABEL, 1, "Display:", 10, 50, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
-
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, V3D_SELECT_OUTLINE, REDRAWVIEW3D, "Outline Selected", 10, 30, 140, 19, &vd->flag, 0, 0, 0, 0, "Highlight selected objects with an outline, in Solid, Shaded or Textured viewport shading modes");
uiDefButBitS(block, TOG, V3D_DRAW_CENTERS, REDRAWVIEW3D, "All Object Centers", 10, 10, 140, 19, &vd->flag, 0, 0, 0, 0, "Draw the center points on all objects");
@@ -2617,11 +2541,21 @@
uiDefButBitS(block, TOG, V3D_SOLID_TEX, REDRAWVIEW3D, "Solid Tex", 10, -30, 140, 19, &vd->flag2, 0, 0, 0, 0, "Display textures in Solid draw type (Shift T)");
uiBlockEndAlign(block);
- uiDefBut(block, LABEL, 1, "View Locking:", 160, 50, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefBut(block, LABEL, 1, "View Locking:", 160, 60, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
uiBlockBeginAlign(block);
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, REDRAWVIEW3D, "Object:", 160, 30, 140, 19, &vd->ob_centre, "Lock view to center to this Object");
- uiDefBut(block, TEX, REDRAWVIEW3D, "Bone:", 160, 10, 140, 19, vd->ob_centre_bone, 1, 31, 0, 0, "If view locked to Object, use this Bone to lock to view to");
+ uiDefIDPoinBut(block, test_obpoin_but, ID_OB, REDRAWVIEW3D, "Object:", 160, 40, 140, 19, &vd->ob_centre, "Lock view to center to this Object");
+ uiDefBut(block, TEX, REDRAWVIEW3D, "Bone:", 160, 20, 140, 19, vd->ob_centre_bone, 1, 31, 0, 0, "If view locked to Object, use this Bone to lock to view to");
+ uiDefBut(block, LABEL, 1, "Keyframe Display:", 160, -2, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
+ uiBlockBeginAlign(block);
+ uiDefButBitS(block, TOG, ANIMFILTER_ACTIVE, REDRAWVIEW3D, "Active",160, -22, 50, 19, &vd->keyflags, 0, 0, 0, 0, "Show keyframes for active element only (i.e. active bone or active material)");
+ uiDefButBitS(block, TOG, ANIMFILTER_MUTED, REDRAWVIEW3D, "Muted",210, -22, 50, 19, &vd->keyflags, 0, 0, 0, 0, "Show keyframes in muted channels");
+ uiDefButBitS(block, TOG, ANIMFILTER_LOCAL, REDRAWVIEW3D, "Local",260, -22, 50, 19, &vd->keyflags, 0, 0, 0, 0, "Show keyframes directly connected to datablock");
+ if ((vd->keyflags & ANIMFILTER_LOCAL)==0) {
+ uiDefButBitS(block, TOGN, ANIMFILTER_NOMAT, REDRAWVIEW3D, "Material",160, -42, 75, 19, &vd->keyflags, 0, 0, 0, 0, "Show keyframes for any available Materials");
+ uiDefButBitS(block, TOGN, ANIMFILTER_NOSKEY, REDRAWVIEW3D, "ShapeKey",235, -42, 75, 19, &vd->keyflags, 0, 0, 0, 0, "Show keyframes for any available Shape Keys");
+ }
+ uiBlockEndAlign(block);
}
static void view3d_panel_preview(ScrArea *sa, short cntrl) // VIEW3D_HANDLER_PREVIEW
Modified: trunk/blender/source/blender/src/keyframing.c
===================================================================
--- trunk/blender/source/blender/src/keyframing.c 2008-10-02 06:22:36 UTC (rev 16879)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list