== Action Editor ==
Cleaned-up drawing code of keyframes. Code redundancy has been reduced, and there should be slight performance gains (less looping, no sorting of keys needed, possibly less memory usage).
This commit is contained in:
@@ -2297,6 +2297,8 @@ void make_cfra_list(Ipo *ipo, ListBase *elems)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* what's the point of this little block of code? */
|
||||||
|
#if 0
|
||||||
if(ipo->showkey==0) {
|
if(ipo->showkey==0) {
|
||||||
/* deselect all keys */
|
/* deselect all keys */
|
||||||
ce= elems->first;
|
ce= elems->first;
|
||||||
@@ -2305,6 +2307,7 @@ void make_cfra_list(Ipo *ipo, ListBase *elems)
|
|||||||
ce= ce->next;
|
ce= ce->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *********************** INTERFACE FOR KETSJI ********** */
|
/* *********************** INTERFACE FOR KETSJI ********** */
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#include "BLI_arithb.h"
|
#include "BLI_arithb.h"
|
||||||
|
|
||||||
/* Types --------------------------------------------------------------- */
|
/* Types --------------------------------------------------------------- */
|
||||||
|
#include "DNA_listBase.h"
|
||||||
#include "DNA_action_types.h"
|
#include "DNA_action_types.h"
|
||||||
#include "DNA_armature_types.h"
|
#include "DNA_armature_types.h"
|
||||||
#include "DNA_curve_types.h"
|
#include "DNA_curve_types.h"
|
||||||
@@ -92,10 +93,10 @@
|
|||||||
|
|
||||||
/* local functions ----------------------------------------------------- */
|
/* local functions ----------------------------------------------------- */
|
||||||
int count_action_levels(bAction *act);
|
int count_action_levels(bAction *act);
|
||||||
static BezTriple **ipo_to_keylist(Ipo *ipo, int flags, int *totvert);
|
static ListBase *ipo_to_keylist(Ipo *ipo, int flags);
|
||||||
static BezTriple **action_to_keylist(bAction *act, int flags, int *totvert);
|
static ListBase *action_to_keylist(bAction *act, int flags);
|
||||||
static BezTriple **ob_to_keylist(Object *ob, int flags, int *totvert);
|
static ListBase *ob_to_keylist(Object *ob, int flags);
|
||||||
static BezTriple **icu_to_keylist(IpoCurve *icu, int flags, int *totvert);
|
static ListBase *icu_to_keylist(IpoCurve *icu, int flags);
|
||||||
void draw_icu_channel(gla2DDrawInfo *di, IpoCurve *icu, int flags, float ypos);
|
void draw_icu_channel(gla2DDrawInfo *di, IpoCurve *icu, int flags, float ypos);
|
||||||
|
|
||||||
|
|
||||||
@@ -777,50 +778,50 @@ static void draw_key_but(int x, int y, int w, int h, int sel)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void draw_keylist(gla2DDrawInfo *di, int totvert, BezTriple **blist, float ypos)
|
static void draw_keylist(gla2DDrawInfo *di, ListBase *elems, float ypos)
|
||||||
{
|
{
|
||||||
int v;
|
CfraElem *ce;
|
||||||
|
|
||||||
if (!blist)
|
if (!elems)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
for (v = 0; v<totvert; v++){
|
for (ce= elems->first; ce; ce= ce->next){
|
||||||
if (v==0 || (blist[v]->vec[1][0] != blist[v-1]->vec[1][0])){
|
|
||||||
int sc_x, sc_y;
|
int sc_x, sc_y;
|
||||||
gla2DDrawTranslatePt(di, blist[v]->vec[1][0], ypos, &sc_x, &sc_y);
|
gla2DDrawTranslatePt(di, ce->cfra, ypos, &sc_x, &sc_y);
|
||||||
// draw_key_but(sc_x-5, sc_y-6, 13, 13, (blist[v]->f2 & 1));
|
// draw_key_but(sc_x-5, sc_y-6, 13, 13, (ce->sel & 1));
|
||||||
|
|
||||||
if(blist[v]->f2 & 1) BIF_icon_draw_aspect(sc_x-7, sc_y-6, ICON_SPACE2, 1.0f);
|
if(ce->sel & 1) BIF_icon_draw_aspect(sc_x-7, sc_y-6, ICON_SPACE2, 1.0f);
|
||||||
else BIF_icon_draw_aspect(sc_x-7, sc_y-6, ICON_SPACE3, 1.0f);
|
else BIF_icon_draw_aspect(sc_x-7, sc_y-6, ICON_SPACE3, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_object_channel(gla2DDrawInfo *di, Object *ob, int flags, float ypos)
|
void draw_object_channel(gla2DDrawInfo *di, Object *ob, int flags, float ypos)
|
||||||
{
|
{
|
||||||
BezTriple **blist;
|
ListBase *elems;
|
||||||
int totvert;
|
|
||||||
|
|
||||||
blist = ob_to_keylist(ob, flags, &totvert);
|
elems = ob_to_keylist(ob, flags);
|
||||||
if (blist){
|
if (elems){
|
||||||
draw_keylist(di,totvert, blist, ypos);
|
draw_keylist(di, elems, ypos);
|
||||||
MEM_freeN(blist);
|
|
||||||
|
BLI_freelistN(elems);
|
||||||
|
MEM_freeN(elems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_ipo_channel(gla2DDrawInfo *di, Ipo *ipo, int flags, float ypos)
|
void draw_ipo_channel(gla2DDrawInfo *di, Ipo *ipo, int flags, float ypos)
|
||||||
{
|
{
|
||||||
BezTriple **blist;
|
ListBase *elems;
|
||||||
int totvert;
|
|
||||||
|
|
||||||
blist = ipo_to_keylist(ipo, flags, &totvert);
|
elems = ipo_to_keylist(ipo, flags);
|
||||||
if (blist){
|
if (elems){
|
||||||
draw_keylist(di,totvert, blist, ypos);
|
draw_keylist(di, elems, ypos);
|
||||||
MEM_freeN(blist);
|
|
||||||
|
BLI_freelistN(elems);
|
||||||
|
MEM_freeN(elems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -828,194 +829,127 @@ void draw_icu_channel(gla2DDrawInfo *di, IpoCurve *icu, int flags, float ypos)
|
|||||||
{
|
{
|
||||||
/* draw the keys for an IpoCurve
|
/* draw the keys for an IpoCurve
|
||||||
*/
|
*/
|
||||||
BezTriple **blist;
|
ListBase *elems;
|
||||||
int totvert;
|
|
||||||
|
|
||||||
blist = icu_to_keylist(icu, flags, &totvert);
|
elems = icu_to_keylist(icu, flags);
|
||||||
if (blist){
|
if (elems){
|
||||||
draw_keylist(di,totvert, blist, ypos);
|
draw_keylist(di, elems, ypos);
|
||||||
MEM_freeN(blist);
|
|
||||||
|
BLI_freelistN(elems);
|
||||||
|
MEM_freeN(elems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_action_channel(gla2DDrawInfo *di, bAction *act, int flags, float ypos)
|
void draw_action_channel(gla2DDrawInfo *di, bAction *act, int flags, float ypos)
|
||||||
{
|
{
|
||||||
BezTriple **blist;
|
ListBase *elems;
|
||||||
int totvert;
|
|
||||||
|
|
||||||
blist = action_to_keylist(act, flags, &totvert);
|
elems = action_to_keylist(act, flags);
|
||||||
if (blist){
|
|
||||||
draw_keylist(di,totvert, blist, ypos);
|
if (elems){
|
||||||
MEM_freeN(blist);
|
draw_keylist(di, elems, ypos);
|
||||||
|
|
||||||
|
BLI_freelistN(elems);
|
||||||
|
MEM_freeN(elems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BezTriple **ob_to_keylist(Object *ob, int flags, int *totvert)
|
static ListBase *ob_to_keylist(Object *ob, int flags)
|
||||||
{
|
{
|
||||||
IpoCurve *icu;
|
|
||||||
bConstraintChannel *conchan;
|
bConstraintChannel *conchan;
|
||||||
int v, count=0;
|
ListBase *elems = NULL;
|
||||||
|
|
||||||
BezTriple **list = NULL;
|
|
||||||
|
|
||||||
if (ob) {
|
if (ob) {
|
||||||
|
/* allocate memory for list */
|
||||||
/* Count Object Keys */
|
elems = MEM_callocN(sizeof(ListBase), "ObKeylist");
|
||||||
if (ob->ipo){
|
|
||||||
for (icu=ob->ipo->curve.first; icu; icu=icu->next){
|
|
||||||
count+=icu->totvert;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Count Constraint Keys */
|
|
||||||
for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next){
|
|
||||||
if(conchan->ipo)
|
|
||||||
for (icu=conchan->ipo->curve.first; icu; icu=icu->next)
|
|
||||||
count+=icu->totvert;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Count object data keys */
|
|
||||||
|
|
||||||
/* Build the list */
|
|
||||||
if (count){
|
|
||||||
list = MEM_callocN(sizeof(BezTriple*)*count, "beztlist");
|
|
||||||
count=0;
|
|
||||||
|
|
||||||
/* Add object keyframes */
|
/* Add object keyframes */
|
||||||
if (ob->ipo) {
|
if (ob->ipo) {
|
||||||
for (icu=ob->ipo->curve.first; icu; icu=icu->next){
|
make_cfra_list(ob->ipo, elems);
|
||||||
for (v=0; v<icu->totvert; v++){
|
|
||||||
list[count++]=&icu->bezt[v];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add constraint keyframes */
|
/* Add constraint keyframes */
|
||||||
for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next){
|
for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next){
|
||||||
if(conchan->ipo)
|
if(conchan->ipo) {
|
||||||
for (icu=conchan->ipo->curve.first; icu; icu=icu->next)
|
make_cfra_list(conchan->ipo, elems);
|
||||||
for (v=0; v<icu->totvert; v++)
|
}
|
||||||
list[count++]=&icu->bezt[v];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add object data keyframes */
|
/* Add object data keyframes */
|
||||||
|
// TODO??
|
||||||
/* Sort */
|
|
||||||
qsort(list, count, sizeof(BezTriple*), bezt_compare);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(*totvert)=count;
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BezTriple **icu_to_keylist(IpoCurve *icu, int flags, int *totvert)
|
/* return pointer to listbase */
|
||||||
|
return elems;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ListBase *icu_to_keylist(IpoCurve *icu, int flags)
|
||||||
{
|
{
|
||||||
/* compile a list of all bezier triples in an
|
/* compile a list of all bezier triples in an
|
||||||
* IpoCurve.
|
* IpoCurve.
|
||||||
*/
|
*/
|
||||||
int v, count = 0;
|
ListBase *elems = NULL;
|
||||||
|
BezTriple *bezt;
|
||||||
|
int v;
|
||||||
|
|
||||||
BezTriple **list = NULL;
|
if (icu && icu->totvert){
|
||||||
|
elems = MEM_callocN(sizeof(ListBase), "IpoCurveKeylist");
|
||||||
|
|
||||||
count=icu->totvert;
|
/* loop through beztriples, making CfraElems */
|
||||||
|
bezt= icu->bezt;
|
||||||
if (count){
|
for (v=0; v<icu->totvert; v++, bezt++) {
|
||||||
list = MEM_callocN(sizeof(BezTriple*)*count, "beztlist");
|
add_to_cfra_elem(elems, bezt);
|
||||||
count=0;
|
|
||||||
|
|
||||||
for (v=0; v<icu->totvert; v++){
|
|
||||||
list[count++]=&icu->bezt[v];
|
|
||||||
}
|
}
|
||||||
qsort(list, count, sizeof(BezTriple*), bezt_compare);
|
|
||||||
}
|
|
||||||
(*totvert)=count;
|
|
||||||
return list;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BezTriple **ipo_to_keylist(Ipo *ipo, int flags, int *totvert)
|
/* return pointer to listbase */
|
||||||
|
return elems;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ListBase *ipo_to_keylist(Ipo *ipo, int flags)
|
||||||
{
|
{
|
||||||
IpoCurve *icu;
|
ListBase *elems = NULL;
|
||||||
int v, count=0;
|
|
||||||
|
|
||||||
BezTriple **list = NULL;
|
|
||||||
|
|
||||||
if (ipo) {
|
if (ipo) {
|
||||||
/* Count required keys */
|
/* allocate memory for list of keys */
|
||||||
for (icu=ipo->curve.first; icu; icu=icu->next){
|
elems= MEM_callocN(sizeof(ListBase), "IpoKeylist");
|
||||||
count+=icu->totvert;
|
|
||||||
|
/* make list */
|
||||||
|
make_cfra_list(ipo, elems);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build the list */
|
/* return pointer to listbase */
|
||||||
if (count){
|
return elems;
|
||||||
list = MEM_callocN(sizeof(BezTriple*)*count, "beztlist");
|
|
||||||
count=0;
|
|
||||||
|
|
||||||
for (icu=ipo->curve.first; icu; icu=icu->next){
|
|
||||||
for (v=0; v<icu->totvert; v++){
|
|
||||||
list[count++]=&icu->bezt[v];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qsort(list, count, sizeof(BezTriple*), bezt_compare);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(*totvert)=count;
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BezTriple **action_to_keylist(bAction *act, int flags, int *totvert)
|
static ListBase *action_to_keylist(bAction *act, int flags)
|
||||||
{
|
{
|
||||||
IpoCurve *icu;
|
|
||||||
bActionChannel *achan;
|
bActionChannel *achan;
|
||||||
bConstraintChannel *conchan;
|
bConstraintChannel *conchan;
|
||||||
int v, count=0;
|
|
||||||
|
|
||||||
BezTriple **list = NULL;
|
ListBase *elems = NULL;
|
||||||
|
|
||||||
if (act) {
|
if (act) {
|
||||||
/* Count required keys */
|
/* allocate memory for list of keys */
|
||||||
|
elems= MEM_callocN(sizeof(ListBase), "ActionKeylist");
|
||||||
|
|
||||||
|
/* loop through action channels */
|
||||||
for (achan= act->chanbase.first; achan; achan= achan->next) {
|
for (achan= act->chanbase.first; achan; achan= achan->next) {
|
||||||
if((achan->flag & ACHAN_HIDDEN)==0) {
|
/* firstly, add keys from action channel's ipo block */
|
||||||
/* Count transformation keys */
|
|
||||||
if (achan->ipo) {
|
if (achan->ipo) {
|
||||||
for (icu=achan->ipo->curve.first; icu; icu=icu->next)
|
make_cfra_list(achan->ipo, elems);
|
||||||
count+=icu->totvert;
|
|
||||||
}
|
|
||||||
/* Count constraint keys */
|
|
||||||
for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next)
|
|
||||||
if(conchan->ipo)
|
|
||||||
for (icu=conchan->ipo->curve.first; icu; icu=icu->next)
|
|
||||||
count+=icu->totvert;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build the list */
|
/* then, add keys from constraint channels */
|
||||||
if (count){
|
|
||||||
list = MEM_callocN(sizeof(BezTriple*)*count, "beztlist");
|
|
||||||
count=0;
|
|
||||||
|
|
||||||
for (achan=act->chanbase.first; achan; achan=achan->next){
|
|
||||||
if((achan->flag & ACHAN_HIDDEN)==0) {
|
|
||||||
if(achan->ipo) {
|
|
||||||
/* Add transformation keys */
|
|
||||||
for (icu=achan->ipo->curve.first; icu; icu=icu->next){
|
|
||||||
for (v=0; v<icu->totvert; v++)
|
|
||||||
list[count++]=&icu->bezt[v];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Add constraint keys */
|
|
||||||
for (conchan= achan->constraintChannels.first; conchan; conchan= conchan->next) {
|
for (conchan= achan->constraintChannels.first; conchan; conchan= conchan->next) {
|
||||||
if(conchan->ipo)
|
if (conchan->ipo) {
|
||||||
for (icu=conchan->ipo->curve.first; icu; icu=icu->next)
|
make_cfra_list(conchan->ipo, elems);
|
||||||
for (v=0; v<icu->totvert; v++)
|
|
||||||
list[count++]=&icu->bezt[v];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qsort(list, count, sizeof(BezTriple*), bezt_compare);
|
}
|
||||||
|
|
||||||
}
|
/* return pointer to listbase */
|
||||||
}
|
return elems;
|
||||||
(*totvert)=count;
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user