-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RecastCracks node, fix angle scaling of GaborWave and Gavoronoise
- Loading branch information
Showing
5 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General | ||
* Public License. The full license is in the file LICENSE, distributed with | ||
* this software. */ | ||
#include "highmap/filters.hpp" | ||
|
||
#include "attributes.hpp" | ||
|
||
#include "hesiod/logger.hpp" | ||
#include "hesiod/model/nodes/base_node.hpp" | ||
#include "hesiod/model/utils.hpp" | ||
|
||
using namespace attr; | ||
|
||
namespace hesiod | ||
{ | ||
|
||
void setup_recast_cracks_node(BaseNode *p_node) | ||
{ | ||
LOG->trace("setup node {}", p_node->get_label()); | ||
|
||
// port(s) | ||
p_node->add_port<hmap::Heightmap>(gnode::PortType::IN, "input"); | ||
p_node->add_port<hmap::Heightmap>(gnode::PortType::OUT, "output", CONFIG); | ||
|
||
// attribute(s) | ||
p_node->add_attr<FloatAttribute>("cut_min", 0.05f, 0.f, 1.f, "cut_min"); | ||
p_node->add_attr<FloatAttribute>("cut_max", 0.5f, 0.f, 1.f, "cut_max"); | ||
p_node->add_attr<FloatAttribute>("k_smoothing", 0.01f, 0.f, 1.f, "k_smoothing"); | ||
} | ||
|
||
void compute_recast_cracks_node(BaseNode *p_node) | ||
{ | ||
Q_EMIT p_node->compute_started(p_node->get_id()); | ||
|
||
LOG->trace("computing node {}", p_node->get_label()); | ||
|
||
hmap::Heightmap *p_in = p_node->get_value_ref<hmap::Heightmap>("input"); | ||
|
||
if (p_in) | ||
{ | ||
hmap::Heightmap *p_out = p_node->get_value_ref<hmap::Heightmap>("output"); | ||
|
||
// copy the input heightmap | ||
*p_out = *p_in; | ||
|
||
float hmin = p_in->min(); | ||
float hmax = p_in->max(); | ||
|
||
hmap::transform( | ||
{p_out}, | ||
[p_node, hmin, hmax](std::vector<hmap::Array *> p_arrays, | ||
hmap::Vec2<int>, | ||
hmap::Vec4<float>) | ||
{ | ||
hmap::Array *pa_out = p_arrays[0]; | ||
|
||
hmap::recast_cracks(*pa_out, | ||
GET("cut_min", FloatAttribute), | ||
GET("cut_max", FloatAttribute), | ||
GET("k_smoothing", FloatAttribute), | ||
hmin, | ||
hmax); | ||
}, | ||
hmap::TransformMode::DISTRIBUTED); | ||
|
||
p_out->smooth_overlap_buffers(); | ||
} | ||
|
||
Q_EMIT p_node->compute_finished(p_node->get_id()); | ||
} | ||
|
||
} // namespace hesiod |