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
0338c2eb
Commit
0338c2eb
authored
8 years ago
by
kwolekr
Browse files
Options
Downloads
Patches
Plain Diff
Mapgen: Spread both night and day light banks in spreadLight
parent
8f43aaf6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mapgen.cpp
+40
-11
40 additions, 11 deletions
src/mapgen.cpp
with
40 additions
and
11 deletions
src/mapgen.cpp
+
40
−
11
View file @
0338c2eb
...
...
@@ -242,18 +242,38 @@ void Mapgen::setLighting(u8 light, v3s16 nmin, v3s16 nmax)
void
Mapgen
::
lightSpread
(
VoxelArea
&
a
,
v3s16
p
,
u8
light
)
{
if
(
light
<=
1
||
!
a
.
contains
(
p
)
)
if
(
light
<=
1
)
return
;
u32
vi
=
vm
->
m_area
.
index
(
p
);
MapNode
&
nn
=
vm
->
m_data
[
vi
];
if
(
!
a
.
contains
(
vi
))
return
;
MapNode
&
n
=
vm
->
m_data
[
vi
];
// Decay light in each of the banks separately
u8
light_day
=
light
&
0x0F
;
if
(
light_day
>
0
)
light_day
-=
0x01
;
light
--
;
// should probably compare masked, but doesn't seem to make a difference
if
(
light
<=
nn
.
param1
||
!
ndef
->
get
(
nn
).
light_propagates
)
u8
light_night
=
light
&
0xF0
;
if
(
light_night
>
0
)
light_night
-=
0x10
;
// Bail out only if we have no more light from either bank to propogate, or
// we hit a solid block that light cannot pass through.
if
((
light_day
<=
(
n
.
param1
&
0x0F
)
&&
light_night
<=
(
n
.
param1
&
0xF0
))
||
!
ndef
->
get
(
n
).
light_propagates
)
return
;
nn
.
param1
=
light
;
// Since this recursive function only terminates when there is no light from
// either bank left, we need to take the max of both banks into account for
// the case where spreading has stopped for one light bank but not the other.
light
=
MYMAX
(
light_day
,
n
.
param1
&
0x0F
)
|
MYMAX
(
light_night
,
n
.
param1
&
0xF0
);
n
.
param1
=
light
;
lightSpread
(
a
,
p
+
v3s16
(
0
,
0
,
1
),
light
);
lightSpread
(
a
,
p
+
v3s16
(
0
,
1
,
0
),
light
);
...
...
@@ -284,6 +304,9 @@ void Mapgen::propagateSunlight(v3s16 nmin, v3s16 nmax, bool propagate_shadow)
bool
block_is_underground
=
(
water_level
>=
nmax
.
Y
);
v3s16
em
=
vm
->
m_area
.
getExtent
();
// NOTE: Direct access to the low 4 bits of param1 is okay here because,
// by definition, sunlight will never be in the night lightbank.
for
(
int
z
=
a
.
MinEdge
.
Z
;
z
<=
a
.
MaxEdge
.
Z
;
z
++
)
{
for
(
int
x
=
a
.
MinEdge
.
X
;
x
<=
a
.
MaxEdge
.
X
;
x
++
)
{
// see if we can get a light value from the overtop
...
...
@@ -320,15 +343,21 @@ void Mapgen::spreadLight(v3s16 nmin, v3s16 nmax)
u32
i
=
vm
->
m_area
.
index
(
a
.
MinEdge
.
X
,
y
,
z
);
for
(
int
x
=
a
.
MinEdge
.
X
;
x
<=
a
.
MaxEdge
.
X
;
x
++
,
i
++
)
{
MapNode
&
n
=
vm
->
m_data
[
i
];
if
(
n
.
getContent
()
==
CONTENT_IGNORE
||
!
ndef
->
get
(
n
).
light_propagates
)
if
(
n
.
getContent
()
==
CONTENT_IGNORE
)
continue
;
const
ContentFeatures
&
cf
=
ndef
->
get
(
n
);
if
(
!
cf
.
light_propagates
)
continue
;
u8
light_produced
=
ndef
->
get
(
n
).
light_source
&
0x0F
;
// TODO(hmmmmm): Abstract away direct param1 accesses with a
// wrapper, but something lighter than MapNode::get/setLight
u8
light_produced
=
cf
.
light_source
;
if
(
light_produced
)
n
.
param1
=
light_produced
;
n
.
param1
=
light_produced
|
(
light_produced
<<
4
)
;
u8
light
=
n
.
param1
&
0x0F
;
u8
light
=
n
.
param1
;
if
(
light
)
{
lightSpread
(
a
,
v3s16
(
x
,
y
,
z
+
1
),
light
);
lightSpread
(
a
,
v3s16
(
x
,
y
+
1
,
z
),
light
);
...
...
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