remove bitrot, update and set versions of all deps, notably gfx & nalgebra
This commit is contained in:
@@ -13,9 +13,8 @@ use std::time::SystemTime;
|
||||
|
||||
use gfx::{self, texture};
|
||||
use gfx::traits::FactoryExt;
|
||||
use na::{self, ToHomogeneous};
|
||||
use num_traits::identities::One;
|
||||
use piston::input::{Button, Input, Key};
|
||||
use na;
|
||||
use piston::input::{Button, ButtonArgs, ButtonState, Input, Key};
|
||||
|
||||
const PI: f32 = ::std::f32::consts::PI;
|
||||
const TWO_PI_CIRC: f32 = 2.0 * PI / 256.0;
|
||||
@@ -135,7 +134,7 @@ pub struct WorldScene<D: gfx::Device,
|
||||
|
||||
start_time: SystemTime,
|
||||
treadmills: (f32, f32),
|
||||
pads: BTreeMap<u32, (TrackMode, Option<vr::VRControllerState_t>)>,
|
||||
pads: BTreeMap<u32, (TrackMode, Option<vr::ControllerState>)>,
|
||||
|
||||
_worldmap: model::World,
|
||||
lat: u8,
|
||||
@@ -156,7 +155,7 @@ impl<D: gfx::Device, F: gfx::Factory<D::Resources>> WorldScene<D, F> {
|
||||
FRAGMENT_SHADER_SRC,
|
||||
pipe::new())
|
||||
.expect("create pipeline"),
|
||||
camera: na::Matrix4::one(),
|
||||
camera: na::Matrix4::identity(),
|
||||
constants: Constants { anim: ANIMDATA,
|
||||
r1: R1, r2: R2, r3: R3,
|
||||
haze: 1.0/2.0f32.sqrt(), hazecolor: SKY_COLOR },
|
||||
@@ -164,7 +163,7 @@ impl<D: gfx::Device, F: gfx::Factory<D::Resources>> WorldScene<D, F> {
|
||||
constants_dirty: true,
|
||||
locals: factory.create_constant_buffer(1),
|
||||
atlas: tile::get_tiles::<_, _, view::ColorFormat>(device, factory, aux_command),
|
||||
sampler: factory.create_sampler(texture::SamplerInfo::new(texture::FilterMethod::Jrd,
|
||||
sampler: factory.create_sampler(texture::SamplerInfo::new(texture::FilterMethod::Trilinear, //::Jrd
|
||||
texture::WrapMode::Tile)),
|
||||
f: PhantomData,
|
||||
|
||||
@@ -217,60 +216,67 @@ impl<D: gfx::Device,
|
||||
self.pads.remove(&dev_idx);
|
||||
},
|
||||
|
||||
// treadmill / camera reset
|
||||
Piston(Input::Press(Button::Keyboard(Key::Backspace))) => {
|
||||
self.treadmills = (0.0, 0.0);
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::D0))) => {
|
||||
self.camera = na::Matrix4::one();
|
||||
},
|
||||
Piston(Input::Button(ButtonArgs { state: ButtonState::Press,
|
||||
button: Button::Keyboard(key),
|
||||
.. })) => {
|
||||
match key {
|
||||
// treadmill / camera reset
|
||||
Key::Backspace => {
|
||||
self.treadmills = (0.0, 0.0);
|
||||
},
|
||||
Key::D0 => {
|
||||
self.camera = na::Matrix4::identity();
|
||||
},
|
||||
|
||||
// player movement
|
||||
Piston(Input::Press(Button::Keyboard(Key::Up))) => {
|
||||
self.lat = self.lat.wrapping_sub(1);
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::Down))) => {
|
||||
self.lat = self.lat.wrapping_add(1);
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::Left))) => {
|
||||
self.lng = self.lng.wrapping_sub(1);
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::Right))) => {
|
||||
self.lng = self.lng.wrapping_add(1);
|
||||
},
|
||||
// player movement
|
||||
Key::Up => {
|
||||
self.lat = self.lat.wrapping_sub(1);
|
||||
},
|
||||
Key::Down => {
|
||||
self.lat = self.lat.wrapping_add(1);
|
||||
},
|
||||
Key::Left => {
|
||||
self.lng = self.lng.wrapping_sub(1);
|
||||
},
|
||||
Key::Right => {
|
||||
self.lng = self.lng.wrapping_add(1);
|
||||
},
|
||||
|
||||
// scale adjustment
|
||||
Piston(Input::Press(Button::Keyboard(Key::Q))) => {
|
||||
self.constants = Constants { r1: R1 / 2.0, r2: R2 / 2.0, r3: R3 / 2.0, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::D1))) => {
|
||||
self.constants = Constants { r1: R1, r2: R2, r3: R3, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::D2))) => {
|
||||
self.constants = Constants { r1: R1 * 2.0, r2: R2 * 2.0, r3: R3 * 2.0, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::D3))) => {
|
||||
self.constants = Constants { r1: R1 * 4.0, r2: R2 * 4.0, r3: R3 * 4.0, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::D4))) => {
|
||||
self.constants = Constants { r1: R1 * 16.0, r2: R2 * 16.0, r3: R3 * 16.0, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
// scale adjustment
|
||||
Key::Q => {
|
||||
self.constants = Constants { r1: R1 / 2.0, r2: R2 / 2.0, r3: R3 / 2.0, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Key::D1 => {
|
||||
self.constants = Constants { r1: R1, r2: R2, r3: R3, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Key::D2 => {
|
||||
self.constants = Constants { r1: R1 * 2.0, r2: R2 * 2.0, r3: R3 * 2.0, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Key::D3 => {
|
||||
self.constants = Constants { r1: R1 * 4.0, r2: R2 * 4.0, r3: R3 * 4.0, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Key::D4 => {
|
||||
self.constants = Constants { r1: R1 * 16.0, r2: R2 * 16.0, r3: R3 * 16.0, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
|
||||
Piston(Input::Press(Button::Keyboard(Key::H))) => {
|
||||
self.constants = Constants { haze: self.constants.haze * 2.0f32.sqrt().sqrt(), ..self.constants };
|
||||
println!("haze: {}", self.constants.haze);
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::N))) => {
|
||||
self.constants = Constants { haze: self.constants.haze / 2.0f32.sqrt().sqrt(), ..self.constants };
|
||||
println!("haze: {}", self.constants.haze);
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Key::H => {
|
||||
self.constants = Constants { haze: self.constants.haze * 2.0f32.sqrt().sqrt(), ..self.constants };
|
||||
println!("haze: {}", self.constants.haze);
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Key::N => {
|
||||
self.constants = Constants { haze: self.constants.haze / 2.0f32.sqrt().sqrt(), ..self.constants };
|
||||
println!("haze: {}", self.constants.haze);
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
@@ -291,31 +297,31 @@ impl<D: gfx::Device,
|
||||
TrackMode::Touch => {
|
||||
const THRESHOLD: f32 = 0.005;
|
||||
const SCALE: f32 = 32.0;
|
||||
let xdiff = state.rAxis[0].x - old_state.rAxis[0].x;
|
||||
let ydiff = state.rAxis[0].y - old_state.rAxis[0].y;
|
||||
let xdiff = state.axis[0].x - old_state.axis[0].x;
|
||||
let ydiff = state.axis[0].y - old_state.axis[0].y;
|
||||
if xdiff.abs() > THRESHOLD { self.treadmills.0 += SCALE * xdiff; }
|
||||
if ydiff.abs() > THRESHOLD { self.treadmills.1 += SCALE * ydiff; }
|
||||
},
|
||||
TrackMode::Press => {
|
||||
let rot = na::Vector3::new(0.0, 0.0, 0.0);
|
||||
let speed = R2 * 0.005;
|
||||
if state.rAxis[0].x > 0.5 {
|
||||
if state.axis[0].x > 0.5 {
|
||||
self.camera = na::Similarity3::new(na::Vector3::new(-speed, 0.0, 0.0),
|
||||
rot, 1.0).to_homogeneous() * self.camera;
|
||||
} if state.rAxis[0].x < -0.5 {
|
||||
} if state.axis[0].x < -0.5 {
|
||||
self.camera = na::Similarity3::new(na::Vector3::new( speed, 0.0, 0.0),
|
||||
rot, 1.0).to_homogeneous() * self.camera;
|
||||
} if state.rAxis[0].y > 0.5 {
|
||||
} if state.axis[0].y > 0.5 {
|
||||
self.camera = na::Similarity3::new(na::Vector3::new( 0.0, -speed, 0.0),
|
||||
rot, 1.0).to_homogeneous() * self.camera;
|
||||
} if state.rAxis[0].y < -0.5 {
|
||||
} if state.axis[0].y < -0.5 {
|
||||
self.camera = na::Similarity3::new(na::Vector3::new( 0.0, speed, 0.0),
|
||||
rot, 1.0).to_homogeneous() * self.camera;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
if state.unPacketNum == old_state.unPacketNum {
|
||||
if state.packet_num == old_state.packet_num {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -359,9 +365,9 @@ impl<D: gfx::Device,
|
||||
let (y, x) = (self.lat as f32 + 0.5, self.lng as f32 + 0.5); // center of tile
|
||||
let eye = Self::toroid((x, y), r1, r2, r3);
|
||||
let looktgt = Self::toroid((x, y - 1.0), r1, r2, r3); // look ahead = north
|
||||
let normal = Self::toroid((x, y), 0.0, r2, r2) * na::Vector3::new(r2 / r3, 1.0, 1.0);
|
||||
self.camera * na::Isometry3::look_at_rh(eye.as_point(),
|
||||
looktgt.as_point(),
|
||||
let normal = Self::toroid((x, y), 0.0, r2, r2).component_mul(&na::Vector3::new(r2 / r3, 1.0, 1.0));
|
||||
self.camera * na::Isometry3::look_at_rh(&na::Point3::from_coordinates(eye),
|
||||
&na::Point3::from_coordinates(looktgt),
|
||||
&normal,
|
||||
).to_homogeneous()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user