get rid of vecmath

This commit is contained in:
Dustin Carlino 2018-06-28 19:41:08 -07:00
parent 8e1f9b79f0
commit 34e7f11cda
10 changed files with 12 additions and 37 deletions

View File

@ -120,11 +120,8 @@ wait slow down even more -- before any of this change, lanes on adjacent roads s
- make final Map serializable too
- useful to precompute sidewalk paths
- waiting on https://github.com/paholg/dimensioned/issues/31 to release
- cant easily serialize ordered float, so move away from it first?
- isolate vec2d
- turn's slope() and vecmath::normalized
- split out geometry crate again
- let ezgui stuff depend on it too
- also a polygon struct? for parcels and buildings

View File

@ -23,4 +23,3 @@ sim = { path = "../sim" }
structopt = "0.2"
strum = "0.9.0"
strum_macros = "0.9.0"
vecmath = "0.3.1"

View File

@ -21,7 +21,6 @@ extern crate structopt;
extern crate strum;
#[macro_use]
extern crate strum_macros;
extern crate vecmath;
use ezgui::input::UserInput;
use glutin_window::GlutinWindow;

View File

@ -13,7 +13,6 @@ use map_model::geometry;
use render::{BIG_ARROW_TIP_LENGTH, TURN_ICON_ARROW_LENGTH, TURN_ICON_ARROW_THICKNESS,
TURN_ICON_ARROW_TIP_LENGTH};
use std::f64;
use vecmath;
#[derive(Debug)]
pub struct DrawTurn {
@ -27,23 +26,21 @@ pub struct DrawTurn {
impl DrawTurn {
pub fn new(map: &map_model::Map, turn: &map_model::Turn, offset_along_road: usize) -> DrawTurn {
let offset_along_road = offset_along_road as f64;
let src_pt = map.get_r(turn.src).last_pt();
let dst_pt = map.get_r(turn.dst).first_pt();
let slope = vecmath::vec2_normalized([dst_pt.x() - src_pt.x(), dst_pt.y() - src_pt.y()]);
let src_pt = turn.line.pt1();
let dst_pt = turn.line.pt2();
let angle = turn.line.angle();
let last_line = map.get_r(turn.src).last_line();
// Start the distance from the intersection
let icon_center = last_line
.reverse()
.unbounded_dist_along((offset_along_road + 0.5) * TURN_ICON_ARROW_LENGTH * si::M);
let icon_src = [
icon_center.x() - (TURN_ICON_ARROW_LENGTH / 2.0) * slope[0],
icon_center.y() - (TURN_ICON_ARROW_LENGTH / 2.0) * slope[1],
];
let icon_dst = [
icon_center.x() + (TURN_ICON_ARROW_LENGTH / 2.0) * slope[0],
icon_center.y() + (TURN_ICON_ARROW_LENGTH / 2.0) * slope[1],
];
let icon_src = icon_center
.project_away(TURN_ICON_ARROW_LENGTH / 2.0, angle.opposite())
.to_vec();
let icon_dst = icon_center
.project_away(TURN_ICON_ARROW_LENGTH / 2.0, angle)
.to_vec();
let icon_circle = geometry::circle(
icon_center.x(),

View File

@ -13,4 +13,3 @@ piston2d-graphics = "*"
rand = "0.5.1"
serde = "1.0"
serde_derive = "1.0"
vecmath = "0.3.1"

View File

@ -10,7 +10,6 @@ extern crate rand;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate vecmath;
mod building;
pub mod geometry;

View File

@ -7,7 +7,6 @@ use Pt2D;
use RoadID;
use dimensioned::si;
use std::f64;
use vecmath;
// TODO reconsider pub usize. maybe outside world shouldnt know.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
@ -49,12 +48,4 @@ impl Turn {
pub fn length(&self) -> si::Meter<f64> {
self.line.length()
}
// TODO rethink this one
pub fn slope(&self) -> [f64; 2] {
vecmath::vec2_normalized([
self.line.pt2().x() - self.line.pt1().x(),
self.line.pt2().y() - self.line.pt1().y(),
])
}
}

View File

@ -15,4 +15,3 @@ piston2d-graphics = "*"
rand = { version = "0.5.1", features = ["serde1"] }
serde = "1.0"
serde_derive = "1.0"
vecmath = "0.3.1"

View File

@ -12,7 +12,6 @@ extern crate rand;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate vecmath;
pub mod common;
mod straw_intersections;

View File

@ -495,13 +495,9 @@ impl Sim {
let mut cars = self.roads[r.0].get_draw_cars(&self, map);
for c in &mut cars {
if let Some(on) = self.cars[&c.id].waiting_for {
let slope = map.get_t(on.as_turn()).slope();
c.turn_arrow = Some([
c.front.x() - (CAR_LENGTH / 2.0) * slope[0],
c.front.y() - (CAR_LENGTH / 2.0) * slope[1],
c.front.x(),
c.front.y(),
]);
let angle = map.get_t(on.as_turn()).line.angle();
let arrow_pt = c.front.project_away(CAR_LENGTH / 2.0, angle.opposite());
c.turn_arrow = Some([arrow_pt.x(), arrow_pt.y(), c.front.x(), c.front.y()]);
}
}
cars