fix heightmaps binary operations
This commit is contained in:
parent
eab1519597
commit
347a01e0c2
@ -7,9 +7,20 @@ function generate_heightmap(x, y, w, h)
|
|||||||
vmap:noise({x+95, y+246}, 0.15, 3, 35.8)
|
vmap:noise({x+95, y+246}, 0.15, 3, 35.8)
|
||||||
|
|
||||||
local map = Heightmap(w, h)
|
local map = Heightmap(w, h)
|
||||||
map:noise({x, y}, 0.02, 6, 0.2)
|
map:noise({x, y}, 0.02, 7, 0.2)
|
||||||
map:noise({x, y}, 0.06, 7, 0.5, umap, vmap)
|
map:noise({x, y}, 0.06, 8, 0.5, umap, vmap)
|
||||||
map:mul(0.3)
|
map:mul(0.5)
|
||||||
map:add(0.3)
|
map:add(0.3)
|
||||||
|
map:pow(2.0)
|
||||||
|
|
||||||
|
local rivermap = Heightmap(w, h)
|
||||||
|
rivermap:noise({x+21, y+12}, 0.03, 4)
|
||||||
|
rivermap:abs()
|
||||||
|
rivermap:mul(2.0)
|
||||||
|
rivermap:pow(0.18)
|
||||||
|
map:add(0.4)
|
||||||
|
map:mul(rivermap)
|
||||||
|
map:add(-0.2)
|
||||||
|
|
||||||
return map
|
return map
|
||||||
end
|
end
|
||||||
|
|||||||
@ -113,7 +113,7 @@ static int l_binop_func(lua::State* L) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto map = touserdata<Heightmap>(L, 2);
|
auto map = touserdata<LuaHeightmap>(L, 2);
|
||||||
for (uint y = 0; y < h; y++) {
|
for (uint y = 0; y < h; y++) {
|
||||||
for (uint x = 0; x < w; x++) {
|
for (uint x = 0; x < w; x++) {
|
||||||
uint i = y * w + x;
|
uint i = y * w + x;
|
||||||
@ -132,7 +132,6 @@ static int l_unaryop_func(lua::State* L) {
|
|||||||
uint w = heightmap->getWidth();
|
uint w = heightmap->getWidth();
|
||||||
uint h = heightmap->getHeight();
|
uint h = heightmap->getHeight();
|
||||||
auto heights = heightmap->getValues();
|
auto heights = heightmap->getValues();
|
||||||
float power = tonumber(L, 2);
|
|
||||||
for (uint y = 0; y < h; y++) {
|
for (uint y = 0; y < h; y++) {
|
||||||
for (uint x = 0; x < w; x++) {
|
for (uint x = 0; x < w; x++) {
|
||||||
uint i = y * w + x;
|
uint i = y * w + x;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user