Skip to content

Commit

Permalink
redo the economy plot
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Feb 7, 2024
1 parent 26accae commit 6dc2603
Show file tree
Hide file tree
Showing 9 changed files with 342 additions and 176 deletions.
2 changes: 1 addition & 1 deletion assets_gui/src/yakui_gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl State {
}
});
});
scroll_vertical(|| {
scroll_vertical(1000.0, || {
let mut l = List::column();
l.cross_axis_alignment = CrossAxisAlignment::Stretch;
l.show(|| {
Expand Down
52 changes: 26 additions & 26 deletions base_mod/companies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data:extend {
recipe = {
consumption = {{"flour", 1}},
production = {{"bread", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 3,
Expand All @@ -35,7 +35,7 @@ data:extend {
recipe = {
consumption = {{"cereal", 1}},
production = {{"flour", 10}},
duration = "200m",
duration = "200s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -55,7 +55,7 @@ data:extend {
recipe = {
consumption = {},
production = {{"cereal", 1}},
duration = "40m",
duration = "40s",
storage_multiplier = 5,
},
n_workers = 10,
Expand Down Expand Up @@ -105,7 +105,7 @@ data:extend {
recipe = {
consumption = {{"coal", 1}},
production = {},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -127,7 +127,7 @@ data:extend {
recipe = {
consumption = {{"meat", 1}, {"vegetable", 1}, {"cereal", 1}},
production = {},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -149,7 +149,7 @@ data:extend {
recipe = {
consumption = {{"cloth", 1}},
production = {},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -172,7 +172,7 @@ data:extend {
recipe = {
consumption = {{"polyester", 1}, {"wool", 1}},
production = {{"cloth", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -195,7 +195,7 @@ data:extend {
recipe = {
consumption = {{"wool", 1}},
production = {{"cloth", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -218,7 +218,7 @@ data:extend {
recipe = {
consumption = {{"oil", 1}},
production = {{"polyester", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 5,
Expand All @@ -241,7 +241,7 @@ data:extend {
recipe = {
consumption = {},
production = {{"oil", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 5,
Expand All @@ -264,7 +264,7 @@ data:extend {
recipe = {
consumption = {},
production = {{"coal", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 5,
Expand All @@ -286,7 +286,7 @@ data:extend {
recipe = {
consumption = {},
production = {{"wool", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -308,7 +308,7 @@ data:extend {
recipe = {
consumption = {{"flower", 1}},
production = {},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -331,7 +331,7 @@ data:extend {
recipe = {
consumption = {},
production = {{"flower", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 5,
Expand All @@ -353,7 +353,7 @@ data:extend {
recipe = {
consumption = {{"high-tech-product", 1}},
production = {},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -376,7 +376,7 @@ data:extend {
recipe = {
consumption = {{"gold", 1}, {"metal", 1}},
production = {{"high-tech-product", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -399,7 +399,7 @@ data:extend {
recipe = {
consumption = {},
production = {{"iron-ore", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -422,7 +422,7 @@ data:extend {
recipe = {
consumption = {},
production = {{"gold", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -442,7 +442,7 @@ data:extend {
recipe = {
consumption = {},
production = {{"tree-log", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -465,7 +465,7 @@ data:extend {
recipe = {
consumption = {{"tree-log", 1}},
production = {{"wood-plank", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -487,7 +487,7 @@ data:extend {
recipe = {
consumption = {{"metal", 1}, {"wood-plank", 1}},
production = {{"furniture", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -510,7 +510,7 @@ data:extend {
recipe = {
consumption = {{"iron-ore", 1}},
production = {{"metal", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -533,7 +533,7 @@ data:extend {
recipe = {
consumption = {{"carcass", 1}},
production = {{"raw-meat", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 5,
Expand All @@ -553,7 +553,7 @@ data:extend {
recipe = {
consumption = {{"cereal", 1}},
production = {{"carcass", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 5,
Expand All @@ -576,7 +576,7 @@ data:extend {
recipe = {
consumption = {{"raw-meat", 1}},
production = {{"meat", 1}},
duration = "100m",
duration = "100s",
storage_multiplier = 5,
},
n_workers = 10,
Expand All @@ -596,7 +596,7 @@ data:extend {
recipe = {
consumption = {},
production = {{"vegetable", 2}},
duration = "2m",
duration = "2s",
storage_multiplier = 5,
},
n_workers = 10,
Expand Down
10 changes: 9 additions & 1 deletion engine/src/geometry/tesselator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ impl<'a> Tesselator<'a> {
let dir = match (ae + ce).try_normalize() {
Some(x) => {
let d = ae.perp_dot(ce);

if d.abs() < 0.01 {
-ae.perpendicular()
} else if d < 0.0 {
Expand All @@ -431,7 +432,14 @@ impl<'a> Tesselator<'a> {
None => -ae.perpendicular(),
};

let mul = 1.0 + (1.0 + ae.dot(ce).min(0.0)) * (std::f32::consts::SQRT_2 - 1.0);
let mut sin_theta = ae.perp_dot(dir);

if sin_theta < 0.1 {
sin_theta = 0.1;
}

//let mul = 1.0 + (1.0 + ae.dot(ce).min(0.0)) * (std::f32::consts::SQRT_2 - 1.0);
let mul = 1.0 / sin_theta;

let p1 = elbow + (mul * dir * (offset + halfthick)).z0();
let p2 = elbow + (mul * dir * (offset - halfthick)).z0();
Expand Down
19 changes: 15 additions & 4 deletions geom/src/aabb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::Vec2;
use crate::{Circle, Intersect, Polygon, Segment, Shape, OBB};
use serde::{Deserialize, Serialize};
use std::panic::Location;

#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
#[repr(C)]
Expand All @@ -12,17 +13,21 @@ pub struct AABB {
impl AABB {
/// Create a new `AABB`.
#[inline]
#[cfg_attr(debug_assertions, track_caller)]
#[rustfmt::skip]
pub fn new_ll_ur(ll: Vec2, ur: Vec2) -> Self {
debug_assert!(ll.x <= ur.x);
debug_assert!(ll.y <= ur.y);
debug_assert!(ll.x <= ur.x, "ll.x ({}) > ur.x ({}) :( at {}", ll.x, ur.x, Location::caller());
debug_assert!(ll.y <= ur.y, "ll.y ({}) > ur.y ({}) :( at {}", ll.y, ur.y, Location::caller());
AABB { ll, ur }
}

/// Create a new `AABB`.
#[inline]
#[cfg_attr(debug_assertions, track_caller)]
#[rustfmt::skip]
pub fn new_ll_size(ll: Vec2, size: Vec2) -> Self {
debug_assert!(size.x >= 0.0);
debug_assert!(size.y >= 0.0);
debug_assert!(size.x >= 0.0, "size.x ({}) < 0 :( {}", size.x, Location::caller());
debug_assert!(size.y >= 0.0, "size.y ({}) < 0 :( {}", size.y, Location::caller());
AABB { ll, ur: ll + size }
}

Expand Down Expand Up @@ -116,6 +121,12 @@ impl AABB {
]
}

pub fn make_rescaler(&self, target: AABB) -> impl Fn(Vec2) -> Vec2 {
let scale = target.size() / self.size();
let offset = target.ll - self.ll * scale;
move |p| p * scale + offset
}

#[inline(always)]
pub fn compute_code(&self, p: Vec2) -> u8 {
const LEFT: u8 = 1; // 0001
Expand Down
Loading

0 comments on commit 6dc2603

Please sign in to comment.