Skip to content

Commit

Permalink
[maptool] Implement learn
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Nov 1, 2024
1 parent 9d15a79 commit 2a76f2c
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions examples/Advanced/Utilities/MapTool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@ struct MapTool

struct ins
{
halp::spinbox_f32<"Min", halp::free_range_min<>> in_min;
halp::spinbox_f32<"Max", halp::free_range_max<>> in_max;
struct : halp::spinbox_f32<"Min", halp::free_range_min<>>
{
halp_flag(class_attribute);
std::function<void(float)> update_controller;
} in_min;
struct : halp::spinbox_f32<"Max", halp::free_range_max<>>
{
halp_flag(class_attribute);
std::function<void(float)> update_controller;
} in_max;

halp::toggle<"Learn min"> min_learn;
halp::toggle<"Learn max"> max_learn;
Expand Down Expand Up @@ -72,6 +80,20 @@ struct MapTool
double operator()(double v)
{
/// 0. Learn min / max
// TODO think of a better way to have host feature detection?
if(inputs.in_min.update_controller)
{
if(inputs.min_learn && v < inputs.in_min)
{
inputs.in_min.value = v;
inputs.in_min.update_controller(v);
}
if(inputs.max_learn && v > inputs.in_max)
{
inputs.in_max.value = v;
inputs.in_max.update_controller(v);
}
}

/// 1. Scale input to 0 - 1
double in_scale = (inputs.in_max - inputs.in_min);
Expand Down

0 comments on commit 2a76f2c

Please sign in to comment.