diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-01-19 19:32:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-01-19 19:32:29 +0300 |
commit | d450dbec9177f2e691fddbefdab20adda18c7ae3 (patch) | |
tree | ef57d87a2714354da103960926c004edc1874942 | |
parent | 7b6c88473c02d97485970390086395b515be653e (diff) |
add the option to add the parents time offset value.
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/group.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 25 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 3 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Effect.c | 4 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 22 | ||||
-rw-r--r-- | source/blender/src/drawaction.c | 4 | ||||
-rw-r--r-- | source/blender/src/drawipo.c | 4 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 4 | ||||
-rw-r--r-- | source/blender/src/editipo.c | 24 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 2 |
12 files changed, 59 insertions, 41 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 6e363515f41..b9f31d5590b 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -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 diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index e09f6207642..6e33805fbeb 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -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) */ diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 3a64f8c8c34..b29cf63ab0b 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -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) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3ac4a572b96..70be6d2c79b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -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; + } +}
\ No newline at end of file diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 565b2cfd678..f3a0dfdfdc7 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -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 diff --git a/source/blender/python/api2_2x/Effect.c b/source/blender/python/api2_2x/Effect.c index 1dcc2279ee2..43c86ebe634 100644 --- a/source/blender/python/api2_2x/Effect.c +++ b/source/blender/python/api2_2x/Effect.c @@ -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; diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 0ff1e3dd40d..f659611c2be 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -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"); + uiBlockEndAlign(block); + 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"); + 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); - 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"); + 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, ""); } diff --git a/source/blender/src/drawaction.c b/source/blender/src/drawaction.c index 2b280864f1c..42b0b0bda3b 100644 --- a/source/blender/src/drawaction.c +++ b/source/blender/src/drawaction.c @@ -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); diff --git a/source/blender/src/drawipo.c b/source/blender/src/drawipo.c index 07442a541a5..d5040bf0a51 100644 --- a/source/blender/src/drawipo.c +++ b/source/blender/src/drawipo.c @@ -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); diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 3e154298517..1d30815f29a 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -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); diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index f6ef0eaadb2..22eea819077 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -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); diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index bbdcfc428dd..90b0e8c048e 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -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]; |