Partial cleanup of timing system, with some guidance from Joshua:
* Fractional frames support has been changed to use a new var, scene->r.subframe. This is a 0.0-1.0 float representing a subframe interval, used in generating a final float frame number to evaluate animation system etc. * Changed frame_to_float() and some instances of bsystem_time() into a convenience function: float BKE_curframe(scene) which retrieves the floating point current frame, after subframe and frame length corrections. * Removed blur_offs and field_offs globals. These are now stored in render, used to generate a scene->r.subframe before render database processing.
This commit is contained in:
@@ -80,6 +80,8 @@ void scene_select_base(struct Scene *sce, struct Base *selbase);
|
||||
/* checks for cycle, returns 1 if it's all OK */
|
||||
int scene_check_setscene(struct Scene *sce);
|
||||
|
||||
float BKE_curframe(struct Scene *scene);
|
||||
|
||||
void scene_update_tagged(struct Scene *sce);
|
||||
void scene_update_for_newframe(struct Scene *sce, unsigned int lay);
|
||||
|
||||
|
@@ -1418,7 +1418,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
|
||||
bActionStrip *strip, *striplast=NULL, *stripfirst=NULL;
|
||||
float striptime, frametime, length, actlength;
|
||||
float blendfac, stripframe;
|
||||
float scene_cfra= frame_to_float(scene, scene->r.cfra);
|
||||
float scene_cfra= BKE_curframe(scene);
|
||||
int doit, dostride;
|
||||
|
||||
if(blocktype==ID_AR) {
|
||||
|
@@ -1605,20 +1605,8 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
|
||||
|
||||
/* there is also a timing calculation in drawobject() */
|
||||
|
||||
float bluroffs= 0.0f, fieldoffs= 0.0f;
|
||||
int no_speed_curve= 0;
|
||||
|
||||
/* ugly calls from render */
|
||||
void set_mblur_offs(float blur)
|
||||
{
|
||||
bluroffs= blur;
|
||||
}
|
||||
|
||||
void set_field_offs(float field)
|
||||
{
|
||||
fieldoffs= field;
|
||||
}
|
||||
|
||||
void disable_speed_curve(int val)
|
||||
{
|
||||
no_speed_curve= val;
|
||||
@@ -1628,10 +1616,8 @@ void disable_speed_curve(int val)
|
||||
/* ob can be NULL */
|
||||
float bsystem_time(struct Scene *scene, 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;
|
||||
/* returns float ( see BKE_curframe in scene.c) */
|
||||
cfra += scene->r.subframe;
|
||||
|
||||
/* global time */
|
||||
if (scene)
|
||||
|
@@ -3925,7 +3925,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
|
||||
if(!psys_check_enabled(ob, psys))
|
||||
return;
|
||||
|
||||
cfra= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0f);
|
||||
cfra= BKE_curframe(scene);
|
||||
sim.psmd= psys_get_modifier(ob, psys);
|
||||
|
||||
/* system was already updated from modifier stack */
|
||||
|
@@ -879,20 +879,14 @@ int scene_check_setscene(Scene *sce)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* This (evil) function is needed to cope with two legacy Blender rendering features
|
||||
* mblur (motion blur that renders 'subframes' and blurs them together), and fields
|
||||
* rendering. Thus, the use of ugly globals from object.c
|
||||
*/
|
||||
// BAD... EVIL... JUJU...!!!!
|
||||
// XXX moved here temporarily
|
||||
float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in object.c */
|
||||
{
|
||||
extern float bluroffs; /* bad stuff borrowed from object.c */
|
||||
extern float fieldoffs;
|
||||
float ctime;
|
||||
/* This function is needed to cope with fractional frames - including two Blender rendering features
|
||||
* mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering. */
|
||||
|
||||
ctime= (float)cfra;
|
||||
ctime+= bluroffs+fieldoffs;
|
||||
/* see also bsystem_time in object.c */
|
||||
float BKE_curframe(Scene *scene)
|
||||
{
|
||||
float ctime = scene->r.cfra;
|
||||
ctime+= scene->r.subframe;
|
||||
ctime*= scene->r.framelen;
|
||||
|
||||
return ctime;
|
||||
@@ -929,7 +923,7 @@ void scene_update_tagged(Scene *scene)
|
||||
|
||||
/* recalc scene animation data here (for sequencer) */
|
||||
{
|
||||
float ctime = frame_to_float(scene, scene->r.cfra);
|
||||
float ctime = BKE_curframe(scene);
|
||||
AnimData *adt= BKE_animdata_from_id(&scene->id);
|
||||
|
||||
if(adt && (adt->recalc & ADT_RECALC_ANIM))
|
||||
@@ -946,7 +940,7 @@ void scene_update_tagged(Scene *scene)
|
||||
/* applies changes right away, does all sets too */
|
||||
void scene_update_for_newframe(Scene *sce, unsigned int lay)
|
||||
{
|
||||
float ctime = frame_to_float(sce, sce->r.cfra);
|
||||
float ctime = BKE_curframe(sce);
|
||||
Scene *sce_iter;
|
||||
|
||||
/* clear animation overrides */
|
||||
|
@@ -69,6 +69,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
|
||||
/* set the new frame number */
|
||||
CFRA= RNA_int_get(op->ptr, "frame");
|
||||
FRAMENUMBER_MIN_CLAMP(CFRA);
|
||||
SUBFRA = 0.f;
|
||||
|
||||
/* do updates */
|
||||
sound_seek_scene(C);
|
||||
|
@@ -257,7 +257,7 @@ short fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter);
|
||||
* Checks whether a keyframe exists for the given ID-block one the given frame.
|
||||
* - It is recommended to call this method over the other keyframe-checkers directly,
|
||||
* in case some detail of the implementation changes...
|
||||
* - frame: the value of this is quite often result of frame_to_float(CFRA)
|
||||
* - frame: the value of this is quite often result of BKE_curframe()
|
||||
*/
|
||||
short id_frame_has_keyframe(struct ID *id, float frame, short filter);
|
||||
|
||||
|
@@ -1504,6 +1504,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
|
||||
delta = RNA_int_get(op->ptr, "delta");
|
||||
|
||||
CTX_data_scene(C)->r.cfra += delta;
|
||||
CTX_data_scene(C)->r.subframe = 0.f;
|
||||
|
||||
sound_seek_scene(C);
|
||||
|
||||
|
@@ -1138,6 +1138,7 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *op)
|
||||
if (ked.i1) {
|
||||
Scene *scene= ac.scene;
|
||||
CFRA= (int)floor((ked.f1 / ked.i1) + 0.5f);
|
||||
SUBFRA= 0.f;
|
||||
}
|
||||
|
||||
/* set notifier that things have changed */
|
||||
|
@@ -1582,6 +1582,7 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* take the average values, rounding to the nearest int for the current frame */
|
||||
CFRA= (int)floor((ked.f1 / ked.i1) + 0.5f);
|
||||
SUBFRA= 0.f;
|
||||
sipo->cursorVal= ked.f2 / (float)ked.i1;
|
||||
}
|
||||
|
||||
|
@@ -71,6 +71,7 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op)
|
||||
* NOTE: sync this part of the code with ANIM_OT_change_frame
|
||||
*/
|
||||
CFRA= RNA_int_get(op->ptr, "frame");
|
||||
SUBFRA=0.f;
|
||||
sound_seek_scene(C);
|
||||
|
||||
/* set the cursor value */
|
||||
|
@@ -820,7 +820,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d)
|
||||
}
|
||||
|
||||
/* colour depends on whether there is a keyframe */
|
||||
if (id_frame_has_keyframe((ID *)ob, /*frame_to_float(scene, CFRA)*/(float)(CFRA), v3d->keyflags))
|
||||
if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/(float)(CFRA), v3d->keyflags))
|
||||
UI_ThemeColor(TH_VERTEX_SELECT);
|
||||
else
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
|
@@ -209,12 +209,12 @@ typedef struct RenderData {
|
||||
struct FFMpegCodecData ffcodecdata;
|
||||
|
||||
int cfra, sfra, efra; /* frames as in 'images' */
|
||||
float subframe; /* subframe offset from cfra, in 0.0-1.0 */
|
||||
int psfra, pefra; /* start+end frames of preview range */
|
||||
|
||||
int images, framapto;
|
||||
short flag, threads;
|
||||
|
||||
float ctime; /* use for calcutions */
|
||||
float framelen, blurfac;
|
||||
|
||||
/** For UR edge rendering: give the edges this color */
|
||||
@@ -1022,6 +1022,7 @@ typedef struct Scene {
|
||||
#define ID_NEW_US(a) if( (a)->id.newid) {(a)= (void *)(a)->id.newid; (a)->id.us++;}
|
||||
#define ID_NEW_US2(a) if( ((ID *)a)->newid) {(a)= ((ID *)a)->newid; ((ID *)a)->us++;}
|
||||
#define CFRA (scene->r.cfra)
|
||||
#define SUBFRA (scene->r.subframe)
|
||||
#define F_CFRA ((float)(scene->r.cfra))
|
||||
#define SFRA (scene->r.sfra)
|
||||
#define EFRA (scene->r.efra)
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_particle.h"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
|
||||
static void initData(ModifierData *md)
|
||||
@@ -106,7 +107,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
frac = bsystem_time(md->scene, ob, md->scene->r.cfra,
|
||||
bmd->start - 1.0f) / bmd->length;
|
||||
} else {
|
||||
frac = md->scene->r.cfra - bmd->start / bmd->length;
|
||||
frac = BKE_curframe(md->scene) - bmd->start / bmd->length;
|
||||
}
|
||||
CLAMP(frac, 0.0, 1.0);
|
||||
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_pointcache.h"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
|
||||
static void initData(ModifierData *md)
|
||||
@@ -119,7 +120,7 @@ static void deformVerts(
|
||||
CDDM_apply_vert_coords(dm, vertexCos);
|
||||
CDDM_calc_normals(dm);
|
||||
|
||||
current_time = bsystem_time (md->scene, ob, ( float ) md->scene->r.cfra, 0.0 );
|
||||
current_time = BKE_curframe(md->scene);
|
||||
|
||||
if(G.rt > 0)
|
||||
printf("current_time %f, collmd->time %f\n", current_time, collmd->time);
|
||||
|
@@ -39,13 +39,14 @@
|
||||
#include "BLI_edgehash.h"
|
||||
|
||||
#include "BKE_cdderivedmesh.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_lattice.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_particle.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BKE_deform.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -682,7 +683,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
timestep= psys_get_timestep(&sim);
|
||||
|
||||
//if(part->flag & PART_GLOB_TIME)
|
||||
cfra=bsystem_time(scene, 0,(float)scene->r.cfra,0.0);
|
||||
cfra= BKE_curframe(scene);
|
||||
//else
|
||||
// cfra=bsystem_time(scene, ob,(float)scene->r.cfra,0.0);
|
||||
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include "BKE_DerivedMesh.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "depsgraph_private.h"
|
||||
|
||||
@@ -247,7 +248,7 @@ static void waveModifier_do(WaveModifierData *md,
|
||||
MVert *mvert = NULL;
|
||||
MDeformVert *dvert = NULL;
|
||||
int defgrp_index;
|
||||
float ctime = bsystem_time(scene, ob, (float)scene->r.cfra, 0.0);
|
||||
float ctime = BKE_curframe(scene);
|
||||
float minfac =
|
||||
(float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
|
||||
float lifefac = wmd->height;
|
||||
|
@@ -190,6 +190,7 @@ struct Render
|
||||
|
||||
/* use this instead of R.r.cfra */
|
||||
float cfra;
|
||||
float mblur_offs, field_offs;
|
||||
|
||||
/* render database */
|
||||
int totvlak, totvert, tothalo, totstrand, totlamp;
|
||||
|
@@ -1520,7 +1520,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
|
||||
RNG *rng= 0;
|
||||
float loc[3],loc1[3],loc0[3],mat[4][4],nmat[3][3],co[3],nor[3],time;
|
||||
float strandlen=0.0f, curlen=0.0f;
|
||||
float hasize, pa_size, r_tilt, r_length, cfra=bsystem_time(re->scene, ob, (float)re->scene->r.cfra, 0.0);
|
||||
float hasize, pa_size, r_tilt, r_length, cfra= BKE_curframe(re->scene);
|
||||
float pa_time, pa_birthtime, pa_dietime;
|
||||
float random, simplify[2];
|
||||
int i, a, k, max_k=0, totpart, dosimplify = 0, dosurfacecache = 0;
|
||||
@@ -1639,7 +1639,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
|
||||
|
||||
if(part->flag & PART_GLOB_TIME)
|
||||
#endif // XXX old animation system
|
||||
cfra = bsystem_time(re->scene, 0, (float)re->scene->r.cfra, 0.0);
|
||||
cfra = BKE_curframe(re->scene);
|
||||
|
||||
///* 2.4 setup reactors */
|
||||
// if(part->type == PART_REACTOR){
|
||||
|
@@ -1302,6 +1302,8 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *
|
||||
/* we clip faces with a minimum of 2 pixel boundary outside of image border. see zbuf.c */
|
||||
re->clipcrop= 1.0f + 2.0f/(float)(re->winx>re->winy?re->winy:re->winx);
|
||||
|
||||
re->mblur_offs = re->field_offs = 0.f;
|
||||
|
||||
RE_init_threadcount(re);
|
||||
}
|
||||
|
||||
@@ -1762,6 +1764,7 @@ static void do_render_3d(Render *re)
|
||||
/* internal */
|
||||
|
||||
// re->cfra= cfra; /* <- unused! */
|
||||
re->scene->r.subframe = re->mblur_offs + re->field_offs;
|
||||
|
||||
/* make render verts/faces/halos/lamps */
|
||||
if(render_scene_needs_vector(re))
|
||||
@@ -1778,6 +1781,8 @@ static void do_render_3d(Render *re)
|
||||
|
||||
/* free all render verts etc */
|
||||
RE_Database_Free(re);
|
||||
|
||||
re->scene->r.subframe = 0.f;
|
||||
}
|
||||
|
||||
/* called by blur loop, accumulate RGBA key alpha */
|
||||
@@ -1877,7 +1882,7 @@ static void do_render_blur_3d(Render *re)
|
||||
|
||||
/* do the blur steps */
|
||||
while(blur--) {
|
||||
set_mblur_offs( re->r.blurfac*((float)(re->r.mblur_samples-blur))/(float)re->r.mblur_samples );
|
||||
re->mblur_offs = re->r.blurfac*((float)(re->r.mblur_samples-blur))/(float)re->r.mblur_samples;
|
||||
|
||||
re->i.curblur= re->r.mblur_samples-blur; /* stats */
|
||||
|
||||
@@ -1895,7 +1900,7 @@ static void do_render_blur_3d(Render *re)
|
||||
re->result= rres;
|
||||
BLI_rw_mutex_unlock(&re->resultmutex);
|
||||
|
||||
set_mblur_offs(0.0f);
|
||||
re->mblur_offs = 0.0f;
|
||||
re->i.curblur= 0; /* stats */
|
||||
|
||||
/* weak... the display callback wants an active renderlayer pointer... */
|
||||
@@ -1975,15 +1980,17 @@ static void do_render_fields_3d(Render *re)
|
||||
re->i.curfield= 2; /* stats */
|
||||
|
||||
re->flag |= R_SEC_FIELD;
|
||||
if((re->r.mode & R_FIELDSTILL)==0)
|
||||
set_field_offs(0.5f);
|
||||
if((re->r.mode & R_FIELDSTILL)==0) {
|
||||
re->field_offs = 0.5f;
|
||||
}
|
||||
RE_SetCamera(re, re->scene->camera);
|
||||
if(re->r.mode & R_MBLUR)
|
||||
do_render_blur_3d(re);
|
||||
else
|
||||
do_render_3d(re);
|
||||
re->flag &= ~R_SEC_FIELD;
|
||||
set_field_offs(0.0f);
|
||||
|
||||
re->field_offs = 0.0f;
|
||||
|
||||
rr2= re->result;
|
||||
}
|
||||
@@ -2448,7 +2455,7 @@ static void do_render_seq(Render * re)
|
||||
|
||||
if(recurs_depth==0) {
|
||||
/* otherwise sequencer animation isnt updated */
|
||||
BKE_animsys_evaluate_all_animation(G.main, (float)cfra); // XXX, was frame_to_float(re->scene, cfra)
|
||||
BKE_animsys_evaluate_all_animation(G.main, (float)cfra); // XXX, was BKE_curframe(re->scene)
|
||||
}
|
||||
|
||||
recurs_depth++;
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_particle.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_texture.h"
|
||||
|
||||
#include "DNA_meshdata_types.h"
|
||||
@@ -95,7 +96,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
|
||||
ParticleKey state;
|
||||
ParticleSimulationData sim = {re->scene, ob, psys, NULL};
|
||||
ParticleData *pa=NULL;
|
||||
float cfra = bsystem_time(re->scene, ob, (float)re->scene->r.cfra, 0.0);
|
||||
float cfra = BKE_curframe(re->scene);
|
||||
int i, childexists;
|
||||
int total_particles, offset=0;
|
||||
int data_used = point_data_used(pd);
|
||||
|
@@ -98,7 +98,7 @@ void init_render_texture(Render *re, Tex *tex)
|
||||
if(tex->type==TEX_PLUGIN) {
|
||||
if(tex->plugin && tex->plugin->doit) {
|
||||
if(tex->plugin->cfra) {
|
||||
*(tex->plugin->cfra)= (float)cfra; //frame_to_float(re->scene, cfra); // XXX old animsys - timing stuff to be fixed
|
||||
*(tex->plugin->cfra)= (float)cfra; //BKE_curframe(re->scene); // XXX old animsys - timing stuff to be fixed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user