mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Optimize lighting calculation (#12797)
This commit is contained in:
parent
440d966b93
commit
9676364c1f
18 changed files with 188 additions and 220 deletions
|
@ -505,10 +505,13 @@ struct ContentFeatures
|
|||
liquid_alternative_source_id == f.liquid_alternative_source_id;
|
||||
}
|
||||
|
||||
bool lightingEquivalent(const ContentFeatures &other) const {
|
||||
return light_propagates == other.light_propagates
|
||||
&& sunlight_propagates == other.sunlight_propagates
|
||||
&& light_source == other.light_source;
|
||||
ContentLightingFlags getLightingFlags() const {
|
||||
ContentLightingFlags flags;
|
||||
flags.has_light = param_type == CPT_LIGHT;
|
||||
flags.light_propagates = light_propagates;
|
||||
flags.sunlight_propagates = sunlight_propagates;
|
||||
flags.light_source = light_source;
|
||||
return flags;
|
||||
}
|
||||
|
||||
int getGroup(const std::string &group) const
|
||||
|
@ -580,6 +583,15 @@ public:
|
|||
return get(n.getContent());
|
||||
}
|
||||
|
||||
inline ContentLightingFlags getLightingFlags(content_t c) const {
|
||||
// No bound check is necessary, since the array's length is CONTENT_MAX + 1.
|
||||
return m_content_lighting_flag_cache[c];
|
||||
}
|
||||
|
||||
inline ContentLightingFlags getLightingFlags(const MapNode &n) const {
|
||||
return getLightingFlags(n.getContent());
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the node properties for a node name.
|
||||
* @param name name of a node
|
||||
|
@ -826,6 +838,11 @@ private:
|
|||
* Even constant NodeDefManager instances can register listeners.
|
||||
*/
|
||||
mutable std::vector<NodeResolver *> m_pending_resolve_callbacks;
|
||||
|
||||
/*!
|
||||
* Fast cache of content lighting flags.
|
||||
*/
|
||||
ContentLightingFlags m_content_lighting_flag_cache[CONTENT_MAX + 1L];
|
||||
};
|
||||
|
||||
NodeDefManager *createNodeDefManager();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue