mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
implement Copy for Handle
This commit is contained in:
parent
1a4bd98434
commit
9e5f4aeefc
13 changed files with 27 additions and 27 deletions
|
@ -83,7 +83,7 @@ fn setup(world: &mut World) {
|
|||
.build()
|
||||
// cube
|
||||
.add_archetype(MeshMaterialEntity::<MyMaterial> {
|
||||
mesh: cube_handle.clone(),
|
||||
mesh: cube_handle,
|
||||
renderable: Renderable {
|
||||
pipelines: vec![Handle::new(2)], // TODO: make this pipeline assignment cleaner
|
||||
..Default::default()
|
||||
|
|
|
@ -14,7 +14,7 @@ fn create_entities_insert_vec(
|
|||
world.insert(
|
||||
(),
|
||||
vec![(
|
||||
plane_handle.clone(),
|
||||
plane_handle,
|
||||
StandardMaterial {
|
||||
albedo: math::vec4(0.1, 0.2, 0.1, 1.0).into(),
|
||||
},
|
||||
|
@ -77,7 +77,7 @@ fn create_entities_builder_add_component(
|
|||
.build()
|
||||
// plane
|
||||
.build_entity()
|
||||
.add(plane_handle.clone())
|
||||
.add(plane_handle)
|
||||
.add(StandardMaterial {
|
||||
albedo: math::vec4(0.1, 0.2, 0.1, 1.0).into(),
|
||||
})
|
||||
|
@ -123,7 +123,7 @@ fn create_entities_builder_archetype(
|
|||
.build()
|
||||
// plane
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: plane_handle.clone(),
|
||||
mesh: plane_handle,
|
||||
material: StandardMaterial {
|
||||
albedo: math::vec4(0.1, 0.2, 0.1, 1.0).into(),
|
||||
},
|
||||
|
|
|
@ -74,7 +74,7 @@ fn setup(world: &mut World) {
|
|||
for _ in 0..70000 {
|
||||
create_person(
|
||||
world,
|
||||
cube_handle.clone(),
|
||||
cube_handle,
|
||||
Translation::new(rng.gen_range(-50.0, 50.0), 0.0, rng.gen_range(-50.0, 50.0)),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ fn setup(world: &mut World) {
|
|||
world.insert(
|
||||
(),
|
||||
vec![(
|
||||
plane_handle.clone(),
|
||||
plane_handle,
|
||||
StandardMaterial {
|
||||
albedo: math::vec4(0.1, 0.2, 0.1, 1.0).into(),
|
||||
},
|
||||
|
@ -48,7 +48,7 @@ fn setup(world: &mut World) {
|
|||
.insert(
|
||||
(),
|
||||
vec![(
|
||||
cube_handle.clone(),
|
||||
cube_handle,
|
||||
StandardMaterial {
|
||||
albedo: math::vec4(0.5, 0.3, 0.3, 1.0).into(),
|
||||
},
|
||||
|
|
|
@ -26,7 +26,7 @@ pub fn setup(world: &mut World) {
|
|||
world.build()
|
||||
// plane
|
||||
.add_archetype(NewMeshEntity {
|
||||
mesh: plane_handle.clone(),
|
||||
mesh: plane_handle,
|
||||
material: Material::new(Albedo::Color(math::vec4(0.1, 0.2, 0.1, 1.0))),
|
||||
local_to_world: LocalToWorld::identity(),
|
||||
translation: Translation::new(0.0, 0.0, 0.0),
|
||||
|
|
|
@ -17,7 +17,7 @@ fn setup(world: &mut World) {
|
|||
.build()
|
||||
// plane
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: plane_handle.clone(),
|
||||
mesh: plane_handle,
|
||||
material: StandardMaterial {
|
||||
albedo: math::vec4(0.1, 0.2, 0.1, 1.0).into(),
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ fn setup(world: &mut World) {
|
|||
})
|
||||
// cube
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: cube_handle.clone(),
|
||||
mesh: cube_handle,
|
||||
material: StandardMaterial {
|
||||
albedo: math::vec4(0.5, 0.4, 0.3, 1.0).into(),
|
||||
},
|
||||
|
|
|
@ -74,7 +74,7 @@ fn setup(world: &mut World) {
|
|||
.build()
|
||||
// plane
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: plane_handle.clone(),
|
||||
mesh: plane_handle,
|
||||
material: StandardMaterial {
|
||||
albedo: math::vec4(0.1, 0.2, 0.1, 1.0).into(),
|
||||
},
|
||||
|
@ -82,7 +82,7 @@ fn setup(world: &mut World) {
|
|||
})
|
||||
// cube
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: cube_handle.clone(),
|
||||
mesh: cube_handle,
|
||||
material: StandardMaterial {
|
||||
albedo: math::vec4(1.0, 1.0, 1.0, 1.0).into(),
|
||||
},
|
||||
|
@ -90,7 +90,7 @@ fn setup(world: &mut World) {
|
|||
..Default::default()
|
||||
})
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: cube_handle.clone(),
|
||||
mesh: cube_handle,
|
||||
material: StandardMaterial {
|
||||
albedo: math::vec4(0.0, 1.0, 0.0, 1.0).into(),
|
||||
},
|
||||
|
@ -121,7 +121,7 @@ fn setup(world: &mut World) {
|
|||
let mut rng = StdRng::from_entropy();
|
||||
for _ in 0..10000 {
|
||||
builder = builder.add_archetype(MeshEntity {
|
||||
mesh: cube_handle.clone(),
|
||||
mesh: cube_handle,
|
||||
material: StandardMaterial {
|
||||
albedo: math::vec4(
|
||||
rng.gen_range(0.0, 1.0),
|
||||
|
|
|
@ -20,7 +20,7 @@ fn setup(world: &mut World) {
|
|||
.build()
|
||||
// cube
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: cube_handle.clone(),
|
||||
mesh: cube_handle,
|
||||
material: StandardMaterial {
|
||||
albedo: texture_handle.into(),
|
||||
},
|
||||
|
|
|
@ -15,7 +15,7 @@ fn setup(world: &mut World) {
|
|||
.build()
|
||||
// cube
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: cube_handle.clone(),
|
||||
mesh: cube_handle,
|
||||
material: StandardMaterial {
|
||||
albedo: math::vec4(0.5, 0.3, 0.3, 1.0).into(),
|
||||
},
|
||||
|
|
|
@ -12,7 +12,6 @@ pub use texture::*;
|
|||
|
||||
use std::{collections::HashMap, marker::PhantomData};
|
||||
|
||||
#[derive(Copy)]
|
||||
pub struct Handle<T> {
|
||||
pub id: usize,
|
||||
marker: PhantomData<T>,
|
||||
|
@ -58,6 +57,7 @@ impl<T> Default for Handle<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Copy for Handle<T> {}
|
||||
impl<T> Clone for Handle<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Handle {
|
||||
|
|
|
@ -64,7 +64,7 @@ fn try_compiling_shader_with_macros(
|
|||
if let None = compiled_shader_map.source_to_compiled.get(shader_handle) {
|
||||
compiled_shader_map
|
||||
.source_to_compiled
|
||||
.insert(shader_handle.clone(), Vec::new());
|
||||
.insert(*shader_handle, Vec::new());
|
||||
}
|
||||
|
||||
let compiled_shaders = compiled_shader_map
|
||||
|
@ -90,7 +90,7 @@ fn try_compiling_shader_with_macros(
|
|||
.cloned()
|
||||
.collect::<Vec<String>>();
|
||||
let compiled_shader = shader.get_spirv_shader(Some(&shader_def_vec));
|
||||
compiled_shaders.push((renderable.shader_defs.clone(), shader_handle.clone()));
|
||||
compiled_shaders.push((renderable.shader_defs.clone(), *shader_handle));
|
||||
let compiled_shader_handle = shader_storage.add(compiled_shader);
|
||||
Some(compiled_shader_handle)
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ pub fn update_shader_assignments(world: &mut World, render_graph: &mut RenderGra
|
|||
{
|
||||
compiled_shader_map
|
||||
.pipeline_to_macro_pipelines
|
||||
.insert(pipeline_handle.clone(), Vec::new());
|
||||
.insert(*pipeline_handle, Vec::new());
|
||||
}
|
||||
|
||||
let final_handle = if let Some((_shader_defs, macroed_pipeline_handle)) =
|
||||
|
@ -133,7 +133,7 @@ pub fn update_shader_assignments(world: &mut World, render_graph: &mut RenderGra
|
|||
.find(|(shader_defs, _macroed_pipeline_handle)| {
|
||||
*shader_defs == renderable.shader_defs
|
||||
}) {
|
||||
macroed_pipeline_handle.clone()
|
||||
*macroed_pipeline_handle
|
||||
} else {
|
||||
let pipeline_descriptor =
|
||||
pipeline_descriptor_storage.get(pipeline_handle).unwrap();
|
||||
|
@ -172,11 +172,11 @@ pub fn update_shader_assignments(world: &mut World, render_graph: &mut RenderGra
|
|||
// TODO: get correct pass name
|
||||
render_graph.add_pipeline(
|
||||
resource_name::pass::MAIN,
|
||||
macroed_pipeline_handle.clone(),
|
||||
macroed_pipeline_handle,
|
||||
);
|
||||
macroed_pipeline_handle
|
||||
} else {
|
||||
pipeline_handle.clone()
|
||||
*pipeline_handle
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -186,7 +186,7 @@ pub fn update_shader_assignments(world: &mut World, render_graph: &mut RenderGra
|
|||
.unwrap();
|
||||
macro_pipelines.push((
|
||||
renderable.shader_defs.clone(),
|
||||
macroed_pipeline_handle.clone(),
|
||||
macroed_pipeline_handle,
|
||||
));
|
||||
macroed_pipeline_handle
|
||||
};
|
||||
|
@ -195,7 +195,7 @@ pub fn update_shader_assignments(world: &mut World, render_graph: &mut RenderGra
|
|||
if let None = shader_pipeline_assignments.assignments.get(&final_handle) {
|
||||
shader_pipeline_assignments
|
||||
.assignments
|
||||
.insert(final_handle.clone(), Vec::new());
|
||||
.insert(final_handle, Vec::new());
|
||||
}
|
||||
|
||||
let assignments = shader_pipeline_assignments
|
||||
|
|
|
@ -529,7 +529,7 @@ impl Renderer for WgpuRenderer {
|
|||
fragment_shader,
|
||||
);
|
||||
self.render_pipelines
|
||||
.insert(pipeline_descriptor_handle.clone(), render_pipeline);
|
||||
.insert(*pipeline_descriptor_handle, render_pipeline);
|
||||
}
|
||||
|
||||
// create bind groups
|
||||
|
|
|
@ -75,7 +75,7 @@ where
|
|||
uniforms.get_uniform_texture(&uniform_info.name).unwrap();
|
||||
let storage = world.resources.get::<AssetStorage<Texture>>().unwrap();
|
||||
let texture = storage.get(&texture_handle).unwrap();
|
||||
if let None = renderer.get_texture_resource(texture_handle.clone()) {
|
||||
if let None = renderer.get_texture_resource(texture_handle) {
|
||||
let descriptor: TextureDescriptor = texture.into();
|
||||
let resource =
|
||||
renderer.create_texture(&descriptor, Some(&texture.data));
|
||||
|
|
Loading…
Reference in a new issue