mirror of
https://github.com/bevyengine/bevy
synced 2024-11-24 21:53:07 +00:00
begin instancing work
This commit is contained in:
parent
56e79d5225
commit
63f40589e3
5 changed files with 10 additions and 8 deletions
|
@ -157,10 +157,13 @@ fn create_person(world: &mut World, mesh_handle: Handle<Mesh>, translation: Tran
|
||||||
Velocity {
|
Velocity {
|
||||||
value: math::vec3(0.0, 0.0, 0.0),
|
value: math::vec3(0.0, 0.0, 0.0),
|
||||||
},
|
},
|
||||||
Instanced,
|
|
||||||
StandardMaterial {
|
StandardMaterial {
|
||||||
albedo: (math::vec4(0.5, 0.3, 0.3, 1.0) * random::<f32>()).into(),
|
albedo: (math::vec4(0.5, 0.3, 0.3, 1.0) * random::<f32>()).into(),
|
||||||
},
|
},
|
||||||
|
Renderable {
|
||||||
|
instanced: true,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
mesh_handle,
|
mesh_handle,
|
||||||
LocalToWorld::identity(),
|
LocalToWorld::identity(),
|
||||||
translation,
|
translation,
|
||||||
|
|
|
@ -9,8 +9,7 @@ pub use crate::{
|
||||||
pipeline::PipelineDescriptor,
|
pipeline::PipelineDescriptor,
|
||||||
render_resource::{resource_name, resource_providers::UniformResourceProvider},
|
render_resource::{resource_name, resource_providers::UniformResourceProvider},
|
||||||
shader::{uniforms::StandardMaterial, Shader, ShaderDefSuffixProvider, ShaderStage},
|
shader::{uniforms::StandardMaterial, Shader, ShaderDefSuffixProvider, ShaderStage},
|
||||||
texture::{Texture, TextureType},
|
ActiveCamera, ActiveCamera2d, Camera, CameraType, Color, ColorSource, Light,
|
||||||
ActiveCamera, ActiveCamera2d, Camera, CameraType, Color, ColorSource, Instanced, Light,
|
|
||||||
Renderable,
|
Renderable,
|
||||||
},
|
},
|
||||||
ui::{Anchors, Margins, Node},
|
ui::{Anchors, Margins, Node},
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
pipeline::PipelineDescriptor,
|
pipeline::PipelineDescriptor,
|
||||||
render_resource::{resource_name, ResourceInfo},
|
render_resource::{resource_name, ResourceInfo},
|
||||||
renderer::RenderPass,
|
renderer::RenderPass,
|
||||||
Instanced, Renderable,
|
Renderable,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ impl DrawTarget for MeshesDrawTarget {
|
||||||
let mut current_mesh_handle = None;
|
let mut current_mesh_handle = None;
|
||||||
let mut current_mesh_index_len = 0;
|
let mut current_mesh_index_len = 0;
|
||||||
let mesh_query =
|
let mesh_query =
|
||||||
<(Read<Handle<Mesh>>, Read<Renderable>)>::query().filter(!component::<Instanced>());
|
<(Read<Handle<Mesh>>, Read<Renderable>)>::query();
|
||||||
|
|
||||||
for (entity, (mesh, renderable)) in mesh_query.iter_entities(world) {
|
for (entity, (mesh, renderable)) in mesh_query.iter_entities(world) {
|
||||||
if !renderable.is_visible {
|
if !renderable.is_visible {
|
||||||
|
|
|
@ -20,6 +20,4 @@ pub mod pipeline;
|
||||||
pub mod render_resource;
|
pub mod render_resource;
|
||||||
mod renderable;
|
mod renderable;
|
||||||
pub mod renderer;
|
pub mod renderer;
|
||||||
pub mod texture;
|
pub mod texture;
|
||||||
|
|
||||||
pub struct Instanced;
|
|
|
@ -13,6 +13,7 @@ pub struct Renderable {
|
||||||
pub is_visible: bool,
|
pub is_visible: bool,
|
||||||
pub pipelines: Vec<Handle<PipelineDescriptor>>,
|
pub pipelines: Vec<Handle<PipelineDescriptor>>,
|
||||||
pub shader_defs: HashSet<String>,
|
pub shader_defs: HashSet<String>,
|
||||||
|
pub instanced: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Renderable {
|
impl Default for Renderable {
|
||||||
|
@ -23,6 +24,7 @@ impl Default for Renderable {
|
||||||
Handle::new(0), // TODO: this could be better
|
Handle::new(0), // TODO: this could be better
|
||||||
],
|
],
|
||||||
shader_defs: HashSet::new(),
|
shader_defs: HashSet::new(),
|
||||||
|
instanced: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue