summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-25 01:09:28 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-25 01:09:28 +0100
commit0163f8486ceca8bd6897c1074f6846f36827d040 (patch)
tree16656b39011328c2ee9bda11730616afafe8fe18
parent1caf7aefcc29602a21fa8a400c897b576be238a8 (diff)
downloadweareserver-0163f8486ceca8bd6897c1074f6846f36827d040.tar
weareserver-0163f8486ceca8bd6897c1074f6846f36827d040.tar.bz2
weareserver-0163f8486ceca8bd6897c1074f6846f36827d040.tar.zst
funny cursor animation
-rw-r--r--client/src/render/mod.rs2
-rw-r--r--client/src/render/scene/mod.rs1
-rw-r--r--client/src/window.rs15
3 files changed, 16 insertions, 2 deletions
diff --git a/client/src/render/mod.rs b/client/src/render/mod.rs
index c3ee7da..6964337 100644
--- a/client/src/render/mod.rs
+++ b/client/src/render/mod.rs
@@ -43,7 +43,7 @@ pub struct Renderer<'a> {
surface: Surface<'a>,
queue: Arc<Queue>,
device: Arc<Device>,
- surface_configuration: SurfaceConfiguration,
+ pub surface_configuration: SurfaceConfiguration,
scene_pipeline: ScenePipeline,
pub ui_renderer: UiRenderer,
pub scene_prepare: Arc<ScenePreparer>,
diff --git a/client/src/render/scene/mod.rs b/client/src/render/scene/mod.rs
index 96c8ba4..7471fc8 100644
--- a/client/src/render/scene/mod.rs
+++ b/client/src/render/scene/mod.rs
@@ -145,7 +145,6 @@ impl ScenePreparer {
downloader: Arc<Downloader>,
) -> Self {
Self {
- // TODO normal mipmap requires linear texture, also demand map?
render_format,
config: GraphicsConfig {
max_anisotropy: 16,
diff --git a/client/src/window.rs b/client/src/window.rs
index 68ca25b..05035c4 100644
--- a/client/src/window.rs
+++ b/client/src/window.rs
@@ -20,6 +20,7 @@ use log::{info, warn};
use std::net::TcpStream;
use winit::{
application::ApplicationHandler,
+ dpi::LogicalPosition,
event::{DeviceEvent, ElementState, WindowEvent},
event_loop::ActiveEventLoop,
keyboard::{KeyCode, PhysicalKey},
@@ -64,6 +65,19 @@ impl ApplicationHandler for WindowState {
sta.resize(size.width, size.height);
}
WindowEvent::RedrawRequested => {
+ if self.lock {
+ let size = vec2(
+ sta.renderer.surface_configuration.width as f32,
+ sta.renderer.surface_configuration.height as f32,
+ );
+ let center = size / 2.;
+ let dt = 0.008_f32;
+ let h = center + (sta.input_state.cursor_pos - center) * (-dt).exp();
+ sta.input_state.cursor_pos = h;
+ win.set_cursor_visible(center.distance(sta.input_state.cursor_pos) > 5.);
+ win.set_cursor_position(LogicalPosition::new(h.x, h.y))
+ .unwrap();
+ }
sta.draw();
win.request_redraw();
}
@@ -81,6 +95,7 @@ impl ApplicationHandler for WindowState {
})
.unwrap();
self.lock = !self.lock;
+ win.set_cursor_visible(!self.lock);
}
_ => (),
}