Skip to content

Commit

Permalink
fix changed meshes (#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
cart authored Dec 2, 2020
1 parent 5a77339 commit 915024b
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions crates/bevy_render/src/mesh/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ fn remove_current_mesh_resources(
#[derive(Default)]
pub struct MeshEntities {
entities: HashSet<Entity>,
waiting: HashSet<Entity>,
}

#[derive(Default)]
Expand All @@ -342,7 +341,7 @@ pub fn mesh_resource_provider_system(
Query<(Entity, &Handle<Mesh>, &mut RenderPipelines), Changed<Handle<Mesh>>>,
)>,
) {
let mut changed_meshes = bevy_utils::HashSet::<Handle<Mesh>>::default();
let mut changed_meshes = HashSet::default();
let render_resource_context = &**render_resource_context;
for event in state.mesh_event_reader.iter(&mesh_events) {
match event {
Expand Down Expand Up @@ -395,9 +394,8 @@ pub fn mesh_resource_provider_system(
);

if let Some(mesh_entities) = state.mesh_entities.get_mut(changed_mesh_handle) {
for entity in mesh_entities.waiting.drain() {
if let Ok(render_pipelines) = queries.q0_mut().get_mut(entity) {
mesh_entities.entities.insert(entity);
for entity in mesh_entities.entities.iter() {
if let Ok(render_pipelines) = queries.q0_mut().get_mut(*entity) {
update_entity_mesh(
render_resource_context,
mesh,
Expand All @@ -416,12 +414,9 @@ pub fn mesh_resource_provider_system(
.mesh_entities
.entry(handle.clone_weak())
.or_insert_with(MeshEntities::default);
mesh_entities.entities.insert(entity);
if let Some(mesh) = meshes.get(handle) {
mesh_entities.entities.insert(entity);
mesh_entities.waiting.remove(&entity);
update_entity_mesh(render_resource_context, mesh, handle, render_pipelines);
} else {
mesh_entities.waiting.insert(entity);
}
}
}
Expand Down

0 comments on commit 915024b

Please sign in to comment.