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:
Dustin Carlino 2019-12-05 09:37:05 -08:00
parent c523f7fb9c
commit 81a19eb78d
14 changed files with 233 additions and 315 deletions

View File

@ -65,6 +65,5 @@ Other binary data bundled in:
- DejaVuSans.ttf (https://dejavu-fonts.github.io/License.html) - DejaVuSans.ttf (https://dejavu-fonts.github.io/License.html)
- Roboto-Regular.ttf (https://fonts.google.com/specimen/Roboto, Apache license) - Roboto-Regular.ttf (https://fonts.google.com/specimen/Roboto, Apache license)
- http://www.textures4photoshop.com for textures
- Icons from https://thenounproject.com/aiga-icons/, - Icons from https://thenounproject.com/aiga-icons/,
https://thenounproject.com/sakchai.ruankam, https://thenounproject.com/wilmax https://thenounproject.com/sakchai.ruankam, https://thenounproject.com/wilmax

View File

@ -47,21 +47,10 @@ impl<'a> EventCtx<'a> {
|| self.input.get_mouse_scroll().is_some() || self.input.get_mouse_scroll().is_some()
} }
pub fn set_textures( pub fn set_textures(&mut self, textures: Vec<(&str, TextureType)>, timer: &mut Timer) {
&mut self,
skip_textures: Vec<(&str, Color)>,
textures: Vec<(&str, TextureType)>,
timer: &mut Timer,
) {
self.canvas.texture_arrays.clear(); self.canvas.texture_arrays.clear();
self.canvas.texture_lookups.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 // Group textures with the same dimensions and create a texture array. Videocards have a
// limit on the number of textures that can be uploaded. // limit on the number of textures that can be uploaded.
let mut dims_to_textures: BTreeMap<(u32, u32), Vec<(String, Vec<u8>, TextureType)>> = 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

View File

@ -32,7 +32,6 @@ fn main() {
kml: args.optional("--kml"), kml: args.optional("--kml"),
draw_lane_markings: !args.enabled("--dont_draw_lane_markings"), draw_lane_markings: !args.enabled("--dont_draw_lane_markings"),
num_agents: args.optional_parse("--num_agents", |s| s.parse()), num_agents: args.optional_parse("--num_agents", |s| s.parse()),
textures: args.enabled("--textures"),
}; };
let mut opts = options::Options::default(); let mut opts = options::Options::default();
if args.enabled("--dev") { if args.enabled("--dev") {

View File

@ -1,6 +1,6 @@
use crate::helpers::ID; use crate::helpers::{ColorScheme, ID};
use crate::render::{DrawCtx, DrawOptions, Renderable}; use crate::render::{DrawCtx, DrawOptions, Renderable};
use ezgui::{Color, EventCtx, GeomBatch, GfxCtx}; use ezgui::{Color, GeomBatch, GfxCtx};
use geom::Polygon; use geom::Polygon;
use map_model::{Area, AreaID, AreaType, Map}; use map_model::{Area, AreaID, AreaType, Map};
@ -9,10 +9,10 @@ pub struct DrawArea {
} }
impl 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 { let color = match area.area_type {
AreaType::Park => ctx.canvas.texture("assets/grass_texture.png"), AreaType::Park => cs.get_def("grass", Color::hex("#94C84A")),
AreaType::Water => ctx.canvas.texture("assets/water_texture.png"), AreaType::Water => cs.get_def("water", Color::rgb(164, 200, 234)),
AreaType::PedestrianIsland => Color::grey(0.3), AreaType::PedestrianIsland => Color::grey(0.3),
}; };
all_areas.push(color, area.polygon.clone()); all_areas.push(color, area.polygon.clone());

View File

@ -1,6 +1,6 @@
use crate::helpers::{ColorScheme, ID}; use crate::helpers::{ColorScheme, ID};
use crate::render::{AgentColorScheme, DrawCtx, DrawOptions, Renderable, OUTLINE_THICKNESS}; 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 geom::{Angle, Circle, Distance, PolyLine, Polygon, Pt2D};
use map_model::{Map, TurnType}; use map_model::{Map, TurnType};
use sim::{CarID, DrawCarInput}; use sim::{CarID, DrawCarInput};
@ -22,21 +22,12 @@ impl DrawCar {
input: DrawCarInput, input: DrawCarInput,
map: &Map, map: &Map,
prerender: &Prerender, prerender: &Prerender,
canvas: &Canvas,
cs: &ColorScheme, cs: &ColorScheme,
acs: AgentColorScheme, acs: AgentColorScheme,
use_textures: bool,
) -> DrawCar { ) -> DrawCar {
let mut draw_default = GeomBatch::new(); let mut draw_default = GeomBatch::new();
let body_polygon = input.body.make_polygons(CAR_WIDTH); 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());
{ {
@ -75,8 +66,7 @@ impl DrawCar {
{ {
let radius = Distance::meters(0.3); let radius = Distance::meters(0.3);
let edge_offset = Distance::meters(0.5); let edge_offset = Distance::meters(0.5);
let (front_pos, front_angle) = let (front_pos, front_angle) = input.body.dist_along(input.body.length() - edge_offset);
input.body.dist_along(input.body.length() - edge_offset);
let (back_pos, back_angle) = input.body.dist_along(edge_offset); let (back_pos, back_angle) = input.body.dist_along(edge_offset);
let front_left = Circle::new( let front_left = Circle::new(
@ -92,13 +82,11 @@ impl DrawCar {
radius, radius,
); );
let back_left = Circle::new( let back_left = Circle::new(
back_pos back_pos.project_away(CAR_WIDTH / 2.0 - edge_offset, back_angle.rotate_degs(-90.0)),
.project_away(CAR_WIDTH / 2.0 - edge_offset, back_angle.rotate_degs(-90.0)),
radius, radius,
); );
let back_right = Circle::new( let back_right = Circle::new(
back_pos back_pos.project_away(CAR_WIDTH / 2.0 - edge_offset, back_angle.rotate_degs(90.0)),
.project_away(CAR_WIDTH / 2.0 - edge_offset, back_angle.rotate_degs(90.0)),
radius, radius,
); );
@ -146,7 +134,6 @@ impl DrawCar {
} }
} }
} }
}
DrawCar { DrawCar {
id: input.id, id: input.id,

View File

@ -192,7 +192,7 @@ impl DrawMap {
timer.start_iter("make DrawAreas", map.all_areas().len()); timer.start_iter("make DrawAreas", map.all_areas().len());
for a in map.all_areas() { for a in map.all_areas() {
timer.next(); 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"); timer.start("upload all areas");
let draw_all_areas = all_areas.upload(ctx); let draw_all_areas = all_areas.upload(ctx);

View File

@ -25,7 +25,7 @@ pub use crate::render::pedestrian::{DrawPedCrowd, DrawPedestrian};
pub use crate::render::road::DrawRoad; pub use crate::render::road::DrawRoad;
pub use crate::render::traffic_signal::{draw_signal_phase, TrafficSignalDiagram}; pub use crate::render::traffic_signal::{draw_signal_phase, TrafficSignalDiagram};
pub use crate::render::turn::{DrawTurn, DrawTurnGroup}; 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 geom::{Distance, PolyLine, Polygon, Pt2D, EPSILON_DIST};
use map_model::{IntersectionID, Map}; use map_model::{IntersectionID, Map};
use sim::{DrawCarInput, Sim, VehicleType}; use sim::{DrawCarInput, Sim, VehicleType};
@ -65,23 +65,13 @@ pub fn draw_vehicle(
input: DrawCarInput, input: DrawCarInput,
map: &Map, map: &Map,
prerender: &Prerender, prerender: &Prerender,
canvas: &Canvas,
cs: &ColorScheme, cs: &ColorScheme,
acs: AgentColorScheme, acs: AgentColorScheme,
use_textures: bool,
) -> Box<dyn Renderable> { ) -> Box<dyn Renderable> {
if input.id.1 == VehicleType::Bike { if input.id.1 == VehicleType::Bike {
Box::new(DrawBike::new(input, map, prerender, cs, acs)) Box::new(DrawBike::new(input, map, prerender, cs, acs))
} else { } else {
Box::new(DrawCar::new( Box::new(DrawCar::new(input, map, prerender, cs, acs))
input,
map,
prerender,
canvas,
cs,
acs,
use_textures,
))
} }
} }

View File

@ -1,6 +1,6 @@
use crate::helpers::{ColorScheme, ID}; use crate::helpers::{ColorScheme, ID};
use crate::render::{AgentColorScheme, DrawCtx, DrawOptions, Renderable, OUTLINE_THICKNESS}; 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 geom::{Circle, Distance, PolyLine, Polygon};
use map_model::{Map, LANE_THICKNESS}; use map_model::{Map, LANE_THICKNESS};
use sim::{DrawPedCrowdInput, DrawPedestrianInput, PedCrowdLocation, PedestrianID}; use sim::{DrawPedCrowdInput, DrawPedestrianInput, PedCrowdLocation, PedestrianID};
@ -19,10 +19,8 @@ impl DrawPedestrian {
step_count: usize, step_count: usize,
map: &Map, map: &Map,
prerender: &Prerender, prerender: &Prerender,
canvas: &Canvas,
cs: &ColorScheme, cs: &ColorScheme,
acs: AgentColorScheme, acs: AgentColorScheme,
use_textures: bool,
) -> DrawPedestrian { ) -> DrawPedestrian {
// TODO Slight issues with rendering small pedestrians: // TODO Slight issues with rendering small pedestrians:
// - route visualization is thick // - route visualization is thick
@ -33,12 +31,6 @@ impl DrawPedestrian {
let mut draw_default = GeomBatch::new(); let mut draw_default = GeomBatch::new();
if use_textures {
draw_default.push(
canvas.texture("assets/pedestrian.png").rotate(input.facing),
body_circle.to_polygon(),
);
} else {
let foot_radius = 0.2 * radius; let foot_radius = 0.2 * radius;
let hand_radius = 0.2 * radius; let hand_radius = 0.2 * radius;
let left_foot_angle = 30.0; let left_foot_angle = 30.0;
@ -136,7 +128,6 @@ impl DrawPedestrian {
cs.get_def("pedestrian head", Color::rgb(139, 69, 19)), cs.get_def("pedestrian head", Color::rgb(139, 69, 19)),
head_circle.to_polygon(), head_circle.to_polygon(),
); );
}
if let Some(t) = input.waiting_for_turn { if let Some(t) = input.waiting_for_turn {
// A silly idea for peds... use hands to point at their turn? // A silly idea for peds... use hands to point at their turn?

View File

@ -5,7 +5,7 @@ use crate::render::{
DrawPedestrian, Renderable, MIN_ZOOM_FOR_DETAIL, DrawPedestrian, Renderable, MIN_ZOOM_FOR_DETAIL,
}; };
use abstutil::{MeasureMemory, Timer}; 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 geom::{Bounds, Circle, Distance, Pt2D};
use map_model::{Map, Traversable}; use map_model::{Map, Traversable};
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
@ -24,8 +24,8 @@ impl UI {
pub fn new(flags: Flags, opts: Options, ctx: &mut EventCtx, splash: bool) -> UI { pub fn new(flags: Flags, opts: Options, ctx: &mut EventCtx, splash: bool) -> UI {
let cs = ColorScheme::load(opts.color_scheme.clone()); let cs = ColorScheme::load(opts.color_scheme.clone());
let primary = ctx.loading_screen("load map", |ctx, mut timer| { let primary = ctx.loading_screen("load map", |ctx, mut timer| {
// Always load some small icons. ctx.set_textures(
let mut textures = vec![ vec![
("assets/pregame/back.png", TextureType::Stretch), ("assets/pregame/back.png", TextureType::Stretch),
("assets/pregame/challenges.png", TextureType::Stretch), ("assets/pregame/challenges.png", TextureType::Stretch),
("assets/pregame/quit.png", TextureType::Stretch), ("assets/pregame/quit.png", TextureType::Stretch),
@ -53,31 +53,9 @@ impl UI {
("assets/ui/location.png", TextureType::Stretch), ("assets/ui/location.png", TextureType::Stretch),
("assets/ui/save.png", TextureType::Stretch), ("assets/ui/save.png", TextureType::Stretch),
("assets/ui/show.png", TextureType::Stretch), ("assets/ui/show.png", TextureType::Stretch),
]; ],
let skip_textures = if flags.textures { &mut timer,
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 {
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);
PerMapUI::new(flags, &cs, ctx, &mut timer) PerMapUI::new(flags, &cs, ctx, &mut timer)
}); });
@ -189,7 +167,6 @@ impl UI {
let objects = self.get_renderables_back_to_front( let objects = self.get_renderables_back_to_front(
g.get_screen_bounds(), g.get_screen_bounds(),
&g.prerender, &g.prerender,
&g.canvas,
&mut cache, &mut cache,
source, source,
show_objs, show_objs,
@ -264,7 +241,6 @@ impl UI {
let mut objects = self.get_renderables_back_to_front( let mut objects = self.get_renderables_back_to_front(
Circle::new(pt, Distance::meters(3.0)).get_bounds(), Circle::new(pt, Distance::meters(3.0)).get_bounds(),
ctx.prerender, ctx.prerender,
ctx.canvas,
&mut cache, &mut cache,
source, source,
show_objs, show_objs,
@ -302,7 +278,6 @@ impl UI {
&'a self, &'a self,
bounds: Bounds, bounds: Bounds,
prerender: &Prerender, prerender: &Prerender,
canvas: &Canvas,
agents: &'a mut AgentCache, agents: &'a mut AgentCache,
source: &dyn GetDrawAgents, source: &dyn GetDrawAgents,
show_objs: &dyn ShowObject, show_objs: &dyn ShowObject,
@ -372,15 +347,7 @@ impl UI {
if !agents.has(time, *on) { if !agents.has(time, *on) {
let mut list: Vec<Box<dyn Renderable>> = Vec::new(); let mut list: Vec<Box<dyn Renderable>> = Vec::new();
for c in source.get_draw_cars(*on, map).into_iter() { for c in source.get_draw_cars(*on, map).into_iter() {
list.push(draw_vehicle( list.push(draw_vehicle(c, map, prerender, &self.cs, self.agent_cs));
c,
map,
prerender,
canvas,
&self.cs,
self.agent_cs,
self.primary.current_flags.textures,
));
} }
let (loners, crowds) = source.get_draw_peds(*on, map); let (loners, crowds) = source.get_draw_peds(*on, map);
for p in loners { for p in loners {
@ -389,10 +356,8 @@ impl UI {
step_count, step_count,
map, map,
prerender, prerender,
canvas,
&self.cs, &self.cs,
self.agent_cs, self.agent_cs,
self.primary.current_flags.textures,
))); )));
} }
for c in crowds { 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 // Number of agents to generate when requested. If unspecified, trips to/from borders will be
// included. // included.
pub num_agents: Option<usize>, pub num_agents: Option<usize>,
pub textures: bool,
} }
// All of the state that's bound to a specific map+edit has to live here. // All of the state that's bound to a specific map+edit has to live here.

View File

@ -70,7 +70,6 @@ impl UI {
Model::blank() Model::blank()
}; };
ctx.set_textures( ctx.set_textures(
Vec::new(),
vec![ vec![
("assets/ui/hide.png", TextureType::Stretch), ("assets/ui/hide.png", TextureType::Stretch),
("assets/ui/show.png", TextureType::Stretch), ("assets/ui/show.png", TextureType::Stretch),