Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
18882a4d
Commit
18882a4d
authored
11 years ago
by
kwolekr
Browse files
Options
Downloads
Patches
Plain Diff
Add Lua PerlinNoiseMap:get#dMap_flat API
parent
8aa930f2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/lua_api.txt
+9
-0
9 additions, 0 deletions
doc/lua_api.txt
src/script/lua_api/l_noise.cpp
+45
-0
45 additions, 0 deletions
src/script/lua_api/l_noise.cpp
src/script/lua_api/l_noise.h
+2
-1
2 additions, 1 deletion
src/script/lua_api/l_noise.h
with
56 additions
and
1 deletion
doc/lua_api.txt
+
9
−
0
View file @
18882a4d
...
...
@@ -1529,6 +1529,15 @@ methods:
- get2d(pos) -> 2d noise value at pos={x=,y=}
- get3d(pos) -> 3d noise value at pos={x=,y=,z=}
PerlinNoiseMap: A fast, bulk perlin noise generator
- Can be created via PerlinNoiseMap(noiseparams, size)
- Also minetest.get_perlin_map(noiseparams, size)
methods:
- get2dMap(pos) -> <size.x>X<size.y> 2d array of 2d noise values starting at pos={x=,y=}
- get3dMap(pos) -> <size.x>X<size.y>X<size.z> 3d array of 3d noise values starting at pos={x=,y=,z=}
- get2dMap_flat(pos) -> Flat <size.x * size.y> element array of 2d noise values starting at pos={x=,y=}
- get3dMap_flat(pos) -> Same as get2dMap_flat, but 3d noise
VoxelManip: An interface to the MapVoxelManipulator for Lua
- Can be created via VoxelManip()
- Also minetest.get_voxel_manip()
...
...
This diff is collapsed.
Click to expand it.
src/script/lua_api/l_noise.cpp
+
45
−
0
View file @
18882a4d
...
...
@@ -159,6 +159,27 @@ int LuaPerlinNoiseMap::l_get2dMap(lua_State *L)
return
1
;
}
int
LuaPerlinNoiseMap
::
l_get2dMap_flat
(
lua_State
*
L
)
{
NO_MAP_LOCK_REQUIRED
;
LuaPerlinNoiseMap
*
o
=
checkobject
(
L
,
1
);
v2f
p
=
read_v2f
(
L
,
2
);
Noise
*
n
=
o
->
noise
;
n
->
perlinMap2D
(
p
.
X
,
p
.
Y
);
int
maplen
=
n
->
sx
*
n
->
sy
;
lua_newtable
(
L
);
for
(
int
i
=
0
;
i
!=
maplen
;
i
++
)
{
float
noiseval
=
n
->
np
->
offset
+
n
->
np
->
scale
*
n
->
result
[
i
];
lua_pushnumber
(
L
,
noiseval
);
lua_rawseti
(
L
,
-
2
,
i
+
1
);
}
return
1
;
}
int
LuaPerlinNoiseMap
::
l_get3dMap
(
lua_State
*
L
)
{
NO_MAP_LOCK_REQUIRED
;
...
...
@@ -186,6 +207,28 @@ int LuaPerlinNoiseMap::l_get3dMap(lua_State *L)
return
1
;
}
int
LuaPerlinNoiseMap
::
l_get3dMap_flat
(
lua_State
*
L
)
{
NO_MAP_LOCK_REQUIRED
;
LuaPerlinNoiseMap
*
o
=
checkobject
(
L
,
1
);
v3f
p
=
read_v3f
(
L
,
2
);
Noise
*
n
=
o
->
noise
;
n
->
perlinMap3D
(
p
.
X
,
p
.
Y
,
p
.
Z
);
int
maplen
=
n
->
sx
*
n
->
sy
*
n
->
sz
;
lua_newtable
(
L
);
for
(
int
i
=
0
;
i
!=
maplen
;
i
++
)
{
float
noiseval
=
n
->
np
->
offset
+
n
->
np
->
scale
*
n
->
result
[
i
];
lua_pushnumber
(
L
,
noiseval
);
lua_rawseti
(
L
,
-
2
,
i
+
1
);
}
return
1
;
}
LuaPerlinNoiseMap
::
LuaPerlinNoiseMap
(
NoiseParams
*
np
,
int
seed
,
v3s16
size
)
{
noise
=
new
Noise
(
np
,
seed
,
size
.
X
,
size
.
Y
,
size
.
Z
);
}
...
...
@@ -254,7 +297,9 @@ void LuaPerlinNoiseMap::Register(lua_State *L)
const
char
LuaPerlinNoiseMap
::
className
[]
=
"PerlinNoiseMap"
;
const
luaL_reg
LuaPerlinNoiseMap
::
methods
[]
=
{
luamethod
(
LuaPerlinNoiseMap
,
get2dMap
),
luamethod
(
LuaPerlinNoiseMap
,
get2dMap_flat
),
luamethod
(
LuaPerlinNoiseMap
,
get3dMap
),
luamethod
(
LuaPerlinNoiseMap
,
get3dMap_flat
),
{
0
,
0
}
};
...
...
This diff is collapsed.
Click to expand it.
src/script/lua_api/l_noise.h
+
2
−
1
View file @
18882a4d
...
...
@@ -74,8 +74,9 @@ class LuaPerlinNoiseMap
static
int
gc_object
(
lua_State
*
L
);
static
int
l_get2dMap
(
lua_State
*
L
);
static
int
l_get2dMap_flat
(
lua_State
*
L
);
static
int
l_get3dMap
(
lua_State
*
L
);
static
int
l_get3dMap_flat
(
lua_State
*
L
);
public:
LuaPerlinNoiseMap
(
NoiseParams
*
np
,
int
seed
,
v3s16
size
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment