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
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
@ -177,7 +177,7 @@ impl ApplicationContext {
let renderer = vulkano_windows
.get_renderer(self.window_id)
.expect("Failed to get renderer");
f(&renderer)
f(renderer)
}
/// 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");
let window_id = vulkano_windows.create_window(
event_loop,
&self.vulkan_context.vulkano_context(),
self.vulkan_context.vulkano_context(),
&WindowDescriptor {
title: "Rust ASH Test".to_string(),
width: 800.0,

View file

@ -40,11 +40,8 @@ impl InputManager {
}
pub fn process_device_event(&mut self, event: &DeviceEvent) {
match event {
DeviceEvent::MouseMotion { delta, .. } => {
self.mouse_position_delta += glam::Vec2::new(delta.0 as f32, delta.1 as f32);
}
_ => {}
if let DeviceEvent::MouseMotion { delta, .. } = event {
self.mouse_position_delta += glam::Vec2::new(delta.0 as f32, delta.1 as f32);
}
}
@ -75,7 +72,7 @@ impl InputManager {
MouseScrollDelta::PixelDelta(position) => {
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, _) => {
self.states_by_key
.entry(*key)
.or_insert(Vec::new())
.or_default()
.push(state.clone());
}
VirtualBinding::MouseX(_) | VirtualBinding::MouseY(_) => {
@ -67,7 +67,7 @@ impl VirtualInput {
VirtualBinding::MouseButton(button, _) => {
self.mouse_button_states
.entry(*button)
.or_insert(Vec::new())
.or_default()
.push(state.clone());
}
VirtualBinding::MouseWheelX(_) | VirtualBinding::MouseWheelY(_) => {
@ -76,7 +76,7 @@ impl VirtualInput {
VirtualBinding::Axis(axis, _, _) => {
self.axis_states
.entry(*axis)
.or_insert(Vec::new())
.or_default()
.push(state.clone());
}
}

View file

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

View file

@ -9,7 +9,7 @@ use vulkano::{
use crate::core::{input::InputManager, timer::Timer};
use super::mvp::MVP;
use super::mvp::Mvp;
// See docs/OPENGL_VULKAN_DIFF.md
const OPENGL_TO_VULKAN_Y_AXIS_FLIP: Mat4 = Mat4 {
@ -102,7 +102,7 @@ impl Camera3D {
pub fn create_buffer(
&self,
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_yaw, cos_yaw) = self.rotation.y.sin_cos();
@ -112,7 +112,7 @@ impl Camera3D {
Vec3::Y,
);
MVP {
Mvp {
model: OPENGL_TO_VULKAN_Y_AXIS_FLIP.to_cols_array_2d(),
view: view_matrix.to_cols_array_2d(),
projection: self.projection.to_cols_array_2d(),

View file

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

View file

@ -35,7 +35,7 @@ impl Default for Transform {
impl Transform {
pub fn rotate(&mut self, rotation: Quat) {
self.rotation = self.rotation * rotation;
self.rotation *= rotation;
}
pub fn translate(&mut self, translation: Vec3) {
@ -46,7 +46,7 @@ impl Transform {
self.scale *= scale;
}
pub fn into_raw(&self) -> TransformRaw {
pub fn to_raw_tranform(&self) -> TransformRaw {
TransformRaw {
model: (Mat4::from_translation(self.position)
* Mat4::from_quat(self.rotation)
@ -59,7 +59,8 @@ impl Transform {
memory_allocator: &Arc<StandardMemoryAllocator>,
transforms: &[Transform],
) -> 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(
memory_allocator.clone(),

View file

@ -78,7 +78,7 @@ impl Texture {
ImageCreateInfo {
image_type: ImageType::Dim2d,
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,
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
..Default::default()

View file

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

View file

@ -59,7 +59,7 @@ impl Scene for MainScene {
let num_instances = 100;
let instance_size = 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)
.map(|i| Transform {
position: Vec3::new(
@ -276,9 +276,7 @@ impl Scene for MainScene {
});
});
let render_future = gui.draw_on_image(render_future, swapchain_image_view.clone());
render_future
gui.draw_on_image(render_future, swapchain_image_view.clone())
});
Ok(render_future)