Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 167 vs 168 for /trunk/Source Code/Environment/Terrain/Terrain.cpp

Diff revisions: vs.
  @@ -52,7 +52,7 @@
52 52 {
53 53 }
54 54
55 - void Terrain::sceneUpdate(const U32 sceneTime,SceneGraphNode* const sgn){
55 + void Terrain::sceneUpdate(const U32 sceneTime, SceneGraphNode* const sgn, SceneState& sceneState){
56 56 ///Query shadow state every "_stateRefreshInterval" milliseconds
57 57
58 58 if (sceneTime - _stateRefreshIntervalBuffer >= _stateRefreshInterval){
  @@ -60,9 +60,9 @@
60 60
61 61 _stateRefreshIntervalBuffer += _stateRefreshInterval;
62 62 }
63 - _veg->sceneUpdate(sceneTime,sgn);
63 + _veg->sceneUpdate(sceneTime,sgn,sceneState);
64 64
65 - SceneNode::sceneUpdate(sceneTime, sgn);
65 + SceneNode::sceneUpdate(sceneTime, sgn, sceneState);
66 66 }
67 67
68 68 #pragma message("ToDo: Add multiple local lights for terrain, such as torches, rockets, flashlights etc - Ionut")
  @@ -82,7 +82,7 @@
82 82 }
83 83 CLAMP<U8>(_lightCount, 0, 1);
84 84 if(GFX_DEVICE.isCurrentRenderStage(DISPLAY_STAGE)){
85 - U8 offset = 9;
85 + U8 offset = Config::MAX_TEXTURE_STORAGE;
86 86 for(U8 n = 0; n < _lightCount; n++, offset++){
87 87 Light* l = LightManager::getInstance().getLightForCurrentNode(n);
88 88 LightManager::getInstance().bindDepthMaps(l, n, offset);
  @@ -107,15 +107,12 @@
107 107 _terrainTextures[TERRAIN_TEXTURE_RED]->Bind(3); //AlphaMap: RED
108 108 _terrainTextures[TERRAIN_TEXTURE_GREEN]->Bind(4); //AlphaMap: GREEN
109 109 _terrainTextures[TERRAIN_TEXTURE_BLUE]->Bind(5); //AlphaMap: BLUE
110 -
111 - terrainShader->bind();
112 - terrainShader->Uniform("material",getMaterial()->getMaterialMatrix());
113 - terrainShader->Uniform("water_reflection_rendering", GFX_DEVICE.isCurrentRenderStage(REFLECTION_STAGE));
114 110 if(_alphaTexturePresent){
115 111 _terrainTextures[TERRAIN_TEXTURE_ALPHA]->Bind(6); //AlphaMap: Alpha
116 112 }
117 -
118 - terrainShader->Uniform("worldHalfExtent", GET_ACTIVE_SCENE()->getSceneGraph()->getRoot()->getBoundingBox().getWidth() * 0.5f);
113 + terrainShader->bind();
114 + terrainShader->Uniform("material",getMaterial()->getMaterialMatrix());
115 + terrainShader->Uniform("worldHalfExtent", GET_ACTIVE_SCENEGRAPH()->getRoot()->getBoundingBox().getWidth() * 0.5f);
119 116 terrainShader->Uniform("dvd_enableShadowMapping", _shadowMapped);
120 117 terrainShader->Uniform("dvd_lightProjectionMatrices",LightManager::getInstance().getLightProjectionMatricesCache());
121 118 terrainShader->Uniform("dvd_lightType",types);
  @@ -133,7 +130,7 @@
133 130 _terrainTextures[TERRAIN_TEXTURE_DIFFUSE]->Unbind(0);
134 131
135 132 if(GFX_DEVICE.isCurrentRenderStage(DISPLAY_STAGE)){
136 - U8 offset = (_lightCount - 1) + 9;
133 + U8 offset = (_lightCount - 1) + Config::MAX_TEXTURE_STORAGE;
137 134 for(I32 n = _lightCount - 1; n >= 0; n--,offset--){
138 135 Light* l = LightManager::getInstance().getLightForCurrentNode(n);
139 136 LightManager::getInstance().unbindDepthMaps(l, offset);
  @@ -166,7 +163,7 @@
166 163 }
167 164
168 165 void Terrain::onDraw(const RenderStage& currentStage){
169 - _eyePos = GET_ACTIVE_SCENE()->renderState()->getCamera()->getEye();
166 + _eyePos = GET_ACTIVE_SCENE()->renderState().getCamera().getEye();
170 167 }
171 168
172 169 void Terrain::postDraw(const RenderStage& currentStage){
  @@ -174,14 +171,13 @@
174 171 }
175 172
176 173 void Terrain::drawInfinitePlain(){
174 + if(GFX_DEVICE.isCurrentRenderStage(REFLECTION_STAGE | DEPTH_STAGE)) return;
175 +
177 176 SET_STATE_BLOCK(_terrainDepthRenderState);
178 177 _planeTransform->setPosition(vec3<F32>(_eyePos.x,_planeTransform->getPosition().y,_eyePos.z));
179 178 _planeSGN->getBoundingBox().Transform(_planeSGN->getInitialBoundingBox(),
180 179 _planeTransform->getMatrix());
181 180
182 - if(GFX_DEVICE.isCurrentRenderStage(REFLECTION_STAGE)) return;
183 - if(GFX_DEVICE.isCurrentRenderStage(DEPTH_STAGE)) return;
184 -
185 181 GFX_DEVICE.renderInstance(_plane->renderInstance());
186 182 }
187 183
  @@ -205,7 +201,8 @@
205 201 }
206 202
207 203 vec3<F32> Terrain::getPosition(F32 x_clampf, F32 z_clampf) const{
208 - if(x_clampf<.0f || z_clampf<.0f || x_clampf>1.0f || z_clampf>1.0f) return vec3<F32>(0.0f, 0.0f, 0.0f);
204 + if(x_clampf<.0f || z_clampf<.0f || x_clampf>1.0f || z_clampf>1.0f)
205 + return vec3<F32>(0.0f);
209 206
210 207 vec2<F32> posF( x_clampf * _terrainWidth, z_clampf * _terrainHeight );
211 208 vec2<U32> posI( (I32)(posF.x), (I32)(posF.y) );