diff options
Diffstat (limited to 'source')
9 files changed, 195 insertions, 163 deletions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 42ad7769cbd..9dbda3f195b 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -28,6 +28,8 @@ #include "GL/glew.h" +#include "DNA_scene_types.h" + #include "RAS_IRenderTools.h" #include "RAS_IRasterizer.h" #include "RAS_LightObject.h" @@ -67,6 +69,7 @@ void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty) m_clientobject = NULL; m_lastlightlayer = -1; m_lastlighting = false; + m_lastauxinfo = NULL; DisableOpenGLLights(); } @@ -80,25 +83,27 @@ void KX_BlenderRenderTools::EndFrame(RAS_IRasterizer* rasty) * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in * a scene. */ -void KX_BlenderRenderTools::ProcessLighting(RAS_IRasterizer *rasty, int layer, const MT_Transform& viewmat) +void KX_BlenderRenderTools::ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat) { - if(m_lastlightlayer == layer) - return; + bool enable = false; + int layer= -1; - m_lastlightlayer = layer; + /* find the layer */ + if(uselights) { + if(m_clientobject) + layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer(); + } - bool enable = false; + /* avoid state switching */ + if(m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo) + return; - if (layer >= 0) - { - if (m_clientobject) - { - if (layer == RAS_LIGHT_OBJECT_LAYER) - layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer(); + m_lastlightlayer = layer; + m_lastauxinfo = m_auxilaryClientInfo; - enable = applyLights(layer, viewmat); - } - } + /* enable/disable lights as needed */ + if(layer >= 0) + enable = applyLights(layer, viewmat); if(enable) EnableOpenGLLights(rasty); @@ -324,11 +329,16 @@ void KX_BlenderRenderTools::PopMatrix() int KX_BlenderRenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) { // taken from blender source, incompatibility between Blender Object / GameObject + KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; + int scenelayer = ~0; float glviewmat[16]; unsigned int count; float vec[4]; vec[3]= 1.0; + + if(kxscene && kxscene->GetBlenderScene()) + scenelayer = kxscene->GetBlenderScene()->lay; for(count=0; count<m_numgllights; count++) glDisable((GLenum)(GL_LIGHT0+count)); @@ -343,71 +353,77 @@ int KX_BlenderRenderTools::applyLights(int objectlayer, const MT_Transform& view for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); - if (lightdata->m_layer & objectlayer) - { - vec[0] = (*(lightdata->m_worldmatrix))(0,3); - vec[1] = (*(lightdata->m_worldmatrix))(1,3); - vec[2] = (*(lightdata->m_worldmatrix))(2,3); - vec[3] = 1; + KX_Scene* lightscene = (KX_Scene*)lightdata->m_scene; - if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) { - - vec[0] = (*(lightdata->m_worldmatrix))(0,2); - vec[1] = (*(lightdata->m_worldmatrix))(1,2); - vec[2] = (*(lightdata->m_worldmatrix))(2,2); - //vec[0]= base->object->obmat[2][0]; - //vec[1]= base->object->obmat[2][1]; - //vec[2]= base->object->obmat[2][2]; - vec[3]= 0.0; - glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); - } - else { - //vec[3]= 1.0; - glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); - glLightf((GLenum)(GL_LIGHT0+count), GL_CONSTANT_ATTENUATION, 1.0); - glLightf((GLenum)(GL_LIGHT0+count), GL_LINEAR_ATTENUATION, lightdata->m_att1/lightdata->m_distance); - // without this next line it looks backward compatible. - //attennuation still is acceptable - glLightf((GLenum)(GL_LIGHT0+count), GL_QUADRATIC_ATTENUATION, lightdata->m_att2/(lightdata->m_distance*lightdata->m_distance)); - - if(lightdata->m_type==RAS_LightObject::LIGHT_SPOT) { - vec[0] = -(*(lightdata->m_worldmatrix))(0,2); - vec[1] = -(*(lightdata->m_worldmatrix))(1,2); - vec[2] = -(*(lightdata->m_worldmatrix))(2,2); - //vec[0]= -base->object->obmat[2][0]; - //vec[1]= -base->object->obmat[2][1]; - //vec[2]= -base->object->obmat[2][2]; - glLightfv((GLenum)(GL_LIGHT0+count), GL_SPOT_DIRECTION, vec); - glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, lightdata->m_spotsize/2.0); - glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_EXPONENT, 128.0*lightdata->m_spotblend); - } - else glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, 180.0); - } + /* only use lights in the same layer as the object */ + if(!(lightdata->m_layer & objectlayer)) + continue; + /* only use lights in the same scene, and in a visible layer */ + if(kxscene != lightscene || !(lightdata->m_layer & scenelayer)) + continue; + + vec[0] = (*(lightdata->m_worldmatrix))(0,3); + vec[1] = (*(lightdata->m_worldmatrix))(1,3); + vec[2] = (*(lightdata->m_worldmatrix))(2,3); + vec[3] = 1; + + if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) { - if (lightdata->m_nodiffuse) - { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; - } else { - vec[0]= lightdata->m_energy*lightdata->m_red; - vec[1]= lightdata->m_energy*lightdata->m_green; - vec[2]= lightdata->m_energy*lightdata->m_blue; - vec[3]= 1.0; - } - glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec); - if (lightdata->m_nospecular) - { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; - } else if (lightdata->m_nodiffuse) { - vec[0]= lightdata->m_energy*lightdata->m_red; - vec[1]= lightdata->m_energy*lightdata->m_green; - vec[2]= lightdata->m_energy*lightdata->m_blue; - vec[3]= 1.0; + vec[0] = (*(lightdata->m_worldmatrix))(0,2); + vec[1] = (*(lightdata->m_worldmatrix))(1,2); + vec[2] = (*(lightdata->m_worldmatrix))(2,2); + //vec[0]= base->object->obmat[2][0]; + //vec[1]= base->object->obmat[2][1]; + //vec[2]= base->object->obmat[2][2]; + vec[3]= 0.0; + glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); + } + else { + //vec[3]= 1.0; + glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); + glLightf((GLenum)(GL_LIGHT0+count), GL_CONSTANT_ATTENUATION, 1.0); + glLightf((GLenum)(GL_LIGHT0+count), GL_LINEAR_ATTENUATION, lightdata->m_att1/lightdata->m_distance); + // without this next line it looks backward compatible. + //attennuation still is acceptable + glLightf((GLenum)(GL_LIGHT0+count), GL_QUADRATIC_ATTENUATION, lightdata->m_att2/(lightdata->m_distance*lightdata->m_distance)); + + if(lightdata->m_type==RAS_LightObject::LIGHT_SPOT) { + vec[0] = -(*(lightdata->m_worldmatrix))(0,2); + vec[1] = -(*(lightdata->m_worldmatrix))(1,2); + vec[2] = -(*(lightdata->m_worldmatrix))(2,2); + //vec[0]= -base->object->obmat[2][0]; + //vec[1]= -base->object->obmat[2][1]; + //vec[2]= -base->object->obmat[2][2]; + glLightfv((GLenum)(GL_LIGHT0+count), GL_SPOT_DIRECTION, vec); + glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, lightdata->m_spotsize/2.0); + glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_EXPONENT, 128.0*lightdata->m_spotblend); } - glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); - glEnable((GLenum)(GL_LIGHT0+count)); - - count++; + else glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, 180.0); + } + + if (lightdata->m_nodiffuse) + { + vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + } else { + vec[0]= lightdata->m_energy*lightdata->m_red; + vec[1]= lightdata->m_energy*lightdata->m_green; + vec[2]= lightdata->m_energy*lightdata->m_blue; + vec[3]= 1.0; + } + glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec); + if (lightdata->m_nospecular) + { + vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + } else if (lightdata->m_nodiffuse) { + vec[0]= lightdata->m_energy*lightdata->m_red; + vec[1]= lightdata->m_energy*lightdata->m_green; + vec[2]= lightdata->m_energy*lightdata->m_blue; + vec[3]= 1.0; } + glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); + glEnable((GLenum)(GL_LIGHT0+count)); + + count++; } glPopMatrix(); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index ebf7562503f..60130e6bfc9 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -51,6 +51,7 @@ class KX_BlenderRenderTools : public RAS_IRenderTools { int m_lastlightlayer; bool m_lastlighting; + void *m_lastauxinfo; static unsigned int m_numgllights; public: @@ -62,7 +63,7 @@ public: void EnableOpenGLLights(RAS_IRasterizer *rasty); void DisableOpenGLLights(); - void ProcessLighting(RAS_IRasterizer *rasty, int layer, const MT_Transform& viewmat); + void ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat); void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char* text, diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index c0d6248a3ca..8135635ddb3 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -29,6 +29,8 @@ #include "GL/glew.h" +#include "DNA_scene_types.h" + #include "RAS_IRenderTools.h" #include "RAS_IRasterizer.h" #include "RAS_LightObject.h" @@ -72,6 +74,7 @@ void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty) m_clientobject = NULL; m_lastlightlayer = -1; m_lastlighting = false; + m_lastauxinfo = NULL; DisableOpenGLLights(); } @@ -85,25 +88,27 @@ void GPC_RenderTools::EndFrame(RAS_IRasterizer* rasty) * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in * a scene. */ -void GPC_RenderTools::ProcessLighting(RAS_IRasterizer *rasty, int layer, const MT_Transform& viewmat) +void GPC_RenderTools::ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat) { - if(m_lastlightlayer == layer) - return; + bool enable = false; + int layer= -1; - m_lastlightlayer = layer; + /* find the layer */ + if(uselights) { + if(m_clientobject) + layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer(); + } - bool enable = false; + /* avoid state switching */ + if(m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo) + return; - if (layer >= 0) - { - if (m_clientobject) - { - if (layer == RAS_LIGHT_OBJECT_LAYER) - layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer(); + m_lastlightlayer = layer; + m_lastauxinfo = m_auxilaryClientInfo; - enable = applyLights(layer, viewmat); - } - } + /* enable/disable lights as needed */ + if(layer >= 0) + enable = applyLights(layer, viewmat); if(enable) EnableOpenGLLights(rasty); @@ -392,11 +397,16 @@ void GPC_RenderTools::PopMatrix() int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) { // taken from blender source, incompatibility between Blender Object / GameObject + KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; + int scenelayer = ~0; float glviewmat[16]; unsigned int count; float vec[4]; vec[3]= 1.0; + + if(kxscene && kxscene->GetBlenderScene()) + scenelayer = kxscene->GetBlenderScene()->lay; for(count=0; count<m_numgllights; count++) glDisable((GLenum)(GL_LIGHT0+count)); @@ -411,71 +421,77 @@ int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); - if (lightdata->m_layer & objectlayer) - { - vec[0] = (*(lightdata->m_worldmatrix))(0,3); - vec[1] = (*(lightdata->m_worldmatrix))(1,3); - vec[2] = (*(lightdata->m_worldmatrix))(2,3); - vec[3] = 1; + KX_Scene* lightscene = (KX_Scene*)lightdata->m_scene; - if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) { - - vec[0] = (*(lightdata->m_worldmatrix))(0,2); - vec[1] = (*(lightdata->m_worldmatrix))(1,2); - vec[2] = (*(lightdata->m_worldmatrix))(2,2); - //vec[0]= base->object->obmat[2][0]; - //vec[1]= base->object->obmat[2][1]; - //vec[2]= base->object->obmat[2][2]; - vec[3]= 0.0; - glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); - } - else { - //vec[3]= 1.0; - glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); - glLightf((GLenum)(GL_LIGHT0+count), GL_CONSTANT_ATTENUATION, 1.0); - glLightf((GLenum)(GL_LIGHT0+count), GL_LINEAR_ATTENUATION, lightdata->m_att1/lightdata->m_distance); - // without this next line it looks backward compatible. - //attennuation still is acceptable - glLightf((GLenum)(GL_LIGHT0+count), GL_QUADRATIC_ATTENUATION, lightdata->m_att2/(lightdata->m_distance*lightdata->m_distance)); - - if(lightdata->m_type==RAS_LightObject::LIGHT_SPOT) { - vec[0] = -(*(lightdata->m_worldmatrix))(0,2); - vec[1] = -(*(lightdata->m_worldmatrix))(1,2); - vec[2] = -(*(lightdata->m_worldmatrix))(2,2); - //vec[0]= -base->object->obmat[2][0]; - //vec[1]= -base->object->obmat[2][1]; - //vec[2]= -base->object->obmat[2][2]; - glLightfv((GLenum)(GL_LIGHT0+count), GL_SPOT_DIRECTION, vec); - glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, lightdata->m_spotsize/2.0); - glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_EXPONENT, 128.0*lightdata->m_spotblend); - } - else glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, 180.0); - } + /* only use lights in the same layer as the object */ + if(!(lightdata->m_layer & objectlayer)) + continue; + /* only use lights in the same scene, and in a visible layer */ + if(kxscene != lightscene || !(lightdata->m_layer & scenelayer)) + continue; + + vec[0] = (*(lightdata->m_worldmatrix))(0,3); + vec[1] = (*(lightdata->m_worldmatrix))(1,3); + vec[2] = (*(lightdata->m_worldmatrix))(2,3); + vec[3] = 1; + + if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) { - if (lightdata->m_nodiffuse) - { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; - } else { - vec[0]= lightdata->m_energy*lightdata->m_red; - vec[1]= lightdata->m_energy*lightdata->m_green; - vec[2]= lightdata->m_energy*lightdata->m_blue; - vec[3]= 1.0; - } - glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec); - if (lightdata->m_nospecular) - { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; - } else if (lightdata->m_nodiffuse) { - vec[0]= lightdata->m_energy*lightdata->m_red; - vec[1]= lightdata->m_energy*lightdata->m_green; - vec[2]= lightdata->m_energy*lightdata->m_blue; - vec[3]= 1.0; + vec[0] = (*(lightdata->m_worldmatrix))(0,2); + vec[1] = (*(lightdata->m_worldmatrix))(1,2); + vec[2] = (*(lightdata->m_worldmatrix))(2,2); + //vec[0]= base->object->obmat[2][0]; + //vec[1]= base->object->obmat[2][1]; + //vec[2]= base->object->obmat[2][2]; + vec[3]= 0.0; + glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); + } + else { + //vec[3]= 1.0; + glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); + glLightf((GLenum)(GL_LIGHT0+count), GL_CONSTANT_ATTENUATION, 1.0); + glLightf((GLenum)(GL_LIGHT0+count), GL_LINEAR_ATTENUATION, lightdata->m_att1/lightdata->m_distance); + // without this next line it looks backward compatible. + //attennuation still is acceptable + glLightf((GLenum)(GL_LIGHT0+count), GL_QUADRATIC_ATTENUATION, lightdata->m_att2/(lightdata->m_distance*lightdata->m_distance)); + + if(lightdata->m_type==RAS_LightObject::LIGHT_SPOT) { + vec[0] = -(*(lightdata->m_worldmatrix))(0,2); + vec[1] = -(*(lightdata->m_worldmatrix))(1,2); + vec[2] = -(*(lightdata->m_worldmatrix))(2,2); + //vec[0]= -base->object->obmat[2][0]; + //vec[1]= -base->object->obmat[2][1]; + //vec[2]= -base->object->obmat[2][2]; + glLightfv((GLenum)(GL_LIGHT0+count), GL_SPOT_DIRECTION, vec); + glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, lightdata->m_spotsize/2.0); + glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_EXPONENT, 128.0*lightdata->m_spotblend); } - glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); - glEnable((GLenum)(GL_LIGHT0+count)); - - count++; + else glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, 180.0); + } + + if (lightdata->m_nodiffuse) + { + vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + } else { + vec[0]= lightdata->m_energy*lightdata->m_red; + vec[1]= lightdata->m_energy*lightdata->m_green; + vec[2]= lightdata->m_energy*lightdata->m_blue; + vec[3]= 1.0; + } + glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec); + if (lightdata->m_nospecular) + { + vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + } else if (lightdata->m_nodiffuse) { + vec[0]= lightdata->m_energy*lightdata->m_red; + vec[1]= lightdata->m_energy*lightdata->m_green; + vec[2]= lightdata->m_energy*lightdata->m_blue; + vec[3]= 1.0; } + glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); + glEnable((GLenum)(GL_LIGHT0+count)); + + count++; } glPopMatrix(); diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index 2a1b66a3aa9..316860a7d43 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -54,6 +54,7 @@ class GPC_RenderTools : public RAS_IRenderTools { int m_lastlightlayer; bool m_lastlighting; + void *m_lastauxinfo; static unsigned int m_numgllights; BMF_Font* m_font; @@ -67,7 +68,7 @@ public: void EnableOpenGLLights(RAS_IRasterizer *rasty); void DisableOpenGLLights(); - void ProcessLighting(RAS_IRasterizer *rasty, int layer, const MT_Transform& viewmat); + void ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat); /* @attention mode is ignored here */ void RenderText2D(RAS_TEXT_RENDER_MODE mode, diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 8ec463be6ff..3df483b0598 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -52,7 +52,7 @@ void BL_BlenderShader::SetProg(bool enable, double time) { if(VerifyShader()) { if(enable) - GPU_material_bind(GPU_material_from_blender(mBlenderScene, mMat), mLightLayer, ~0, time); + GPU_material_bind(GPU_material_from_blender(mBlenderScene, mMat), mLightLayer, mBlenderScene->lay, time); else GPU_material_unbind(GPU_material_from_blender(mBlenderScene, mMat)); } diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index a2e93ecdd36..487b8f30e0d 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -57,6 +57,7 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, { m_lightobj = lightobj; m_lightobj.m_worldmatrix = GetOpenGLMatrixPtr(); + m_lightobj.m_scene = sgReplicationInfo; m_rendertools->AddLight(&m_lightobj); m_glsl = glsl; m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene(); diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index a289ffed492..52f6397cf6c 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -58,10 +58,6 @@ public: RAS_TEXT_PADDED, RAS_TEXT_MAX }; - enum RAS_LIGHT_MODE { - RAS_LIGHT_NONE = -1, - RAS_LIGHT_OBJECT_LAYER = 0 - }; RAS_IRenderTools( ) : @@ -135,7 +131,7 @@ public: void ProcessLighting( RAS_IRasterizer *rasty, - int layer, + bool uselights, const MT_Transform& trans )=0; diff --git a/source/gameengine/Rasterizer/RAS_LightObject.h b/source/gameengine/Rasterizer/RAS_LightObject.h index 4c54857dc39..6b63a891981 100644 --- a/source/gameengine/Rasterizer/RAS_LightObject.h +++ b/source/gameengine/Rasterizer/RAS_LightObject.h @@ -40,6 +40,7 @@ struct RAS_LightObject }; bool m_modified; int m_layer; + void *m_scene; float m_energy; float m_distance; diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index d8631c1edf6..20a8e9c3574 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -513,13 +513,13 @@ list<RAS_MeshSlot>::iterator RAS_MaterialBucket::msEnd() bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools *rendertools) { - if (!rasty->SetMaterial(*m_material)) + bool uselights; + + if(!rasty->SetMaterial(*m_material)) return false; - if (m_material->UsesLighting(rasty)) - rendertools->ProcessLighting(rasty, RAS_IRenderTools::RAS_LIGHT_OBJECT_LAYER, cameratrans); - else - rendertools->ProcessLighting(rasty, -1, cameratrans); + uselights= m_material->UsesLighting(rasty); + rendertools->ProcessLighting(rasty, uselights, cameratrans); return true; } |