summaryrefslogtreecommitdiff
path: root/src/content_cao.cpp
diff options
context:
space:
mode:
authorRealBadAngel <maciej.kasatkin@o2.pl>2015-07-23 04:35:13 +0200
committerRealBadAngel <maciej.kasatkin@o2.pl>2015-07-23 04:35:13 +0200
commit1e0e85f82e030e761c36ba5a12427bec0fb4e4f2 (patch)
tree6941c7ed68b6cce623155aba16e68745237c638c /src/content_cao.cpp
parent4eacce5e2f89bd6864f9a231488b507ac33e4902 (diff)
downloadminetest-1e0e85f82e030e761c36ba5a12427bec0fb4e4f2.tar.gz
minetest-1e0e85f82e030e761c36ba5a12427bec0fb4e4f2.tar.bz2
minetest-1e0e85f82e030e761c36ba5a12427bec0fb4e4f2.zip
Fix issues with light of attached CAOs
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r--src/content_cao.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index a16bd4efa..0293b7983 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -985,19 +985,37 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
void GenericCAO::updateLight(u8 light_at_pos)
{
+ // Don't update light of attached one
+ if (getParent() != NULL) {
+ return;
+ }
+
+ updateLightNoCheck(light_at_pos);
+
+ // Update light of all children
+ for (std::vector<u16>::size_type i = 0; i < m_children.size(); i++) {
+ ClientActiveObject *obj = m_env->getActiveObject(m_children[i]);
+ if (obj) {
+ obj->updateLightNoCheck(light_at_pos);
+ }
+ }
+}
+
+void GenericCAO::updateLightNoCheck(u8 light_at_pos)
+{
u8 li = decode_light(light_at_pos);
- if(li != m_last_light)
- {
+ if (li != m_last_light) {
m_last_light = li;
video::SColor color(255,li,li,li);
- if(m_meshnode)
+ if (m_meshnode) {
setMeshColor(m_meshnode->getMesh(), color);
- if(m_animated_meshnode)
+ } else if (m_animated_meshnode) {
setMeshColor(m_animated_meshnode->getMesh(), color);
- if(m_wield_meshnode)
+ } else if (m_wield_meshnode) {
m_wield_meshnode->setColor(color);
- if(m_spritenode)
+ } else if (m_spritenode) {
m_spritenode->setColor(color);
+ }
}
}