Skip to content

Commit 1e0e85f

Browse files
committedJul 23, 2015
Fix issues with light of attached CAOs
1 parent 4eacce5 commit 1e0e85f

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed
 

Diff for: ‎src/clientobject.h

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class ClientActiveObject : public ActiveObject
5454
virtual void removeFromScene(bool permanent){}
5555
// 0 <= light_at_pos <= LIGHT_SUN
5656
virtual void updateLight(u8 light_at_pos){}
57+
virtual void updateLightNoCheck(u8 light_at_pos){}
5758
virtual v3s16 getLightPosition(){return v3s16(0,0,0);}
5859
virtual core::aabbox3d<f32>* getSelectionBox(){return NULL;}
5960
virtual bool getCollisionBox(aabb3f *toset){return false;}

Diff for: ‎src/content_cao.cpp

+24-6
Original file line numberDiff line numberDiff line change
@@ -984,20 +984,38 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
984984
}
985985

986986
void GenericCAO::updateLight(u8 light_at_pos)
987+
{
988+
// Don't update light of attached one
989+
if (getParent() != NULL) {
990+
return;
991+
}
992+
993+
updateLightNoCheck(light_at_pos);
994+
995+
// Update light of all children
996+
for (std::vector<u16>::size_type i = 0; i < m_children.size(); i++) {
997+
ClientActiveObject *obj = m_env->getActiveObject(m_children[i]);
998+
if (obj) {
999+
obj->updateLightNoCheck(light_at_pos);
1000+
}
1001+
}
1002+
}
1003+
1004+
void GenericCAO::updateLightNoCheck(u8 light_at_pos)
9871005
{
9881006
u8 li = decode_light(light_at_pos);
989-
if(li != m_last_light)
990-
{
1007+
if (li != m_last_light) {
9911008
m_last_light = li;
9921009
video::SColor color(255,li,li,li);
993-
if(m_meshnode)
1010+
if (m_meshnode) {
9941011
setMeshColor(m_meshnode->getMesh(), color);
995-
if(m_animated_meshnode)
1012+
} else if (m_animated_meshnode) {
9961013
setMeshColor(m_animated_meshnode->getMesh(), color);
997-
if(m_wield_meshnode)
1014+
} else if (m_wield_meshnode) {
9981015
m_wield_meshnode->setColor(color);
999-
if(m_spritenode)
1016+
} else if (m_spritenode) {
10001017
m_spritenode->setColor(color);
1018+
}
10011019
}
10021020
}
10031021

Diff for: ‎src/content_cao.h

+2
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ class GenericCAO : public ClientActiveObject
178178

179179
void updateLight(u8 light_at_pos);
180180

181+
void updateLightNoCheck(u8 light_at_pos);
182+
181183
v3s16 getLightPosition();
182184

183185
void updateNodePos();

0 commit comments

Comments
 (0)
Please sign in to comment.