Skip to content

Commit

Permalink
Fix redrawing causing stutters
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurBrussee committed Nov 15, 2024
1 parent 8338ea9 commit faed9fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/brush-viewer/src/orbit_controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ impl OrbitControls {
let rot_matrix = Mat3::from_quat(camera.rotation);
camera.position = self.focus + rot_matrix.mul_vec3(Vec3::new(0.0, 0.0, -radius));
}

pub fn is_animating(&self) -> bool {
self.pan_momentum.length_squared() > 0.001 || self.rotate_momentum.length_squared() > 0.001
}
}
8 changes: 7 additions & 1 deletion crates/brush-viewer/src/panels/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ impl ScenePanel {
}
self.last_draw = Some(cur_time);

// Also redraw next frame, need to check if we're still animating.
if self.dirty {
ui.ctx().request_repaint();
}

// If this viewport is re-rendering.
if ui.ctx().has_requested_repaint() && self.dirty {
if ui.ctx().has_requested_repaint() {
let _span = trace_span!("Render splats").entered();
let (img, _) = splats.render(&context.camera, size, true);
self.backbuffer.update_texture(img, self.renderer.clone());
Expand Down Expand Up @@ -220,6 +225,7 @@ For bigger training runs consider using the native app."#,
context.camera.rotation,
context.camera.position,
)
|| context.controls.is_animating()
{
self.dirty = true;
}
Expand Down

0 comments on commit faed9fb

Please sign in to comment.