Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 262 vs 264 for /trunk/Source Code/Managers/LightManager.cpp

Diff revisions: vs.
  @@ -13,7 +13,8 @@
13 13 LightManager::LightManager() : FrameListener(),
14 14 _shadowMapsEnabled(true),
15 15 _previewShadowMaps(false),
16 - _dominantLight(nullptr)
16 + _dominantLight(nullptr),
17 + _currentShadowPass(0)
17 18 {
18 19 s_shadowPassTimer = ADD_TIMER("ShadowPassTimer");
19 20 }
  @@ -25,7 +26,8 @@
25 26 }
26 27
27 28 void LightManager::init(){
28 - REGISTER_FRAME_LISTENER(&(this->getInstance()));
29 + REGISTER_FRAME_LISTENER(&(this->getInstance()), 2);
30 + GFX_DEVICE.add2DRenderFunction(DELEGATE_BIND(&LightManager::previewShadowMaps, this, nullptr), 1);
29 31 }
30 32
31 33 bool LightManager::clear(){
  @@ -53,7 +55,7 @@
53 55
54 56 light->setSlot((U8)_lights.size());
55 57 _lights.insert(std::make_pair(light->getId(),light));
56 -
58 + GET_ACTIVE_SCENE()->renderState().getCameraMgr().addNewCamera(light->getName(), light->shadowCamera());
57 59 return true;
58 60 }
59 61
  @@ -129,9 +131,8 @@
129 131 START_TIMER(s_shadowPassTimer);
130 132
131 133 //Tell the engine that we are drawing to depth maps
132 - RenderStage previousRS = GFX_DEVICE.getRenderStage();
133 134 //set the current render stage to SHADOW_STAGE
134 - GFX_DEVICE.setRenderStage(SHADOW_STAGE);
135 + RenderStage previousRS = GFX_DEVICE.setRenderStage(SHADOW_STAGE);
135 136 // if we have a dominant light, generate only it's shadows
136 137 if(_dominantLight){
137 138 setCurrentLight(_dominantLight);
  @@ -203,8 +204,9 @@
203 204
204 205 if(lightLocal->getLightType() == LIGHT_TYPE_POINT)
205 206 offset = Config::MAX_TEXTURE_STORAGE + Config::MAX_SHADOW_CASTING_LIGHTS_PER_NODE + 1;
206 -
207 - lightLocal->getShadowMapInfo()->getShadowMap()->Bind(offset);
207 + ShadowMap* sm = lightLocal->getShadowMapInfo()->getShadowMap();
208 + if(sm)
209 + sm->Bind(offset);
208 210 }
209 211
210 212 void LightManager::unbindDepthMaps(Light* light, U8 offset, bool overrideDominant){
  @@ -225,7 +227,9 @@
225 227 if(lightLocal->getLightType() == LIGHT_TYPE_POINT)
226 228 offset = Config::MAX_TEXTURE_STORAGE + Config::MAX_SHADOW_CASTING_LIGHTS_PER_NODE + 1;
227 229
228 - lightLocal->getShadowMapInfo()->getShadowMap()->Unbind(offset);
230 + ShadowMap* sm = lightLocal->getShadowMapInfo()->getShadowMap();
231 + if (sm)
232 + sm->Unbind(offset);
229 233 }
230 234
231 235 bool LightManager::shadowMappingEnabled() const {