mirror of https://github.com/wayvr-org/wayvr.git
resize lerp
This commit is contained in:
parent
4cf84e19f0
commit
df1cf668a0
|
|
@ -146,7 +146,7 @@ pub enum TickTask {
|
|||
|
||||
const KEY_REPEAT_DELAY: i32 = 200;
|
||||
const KEY_REPEAT_RATE: i32 = 50;
|
||||
const WAYVR_SCREEN_RES: [i32; 2] = [2560, 2560];
|
||||
const WAYVR_SCREEN_RES: [i32; 2] = [2048, 2048];
|
||||
|
||||
impl WvrServerState {
|
||||
pub fn new(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ pub struct Window {
|
|||
}
|
||||
|
||||
impl Window {
|
||||
const fn new(
|
||||
fn new(
|
||||
toplevel: Rc<ToplevelSurface>,
|
||||
process: process::ProcessHandle,
|
||||
bounds: Size<i32, Logical>,
|
||||
|
|
@ -29,7 +29,7 @@ impl Window {
|
|||
Self {
|
||||
bounds,
|
||||
min_size,
|
||||
max_size,
|
||||
max_size: max_size.clamp(Size::new(160, 160), bounds),
|
||||
size_x: 0,
|
||||
size_y: 0,
|
||||
visible: true,
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ enum ResizeState {
|
|||
pointer: usize,
|
||||
start_uv: Vec2,
|
||||
last_uv: Vec2,
|
||||
last_extent: [u32; 2],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -271,17 +272,26 @@ impl OverlayBackend for EditModeBackendWrapper {
|
|||
pointer,
|
||||
start_uv,
|
||||
last_uv,
|
||||
last_extent,
|
||||
} if *pointer == hit.pointer => {
|
||||
fn lerp_u32(a: [u32; 2], b: [u32; 2], t: f32) -> [u32; 2] {
|
||||
[
|
||||
(a[0] as f32 + (b[0] as f32 - a[0] as f32) * t).round() as u32,
|
||||
(a[1] as f32 + (b[1] as f32 - a[1] as f32) * t).round() as u32,
|
||||
]
|
||||
}
|
||||
|
||||
// freshest extent we can get is from last frame, so use uv from that frame
|
||||
let new_extent = resize_centered_from_uv(*start_uv, *last_uv, self.extent);
|
||||
let want_extent = resize_centered_from_uv(*start_uv, *last_uv, self.extent);
|
||||
|
||||
app.tasks
|
||||
.enqueue(TaskType::Overlay(OverlayTask::ResizeOverlay(
|
||||
OverlaySelector::Id(*overlay_id),
|
||||
new_extent,
|
||||
lerp_u32(*last_extent, want_extent, 0.33),
|
||||
)));
|
||||
|
||||
*last_uv = hit.uv;
|
||||
*last_extent = self.extent;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -317,6 +327,7 @@ impl OverlayBackend for EditModeBackendWrapper {
|
|||
pointer: hit.pointer,
|
||||
start_uv: last_uv,
|
||||
last_uv: last_uv,
|
||||
last_extent: self.extent,
|
||||
};
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue