Skip to content

Commit

Permalink
Make remapping optional for base elevation node (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
otto-link committed Oct 26, 2023
1 parent 76179ac commit 7f7834c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/hesiod/control_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ class BaseElevation : public Primitive
{0.f, 0.f, 0.f},
{0.f, 0.f, 0.f}};
float width_factor = 1.f;
bool remap = false;
};

class BezierPath : public gnode::Node
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ int main()

tree.add_view_node("FbmPerlin");
// tree.add_view_node("ZeroedEdges");
tree.add_view_node("Plateau");
// tree.add_view_node("Plateau");
// tree.add_view_node("Path");
// tree.add_view_node("PathToHeightmap");
tree.new_link("FbmPerlin##0", "output", "Plateau##1", "input");
// tree.new_link("FbmPerlin##0", "output", "Plateau##1", "input");
// tree.new_link("Path##1", "output", "PathToHeightmap##2", "path");

// hmap::Cloud cloud = hmap::Cloud(5, 2);
Expand Down
3 changes: 2 additions & 1 deletion src/nodes/control_node/base_elevation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ void BaseElevation::compute()
});

// remap the output
this->value_out.remap(this->vmin, this->vmax);
if (this->remap)
this->value_out.remap(this->vmin, this->vmax);
}

} // namespace hesiod::cnode
20 changes: 14 additions & 6 deletions src/nodes/view_node/view_base_elevation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ bool ViewBaseElevation::render_settings()
has_changed = true;
}

ImGui::Separator();
ImGui::Checkbox("remap", &this->remap);
has_changed |= this->trigger_update_after_edit();

if (hesiod::gui::slider_vmin_vmax(vmin, vmax))
{
this->force_update();
has_changed = true;
}
if (this->remap)
if (hesiod::gui::slider_vmin_vmax(vmin, vmax))
{
this->force_update();
has_changed = true;
}

has_changed |= this->render_settings_footer();

Expand All @@ -55,12 +57,18 @@ void ViewBaseElevation::serialize_save(cereal::JSONOutputArchive &ar)
{
ar(cereal::make_nvp("values", this->values));
ar(cereal::make_nvp("width_factor", this->width_factor));
ar(cereal::make_nvp("remap", this->remap));
ar(cereal::make_nvp("vmin", this->vmin));
ar(cereal::make_nvp("vmax", this->vmax));
}

void ViewBaseElevation::serialize_load(cereal::JSONInputArchive &ar)
{
ar(cereal::make_nvp("values", this->values));
ar(cereal::make_nvp("width_factor", this->width_factor));
ar(cereal::make_nvp("remap", this->remap));
ar(cereal::make_nvp("vmin", this->vmin));
ar(cereal::make_nvp("vmax", this->vmax));
}

} // namespace hesiod::vnode

0 comments on commit 7f7834c

Please sign in to comment.