Page MenuHome

path_ghosts_01.patch

path_ghosts_01.patch

Index: source/blender/include/butspace.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/butspace.h,v
retrieving revision 1.94
diff -u -r1.94 butspace.h
--- source/blender/include/butspace.h 30 Nov 2006 00:18:53 -0000 1.94
+++ source/blender/include/butspace.h 1 Dec 2006 06:20:03 -0000
@@ -476,6 +476,8 @@
#define B_ARM_RECALCDATA 2301
#define B_ARM_STRIDE 2302
+#define B_ARM_CALCPATHS 2303
+#define B_ARM_CLEARPATHS 2304
/* *********************** */
#define B_CAMBUTS 2500
Index: source/blender/makesdna/DNA_armature_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_armature_types.h,v
retrieving revision 1.30
diff -u -r1.30 DNA_armature_types.h
--- source/blender/makesdna/DNA_armature_types.h 11 Nov 2006 16:45:16 -0000 1.30
+++ source/blender/makesdna/DNA_armature_types.h 1 Dec 2006 09:16:00 -0000
@@ -78,8 +78,10 @@
int drawtype;
short deformflag, pad1;
short layer, layer_protected; /* for buttons to work, both variables in this order together */
- short ghostep, ghostsize;
- int pad2;
+ short ghostep, ghostsize; /*number of frames to ghosts to show, and step between them */
+ short ghosttype, pathsize; /* ghost drawing options and number of frames between points of path */
+ int ghostsf, ghostef; /* start and end frames of ghost-drawing range */
+ int pathsf, pathef; /* start and end frames of path-calculation range for all bones */
}bArmature;
/* armature->flag */
@@ -110,6 +112,9 @@
#define ARM_DEF_VGROUP 1
#define ARM_DEF_ENVELOPE 2
+/* armature->ghosttype */
+#define ARM_GHOST_CUR 0
+#define ARM_GHOST_RANGE 1
/* bone->flag */
#define BONE_SELECTED 1
Index: source/blender/src/buttons_editing.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_editing.c,v
retrieving revision 1.305
diff -u -r1.305 buttons_editing.c
--- source/blender/src/buttons_editing.c 29 Nov 2006 21:59:19 -0000 1.305
+++ source/blender/src/buttons_editing.c 1 Dec 2006 10:43:18 -0000
@@ -145,6 +145,8 @@
#include "BKE_texture.h"
#include "BKE_utildefines.h"
+#include "BIF_poseobject.h"
+
#include "BDR_drawobject.h"
#include "BDR_editcurve.h"
#include "BDR_editface.h"
@@ -2985,6 +2987,14 @@
allqueue(REDRAWBUTSEDIT, 0);
}
break;
+ case B_ARM_CALCPATHS:
+ if (ob && ob->pose)
+ pose_calculate_path(ob);
+ break;
+ case B_ARM_CLEARPATHS:
+ if (ob && ob->pose)
+ pose_clear_paths(ob);
+ break;
}
}
@@ -3186,8 +3196,6 @@
uiDefButBitI(block, TOG, ARM_DRAWNAMES, REDRAWVIEW3D, "Draw Names", 110,80,100,20, &arm->flag, 0, 0, 0, 0, "Draw bone names");
uiDefButBitI(block, TOGN, ARM_NO_CUSTOM, REDRAWVIEW3D, "Draw Shapes", 210,80,100,20, &arm->flag, 0, 0, 0, 0, "Draw custom bone shapes");
- uiDefButS(block, NUM, REDRAWVIEW3D, "Ghost: ", 10,60,150,20, &arm->ghostep, 0.0f, 30.0f, 0, 0, "Draw Ghosts around current frame, for current Action");
- uiDefButS(block, NUM, REDRAWVIEW3D, "Step: ", 160,60,150,20, &arm->ghostsize, 1.0f, 20.0f, 0, 0, "How many frames between Ghost instances");
uiBlockEndAlign(block);
uiDefBut(block, LABEL, 0, "Deform Options", 10,40,150,20, 0, 0, 0, 0, 0, "");
@@ -3196,7 +3204,55 @@
uiDefButBitS(block, TOG, ARM_DEF_ENVELOPE, B_ARM_RECALCDATA, "Envelopes", 160,20,150,20, &arm->deformflag, 0, 0, 0, 0, "Enable Bone Envelopes defining deform (not for Modifiers)");
uiDefButBitI(block, TOG, ARM_RESTPOS, B_ARM_RECALCDATA,"Rest Position", 10,0,150,20, &arm->flag, 0, 0, 0, 0, "Show armature rest position, no posing possible");
uiDefButBitI(block, TOG, ARM_DELAYDEFORM, REDRAWVIEW3D, "Delay Deform", 160,0,150,20, &arm->flag, 0, 0, 0, 0, "Don't deform children when manipulating bones in pose mode");
+ uiBlockEndAlign(block);
+}
+
+static void editing_panel_armature_visuals(Object *ob, bArmature *arm)
+{
+ uiBlock *block;
+
+ block= uiNewBlock(&curarea->uiblocks, "editing_panel_armature_visuals", UI_EMBOSS, UI_HELV, curarea->win);
+ uiNewPanelTabbed("Armature Visualisations", "Editing");
+ if(uiNewPanel(curarea, block, "Armature Visualisations", "Editing", 320, 0, 318, 204)==0) return;
+
+ /* Ghost Drawing Options */
+ uiDefBut(block, LABEL, 0, "Ghost Options", 10,180,150,20, 0, 0, 0, 0, 0, "");
+
+ uiBlockBeginAlign(block);
+ uiDefButS(block, MENU, REDRAWVIEW3D, "Ghosts %t|Around Current Frame %x0|In Range %x1",
+ 10, 160, 150, 20, &arm->ghosttype, 0, 0, 0, 0, "Choose range of Ghosts to draw for current Action");
+
+ uiDefButS(block, NUM, REDRAWVIEW3D, "GStep: ", 160,160,150,20, &arm->ghostsize, 1.0f, 20.0f, 0, 0, "How many frames between Ghost instances");
+ uiBlockEndAlign(block);
+
+ uiBlockBeginAlign(block);
+ if (arm->ghosttype == ARM_GHOST_CUR) {
+ /* range is around current frame */
+ uiDefButS(block, NUM, REDRAWVIEW3D, "Ghost: ", 10,130,150,20, &arm->ghostep, 0.0f, 30.0f, 0, 0, "Draw Ghosts around current frame, for current Action");
+ }
+ else if (arm->ghosttype == ARM_GHOST_RANGE) {
+ /* range is subset of current action (if any) */
+ if ((arm->ghostsf == arm->ghostef) && (arm->ghostsf == 0.0f))
+ arm->ghostsf = arm->ghostef = CFRA;
+
+ uiDefButI(block, NUM,REDRAWVIEW3D,"GSta:",10,130,150,20, &arm->ghostsf,1.0,MAXFRAMEF, 0, 0, "The start frame for Ghost display range");
+ uiDefButI(block, NUM,REDRAWVIEW3D,"GEnd:",160,130,150,20, &arm->ghostef,1.0,MAXFRAMEF, 0, 0, "The end frame for Ghost display range");
+ }
+ uiBlockEndAlign(block);
+ /* Bone Path Drawing Options */
+ uiDefBut(block, LABEL, 0, "Bone Paths", 10,80,150,20, 0, 0, 0, 0, 0, "");
+
+ uiBlockBeginAlign(block);
+ uiDefButS(block, NUM, REDRAWVIEW3D, "PStep:",10,60,140,20, &arm->pathsize,1,100, 0, 0, "Frames between highlighted points on bone path");
+ uiDefButI(block, NUM,REDRAWVIEW3D,"PSta:",10,40,140,20, &arm->pathsf,1.0,MAXFRAMEF, 0, 0, "The start frame for Bone Path display range");
+ uiDefButI(block, NUM,REDRAWVIEW3D,"PEnd:",10,20,140,20, &arm->pathef,1.0,MAXFRAMEF, 0, 0, "The end frame for Bone Path display range");
+ uiBlockEndAlign(block);
+
+ uiBlockBeginAlign(block);
+ uiDefBut(block, BUT, B_ARM_CALCPATHS, "(Re)calc Paths", 160,50,150,20, 0, 0, 0, 0, 0, "(Re)calculates the paths of the selected bones");
+ uiDefBut(block, BUT, B_ARM_CLEARPATHS, "Clear All Paths", 160,30,150,20, 0, 0, 0, 0, 0, "Clears all bone paths");
+ uiBlockEndAlign(block);
}
/* autocomplete callback for editbones */
@@ -4920,6 +4976,7 @@
editing_panel_armature_bones(ob, arm);
}
else if(ob->flag & OB_POSEMODE) {
+ editing_panel_armature_visuals(ob, arm);
editing_panel_pose_bones(ob, arm);
object_panel_constraint("Editing");
}
Index: source/blender/src/drawarmature.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/drawarmature.c,v
retrieving revision 1.38
diff -u -r1.38 drawarmature.c
--- source/blender/src/drawarmature.c 11 Nov 2006 18:17:53 -0000 1.38
+++ source/blender/src/drawarmature.c 1 Dec 2006 10:53:49 -0000
@@ -1733,34 +1733,42 @@
bPoseChannel *pchan;
float *fp;
int a;
+ int stepsize, sfra;
if(G.vd->zbuf) glDisable(GL_DEPTH_TEST);
glPushMatrix();
glLoadMatrixf(G.vd->viewmat);
+ stepsize = arm->pathsize;
+ sfra = arm->pathsf;
+
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->bone->layer & arm->layer) {
if(pchan->path) {
-
+ /* draw curve-line of path */
BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.7);
glBegin(GL_LINE_STRIP);
for(a=0, fp= pchan->path; a<pchan->pathlen; a++, fp+=3)
glVertex3fv(fp);
glEnd();
- glPointSize(1.0);
- BIF_ThemeColor(TH_WIRE);
- glBegin(GL_POINTS);
- for(a=0, fp= pchan->path; a<pchan->pathlen; a++, fp+=3)
- glVertex3fv(fp);
- glEnd();
-
+ /* draw points */
BIF_ThemeColor(TH_TEXT_HI);
+ glPointSize(1.0);
glBegin(GL_POINTS);
- for(a=0, fp= pchan->path; a<pchan->pathlen; a+=10, fp+=30)
+ for(a=0, fp= pchan->path; a<pchan->pathlen; a+=stepsize, fp+=(stepsize*3))
glVertex3fv(fp);
glEnd();
+
+ /* draw frame numbers */
+ for(a=0, fp= pchan->path; a<pchan->pathlen; a+=stepsize, fp+=(stepsize*3)) {
+ char str[32];
+
+ glRasterPos3fv(fp);
+ sprintf(str, " %d\n", (a+sfra));
+ BMF_DrawString(G.font, str);
+ }
}
}
}
@@ -1769,6 +1777,66 @@
glPopMatrix();
}
+/* draw ghosts that occur within a frame range
+ * note: object should be in posemode */
+static void draw_ghost_poses_range(Base *base)
+{
+ Object *ob= base->object;
+ bArmature *arm= ob->data;
+ bPose *posen, *poseo;
+ float start, end, stepsize, range, colfac;
+ int cfrao, flago, ipoflago;
+
+ start = arm->ghostsf;
+ end = arm->ghostef;
+ if (end<=start)
+ return;
+
+ stepsize= (float)(arm->ghostsize);
+ range= (float)(end - start);
+
+ /* store values */
+ ob->flag &= ~OB_POSEMODE;
+ cfrao= CFRA;
+ flago= arm->flag;
+ arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES);
+ ipoflago= ob->ipoflag;
+ ob->ipoflag |= OB_DISABLE_PATH;
+
+ /* copy the pose */
+ poseo= ob->pose;
+ copy_pose(&posen, ob->pose, 1);
+ ob->pose= posen;
+ armature_rebuild_pose(ob, ob->data); /* child pointers for IK */
+
+ glEnable(GL_BLEND);
+ if(G.vd->zbuf) glDisable(GL_DEPTH_TEST);
+
+ /* draw from first frame of range to last */
+ for(CFRA= start; CFRA<end; CFRA+=stepsize) {
+ colfac = (end-CFRA)/range;
+ BIF_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0f*sqrt(colfac)));
+
+ do_all_pose_actions(ob);
+ where_is_pose(ob);
+ draw_pose_channels(base, OB_WIRE);
+ }
+ glDisable(GL_BLEND);
+ if(G.vd->zbuf) glEnable(GL_DEPTH_TEST);
+
+ free_pose_channels(posen);
+ MEM_freeN(posen);
+
+ /* restore */
+ CFRA= cfrao;
+ ob->pose= poseo;
+ arm->flag= flago;
+ armature_rebuild_pose(ob, ob->data);
+ ob->flag |= OB_POSEMODE;
+ ob->ipoflag= ipoflago;
+
+}
+
/* object is supposed to be armature in posemode */
static void draw_ghost_poses(Base *base)
{
@@ -1904,9 +1972,12 @@
arm->flag |= ARM_POSEMODE;
}
else if(ob->flag & OB_POSEMODE) {
-
- if(arm->ghostep) {
- draw_ghost_poses(base);
+ if (arm->ghosttype == ARM_GHOST_RANGE){
+ draw_ghost_poses_range(base);
+ }
+ else {
+ if (arm->ghostep)
+ draw_ghost_poses(base);
}
if(ob==OBACT)
Index: source/blender/src/poseobject.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/poseobject.c,v
retrieving revision 1.50
diff -u -r1.50 poseobject.c
--- source/blender/src/poseobject.c 30 Nov 2006 15:54:21 -0000 1.50
+++ source/blender/src/poseobject.c 1 Dec 2006 10:08:52 -0000
@@ -229,12 +229,17 @@
Base *base;
float *fp;
int cfra;
+ int sfra, efra;
if(ob==NULL || ob->pose==NULL)
return;
arm= ob->data;
- if(EFRA<=SFRA) return;
+ /* set frame values */
+ cfra= CFRA;
+ sfra = arm->pathsf;
+ efra = arm->pathef;
+ if (efra<=sfra) return;
DAG_object_update_flags(G.scene, ob, screen_view3d_layers());
@@ -242,7 +247,7 @@
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->bone && (pchan->bone->flag & BONE_SELECTED)) {
if(arm->layer & pchan->bone->layer) {
- pchan->pathlen= EFRA-SFRA+1;
+ pchan->pathlen= efra-sfra+1;
if(pchan->path)
MEM_freeN(pchan->path);
pchan->path= MEM_callocN(3*pchan->pathlen*sizeof(float), "pchan path");
@@ -250,8 +255,7 @@
}
}
- cfra= CFRA;
- for(CFRA=SFRA; CFRA<=EFRA; CFRA++) {
+ for(CFRA=sfra; CFRA<=efra; CFRA++) {
/* do all updates */
for(base= FIRSTBASE; base; base= base->next) {
@@ -266,7 +270,7 @@
if(pchan->bone && (pchan->bone->flag & BONE_SELECTED)) {
if(arm->layer & pchan->bone->layer) {
if(pchan->path) {
- fp= pchan->path+3*(CFRA-SFRA);
+ fp= pchan->path+3*(CFRA-sfra);
VECCOPY(fp, pchan->pose_tail);
Mat4MulVecfl(ob->obmat, fp);
}

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
04/bb/d53cd937fe92d95014f70b33c1a1

Event Timeline