[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15166] branches/apricot/source/blender: ipo ghosting option, request from venomgfx to help adjusting ipos with a reference to the original (enable in the view menu -> Ghost Editmode)
Campbell Barton
ideasman42 at gmail.com
Sun Jun 8 22:47:34 CEST 2008
Revision: 15166
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15166
Author: campbellbarton
Date: 2008-06-08 22:47:34 +0200 (Sun, 08 Jun 2008)
Log Message:
-----------
ipo ghosting option, request from venomgfx to help adjusting ipos with a reference to the original (enable in the view menu -> Ghost Editmode)
Modified Paths:
--------------
branches/apricot/source/blender/blenloader/intern/readfile.c
branches/apricot/source/blender/include/BSE_editipo.h
branches/apricot/source/blender/makesdna/DNA_space_types.h
branches/apricot/source/blender/src/drawipo.c
branches/apricot/source/blender/src/editipo.c
branches/apricot/source/blender/src/header_ipo.c
branches/apricot/source/blender/src/space.c
Modified: branches/apricot/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/apricot/source/blender/blenloader/intern/readfile.c 2008-06-08 20:43:22 UTC (rev 15165)
+++ branches/apricot/source/blender/blenloader/intern/readfile.c 2008-06-08 20:47:34 UTC (rev 15166)
@@ -151,6 +151,8 @@
#include "BLO_undofile.h"
#include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory
+#include "BSE_editipo_types.h"
+
#include "readfile.h"
#include "genfile.h"
@@ -3733,6 +3735,7 @@
else if(sl->spacetype==SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo *)sl;
sipo->editipo= 0;
+ sipo->editipo_ghost= 0;
if(sipo->blocktype==ID_SEQ) sipo->from= NULL; // no libdata
else sipo->from= newlibadr(fd, sc->id.lib, sipo->from);
@@ -3927,6 +3930,21 @@
sipo->ipo= restore_pointer_by_name(newmain, (ID *)sipo->ipo, 0);
if(sipo->editipo) MEM_freeN(sipo->editipo);
sipo->editipo= NULL;
+
+ if(sipo->editipo_ghost) {
+ EditIpo *ei = sipo->editipo_ghost;
+ int a;
+ for(a=0; a<sipo->totipo_ghost; a++, ei++) {
+ if (ei->icu) {
+ free_ipo_curve(ei->icu);
+ }
+ }
+ MEM_freeN(sipo->editipo_ghost);
+ sipo->editipo_ghost = NULL;
+ }
+
+ if(sipo->editipo_ghost) MEM_freeN(sipo->editipo_ghost);
+ sipo->editipo_ghost= NULL;
}
else if(sl->spacetype==SPACE_BUTS) {
SpaceButs *sbuts= (SpaceButs *)sl;
Modified: branches/apricot/source/blender/include/BSE_editipo.h
===================================================================
--- branches/apricot/source/blender/include/BSE_editipo.h 2008-06-08 20:43:22 UTC (rev 15165)
+++ branches/apricot/source/blender/include/BSE_editipo.h 2008-06-08 20:47:34 UTC (rev 15166)
@@ -169,6 +169,11 @@
void select_icu_key(struct IpoCurve *icu, float selx, int selectmode);
void setexprap_ipoloop(struct Ipo *ipo, int code);
+void free_ipo_ghost(void);
+void make_ipo_ghost(void);
+void make_ipo_ghost(void);
+struct EditIpo *give_ghost_orig( struct EditIpo *ei_ghost );
+
/* callbacks */
int select_bezier_add(struct BezTriple *bezt);
int select_bezier_subtract(struct BezTriple *bezt);
Modified: branches/apricot/source/blender/makesdna/DNA_space_types.h
===================================================================
--- branches/apricot/source/blender/makesdna/DNA_space_types.h 2008-06-08 20:43:22 UTC (rev 15165)
+++ branches/apricot/source/blender/makesdna/DNA_space_types.h 2008-06-08 20:47:34 UTC (rev 15166)
@@ -86,7 +86,8 @@
View2D v2d;
void *editipo;
- ListBase ipokey;
+ void *editipo_ghost; /* copies of the editipos made when entering editmode, APRICOT HACK */
+ ListBase ipokey;
/* the ipo context we need to store */
struct Ipo *ipo;
@@ -94,6 +95,8 @@
char actname[32], constname[32], bonename[32];
short totipo, pin;
+ short totipo_ghost, pad3;
+ int pad4;
short butofs, channel;
short showkey, blocktype;
short menunr, lock;
@@ -527,6 +530,7 @@
/* SpaceIpo->flag */
#define SIPO_LOCK_VIEW 1<<0
#define SIPO_NOTRANSKEYCULL 1<<1
+#define SIPO_EDITGHOST 1<<2
/* SpaceText flags (moved from DNA_text_types.h) */
Modified: branches/apricot/source/blender/src/drawipo.c
===================================================================
--- branches/apricot/source/blender/src/drawipo.c 2008-06-08 20:43:22 UTC (rev 15165)
+++ branches/apricot/source/blender/src/drawipo.c 2008-06-08 20:47:34 UTC (rev 15166)
@@ -1307,27 +1307,44 @@
pickselcode= 1;
}
-static void draw_ipocurves(int sel)
+static void draw_ipocurves(int sel, int ghost)
{
- EditIpo *ei;
+ EditIpo *ei, *ei_orig=NULL;
IpoCurve *icu;
BezTriple *bezt, *prevbezt;
float *fp, fac, data[120], v1[2], v2[2], v3[2], v4[2];
float cycdx=0, cycdy=0, cycxofs, cycyofs;
- int a, b, resol, cycount, val, nr;
+ int a, b, resol, cycount, val, nr, totipo_context;
+ if (ghost) {
+ ei = G.sipo->editipo_ghost;
+ setlinestyle(1);
+ } else {
+ ei = G.sipo->editipo;
+ }
- ei= G.sipo->editipo;
- for(nr=0; nr<G.sipo->totipo; nr++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt) {
+ for(nr=0; nr< (ghost ? G.sipo->totipo_ghost : G.sipo->totipo); nr++, ei++) {
+ if (ghost) {
+ ei_orig = give_ghost_orig(ei);
+ if (ei_orig==NULL) {
+ continue;
+ }
+ }
+ if ISPOIN3((ghost?ei_orig:ei), flag & IPO_VISIBLE, icu, icu->bezt) {
if(G.f & G_PICKSEL) {
glLoadName(pickselcode++);
val= 1;
}
else {
- val= (ei->flag & (IPO_SELECT+IPO_EDIT))!=0;
- val= (val==sel);
+ if (ghost) {
+ val= (ei_orig->flag & (IPO_SELECT+IPO_EDIT))!=0;
+ val= (val==sel);
+ } else {
+ val= (ei->flag & (IPO_SELECT+IPO_EDIT))!=0;
+ val= (val==sel);
+ }
+
}
if(val) {
@@ -1510,20 +1527,26 @@
}
/* line that indicates the end of a speed curve */
- if(G.sipo->blocktype==ID_CU && icu->adrcode==CU_SPEED) {
- b= icu->totvert-1;
- if(b) {
- glColor3ub(0, 0, 0);
- bezt= icu->bezt+b;
- glBegin(GL_LINES);
- glVertex2f(bezt->vec[1][0], 0.0);
- glVertex2f(bezt->vec[1][0], bezt->vec[1][1]);
- glEnd();
+ if (!ghost) {
+ if(G.sipo->blocktype==ID_CU && icu->adrcode==CU_SPEED) {
+ b= icu->totvert-1;
+ if(b) {
+ glColor3ub(0, 0, 0);
+ bezt= icu->bezt+b;
+ glBegin(GL_LINES);
+ glVertex2f(bezt->vec[1][0], 0.0);
+ glVertex2f(bezt->vec[1][0], bezt->vec[1][1]);
+ glEnd();
+ }
}
}
}
}
}
+
+ if (ghost) {
+ setlinestyle(0);
+ }
}
static int get_ipo_cfra_from_cfra(SpaceIpo * sipo, int cfra)
@@ -2244,13 +2267,18 @@
if (NLA_IPO_SCALED)
actstrip_map_ipo_keys(OBACT, sipo->ipo, 0, 0);
+ /* draw ghost */
+ if ((G.sipo->flag & SIPO_EDITGHOST) && G.sipo->editipo_ghost) {
+ draw_ipocurves(1, 1);
+ }
+
/* draw deselect */
- draw_ipocurves(0);
+ draw_ipocurves(0, 0);
draw_ipohandles(0);
draw_ipovertices(0);
/* draw select */
- draw_ipocurves(1);
+ draw_ipocurves(1, 0);
draw_ipohandles(1);
draw_ipovertices(1);
@@ -2709,7 +2737,7 @@
glLoadIdentity();
init_pickselcode(); /* drawipo.c */
- draw_ipocurves(0);
+ draw_ipocurves(0, 0);
/* restore buttons view */
glPopMatrix();
Modified: branches/apricot/source/blender/src/editipo.c
===================================================================
--- branches/apricot/source/blender/src/editipo.c 2008-06-08 20:43:22 UTC (rev 15165)
+++ branches/apricot/source/blender/src/editipo.c 2008-06-08 20:47:34 UTC (rev 15166)
@@ -872,17 +872,83 @@
}
}
+/* APRICOT HACK */
+void free_ipo_ghost(void)
+{
+ EditIpo *ei = G.sipo->editipo_ghost;
+ int a;
+
+ if (G.sipo->editipo_ghost==NULL) {
+ G.sipo->totipo_ghost = 0; /* just incase */
+ return;
+ }
+ for(a=0; a<G.sipo->totipo_ghost; a++, ei++) {
+ if (ei->icu) {
+ free_ipo_curve(ei->icu);
+ }
+ }
+ MEM_freeN(G.sipo->editipo_ghost);
+ G.sipo->totipo_ghost = 0;
+ G.sipo->editipo_ghost = NULL;
+}
+void make_ipo_ghost(void)
+{
+ EditIpo *ei, *ei_ghost;
+ IpoCurve *icu;
+ int a;
+
+ free_ipo_ghost();
+
+ ei = G.sipo->editipo;
+ ei_ghost= G.sipo->editipo_ghost = MEM_dupallocN(G.sipo->editipo);
+ G.sipo->totipo_ghost = G.sipo->totipo;
+
+ for(a=0; a<G.sipo->totipo; a++, ei++, ei_ghost++) {
+ if (ei->icu) {
+ icu = ei_ghost->icu= MEM_callocN(sizeof(IpoCurve), "ipoghostbuf");
+ *ei_ghost->icu= *(ei->icu);
+ icu->bezt= MEM_dupallocN(icu->bezt);
+ icu->driver= MEM_dupallocN(icu->driver);
+ }
+ }
+}
+EditIpo *give_ghost_orig( EditIpo *ei_ghost ) /* ei must be from */
+{
+ EditIpo *ei;
+ IpoCurve *icu;
+ int a;
+
+ ei = G.sipo->editipo;
+ if (!ei || !ei_ghost || !ei_ghost->icu) {
+ return NULL;
+ }
+
+ for(a=0; a<G.sipo->totipo; a++, ei++) {
+ if (ei && ei->icu) {
+ if (ei_ghost->icu->blocktype != ei->icu->blocktype ) {
+ return NULL;
+ }
+ if (ei_ghost->icu->adrcode == ei->icu->adrcode) {
+ return ei;
+ }
+ }
+ }
+
+ return NULL;
+}
+
/* only called in test_editipo() below */
static void make_editipo(void)
{
EditIpo *ei;
Object *ob;
rctf *rf;
- int a;
+ int a, ghost = 1;
- if(G.sipo->editipo)
+ if(G.sipo->editipo) {
+ ghost = 0;
MEM_freeN(G.sipo->editipo);
-
+ }
G.sipo->editipo= NULL;
G.sipo->totipo= 0;
@@ -1382,6 +1448,11 @@
}
}
}
+ if (G.sipo->flag & SIPO_EDITGHOST) {
+ make_ipo_ghost();
+ } else {
+ free_ipo_ghost();
+ }
scrarea_queue_headredraw(curarea);
scrarea_queue_winredraw(curarea);
}
Modified: branches/apricot/source/blender/src/header_ipo.c
===================================================================
--- branches/apricot/source/blender/src/header_ipo.c 2008-06-08 20:43:22 UTC (rev 15165)
+++ branches/apricot/source/blender/src/header_ipo.c 2008-06-08 20:47:34 UTC (rev 15166)
@@ -754,6 +754,14 @@
case 15: /* AutoMerge Keyframes */
G.sipo->flag ^= SIPO_NOTRANSKEYCULL;
break;
+ case 16: /* Ipo Editmode Ghost */
+ G.sipo->flag ^= SIPO_EDITGHOST;
+ if (G.sipo->flag & SIPO_EDITGHOST) {
+ make_ipo_ghost();
+ } else {
+ free_ipo_ghost();
+ }
+ break;
}
}
@@ -778,6 +786,9 @@
uiDefIconTextBut(block, BUTM, 1, (G.sipo->flag & SIPO_NOTRANSKEYCULL)?ICON_CHECKBOX_DEHLT:ICON_CHECKBOX_HLT,
"AutoMerge Keyframes|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
+ uiDefIconTextBut(block, BUTM, 1, (G.sipo->flag & SIPO_EDITGHOST)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT,
+ "Ghost EditMode|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, "");
+
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Out|NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
Modified: branches/apricot/source/blender/src/space.c
===================================================================
--- branches/apricot/source/blender/src/space.c 2008-06-08 20:43:22 UTC (rev 15165)
+++ branches/apricot/source/blender/src/space.c 2008-06-08 20:47:34 UTC (rev 15166)
@@ -148,6 +148,7 @@
#include "BSE_editnla_types.h"
#include "BSE_time.h"
#include "BSE_trans_types.h"
+#include "BSE_editipo_types.h"
#include "BDR_vpaint.h"
#include "BDR_editmball.h"
@@ -6255,6 +6256,19 @@
else if(sl->spacetype==SPACE_IPO) {
SpaceIpo *si= (SpaceIpo*) sl;
if(si->editipo) MEM_freeN(si->editipo);
+
+ if(si->editipo_ghost) {
+ EditIpo *ei = si->editipo_ghost;
+ int a;
+ for(a=0; a<si->totipo_ghost; a++, ei++) {
+ if (ei->icu) {
+ free_ipo_curve(ei->icu);
+ }
+ }
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list