From f728fdd7319b88c299826d6a98aa11d3ec1ba6e4 Mon Sep 17 00:00:00 2001 From: hop311 Date: Sun, 14 Apr 2024 23:51:10 +0100 Subject: Rework province position loading and map dims --- src/openvic-simulation/dataloader/NodeTools.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/openvic-simulation/dataloader/NodeTools.hpp') 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 + constexpr Callback auto negate_callback(Callback 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 + constexpr Callback> auto flip_y_callback(Callback> auto callback, T height) { + return [callback, height](vec2_t val) -> bool { + val.y = height - val.y; + return callback(val); + }; + } } } -- cgit v1.2.3-56-ga3b1