Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 330 vs 331 for /trunk/Source Code/Rendering/Lighting/ShadowMapping/ShadowMap.cpp

Diff revisions: vs.
  @@ -11,56 +11,63 @@
11 11
12 12 namespace Divide {
13 13
14 - ShadowMap::ShadowMap(Light* light, Camera* shadowCamera, ShadowType type) : _init(false),
15 - _light(light),
16 - _shadowCamera(shadowCamera),
17 - _shadowMapType(type),
18 - _resolution(0),
19 - _par(ParamHandler::getInstance())
14 + ShadowMap::ShadowMap(Light* light,
15 + Camera* shadowCamera,
16 + ShadowType type) : _init(false),
17 + _light(light),
18 + _shadowCamera(shadowCamera),
19 + _shadowMapType(type),
20 + _resolution(0),
21 + _par(ParamHandler::getInstance())
20 22 {
21 23 _bias.bias();
22 24 }
23 25
24 26 ShadowMap::~ShadowMap()
25 27 {
26 - MemoryManager::SAFE_DELETE( _depthMap );
28 + MemoryManager::DELETE( _depthMap );
27 29 }
28 30
29 31 ShadowMapInfo::ShadowMapInfo(Light* light) : _light(light),
30 32 _shadowMap(nullptr)
31 33 {
32 34 if ( GFX_DEVICE.shadowDetailLevel() == DETAIL_ULTRA ) {
33 - _resolution = 2048;
35 + _resolution = 2048;
34 36 } else if ( GFX_DEVICE.shadowDetailLevel() == DETAIL_HIGH ) {
35 - _resolution = 1024;
36 - } else {
37 - _resolution = 512;
38 - }
39 - _numLayers = 1;
37 + _resolution = 1024;
38 + } else {
39 + _resolution = 512;
40 + }
41 + _numLayers = 1;
40 42 }
41 43
42 44 ShadowMapInfo::~ShadowMapInfo()
43 45 {
44 - MemoryManager::SAFE_DELETE( _shadowMap );
46 + MemoryManager::DELETE( _shadowMap );
45 47 }
46 48
47 - ShadowMap* ShadowMapInfo::getOrCreateShadowMap(const SceneRenderState& renderState, Camera* shadowCamera){
48 - if(_shadowMap) return _shadowMap;
49 + ShadowMap* ShadowMapInfo::getOrCreateShadowMap(const SceneRenderState& renderState,
50 + Camera* shadowCamera) {
51 + if (_shadowMap) {
52 + return _shadowMap;
53 + }
49 54
50 - if(!_light->castsShadows()) return nullptr;
55 + if (!_light->castsShadows()) {
56 + return nullptr;
57 + }
51 58
52 - switch(_light->getLightType()){
59 + switch (_light->getLightType()) {
53 60 case LIGHT_TYPE_POINT:{
54 61 _numLayers = 6;
55 - _shadowMap = New CubeShadowMap(_light, shadowCamera);
62 + _shadowMap = MemoryManager_NEW CubeShadowMap(_light, shadowCamera);
56 63 }break;
57 64 case LIGHT_TYPE_DIRECTIONAL:{
58 65 DirectionalLight* dirLight = dynamic_cast<DirectionalLight*>(_light);
59 66 _numLayers = dirLight->csmSplitCount();
60 - _shadowMap = New CascadedShadowMaps(_light, shadowCamera, _numLayers);
67 + _shadowMap = MemoryManager_NEW CascadedShadowMaps(_light, shadowCamera, _numLayers);
61 68 }break;
62 69 case LIGHT_TYPE_SPOT:{
63 - _shadowMap = New SingleShadowMap(_light, shadowCamera);
70 + _shadowMap = MemoryManager_NEW SingleShadowMap(_light, shadowCamera);
64 71 }break;
65 72 default:
66 73 break;
  @@ -74,27 +81,25 @@
74 81
75 82 void ShadowMapInfo::resolution(U16 resolution) {
76 83 _resolution = resolution;
77 - if (_shadowMap)
84 + if (_shadowMap) {
78 85 _shadowMap->resolution(_resolution, _light->shadowMapResolutionFactor());
86 + }
79 87 }
80 88
81 - bool ShadowMap::Bind(U8 offset){
82 - if (!_depthMap)
83 - return false;
84 -
85 - return BindInternal(offset);
89 + bool ShadowMap::Bind(U8 offset) {
90 + return _depthMap ? BindInternal(offset) : false;
86 91 }
87 92
88 - bool ShadowMap::BindInternal(U8 offset){
93 + bool ShadowMap::BindInternal(U8 offset) {
89 94 _depthMap->Bind(offset, TextureDescriptor::Depth);
90 95 return true;
91 96 }
92 97
93 - U16 ShadowMap::resolution(){
98 + U16 ShadowMap::resolution() {
94 99 return _depthMap->getWidth();
95 100 }
96 101
97 - void ShadowMap::postRender(){
102 + void ShadowMap::postRender() {
98 103 }
99 104
100 105 };