Skip to content
This repository has been archived by the owner on Jun 19, 2021. It is now read-only.

Commit

Permalink
Address most comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Jul 23, 2016
1 parent 5e91259 commit becdf95
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 25 deletions.
7 changes: 1 addition & 6 deletions base/src/gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ fn seeded_rng<T: Hash, U: Hash>(world_seed: u64, feat_seed: T, loc_seed: U) -> R
let rng_seed = fnv.finish();
let seed0 = (rng_seed >> 32) as u32;
let seed1 = rng_seed as u32;
// Apply our patented cryptoperturbation mask to magically extend the 64-bit
// hash to 128 bits used by xorshift:
// (To be honest, I just didn't want to pass the same 2 word twice)
let seed2 = seed0 ^ 0xdeadbeef;
let seed3 = seed1 ^ 0xcafebabe;

XorShiftRng::from_seed([seed0, seed1, seed2, seed3])
XorShiftRng::from_seed([seed0, seed1, seed0, seed1])
}
10 changes: 5 additions & 5 deletions base/src/gen/plant/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ impl TreeGen {
let trunk_diameter_top = range_sample(&self.preset.trunk_diameter_top, rng);
let min_branch_height = range_sample(&self.preset.min_branch_height, rng) * trunk_height;

info!("trunk diam {} to {}, height {}, branch start at {}",
trunk_diameter,
trunk_diameter_top,
trunk_height,
min_branch_height);
debug!("trunk diam {} to {}, height {}, branch start at {}",
trunk_diameter,
trunk_diameter_top,
trunk_height,
min_branch_height);

let mut points = Vec::new();

Expand Down
16 changes: 16 additions & 0 deletions client/src/render/to_arr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,19 @@ impl<T: BaseFloat> ToArr for Vector2<T> {
(*self).into()
}
}

impl<T: BaseNum> ToArr for Point2<T> {
type Output = [T; 2];

fn to_arr(&self) -> Self::Output {
(*self).into()
}
}

impl<T: BaseNum> ToArr for Point3<T> {
type Output = [T; 3];

fn to_arr(&self) -> Self::Output {
(*self).into()
}
}
15 changes: 9 additions & 6 deletions client/src/world/chunk_view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use base::world::{self, Chunk, HexPillar, PillarSection, PropType};
use base::math::*;
use glium::{Depth, DrawParameters, IndexBuffer, Program, Surface, VertexBuffer};
use glium::{self, DrawParameters, IndexBuffer, Program, VertexBuffer};
use glium::draw_parameters::{BackfaceCullingMode, DepthTest};
use glium::backend::Facade;
use glium::index::PrimitiveType;
Expand Down Expand Up @@ -86,9 +86,9 @@ impl ChunkView {
}
}

pub fn draw<S: Surface>(&self, surface: &mut S, camera: &Camera) {
pub fn draw<S: glium::Surface>(&self, surface: &mut S, camera: &Camera) {
for pillar in &self.pillars {
for section in &pillar.pillars {
for section in &pillar.sections {
let scale_matrix =
Matrix4::from_nonuniform_scale(1.0,
1.0,
Expand All @@ -102,7 +102,7 @@ impl ChunkView {
material_color: section.ground.get_color(),
};
let params = DrawParameters {
depth: Depth {
depth: glium::Depth {
write: true,
test: DepthTest::IfLess,
..Default::default()
Expand All @@ -126,6 +126,9 @@ impl ChunkView {
}
}


// FIXME `Vertex` really shouldn't be in this module

#[derive(Debug, Copy, Clone)]
pub struct Vertex {
pub position: [f32; 3],
Expand All @@ -136,15 +139,15 @@ implement_vertex!(Vertex, position, color);

pub struct PillarView {
pos: Point2f,
pillars: Vec<PillarSection>,
sections: Vec<PillarSection>,
plants: Vec<PlantView>,
}

impl PillarView {
fn from_pillar<F: Facade>(pos: Point2f, pillar: &HexPillar, facade: &F) -> PillarView {
PillarView {
pos: pos,
pillars: pillar.sections().to_vec(),
sections: pillar.sections().to_vec(),
plants: pillar.props()
.iter()
.map(|prop| {
Expand Down
12 changes: 6 additions & 6 deletions client/src/world/plant_view.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use glium::backend::Facade;
use glium::{Depth, DepthTest, DrawParameters, Program, Surface, VertexBuffer};
use glium::{self, DepthTest, DrawParameters, Program, VertexBuffer};
use glium::index::{NoIndices, PrimitiveType};
use Camera;
use render::ToArr;
Expand Down Expand Up @@ -34,8 +34,8 @@ impl PlantView {
for cp in branch.points.iter() {
verts += 1;
vertices.push(Vertex {
position: [cp.point.x, cp.point.y, cp.point.z],
color: [branch.color.x, branch.color.y, branch.color.z],
position: cp.point.to_arr(),
color: branch.color.to_arr(),
});
}

Expand All @@ -45,7 +45,7 @@ impl PlantView {
}
};

info!("{} verts -> {:?}", verts, pos);
debug!("{} verts -> {:?}", verts, pos);

PlantView {
branches: branches,
Expand All @@ -54,7 +54,7 @@ impl PlantView {
}
}

pub fn draw<S: Surface>(&self, surface: &mut S, camera: &Camera) {
pub fn draw<S: glium::Surface>(&self, surface: &mut S, camera: &Camera) {
let uniforms = uniform! {
// FIXME HACK why do i have to half the Z coordinate...
offset: [self.pos.x, self.pos.y, self.pos.z/2.0],
Expand All @@ -63,7 +63,7 @@ impl PlantView {
};

let params = DrawParameters {
depth: Depth {
depth: glium::Depth {
write: true,
test: DepthTest::IfLess,
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions client/src/world/world_view.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use base::world::{self, World};
use base::math::*;
use glium::backend::Facade;
use glium::Surface;
use glium;
use Camera;

pub use world::chunk_view::ChunkView;
Expand Down Expand Up @@ -36,7 +36,7 @@ impl WorldView {
WorldView { chunks: chunks }
}

pub fn draw<S: Surface>(&self, surface: &mut S, camera: &Camera) {
pub fn draw<S: glium::Surface>(&self, surface: &mut S, camera: &Camera) {
for chunkview in &self.chunks {
chunkview.draw(surface, camera);
}
Expand Down

0 comments on commit becdf95

Please sign in to comment.