mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Meshing performance improvements
This commit is contained in:
parent
3979dddbc1
commit
2416b77a33
@ -181,13 +181,14 @@ impl<V: RectRasterableVol<Vox = Block> + ReadVol + Debug> Meshable<TerrainPipeli
|
||||
|
||||
lights[0] = lights[1];
|
||||
lights[1] = lights[2];
|
||||
colors[0] = colors[1];
|
||||
colors[1] = colors[2];
|
||||
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
lights[2][j][i] = light(pos + Vec3::new(i as i32, j as i32, 2) - 1);
|
||||
}
|
||||
}
|
||||
colors[0] = colors[1];
|
||||
colors[1] = colors[2];
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
colors[2][j][i] = get_color(pos + Vec3::new(i as i32, j as i32, 2) - 1);
|
||||
|
@ -60,6 +60,7 @@ fn get_ao_quad<V: ReadVol>(
|
||||
.collect::<Vec4<(f32, f32)>>()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_col_quad<V: ReadVol>(
|
||||
vol: &V,
|
||||
pos: Vec3<i32>,
|
||||
@ -75,27 +76,23 @@ fn get_col_quad<V: ReadVol>(
|
||||
let mut total = 0.0;
|
||||
for x in 0..2 {
|
||||
for y in 0..2 {
|
||||
for z in 0..2 {
|
||||
let col_pos = shift * z + offs[0] * x + offs[1] * y + 1;
|
||||
if let Some(col) =
|
||||
cols[col_pos.z as usize][col_pos.y as usize][col_pos.x as usize]
|
||||
let col_pos = offs[0] * x + offs[1] * y + 1;
|
||||
if let Some(col) = unsafe {
|
||||
cols.get_unchecked(col_pos.z as usize)
|
||||
.get_unchecked(col_pos.y as usize)
|
||||
.get_unchecked(col_pos.x as usize)
|
||||
} {
|
||||
if Vec3::<f32>::from(primary_col).distance_squared(Vec3::from(*col))
|
||||
< 0.25 * 0.25
|
||||
{
|
||||
if Vec3::<f32>::from(primary_col).distance_squared(Vec3::from(col))
|
||||
< 0.25 * 0.25
|
||||
{
|
||||
color += col;
|
||||
total += 1.0;
|
||||
}
|
||||
color += *col;
|
||||
total += 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if total == 0.0 {
|
||||
Rgb::zero()
|
||||
} else {
|
||||
color / total
|
||||
}
|
||||
color / total
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user