diff -r a4055f67b9c7 -r cb81ecb5fb23 src/basics.h --- a/src/basics.h Thu Feb 13 15:25:01 2020 +0200 +++ b/src/basics.h Wed Feb 26 02:21:07 2020 +0200 @@ -108,30 +108,48 @@ /** -* @brief casts double and long double - and only those types - to float -* @param[in] x double or long double to cast +* @brief casts floating point values to float, converting non-floating point values causes an error +* @param[in] x floating point value to cast * @returns float */ template -auto doubleToFloat(T x) - -> std::enable_if_t< - std::is_same_v, double> || - std::is_same_v, long double - >, float> +auto toFloat(T x) -> std::enable_if_t, float> { return static_cast(x); } /** -* @brief Casts float - and only float - to double -* @param[in] x float to cast +* @brief casts floating point values to double, converting non-floating point values causes an error +* @param[in] x floating point value to cast * @returns double */ template -auto floatToDouble(T x) - -> std::enable_if_t, float>, double> +auto toDouble(T x) -> std::enable_if_t, double> { return static_cast(x); } + +template +inline QPoint toQPoint(const glm::vec& vec) +{ + return {static_cast(vec.x), static_cast(vec.y)}; +} + +template +inline QPointF toQPointF(const glm::vec& vec) +{ + return {toDouble(vec.x), toDouble(vec.y)}; +} + +inline glm::vec2 toVec2(const QPoint& point) +{ + return {point.x(), point.y()}; +} + +inline glm::vec2 toVec2(const QPointF& point) +{ + return {point.x(), point.y()}; +} + Q_DECLARE_METATYPE(glm::vec3) Q_DECLARE_METATYPE(glm::mat4)