From bd5713febf43703c193c1de0118f6c87fbc54148 Mon Sep 17 00:00:00 2001 From: nullprop Date: Fri, 27 Jan 2023 02:40:40 +0200 Subject: [PATCH] remove unused instance code --- src/core/state.rs | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/src/core/state.rs b/src/core/state.rs index f25a592..341d566 100644 --- a/src/core/state.rs +++ b/src/core/state.rs @@ -12,8 +12,6 @@ use super::resources; use super::texture::Texture; use crate::shaders::preprocessor::preprocess_wgsl; -const NUM_INSTANCES_PER_ROW: u32 = 1; - pub struct State { pub size: winit::dpi::PhysicalSize, @@ -220,40 +218,10 @@ impl State { .await .unwrap(); - let instances: Vec; - if NUM_INSTANCES_PER_ROW > 1 { - const SPACE_BETWEEN: f32 = 3.0; - instances = (0..NUM_INSTANCES_PER_ROW) - .flat_map(|z| { - (0..NUM_INSTANCES_PER_ROW).map(move |x| { - let x = SPACE_BETWEEN * (x as f32 - NUM_INSTANCES_PER_ROW as f32 / 2.0); - let z = SPACE_BETWEEN * (z as f32 - NUM_INSTANCES_PER_ROW as f32 / 2.0); - - let position = cgmath::Vector3 { x, y: 0.0, z }; - - let rotation = if position.is_zero() { - cgmath::Quaternion::from_axis_angle( - cgmath::Vector3::unit_z(), - cgmath::Deg(0.0), - ) - } else { - cgmath::Quaternion::from_axis_angle( - position.normalize(), - cgmath::Deg(45.0), - ) - }; - - Instance { position, rotation } - }) - }) - .collect::>(); - } else { - instances = [Instance { - position: [0.0, 0.0, 0.0].into(), - rotation: cgmath::Quaternion::one(), - }] - .into(); - } + let instances = vec![Instance { + position: [0.0, 0.0, 0.0].into(), + rotation: cgmath::Quaternion::one(), + }]; let instance_data = instances.iter().map(Instance::to_raw).collect::>(); let instance_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {