Skip to content

Commit

Permalink
[geozones] Normalize coordinates in the ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jun 25, 2024
1 parent c6d9504 commit 53c39f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 17 additions & 1 deletion examples/Advanced/GeoZones/GeoZones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,23 @@ void GeoZones::operator()()
}

outputs.zones.value = oscr::to_ossia_value(m_outputs);
send_message({pos_message{inputs.latitude, inputs.longitude}});
if(inputs.normalize)
{
send_message({pos_message{inputs.latitude, inputs.longitude}});
}
else
{
// put the inputs / outputs between 0 / 1

const float w = m_bounding1.x() - m_bounding0.x();
const float h = m_bounding1.y() - m_bounding0.y();
if(w > 0 && h > 0)
{
const float lat = (inputs.latitude - m_bounding0.x()) / w;
const float lon = (inputs.longitude - m_bounding0.y()) / h;
send_message({pos_message{lat, lon}});
}
}
}

void GeoZones::loadZones()
Expand Down
3 changes: 3 additions & 0 deletions include/avnd/common/struct_reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ struct fields_introspection
static constexpr auto size = pfr::tuple_size_v<type>;
using indices_n = std::make_integer_sequence<int, size>;

template <std::size_t N>
using field_type = pfr::tuple_element_t<N, T>;

static constexpr void for_all(auto&& func) noexcept
{
if constexpr(size > 0)
Expand Down

0 comments on commit 53c39f1

Please sign in to comment.