@@ -621,8 +621,6 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
621
621
622
622
setSceneNodeMaterial (m_spritenode);
623
623
624
- u8 li = m_last_light;
625
- m_spritenode->setColor (video::SColor (255 ,li,li,li));
626
624
m_spritenode->setSize (v2f (m_prop.visual_size .X ,
627
625
m_prop.visual_size .Y ) * BS);
628
626
{
@@ -636,8 +634,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
636
634
scene::SMesh *mesh = new scene::SMesh ();
637
635
double dx = BS * m_prop.visual_size .X / 2 ;
638
636
double dy = BS * m_prop.visual_size .Y / 2 ;
639
- u8 li = m_last_light;
640
- video::SColor c (255 , li, li, li);
637
+ video::SColor c (0xFFFFFFFF );
641
638
642
639
{ // Front
643
640
scene::IMeshBuffer *buf = new scene::SMeshBuffer ();
@@ -717,8 +714,6 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
717
714
mesh->drop ();
718
715
719
716
m_meshnode->setScale (m_prop.visual_size );
720
- u8 li = m_last_light;
721
- setMeshColor (m_meshnode->getMesh (), video::SColor (255 ,li,li,li));
722
717
723
718
setSceneNodeMaterial (m_meshnode);
724
719
} else if (m_prop.visual == " mesh" ) {
@@ -731,12 +726,11 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
731
726
mesh->drop (); // The scene node took hold of it
732
727
m_animated_meshnode->animateJoints (); // Needed for some animations
733
728
m_animated_meshnode->setScale (m_prop.visual_size );
734
- u8 li = m_last_light;
735
729
736
730
// set vertex colors to ensure alpha is set
737
- setMeshColor (m_animated_meshnode->getMesh (), video::SColor (255 ,li,li,li ));
731
+ setMeshColor (m_animated_meshnode->getMesh (), video::SColor (0xFFFFFFFF ));
738
732
739
- setAnimatedMeshColor (m_animated_meshnode, video::SColor (255 ,li,li,li ));
733
+ setAnimatedMeshColor (m_animated_meshnode, video::SColor (0xFFFFFFFF ));
740
734
741
735
setSceneNodeMaterial (m_animated_meshnode);
742
736
@@ -766,8 +760,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
766
760
(m_prop.visual == " wielditem" ));
767
761
768
762
m_wield_meshnode->setScale (m_prop.visual_size / 2 .0f );
769
- u8 li = m_last_light;
770
- m_wield_meshnode->setColor (video::SColor (255 , li, li, li));
763
+ m_wield_meshnode->setColor (video::SColor (0xFFFFFFFF ));
771
764
} else {
772
765
infostream<<" GenericCAO::addToScene(): \" " <<m_prop.visual
773
766
<<" \" not supported" <<std::endl;
@@ -795,6 +788,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
795
788
updateAnimation ();
796
789
updateBonePosition ();
797
790
updateAttachments ();
791
+ setNodeLight (m_last_light);
798
792
}
799
793
800
794
void GenericCAO::updateLight (u8 light_at_pos)
@@ -824,39 +818,43 @@ void GenericCAO::updateLightNoCheck(u8 light_at_pos)
824
818
825
819
if (li != m_last_light) {
826
820
m_last_light = li;
827
- video::SColor color (255 ,li,li,li);
821
+ setNodeLight (li);
822
+ }
823
+ }
828
824
829
- if (m_enable_shaders) {
830
- scene::ISceneNode *node = getSceneNode ();
825
+ void GenericCAO::setNodeLight (u8 light)
826
+ {
827
+ video::SColor color (255 , light, light, light);
831
828
832
- if (node == nullptr ) {
833
- return ;
834
- }
829
+ if (m_enable_shaders) {
830
+ scene::ISceneNode *node = getSceneNode ();
835
831
836
- if (m_prop.visual == " upright_sprite" ) {
837
- scene::IMesh *mesh = m_meshnode->getMesh ();
838
- for (u32 i = 0 ; i < mesh->getMeshBufferCount (); ++i) {
839
- scene::IMeshBuffer* buf = mesh->getMeshBuffer (i);
840
- video::SMaterial& material = buf->getMaterial ();
841
- material.EmissiveColor = color;
842
- }
843
- } else {
844
- for (u32 i = 0 ; i < node->getMaterialCount (); ++i) {
845
- video::SMaterial& material = node->getMaterial (i);
846
- material.EmissiveColor = color;
847
- }
832
+ if (node == nullptr )
833
+ return ;
834
+
835
+ if (m_prop.visual == " upright_sprite" ) {
836
+ scene::IMesh *mesh = m_meshnode->getMesh ();
837
+ for (u32 i = 0 ; i < mesh->getMeshBufferCount (); ++i) {
838
+ scene::IMeshBuffer *buf = mesh->getMeshBuffer (i);
839
+ video::SMaterial &material = buf->getMaterial ();
840
+ material.EmissiveColor = color;
848
841
}
849
842
} else {
850
- if (m_meshnode) {
851
- setMeshColor (m_meshnode->getMesh (), color);
852
- } else if (m_animated_meshnode) {
853
- setAnimatedMeshColor (m_animated_meshnode, color);
854
- } else if (m_wield_meshnode) {
855
- m_wield_meshnode->setColor (color);
856
- } else if (m_spritenode) {
857
- m_spritenode->setColor (color);
843
+ for (u32 i = 0 ; i < node->getMaterialCount (); ++i) {
844
+ video::SMaterial &material = node->getMaterial (i);
845
+ material.EmissiveColor = color;
858
846
}
859
847
}
848
+ } else {
849
+ if (m_meshnode) {
850
+ setMeshColor (m_meshnode->getMesh (), color);
851
+ } else if (m_animated_meshnode) {
852
+ setAnimatedMeshColor (m_animated_meshnode, color);
853
+ } else if (m_wield_meshnode) {
854
+ m_wield_meshnode->setColor (color);
855
+ } else if (m_spritenode) {
856
+ m_spritenode->setColor (color);
857
+ }
860
858
}
861
859
}
862
860
0 commit comments