/**************************************************************************/ /* main_timer_sync.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #include "main_timer_sync.h" #include "core/os/os.h" #include "servers/display_server.h" void MainFrameTime::clamp_process_step(double min_process_step, double max_process_step) { … } ///////////////////////////////// void MainTimerSync::DeltaSmoother::update_refresh_rate_estimator(int64_t p_delta) { … } bool MainTimerSync::DeltaSmoother::fps_allows_smoothing(int64_t p_delta) { … } int64_t MainTimerSync::DeltaSmoother::smooth_delta(int64_t p_delta) { … } ///////////////////////////////////// // returns the fraction of p_physics_step required for the timer to overshoot // before advance_core considers changing the physics_steps return from // the typical values as defined by typical_physics_steps double MainTimerSync::get_physics_jitter_fix() { … } // gets our best bet for the average number of physics steps per render frame // return value: number of frames back this data is consistent int MainTimerSync::get_average_physics_steps(double &p_min, double &p_max) { … } // advance physics clock by p_process_step, return appropriate number of steps to simulate MainFrameTime MainTimerSync::advance_core(double p_physics_step, int p_physics_ticks_per_second, double p_process_step) { … } // calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero MainFrameTime MainTimerSync::advance_checked(double p_physics_step, int p_physics_ticks_per_second, double p_process_step) { … } // determine wall clock step since last iteration double MainTimerSync::get_cpu_process_step() { … } MainTimerSync::MainTimerSync() { … } // start the clock void MainTimerSync::init(uint64_t p_cpu_ticks_usec) { … } // set measured wall clock time void MainTimerSync::set_cpu_ticks_usec(uint64_t p_cpu_ticks_usec) { … } void MainTimerSync::set_fixed_fps(int p_fixed_fps) { … } // advance one physics frame, return timesteps to take MainFrameTime MainTimerSync::advance(double p_physics_step, int p_physics_ticks_per_second) { … }