Use if let instead of map, fixes option_map_unit_fn
This commit is contained in:
parent
3aaa14eb80
commit
b4aa23ecf5
|
@ -86,31 +86,36 @@ impl Manager {
|
||||||
let mut model = {
|
let mut model = {
|
||||||
let collection = &mut self.collections[ckey.0];
|
let collection = &mut self.collections[ckey.0];
|
||||||
collection.shader.program.use_program();
|
collection.shader.program.use_program();
|
||||||
collection.shader.position.map(|v| v.enable());
|
if let Some(v) = collection.shader.position {
|
||||||
collection.shader.texture_info.map(|v| v.enable());
|
v.enable()
|
||||||
collection.shader.texture_offset.map(|v| v.enable());
|
}
|
||||||
collection.shader.color.map(|v| v.enable());
|
if let Some(v) = collection.shader.texture_info {
|
||||||
collection.shader.id.map(|v| v.enable());
|
v.enable()
|
||||||
collection
|
}
|
||||||
.shader
|
if let Some(v) = collection.shader.texture_offset {
|
||||||
.position
|
v.enable()
|
||||||
.map(|v| v.vertex_pointer(3, gl::FLOAT, false, 36, 0));
|
}
|
||||||
collection
|
if let Some(v) = collection.shader.color {
|
||||||
.shader
|
v.enable()
|
||||||
.texture_info
|
}
|
||||||
.map(|v| v.vertex_pointer(4, gl::UNSIGNED_SHORT, false, 36, 12));
|
if let Some(v) = collection.shader.id {
|
||||||
collection
|
v.enable()
|
||||||
.shader
|
}
|
||||||
.texture_offset
|
if let Some(v) = collection.shader.position {
|
||||||
.map(|v| v.vertex_pointer_int(3, gl::SHORT, 36, 20));
|
v.vertex_pointer(3, gl::FLOAT, false, 36, 0)
|
||||||
collection
|
}
|
||||||
.shader
|
if let Some(v) = collection.shader.texture_info {
|
||||||
.color
|
v.vertex_pointer(4, gl::UNSIGNED_SHORT, false, 36, 12)
|
||||||
.map(|v| v.vertex_pointer(4, gl::UNSIGNED_BYTE, true, 36, 28));
|
}
|
||||||
collection
|
if let Some(v) = collection.shader.texture_offset {
|
||||||
.shader
|
v.vertex_pointer_int(3, gl::SHORT, 36, 20)
|
||||||
.id
|
}
|
||||||
.map(|v| v.vertex_pointer_int(1, gl::UNSIGNED_BYTE, 36, 32));
|
if let Some(v) = collection.shader.color {
|
||||||
|
v.vertex_pointer(4, gl::UNSIGNED_BYTE, true, 36, 28)
|
||||||
|
}
|
||||||
|
if let Some(v) = collection.shader.id {
|
||||||
|
v.vertex_pointer_int(1, gl::UNSIGNED_BYTE, 36, 32)
|
||||||
|
}
|
||||||
|
|
||||||
let mut model = Model {
|
let mut model = Model {
|
||||||
// For culling only
|
// For culling only
|
||||||
|
@ -244,23 +249,21 @@ impl Manager {
|
||||||
gl::enable(gl::BLEND);
|
gl::enable(gl::BLEND);
|
||||||
for collection in &self.collections {
|
for collection in &self.collections {
|
||||||
collection.shader.program.use_program();
|
collection.shader.program.use_program();
|
||||||
collection
|
if let Some(v) = collection.shader.perspective_matrix {
|
||||||
.shader
|
v.set_matrix4(perspective_matrix)
|
||||||
.perspective_matrix
|
}
|
||||||
.map(|v| v.set_matrix4(perspective_matrix));
|
if let Some(v) = collection.shader.camera_matrix {
|
||||||
collection
|
v.set_matrix4(camera_matrix)
|
||||||
.shader
|
}
|
||||||
.camera_matrix
|
if let Some(v) = collection.shader.texture {
|
||||||
.map(|v| v.set_matrix4(camera_matrix));
|
v.set_int(0)
|
||||||
collection.shader.texture.map(|v| v.set_int(0));
|
}
|
||||||
collection
|
if let Some(v) = collection.shader.sky_offset {
|
||||||
.shader
|
v.set_float(sky_offset)
|
||||||
.sky_offset
|
}
|
||||||
.map(|v| v.set_float(sky_offset));
|
if let Some(v) = collection.shader.light_level {
|
||||||
collection
|
v.set_float(light_level)
|
||||||
.shader
|
}
|
||||||
.light_level
|
|
||||||
.map(|v| v.set_float(light_level));
|
|
||||||
gl::blend_func(collection.blend_s, collection.blend_d);
|
gl::blend_func(collection.blend_s, collection.blend_d);
|
||||||
|
|
||||||
for model in collection.models.values() {
|
for model in collection.models.values() {
|
||||||
|
@ -273,17 +276,15 @@ impl Manager {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
model.array.bind();
|
model.array.bind();
|
||||||
collection
|
if let Some(v) = collection.shader.lighting {
|
||||||
.shader
|
v.set_float2(model.block_light, model.sky_light)
|
||||||
.lighting
|
}
|
||||||
.map(|v| v.set_float2(model.block_light, model.sky_light));
|
if let Some(v) = collection.shader.model_matrix {
|
||||||
collection
|
v.set_matrix4_multi(&model.matrix)
|
||||||
.shader
|
}
|
||||||
.model_matrix
|
if let Some(v) = collection.shader.color_mul {
|
||||||
.map(|v| v.set_matrix4_multi(&model.matrix));
|
|
||||||
collection.shader.color_mul.map(|v| {
|
|
||||||
v.set_float_mutli_raw(model.colors.as_ptr() as *const _, model.colors.len())
|
v.set_float_mutli_raw(model.colors.as_ptr() as *const _, model.colors.len())
|
||||||
});
|
}
|
||||||
gl::draw_elements(gl::TRIANGLES, model.count, self.index_type, 0);
|
gl::draw_elements(gl::TRIANGLES, model.count, self.index_type, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue