Skip to content

Commit

Permalink
Temporarily disable dynamic depth sort and chunk updates on wasm target.
Browse files Browse the repository at this point in the history
This is a workaround for hadronized/luminance-rs#483
  • Loading branch information
kpreid committed Feb 15, 2021
1 parent 50674f2 commit 7eac89f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions all-is-cubes/src/lum/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ impl Chunk {
let existing_tess_size_ok = if let Some(tess) = tess_option.as_ref() {
tess.vert_nb() == new_triangulation.vertices().len()
&& old_indices_len == new_triangulation.indices().len()
// TODO: workaround for https://github.com/phaazon/luminance-rs/issues/483
&& !cfg!(target_arch = "wasm32")
} else {
false
};
Expand Down Expand Up @@ -486,14 +488,20 @@ impl Chunk {
}

fn depth_sort_for_view(&mut self, view_position: Point3<FreeCoordinate>) {
let range = self.triangulation.transparent_range(DepthOrdering::Within);
if !range.is_empty() {
if let Some(tess) = &mut self.tess {
self.triangulation
.depth_sort_for_view(view_position.map(|s| s as f32));
tess.indices_mut()
.expect("failed to map indices for depth sorting")[range.clone()]
.copy_from_slice(&self.triangulation.indices()[range]);
// Disable dynamic depth sorting because luminance bug
// https://github.com/phaazon/luminance-rs/issues/483
// means indices_mut() can fail and corrupt other buffers.
// TODO: Reenble this and also in-place chunk updating when bug is fixed
if !cfg!(target_arch = "wasm32") {
let range = self.triangulation.transparent_range(DepthOrdering::Within);
if !range.is_empty() {
if let Some(tess) = &mut self.tess {
self.triangulation
.depth_sort_for_view(view_position.map(|s| s as f32));
tess.indices_mut()
.expect("failed to map indices for depth sorting")[range.clone()]
.copy_from_slice(&self.triangulation.indices()[range]);
}
}
}
}
Expand Down

0 comments on commit 7eac89f

Please sign in to comment.