remove unused instance code
This commit is contained in:
parent
f6b0754570
commit
bd5713febf
1 changed files with 4 additions and 36 deletions
|
@ -12,8 +12,6 @@ use super::resources;
|
||||||
use super::texture::Texture;
|
use super::texture::Texture;
|
||||||
use crate::shaders::preprocessor::preprocess_wgsl;
|
use crate::shaders::preprocessor::preprocess_wgsl;
|
||||||
|
|
||||||
const NUM_INSTANCES_PER_ROW: u32 = 1;
|
|
||||||
|
|
||||||
pub struct State {
|
pub struct State {
|
||||||
pub size: winit::dpi::PhysicalSize<u32>,
|
pub size: winit::dpi::PhysicalSize<u32>,
|
||||||
|
|
||||||
|
@ -220,40 +218,10 @@ impl State {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let instances: Vec<Instance>;
|
let instances = vec![Instance {
|
||||||
if NUM_INSTANCES_PER_ROW > 1 {
|
position: [0.0, 0.0, 0.0].into(),
|
||||||
const SPACE_BETWEEN: f32 = 3.0;
|
rotation: cgmath::Quaternion::one(),
|
||||||
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::<Vec<_>>();
|
|
||||||
} else {
|
|
||||||
instances = [Instance {
|
|
||||||
position: [0.0, 0.0, 0.0].into(),
|
|
||||||
rotation: cgmath::Quaternion::one(),
|
|
||||||
}]
|
|
||||||
.into();
|
|
||||||
}
|
|
||||||
|
|
||||||
let instance_data = instances.iter().map(Instance::to_raw).collect::<Vec<_>>();
|
let instance_data = instances.iter().map(Instance::to_raw).collect::<Vec<_>>();
|
||||||
let instance_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
let instance_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue