mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Optimise getTileInfo()
getTileInfo() ~1.5x faster getSmoothLight ~2.0x faster
This commit is contained in:
parent
fcdb1a8fc2
commit
ea404979e1
2 changed files with 40 additions and 46 deletions
|
@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "serialization.h" // For ser_ver_supported
|
||||
#include "util/serialize.h"
|
||||
#include "log.h"
|
||||
#include "util/numeric.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
|
@ -77,19 +78,14 @@ u8 MapNode::getLight(enum LightBank bank, INodeDefManager *nodemgr) const
|
|||
{
|
||||
// Select the brightest of [light source, propagated light]
|
||||
const ContentFeatures &f = nodemgr->get(*this);
|
||||
u8 light = 0;
|
||||
|
||||
u8 light;
|
||||
if(f.param_type == CPT_LIGHT)
|
||||
{
|
||||
if(bank == LIGHTBANK_DAY)
|
||||
light = param1 & 0x0f;
|
||||
else if(bank == LIGHTBANK_NIGHT)
|
||||
light = (param1>>4)&0x0f;
|
||||
else
|
||||
assert(0);
|
||||
}
|
||||
if(f.light_source > light)
|
||||
light = f.light_source;
|
||||
return light;
|
||||
light = bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f;
|
||||
else
|
||||
light = 0;
|
||||
|
||||
return MYMAX(f.light_source, light);
|
||||
}
|
||||
|
||||
bool MapNode::getLightBanks(u8 &lightday, u8 &lightnight, INodeDefManager *nodemgr) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue