diff options
Diffstat (limited to 'linden/indra/newview/lldrawpooltree.cpp')
-rw-r--r-- | linden/indra/newview/lldrawpooltree.cpp | 125 |
1 files changed, 27 insertions, 98 deletions
diff --git a/linden/indra/newview/lldrawpooltree.cpp b/linden/indra/newview/lldrawpooltree.cpp index ad05d9a..36a4393 100644 --- a/linden/indra/newview/lldrawpooltree.cpp +++ b/linden/indra/newview/lldrawpooltree.cpp | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #include "lldrawpooltree.h" | 30 | #include "lldrawpooltree.h" |
31 | 31 | ||
32 | #include "llagparray.h" | ||
33 | #include "lldrawable.h" | 32 | #include "lldrawable.h" |
34 | #include "llface.h" | 33 | #include "llface.h" |
35 | #include "llsky.h" | 34 | #include "llsky.h" |
@@ -41,7 +40,7 @@ | |||
41 | S32 LLDrawPoolTree::sDiffTex = 0; | 40 | S32 LLDrawPoolTree::sDiffTex = 0; |
42 | 41 | ||
43 | LLDrawPoolTree::LLDrawPoolTree(LLViewerImage *texturep) : | 42 | LLDrawPoolTree::LLDrawPoolTree(LLViewerImage *texturep) : |
44 | LLDrawPool(POOL_TREE, DATA_SIMPLE_IL_MASK, 0), | 43 | LLFacePool(POOL_TREE), |
45 | mTexturep(texturep) | 44 | mTexturep(texturep) |
46 | { | 45 | { |
47 | mTexturep->bind(0); | 46 | mTexturep->bind(0); |
@@ -55,7 +54,7 @@ LLDrawPool *LLDrawPoolTree::instancePool() | |||
55 | 54 | ||
56 | void LLDrawPoolTree::prerender() | 55 | void LLDrawPoolTree::prerender() |
57 | { | 56 | { |
58 | mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_OBJECT); | 57 | mVertexShaderLevel = 0; |
59 | } | 58 | } |
60 | 59 | ||
61 | void LLDrawPoolTree::beginRenderPass(S32 pass) | 60 | void LLDrawPoolTree::beginRenderPass(S32 pass) |
@@ -63,13 +62,7 @@ void LLDrawPoolTree::beginRenderPass(S32 pass) | |||
63 | glEnableClientState(GL_VERTEX_ARRAY); | 62 | glEnableClientState(GL_VERTEX_ARRAY); |
64 | glEnableClientState(GL_NORMAL_ARRAY); | 63 | glEnableClientState(GL_NORMAL_ARRAY); |
65 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 64 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
66 | 65 | glAlphaFunc(GL_GREATER, 0.5f); | |
67 | if ((mVertexShaderLevel > 0)) | ||
68 | { | ||
69 | S32 scatterTex = gPipeline.mObjectSimpleProgram.enableTexture(LLPipeline::GLSL_SCATTER_MAP); | ||
70 | LLViewerImage::bindTexture(gSky.mVOSkyp->getScatterMap(), scatterTex); | ||
71 | sDiffTex = gPipeline.mObjectSimpleProgram.enableTexture(LLPipeline::GLSL_DIFFUSE_MAP); | ||
72 | } | ||
73 | } | 66 | } |
74 | 67 | ||
75 | void LLDrawPoolTree::render(S32 pass) | 68 | void LLDrawPoolTree::render(S32 pass) |
@@ -83,34 +76,21 @@ void LLDrawPoolTree::render(S32 pass) | |||
83 | 76 | ||
84 | gPipeline.enableLightsDynamic(1.f); | 77 | gPipeline.enableLightsDynamic(1.f); |
85 | LLGLSPipelineAlpha gls_pipeline_alpha; | 78 | LLGLSPipelineAlpha gls_pipeline_alpha; |
86 | |||
87 | bindGLVertexPointer(); | ||
88 | bindGLTexCoordPointer(); | ||
89 | bindGLNormalPointer(); | ||
90 | |||
91 | LLOverrideFaceColor color(this, 1.f, 1.f, 1.f, 1.f); | 79 | LLOverrideFaceColor color(this, 1.f, 1.f, 1.f, 1.f); |
92 | 80 | ||
93 | renderTree(); | 81 | renderTree(); |
94 | |||
95 | } | 82 | } |
96 | 83 | ||
97 | void LLDrawPoolTree::endRenderPass(S32 pass) | 84 | void LLDrawPoolTree::endRenderPass(S32 pass) |
98 | { | 85 | { |
99 | if ((mVertexShaderLevel > 0)) | 86 | glAlphaFunc(GL_GREATER, 0.01f); |
100 | { | ||
101 | gPipeline.mObjectSimpleProgram.disableTexture(LLPipeline::GLSL_SCATTER_MAP); | ||
102 | gPipeline.mObjectSimpleProgram.disableTexture(LLPipeline::GLSL_DIFFUSE_MAP); | ||
103 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
104 | glEnable(GL_TEXTURE_2D); | ||
105 | } | ||
106 | |||
107 | glDisableClientState(GL_NORMAL_ARRAY); | 87 | glDisableClientState(GL_NORMAL_ARRAY); |
108 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 88 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
109 | } | 89 | } |
110 | 90 | ||
111 | void LLDrawPoolTree::renderForSelect() | 91 | void LLDrawPoolTree::renderForSelect() |
112 | { | 92 | { |
113 | if (mDrawFace.empty() || !mMemory.count()) | 93 | if (mDrawFace.empty()) |
114 | { | 94 | { |
115 | return; | 95 | return; |
116 | } | 96 | } |
@@ -123,10 +103,7 @@ void LLDrawPoolTree::renderForSelect() | |||
123 | LLGLSObjectSelectAlpha gls_alpha; | 103 | LLGLSObjectSelectAlpha gls_alpha; |
124 | 104 | ||
125 | glBlendFunc(GL_ONE, GL_ZERO); | 105 | glBlendFunc(GL_ONE, GL_ZERO); |
126 | glAlphaFunc(gPickTransparent ? GL_GEQUAL : GL_GREATER, 0.f); | 106 | glAlphaFunc(GL_GREATER, 0.5f); |
127 | |||
128 | bindGLVertexPointer(); | ||
129 | bindGLTexCoordPointer(); | ||
130 | 107 | ||
131 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); | 108 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); |
132 | glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); | 109 | glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); |
@@ -166,6 +143,8 @@ void LLDrawPoolTree::renderTree(BOOL selecting) | |||
166 | } | 143 | } |
167 | } | 144 | } |
168 | 145 | ||
146 | U32 indices_drawn = 0; | ||
147 | |||
169 | glMatrixMode(GL_MODELVIEW); | 148 | glMatrixMode(GL_MODELVIEW); |
170 | 149 | ||
171 | for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); | 150 | for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); |
@@ -174,11 +153,14 @@ void LLDrawPoolTree::renderTree(BOOL selecting) | |||
174 | LLFace *face = *iter; | 153 | LLFace *face = *iter; |
175 | LLDrawable *drawablep = face->getDrawable(); | 154 | LLDrawable *drawablep = face->getDrawable(); |
176 | 155 | ||
177 | if (drawablep->isDead()) | 156 | if (drawablep->isDead() || face->mVertexBuffer.isNull()) |
178 | { | 157 | { |
179 | continue; | 158 | continue; |
180 | } | 159 | } |
181 | 160 | ||
161 | face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK); | ||
162 | U32* indicesp = (U32*) face->mVertexBuffer->getIndicesPointer(); | ||
163 | |||
182 | // Render each of the trees | 164 | // Render each of the trees |
183 | LLVOTree *treep = (LLVOTree *)drawablep->getVObj(); | 165 | LLVOTree *treep = (LLVOTree *)drawablep->getVObj(); |
184 | 166 | ||
@@ -236,55 +218,26 @@ void LLDrawPoolTree::renderTree(BOOL selecting) | |||
236 | } | 218 | } |
237 | } | 219 | } |
238 | 220 | ||
239 | if (app_angle > (THRESH_ANGLE_FOR_BILLBOARD + BLEND_RANGE_FOR_BILLBOARD)) | 221 | if (app_angle < (THRESH_ANGLE_FOR_BILLBOARD - BLEND_RANGE_FOR_BILLBOARD)) |
240 | { | ||
241 | // | ||
242 | // Draw only the full geometry tree | ||
243 | // | ||
244 | //stop_depth = (app_angle < THRESH_ANGLE_FOR_RECURSION_REDUCTION); | ||
245 | glAlphaFunc(GL_GREATER, 0.5f); | ||
246 | LLDrawPool::LLOverrideFaceColor clr(this, color); | ||
247 | treep->drawBranchPipeline(this, trunk_LOD, stop_depth, treep->mDepth, treep->mTrunkDepth, 1.0, treep->mTwist, droop, treep->mBranches, alpha); | ||
248 | } | ||
249 | else if (app_angle < (THRESH_ANGLE_FOR_BILLBOARD - BLEND_RANGE_FOR_BILLBOARD)) | ||
250 | { | 222 | { |
251 | // | 223 | // |
252 | // Draw only the billboard | 224 | // Draw only the billboard |
253 | // | 225 | // |
254 | // Only the billboard, can use closer to normal alpha func. | 226 | // Only the billboard, can use closer to normal alpha func. |
255 | stop_depth = -1; | 227 | stop_depth = -1; |
256 | glAlphaFunc(GL_GREATER, 0.4f); | 228 | LLFacePool::LLOverrideFaceColor clr(this, color); |
257 | LLDrawPool::LLOverrideFaceColor clr(this, color); | 229 | indices_drawn += treep->drawBranchPipeline(indicesp, trunk_LOD, stop_depth, treep->mDepth, treep->mTrunkDepth, 1.0, treep->mTwist, droop, treep->mBranches, alpha); |
258 | treep->drawBranchPipeline(this, trunk_LOD, stop_depth, treep->mDepth, treep->mTrunkDepth, 1.0, treep->mTwist, droop, treep->mBranches, alpha); | ||
259 | } | 230 | } |
260 | else | 231 | else // if (app_angle > (THRESH_ANGLE_FOR_BILLBOARD + BLEND_RANGE_FOR_BILLBOARD)) |
261 | { | 232 | { |
262 | // | 233 | // |
263 | // Draw a blended version including both billboard and full tree | 234 | // Draw only the full geometry tree |
264 | // | 235 | // |
265 | alpha = (app_angle - THRESH_ANGLE_FOR_BILLBOARD)/BLEND_RANGE_FOR_BILLBOARD; | 236 | //stop_depth = (app_angle < THRESH_ANGLE_FOR_RECURSION_REDUCTION); |
266 | BOOL billboard_depth = TRUE; // billboard gets alpha | 237 | LLFacePool::LLOverrideFaceColor clr(this, color); |
267 | if (alpha > 0.5f) | 238 | indices_drawn += treep->drawBranchPipeline(indicesp, trunk_LOD, stop_depth, treep->mDepth, treep->mTrunkDepth, 1.0, treep->mTwist, droop, treep->mBranches, alpha); |
268 | { | ||
269 | billboard_depth = FALSE; | ||
270 | } | ||
271 | alpha = alpha/2.f + 0.5f; | ||
272 | |||
273 | glAlphaFunc(GL_GREATER, alpha*0.5f); | ||
274 | { | ||
275 | LLGLDepthTest gls_depth(GL_TRUE, billboard_depth ? GL_FALSE : GL_TRUE); | ||
276 | color.mV[3] = (U8) (llclamp(alpha, 0.0f, 1.0f) * 255); | ||
277 | LLDrawPool::LLOverrideFaceColor clr(this, color); | ||
278 | treep->drawBranchPipeline(this, trunk_LOD, 0, treep->mDepth, treep->mTrunkDepth, 1.0, treep->mTwist, droop, treep->mBranches, alpha); | ||
279 | } | ||
280 | { | ||
281 | LLGLDepthTest gls_depth(GL_TRUE, billboard_depth ? GL_TRUE : GL_FALSE); | ||
282 | glAlphaFunc(GL_GREATER, (1.f - alpha)*0.1f); | ||
283 | color.mV[3] = (U8) (llclamp(1.f-alpha, 0.0f, 1.0f) * 255); | ||
284 | LLDrawPool::LLOverrideFaceColor clr(this, color); | ||
285 | treep->drawBranchPipeline(this, trunk_LOD, -1, treep->mDepth, treep->mTrunkDepth, 1.0, treep->mTwist, droop, treep->mBranches, 1.f - alpha); | ||
286 | } | ||
287 | } | 239 | } |
240 | |||
288 | glPopMatrix(); | 241 | glPopMatrix(); |
289 | } | 242 | } |
290 | } | 243 | } |
@@ -298,45 +251,21 @@ void LLDrawPoolTree::renderTree(BOOL selecting) | |||
298 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 251 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
299 | } | 252 | } |
300 | } | 253 | } |
301 | glAlphaFunc(GL_GREATER, 0.01f); | ||
302 | } | ||
303 | |||
304 | |||
305 | S32 LLDrawPoolTree::rebuild() | ||
306 | { | ||
307 | mRebuildTime++; | ||
308 | if (mRebuildTime > mRebuildFreq) | ||
309 | { | ||
310 | // Flush AGP to force an AGP realloc and reduce AGP fragmentation | ||
311 | flushAGP(); | ||
312 | mRebuildTime = 0; | ||
313 | } | ||
314 | 254 | ||
315 | return 0; | 255 | addIndicesDrawn(indices_drawn); |
316 | } | 256 | } |
317 | 257 | ||
318 | BOOL LLDrawPoolTree::verify() const | 258 | BOOL LLDrawPoolTree::verify() const |
319 | { | 259 | { |
320 | BOOL ok = TRUE; | 260 | /* BOOL ok = TRUE; |
321 | |||
322 | // shared geometry. Just verify that it's there and correct. | ||
323 | 261 | ||
324 | // Verify all indices in the pool are in the right range | ||
325 | const U32 *indicesp = getRawIndices(); | ||
326 | for (U32 i = 0; i < getIndexCount(); i++) | ||
327 | { | ||
328 | if (indicesp[i] > getVertexCount()) | ||
329 | { | ||
330 | ok = FALSE; | ||
331 | llinfos << "Bad index in tree pool!" << llendl; | ||
332 | } | ||
333 | } | ||
334 | |||
335 | if (!ok) | 262 | if (!ok) |
336 | { | 263 | { |
337 | printDebugInfo(); | 264 | printDebugInfo(); |
338 | } | 265 | } |
339 | return ok; | 266 | return ok;*/ |
267 | |||
268 | return TRUE; | ||
340 | } | 269 | } |
341 | 270 | ||
342 | LLViewerImage *LLDrawPoolTree::getTexture() | 271 | LLViewerImage *LLDrawPoolTree::getTexture() |