Simplify material handling to reduce duplicates

This commit is contained in:
Thinkofname 2016-04-03 12:58:53 +01:00
parent 58ffe250e2
commit e7cef1eea7
3 changed files with 266 additions and 1495 deletions

View File

@ -0,0 +1,48 @@
pub struct Material {
pub renderable: bool,
pub should_cull_against: bool,
pub never_cull: bool, // Because leaves suck
pub force_shade: bool,
pub transparent: bool,
}
pub const INVISIBLE: Material = Material {
renderable: false,
never_cull: false,
should_cull_against: false,
force_shade: false,
transparent: false,
};
pub const SOLID: Material = Material {
renderable: true,
never_cull: false,
should_cull_against: true,
force_shade: false,
transparent: false,
};
pub const NON_SOLID: Material = Material {
renderable: true,
never_cull: false,
should_cull_against: false,
force_shade: false,
transparent: false,
};
pub const TRANSPARENT: Material = Material {
renderable: true,
never_cull: false,
should_cull_against: false,
force_shade: false,
transparent: true,
};
pub const LEAVES: Material = Material {
renderable: true,
never_cull: true,
should_cull_against: false,
force_shade: true,
transparent: false,
};

File diff suppressed because it is too large Load Diff

View File

@ -377,7 +377,7 @@ impl World {
let mut block_map = HashMap::with_hasher(BuildHasherDefault::<FNVHash>::default());
if bit_size == 0 {
bit_size = 13;
} else {
} else {
let count = try!(VarInt::read_from(&mut data)).0;
for i in 0 .. count {
let id = try!(VarInt::read_from(&mut data)).0;
@ -543,7 +543,7 @@ impl Chunk {
let idx = ((z<<4)|x) as usize;
for yy in 0 .. 256 {
let sy = 255 - yy;
if let block::Block::Air{..} = self.get_block(x, sy, z) {
if let block::Air{..} = self.get_block(x, sy, z) {
continue
}
self.heightmap[idx] = sy as u8;
@ -577,7 +577,7 @@ impl Chunk {
// Find a new lowest
for yy in 0 .. y {
let sy = y - yy - 1;
if let block::Block::Air{..} = self.get_block(x, sy, z) {
if let block::Air{..} = self.get_block(x, sy, z) {
continue
}
self.heightmap[idx] = sy as u8;