Cleanup: Core: Replace FPS scene macro with member function
Replaces the `FPS` macro with `scene->frames_per_second()`. The macro has two major issues: * It hides that it depends on a `Scene *` variable named `scene`. * It makes debugging harder. This is now replaced with a member function on the scene. Pull Request: https://projects.blender.org/blender/blender/pulls/144127
This commit is contained in:
@@ -5372,7 +5372,8 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
|
||||
}
|
||||
|
||||
const float frame = DEG_get_ctime(cob->depsgraph);
|
||||
const double time = BKE_cachefile_time_offset(cache_file, double(frame), FPS);
|
||||
const double time = BKE_cachefile_time_offset(
|
||||
cache_file, double(frame), scene->frames_per_second());
|
||||
|
||||
if (!data->reader || !STREQ(data->reader_object_path, data->object_path)) {
|
||||
STRNCPY(data->reader_object_path, data->object_path);
|
||||
@@ -5388,7 +5389,7 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
|
||||
case CACHEFILE_TYPE_USD:
|
||||
# ifdef WITH_USD
|
||||
blender::io::usd::USD_get_transform(
|
||||
data->reader, cob->matrix, time * FPS, cache_file->scale);
|
||||
data->reader, cob->matrix, time * scene->frames_per_second(), cache_file->scale);
|
||||
# endif
|
||||
break;
|
||||
case CACHE_FILE_TYPE_INVALID:
|
||||
|
||||
@@ -521,7 +521,7 @@ static bool fluid_modifier_init(
|
||||
copy_v3_v3_int(fds->res_max, res);
|
||||
|
||||
/* Set time, frame length = 0.1 is at 25fps. */
|
||||
fds->frame_length = DT_DEFAULT * (25.0f / FPS) * fds->time_scale;
|
||||
fds->frame_length = DT_DEFAULT * (25.0f / scene->frames_per_second()) * fds->time_scale;
|
||||
/* Initially dt is equal to frame length (dt can change with adaptive-time stepping though). */
|
||||
fds->dt = fds->frame_length;
|
||||
fds->time_per_frame = 0;
|
||||
@@ -3244,7 +3244,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
|
||||
bool use_speedvectors = fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS;
|
||||
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
|
||||
SpanAttributeWriter<float3> velocities;
|
||||
float time_mult = fds->dx / (DT_DEFAULT * (25.0f / FPS));
|
||||
float time_mult = fds->dx / (DT_DEFAULT * (25.0f / scene->frames_per_second()));
|
||||
|
||||
if (use_speedvectors) {
|
||||
velocities = attributes.lookup_or_add_for_write_only_span<float3>("velocity",
|
||||
@@ -3547,7 +3547,7 @@ static void manta_guiding(
|
||||
Depsgraph *depsgraph, Scene *scene, Object *ob, FluidModifierData *fmd, int frame)
|
||||
{
|
||||
FluidDomainSettings *fds = fmd->domain;
|
||||
float dt = DT_DEFAULT * (25.0f / FPS) * fds->time_scale;
|
||||
float dt = DT_DEFAULT * (25.0f / scene->frames_per_second()) * fds->time_scale;
|
||||
|
||||
std::scoped_lock lock(object_update_lock);
|
||||
|
||||
@@ -3718,7 +3718,7 @@ static void fluid_modifier_processDomain(FluidModifierData *fmd,
|
||||
copy_v3_v3_int(o_shift, fds->shift);
|
||||
|
||||
/* Ensure that time parameters are initialized correctly before every step. */
|
||||
fds->frame_length = DT_DEFAULT * (25.0f / FPS) * fds->time_scale;
|
||||
fds->frame_length = DT_DEFAULT * (25.0f / scene->frames_per_second()) * fds->time_scale;
|
||||
fds->dt = fds->frame_length;
|
||||
fds->time_per_frame = 0;
|
||||
|
||||
|
||||
@@ -1777,8 +1777,12 @@ static void stampdata(
|
||||
|
||||
if (use_dynamic && scene->r.stamp & R_STAMP_TIME) {
|
||||
const short timecode_style = USER_TIMECODE_SMPTE_FULL;
|
||||
BLI_timecode_string_from_time(
|
||||
text, sizeof(text), 0, FRA2TIME(scene->r.cfra), FPS, timecode_style);
|
||||
BLI_timecode_string_from_time(text,
|
||||
sizeof(text),
|
||||
0,
|
||||
FRA2TIME(scene->r.cfra),
|
||||
scene->frames_per_second(),
|
||||
timecode_style);
|
||||
SNPRINTF_UTF8(stamp_data->time, do_prefix ? "Timecode %s" : "%s", text);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -616,7 +616,7 @@ NlaStrip *BKE_nla_add_soundstrip(Main *bmain, Scene *scene, Speaker *speaker)
|
||||
if (speaker->sound) {
|
||||
SoundInfo info;
|
||||
if (BKE_sound_info_get(bmain, speaker->sound, &info)) {
|
||||
strip->end = float(ceil(double(info.length) * FPS));
|
||||
strip->end = float(ceil(double(info.length) * scene->frames_per_second()));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -2255,7 +2255,7 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
|
||||
|
||||
const float frame_diff = ctime - rbw->ltime;
|
||||
/* calculate how much time elapsed since last step in seconds */
|
||||
const float timestep = 1.0f / float(FPS) * frame_diff * rbw->time_scale;
|
||||
const float timestep = 1.0f / float(scene->frames_per_second()) * frame_diff * rbw->time_scale;
|
||||
|
||||
const float substep = timestep / rbw->substeps_per_frame;
|
||||
|
||||
|
||||
@@ -1631,6 +1631,19 @@ constexpr IDTypeInfo get_type_info()
|
||||
}
|
||||
IDTypeInfo IDType_ID_SCE = get_type_info();
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Scene member functions
|
||||
*/
|
||||
|
||||
double Scene::frames_per_second() const
|
||||
{
|
||||
return double(this->r.frs_sec) / double(this->r.frs_sec_base);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
|
||||
const char *RE_engine_id_BLENDER_EEVEE_NEXT = "BLENDER_EEVEE_NEXT";
|
||||
const char *RE_engine_id_BLENDER_WORKBENCH = "BLENDER_WORKBENCH";
|
||||
@@ -2342,7 +2355,7 @@ const char *BKE_scene_find_last_marker_name(const Scene *scene, int frame)
|
||||
|
||||
int BKE_scene_frame_snap_by_seconds(Scene *scene, double interval_in_seconds, int frame)
|
||||
{
|
||||
const int fps = round_db_to_int(FPS * interval_in_seconds);
|
||||
const int fps = round_db_to_int(scene->frames_per_second() * interval_in_seconds);
|
||||
const int second_prev = frame - mod_i(frame, fps);
|
||||
const int second_next = second_prev + fps;
|
||||
const int delta_prev = frame - second_prev;
|
||||
|
||||
@@ -784,8 +784,11 @@ void BKE_sound_load(Main *bmain, bSound *sound)
|
||||
AUD_Device *BKE_sound_mixdown(const Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
|
||||
{
|
||||
sound_verify_evaluated_id(&scene->id);
|
||||
return AUD_openMixdownDevice(
|
||||
specs, scene->sound_scene, volume, AUD_RESAMPLE_QUALITY_MEDIUM, start / FPS);
|
||||
return AUD_openMixdownDevice(specs,
|
||||
scene->sound_scene,
|
||||
volume,
|
||||
AUD_RESAMPLE_QUALITY_MEDIUM,
|
||||
start / scene->frames_per_second());
|
||||
}
|
||||
|
||||
void BKE_sound_create_scene(Scene *scene)
|
||||
@@ -797,7 +800,8 @@ void BKE_sound_create_scene(Scene *scene)
|
||||
scene->r.frs_sec_base = 1;
|
||||
}
|
||||
|
||||
scene->sound_scene = AUD_Sequence_create(FPS, scene->audio.flag & AUDIO_MUTE);
|
||||
scene->sound_scene = AUD_Sequence_create(scene->frames_per_second(),
|
||||
scene->audio.flag & AUDIO_MUTE);
|
||||
AUD_Sequence_setSpeedOfSound(scene->sound_scene, scene->audio.speed_of_sound);
|
||||
AUD_Sequence_setDopplerFactor(scene->sound_scene, scene->audio.doppler_factor);
|
||||
AUD_Sequence_setDistanceModel(scene->sound_scene,
|
||||
@@ -869,7 +873,7 @@ void BKE_sound_update_fps(Main *bmain, Scene *scene)
|
||||
sound_verify_evaluated_id(&scene->id);
|
||||
|
||||
if (scene->sound_scene) {
|
||||
AUD_Sequence_setFPS(scene->sound_scene, FPS);
|
||||
AUD_Sequence_setFPS(scene->sound_scene, scene->frames_per_second());
|
||||
}
|
||||
|
||||
blender::seq::sound_update_length(bmain, scene);
|
||||
@@ -890,7 +894,7 @@ void *BKE_sound_scene_add_scene_sound(
|
||||
{
|
||||
sound_verify_evaluated_id(&scene->id);
|
||||
if (sequence->scene && scene != sequence->scene) {
|
||||
const double fps = FPS;
|
||||
const double fps = scene->frames_per_second();
|
||||
return AUD_Sequence_add(scene->sound_scene,
|
||||
sequence->scene->sound_scene,
|
||||
startframe / fps,
|
||||
@@ -919,7 +923,7 @@ void *BKE_sound_add_scene_sound(
|
||||
return nullptr;
|
||||
}
|
||||
sound_verify_evaluated_id(&sequence->sound->id);
|
||||
const double fps = FPS;
|
||||
const double fps = scene->frames_per_second();
|
||||
const double offset_time = sequence->sound->offset_time + sequence->sound_offset -
|
||||
frameskip / fps;
|
||||
if (offset_time >= 0.0f) {
|
||||
@@ -963,7 +967,7 @@ void BKE_sound_move_scene_sound(const Scene *scene,
|
||||
double audio_offset)
|
||||
{
|
||||
sound_verify_evaluated_id(&scene->id);
|
||||
const double fps = FPS;
|
||||
const double fps = scene->frames_per_second();
|
||||
const double offset_time = audio_offset - frameskip / fps;
|
||||
if (offset_time >= 0.0f) {
|
||||
AUD_SequenceEntry_move(handle, startframe / fps + offset_time, endframe / fps, 0.0f);
|
||||
@@ -1193,7 +1197,7 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene)
|
||||
AUD_Handle_pause(scene->playback_handle);
|
||||
}
|
||||
|
||||
const double one_frame = 1.0 / FPS +
|
||||
const double one_frame = 1.0 / scene->frames_per_second() +
|
||||
(U.audiorate > 0 ? U.mixbufsize / double(U.audiorate) : 0.0);
|
||||
const double cur_time = FRA2TIME(scene->r.cfra);
|
||||
|
||||
@@ -1337,7 +1341,10 @@ static void sound_update_base(Scene *scene, Object *object, void *new_set)
|
||||
|
||||
if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) {
|
||||
if (speaker->sound) {
|
||||
AUD_SequenceEntry_move(strip->speaker_handle, double(strip->start) / FPS, FLT_MAX, 0);
|
||||
AUD_SequenceEntry_move(strip->speaker_handle,
|
||||
double(strip->start) / scene->frames_per_second(),
|
||||
FLT_MAX,
|
||||
0);
|
||||
}
|
||||
else {
|
||||
AUD_Sequence_remove(scene->sound_scene, strip->speaker_handle);
|
||||
@@ -1348,7 +1355,8 @@ static void sound_update_base(Scene *scene, Object *object, void *new_set)
|
||||
if (speaker->sound) {
|
||||
strip->speaker_handle = AUD_Sequence_add(scene->sound_scene,
|
||||
speaker->sound->playback_handle,
|
||||
double(strip->start) / FPS,
|
||||
double(strip->start) /
|
||||
scene->frames_per_second(),
|
||||
FLT_MAX,
|
||||
0);
|
||||
AUD_SequenceEntry_setRelative(strip->speaker_handle, 0);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* \param brevity_level: special setting for #View2D grid drawing,
|
||||
* used to specify how detailed we need to be
|
||||
* \param time_seconds: time total time in seconds
|
||||
* \param fps: frames per second, typically from the #FPS macro
|
||||
* \param fps: frames per second
|
||||
* \param timecode_style: enum from #eTimecodeStyles
|
||||
* \return length of \a str
|
||||
*/
|
||||
|
||||
@@ -1175,7 +1175,7 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
|
||||
/* The sub-step method changed from "per second" to "per frame".
|
||||
* To get the new value simply divide the old bullet sim FPS with the scene FPS. */
|
||||
rbw->substeps_per_frame /= FPS;
|
||||
rbw->substeps_per_frame /= scene->frames_per_second();
|
||||
|
||||
if (rbw->substeps_per_frame <= 0) {
|
||||
rbw->substeps_per_frame = 1;
|
||||
|
||||
@@ -703,7 +703,7 @@ void ANIM_center_frame(bContext *C, int smooth_viewtx)
|
||||
|
||||
switch (U.view_frame_type) {
|
||||
case ZOOM_FRAME_MODE_SECONDS: {
|
||||
const float fps = FPS;
|
||||
const float fps = scene->frames_per_second();
|
||||
newrct.xmax = scene->r.cfra + U.view_frame_seconds * fps + 1;
|
||||
newrct.xmin = scene->r.cfra - U.view_frame_seconds * fps - 1;
|
||||
newrct.ymax = region->v2d.cur.ymax;
|
||||
|
||||
@@ -1113,8 +1113,8 @@ static wmOperatorStatus ed_marker_move_modal(bContext *C, wmOperator *op, const
|
||||
(event->modifier & KM_CTRL) != 0,
|
||||
&fac,
|
||||
0.0,
|
||||
FPS,
|
||||
0.1 * FPS,
|
||||
scene->frames_per_second(),
|
||||
0.1 * scene->frames_per_second(),
|
||||
0);
|
||||
|
||||
RNA_int_set(op->ptr, "frames", int(fac));
|
||||
|
||||
@@ -913,7 +913,7 @@ static short snap_bezier_nearest(KeyframeEditData * /*ked*/, BezTriple *bezt)
|
||||
static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
|
||||
{
|
||||
const Scene *scene = ked->scene;
|
||||
const float secf = float(FPS);
|
||||
const float secf = float(scene->frames_per_second());
|
||||
|
||||
if (bezt->f2 & SELECT) {
|
||||
BKE_fcurve_keyframe_move_time_with_handles(bezt, floorf(bezt->vec[1][0] / secf + 0.5f) * secf);
|
||||
|
||||
@@ -68,7 +68,8 @@ static void get_current_time_str(
|
||||
const Scene *scene, bool display_seconds, int frame, char *r_str, uint str_maxncpy)
|
||||
{
|
||||
if (display_seconds) {
|
||||
BLI_timecode_string_from_time(r_str, str_maxncpy, -1, FRA2TIME(frame), FPS, U.timecode_style);
|
||||
BLI_timecode_string_from_time(
|
||||
r_str, str_maxncpy, -1, FRA2TIME(frame), scene->frames_per_second(), U.timecode_style);
|
||||
}
|
||||
else {
|
||||
BLI_snprintf_utf8(r_str, str_maxncpy, "%d", frame);
|
||||
|
||||
@@ -501,7 +501,7 @@ static bool gpencil_frame_snap_nearest(bGPDframe * /*gpf*/, Scene * /*scene*/)
|
||||
|
||||
static bool gpencil_frame_snap_nearestsec(bGPDframe *gpf, Scene *scene)
|
||||
{
|
||||
float secf = float(FPS);
|
||||
float secf = float(scene->frames_per_second());
|
||||
if (gpf->flag & GP_FRAME_SELECT) {
|
||||
gpf->framenum = int(floorf(gpf->framenum / secf + 0.5f) * secf);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ static float view2d_major_step_y__continuous(const View2D *v2d)
|
||||
|
||||
static float view2d_major_step_x__time(const View2D *v2d, const Scene *scene)
|
||||
{
|
||||
const double fps = FPS;
|
||||
const double fps = scene->frames_per_second();
|
||||
|
||||
blender::Vector<float, 32> possible_distances;
|
||||
|
||||
@@ -419,12 +419,16 @@ static void view_to_string__time(
|
||||
const Scene *scene = (const Scene *)user_data;
|
||||
|
||||
int brevity_level = -1;
|
||||
if (U.timecode_style == USER_TIMECODE_MINIMAL && v2d_step >= FPS) {
|
||||
if (U.timecode_style == USER_TIMECODE_MINIMAL && v2d_step >= scene->frames_per_second()) {
|
||||
brevity_level = 1;
|
||||
}
|
||||
|
||||
BLI_timecode_string_from_time(
|
||||
r_str, str_maxncpy, brevity_level, v2d_pos / float(FPS), FPS, U.timecode_style);
|
||||
BLI_timecode_string_from_time(r_str,
|
||||
str_maxncpy,
|
||||
brevity_level,
|
||||
v2d_pos / float(scene->frames_per_second()),
|
||||
scene->frames_per_second(),
|
||||
U.timecode_style);
|
||||
}
|
||||
|
||||
static void view_to_string__value(
|
||||
|
||||
@@ -271,7 +271,7 @@ static bool snap_mask_layer_nearest(MaskLayerShape *mask_layer_shape, Scene * /*
|
||||
|
||||
static bool snap_mask_layer_nearestsec(MaskLayerShape *mask_layer_shape, Scene *scene)
|
||||
{
|
||||
float secf = float(FPS);
|
||||
float secf = float(scene->frames_per_second());
|
||||
if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
|
||||
mask_layer_shape->frame = int(floorf(mask_layer_shape->frame / secf + 0.5f) * secf);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ void ED_scene_fps_average_clear(Scene *scene)
|
||||
|
||||
void ED_scene_fps_average_accumulate(Scene *scene, const short fps_samples, const double ltime)
|
||||
{
|
||||
const float fps_target = float(FPS);
|
||||
const float fps_target = float(scene->frames_per_second());
|
||||
const int times_fps_num = (fps_samples > 0) ? fps_samples : max_ii(1, int(ceilf(fps_target)));
|
||||
|
||||
ScreenFrameRateInfo *fpsi = static_cast<ScreenFrameRateInfo *>(scene->fps_info);
|
||||
|
||||
@@ -1943,7 +1943,7 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable)
|
||||
if (enable) {
|
||||
ScreenAnimData *sad = MEM_callocN<ScreenAnimData>("ScreenAnimData");
|
||||
|
||||
screen->animtimer = WM_event_timer_add(wm, win, TIMER0, (1.0 / FPS));
|
||||
screen->animtimer = WM_event_timer_add(wm, win, TIMER0, (1.0 / scene->frames_per_second()));
|
||||
|
||||
sad->region = CTX_wm_region(C);
|
||||
sad->sfra = scene->r.cfra;
|
||||
|
||||
@@ -5650,7 +5650,7 @@ static wmOperatorStatus screen_animation_step_invoke(bContext *C,
|
||||
else if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false &&
|
||||
isfinite(time = BKE_sound_sync_scene(scene_eval)))
|
||||
{
|
||||
scene->r.cfra = round(time * FPS);
|
||||
scene->r.cfra = round(time * scene->frames_per_second());
|
||||
|
||||
#ifdef PROFILE_AUDIO_SYNC
|
||||
newfra_int = scene->r.cfra;
|
||||
@@ -5669,7 +5669,7 @@ static wmOperatorStatus screen_animation_step_invoke(bContext *C,
|
||||
/* Try to keep the playback in realtime by dropping frames. */
|
||||
|
||||
/* How much time (in frames) has passed since the last frame was drawn? */
|
||||
double delta_frames = wt->time_delta * FPS;
|
||||
double delta_frames = wt->time_delta * scene->frames_per_second();
|
||||
|
||||
/* Add the remaining fraction from the last time step. */
|
||||
delta_frames += sad->lagging_frame_count;
|
||||
@@ -5803,7 +5803,7 @@ static wmOperatorStatus screen_animation_step_invoke(bContext *C,
|
||||
*/
|
||||
/* TODO: this may make evaluation a bit slower if the value doesn't change...
|
||||
* any way to avoid this? */
|
||||
wt->time_step = (1.0 / FPS);
|
||||
wt->time_step = (1.0 / scene->frames_per_second());
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -1160,7 +1160,7 @@ static wmOperatorStatus graphkeys_sound_to_samples_exec(bContext *C, wmOperator
|
||||
RNA_boolean_get(op->ptr, "use_additive"),
|
||||
RNA_boolean_get(op->ptr, "use_square"),
|
||||
RNA_float_get(op->ptr, "sthreshold"),
|
||||
FPS,
|
||||
scene->frames_per_second(),
|
||||
&sbi.length,
|
||||
0);
|
||||
|
||||
|
||||
@@ -711,8 +711,12 @@ const char *ED_info_statusbar_string_ex(Main *bmain,
|
||||
const int relative_current_frame = (scene->r.cfra - scene->r.sfra) + 1;
|
||||
const int frame_count = (scene->r.efra - scene->r.sfra) + 1;
|
||||
char timecode[32];
|
||||
BLI_timecode_string_from_time(
|
||||
timecode, sizeof(timecode), -2, FRA2TIME(frame_count), FPS, U.timecode_style);
|
||||
BLI_timecode_string_from_time(timecode,
|
||||
sizeof(timecode),
|
||||
-2,
|
||||
FRA2TIME(frame_count),
|
||||
scene->frames_per_second(),
|
||||
U.timecode_style);
|
||||
ofs += BLI_snprintf_utf8_rlen(info + ofs,
|
||||
len - ofs,
|
||||
|
||||
|
||||
@@ -2390,7 +2390,7 @@ static wmOperatorStatus nlaedit_snap_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* get some necessary vars */
|
||||
scene = ac.scene;
|
||||
secf = float(FPS);
|
||||
secf = float(scene->frames_per_second());
|
||||
|
||||
bool any_added = false;
|
||||
|
||||
|
||||
@@ -591,7 +591,7 @@ static void slip_update_header(const Scene *scene,
|
||||
else {
|
||||
int frame_offset = std::trunc(offset);
|
||||
if (data->show_subframe) {
|
||||
float subframe_offset_sec = (offset - std::trunc(offset)) / FPS;
|
||||
float subframe_offset_sec = (offset - std::trunc(offset)) / scene->frames_per_second();
|
||||
SNPRINTF_UTF8(msg,
|
||||
IFACE_("Slip Offset: Frames: %d Sound Offset: %.3f"),
|
||||
frame_offset,
|
||||
@@ -3147,14 +3147,14 @@ static wmOperatorStatus sequencer_export_subtitles_exec(bContext *C, wmOperator
|
||||
sizeof(timecode_str_start),
|
||||
-2,
|
||||
FRA2TIME(max_ii(seq::time_left_handle_frame_get(scene, strip) - scene->r.sfra, 0)),
|
||||
FPS,
|
||||
scene->frames_per_second(),
|
||||
USER_TIMECODE_SUBRIP);
|
||||
BLI_timecode_string_from_time(
|
||||
timecode_str_end,
|
||||
sizeof(timecode_str_end),
|
||||
-2,
|
||||
FRA2TIME(seq::time_right_handle_frame_get(scene, strip) - scene->r.sfra),
|
||||
FPS,
|
||||
scene->frames_per_second(),
|
||||
USER_TIMECODE_SUBRIP);
|
||||
|
||||
fprintf(file,
|
||||
|
||||
@@ -222,7 +222,8 @@ static StripDrawContext strip_draw_context_get(TimelineDrawContext *ctx, Strip *
|
||||
|
||||
if (strip->type == STRIP_TYPE_SOUND_RAM && strip->sound != nullptr) {
|
||||
/* Visualize sub-frame sound offsets. */
|
||||
const double sound_offset = (strip->sound->offset_time + strip->sound_offset) * FPS;
|
||||
const double sound_offset = (strip->sound->offset_time + strip->sound_offset) *
|
||||
scene->frames_per_second();
|
||||
strip_ctx.content_start += sound_offset;
|
||||
strip_ctx.content_end += sound_offset;
|
||||
}
|
||||
@@ -483,7 +484,7 @@ static void draw_seq_waveform_overlay(TimelineDrawContext *timeline_ctx,
|
||||
SEQ_TIMELINE_WAVEFORMS_HALF) != 0;
|
||||
|
||||
const float frames_per_pixel = BLI_rctf_size_x(&v2d->cur) / timeline_ctx->region->winx;
|
||||
const float samples_per_frame = SOUND_WAVE_SAMPLES_PER_SECOND / FPS;
|
||||
const float samples_per_frame = SOUND_WAVE_SAMPLES_PER_SECOND / scene->frames_per_second();
|
||||
const float samples_per_pixel = samples_per_frame * frames_per_pixel;
|
||||
const float bottom = strip_ctx->bottom + timeline_ctx->pixely * 2.0f;
|
||||
const float top = strip_ctx->strip_content_top;
|
||||
@@ -500,8 +501,8 @@ static void draw_seq_waveform_overlay(TimelineDrawContext *timeline_ctx,
|
||||
const float draw_end_frame = min_ff(v2d->cur.xmax,
|
||||
strip_ctx->right_handle - timeline_ctx->pixelx * 3.0f);
|
||||
/* Offset must be also aligned, otherwise waveform flickers when moving left handle. */
|
||||
float sample_start_frame = draw_start_frame -
|
||||
(strip->sound->offset_time + strip->sound_offset) * FPS;
|
||||
float sample_start_frame = draw_start_frame - (strip->sound->offset_time + strip->sound_offset) *
|
||||
scene->frames_per_second();
|
||||
|
||||
const int pixels_to_draw = round_fl_to_int((draw_end_frame - draw_start_frame) /
|
||||
frames_per_pixel);
|
||||
|
||||
@@ -326,7 +326,7 @@ static void seq_view_collection_rect_timeline(const bContext *C,
|
||||
int xmax = -MAXFRAME * 2;
|
||||
int ymin = seq::MAX_CHANNELS + 1;
|
||||
int ymax = 0;
|
||||
int xmargin = FPS;
|
||||
int xmargin = scene->frames_per_second();
|
||||
|
||||
for (Strip *strip : strips) {
|
||||
xmin = min_ii(xmin, seq::time_left_handle_frame_get(scene, strip));
|
||||
|
||||
@@ -52,8 +52,8 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR])
|
||||
if (snap_mode == SCE_SNAP_TO_SECOND) {
|
||||
/* Convert to seconds. */
|
||||
const Scene *scene = t->scene;
|
||||
delta_x /= FPS;
|
||||
val /= FPS;
|
||||
delta_x /= scene->frames_per_second();
|
||||
val /= scene->frames_per_second();
|
||||
}
|
||||
|
||||
if (snap_mode == SCE_SNAP_TO_FRAME) {
|
||||
|
||||
@@ -48,10 +48,12 @@ void snapFrameTransform(TransInfo *t,
|
||||
}
|
||||
case SCE_SNAP_TO_SECOND: {
|
||||
if (snap_flag & SCE_SNAP_ABS_TIME_STEP) {
|
||||
*r_val_final = floorf((val_final / FPS) + 0.5) * FPS;
|
||||
*r_val_final = floorf((val_final / scene->frames_per_second()) + 0.5) *
|
||||
scene->frames_per_second();
|
||||
}
|
||||
else {
|
||||
deltax = float(floor((deltax / FPS) + 0.5) * FPS);
|
||||
deltax = float(floor((deltax / scene->frames_per_second()) + 0.5) *
|
||||
scene->frames_per_second());
|
||||
*r_val_final = val_initial + deltax;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -163,7 +163,7 @@ ABCArchive::ABCArchive(const Main *bmain,
|
||||
const std::string &filepath)
|
||||
: archive(nullptr)
|
||||
{
|
||||
double scene_fps = FPS;
|
||||
double scene_fps = scene->frames_per_second();
|
||||
MetaData abc_metadata = create_abc_metadata(bmain, scene_fps);
|
||||
|
||||
/* Create the Archive. */
|
||||
|
||||
@@ -615,8 +615,8 @@ static void set_frame_range(ImportJobData *data)
|
||||
scene->r.cfra = scene->r.sfra;
|
||||
}
|
||||
else if (data->min_time < data->max_time) {
|
||||
scene->r.sfra = int(round(data->min_time * FPS));
|
||||
scene->r.efra = int(round(data->max_time * FPS));
|
||||
scene->r.sfra = int(round(data->min_time * scene->frames_per_second()));
|
||||
scene->r.efra = int(round(data->max_time * scene->frames_per_second()));
|
||||
scene->r.cfra = scene->r.sfra;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ void importer_main(Main *bmain, Scene *scene, ViewLayer *view_layer, const FBXIm
|
||||
ctx.import_cameras();
|
||||
ctx.import_lights();
|
||||
ctx.import_empties();
|
||||
ctx.import_animation(FPS);
|
||||
ctx.import_animation(scene->frames_per_second());
|
||||
ctx.setup_hierarchy();
|
||||
|
||||
ufbx_free_scene(fbx);
|
||||
|
||||
@@ -503,7 +503,7 @@ pxr::UsdStageRefPtr export_to_stage(const USDExportParams ¶ms,
|
||||
|
||||
/* Set up the stage for animated data. */
|
||||
if (params.export_animation) {
|
||||
usd_stage->SetTimeCodesPerSecond(FPS);
|
||||
usd_stage->SetTimeCodesPerSecond(scene->frames_per_second());
|
||||
usd_stage->SetStartTimeCode(scene->r.sfra);
|
||||
usd_stage->SetEndTimeCode(scene->r.efra);
|
||||
}
|
||||
|
||||
@@ -2185,6 +2185,10 @@ typedef struct Scene {
|
||||
struct SceneHydra hydra;
|
||||
|
||||
SceneRuntimeHandle *runtime;
|
||||
#ifdef __cplusplus
|
||||
/* Return the frame rate of the scene. */
|
||||
double frames_per_second() const;
|
||||
#endif
|
||||
} Scene;
|
||||
|
||||
/** \} */
|
||||
@@ -2419,7 +2423,6 @@ extern const char *RE_engine_id_BLENDER_EEVEE_NEXT;
|
||||
#define PEFRA ((PRVRANGEON) ? (scene->r.pefra) : (scene->r.efra))
|
||||
#define FRA2TIME(a) ((((double)scene->r.frs_sec_base) * (double)(a)) / (double)scene->r.frs_sec)
|
||||
#define TIME2FRA(a) ((((double)scene->r.frs_sec) * (double)(a)) / (double)scene->r.frs_sec_base)
|
||||
#define FPS (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base)
|
||||
|
||||
/** \} */
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd,
|
||||
nullptr;
|
||||
float(*vertexCos)[3] = vertexCos_Store ? vertexCos_Store : vertexCos_Real;
|
||||
|
||||
const float fps = FPS;
|
||||
const float fps = scene->frames_per_second();
|
||||
|
||||
char filepath[FILE_MAX];
|
||||
const char *err_str = nullptr;
|
||||
|
||||
@@ -179,7 +179,8 @@ static void modify_geometry_set(ModifierData *md,
|
||||
CacheFile *cache_file = mcmd->cache_file;
|
||||
const double frame = double(DEG_get_ctime(ctx->depsgraph));
|
||||
const double frame_offset = BKE_cachefile_frame_offset(cache_file, frame);
|
||||
const double time_offset = BKE_cachefile_time_offset(cache_file, frame, FPS);
|
||||
const double time_offset = BKE_cachefile_time_offset(
|
||||
cache_file, frame, scene->frames_per_second());
|
||||
const char *err_str = nullptr;
|
||||
|
||||
if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) {
|
||||
@@ -222,7 +223,7 @@ static void modify_geometry_set(ModifierData *md,
|
||||
# ifdef WITH_ALEMBIC
|
||||
float velocity_scale = mcmd->velocity_scale;
|
||||
if (mcmd->cache_file->velocity_unit == CACHEFILE_VELOCITY_UNIT_FRAME) {
|
||||
velocity_scale *= FPS;
|
||||
velocity_scale *= scene->frames_per_second();
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -275,7 +276,8 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh
|
||||
CacheFile *cache_file = mcmd->cache_file;
|
||||
const double frame = double(DEG_get_ctime(ctx->depsgraph));
|
||||
const double frame_offset = BKE_cachefile_frame_offset(cache_file, frame);
|
||||
const double time_offset = BKE_cachefile_time_offset(cache_file, frame, FPS);
|
||||
const double time_offset = BKE_cachefile_time_offset(
|
||||
cache_file, frame, scene->frames_per_second());
|
||||
const char *err_str = nullptr;
|
||||
|
||||
if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) {
|
||||
|
||||
@@ -1178,7 +1178,7 @@ class NodesModifierSimulationParams : public nodes::GeoNodesSimulationParams {
|
||||
use_frame_cache_ = ctx_.object->flag & OB_FLAG_USE_SIMULATION_CACHE;
|
||||
depsgraph_is_active_ = DEG_is_active(depsgraph);
|
||||
modifier_cache_ = nmd.runtime->cache.get();
|
||||
fps_ = FPS;
|
||||
fps_ = scene->frames_per_second();
|
||||
|
||||
if (!modifier_cache_) {
|
||||
return;
|
||||
|
||||
@@ -62,7 +62,8 @@ static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene,
|
||||
int old = strip->len;
|
||||
float fac;
|
||||
|
||||
strip->len = std::max(1, int(round((info.length - strip->sound->offset_time) * FPS)));
|
||||
strip->len = std::max(
|
||||
1, int(round((info.length - strip->sound->offset_time) * scene->frames_per_second())));
|
||||
fac = float(strip->len) / float(old);
|
||||
old = strip->startofs;
|
||||
strip->startofs *= fac;
|
||||
|
||||
@@ -295,9 +295,10 @@ void add_sound_av_sync(Main *bmain, Scene *scene, Strip *strip, LoadData *load_d
|
||||
}
|
||||
|
||||
const double av_stream_offset = sound_stream.start - load_data->r_video_stream_start;
|
||||
const int frame_offset = av_stream_offset * FPS;
|
||||
const int frame_offset = av_stream_offset * scene->frames_per_second();
|
||||
/* Set sub-frame offset. */
|
||||
strip->sound->offset_time = (double(frame_offset) / FPS) - av_stream_offset;
|
||||
strip->sound->offset_time = (double(frame_offset) / scene->frames_per_second()) -
|
||||
av_stream_offset;
|
||||
transform_translate_strip(scene, strip, frame_offset);
|
||||
}
|
||||
|
||||
@@ -327,7 +328,8 @@ Strip *add_sound_strip(Main *bmain, Scene *scene, ListBase *seqbase, LoadData *l
|
||||
* nearest frame as the audio track usually overshoots or undershoots the
|
||||
* end frame of the video by a little bit.
|
||||
* See #47135 for under shoot example. */
|
||||
strip->len = std::max(1, int(round((info.length - sound->offset_time) * FPS)));
|
||||
strip->len = std::max(
|
||||
1, int(round((info.length - sound->offset_time) * scene->frames_per_second())));
|
||||
|
||||
StripData *data = strip->data;
|
||||
/* We only need 1 element to store the filename. */
|
||||
@@ -669,7 +671,8 @@ void add_reload_new_file(Main *bmain, Scene *scene, Strip *strip, const bool loc
|
||||
if (!strip->sound) {
|
||||
return;
|
||||
}
|
||||
strip->len = ceil(double(BKE_sound_get_length(bmain, strip->sound)) * FPS);
|
||||
strip->len = ceil(double(BKE_sound_get_length(bmain, strip->sound)) *
|
||||
scene->frames_per_second());
|
||||
strip->len -= strip->anim_startofs;
|
||||
strip->len -= strip->anim_endofs;
|
||||
strip->len = std::max(strip->len, 0);
|
||||
|
||||
@@ -560,7 +560,7 @@ static void strip_time_slip_strip_ex(const Scene *scene,
|
||||
bool recursed)
|
||||
{
|
||||
if (strip->type == STRIP_TYPE_SOUND_RAM && subframe_delta != 0.0f) {
|
||||
strip->sound_offset += subframe_delta / FPS;
|
||||
strip->sound_offset += subframe_delta / scene->frames_per_second();
|
||||
}
|
||||
|
||||
if (delta == 0 && (!slip_keyframes || subframe_delta == 0.0f)) {
|
||||
|
||||
Reference in New Issue
Block a user