Skip to content

Commit

Permalink
Add center positioning for caldera primitive (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
otto-link committed Oct 29, 2023
1 parent d50621c commit 091c56c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion external/HighMap
13 changes: 7 additions & 6 deletions include/hesiod/control_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,13 @@ class Caldera : public Primitive
void compute();

protected:
float radius = 128.f;
float sigma_inner = 16.f;
float sigma_outer = 32.f;
float noise_r_amp = 32.f;
float z_bottom = 0.5f;
float noise_ratio_z = 0.1f;
float radius = 128.f;
float sigma_inner = 16.f;
float sigma_outer = 32.f;
float noise_r_amp = 32.f;
float z_bottom = 0.5f;
float noise_ratio_z = 0.1f;
hmap::Vec2<float> center = {0.5f, 0.5f};
};

class Clamp : public Unary
Expand Down
3 changes: 2 additions & 1 deletion src/nodes/control_node/caldera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ void Caldera::compute()
p_noise_x,
this->noise_r_amp,
this->noise_ratio_z,
this->center,
shift,
scale);
});

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

Expand Down
10 changes: 10 additions & 0 deletions src/nodes/view_node/view_caldera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ bool ViewCaldera::render_settings()
ImGui::SliderFloat("noise_ratio_z", &this->noise_ratio_z, 0.f, 1.f, "%.2f");
has_changed |= this->trigger_update_after_edit();

ImGui::SliderFloat("center.x", &this->center.x, -0.5f, 1.5f, "%.2f");
has_changed |= this->trigger_update_after_edit();

ImGui::SliderFloat("center.y", &this->center.y, -0.5f, 1.5f, "%.2f");
has_changed |= this->trigger_update_after_edit();

ImGui::Separator();

if (hesiod::gui::slider_vmin_vmax(vmin, vmax))
Expand All @@ -62,6 +68,8 @@ void ViewCaldera::serialize_save(cereal::JSONOutputArchive &ar)
ar(cereal::make_nvp("z_bottom", this->z_bottom));
ar(cereal::make_nvp("noise_r_amp", this->noise_r_amp));
ar(cereal::make_nvp("noise_ratio_z", this->noise_ratio_z));
ar(cereal::make_nvp("center.x", this->center.x));
ar(cereal::make_nvp("cneter.y", this->center.y));
ar(cereal::make_nvp("vmin", this->vmin));
ar(cereal::make_nvp("vmax", this->vmax));
}
Expand All @@ -74,6 +82,8 @@ void ViewCaldera::serialize_load(cereal::JSONInputArchive &ar)
ar(cereal::make_nvp("z_bottom", this->z_bottom));
ar(cereal::make_nvp("noise_r_amp", this->noise_r_amp));
ar(cereal::make_nvp("noise_ratio_z", this->noise_ratio_z));
ar(cereal::make_nvp("center.x", this->center.x));
ar(cereal::make_nvp("cneter.y", this->center.y));
ar(cereal::make_nvp("vmin", this->vmin));
ar(cereal::make_nvp("vmax", this->vmax));
}
Expand Down

0 comments on commit 091c56c

Please sign in to comment.