Fix drivers and shape keys not handling subframes / frame mapping properly.

Change Scene.frame_set so that it ensures subframe in range [0,1[ as Blender
expects, otherwise some things like physics point cache lookups don't get
evaluated properly.
This commit is contained in:
Brecht Van Lommel 2013-01-27 16:45:00 +00:00
parent 431619e45b
commit 6cadd2bee3
4 changed files with 13 additions and 11 deletions

@ -2258,7 +2258,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
{
bActionModifier *amod;
bActionStrip *strip, *strip2;
float scene_cfra = (float)scene->r.cfra;
float scene_cfra = BKE_scene_frame_get(scene);
int do_modif;
for (strip = armob->nlastrips.first; strip; strip = strip->next) {

@ -1065,7 +1065,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
if (key->slurph && key->type != KEY_RELATIVE) {
const float ctime_scaled = key->ctime / 100.0f;
float delta = (float)key->slurph / tot;
float cfra = (float)scene->r.cfra + scene->r.subframe;
float cfra = BKE_scene_frame_get(scene);
int step, a;
if (tot > 100 && slurph_opt) {
@ -1163,7 +1163,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
if (key->slurph && key->type != KEY_RELATIVE) {
const float ctime_scaled = key->ctime / 100.0f;
float delta = (float)key->slurph / tot;
float cfra = (float)scene->r.cfra + scene->r.subframe;
float cfra = BKE_scene_frame_get(scene);
Nurb *nu;
int i = 0, remain = 0;
int step, a;
@ -1245,7 +1245,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
if (key->slurph && key->type != KEY_RELATIVE) {
const float ctime_scaled = key->ctime / 100.0f;
float delta = (float)key->slurph / tot;
float cfra = (float)scene->r.cfra + scene->r.subframe;
float cfra = BKE_scene_frame_get(scene);
int a;
for (a = 0; a < tot; a++, cfra += delta) {
@ -1360,7 +1360,7 @@ float *BKE_key_evaluate_object(Scene *scene, Object *ob, int *r_totelem)
}
else {
/* do shapekey local drivers */
float ctime = (float)scene->r.cfra + scene->r.subframe;
float ctime = BKE_scene_frame_get(scene);
BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);

@ -1808,7 +1808,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
CLAMP(ctime, 0.0f, 1.0f);
}
else {
ctime = scene->r.cfra;
ctime = BKE_scene_frame_get(scene);
if (IS_EQF(cu->pathlen, 0.0f) == 0)
ctime /= cu->pathlen;
@ -2187,7 +2187,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
void BKE_object_where_is_calc(struct Scene *scene, Object *ob)
{
BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
BKE_object_where_is_calc_time(scene, ob, BKE_scene_frame_get(scene));
}
void BKE_object_where_is_calc_simul(Scene *scene, Object *ob)
@ -2226,7 +2226,7 @@ void BKE_object_where_is_calc_simul(Scene *scene, Object *ob)
bConstraintOb *cob;
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
BKE_solve_constraints(&ob->constraints, cob, (float)scene->r.cfra);
BKE_solve_constraints(&ob->constraints, cob, BKE_scene_frame_get(scene));
BKE_constraints_clear_evalob(cob);
}
}
@ -2670,7 +2670,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob)
if (ob->recalc & OB_RECALC_DATA) {
ID *data_id = (ID *)ob->data;
AnimData *adt = BKE_animdata_from_id(data_id);
float ctime = (float)scene->r.cfra; /* XXX this is bad... */
float ctime = BKE_scene_frame_get(scene);
if (G.debug & G_DEBUG)
printf("recalcdata %s\n", ob->id.name + 2);

@ -55,8 +55,10 @@
static void rna_Scene_frame_set(Scene *scene, int frame, float subframe)
{
scene->r.cfra = frame;
scene->r.subframe = subframe;
float cfra = (float)frame + subframe;
scene->r.cfra = floorf(cfra);
scene->r.subframe = cfra - floorf(cfra);
CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME);
BKE_scene_update_for_newframe(G.main, scene, (1 << 20) - 1);