Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 336 vs 337 for /trunk/Source Code/Managers/LightManager.cpp

Diff revisions: vs.
  @@ -2,6 +2,7 @@
2 2 #include "Headers/SceneManager.h"
3 3
4 4 #include "Core/Headers/ParamHandler.h"
5 + #include "Core/Headers/ProfileTimer.h"
5 6 #include "Core/Headers/ApplicationTimer.h"
6 7 #include "Graphs/Headers/SceneGraphNode.h"
7 8 #include "Platform/Video/Headers/GFXDevice.h"
  @@ -23,16 +24,16 @@
23 24 // shadowPassTimer is used to measure the CPU-duration of shadow map generation step
24 25 s_shadowPassTimer = ADD_TIMER("ShadowPassTimer");
25 26 // SHADER_BUFFER_NORMAL holds general info about the currently active lights: position, color, etc.
26 - _lightShaderBuffer[SHADER_BUFFER_NORMAL] = nullptr;
27 + _lightShaderBuffer[SHADER_BUFFER_NORMAL] = nullptr;
27 28 // SHADER_BUFFER_SHADOWS holds info about the currently active shadow casting lights:
28 29 // ViewProjection Matrices, View Space Position, etc
29 - _lightShaderBuffer[SHADER_BUFFER_SHADOW] = nullptr;
30 + _lightShaderBuffer[SHADER_BUFFER_SHADOW] = nullptr;
30 31 // We bind shadow maps to the last available texture slots that the hardware supports.
31 32 // Starting offsets for each texture type is stored here
32 33 _cubeShadowLocation = 255;
33 34 _normShadowLocation = 255;
34 35 _arrayShadowLocation = 255;
35 - ParamHandler::getInstance().setParam<bool>("rendering.debug.showSplits", false);
36 + ParamHandler::getInstance().setParam<bool>("rendering.debug.showSplits", false);
36 37 }
37 38
38 39 LightManager::~LightManager()
  @@ -44,19 +45,19 @@
44 45 }
45 46
46 47 void LightManager::init(){
47 - if (_init) {
48 - return;
49 - }
48 + if (_init) {
49 + return;
50 + }
50 51 STUBBED("Replace light map bind slots with bindless textures! Max texture units is currently used! -Ionut!");
51 52
52 53 REGISTER_FRAME_LISTENER(&(this->getInstance()), 2);
53 54
54 55 GFX_DEVICE.add2DRenderFunction(DELEGATE_BIND(&LightManager::previewShadowMaps, this, nullptr), 1);
55 - // SHADER_BUFFER_NORMAL holds general info about the currently active lights: position, color, etc.
56 - _lightShaderBuffer[SHADER_BUFFER_NORMAL] = GFX_DEVICE.newSB();
57 - // SHADER_BUFFER_SHADOWS holds info about the currently active shadow casting lights:
56 + // SHADER_BUFFER_NORMAL holds general info about the currently active lights: position, color, etc.
57 + _lightShaderBuffer[SHADER_BUFFER_NORMAL] = GFX_DEVICE.newSB();
58 + // SHADER_BUFFER_SHADOWS holds info about the currently active shadow casting lights:
58 59 // ViewProjection Matrices, View Space Position, etc
59 - _lightShaderBuffer[SHADER_BUFFER_SHADOW] = GFX_DEVICE.newSB();
60 + _lightShaderBuffer[SHADER_BUFFER_SHADOW] = GFX_DEVICE.newSB();
60 61
61 62 _lightShaderBuffer[SHADER_BUFFER_NORMAL]->Create(Config::Lighting::MAX_LIGHTS_PER_SCENE, sizeof(LightProperties));
62 63 _lightShaderBuffer[SHADER_BUFFER_NORMAL]->Bind(SHADER_BUFFER_LIGHT_NORMAL);
  @@ -76,7 +77,7 @@
76 77 UNREGISTER_FRAME_LISTENER(&(this->getInstance()));
77 78
78 79 //Lights are removed by the sceneGraph
79 - for (Light::LightMap::value_type& it : _lights){
80 + for (Light::LightMap::value_type& it : _lights){
80 81 //in case we had some light hanging
81 82 RemoveResource(it.second);
82 83 }
  @@ -106,10 +107,10 @@
106 107 /// we can't remove a light if the light list is empty. That light has to exist somewhere!
107 108 assert(!_lights.empty());
108 109
109 - Light::LightMap::iterator it = _lights.find(lightGUID);
110 + Light::LightMap::iterator it = _lights.find(lightGUID);
110 111
111 112 if(it == _lights.end()){
112 - ERROR_FN(Locale::get("ERROR_LIGHT_MANAGER_REMOVE_LIGHT"), lightGUID);
113 + ERROR_FN(Locale::get("ERROR_LIGHT_MANAGER_REMOVE_LIGHT"), lightGUID);
113 114 return false;
114 115 }
115 116
  @@ -119,12 +120,12 @@
119 120
120 121 void LightManager::idle(){
121 122 _shadowMapsEnabled = ParamHandler::getInstance().getParam<bool>("rendering.enableShadows");
122 - _shadowMapsEnabled = false;
123 + _shadowMapsEnabled = false;
123 124 s_shadowPassTimer->pause(!_shadowMapsEnabled);
124 125 }
125 126
126 127 void LightManager::updateResolution(I32 newWidth, I32 newHeight){
127 - for (Light::LightMap::value_type& it : _lights) {
128 + for (Light::LightMap::value_type& it : _lights) {
128 129 it.second->updateResolution( newWidth, newHeight );
129 130 }
130 131
  @@ -151,7 +152,7 @@
151 152 ///Update only if needed. Get projection and view matrices if they changed
152 153 ///Also, search for the dominant light if any
153 154 void LightManager::onCameraChange() {
154 - for (Light::LightMap::value_type& it : _lights) {
155 + for (Light::LightMap::value_type& it : _lights) {
155 156 it.second->onCameraChange();
156 157 }
157 158 }
  @@ -169,7 +170,7 @@
169 170 //set the current render stage to SHADOW_STAGE
170 171 RenderStage previousRS = GFX_DEVICE.setRenderStage(SHADOW_STAGE);
171 172 //generate shadowmaps for each light
172 - for (Light::LightMap::value_type& light : _lights) {
173 + for (Light::LightMap::value_type& light : _lights) {
173 174 setCurrentLight( light.second );
174 175 light.second->generateShadowMaps( GET_ACTIVE_SCENE()->renderState() );
175 176 }
  @@ -189,7 +190,7 @@
189 190 return;
190 191 }
191 192
192 - for (Light::LightMap::value_type& it : _lights) {
193 + for (Light::LightMap::value_type& it : _lights) {
193 194 if ( it.second->getShadowMapInfo()->getShadowMap() ) {
194 195 it.second->getShadowMapInfo()->getShadowMap()->togglePreviewShadowMaps( _previewShadowMaps );
195 196 }
  @@ -235,36 +236,36 @@
235 236 }
236 237
237 238 bool LightManager::shadowMappingEnabled() const {
238 - if (!_shadowMapsEnabled){
239 - return false;
240 - }
241 - for (const Light::LightMap::value_type& light : _lights){
242 - if (!light.second->castsShadows()){
243 - continue;
244 - }
239 + if (!_shadowMapsEnabled){
240 + return false;
241 + }
242 + for (const Light::LightMap::value_type& light : _lights){
243 + if (!light.second->castsShadows()){
244 + continue;
245 + }
245 246 ShadowMapInfo* smi = light.second->getShadowMapInfo();
246 247 //no shadow info;
247 - if (!smi){
248 - continue;
249 - }
248 + if (!smi){
249 + continue;
250 + }
250 251 ShadowMap* sm = smi->getShadowMap();
251 252 //no shadow map;
252 - if (!sm){
253 - continue;
254 - }
255 - if (sm->getDepthMap()){
256 - return true;
257 - }
253 + if (!sm){
254 + continue;
255 + }
256 + if (sm->getDepthMap()){
257 + return true;
258 + }
258 259 }
259 260
260 261 return false;
261 262 }
262 263
263 264 Light* LightManager::getLight(I64 lightGUID) {
264 - Light::LightMap::const_iterator it = std::find_if(_lights.begin(), _lights.end(),
265 + Light::LightMap::const_iterator it = std::find_if(_lights.begin(), _lights.end(),
265 266 [&lightGUID](const Light::LightMap::value_type vt)->bool {
266 - return vt.second->getGUID() == lightGUID;
267 - });
267 + return vt.second->getGUID() == lightGUID;
268 + });
268 269 assert(it != _lights.end());
269 270 return it->second;
270 271 }
  @@ -276,7 +277,7 @@
276 277 _lightShadowProperties.clear();
277 278 _lightShadowProperties.reserve(static_cast<vectorAlg::vecSize>(_lights.size()));
278 279
279 - for (Light::LightMap::value_type& lightIt : _lights) {
280 + for (Light::LightMap::value_type& lightIt : _lights) {
280 281 Light* light = lightIt.second;
281 282 if ( light->_dirty[Light::PROPERTY_TYPE_PHYSICAL] ) {
282 283 LightProperties temp = light->getProperties();