mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
ContentCAO: Update light of all attached entities (#9975)
This commit is contained in:
parent
f849917bbe
commit
a08d18acad
4 changed files with 22 additions and 60 deletions
|
@ -320,21 +320,8 @@ void ClientEnvironment::step(float dtime)
|
|||
// Step object
|
||||
cao->step(dtime, this);
|
||||
|
||||
if (update_lighting) {
|
||||
// Update lighting
|
||||
u8 light = 0;
|
||||
bool pos_ok;
|
||||
|
||||
// Get node at head
|
||||
v3s16 p = cao->getLightPosition();
|
||||
MapNode n = this->m_map->getNode(p, &pos_ok);
|
||||
if (pos_ok)
|
||||
light = n.getLightBlend(day_night_ratio, m_client->ndef());
|
||||
else
|
||||
light = blend_light(day_night_ratio, LIGHT_SUN, 0);
|
||||
|
||||
cao->updateLight(light);
|
||||
}
|
||||
if (update_lighting)
|
||||
cao->updateLight(day_night_ratio);
|
||||
};
|
||||
|
||||
m_ao_manager.step(dtime, cb_state);
|
||||
|
@ -402,18 +389,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
|
|||
object->addToScene(m_texturesource);
|
||||
|
||||
// Update lighting immediately
|
||||
u8 light = 0;
|
||||
bool pos_ok;
|
||||
|
||||
// Get node at head
|
||||
v3s16 p = object->getLightPosition();
|
||||
MapNode n = m_map->getNode(p, &pos_ok);
|
||||
if (pos_ok)
|
||||
light = n.getLightBlend(getDayNightRatio(), m_client->ndef());
|
||||
else
|
||||
light = blend_light(getDayNightRatio(), LIGHT_SUN, 0);
|
||||
|
||||
object->updateLight(light);
|
||||
object->updateLight(getDayNightRatio());
|
||||
return object->getId();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue