diff options
-rw-r--r-- | source/blender/blenkernel/BKE_scene.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 15 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene_api.c | 9 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 5 |
4 files changed, 21 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 74a847a01d4..34f34bb9951 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -99,6 +99,7 @@ int BKE_scene_validate_setscene(struct Main *bmain, struct Scene *sce); float BKE_scene_frame_get(struct Scene *scene); float BKE_scene_frame_get_from_ctime(struct Scene *scene, const float frame); +void BKE_scene_frame_set(struct Scene *scene, double cfra); void BKE_scene_update_tagged(struct Main *bmain, struct Scene *sce); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 9c376f9ea04..26563afa65b 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1045,6 +1045,21 @@ float BKE_scene_frame_get_from_ctime(Scene *scene, const float frame) return ctime; } +/** + * Sets the frame int/float components. + */ +void BKE_scene_frame_set(struct Scene *scene, double cfra) +{ + double intpart; + scene->r.subframe = modf(cfra, &intpart); + scene->r.cfra = (int)intpart; + + if (cfra < 0.0) { + scene->r.cfra -= 1; + scene->r.subframe = 1.0f + scene->r.subframe; + } +} + /* drivers support/hacks * - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render * - these are always run since the depsgraph can't handle non-object data diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 1f4622ff7f4..375b31e0586 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -56,12 +56,11 @@ static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) { - float cfra = (float)frame + subframe; + double cfra = (double)frame + (double)subframe; + + CLAMP(cfra, MINAFRAME, MAXFRAME); + BKE_scene_frame_set(scene, cfra); - 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); BKE_scene_camera_switch_update(scene); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 068df215edb..91244e95d3b 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1113,7 +1113,6 @@ void RE_TileProcessor(Render *re) static void do_render_3d(Render *re) { - float cfra; int cfra_backup; /* try external */ @@ -1126,9 +1125,7 @@ static void do_render_3d(Render *re) /* add motion blur and fields offset to frames */ cfra_backup = re->scene->r.cfra; - cfra = re->scene->r.cfra + re->mblur_offs + re->field_offs; - re->scene->r.cfra = floorf(cfra); - re->scene->r.subframe = cfra - floorf(cfra); + BKE_scene_frame_set(re->scene, (double)re->scene->r.cfra + (double)re->mblur_offs + (double)re->field_offs); /* lock drawing in UI during data phase */ if (re->draw_lock) |