some cleanup from clippy
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 9m20s

This commit is contained in:
Florian RICHER 2025-05-30 22:21:34 +02:00
parent b1458785e5
commit 1568223b9d
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
11 changed files with 30 additions and 38 deletions

View file

@ -148,7 +148,7 @@ impl ApplicationContext {
/// Récupère les résolutions disponibles /// Récupère les résolutions disponibles
pub fn get_available_resolutions(&self) -> Vec<(u32, u32)> { pub fn get_available_resolutions(&self) -> Vec<(u32, u32)> {
self.with_renderer(|renderer| Self::get_monitor_resolutions(&renderer.window())) self.with_renderer(|renderer| Self::get_monitor_resolutions(renderer.window()))
} }
/// Récupère le delta time actuel depuis le timer /// Récupère le delta time actuel depuis le timer
@ -177,7 +177,7 @@ impl ApplicationContext {
let renderer = vulkano_windows let renderer = vulkano_windows
.get_renderer(self.window_id) .get_renderer(self.window_id)
.expect("Failed to get renderer"); .expect("Failed to get renderer");
f(&renderer) f(renderer)
} }
/// Méthode utilitaire pour accéder au renderer de manière thread-safe /// Méthode utilitaire pour accéder au renderer de manière thread-safe

View file

@ -65,7 +65,7 @@ impl ApplicationHandler<UserEvent> for App {
.expect("Failed to lock vulkano_windows"); .expect("Failed to lock vulkano_windows");
let window_id = vulkano_windows.create_window( let window_id = vulkano_windows.create_window(
event_loop, event_loop,
&self.vulkan_context.vulkano_context(), self.vulkan_context.vulkano_context(),
&WindowDescriptor { &WindowDescriptor {
title: "Rust ASH Test".to_string(), title: "Rust ASH Test".to_string(),
width: 800.0, width: 800.0,

View file

@ -40,11 +40,8 @@ impl InputManager {
} }
pub fn process_device_event(&mut self, event: &DeviceEvent) { pub fn process_device_event(&mut self, event: &DeviceEvent) {
match event { if let DeviceEvent::MouseMotion { delta, .. } = event {
DeviceEvent::MouseMotion { delta, .. } => { self.mouse_position_delta += glam::Vec2::new(delta.0 as f32, delta.1 as f32);
self.mouse_position_delta += glam::Vec2::new(delta.0 as f32, delta.1 as f32);
}
_ => {}
} }
} }
@ -75,7 +72,7 @@ impl InputManager {
MouseScrollDelta::PixelDelta(position) => { MouseScrollDelta::PixelDelta(position) => {
glam::Vec2::new(position.x as f32, position.y as f32) glam::Vec2::new(position.x as f32, position.y as f32)
} }
MouseScrollDelta::LineDelta(x, y) => glam::Vec2::new(*x as f32, *y as f32), MouseScrollDelta::LineDelta(x, y) => glam::Vec2::new(*x, *y),
}; };
} }
_ => {} _ => {}

View file

@ -58,7 +58,7 @@ impl VirtualInput {
VirtualBinding::Keyboard(key, _) => { VirtualBinding::Keyboard(key, _) => {
self.states_by_key self.states_by_key
.entry(*key) .entry(*key)
.or_insert(Vec::new()) .or_default()
.push(state.clone()); .push(state.clone());
} }
VirtualBinding::MouseX(_) | VirtualBinding::MouseY(_) => { VirtualBinding::MouseX(_) | VirtualBinding::MouseY(_) => {
@ -67,7 +67,7 @@ impl VirtualInput {
VirtualBinding::MouseButton(button, _) => { VirtualBinding::MouseButton(button, _) => {
self.mouse_button_states self.mouse_button_states
.entry(*button) .entry(*button)
.or_insert(Vec::new()) .or_default()
.push(state.clone()); .push(state.clone());
} }
VirtualBinding::MouseWheelX(_) | VirtualBinding::MouseWheelY(_) => { VirtualBinding::MouseWheelX(_) | VirtualBinding::MouseWheelY(_) => {
@ -76,7 +76,7 @@ impl VirtualInput {
VirtualBinding::Axis(axis, _, _) => { VirtualBinding::Axis(axis, _, _) => {
self.axis_states self.axis_states
.entry(*axis) .entry(*axis)
.or_insert(Vec::new()) .or_default()
.push(state.clone()); .push(state.clone());
} }
} }

View file

@ -70,17 +70,14 @@ impl VirtualInputState {
pub fn update_from_mouse_button(&mut self, button: MouseButton, button_state: ElementState) { pub fn update_from_mouse_button(&mut self, button: MouseButton, button_state: ElementState) {
let mut new_value = 0.0; let mut new_value = 0.0;
for binding in &mut self.bindings { for binding in &mut self.bindings {
match &binding.binding { if let VirtualBinding::MouseButton(binding_button, direction) = &binding.binding {
VirtualBinding::MouseButton(binding_button, direction) => { if binding_button == &button {
if binding_button == &button { if button_state == ElementState::Pressed {
if button_state == ElementState::Pressed { binding.value = f32::from(direction);
binding.value = f32::from(direction); } else {
} else { binding.value = 0.0;
binding.value = 0.0;
}
} }
} }
_ => {}
} }
new_value += binding.value; new_value += binding.value;
} }

View file

@ -9,7 +9,7 @@ use vulkano::{
use crate::core::{input::InputManager, timer::Timer}; use crate::core::{input::InputManager, timer::Timer};
use super::mvp::MVP; use super::mvp::Mvp;
// See docs/OPENGL_VULKAN_DIFF.md // See docs/OPENGL_VULKAN_DIFF.md
const OPENGL_TO_VULKAN_Y_AXIS_FLIP: Mat4 = Mat4 { const OPENGL_TO_VULKAN_Y_AXIS_FLIP: Mat4 = Mat4 {
@ -102,7 +102,7 @@ impl Camera3D {
pub fn create_buffer( pub fn create_buffer(
&self, &self,
memory_allocator: &Arc<StandardMemoryAllocator>, memory_allocator: &Arc<StandardMemoryAllocator>,
) -> Result<Subbuffer<[MVP]>, Validated<AllocateBufferError>> { ) -> Result<Subbuffer<[Mvp]>, Validated<AllocateBufferError>> {
let (sin_pitch, cos_pitch) = self.rotation.x.sin_cos(); let (sin_pitch, cos_pitch) = self.rotation.x.sin_cos();
let (sin_yaw, cos_yaw) = self.rotation.y.sin_cos(); let (sin_yaw, cos_yaw) = self.rotation.y.sin_cos();
@ -112,7 +112,7 @@ impl Camera3D {
Vec3::Y, Vec3::Y,
); );
MVP { Mvp {
model: OPENGL_TO_VULKAN_Y_AXIS_FLIP.to_cols_array_2d(), model: OPENGL_TO_VULKAN_Y_AXIS_FLIP.to_cols_array_2d(),
view: view_matrix.to_cols_array_2d(), view: view_matrix.to_cols_array_2d(),
projection: self.projection.to_cols_array_2d(), projection: self.projection.to_cols_array_2d(),

View file

@ -1,6 +1,5 @@
use std::sync::Arc; use std::sync::Arc;
use glam::Mat4;
use vulkano::Validated; use vulkano::Validated;
use vulkano::buffer::{ use vulkano::buffer::{
AllocateBufferError, Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer, AllocateBufferError, Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer,
@ -9,17 +8,17 @@ use vulkano::memory::allocator::{AllocationCreateInfo, MemoryTypeFilter, Standar
#[derive(BufferContents, Clone, Copy)] #[derive(BufferContents, Clone, Copy)]
#[repr(C)] #[repr(C)]
pub struct MVP { pub struct Mvp {
pub model: [[f32; 4]; 4], pub model: [[f32; 4]; 4],
pub view: [[f32; 4]; 4], pub view: [[f32; 4]; 4],
pub projection: [[f32; 4]; 4], pub projection: [[f32; 4]; 4],
} }
impl MVP { impl Mvp {
pub fn into_buffer( pub fn into_buffer(
self, self,
memory_allocator: &Arc<StandardMemoryAllocator>, memory_allocator: &Arc<StandardMemoryAllocator>,
) -> Result<Subbuffer<[MVP]>, Validated<AllocateBufferError>> { ) -> Result<Subbuffer<[Mvp]>, Validated<AllocateBufferError>> {
Buffer::from_iter( Buffer::from_iter(
memory_allocator.clone(), memory_allocator.clone(),
BufferCreateInfo { BufferCreateInfo {

View file

@ -35,7 +35,7 @@ impl Default for Transform {
impl Transform { impl Transform {
pub fn rotate(&mut self, rotation: Quat) { pub fn rotate(&mut self, rotation: Quat) {
self.rotation = self.rotation * rotation; self.rotation *= rotation;
} }
pub fn translate(&mut self, translation: Vec3) { pub fn translate(&mut self, translation: Vec3) {
@ -46,7 +46,7 @@ impl Transform {
self.scale *= scale; self.scale *= scale;
} }
pub fn into_raw(&self) -> TransformRaw { pub fn to_raw_tranform(&self) -> TransformRaw {
TransformRaw { TransformRaw {
model: (Mat4::from_translation(self.position) model: (Mat4::from_translation(self.position)
* Mat4::from_quat(self.rotation) * Mat4::from_quat(self.rotation)
@ -59,7 +59,8 @@ impl Transform {
memory_allocator: &Arc<StandardMemoryAllocator>, memory_allocator: &Arc<StandardMemoryAllocator>,
transforms: &[Transform], transforms: &[Transform],
) -> Result<Subbuffer<[TransformRaw]>, Validated<AllocateBufferError>> { ) -> Result<Subbuffer<[TransformRaw]>, Validated<AllocateBufferError>> {
let transform_raws: Vec<TransformRaw> = transforms.iter().map(|t| t.into_raw()).collect(); let transform_raws: Vec<TransformRaw> =
transforms.iter().map(|t| t.to_raw_tranform()).collect();
let buffer = Buffer::from_iter( let buffer = Buffer::from_iter(
memory_allocator.clone(), memory_allocator.clone(),

View file

@ -78,7 +78,7 @@ impl Texture {
ImageCreateInfo { ImageCreateInfo {
image_type: ImageType::Dim2d, image_type: ImageType::Dim2d,
format: Format::R8G8B8A8_SRGB, format: Format::R8G8B8A8_SRGB,
extent: [image_dimensions.0 as u32, image_dimensions.1 as u32, 1], extent: [image_dimensions.0, image_dimensions.1, 1],
array_layers: 1, array_layers: 1,
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED, usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
..Default::default() ..Default::default()

View file

@ -31,7 +31,7 @@ use vulkano::{
}; };
use crate::core::render::{ use crate::core::render::{
primitives::{mvp::MVP, transform::TransformRaw, vertex::Vertex3D}, primitives::{mvp::Mvp, transform::TransformRaw, vertex::Vertex3D},
texture::Texture, texture::Texture,
}; };
@ -214,7 +214,7 @@ impl Square {
&self, &self,
command_buffer: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>, command_buffer: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
descriptor_set_allocator: &Arc<StandardDescriptorSetAllocator>, descriptor_set_allocator: &Arc<StandardDescriptorSetAllocator>,
mvp_uniform: &Subbuffer<[MVP]>, mvp_uniform: &Subbuffer<[Mvp]>,
transform_uniform: &Subbuffer<[TransformRaw]>, transform_uniform: &Subbuffer<[TransformRaw]>,
texture: &Texture, texture: &Texture,
) -> Result<(), Box<dyn Error>> { ) -> Result<(), Box<dyn Error>> {

View file

@ -59,7 +59,7 @@ impl Scene for MainScene {
let num_instances = 100; let num_instances = 100;
let instance_size = 10.0; let instance_size = 10.0;
let instance_spacing = 10.0; let instance_spacing = 10.0;
let num_instances_per_row = (num_instances as f32 / instance_spacing as f32).ceil() as u32; let num_instances_per_row = (num_instances as f32 / instance_spacing).ceil() as u32;
let instances: Vec<Transform> = (0..num_instances) let instances: Vec<Transform> = (0..num_instances)
.map(|i| Transform { .map(|i| Transform {
position: Vec3::new( position: Vec3::new(
@ -276,9 +276,7 @@ impl Scene for MainScene {
}); });
}); });
let render_future = gui.draw_on_image(render_future, swapchain_image_view.clone()); gui.draw_on_image(render_future, swapchain_image_view.clone())
render_future
}); });
Ok(render_future) Ok(render_future)