mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Improved lighting
This commit rewrites the procedure that is responsible for light updating. this commit -provides iterative solutions for unlighting and light spreading -introduces a new priority queue-like container for the iteration -creates per-node MapBlock caching to reduce retrieving MapBlocks from the map -calculates with map block positions and in-block relative node coordinates -skips light updating if it is not necessary since the node's new light will be the same as its old light was
This commit is contained in:
parent
1fd9a07497
commit
c071efaa43
6 changed files with 648 additions and 448 deletions
|
@ -54,10 +54,10 @@ MapNode::MapNode(INodeDefManager *ndef, const std::string &name,
|
|||
param2 = a_param2;
|
||||
}
|
||||
|
||||
void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr)
|
||||
void MapNode::setLight(enum LightBank bank, u8 a_light, const ContentFeatures &f)
|
||||
{
|
||||
// If node doesn't contain light data, ignore this
|
||||
if(nodemgr->get(*this).param_type != CPT_LIGHT)
|
||||
if(f.param_type != CPT_LIGHT)
|
||||
return;
|
||||
if(bank == LIGHTBANK_DAY)
|
||||
{
|
||||
|
@ -73,6 +73,11 @@ void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr
|
|||
assert("Invalid light bank" == NULL);
|
||||
}
|
||||
|
||||
void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr)
|
||||
{
|
||||
setLight(bank, a_light, nodemgr->get(*this));
|
||||
}
|
||||
|
||||
bool MapNode::isLightDayNightEq(INodeDefManager *nodemgr) const
|
||||
{
|
||||
const ContentFeatures &f = nodemgr->get(*this);
|
||||
|
@ -103,6 +108,13 @@ u8 MapNode::getLight(enum LightBank bank, INodeDefManager *nodemgr) const
|
|||
return MYMAX(f.light_source, light);
|
||||
}
|
||||
|
||||
u8 MapNode::getLightRaw(enum LightBank bank, const ContentFeatures &f) const
|
||||
{
|
||||
if(f.param_type == CPT_LIGHT)
|
||||
return bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 MapNode::getLightNoChecks(enum LightBank bank, const ContentFeatures *f) const
|
||||
{
|
||||
return MYMAX(f->light_source,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue