mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 01:13:53 +03:00
remove the experimental hi-res grass and park textures and all the
flagged off textures. going to experiment in a different branch instead.
This commit is contained in:
parent
c523f7fb9c
commit
81a19eb78d
@ -65,6 +65,5 @@ Other binary data bundled in:
|
||||
|
||||
- DejaVuSans.ttf (https://dejavu-fonts.github.io/License.html)
|
||||
- Roboto-Regular.ttf (https://fonts.google.com/specimen/Roboto, Apache license)
|
||||
- http://www.textures4photoshop.com for textures
|
||||
- Icons from https://thenounproject.com/aiga-icons/,
|
||||
https://thenounproject.com/sakchai.ruankam, https://thenounproject.com/wilmax
|
||||
|
@ -47,21 +47,10 @@ impl<'a> EventCtx<'a> {
|
||||
|| self.input.get_mouse_scroll().is_some()
|
||||
}
|
||||
|
||||
pub fn set_textures(
|
||||
&mut self,
|
||||
skip_textures: Vec<(&str, Color)>,
|
||||
textures: Vec<(&str, TextureType)>,
|
||||
timer: &mut Timer,
|
||||
) {
|
||||
pub fn set_textures(&mut self, textures: Vec<(&str, TextureType)>, timer: &mut Timer) {
|
||||
self.canvas.texture_arrays.clear();
|
||||
self.canvas.texture_lookups.clear();
|
||||
|
||||
for (filename, fallback) in skip_textures {
|
||||
self.canvas
|
||||
.texture_lookups
|
||||
.insert(filename.to_string(), fallback);
|
||||
}
|
||||
|
||||
// Group textures with the same dimensions and create a texture array. Videocards have a
|
||||
// limit on the number of textures that can be uploaded.
|
||||
let mut dims_to_textures: BTreeMap<(u32, u32), Vec<(String, Vec<u8>, TextureType)>> =
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.2 MiB |
Binary file not shown.
Before Width: | Height: | Size: 49 KiB |
Binary file not shown.
Before Width: | Height: | Size: 765 KiB |
@ -32,7 +32,6 @@ fn main() {
|
||||
kml: args.optional("--kml"),
|
||||
draw_lane_markings: !args.enabled("--dont_draw_lane_markings"),
|
||||
num_agents: args.optional_parse("--num_agents", |s| s.parse()),
|
||||
textures: args.enabled("--textures"),
|
||||
};
|
||||
let mut opts = options::Options::default();
|
||||
if args.enabled("--dev") {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::helpers::ID;
|
||||
use crate::helpers::{ColorScheme, ID};
|
||||
use crate::render::{DrawCtx, DrawOptions, Renderable};
|
||||
use ezgui::{Color, EventCtx, GeomBatch, GfxCtx};
|
||||
use ezgui::{Color, GeomBatch, GfxCtx};
|
||||
use geom::Polygon;
|
||||
use map_model::{Area, AreaID, AreaType, Map};
|
||||
|
||||
@ -9,10 +9,10 @@ pub struct DrawArea {
|
||||
}
|
||||
|
||||
impl DrawArea {
|
||||
pub fn new(area: &Area, ctx: &EventCtx, all_areas: &mut GeomBatch) -> DrawArea {
|
||||
pub fn new(area: &Area, cs: &ColorScheme, all_areas: &mut GeomBatch) -> DrawArea {
|
||||
let color = match area.area_type {
|
||||
AreaType::Park => ctx.canvas.texture("assets/grass_texture.png"),
|
||||
AreaType::Water => ctx.canvas.texture("assets/water_texture.png"),
|
||||
AreaType::Park => cs.get_def("grass", Color::hex("#94C84A")),
|
||||
AreaType::Water => cs.get_def("water", Color::rgb(164, 200, 234)),
|
||||
AreaType::PedestrianIsland => Color::grey(0.3),
|
||||
};
|
||||
all_areas.push(color, area.polygon.clone());
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::helpers::{ColorScheme, ID};
|
||||
use crate::render::{AgentColorScheme, DrawCtx, DrawOptions, Renderable, OUTLINE_THICKNESS};
|
||||
use ezgui::{Canvas, Color, Drawable, GeomBatch, GfxCtx, Line, Prerender, Text};
|
||||
use ezgui::{Color, Drawable, GeomBatch, GfxCtx, Line, Prerender, Text};
|
||||
use geom::{Angle, Circle, Distance, PolyLine, Polygon, Pt2D};
|
||||
use map_model::{Map, TurnType};
|
||||
use sim::{CarID, DrawCarInput};
|
||||
@ -22,128 +22,115 @@ impl DrawCar {
|
||||
input: DrawCarInput,
|
||||
map: &Map,
|
||||
prerender: &Prerender,
|
||||
canvas: &Canvas,
|
||||
cs: &ColorScheme,
|
||||
acs: AgentColorScheme,
|
||||
use_textures: bool,
|
||||
) -> DrawCar {
|
||||
let mut draw_default = GeomBatch::new();
|
||||
let body_polygon = input.body.make_polygons(CAR_WIDTH);
|
||||
|
||||
if use_textures {
|
||||
if let Some(p) = input.body.make_polygons_with_uv(CAR_WIDTH) {
|
||||
draw_default.push(canvas.texture("assets/car.png"), p);
|
||||
} else {
|
||||
draw_default.push(Color::RED, body_polygon.clone());
|
||||
}
|
||||
} else {
|
||||
draw_default.push(acs.zoomed_color_car(&input, cs), body_polygon.clone());
|
||||
draw_default.push(acs.zoomed_color_car(&input, cs), body_polygon.clone());
|
||||
|
||||
{
|
||||
let window_length_gap = Distance::meters(0.2);
|
||||
let window_thickness = Distance::meters(0.3);
|
||||
let front_window = {
|
||||
let (pos, angle) = input
|
||||
.body
|
||||
.dist_along(input.body.length() - Distance::meters(1.0));
|
||||
thick_line_from_angle(
|
||||
window_thickness,
|
||||
CAR_WIDTH - window_length_gap * 2.0,
|
||||
pos.project_away(
|
||||
CAR_WIDTH / 2.0 - window_length_gap,
|
||||
angle.rotate_degs(-90.0),
|
||||
),
|
||||
angle.rotate_degs(90.0),
|
||||
)
|
||||
};
|
||||
let back_window = {
|
||||
let (pos, angle) = input.body.dist_along(Distance::meters(1.0));
|
||||
thick_line_from_angle(
|
||||
window_thickness * 0.8,
|
||||
CAR_WIDTH - window_length_gap * 2.0,
|
||||
pos.project_away(
|
||||
CAR_WIDTH / 2.0 - window_length_gap,
|
||||
angle.rotate_degs(-90.0),
|
||||
),
|
||||
angle.rotate_degs(90.0),
|
||||
)
|
||||
};
|
||||
draw_default.push(cs.get_def("car window", Color::BLACK), front_window);
|
||||
draw_default.push(cs.get("car window"), back_window);
|
||||
}
|
||||
|
||||
{
|
||||
let radius = Distance::meters(0.3);
|
||||
let edge_offset = Distance::meters(0.5);
|
||||
let (front_pos, front_angle) =
|
||||
input.body.dist_along(input.body.length() - edge_offset);
|
||||
let (back_pos, back_angle) = input.body.dist_along(edge_offset);
|
||||
|
||||
let front_left = Circle::new(
|
||||
front_pos.project_away(
|
||||
CAR_WIDTH / 2.0 - edge_offset,
|
||||
front_angle.rotate_degs(-90.0),
|
||||
{
|
||||
let window_length_gap = Distance::meters(0.2);
|
||||
let window_thickness = Distance::meters(0.3);
|
||||
let front_window = {
|
||||
let (pos, angle) = input
|
||||
.body
|
||||
.dist_along(input.body.length() - Distance::meters(1.0));
|
||||
thick_line_from_angle(
|
||||
window_thickness,
|
||||
CAR_WIDTH - window_length_gap * 2.0,
|
||||
pos.project_away(
|
||||
CAR_WIDTH / 2.0 - window_length_gap,
|
||||
angle.rotate_degs(-90.0),
|
||||
),
|
||||
radius,
|
||||
);
|
||||
let front_right = Circle::new(
|
||||
front_pos
|
||||
.project_away(CAR_WIDTH / 2.0 - edge_offset, front_angle.rotate_degs(90.0)),
|
||||
radius,
|
||||
);
|
||||
let back_left = Circle::new(
|
||||
back_pos
|
||||
.project_away(CAR_WIDTH / 2.0 - edge_offset, back_angle.rotate_degs(-90.0)),
|
||||
radius,
|
||||
);
|
||||
let back_right = Circle::new(
|
||||
back_pos
|
||||
.project_away(CAR_WIDTH / 2.0 - edge_offset, back_angle.rotate_degs(90.0)),
|
||||
radius,
|
||||
);
|
||||
angle.rotate_degs(90.0),
|
||||
)
|
||||
};
|
||||
let back_window = {
|
||||
let (pos, angle) = input.body.dist_along(Distance::meters(1.0));
|
||||
thick_line_from_angle(
|
||||
window_thickness * 0.8,
|
||||
CAR_WIDTH - window_length_gap * 2.0,
|
||||
pos.project_away(
|
||||
CAR_WIDTH / 2.0 - window_length_gap,
|
||||
angle.rotate_degs(-90.0),
|
||||
),
|
||||
angle.rotate_degs(90.0),
|
||||
)
|
||||
};
|
||||
draw_default.push(cs.get_def("car window", Color::BLACK), front_window);
|
||||
draw_default.push(cs.get("car window"), back_window);
|
||||
}
|
||||
|
||||
let bg_color = cs.get_def("blinker background", Color::grey(0.2));
|
||||
for c in &[&front_left, &front_right, &back_left, &back_right] {
|
||||
draw_default.push(bg_color, c.to_polygon());
|
||||
}
|
||||
{
|
||||
let radius = Distance::meters(0.3);
|
||||
let edge_offset = Distance::meters(0.5);
|
||||
let (front_pos, front_angle) = input.body.dist_along(input.body.length() - edge_offset);
|
||||
let (back_pos, back_angle) = input.body.dist_along(edge_offset);
|
||||
|
||||
let arrow_color = cs.get_def("blinker on", Color::RED);
|
||||
if let Some(t) = input.waiting_for_turn {
|
||||
let turn = map.get_t(t);
|
||||
let angle = turn.angle();
|
||||
match turn.turn_type {
|
||||
TurnType::Left | TurnType::LaneChangeLeft => {
|
||||
for circle in vec![front_left, back_left] {
|
||||
draw_default.push(
|
||||
arrow_color,
|
||||
PolyLine::new(vec![
|
||||
circle.center.project_away(radius / 2.0, angle.opposite()),
|
||||
circle.center.project_away(radius / 2.0, angle),
|
||||
])
|
||||
.make_arrow(Distance::meters(0.15))
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
let front_left = Circle::new(
|
||||
front_pos.project_away(
|
||||
CAR_WIDTH / 2.0 - edge_offset,
|
||||
front_angle.rotate_degs(-90.0),
|
||||
),
|
||||
radius,
|
||||
);
|
||||
let front_right = Circle::new(
|
||||
front_pos
|
||||
.project_away(CAR_WIDTH / 2.0 - edge_offset, front_angle.rotate_degs(90.0)),
|
||||
radius,
|
||||
);
|
||||
let back_left = Circle::new(
|
||||
back_pos.project_away(CAR_WIDTH / 2.0 - edge_offset, back_angle.rotate_degs(-90.0)),
|
||||
radius,
|
||||
);
|
||||
let back_right = Circle::new(
|
||||
back_pos.project_away(CAR_WIDTH / 2.0 - edge_offset, back_angle.rotate_degs(90.0)),
|
||||
radius,
|
||||
);
|
||||
|
||||
let bg_color = cs.get_def("blinker background", Color::grey(0.2));
|
||||
for c in &[&front_left, &front_right, &back_left, &back_right] {
|
||||
draw_default.push(bg_color, c.to_polygon());
|
||||
}
|
||||
|
||||
let arrow_color = cs.get_def("blinker on", Color::RED);
|
||||
if let Some(t) = input.waiting_for_turn {
|
||||
let turn = map.get_t(t);
|
||||
let angle = turn.angle();
|
||||
match turn.turn_type {
|
||||
TurnType::Left | TurnType::LaneChangeLeft => {
|
||||
for circle in vec![front_left, back_left] {
|
||||
draw_default.push(
|
||||
arrow_color,
|
||||
PolyLine::new(vec![
|
||||
circle.center.project_away(radius / 2.0, angle.opposite()),
|
||||
circle.center.project_away(radius / 2.0, angle),
|
||||
])
|
||||
.make_arrow(Distance::meters(0.15))
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
TurnType::Right | TurnType::LaneChangeRight => {
|
||||
for circle in vec![front_right, back_right] {
|
||||
draw_default.push(
|
||||
arrow_color,
|
||||
PolyLine::new(vec![
|
||||
circle.center.project_away(radius / 2.0, angle.opposite()),
|
||||
circle.center.project_away(radius / 2.0, angle),
|
||||
])
|
||||
.make_arrow(Distance::meters(0.15))
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
}
|
||||
TurnType::Straight => {
|
||||
draw_default.push(arrow_color, back_left.to_polygon());
|
||||
draw_default.push(arrow_color, back_right.to_polygon());
|
||||
}
|
||||
TurnType::Crosswalk | TurnType::SharedSidewalkCorner => unreachable!(),
|
||||
}
|
||||
TurnType::Right | TurnType::LaneChangeRight => {
|
||||
for circle in vec![front_right, back_right] {
|
||||
draw_default.push(
|
||||
arrow_color,
|
||||
PolyLine::new(vec![
|
||||
circle.center.project_away(radius / 2.0, angle.opposite()),
|
||||
circle.center.project_away(radius / 2.0, angle),
|
||||
])
|
||||
.make_arrow(Distance::meters(0.15))
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
}
|
||||
TurnType::Straight => {
|
||||
draw_default.push(arrow_color, back_left.to_polygon());
|
||||
draw_default.push(arrow_color, back_right.to_polygon());
|
||||
}
|
||||
TurnType::Crosswalk | TurnType::SharedSidewalkCorner => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ impl DrawMap {
|
||||
timer.start_iter("make DrawAreas", map.all_areas().len());
|
||||
for a in map.all_areas() {
|
||||
timer.next();
|
||||
areas.push(DrawArea::new(a, ctx, &mut all_areas));
|
||||
areas.push(DrawArea::new(a, cs, &mut all_areas));
|
||||
}
|
||||
timer.start("upload all areas");
|
||||
let draw_all_areas = all_areas.upload(ctx);
|
||||
|
@ -25,7 +25,7 @@ pub use crate::render::pedestrian::{DrawPedCrowd, DrawPedestrian};
|
||||
pub use crate::render::road::DrawRoad;
|
||||
pub use crate::render::traffic_signal::{draw_signal_phase, TrafficSignalDiagram};
|
||||
pub use crate::render::turn::{DrawTurn, DrawTurnGroup};
|
||||
use ezgui::{Canvas, Color, GfxCtx, Prerender};
|
||||
use ezgui::{Color, GfxCtx, Prerender};
|
||||
use geom::{Distance, PolyLine, Polygon, Pt2D, EPSILON_DIST};
|
||||
use map_model::{IntersectionID, Map};
|
||||
use sim::{DrawCarInput, Sim, VehicleType};
|
||||
@ -65,23 +65,13 @@ pub fn draw_vehicle(
|
||||
input: DrawCarInput,
|
||||
map: &Map,
|
||||
prerender: &Prerender,
|
||||
canvas: &Canvas,
|
||||
cs: &ColorScheme,
|
||||
acs: AgentColorScheme,
|
||||
use_textures: bool,
|
||||
) -> Box<dyn Renderable> {
|
||||
if input.id.1 == VehicleType::Bike {
|
||||
Box::new(DrawBike::new(input, map, prerender, cs, acs))
|
||||
} else {
|
||||
Box::new(DrawCar::new(
|
||||
input,
|
||||
map,
|
||||
prerender,
|
||||
canvas,
|
||||
cs,
|
||||
acs,
|
||||
use_textures,
|
||||
))
|
||||
Box::new(DrawCar::new(input, map, prerender, cs, acs))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::helpers::{ColorScheme, ID};
|
||||
use crate::render::{AgentColorScheme, DrawCtx, DrawOptions, Renderable, OUTLINE_THICKNESS};
|
||||
use ezgui::{Canvas, Color, Drawable, GeomBatch, GfxCtx, Line, Prerender, Text};
|
||||
use ezgui::{Color, Drawable, GeomBatch, GfxCtx, Line, Prerender, Text};
|
||||
use geom::{Circle, Distance, PolyLine, Polygon};
|
||||
use map_model::{Map, LANE_THICKNESS};
|
||||
use sim::{DrawPedCrowdInput, DrawPedestrianInput, PedCrowdLocation, PedestrianID};
|
||||
@ -19,10 +19,8 @@ impl DrawPedestrian {
|
||||
step_count: usize,
|
||||
map: &Map,
|
||||
prerender: &Prerender,
|
||||
canvas: &Canvas,
|
||||
cs: &ColorScheme,
|
||||
acs: AgentColorScheme,
|
||||
use_textures: bool,
|
||||
) -> DrawPedestrian {
|
||||
// TODO Slight issues with rendering small pedestrians:
|
||||
// - route visualization is thick
|
||||
@ -33,110 +31,103 @@ impl DrawPedestrian {
|
||||
|
||||
let mut draw_default = GeomBatch::new();
|
||||
|
||||
if use_textures {
|
||||
let foot_radius = 0.2 * radius;
|
||||
let hand_radius = 0.2 * radius;
|
||||
let left_foot_angle = 30.0;
|
||||
let right_foot_angle = -30.0;
|
||||
let left_hand_angle = 70.0;
|
||||
let right_hand_angle = -70.0;
|
||||
|
||||
let left_foot = Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(radius, input.facing.rotate_degs(left_foot_angle)),
|
||||
foot_radius,
|
||||
);
|
||||
let right_foot = Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(radius, input.facing.rotate_degs(right_foot_angle)),
|
||||
foot_radius,
|
||||
);
|
||||
let left_hand = Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(radius, input.facing.rotate_degs(left_hand_angle)),
|
||||
hand_radius,
|
||||
);
|
||||
let right_hand = Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(radius, input.facing.rotate_degs(right_hand_angle)),
|
||||
hand_radius,
|
||||
);
|
||||
let foot_color = cs.get_def("pedestrian foot", Color::BLACK);
|
||||
let hand_color = cs.get("pedestrian head");
|
||||
// Jitter based on ID so we don't all walk synchronized.
|
||||
let jitter = input.id.0 % 2 == 0;
|
||||
let remainder = step_count % 6;
|
||||
if input.waiting_for_turn.is_some() {
|
||||
draw_default.push(foot_color, left_foot.to_polygon());
|
||||
draw_default.push(foot_color, right_foot.to_polygon());
|
||||
draw_default.push(hand_color, left_hand.to_polygon());
|
||||
draw_default.push(hand_color, right_hand.to_polygon());
|
||||
} else if jitter == (remainder < 3) {
|
||||
draw_default.push(foot_color, left_foot.to_polygon());
|
||||
draw_default.push(
|
||||
canvas.texture("assets/pedestrian.png").rotate(input.facing),
|
||||
body_circle.to_polygon(),
|
||||
foot_color,
|
||||
Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(0.9 * radius, input.facing.rotate_degs(right_foot_angle)),
|
||||
foot_radius,
|
||||
)
|
||||
.to_polygon(),
|
||||
);
|
||||
|
||||
draw_default.push(hand_color, right_hand.to_polygon());
|
||||
draw_default.push(
|
||||
hand_color,
|
||||
Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(0.9 * radius, input.facing.rotate_degs(left_hand_angle)),
|
||||
hand_radius,
|
||||
)
|
||||
.to_polygon(),
|
||||
);
|
||||
} else {
|
||||
let foot_radius = 0.2 * radius;
|
||||
let hand_radius = 0.2 * radius;
|
||||
let left_foot_angle = 30.0;
|
||||
let right_foot_angle = -30.0;
|
||||
let left_hand_angle = 70.0;
|
||||
let right_hand_angle = -70.0;
|
||||
|
||||
let left_foot = Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(radius, input.facing.rotate_degs(left_foot_angle)),
|
||||
foot_radius,
|
||||
);
|
||||
let right_foot = Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(radius, input.facing.rotate_degs(right_foot_angle)),
|
||||
foot_radius,
|
||||
);
|
||||
let left_hand = Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(radius, input.facing.rotate_degs(left_hand_angle)),
|
||||
hand_radius,
|
||||
);
|
||||
let right_hand = Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(radius, input.facing.rotate_degs(right_hand_angle)),
|
||||
hand_radius,
|
||||
);
|
||||
let foot_color = cs.get_def("pedestrian foot", Color::BLACK);
|
||||
let hand_color = cs.get("pedestrian head");
|
||||
// Jitter based on ID so we don't all walk synchronized.
|
||||
let jitter = input.id.0 % 2 == 0;
|
||||
let remainder = step_count % 6;
|
||||
if input.waiting_for_turn.is_some() {
|
||||
draw_default.push(foot_color, left_foot.to_polygon());
|
||||
draw_default.push(foot_color, right_foot.to_polygon());
|
||||
draw_default.push(hand_color, left_hand.to_polygon());
|
||||
draw_default.push(hand_color, right_hand.to_polygon());
|
||||
} else if jitter == (remainder < 3) {
|
||||
draw_default.push(foot_color, left_foot.to_polygon());
|
||||
draw_default.push(
|
||||
foot_color,
|
||||
Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(0.9 * radius, input.facing.rotate_degs(right_foot_angle)),
|
||||
foot_radius,
|
||||
)
|
||||
.to_polygon(),
|
||||
);
|
||||
|
||||
draw_default.push(hand_color, right_hand.to_polygon());
|
||||
draw_default.push(
|
||||
hand_color,
|
||||
Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(0.9 * radius, input.facing.rotate_degs(left_hand_angle)),
|
||||
hand_radius,
|
||||
)
|
||||
.to_polygon(),
|
||||
);
|
||||
} else {
|
||||
draw_default.push(foot_color, right_foot.to_polygon());
|
||||
draw_default.push(
|
||||
foot_color,
|
||||
Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(0.9 * radius, input.facing.rotate_degs(left_foot_angle)),
|
||||
foot_radius,
|
||||
)
|
||||
.to_polygon(),
|
||||
);
|
||||
|
||||
draw_default.push(hand_color, left_hand.to_polygon());
|
||||
draw_default.push(
|
||||
hand_color,
|
||||
Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(0.9 * radius, input.facing.rotate_degs(right_hand_angle)),
|
||||
hand_radius,
|
||||
)
|
||||
.to_polygon(),
|
||||
);
|
||||
};
|
||||
|
||||
let head_circle = Circle::new(input.pos, 0.5 * radius);
|
||||
draw_default.push(acs.zoomed_color_ped(&input, cs), body_circle.to_polygon());
|
||||
draw_default.push(foot_color, right_foot.to_polygon());
|
||||
draw_default.push(
|
||||
cs.get_def("pedestrian head", Color::rgb(139, 69, 19)),
|
||||
head_circle.to_polygon(),
|
||||
foot_color,
|
||||
Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(0.9 * radius, input.facing.rotate_degs(left_foot_angle)),
|
||||
foot_radius,
|
||||
)
|
||||
.to_polygon(),
|
||||
);
|
||||
}
|
||||
|
||||
draw_default.push(hand_color, left_hand.to_polygon());
|
||||
draw_default.push(
|
||||
hand_color,
|
||||
Circle::new(
|
||||
input
|
||||
.pos
|
||||
.project_away(0.9 * radius, input.facing.rotate_degs(right_hand_angle)),
|
||||
hand_radius,
|
||||
)
|
||||
.to_polygon(),
|
||||
);
|
||||
};
|
||||
|
||||
let head_circle = Circle::new(input.pos, 0.5 * radius);
|
||||
draw_default.push(acs.zoomed_color_ped(&input, cs), body_circle.to_polygon());
|
||||
draw_default.push(
|
||||
cs.get_def("pedestrian head", Color::rgb(139, 69, 19)),
|
||||
head_circle.to_polygon(),
|
||||
);
|
||||
|
||||
if let Some(t) = input.waiting_for_turn {
|
||||
// A silly idea for peds... use hands to point at their turn?
|
||||
|
102
game/src/ui.rs
102
game/src/ui.rs
@ -5,7 +5,7 @@ use crate::render::{
|
||||
DrawPedestrian, Renderable, MIN_ZOOM_FOR_DETAIL,
|
||||
};
|
||||
use abstutil::{MeasureMemory, Timer};
|
||||
use ezgui::{Canvas, Color, EventCtx, GfxCtx, Prerender, TextureType};
|
||||
use ezgui::{Color, EventCtx, GfxCtx, Prerender, TextureType};
|
||||
use geom::{Bounds, Circle, Distance, Pt2D};
|
||||
use map_model::{Map, Traversable};
|
||||
use rand::seq::SliceRandom;
|
||||
@ -24,60 +24,38 @@ impl UI {
|
||||
pub fn new(flags: Flags, opts: Options, ctx: &mut EventCtx, splash: bool) -> UI {
|
||||
let cs = ColorScheme::load(opts.color_scheme.clone());
|
||||
let primary = ctx.loading_screen("load map", |ctx, mut timer| {
|
||||
// Always load some small icons.
|
||||
let mut textures = vec![
|
||||
("assets/pregame/back.png", TextureType::Stretch),
|
||||
("assets/pregame/challenges.png", TextureType::Stretch),
|
||||
("assets/pregame/quit.png", TextureType::Stretch),
|
||||
("assets/pregame/sandbox.png", TextureType::Stretch),
|
||||
("assets/pregame/tutorial.png", TextureType::Stretch),
|
||||
("assets/pregame/logo.png", TextureType::Stretch),
|
||||
("assets/speed/jump_to_time.png", TextureType::Stretch),
|
||||
("assets/speed/large_step.png", TextureType::Stretch),
|
||||
("assets/speed/pause.png", TextureType::Stretch),
|
||||
("assets/speed/resume.png", TextureType::Stretch),
|
||||
("assets/speed/slow_down.png", TextureType::Stretch),
|
||||
("assets/speed/small_step.png", TextureType::Stretch),
|
||||
("assets/speed/speed_up.png", TextureType::Stretch),
|
||||
("assets/speed/sunrise.png", TextureType::Stretch),
|
||||
("assets/speed/sunset.png", TextureType::Stretch),
|
||||
("assets/ui/edit_bike.png", TextureType::Stretch),
|
||||
("assets/ui/edit_bus.png", TextureType::Stretch),
|
||||
("assets/ui/edit_construction.png", TextureType::Stretch),
|
||||
("assets/ui/edit_contraflow.png", TextureType::Stretch),
|
||||
("assets/ui/edit_driving.png", TextureType::Stretch),
|
||||
("assets/ui/edit_parking.png", TextureType::Stretch),
|
||||
("assets/ui/hamburger.png", TextureType::Stretch),
|
||||
("assets/ui/hide.png", TextureType::Stretch),
|
||||
("assets/ui/info.png", TextureType::Stretch),
|
||||
("assets/ui/location.png", TextureType::Stretch),
|
||||
("assets/ui/save.png", TextureType::Stretch),
|
||||
("assets/ui/show.png", TextureType::Stretch),
|
||||
];
|
||||
let skip_textures = if flags.textures {
|
||||
textures.extend(vec![
|
||||
("assets/water_texture.png", TextureType::Tile),
|
||||
("assets/grass_texture.png", TextureType::Tile),
|
||||
("assets/pedestrian.png", TextureType::Stretch),
|
||||
("assets/car.png", TextureType::CustomUV),
|
||||
]);
|
||||
Vec::new()
|
||||
} else {
|
||||
ctx.set_textures(
|
||||
vec![
|
||||
(
|
||||
"assets/water_texture.png",
|
||||
cs.get_def("water", Color::rgb(164, 200, 234)),
|
||||
),
|
||||
(
|
||||
"assets/grass_texture.png",
|
||||
cs.get_def("grass", Color::hex("#94C84A")),
|
||||
),
|
||||
("assets/pedestrian.png", Color::rgb(51, 178, 178)),
|
||||
("assets/car.png", Color::CYAN),
|
||||
]
|
||||
};
|
||||
|
||||
ctx.set_textures(skip_textures, textures, &mut timer);
|
||||
("assets/pregame/back.png", TextureType::Stretch),
|
||||
("assets/pregame/challenges.png", TextureType::Stretch),
|
||||
("assets/pregame/quit.png", TextureType::Stretch),
|
||||
("assets/pregame/sandbox.png", TextureType::Stretch),
|
||||
("assets/pregame/tutorial.png", TextureType::Stretch),
|
||||
("assets/pregame/logo.png", TextureType::Stretch),
|
||||
("assets/speed/jump_to_time.png", TextureType::Stretch),
|
||||
("assets/speed/large_step.png", TextureType::Stretch),
|
||||
("assets/speed/pause.png", TextureType::Stretch),
|
||||
("assets/speed/resume.png", TextureType::Stretch),
|
||||
("assets/speed/slow_down.png", TextureType::Stretch),
|
||||
("assets/speed/small_step.png", TextureType::Stretch),
|
||||
("assets/speed/speed_up.png", TextureType::Stretch),
|
||||
("assets/speed/sunrise.png", TextureType::Stretch),
|
||||
("assets/speed/sunset.png", TextureType::Stretch),
|
||||
("assets/ui/edit_bike.png", TextureType::Stretch),
|
||||
("assets/ui/edit_bus.png", TextureType::Stretch),
|
||||
("assets/ui/edit_construction.png", TextureType::Stretch),
|
||||
("assets/ui/edit_contraflow.png", TextureType::Stretch),
|
||||
("assets/ui/edit_driving.png", TextureType::Stretch),
|
||||
("assets/ui/edit_parking.png", TextureType::Stretch),
|
||||
("assets/ui/hamburger.png", TextureType::Stretch),
|
||||
("assets/ui/hide.png", TextureType::Stretch),
|
||||
("assets/ui/info.png", TextureType::Stretch),
|
||||
("assets/ui/location.png", TextureType::Stretch),
|
||||
("assets/ui/save.png", TextureType::Stretch),
|
||||
("assets/ui/show.png", TextureType::Stretch),
|
||||
],
|
||||
&mut timer,
|
||||
);
|
||||
|
||||
PerMapUI::new(flags, &cs, ctx, &mut timer)
|
||||
});
|
||||
@ -189,7 +167,6 @@ impl UI {
|
||||
let objects = self.get_renderables_back_to_front(
|
||||
g.get_screen_bounds(),
|
||||
&g.prerender,
|
||||
&g.canvas,
|
||||
&mut cache,
|
||||
source,
|
||||
show_objs,
|
||||
@ -264,7 +241,6 @@ impl UI {
|
||||
let mut objects = self.get_renderables_back_to_front(
|
||||
Circle::new(pt, Distance::meters(3.0)).get_bounds(),
|
||||
ctx.prerender,
|
||||
ctx.canvas,
|
||||
&mut cache,
|
||||
source,
|
||||
show_objs,
|
||||
@ -302,7 +278,6 @@ impl UI {
|
||||
&'a self,
|
||||
bounds: Bounds,
|
||||
prerender: &Prerender,
|
||||
canvas: &Canvas,
|
||||
agents: &'a mut AgentCache,
|
||||
source: &dyn GetDrawAgents,
|
||||
show_objs: &dyn ShowObject,
|
||||
@ -372,15 +347,7 @@ impl UI {
|
||||
if !agents.has(time, *on) {
|
||||
let mut list: Vec<Box<dyn Renderable>> = Vec::new();
|
||||
for c in source.get_draw_cars(*on, map).into_iter() {
|
||||
list.push(draw_vehicle(
|
||||
c,
|
||||
map,
|
||||
prerender,
|
||||
canvas,
|
||||
&self.cs,
|
||||
self.agent_cs,
|
||||
self.primary.current_flags.textures,
|
||||
));
|
||||
list.push(draw_vehicle(c, map, prerender, &self.cs, self.agent_cs));
|
||||
}
|
||||
let (loners, crowds) = source.get_draw_peds(*on, map);
|
||||
for p in loners {
|
||||
@ -389,10 +356,8 @@ impl UI {
|
||||
step_count,
|
||||
map,
|
||||
prerender,
|
||||
canvas,
|
||||
&self.cs,
|
||||
self.agent_cs,
|
||||
self.primary.current_flags.textures,
|
||||
)));
|
||||
}
|
||||
for c in crowds {
|
||||
@ -473,7 +438,6 @@ pub struct Flags {
|
||||
// Number of agents to generate when requested. If unspecified, trips to/from borders will be
|
||||
// included.
|
||||
pub num_agents: Option<usize>,
|
||||
pub textures: bool,
|
||||
}
|
||||
|
||||
// All of the state that's bound to a specific map+edit has to live here.
|
||||
|
@ -70,7 +70,6 @@ impl UI {
|
||||
Model::blank()
|
||||
};
|
||||
ctx.set_textures(
|
||||
Vec::new(),
|
||||
vec![
|
||||
("assets/ui/hide.png", TextureType::Stretch),
|
||||
("assets/ui/show.png", TextureType::Stretch),
|
||||
|
Loading…
Reference in New Issue
Block a user