Disable time smoothing
This commit is contained in:
2 files changed
+16
-10
No files matched your search
@@ -438,7 +438,7 @@ impl NeoMediaSender {
|
||||
pub(super) fn new() -> Self {
|
||||
let (tx, rx) = channel(30);
|
||||
Self {
|
||||
start_time: Spring::new(0.0, 0.0, 10.0),
|
||||
start_time: Spring::new(0.0, 0.0, 0.0),
|
||||
live_offset: 0,
|
||||
buffer: NeoBuffer::default(),
|
||||
vid: None,
|
||||
@@ -510,9 +510,9 @@ impl NeoMediaSender {
|
||||
async fn update_starttime(&mut self) -> AnyResult<()> {
|
||||
self.start_time.update().await;
|
||||
|
||||
if let (Some(runtime), Some(target_time)) = (self.get_runtime(), self.target_live()) {
|
||||
self.start_time.set_target((target_time - runtime) as f64);
|
||||
}
|
||||
// if let (Some(runtime), Some(target_time)) = (self.get_runtime(), self.target_live()) {
|
||||
// self.start_time.set_target((target_time - runtime) as f64);
|
||||
// }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
+12
-6
@@ -54,6 +54,7 @@ impl Spring {
|
||||
.min(std::u64::MAX as f64) as u64
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn set_target(&mut self, target: f64) {
|
||||
self.target = target;
|
||||
}
|
||||
@@ -83,11 +84,16 @@ fn fast_negexp(x: f64) -> f64 {
|
||||
}
|
||||
|
||||
fn spring_update(value: &mut f64, target: f64, velocity: &mut f64, halflife: f64, dt: f64) {
|
||||
let y = halflife_to_damping(halflife) / 2.0;
|
||||
let j0 = *value - target;
|
||||
let j1 = *velocity + j0 * y;
|
||||
let eydt = fast_negexp(y * dt);
|
||||
if halflife.abs() < 1e-3 {
|
||||
*value = target;
|
||||
*velocity = 0.0;
|
||||
} else {
|
||||
let y = halflife_to_damping(halflife) / 2.0;
|
||||
let j0 = *value - target;
|
||||
let j1 = *velocity + j0 * y;
|
||||
let eydt = fast_negexp(y * dt);
|
||||
|
||||
*value = eydt * (j0 + j1 * dt) + target;
|
||||
*velocity = eydt * (*velocity - j1 * y * dt);
|
||||
*value = eydt * (j0 + j1 * dt) + target;
|
||||
*velocity = eydt * (*velocity - j1 * y * dt);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user