diff options
author | hop311 <hop3114@gmail.com> | 2024-04-15 00:51:10 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-04-15 00:51:10 +0200 |
commit | f728fdd7319b88c299826d6a98aa11d3ec1ba6e4 (patch) | |
tree | c3ea25983923b191fe2dacf4c578086fde786726 /src/openvic-simulation/dataloader | |
parent | 5799836bee29024ce8a2d0fc45e06664c0110751 (diff) |
Rework province position loading and map dims
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp index c41c09e..0df057a 100644 --- a/src/openvic-simulation/dataloader/NodeTools.hpp +++ b/src/openvic-simulation/dataloader/NodeTools.hpp @@ -506,5 +506,24 @@ namespace OpenVic { return warn; }; } + + /* Often used for rotations which must be negated due to OpenVic's coordinate system being orientated + * oppositely to Vic2's. */ + template<typename T = fixed_point_t> + constexpr Callback<T> auto negate_callback(Callback<T> auto callback) { + return [callback](T val) -> bool { + return callback(-val); + }; + } + + /* Often used for map-space coordinates which must have their y-coordinate flipped due to OpenVic using the + * top-left of the map as the origin as opposed Vic2 using the bottom-left. */ + template<typename T> + constexpr Callback<vec2_t<T>> auto flip_y_callback(Callback<vec2_t<T>> auto callback, T height) { + return [callback, height](vec2_t<T> val) -> bool { + val.y = height - val.y; + return callback(val); + }; + } } } |