From bbf3eebb1adc50a54b26541b1445204a88776795 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 30 Mar 2012 13:44:48 +0300 Subject: [PATCH] Fix object visuals flashing brightly or disappearing when switching them at night --- src/content_cao.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 03387d03..627d3c04 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -575,6 +575,7 @@ private: float m_reset_textures_timer; bool m_visuals_expired; float m_step_distance_counter; + u8 m_last_light; public: GenericCAO(IGameDef *gamedef, ClientEnvironment *env): @@ -604,7 +605,8 @@ public: m_anim_timer(0), m_reset_textures_timer(-1), m_visuals_expired(false), - m_step_distance_counter(0) + m_step_distance_counter(0), + m_last_light(255) { if(gamedef == NULL) ClientActiveObject::registerType(getType(), create); @@ -707,8 +709,8 @@ public: m_spritenode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false); m_spritenode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); m_spritenode->setMaterialFlag(video::EMF_FOG_ENABLE, true); - m_spritenode->setColor(video::SColor(255,0,0,0)); - m_spritenode->setVisible(false); /* Set visible when brightness is known */ + u8 li = m_last_light; + m_spritenode->setColor(video::SColor(255,li,li,li)); m_spritenode->setSize(m_prop.visual_size*BS); { const float txs = 1.0 / 1; @@ -724,7 +726,8 @@ public: double dy = BS*m_prop.visual_size.Y/2; { // Front scene::IMeshBuffer *buf = new scene::SMeshBuffer(); - video::SColor c(255,255,255,255); + u8 li = m_last_light; + video::SColor c(255,li,li,li); video::S3DVertex vertices[4] = { video::S3DVertex(-dx,-dy,0, 0,0,0, c, 0,1), @@ -745,7 +748,8 @@ public: } { // Back scene::IMeshBuffer *buf = new scene::SMeshBuffer(); - video::SColor c(255,255,255,255); + u8 li = m_last_light; + video::SColor c(255,li,li,li); video::S3DVertex vertices[4] = { video::S3DVertex(dx,-dy,0, 0,0,0, c, 1,1), @@ -777,8 +781,8 @@ public: mesh->drop(); m_meshnode->setScale(v3f(1)); - // Will be shown when we know the brightness - m_meshnode->setVisible(false); + u8 li = m_last_light; + setMeshColor(m_meshnode->getMesh(), video::SColor(255,li,li,li)); } else { infostream<<"GenericCAO::addToScene(): \""<getMesh(), color);