[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13721] trunk/blender/source/blender: == Action Editor Drawing - Optimisation Attempt ==
Joshua Leung
aligorith at gmail.com
Sun Feb 17 07:00:18 CET 2008
Revision: 13721
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13721
Author: aligorith
Date: 2008-02-17 07:00:18 +0100 (Sun, 17 Feb 2008)
Log Message:
-----------
== Action Editor Drawing - Optimisation Attempt ==
Another attempt at further optimising Action Editor drawing without doing any drastic changes.
Modified Paths:
--------------
trunk/blender/source/blender/makesdna/DNA_action_types.h
trunk/blender/source/blender/src/drawaction.c
trunk/blender/source/blender/src/transform_conversions.c
Modified: trunk/blender/source/blender/makesdna/DNA_action_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_action_types.h 2008-02-16 19:37:33 UTC (rev 13720)
+++ trunk/blender/source/blender/makesdna/DNA_action_types.h 2008-02-17 06:00:18 UTC (rev 13721)
@@ -220,7 +220,7 @@
/* SpaceAction flag */
typedef enum SACTION_FLAG {
- /* during transform */
+ /* during transform (only set for TimeSlide) */
SACTION_MOVING = (1<<0),
/* show sliders (if relevant) */
SACTION_SLIDERS = (1<<1),
Modified: trunk/blender/source/blender/src/drawaction.c
===================================================================
--- trunk/blender/source/blender/src/drawaction.c 2008-02-16 19:37:33 UTC (rev 13720)
+++ trunk/blender/source/blender/src/drawaction.c 2008-02-17 06:00:18 UTC (rev 13721)
@@ -1092,10 +1092,10 @@
*/
ActKeyColumn *ak, *akn;
- if (!(keys) || !(bezt)) return;
+ if (ELEM(NULL, keys, bezt)) return;
- /* try to find a keyblock that starts on the previous beztriple */
- for (ak= keys->first; ak; ak= ak->next) {
+ /* try to any existing key to replace, or where to insert after */
+ for (ak= keys->last; ak; ak= ak->prev) {
/* do because of double keys */
if (ak->cfra == bezt->vec[1][0]) {
/* set selection status and 'touched' status */
@@ -1104,12 +1104,12 @@
return;
}
- else if (ak->cfra > bezt->vec[1][0]) break;
+ else if (ak->cfra < bezt->vec[1][0]) break;
}
/* add new block */
akn= MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn");
- if (ak) BLI_insertlinkbefore(keys, ak, akn);
+ if (ak) BLI_insertlinkafter(keys, ak, akn);
else BLI_addtail(keys, akn);
akn->cfra= bezt->vec[1][0];
@@ -1166,7 +1166,7 @@
if (IS_EQ(prev->vec[1][1], prev->vec[2][1])==0) return;
/* try to find a keyblock that starts on the previous beztriple */
- for (ab= blocks->first; ab; ab= ab->next) {
+ for (ab= blocks->last; ab; ab= ab->prev) {
/* check if alter existing block or add new block */
if (ab->start == prev->vec[1][0]) {
/* set selection status and 'touched' status */
@@ -1175,12 +1175,12 @@
return;
}
- else if (ab->start > prev->vec[1][0]) break;
+ else if (ab->start < prev->vec[1][0]) break;
}
/* add new block */
abn= MEM_callocN(sizeof(ActKeyBlock), "ActKeyBlock");
- if (ab) BLI_insertlinkbefore(blocks, ab, abn);
+ if (ab) BLI_insertlinkafter(blocks, ab, abn);
else BLI_addtail(blocks, abn);
abn->start= prev->vec[1][0];
@@ -1197,14 +1197,22 @@
/* helper function - find actkeycolumn that occurs on cframe */
static ActKeyColumn *cfra_find_actkeycolumn (ListBase *keys, float cframe)
{
- ActKeyColumn *ak;
+ ActKeyColumn *ak, *ak2;
if (keys==NULL)
return NULL;
- for (ak= keys->first; ak; ak= ak->next) {
+ /* search from both ends at the same time, and stop if we find match or if both ends meet */
+ for (ak=keys->first, ak2=keys->last; ak && ak2; ak=ak->next, ak2=ak2->prev) {
+ /* return whichever end encounters the frame */
if (ak->cfra == cframe)
return ak;
+ if (ak2->cfra == cframe)
+ return ak2;
+
+ /* no matches on either end, so return NULL */
+ if (ak == ak2)
+ return NULL;
}
return NULL;
@@ -1429,8 +1437,8 @@
void icu_to_keylist(IpoCurve *icu, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
{
BezTriple *bezt;
- ActKeyColumn *ak;
- ActKeyBlock *ab;
+ ActKeyColumn *ak, *ak2;
+ ActKeyBlock *ab, *ab2;
int v;
if (icu && icu->totvert) {
@@ -1447,19 +1455,33 @@
/* update the number of curves that elements have appeared in */
if (keys) {
- for (ak= keys->first; ak; ak= ak->next) {
+ for (ak=keys->first, ak2=keys->last; ak && ak2; ak=ak->next, ak2=ak2->prev) {
if (ak->modified) {
ak->modified = 0;
ak->totcurve += 1;
}
+ if (ak2->modified) {
+ ak2->modified = 0;
+ ak2->totcurve += 1;
+ }
+
+ if (ak == ak2)
+ break;
}
}
if (blocks) {
- for (ab= blocks->first; ab; ab= ab->next) {
+ for (ab=blocks->first, ab2=blocks->last; ab && ab2; ab=ab->next, ab2=ab2->prev) {
if (ab->modified) {
ab->modified = 0;
ab->totcurve += 1;
}
+ if (ab2->modified) {
+ ab2->modified = 0;
+ ab2->totcurve += 1;
+ }
+
+ if (ab == ab2)
+ break;
}
}
}
Modified: trunk/blender/source/blender/src/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/src/transform_conversions.c 2008-02-16 19:37:33 UTC (rev 13720)
+++ trunk/blender/source/blender/src/transform_conversions.c 2008-02-17 06:00:18 UTC (rev 13721)
@@ -3409,8 +3409,6 @@
/* Do curve updates */
remake_action_ipos((bAction *)data);
-
- G.saction->flag &= ~SACTION_MOVING;
}
else if (datatype == ACTCONT_SHAPEKEY) {
/* fix up the Ipocurves and redraw stuff */
@@ -3434,6 +3432,8 @@
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
}
+
+ G.saction->flag &= ~SACTION_MOVING;
}
else if (t->spacetype == SPACE_NLA) {
synchronize_action_strips();
More information about the Bf-blender-cvs
mailing list