Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2007-08-05 13:21:29 +0400
committerJoshua Leung <aligorith@gmail.com>2007-08-05 13:21:29 +0400
commitc4114780d43f2cc973eaad193c61127e9ee54b28 (patch)
treedbc551eee68dde0e0104deef4d028979dc1efca6
parent7dfbe481e26f1b067315ee067f772a9195faf7f2 (diff)
Little code cleanup.
bsystem_time was being called with an extra variable, which was useless. Most of the places that called it, were passing NULL for that variable anyway. I've also cleaned up that function a bit, but the underlying problems with that part of the code still exist (EVIL GLOBALS that are exported for frame_to_float), for mblur and fields rendering features. That remains for another time.
-rw-r--r--source/blender/blenkernel/BKE_object.h2
-rw-r--r--source/blender/blenkernel/intern/action.c12
-rw-r--r--source/blender/blenkernel/intern/anim.c2
-rw-r--r--source/blender/blenkernel/intern/armature.c2
-rw-r--r--source/blender/blenkernel/intern/constraint.c2
-rw-r--r--source/blender/blenkernel/intern/ipo.c2
-rw-r--r--source/blender/blenkernel/intern/key.c14
-rw-r--r--source/blender/blenkernel/intern/modifier.c4
-rw-r--r--source/blender/blenkernel/intern/object.c21
-rw-r--r--source/blender/blenkernel/intern/softbody.c6
-rw-r--r--source/blender/python/api2_2x/Effect.c2
-rw-r--r--source/blender/render/intern/source/convertblender.c4
-rw-r--r--source/blender/src/drawobject.c4
-rw-r--r--source/blender/src/editconstraint.c30
-rw-r--r--source/blender/src/editkey.c2
15 files changed, 71 insertions, 38 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index e38446e0d46..9022e07ebac 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -81,7 +81,7 @@ void set_mblur_offs(float blur);
void set_field_offs(float field);
void disable_speed_curve(int val);
-float bsystem_time(struct Object *ob, struct Object *par, float cfra, float ofs);
+float bsystem_time(struct Object *ob, float cfra, float ofs);
void object_to_mat3(struct Object *ob, float mat[][3]);
void object_to_mat4(struct Object *ob, float mat[][4]);
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 0ab4c70cdae..cbe056fa1b1 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1111,7 +1111,7 @@ static void do_nla(Object *ob, int blocktype)
if(cu->path) {
/* Find the position on the path */
- ctime= bsystem_time(ob, parent, scene_cfra, 0.0);
+ ctime= bsystem_time(ob, scene_cfra, 0.0);
if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
/* correct for actions not starting on zero */
@@ -1133,7 +1133,7 @@ static void do_nla(Object *ob, int blocktype)
}
frametime = (striptime * actlength) + strip->actstart;
- frametime= bsystem_time(ob, 0, frametime, 0.0);
+ frametime= bsystem_time(ob, frametime, 0.0);
if(blocktype==ID_AR) {
extract_pose_from_action (tpose, strip->act, frametime);
@@ -1184,7 +1184,7 @@ static void do_nla(Object *ob, int blocktype)
frametime = actlength * (strip->repeat-(int)strip->repeat);
if(frametime<=0.000001f) frametime= actlength; /* rounding errors... */
- frametime= bsystem_time(ob, 0, frametime+strip->actstart, 0.0);
+ frametime= bsystem_time(ob, frametime+strip->actstart, 0.0);
if(blocktype==ID_AR)
extract_pose_from_action (tpose, strip->act, frametime);
@@ -1267,7 +1267,7 @@ void do_all_pose_actions(Object *ob)
cframe= get_action_frame(ob, cframe);
- extract_pose_from_action (ob->pose, ob->action, bsystem_time(ob, 0, cframe, 0.0));
+ extract_pose_from_action (ob->pose, ob->action, bsystem_time(ob, cframe, 0.0));
}
else if(ob->nlastrips.first) {
do_nla(ob, ID_AR);
@@ -1288,9 +1288,9 @@ void do_all_object_actions(Object *ob)
cframe= get_action_frame(ob, cframe);
- extract_ipochannels_from_action(&tchanbase, &ob->id, ob->action, "Object", bsystem_time(ob, 0, cframe, 0.0));
+ extract_ipochannels_from_action(&tchanbase, &ob->id, ob->action, "Object", bsystem_time(ob, cframe, 0.0));
if(key)
- extract_ipochannels_from_action(&tchanbase, &key->id, ob->action, "Shape", bsystem_time(ob, 0, cframe, 0.0));
+ extract_ipochannels_from_action(&tchanbase, &key->id, ob->action, "Shape", bsystem_time(ob, cframe, 0.0));
if(tchanbase.first) {
execute_ipochannels(&tchanbase);
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 01e945855b6..32ea2b3ed2c 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -582,7 +582,7 @@ static void particle_duplilist(ListBase *lb, Scene *sce, Object *par, PartEff *p
if(pa==NULL) return;
}
- ctime= bsystem_time(par, 0, (float)G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(par, (float)G.scene->r.cfra, 0.0);
lay= G.scene->lay;
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index f75174e47a2..31a25a984c4 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1922,7 +1922,7 @@ void where_is_pose (Object *ob)
Bone *bone;
bPoseChannel *pchan;
float imat[4][4];
- float ctime= bsystem_time(ob, NULL, (float)G.scene->r.cfra, 0.0); /* not accurate... */
+ float ctime= bsystem_time(ob, (float)G.scene->r.cfra, 0.0); /* not accurate... */
arm = get_armature(ob);
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 2981d158a24..6cbe454b79c 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1454,7 +1454,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void *own
if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
makeDispListCurveTypes(data->tar, 0);
if (cu->path && cu->path->data) {
- curvetime= bsystem_time(data->tar, data->tar->parent, (float)ctime, 0.0) - data->offset;
+ curvetime= bsystem_time(data->tar, (float)ctime, 0.0) - data->offset;
if (calc_ipo_spec(cu->ipo, CU_SPEED, &curvetime)==0) {
curvetime /= cu->pathlen;
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index bf02c49b23c..16abf78952d 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -2000,7 +2000,7 @@ void do_ob_ipo(Object *ob)
/* do not set ob->ctime here: for example when parent in invisible layer */
- ctime= bsystem_time(ob, 0, (float) G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(ob, (float) G.scene->r.cfra, 0.0);
calc_ipo(ob->ipo, ctime);
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 345bc522449..0b5650ece44 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1025,7 +1025,7 @@ static int do_mesh_key(Object *ob, Mesh *me)
for(a=0; a<me->totvert; a+=step, cfra+= delta) {
- ctime= bsystem_time(0, 0, cfra, 0.0);
+ ctime= bsystem_time(0, cfra, 0.0);
if(calc_ipo_spec(me->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
@@ -1060,7 +1060,7 @@ static int do_mesh_key(Object *ob, Mesh *me)
}
}
else {
- ctime= bsystem_time(ob, 0, G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(ob, G.scene->r.cfra, 0.0);
if(calc_ipo_spec(me->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
@@ -1180,7 +1180,7 @@ static int do_curve_key(Curve *cu)
for(a=0; a<tot; a+=step, cfra+= delta) {
- ctime= bsystem_time(0, 0, cfra, 0.0);
+ ctime= bsystem_time(0, cfra, 0.0);
if(calc_ipo_spec(cu->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
@@ -1202,7 +1202,7 @@ static int do_curve_key(Curve *cu)
}
else {
- ctime= bsystem_time(NULL, 0, (float)G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(NULL, (float)G.scene->r.cfra, 0.0);
if(cu->key->type==KEY_RELATIVE) {
do_rel_cu_key(cu, ctime);
@@ -1244,7 +1244,7 @@ static int do_latt_key(Object *ob, Lattice *lt)
for(a=0; a<tot; a++, cfra+= delta) {
- ctime= bsystem_time(0, 0, cfra, 0.0);
+ ctime= bsystem_time(0, cfra, 0.0);
if(calc_ipo_spec(lt->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
@@ -1261,7 +1261,7 @@ static int do_latt_key(Object *ob, Lattice *lt)
}
}
else {
- ctime= bsystem_time(NULL, 0, (float)G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(NULL, (float)G.scene->r.cfra, 0.0);
if(lt->key->type==KEY_RELATIVE) {
KeyBlock *kb;
@@ -1342,7 +1342,7 @@ int do_ob_key(Object *ob)
if(ob->ipoflag & OB_ACTION_KEY)
do_all_object_actions(ob);
else {
- calc_ipo(key->ipo, bsystem_time(ob, 0, G.scene->r.cfra, 0.0));
+ calc_ipo(key->ipo, bsystem_time(ob, G.scene->r.cfra, 0.0));
execute_ipo((ID *)key, key->ipo);
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index d6fa8d1d3d6..ad1c432c5a0 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -383,7 +383,7 @@ static DerivedMesh *buildModifier_applyModifier(ModifierData *md, Object *ob,
for(i = 0; i < maxFaces; ++i) faceMap[i] = i;
if (ob) {
- frac = bsystem_time(ob, 0, (float)G.scene->r.cfra,
+ frac = bsystem_time(ob, (float)G.scene->r.cfra,
bmd->start - 1.0f) / bmd->length;
} else {
frac = G.scene->r.cfra - bmd->start / bmd->length;
@@ -4330,7 +4330,7 @@ static void waveModifier_do(
MVert *mvert = NULL;
MDeformVert *dvert = NULL;
int defgrp_index;
- float ctime = bsystem_time(ob, 0, (float)G.scene->r.cfra, 0.0);
+ float ctime = bsystem_time(ob, (float)G.scene->r.cfra, 0.0);
float minfac =
(float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
float lifefac = wmd->height;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 90cbd09b959..3f26501db6f 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1132,20 +1132,23 @@ void disable_speed_curve(int val)
}
/* ob can be NULL */
-float bsystem_time(Object *ob, Object *par, float cfra, float ofs)
+float bsystem_time(Object *ob, float cfra, float ofs)
{
/* returns float ( see frame_to_float in ipo.c) */
-
+
+ /* bluroffs and fieldoffs are ugly globals that are set by render */
cfra+= bluroffs+fieldoffs;
/* global time */
cfra*= G.scene->r.framelen;
- if(no_speed_curve==0) if(ob && ob->ipo) cfra= calc_ipo_time(ob->ipo, cfra);
-
- /* ofset frames */
- if(ob && (ob->ipoflag & OB_OFFS_PARENT)) {
- if((ob->partype & PARSLOW)==0) cfra-= ob->sf;
+ if (ob) {
+ if (no_speed_curve==0 && ob->ipo)
+ cfra= calc_ipo_time(ob->ipo, cfra);
+
+ /* ofset frames */
+ if ((ob->ipoflag & OB_OFFS_PARENT) && (ob->partype & PARSLOW)==0)
+ cfra-= ob->sf;
}
cfra-= ofs;
@@ -1236,7 +1239,7 @@ static void ob_parcurve(Object *ob, Object *par, float mat[][4])
}
/* catch exceptions: curve paths used as a duplicator */
else if(enable_cu_speed) {
- ctime= bsystem_time(ob, par, (float)G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(ob, (float)G.scene->r.cfra, 0.0);
if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
ctime /= cu->pathlen;
@@ -1488,7 +1491,7 @@ void where_is_object_time(Object *ob, float ctime)
if(ob==NULL) return;
/* this is needed to be able to grab objects with ipos, otherwise it always freezes them */
- stime= bsystem_time(ob, 0, ctime, 0.0);
+ stime= bsystem_time(ob, ctime, 0.0);
if(stime != ob->ctime) {
ob->ctime= stime;
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 16a29fb8e80..93bda9ac530 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -2893,7 +2893,7 @@ static int softbody_baked_step(Object *ob, float framenr, float (*vertexCos)[3],
/* convert cfra time to system time */
sfra= (float)sb->sfra;
- cfra= bsystem_time(ob, NULL, framenr, 0.0);
+ cfra= bsystem_time(ob, framenr, 0.0);
efra= (float)sb->efra;
dfra= (float)sb->interval;
@@ -2948,7 +2948,7 @@ static void softbody_baked_add(Object *ob, float framenr)
/* convert cfra time to system time */
sfra= (float)sb->sfra;
fac1= ob->sf; ob->sf= 0.0f; /* disable startframe */
- cfra= bsystem_time(ob, NULL, framenr, 0.0);
+ cfra= bsystem_time(ob, framenr, 0.0);
ob->sf= fac1;
efra= (float)sb->efra;
dfra= (float)sb->interval;
@@ -3126,7 +3126,7 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3], int numVerts
/* checking time: */
- ctime= bsystem_time(ob, NULL, framenr, 0.0);
+ ctime= bsystem_time(ob, framenr, 0.0);
if (ob->softflag&OB_SB_RESET) {
dtime = 0.0;
diff --git a/source/blender/python/api2_2x/Effect.c b/source/blender/python/api2_2x/Effect.c
index 22cef7e9d12..ce6b553da0d 100644
--- a/source/blender/python/api2_2x/Effect.c
+++ b/source/blender/python/api2_2x/Effect.c
@@ -1338,7 +1338,7 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
if( !list )
return EXPP_ReturnPyObjError( PyExc_MemoryError, "PyList() failed" );
- c_time= bsystem_time( ob, 0, cfra, p_time );
+ c_time= bsystem_time( ob, cfra, p_time );
for( a=0; a < paf->totpart; a++, pa += paf->totkey ) {
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 5c57fc3d743..f57fa74f618 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -1116,7 +1116,7 @@ static void render_particle_system(Render *re, Object *ob, Object *par, PartEff
if(ob->ipoflag & OB_OFFS_PARTICLE) ptime= ob->sf;
else ptime= 0.0;
- ctime= bsystem_time(ob, 0, (float)re->scene->r.cfra, ptime);
+ ctime= bsystem_time(ob, (float)re->scene->r.cfra, ptime);
seed= ma->seed1;
for(a=0; a<paf->totpart; a++, pa+=paf->totkey, seed++) {
@@ -1353,7 +1353,7 @@ static void render_static_particle_system(Render *re, Object *ob, PartEff *paf)
if(ob->ipoflag & OB_OFFS_PARTICLE) ptime= ob->sf;
else ptime= 0.0;
- ctime= bsystem_time(ob, 0, (float)re->scene->r.cfra, ptime);
+ ctime= bsystem_time(ob, (float)re->scene->r.cfra, ptime);
seed= ma->seed1;
for(a=0; a<paf->totpart; a++, pa+=paf->totkey) {
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index 4e9b2451029..843502e4a07 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -2610,7 +2610,7 @@ static void draw_particle_system(Base *base, PartEff *paf)
if(ob->ipoflag & OB_OFFS_PARTICLE) ptime= ob->sf;
else ptime= 0.0;
- ctime= bsystem_time(ob, 0, (float)(G.scene->r.cfra), ptime);
+ ctime= bsystem_time(ob, (float)(G.scene->r.cfra), ptime);
glPointSize(1.0);
@@ -4191,7 +4191,7 @@ void draw_object(Base *base, int flag)
for (curcon = list->first; curcon; curcon=curcon->next){
if ((curcon->flag & CONSTRAINT_EXPAND)&&(curcon->type!=CONSTRAINT_TYPE_NULL)&&(constraint_has_target(curcon))){
- get_constraint_target_matrix(curcon, TARGET_OBJECT, NULL, tmat, bsystem_time(ob, 0, (float)(G.scene->r.cfra), ob->sf));
+ get_constraint_target_matrix(curcon, TARGET_OBJECT, NULL, tmat, bsystem_time(ob, (float)(G.scene->r.cfra), ob->sf));
setlinestyle(3);
glBegin(GL_LINES);
glVertex3fv(tmat[3]);
diff --git a/source/blender/src/editconstraint.c b/source/blender/src/editconstraint.c
index 907d2139e1e..531c218f242 100644
--- a/source/blender/src/editconstraint.c
+++ b/source/blender/src/editconstraint.c
@@ -1029,7 +1029,37 @@ void childof_const_setinv (void *conv, void *unused)
/* for now, just use pchan->constinv.
* NOTE: bad hack... doesn't work in many cases
*/
+ //Mat4CpyMat4(data->invmat, pchan->constinv);
+
+ bConstraintOb *cob;
+ float ctime= bsystem_time(ob, (float)G.scene->r.cfra, 0.0); /* not accurate... */
+ float pmat[4][4], chmat[4][4], cimat[4][4];
+ float vec0[3]={0,0,0}, vec1[3]={1,1,1};
+
+ /* make copies of pchan's original matrices */
+ Mat4CpyMat4(pmat, pchan->pose_mat);
+ Mat4CpyMat4(chmat, pchan->chan_mat);
+ Mat4CpyMat4(cimat, pchan->constinv);
+
+
+ /* clear pchan's transform (for constraint solving) */
+ LocEulSizeToMat4(pchan->chan_mat, vec0, vec0, vec1);
+ Mat4MulMat4(pchan->pose_mat, pmat, cimat);
+ Mat4One(pchan->constinv);
+ Mat4One(data->invmat);
+
+ /* do constraint solving - code copied from armature.c (where_is_pose_bone) */
+ cob= constraints_make_evalob(ob, pchan, TARGET_BONE);
+ solve_constraints(&pchan->constraints, cob, ctime);
+ constraints_clear_evalob(cob);
+
+ /* now set inverse */
Mat4CpyMat4(data->invmat, pchan->constinv);
+
+ /* reset data */
+ Mat4CpyMat4(pchan->pose_mat, pmat);
+ Mat4CpyMat4(pchan->chan_mat, chmat);
+ Mat4CpyMat4(pchan->constinv, cimat);
}
else if (ob) {
/* use what_does_parent to find inverse - just like for normal parenting.
diff --git a/source/blender/src/editkey.c b/source/blender/src/editkey.c
index 02f8e650d90..c557b8df259 100644
--- a/source/blender/src/editkey.c
+++ b/source/blender/src/editkey.c
@@ -381,7 +381,7 @@ static KeyBlock *add_keyblock(Key *key)
if(key->type == KEY_RELATIVE)
kb->pos= curpos+0.1;
else {
- curpos= bsystem_time(0, 0, (float)CFRA, 0.0);
+ curpos= bsystem_time(0, (float)CFRA, 0.0);
if(calc_ipo_spec(key->ipo, KEY_SPEED, &curpos)==0) {
curpos /= 100.0;
}