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/Environment/Water/Water.cpp

Diff revisions: vs.
  @@ -8,10 +8,20 @@
8 8
9 9 namespace Divide {
10 10
11 - WaterPlane::WaterPlane() : SceneNode(TYPE_WATER), Reflector(TYPE_WATER_SURFACE,vec2<U16>(1024,1024)),
12 - _plane(nullptr), _waterLevel(0), _waterDepth(0), _refractionPlaneID(ClipPlaneIndex_PLACEHOLDER),
13 - _reflectionPlaneID(ClipPlaneIndex_PLACEHOLDER), _reflectionRendering(false), _refractionRendering(false), _refractionTexture(nullptr),
14 - _dirty(true), _paramsDirty(true), _cameraUnderWater(false), _cameraMgr(Application::getInstance().getKernel()->getCameraMgr())
11 + WaterPlane::WaterPlane() : SceneNode(TYPE_WATER),
12 + Reflector(TYPE_WATER_SURFACE,vec2<U16>(1024,1024)),
13 + _plane(nullptr),
14 + _waterLevel(0),
15 + _waterDepth(0),
16 + _refractionPlaneID(ClipPlaneIndex_PLACEHOLDER),
17 + _reflectionPlaneID(ClipPlaneIndex_PLACEHOLDER),
18 + _reflectionRendering(false),
19 + _refractionRendering(false),
20 + _refractionTexture(nullptr),
21 + _dirty(true),
22 + _paramsDirty(true),
23 + _cameraUnderWater(false),
24 + _cameraMgr(Application::getInstance().getKernel()->getCameraMgr())
15 25 {
16 26 //Set water plane to be single-sided
17 27 P32 quadMask;
  @@ -91,7 +101,8 @@
91 101 _dirty = false;
92 102 }
93 103 if (_paramsDirty){
94 - ShaderProgram* shader = sgn->getComponent<RenderingComponent>()->getMaterialInstance()->getShaderInfo(FINAL_STAGE).getProgram();
104 + RenderingComponent* rComp = sgn->getComponent<RenderingComponent>();
105 + ShaderProgram* shader = rComp->getMaterialInstance()->getShaderInfo(FINAL_STAGE).getProgram();
95 106 shader->Uniform("_waterShininess", _shininess);
96 107 shader->Uniform("_noiseFactor", _noiseFactor);
97 108 shader->Uniform("_noiseTile", _noiseTile);
  @@ -112,7 +123,11 @@
112 123 void WaterPlane::postDraw(SceneGraphNode* const sgn, const RenderStage& currentStage){
113 124 }
114 125
115 - void WaterPlane::getDrawCommands(SceneGraphNode* const sgn, const RenderStage& currentRenderStage, SceneRenderState& sceneRenderState, vectorImpl<GenericDrawCommand>& drawCommandsOut) {
126 + void WaterPlane::getDrawCommands(SceneGraphNode* const sgn,
127 + const RenderStage& currentRenderStage,
128 + SceneRenderState& sceneRenderState,
129 + vectorImpl<GenericDrawCommand>& drawCommandsOut) {
130 +
116 131 bool depthPass = GFX_DEVICE.isCurrentRenderStage(DEPTH_STAGE);
117 132 RenderingComponent* const renderable = sgn->getComponent<RenderingComponent>();
118 133 assert(renderable != nullptr);
  @@ -127,7 +142,10 @@
127 142 drawCommandsOut.push_back(cmd);
128 143 }
129 144
130 - void WaterPlane::render(SceneGraphNode* const sgn, const SceneRenderState& sceneRenderState, const RenderStage& currentRenderStage){
145 + void WaterPlane::render(SceneGraphNode* const sgn,
146 + const SceneRenderState& sceneRenderState,
147 + const RenderStage& currentRenderStage) {
148 +
131 149 if (!_plane->onDraw(nullptr, currentRenderStage)) {
132 150 return;
133 151 }
  @@ -146,8 +164,11 @@
146 164 if (!_createdFB) {
147 165 return false;
148 166 }
167 +
149 168 // Make sure we are not drawing our self unless this is desired
150 - if((currentStage == REFLECTION_STAGE || _reflectionRendering || _refractionRendering) && !_updateSelf) return false;
169 + if((currentStage == REFLECTION_STAGE || _reflectionRendering || _refractionRendering) && !_updateSelf) {
170 + return false;
171 + }
151 172
152 173 // Else, process normal exclusion
153 174 return SceneNode::getDrawState(currentStage);
  @@ -189,7 +210,8 @@
189 210 RenderStage prevRenderStage = GFX_DEVICE.setRenderStage(_cameraUnderWater ? FINAL_STAGE : REFLECTION_STAGE);
190 211 GFX_DEVICE.toggleClipPlane(_reflectionPlaneID, true);
191 212
192 - _cameraUnderWater ? _cameraMgr.getActiveCamera()->renderLookAt() : _cameraMgr.getActiveCamera()->renderLookAtReflected(getReflectionPlane());
213 + _cameraUnderWater ? _cameraMgr.getActiveCamera()->renderLookAt() :
214 + _cameraMgr.getActiveCamera()->renderLookAtReflected(getReflectionPlane());
193 215
194 216 _reflectedTexture->Begin(Framebuffer::defaultPolicy());
195 217 _renderCallback(); //< render to the reflective texture
  @@ -226,12 +248,17 @@
226 248 if (_previewReflection) {
227 249 F32 height = _resolution.y * 0.333f;
228 250 _refractionTexture->Bind();
229 - vec4<I32> viewport(_resolution.x * 0.333f, Application::getInstance().getResolution().y - height, _resolution.x * 0.666f, height);
230 - GFX_DEVICE.renderInViewport(viewport, DELEGATE_BIND((void(GFXDevice::*)(U32, size_t, ShaderProgram* const))&GFXDevice::drawPoints,
231 - &GFX_DEVICE,
232 - 1,
233 - GFX_DEVICE.getDefaultStateBlock(true),
234 - _previewReflectionShader));
251 + vec4<I32> viewport(_resolution.x * 0.333f,
252 + Application::getInstance().getResolution().y - height,
253 + _resolution.x * 0.666f,
254 + height);
255 + GFX_DEVICE.renderInViewport(viewport,
256 + DELEGATE_BIND((void(GFXDevice::*)(U32, size_t, ShaderProgram* const))
257 + &GFXDevice::drawPoints,
258 + &GFX_DEVICE,
259 + 1,
260 + GFX_DEVICE.getDefaultStateBlock(true),
261 + _previewReflectionShader));
235 262 }
236 263 # endif
237 264 Reflector::previewReflection();