Skip to content

Commit

Permalink
msvc: fixes for compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Dec 28, 2024
1 parent 6787ff5 commit 94b1c3c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
22 changes: 14 additions & 8 deletions include/avnd/binding/ossia/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,23 +378,29 @@ void mesh_from_ossia(const ossia::geometry& src, T& dst)
for(const ossia::geometry::binding& in : src.bindings)
{
using value_type = typename decltype(dst.bindings)::value_type;
using stride_type = decltype(value_type::stride);
using step_rate_type = decltype(value_type::step_rate);
using classification_type = decltype(value_type::classification);
dst.bindings.push_back({
.stride = in.stride,
.step_rate = in.step_rate,
.classification
= static_cast<decltype(value_type::classification)>(in.classification) // FIXME
.stride = static_cast<stride_type>(in.stride),
.step_rate = static_cast<step_rate_type>(in.step_rate),
.classification = static_cast<classification_type>(in.classification)
});
}

dst.attributes.clear();
for(const ossia::geometry::attribute& in : src.attributes)
{
using value_type = typename decltype(dst.attributes)::value_type;
using binding_type = decltype(value_type::binding);
using location_type = decltype(value_type::location);
using format_type = decltype(value_type::format);
using offset_type = decltype(value_type::offset);
dst.attributes.push_back(
{.binding = in.binding,
.location = static_cast<decltype(value_type::location)>(in.location),
.format = static_cast<decltype(value_type::format)>(in.format), // FIXME
.offset = in.offset});
{.binding = static_cast<binding_type>(in.binding),
.location = static_cast<location_type>(in.location),
.format = static_cast<format_type>(in.format),
.offset = static_cast<offset_type>(in.offset)});
}
}

Expand Down
35 changes: 22 additions & 13 deletions include/avnd/wrappers/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@

namespace avnd
{
// Was a lambda but turned into a function
// because MSVC:
// error C2039: 'effect': is not a member of 'examples::helpers::SpriteReader'

template <typename F, typename T>
static constexpr inline void init_controls_impl(F& state, T& ctl)
{
if constexpr(avnd::has_range<T>)
{
static_constexpr auto c = avnd::get_range<T>();
// clang-format off
if_possible(ctl.value = c.values[c.init].second) // For {string,value} enums
else if_possible(ctl.value = c.values[c.init]) // For string enums
else if_possible(ctl.value = c.init); // Default case
// clang-format on
}

if_possible(ctl.update(state.effect));
}

template <typename F>
static constexpr void init_controls(F& state)
{
Expand All @@ -25,19 +45,8 @@ static constexpr void init_controls(F& state)
}
else
{
avnd::for_each_field_ref(state.inputs, [&]<typename T>(T& ctl) {
if constexpr(avnd::has_range<T>)
{
static_constexpr auto c = avnd::get_range<T>();
// clang-format off
if_possible(ctl.value = c.values[c.init].second) // For {string,value} enums
else if_possible(ctl.value = c.values[c.init]) // For string enums
else if_possible(ctl.value = c.init); // Default case
// clang-format on
}

if_possible(ctl.update(state.effect));
});
avnd::for_each_field_ref(
state.inputs, [&]<typename T>(T& ctl) { init_controls_impl(state, ctl); });
}
}

Expand Down
4 changes: 3 additions & 1 deletion include/avnd/wrappers/process_execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ auto current_tick(avnd::effect_container<T>& implementation, const Tick& tick_da
requires { t.signature; } && requires { tick_data.signature(); })
{
auto [num, denom] = tick_data.signature();
t.signature = {num, denom};
auto& [tnum, tdenom] = t.signature;
tnum = num;
tdenom = denom;
}
if_possible(t.position_in_frames = tick_data.position_in_frames());
if_possible(t.position_in_seconds = tick_data.position_in_seconds());
Expand Down

0 comments on commit 94b1c3c

Please sign in to comment.