diff --git a/fyrox-impl/src/scene/graph/physics.rs b/fyrox-impl/src/scene/graph/physics.rs index d46335481..fb597abb5 100644 --- a/fyrox-impl/src/scene/graph/physics.rs +++ b/fyrox-impl/src/scene/graph/physics.rs @@ -738,23 +738,25 @@ fn make_heightfield(terrain: &Terrain) -> Option { )), Vector3::new(x_scale, 1.0, z_scale), ); - hf.cells_statuses_mut() - .fill(HeightFieldCellStatus::CELL_REMOVED); - let hole_mask_size = terrain.hole_mask_size(); - for chunk in terrain.chunks_ref() { - let texture = chunk.hole_mask().map(|t| t.data_ref()); - let hole_mask = texture.as_ref().map(|t| t.data_of_type::().unwrap()); - let pos = (chunk.grid_position() - chunk_min).map(|x| x as u32); - let (ox, oy) = (pos.x * chunk_size.x, pos.y * chunk_size.y); + if terrain.holes_enabled() { + hf.cells_statuses_mut() + .fill(HeightFieldCellStatus::CELL_REMOVED); + let hole_mask_size = terrain.hole_mask_size(); + for chunk in terrain.chunks_ref() { + let texture = chunk.hole_mask().map(|t| t.data_ref()); + let hole_mask = texture.as_ref().map(|t| t.data_of_type::().unwrap()); + let pos = (chunk.grid_position() - chunk_min).map(|x| x as u32); + let (ox, oy) = (pos.x * chunk_size.x, pos.y * chunk_size.y); - for iy in 0..hole_mask_size.y { - for ix in 0..hole_mask_size.x { - let is_hole = hole_mask - .map(|m| m[(iy * hole_mask_size.x + ix) as usize] < 128) - .unwrap_or_default(); - let (x, y) = (ox + ix, oy + iy); - if !is_hole { - hf.set_cell_status(y as usize, x as usize, HeightFieldCellStatus::empty()); + for iy in 0..hole_mask_size.y { + for ix in 0..hole_mask_size.x { + let is_hole = hole_mask + .map(|m| m[(iy * hole_mask_size.x + ix) as usize] < 128) + .unwrap_or_default(); + let (x, y) = (ox + ix, oy + iy); + if !is_hole { + hf.set_cell_status(y as usize, x as usize, HeightFieldCellStatus::empty()); + } } } }