Skip to content

Commit 9822851

Browse files
committed
Update node transform
1 parent c5df3e6 commit 9822851

File tree

6 files changed

+63
-68
lines changed

6 files changed

+63
-68
lines changed

Hesiod/src/model/nodes/nodes_function/gamma_correction.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* this software. */
44

55
#include "highmap/filters.hpp"
6+
#include "highmap/range.hpp"
67
#include "highmap/heightmap.hpp"
78

89
#include "attributes.hpp"
@@ -41,25 +42,24 @@ void compute_gamma_correction_node(BaseNode *p_node)
4142
hmap::Heightmap *p_mask = p_node->get_value_ref<hmap::Heightmap>("mask");
4243
hmap::Heightmap *p_out = p_node->get_value_ref<hmap::Heightmap>("output");
4344

44-
*p_out = *p_in;
45-
46-
float hmin = p_out->min();
47-
float hmax = p_out->max();
48-
49-
p_out->remap(0.f, 1.f, hmin, hmax);
45+
float hmin = p_in->min();
46+
float hmax = p_in->max();
5047

5148
hmap::transform(
52-
{p_out, p_mask},
53-
[p_node](std::vector<hmap::Array *> p_arrays)
49+
{p_out, p_in, p_mask},
50+
[p_node, hmin, hmax](std::vector<hmap::Array *> p_arrays)
5451
{
5552
hmap::Array *pa_out = p_arrays[0];
56-
hmap::Array *pa_mask = p_arrays[1];
53+
hmap::Array *pa_in = p_arrays[1];
54+
hmap::Array *pa_mask = p_arrays[2];
5755

56+
*pa_out = *pa_in;
57+
58+
hmap::remap(*pa_out, 0.f, 1.f, hmin, hmax);
5859
hmap::gamma_correction(*pa_out, GET("gamma", FloatAttribute), pa_mask);
60+
hmap::remap(*pa_out, hmin, hmax, 0.f, 1.f);
5961
},
6062
p_node->get_config_ref()->hmap_transform_mode_cpu);
61-
62-
p_out->remap(hmin, hmax, 0.f, 1.f);
6363
}
6464

6565
Q_EMIT p_node->compute_finished(p_node->get_id());

Hesiod/src/model/nodes/nodes_function/paraboloid.cpp

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -60,45 +60,36 @@ void compute_paraboloid_node(BaseNode *p_node)
6060
hmap::Heightmap *p_env = p_node->get_value_ref<hmap::Heightmap>("envelope");
6161
hmap::Heightmap *p_out = p_node->get_value_ref<hmap::Heightmap>("output");
6262

63-
hmap::fill(*p_out,
64-
p_dx,
65-
p_dy,
66-
[p_node](hmap::Vec2<int> shape,
67-
hmap::Vec4<float> bbox,
68-
hmap::Array *p_noise_x,
69-
hmap::Array *p_noise_y)
70-
{
71-
return hmap::paraboloid(shape,
72-
GET("angle", FloatAttribute),
73-
GET("a", FloatAttribute),
74-
GET("b", FloatAttribute),
75-
GET("v0", FloatAttribute),
76-
GET("reverse_x", BoolAttribute),
77-
GET("reverse_y", BoolAttribute),
78-
p_noise_x,
79-
p_noise_y,
80-
nullptr,
81-
GET("center", Vec2FloatAttribute),
82-
bbox);
83-
});
84-
85-
// add envelope
86-
if (p_env)
87-
{
88-
float hmin = p_out->min();
89-
hmap::transform(*p_out,
90-
*p_env,
91-
[&hmin](hmap::Array &a, hmap::Array &b)
92-
{
93-
a -= hmin;
94-
a *= b;
95-
});
96-
}
63+
hmap::transform(
64+
{p_out, p_dx, p_dy},
65+
[p_node](std::vector<hmap::Array *> p_arrays,
66+
hmap::Vec2<int> shape,
67+
hmap::Vec4<float> bbox)
68+
{
69+
hmap::Array *pa_out = p_arrays[0];
70+
hmap::Array *pa_dx = p_arrays[1];
71+
hmap::Array *pa_dy = p_arrays[2];
72+
73+
*pa_out = hmap::paraboloid(shape,
74+
GET("angle", FloatAttribute),
75+
GET("a", FloatAttribute),
76+
GET("b", FloatAttribute),
77+
GET("v0", FloatAttribute),
78+
GET("reverse_x", BoolAttribute),
79+
GET("reverse_y", BoolAttribute),
80+
pa_dx,
81+
pa_dy,
82+
nullptr,
83+
GET("center", Vec2FloatAttribute),
84+
bbox);
85+
},
86+
p_node->get_config_ref()->hmap_transform_mode_cpu);
9787

9888
// post-process
89+
post_apply_enveloppe(p_node, *p_out, p_env);
90+
9991
post_process_heightmap(p_node,
10092
*p_out,
101-
10293
GET("inverse", BoolAttribute),
10394
false, // smooth
10495
0,

Hesiod/src/model/nodes/nodes_function/recurve.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* this software. */
44
#include "highmap/filters.hpp"
55
#include "highmap/operator.hpp"
6+
#include "highmap/range.hpp"
67

78
#include "attributes.hpp"
89

@@ -43,26 +44,30 @@ void compute_recurve_node(BaseNode *p_node)
4344
hmap::Heightmap *p_mask = p_node->get_value_ref<hmap::Heightmap>("mask");
4445
hmap::Heightmap *p_out = p_node->get_value_ref<hmap::Heightmap>("output");
4546

46-
// copy the input heightmap
47-
*p_out = *p_in;
48-
4947
if (GET("values", VecFloatAttribute).size() >= 3)
5048
{
51-
float hmin = p_out->min();
52-
float hmax = p_out->max();
53-
54-
p_out->remap(0.f, 1.f, hmin, hmax);
49+
float hmin = p_in->min();
50+
float hmax = p_in->max();
5551

5652
std::vector<float> t = hmap::linspace(0.f,
5753
1.f,
5854
GET("values", VecFloatAttribute).size());
5955

60-
hmap::transform(*p_out,
61-
p_mask,
62-
[p_node, t](hmap::Array &x, hmap::Array *p_mask)
63-
{ hmap::recurve(x, t, GET("values", VecFloatAttribute), p_mask); });
64-
65-
p_out->remap(hmin, hmax, 0.f, 1.f);
56+
hmap::transform(
57+
{p_out, p_in, p_mask},
58+
[p_node, t, hmin, hmax](std::vector<hmap::Array *> p_arrays)
59+
{
60+
hmap::Array *pa_out = p_arrays[0];
61+
hmap::Array *pa_in = p_arrays[1];
62+
hmap::Array *pa_mask = p_arrays[2];
63+
64+
*pa_out = *pa_in;
65+
66+
hmap::remap(*pa_out, 0.f, 1.f, hmin, hmax);
67+
hmap::recurve(*pa_out, t, GET("values", VecFloatAttribute), pa_mask);
68+
hmap::remap(*pa_out, hmin, hmax, 0.f, 1.f);
69+
},
70+
p_node->get_config_ref()->hmap_transform_mode_cpu);
6671
}
6772
else
6873
{

scripts/format_doxygen.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
echo "- uncrustify"
3+
4+
for F in `find Hesiod/include/. -type f -iname \*.hpp`; do
5+
echo ${F}
6+
uncrustify -c scripts/uncrustify_config.cfg --replace ${F} --no-backup -q
7+
done

scripts/format_src.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ echo "- json"
55
jq . Hesiod/data/node_documentation.json --indent 4 > tmp.json
66
mv tmp.json Hesiod/data/node_documentation.json
77

8-
echo "- uncrustify"
9-
10-
for F in `find Hesiod/include/. -type f -iname \*.hpp`; do
11-
echo ${F}
12-
uncrustify -c scripts/uncrustify_config.cfg --replace ${F} --no-backup -q
13-
done
14-
15-
168
# directories to be formatted (recursive search)
179
DIRS="Hesiod/include Hesiod/src Hesiod/app"
1810
# FORMAT_CMD="clang-format --style=LLVM -i {}"

0 commit comments

Comments
 (0)