diff options
author | Jacek Antonelli | 2009-04-30 13:04:20 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-30 13:07:16 -0500 |
commit | ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch) | |
tree | 8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/lldrawpooltree.cpp | |
parent | Second Life viewer sources 1.22.11 (diff) | |
download | meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2 meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz |
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/newview/lldrawpooltree.cpp')
-rw-r--r-- | linden/indra/newview/lldrawpooltree.cpp | 112 |
1 files changed, 107 insertions, 5 deletions
diff --git a/linden/indra/newview/lldrawpooltree.cpp b/linden/indra/newview/lldrawpooltree.cpp index 312c61c..2f2b072 100644 --- a/linden/indra/newview/lldrawpooltree.cpp +++ b/linden/indra/newview/lldrawpooltree.cpp | |||
@@ -17,7 +17,8 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -42,6 +43,7 @@ | |||
42 | #include "llviewercamera.h" | 43 | #include "llviewercamera.h" |
43 | #include "llviewershadermgr.h" | 44 | #include "llviewershadermgr.h" |
44 | #include "llrender.h" | 45 | #include "llrender.h" |
46 | #include "llviewercontrol.h" | ||
45 | 47 | ||
46 | S32 LLDrawPoolTree::sDiffTex = 0; | 48 | S32 LLDrawPoolTree::sDiffTex = 0; |
47 | static LLGLSLShader* shader = NULL; | 49 | static LLGLSLShader* shader = NULL; |
@@ -51,7 +53,7 @@ LLDrawPoolTree::LLDrawPoolTree(LLViewerImage *texturep) : | |||
51 | mTexturep(texturep) | 53 | mTexturep(texturep) |
52 | { | 54 | { |
53 | gGL.getTexUnit(0)->bind(mTexturep.get()); | 55 | gGL.getTexUnit(0)->bind(mTexturep.get()); |
54 | mTexturep->setClamp(FALSE, FALSE); | 56 | mTexturep->setAddressMode(LLTexUnit::TAM_WRAP); |
55 | } | 57 | } |
56 | 58 | ||
57 | LLDrawPool *LLDrawPoolTree::instancePool() | 59 | LLDrawPool *LLDrawPoolTree::instancePool() |
@@ -90,7 +92,7 @@ void LLDrawPoolTree::beginRenderPass(S32 pass) | |||
90 | 92 | ||
91 | void LLDrawPoolTree::render(S32 pass) | 93 | void LLDrawPoolTree::render(S32 pass) |
92 | { | 94 | { |
93 | LLFastTimer t(LLFastTimer::FTM_RENDER_TREES); | 95 | LLFastTimer t(LLPipeline::sShadowRender ? LLFastTimer::FTM_SHADOW_TREE : LLFastTimer::FTM_RENDER_TREES); |
94 | 96 | ||
95 | if (mDrawFace.empty()) | 97 | if (mDrawFace.empty()) |
96 | { | 98 | { |
@@ -100,7 +102,23 @@ void LLDrawPoolTree::render(S32 pass) | |||
100 | LLGLEnable test(GL_ALPHA_TEST); | 102 | LLGLEnable test(GL_ALPHA_TEST); |
101 | LLOverrideFaceColor color(this, 1.f, 1.f, 1.f, 1.f); | 103 | LLOverrideFaceColor color(this, 1.f, 1.f, 1.f, 1.f); |
102 | 104 | ||
103 | renderTree(); | 105 | if (gSavedSettings.getBOOL("RenderAnimateTrees")) |
106 | { | ||
107 | renderTree(); | ||
108 | } | ||
109 | else | ||
110 | { | ||
111 | gGL.getTexUnit(sDiffTex)->bind(mTexturep); | ||
112 | |||
113 | for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); | ||
114 | iter != mDrawFace.end(); iter++) | ||
115 | { | ||
116 | LLFace *face = *iter; | ||
117 | face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK); | ||
118 | face->mVertexBuffer->drawRange(LLRender::TRIANGLES, 0, face->mVertexBuffer->getRequestedVerts()-1, face->mVertexBuffer->getRequestedIndices(), 0); | ||
119 | gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices()/3); | ||
120 | } | ||
121 | } | ||
104 | } | 122 | } |
105 | 123 | ||
106 | void LLDrawPoolTree::endRenderPass(S32 pass) | 124 | void LLDrawPoolTree::endRenderPass(S32 pass) |
@@ -114,6 +132,54 @@ void LLDrawPoolTree::endRenderPass(S32 pass) | |||
114 | } | 132 | } |
115 | } | 133 | } |
116 | 134 | ||
135 | //============================================ | ||
136 | // deferred implementation | ||
137 | //============================================ | ||
138 | void LLDrawPoolTree::beginDeferredPass(S32 pass) | ||
139 | { | ||
140 | LLFastTimer t(LLFastTimer::FTM_RENDER_TREES); | ||
141 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); | ||
142 | |||
143 | shader = &gDeferredTreeProgram; | ||
144 | shader->bind(); | ||
145 | } | ||
146 | |||
147 | void LLDrawPoolTree::renderDeferred(S32 pass) | ||
148 | { | ||
149 | render(pass); | ||
150 | } | ||
151 | |||
152 | void LLDrawPoolTree::endDeferredPass(S32 pass) | ||
153 | { | ||
154 | LLFastTimer t(LLFastTimer::FTM_RENDER_TREES); | ||
155 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); | ||
156 | |||
157 | shader->unbind(); | ||
158 | } | ||
159 | |||
160 | //============================================ | ||
161 | // shadow implementation | ||
162 | //============================================ | ||
163 | void LLDrawPoolTree::beginShadowPass(S32 pass) | ||
164 | { | ||
165 | LLFastTimer t(LLFastTimer::FTM_SHADOW_TREE); | ||
166 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); | ||
167 | gDeferredShadowProgram.bind(); | ||
168 | } | ||
169 | |||
170 | void LLDrawPoolTree::renderShadow(S32 pass) | ||
171 | { | ||
172 | render(pass); | ||
173 | } | ||
174 | |||
175 | void LLDrawPoolTree::endShadowPass(S32 pass) | ||
176 | { | ||
177 | LLFastTimer t(LLFastTimer::FTM_SHADOW_TREE); | ||
178 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); | ||
179 | gDeferredShadowProgram.unbind(); | ||
180 | } | ||
181 | |||
182 | |||
117 | void LLDrawPoolTree::renderForSelect() | 183 | void LLDrawPoolTree::renderForSelect() |
118 | { | 184 | { |
119 | if (mDrawFace.empty()) | 185 | if (mDrawFace.empty()) |
@@ -132,7 +198,43 @@ void LLDrawPoolTree::renderForSelect() | |||
132 | gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); | 198 | gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); |
133 | gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); | 199 | gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA); |
134 | 200 | ||
135 | renderTree(TRUE); | 201 | if (gSavedSettings.getBOOL("RenderAnimateTrees")) |
202 | { | ||
203 | renderTree(TRUE); | ||
204 | } | ||
205 | else | ||
206 | { | ||
207 | gGL.getTexUnit(sDiffTex)->bind(mTexturep); | ||
208 | |||
209 | for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); | ||
210 | iter != mDrawFace.end(); iter++) | ||
211 | { | ||
212 | LLFace *face = *iter; | ||
213 | LLDrawable *drawablep = face->getDrawable(); | ||
214 | |||
215 | if (drawablep->isDead() || face->mVertexBuffer.isNull()) | ||
216 | { | ||
217 | continue; | ||
218 | } | ||
219 | |||
220 | // Render each of the trees | ||
221 | LLVOTree *treep = (LLVOTree *)drawablep->getVObj().get(); | ||
222 | |||
223 | LLColor4U color(255,255,255,255); | ||
224 | |||
225 | if (treep->mGLName != 0) | ||
226 | { | ||
227 | S32 name = treep->mGLName; | ||
228 | color = LLColor4U((U8)(name >> 16), (U8)(name >> 8), (U8)name, 255); | ||
229 | |||
230 | LLFacePool::LLOverrideFaceColor col(this, color); | ||
231 | |||
232 | face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK); | ||
233 | face->mVertexBuffer->drawRange(LLRender::TRIANGLES, 0, face->mVertexBuffer->getRequestedVerts()-1, face->mVertexBuffer->getRequestedIndices(), 0); | ||
234 | gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices()/3); | ||
235 | } | ||
236 | } | ||
237 | } | ||
136 | 238 | ||
137 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); | 239 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); |
138 | gGL.setSceneBlendType(LLRender::BT_ALPHA); | 240 | gGL.setSceneBlendType(LLRender::BT_ALPHA); |