add the option to add the parents time offset value.

This commit is contained in:
2008-01-19 16:32:29 +00:00
parent 7b6c88473c
commit d450dbec91
12 changed files with 60 additions and 42 deletions

View File

@@ -110,6 +110,8 @@ void solve_tracking (struct Object *ob, float targetmat[][4]);
void object_handle_update(struct Object *ob);
float give_timeoffset(struct Object *ob);
#ifdef __cplusplus
}
#endif

View File

@@ -1559,7 +1559,7 @@ static pMatrixCache *cache_object_matrices(Object *ob, int start, int end)
framelenold= G.scene->r.framelen;
G.scene->r.framelen= 1.0f;
cfrao= G.scene->r.cfra;
sfo= ob->sf;
sfo= ob->sf; /* warning, dont use sfo, value should be from give_timeoffset if used for anything */
ob->sf= 0.0f;
/* clear storage, copy recalc tag (bad loop) */

View File

@@ -241,12 +241,12 @@ void group_handle_recalc_and_update(Object *parent, Group *group)
GroupObject *go;
/* if animated group... */
if(parent->sf != 0.0f || parent->nlastrips.first) {
if(give_timeoffset(parent) != 0.0f || parent->nlastrips.first) {
int cfrao;
/* switch to local time */
cfrao= G.scene->r.cfra;
G.scene->r.cfra -= (int)parent->sf;
G.scene->r.cfra -= (int)give_timeoffset(parent);
/* we need a DAG per group... */
for(go= group->gobject.first; go; go= go->next) {

View File

@@ -1367,7 +1367,7 @@ float bsystem_time(Object *ob, float cfra, float ofs)
/* ofset frames */
if ((ob->ipoflag & OB_OFFS_PARENT) && (ob->partype & PARSLOW)==0)
cfra-= ob->sf;
cfra-= give_timeoffset(ob);
}
cfra-= ofs;
@@ -1438,7 +1438,7 @@ static void ob_parcurve(Object *ob, Object *par, float mat[][4])
{
Curve *cu;
float q[4], vec[4], dir[3], *quat, x1, ctime;
float timeoffs= 0.0;
float timeoffs, sf_orig = 0.0;
Mat4One(mat);
@@ -1449,7 +1449,8 @@ static void ob_parcurve(Object *ob, Object *par, float mat[][4])
/* exception, timeoffset is regarded as distance offset */
if(cu->flag & CU_OFFS_PATHDIST) {
SWAP(float, timeoffs, ob->sf);
timeoffs = give_timeoffset(ob);
SWAP(float, sf_orig, ob->sf);
}
/* catch exceptions: feature for nla stride editing */
@@ -1466,7 +1467,7 @@ static void ob_parcurve(Object *ob, Object *par, float mat[][4])
}
}
else {
ctime= G.scene->r.cfra - ob->sf;
ctime= G.scene->r.cfra - give_timeoffset(ob);
ctime /= cu->pathlen;
CLAMP(ctime, 0.0, 1.0);
@@ -1477,7 +1478,7 @@ static void ob_parcurve(Object *ob, Object *par, float mat[][4])
ctime += timeoffs/cu->path->totdist;
/* restore */
SWAP(float, timeoffs, ob->sf);
SWAP(float, sf_orig, ob->sf);
}
@@ -1735,7 +1736,7 @@ void where_is_object_time(Object *ob, float ctime)
if(ob->parent) {
Object *par= ob->parent;
if(ob->ipoflag & OB_OFFS_PARENT) ctime-= ob->sf;
if(ob->ipoflag & OB_OFFS_PARENT) ctime-= give_timeoffset(ob);
/* hurms, code below conflicts with depgraph... (ton) */
/* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */
@@ -1759,7 +1760,7 @@ void where_is_object_time(Object *ob, float ctime)
if(ob->partype & PARSLOW) {
// include framerate
fac1= (1.0f/(1.0f+ fabs(ob->sf)));
fac1= (1.0f/(1.0f+ fabs(give_timeoffset(ob))));
if(fac1>=1.0) return;
fac2= 1.0f-fac1;
@@ -1942,7 +1943,7 @@ for a lamp that is the child of another object */
if(ob->partype & PARSLOW) {
fac1= (float)(1.0/(1.0+ fabs(ob->sf)));
fac1= (float)(1.0/(1.0+ fabs(give_timeoffset(ob))));
fac2= 1.0f-fac1;
fp1= ob->obmat[0];
fp2= slowmat[0];
@@ -2247,3 +2248,11 @@ void object_handle_update(Object *ob)
// printf("set proxy pointer for later group stuff %s\n", ob->id.name);
}
}
float give_timeoffset(Object *ob) {
if ((ob->ipoflag & OB_OFFS_PARENTADD) && ob->parent) {
return ob->sf + give_timeoffset(ob->parent);
} else {
return ob->sf;
}
}

View File

@@ -297,6 +297,9 @@ extern Object workob;
/* for stride edit */
#define OB_DISABLE_PATH 1024
#define OB_OFFS_PARENTADD 2048
/* (short) trackflag / upflag */
#define OB_POSX 0
#define OB_POSY 1

View File

@@ -1,5 +1,5 @@
/*
* $Id: Effect.c 11485 2007-08-05 09:21:29Z aligorith $
* $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -1330,7 +1330,7 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
/* if object is in motion */
if( ob->ipoflag & OB_OFFS_PARTICLE )
p_time= ob->sf;
p_time= give_timeoffset(ob);
else
p_time= 0.0;

View File

@@ -2494,21 +2494,25 @@ static void object_panel_anim(Object *ob)
uiDefButI(block, NUM, REDRAWVIEW3D, "DupOn:", 170,85,146,19, &ob->dupon, 1.0, 1500.0, 0, 0, "Specify the number of frames to use between DupOff frames");
uiDefButI(block, NUM, REDRAWVIEW3D, "DupEnd", 24,65,140,19, &ob->dupend, 1.0, 32767, 0, 0, "Specify endframe for Dupliframes");
uiDefButI(block, NUM, REDRAWVIEW3D, "DupOff", 171,65,145,19, &ob->dupoff, 0.0, 1500.0, 0, 0, "Specify recurring frames to exclude from the Dupliframes");
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, OB_OFFS_OB, REDRAWALL, "Offs Ob", 24,35,56,20, &ob->ipoflag, 0, 0, 0, 0, "Not functional at the moment!");
uiDefButBitS(block, TOG, OB_OFFS_PARENT, REDRAWALL, "Offs Par", 82,35,56,20 , &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the parent");
uiDefButBitS(block, TOG, OB_OFFS_PARTICLE, REDRAWALL, "Offs Particle", 140,35,103,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect");
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
uiDefButF(block, NUM, REDRAWALL, "TimeOffset:", 24,10,115,20, &ob->sf, -MAXFRAMEF, MAXFRAMEF, 100, 0, "Animation offset in frames for ipo's and dupligroup instances");
uiDefBut(block, BUT, B_AUTOTIMEOFS, "Auto", 139,10,34,20, 0, 0, 0, 0, 0, "Assign selected objects a timeoffset within a range, starting from the active object");
uiDefBut(block, BUT, B_OFSTIMEOFS, "Ofs", 173,10,34,20, 0, 0, 0, 0, 0, "Offset selected objects timeoffset");
uiDefBut(block, BUT, B_RANDTIMEOFS, "Rand", 207,10,34,20, 0, 0, 0, 0, 0, "Randomize selected objects timeoffset");
uiDefBut(block, BUT, B_PRINTSPEED, "PrSpeed", 250,10,65,20, 0, 0, 0, 0, 0, "Print objectspeed");
uiDefButF(block, NUM, REDRAWALL, "TimeOffset:", 24,35,115,20, &ob->sf, -MAXFRAMEF, MAXFRAMEF, 100, 0, "Animation offset in frames for ipo's and dupligroup instances");
uiDefBut(block, BUT, B_AUTOTIMEOFS, "Auto", 139,35,34,20, 0, 0, 0, 0, 0, "Assign selected objects a timeoffset within a range, starting from the active object");
uiDefBut(block, BUT, B_OFSTIMEOFS, "Ofs", 173,35,34,20, 0, 0, 0, 0, 0, "Offset selected objects timeoffset");
uiDefBut(block, BUT, B_RANDTIMEOFS, "Rand", 207,35,34,20, 0, 0, 0, 0, 0, "Randomize selected objects timeoffset");
uiDefBut(block, BUT, B_PRINTSPEED, "PrSpeed", 250,35,65,20, 0, 0, 0, 0, 0, "Print objectspeed");
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, OB_OFFS_OB, REDRAWALL, "OfsEdit", 24,10,56,20, &ob->ipoflag, 0, 0, 0, 0, "Use timeoffset when inserting keys and display timeoffset for ipo and action views");
uiDefButBitS(block, TOG, OB_OFFS_PARENT, REDRAWALL, "OfsParent", 82,10,56,20 , &ob->ipoflag, 0, 0, 0, 0, "Apply the timeoffset to this objects parent relationship");
uiDefButBitS(block, TOG, OB_OFFS_PARTICLE, REDRAWALL, "OfsParticle", 140,10,56,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect");
uiDefButBitS(block, TOG, OB_OFFS_PARENTADD, REDRAWALL, "AddParent", 196,10,56,20, &ob->ipoflag, 0, 0, 0, 0, "Add the parents timeoffset value");
uiBlockEndAlign(block);
sprintf(str, "%.4f", prspeed);
uiDefBut(block, LABEL, 0, str, 247,35,63,31, NULL, 1.0, 0, 0, 0, "");
uiDefBut(block, LABEL, 0, str, 260,10,63,31, NULL, 1.0, 0, 0, 0, "");
}

View File

@@ -374,8 +374,8 @@ void draw_cfra_action (void)
/* Draw dark green line if slow-parenting/time-offset is enabled */
ob= (G.scene->basact) ? (G.scene->basact->object) : 0;
if ((ob) && (ob->sf!=0.0) && (ob->ipoflag & OB_OFFS_OB)) {
vec[0]-= ob->sf;
if ((ob) && (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0)) {
vec[0]-= give_timeoffset(ob); /* could avoid calling twice */
BIF_ThemeColorShade(TH_CFRAME, -30);

View File

@@ -1571,8 +1571,8 @@ static void draw_cfra(SpaceIpo *sipo)
if(sipo->blocktype==ID_OB) {
ob= (G.scene->basact) ? (G.scene->basact->object) : 0;
if (ob && (ob->sf!=0.0) && (ob->ipoflag & OB_OFFS_OB) ) {
vec[0]-= ob->sf;
if (ob && (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0)) {
vec[0]-= give_timeoffset(ob);
BIF_ThemeColorShade(TH_HILITE, -30);

View File

@@ -2857,7 +2857,7 @@ static void draw_particle_system(Base *base, PartEff *paf)
mymultmatrix(mat);
}
if(ob->ipoflag & OB_OFFS_PARTICLE) ptime= ob->sf;
if(ob->ipoflag & OB_OFFS_PARTICLE) ptime= give_timeoffset(ob);
else ptime= 0.0;
ctime= bsystem_time(ob, (float)(G.scene->r.cfra), ptime);
@@ -5248,7 +5248,7 @@ void draw_object(Base *base, int flag)
for (ct= targets.first; ct; ct= ct->next) {
/* calculate target's matrix */
if (cti->get_target_matrix)
cti->get_target_matrix(curcon, cob, ct, bsystem_time(ob, (float)(G.scene->r.cfra), ob->sf));
cti->get_target_matrix(curcon, cob, ct, bsystem_time(ob, (float)(G.scene->r.cfra), give_timeoffset(ob)));
else
Mat4One(ct->matrix);

View File

@@ -2335,9 +2335,9 @@ static void insertkey_nonrecurs(ID *id, int blocktype, char *actname, char *cons
if( GS(id->name)==ID_OB ) {
ob= (Object *)id;
if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
if((ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0) ) {
/* actually frametofloat calc again! */
cfra-= ob->sf*G.scene->r.framelen;
cfra-= give_timeoffset(ob)*G.scene->r.framelen;
}
}
@@ -2556,9 +2556,9 @@ void insertkey(ID *id, int blocktype, char *actname, char *constname, int adrcod
if( GS(id->name)==ID_OB ) {
ob= (Object *)id;
if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
if((ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0) ) {
/* actually frametofloat calc again! */
cfra-= ob->sf*G.scene->r.framelen;
cfra-= give_timeoffset(ob)*G.scene->r.framelen;
}
}
@@ -2598,9 +2598,9 @@ void insertkey_smarter(ID *id, int blocktype, char *actname, char *constname, in
if( GS(id->name)==ID_OB ) {
ob= (Object *)id;
if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
if((ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0) ) {
/* actually frametofloat calc again! */
cfra-= ob->sf*G.scene->r.framelen;
cfra-= give_timeoffset(ob)*G.scene->r.framelen;
}
}
@@ -2649,9 +2649,9 @@ void insertfloatkey(ID *id, int blocktype, char *actname, char *constname, int a
if( GS(id->name)==ID_OB ) {
ob= (Object *)id;
if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
if((ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0) ) {
/* actually frametofloat calc again! */
cfra-= ob->sf*G.scene->r.framelen;
cfra-= give_timeoffset(ob)*G.scene->r.framelen;
}
}
@@ -2731,8 +2731,8 @@ void insertkey_editipo(void)
id= G.sipo->from;
if(id && GS(id->name)==ID_OB ) {
Object *ob= (Object *)id;
if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
cfra-= ob->sf*G.scene->r.framelen;
if((ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0) ) {
cfra-= give_timeoffset(ob)*G.scene->r.framelen;
}
}
else if(id && GS(id->name)==ID_SEQ) {
@@ -5769,8 +5769,8 @@ void move_to_frame(void)
id= G.sipo->from;
if(id && GS(id->name)==ID_OB ) {
Object *ob= (Object *)id;
if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
cfra+= ob->sf/G.scene->r.framelen;
if((ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0) ) {
cfra+= give_timeoffset(ob)/G.scene->r.framelen;
}
}
CFRA= (int)floor(cfra+0.5);

View File

@@ -1430,7 +1430,7 @@ void make_parent(void)
add_constraint_to_object(con, base->object);
get_constraint_target_matrix(con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, G.scene->r.cfra - base->object->sf);
get_constraint_target_matrix(con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, G.scene->r.cfra - give_timeoffset(base->object));
VecSubf(vec, base->object->obmat[3], cmat[3]);
base->object->loc[0] = vec[0];