Skip to content

Commit

Permalink
mesh: Fix ignore_voxels being ignored.
Browse files Browse the repository at this point in the history
This is a partial revert of commit f4bd20f
which introduced the bug; at the time I misread the code and thought
this case was for a different purpose than it actually is.

What remains is the switch from a `match` to `if let` using
`Evoxels::single_voxel()`, which is still desirable since it saves an
indentation level and avoids needing a dummy branch for match
exhaustiveness.
  • Loading branch information
kpreid committed Nov 18, 2023
1 parent 33ddcea commit 7b0f4b7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions all-is-cubes-mesh/src/block_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::fmt::Debug;
use std::sync::Arc;

use all_is_cubes::block::{AnimationChange, EvaluatedBlock, Evoxel, Resolution};
use all_is_cubes::block::{AnimationChange, EvaluatedBlock, Evoxel, Evoxels, Resolution};
use all_is_cubes::camera::Flaws;
use all_is_cubes::euclid::point2;
use all_is_cubes::math::{
Expand Down Expand Up @@ -275,7 +275,17 @@ impl<M: MeshTypes + 'static> BlockMesh<M> {
let flaws = &mut self.flaws;

let resolution = block.resolution();
let voxels = &block.voxels;

// If `options.ignore_voxels` is set, substitute the block color for the
// actual voxels.
let tmp_block_color_voxel: Evoxels;
let voxels: &Evoxels = if options.ignore_voxels {
tmp_block_color_voxel = Evoxels::One(Evoxel::from_color(block.color));
&tmp_block_color_voxel
} else {
&block.voxels
};

if let Some(Evoxel {
color: block_color, ..
}) = voxels.single_voxel()
Expand Down

0 comments on commit 7b0f4b7

Please sign in to comment.