mirror of
https://github.com/bevyengine/bevy
synced 2024-11-24 21:53:07 +00:00
rustfmt: use field init shorthand
This commit is contained in:
parent
76d5f6057c
commit
a721f3595d
11 changed files with 21 additions and 29 deletions
|
@ -1 +1,2 @@
|
||||||
merge_imports = true
|
merge_imports = true
|
||||||
|
use_field_init_shorthand = true
|
|
@ -14,7 +14,7 @@ impl Asset<TextureType> for Texture {
|
||||||
TextureType::Data(data) => data.clone(),
|
TextureType::Data(data) => data.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture { data: data }
|
Texture { data }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl ForwardInstancedPipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
instance_buffer_infos.push(InstanceBufferInfo {
|
instance_buffer_infos.push(InstanceBufferInfo {
|
||||||
mesh_id: mesh_id,
|
mesh_id,
|
||||||
buffer: temp_buf_data.finish(),
|
buffer: temp_buf_data.finish(),
|
||||||
instance_count: entity_count,
|
instance_count: entity_count,
|
||||||
});
|
});
|
||||||
|
@ -126,7 +126,7 @@ impl ForwardInstancedPipeline {
|
||||||
let mut instance_buffer_infos = Vec::new();
|
let mut instance_buffer_infos = Vec::new();
|
||||||
instance_buffer_infos.push(InstanceBufferInfo {
|
instance_buffer_infos.push(InstanceBufferInfo {
|
||||||
mesh_id: last_mesh_id.unwrap(),
|
mesh_id: last_mesh_id.unwrap(),
|
||||||
buffer: buffer,
|
buffer,
|
||||||
instance_count: entities_count,
|
instance_count: entities_count,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ impl UiPipeline {
|
||||||
|
|
||||||
let mut instance_buffer_infos = Vec::new();
|
let mut instance_buffer_infos = Vec::new();
|
||||||
instance_buffer_infos.push(InstanceBufferInfo {
|
instance_buffer_infos.push(InstanceBufferInfo {
|
||||||
mesh_id: mesh_id,
|
mesh_id,
|
||||||
buffer: buffer,
|
buffer,
|
||||||
instance_count: data.len(),
|
instance_count: data.len(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ impl WgpuRenderer {
|
||||||
{
|
{
|
||||||
let buffer = self.buffers.get(&b.name).unwrap();
|
let buffer = self.buffers.get(&b.name).unwrap();
|
||||||
wgpu::BindingResource::Buffer {
|
wgpu::BindingResource::Buffer {
|
||||||
buffer: buffer,
|
buffer,
|
||||||
range: 0..*size,
|
range: 0..*size,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -370,16 +370,13 @@ impl WgpuRenderer {
|
||||||
|
|
||||||
let buffer_usage = wgpu::BufferUsage::COPY_DST | wgpu::BufferUsage::UNIFORM;
|
let buffer_usage = wgpu::BufferUsage::COPY_DST | wgpu::BufferUsage::UNIFORM;
|
||||||
let buffer = self.device.create_buffer(&wgpu::BufferDescriptor {
|
let buffer = self.device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
size: size,
|
size,
|
||||||
usage: buffer_usage,
|
usage: buffer_usage,
|
||||||
});
|
});
|
||||||
|
|
||||||
self.resource_info.insert(
|
self.resource_info.insert(
|
||||||
name.to_string(),
|
name.to_string(),
|
||||||
ResourceInfo::Buffer {
|
ResourceInfo::Buffer { buffer_usage, size },
|
||||||
buffer_usage,
|
|
||||||
size: size,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
self.buffers.insert(name.to_string(), buffer);
|
self.buffers.insert(name.to_string(), buffer);
|
||||||
|
@ -553,17 +550,11 @@ impl Renderer for WgpuRenderer {
|
||||||
|
|
||||||
fn create_buffer(&mut self, name: &str, size: u64, buffer_usage: wgpu::BufferUsage) {
|
fn create_buffer(&mut self, name: &str, size: u64, buffer_usage: wgpu::BufferUsage) {
|
||||||
let buffer = self.device.create_buffer(&wgpu::BufferDescriptor {
|
let buffer = self.device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
size: size,
|
size,
|
||||||
usage: buffer_usage,
|
usage: buffer_usage,
|
||||||
});
|
});
|
||||||
|
|
||||||
self.add_resource_info(
|
self.add_resource_info(name, ResourceInfo::Buffer { buffer_usage, size });
|
||||||
name,
|
|
||||||
ResourceInfo::Buffer {
|
|
||||||
buffer_usage,
|
|
||||||
size: size,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
self.buffers.insert(name.to_string(), buffer);
|
self.buffers.insert(name.to_string(), buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl LightResourceProvider {
|
||||||
pub fn new(max_lights: usize) -> Self {
|
pub fn new(max_lights: usize) -> Self {
|
||||||
LightResourceProvider {
|
LightResourceProvider {
|
||||||
lights_are_dirty: true,
|
lights_are_dirty: true,
|
||||||
max_lights: max_lights,
|
max_lights,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl RenderResourceManager for Global2dResourceManager {
|
||||||
);
|
);
|
||||||
|
|
||||||
let uniform_buffer = UniformBuffer {
|
let uniform_buffer = UniformBuffer {
|
||||||
buffer: buffer,
|
buffer,
|
||||||
size: uniform_size,
|
size: uniform_size,
|
||||||
};
|
};
|
||||||
render_graph.set_uniform_buffer(GLOBAL_2D_UNIFORM_BUFFER_NAME, uniform_buffer);
|
render_graph.set_uniform_buffer(GLOBAL_2D_UNIFORM_BUFFER_NAME, uniform_buffer);
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl RenderResourceManager for GlobalResourceManager {
|
||||||
);
|
);
|
||||||
|
|
||||||
let uniform_buffer = UniformBuffer {
|
let uniform_buffer = UniformBuffer {
|
||||||
buffer: buffer,
|
buffer,
|
||||||
size: uniform_size,
|
size: uniform_size,
|
||||||
};
|
};
|
||||||
render_graph.set_uniform_buffer(FORWARD_UNIFORM_BUFFER_NAME, uniform_buffer);
|
render_graph.set_uniform_buffer(FORWARD_UNIFORM_BUFFER_NAME, uniform_buffer);
|
||||||
|
|
|
@ -18,7 +18,7 @@ impl LightResourceManager {
|
||||||
pub fn new(max_lights: usize) -> Self {
|
pub fn new(max_lights: usize) -> Self {
|
||||||
LightResourceManager {
|
LightResourceManager {
|
||||||
lights_are_dirty: true,
|
lights_are_dirty: true,
|
||||||
max_lights: max_lights,
|
max_lights,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ impl Vertex {
|
||||||
impl From<([f32; 4], [f32; 4], [f32; 2])> for Vertex {
|
impl From<([f32; 4], [f32; 4], [f32; 2])> for Vertex {
|
||||||
fn from((position, normal, uv): ([f32; 4], [f32; 4], [f32; 2])) -> Self {
|
fn from((position, normal, uv): ([f32; 4], [f32; 4], [f32; 2])) -> Self {
|
||||||
Vertex {
|
Vertex {
|
||||||
position: position,
|
position,
|
||||||
normal: normal,
|
normal,
|
||||||
uv: uv,
|
uv,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ impl From<([f32; 3], [f32; 3], [f32; 2])> for Vertex {
|
||||||
Vertex {
|
Vertex {
|
||||||
position: [position[0], position[1], position[2], 1.0],
|
position: [position[0], position[1], position[2], 1.0],
|
||||||
normal: [normal[0], normal[1], normal[2], 0.0],
|
normal: [normal[0], normal[1], normal[2], 0.0],
|
||||||
uv: uv,
|
uv,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,7 +359,7 @@ impl DeserializeImpl {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|reg| (reg.1.uuid, reg.1.clone())),
|
.map(|reg| (reg.1.uuid, reg.1.clone())),
|
||||||
),
|
),
|
||||||
tag_types: tag_types,
|
tag_types,
|
||||||
comp_types: component_types,
|
comp_types: component_types,
|
||||||
// re-use the entity-uuid mapping
|
// re-use the entity-uuid mapping
|
||||||
entity_map: RefCell::new(HashMap::from_iter(
|
entity_map: RefCell::new(HashMap::from_iter(
|
||||||
|
|
Loading…
Reference in a new issue