diff options
author | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
commit | b2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch) | |
tree | 3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/newview/lldrawpoolavatar.cpp | |
parent | Second Life viewer sources 1.14.0.1 (diff) | |
download | meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2 meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz |
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/newview/lldrawpoolavatar.cpp')
-rw-r--r-- | linden/indra/newview/lldrawpoolavatar.cpp | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/linden/indra/newview/lldrawpoolavatar.cpp b/linden/indra/newview/lldrawpoolavatar.cpp index fc4f64b..debcfe2 100644 --- a/linden/indra/newview/lldrawpoolavatar.cpp +++ b/linden/indra/newview/lldrawpoolavatar.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | 5 | * Copyright (c) 2002-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -40,6 +41,7 @@ | |||
40 | #include "llviewerregion.h" | 41 | #include "llviewerregion.h" |
41 | #include "noise.h" | 42 | #include "noise.h" |
42 | #include "pipeline.h" | 43 | #include "pipeline.h" |
44 | #include "llglslshader.h" | ||
43 | 45 | ||
44 | static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK; | 46 | static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK; |
45 | static U32 sBufferUsage = GL_STREAM_DRAW_ARB; | 47 | static U32 sBufferUsage = GL_STREAM_DRAW_ARB; |
@@ -97,16 +99,15 @@ LLDrawPool *LLDrawPoolAvatar::instancePool() | |||
97 | } | 99 | } |
98 | 100 | ||
99 | BOOL gRenderAvatar = TRUE; | 101 | BOOL gRenderAvatar = TRUE; |
100 | static LLMatrix4 sModelViewMatrix = LLMatrix4(); | ||
101 | 102 | ||
102 | S32 LLDrawPoolAvatar::getVertexShaderLevel() const | 103 | S32 LLDrawPoolAvatar::getVertexShaderLevel() const |
103 | { | 104 | { |
104 | return (S32) gPipeline.getVertexShaderLevel(LLPipeline::SHADER_AVATAR); | 105 | return (S32) LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR); |
105 | } | 106 | } |
106 | 107 | ||
107 | void LLDrawPoolAvatar::prerender() | 108 | void LLDrawPoolAvatar::prerender() |
108 | { | 109 | { |
109 | mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_AVATAR); | 110 | mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR); |
110 | sShaderLevel = mVertexShaderLevel; | 111 | sShaderLevel = mVertexShaderLevel; |
111 | 112 | ||
112 | if (sShaderLevel > 0) | 113 | if (sShaderLevel > 0) |
@@ -121,7 +122,14 @@ void LLDrawPoolAvatar::prerender() | |||
121 | 122 | ||
122 | LLMatrix4& LLDrawPoolAvatar::getModelView() | 123 | LLMatrix4& LLDrawPoolAvatar::getModelView() |
123 | { | 124 | { |
124 | return sModelViewMatrix; | 125 | static LLMatrix4 ret; |
126 | |||
127 | ret.initRows(LLVector4(gGLModelView+0), | ||
128 | LLVector4(gGLModelView+4), | ||
129 | LLVector4(gGLModelView+8), | ||
130 | LLVector4(gGLModelView+12)); | ||
131 | |||
132 | return ret; | ||
125 | } | 133 | } |
126 | 134 | ||
127 | //----------------------------------------------------------------------------- | 135 | //----------------------------------------------------------------------------- |
@@ -150,7 +158,6 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass) | |||
150 | beginFootShadow(); | 158 | beginFootShadow(); |
151 | break; | 159 | break; |
152 | case 1: | 160 | case 1: |
153 | glGetFloatv(GL_MODELVIEW_MATRIX, (F32*) sModelViewMatrix.mMatrix); | ||
154 | beginRigid(); | 161 | beginRigid(); |
155 | break; | 162 | break; |
156 | case 2: | 163 | case 2: |
@@ -190,15 +197,15 @@ void LLDrawPoolAvatar::endFootShadow() | |||
190 | 197 | ||
191 | void LLDrawPoolAvatar::beginRigid() | 198 | void LLDrawPoolAvatar::beginRigid() |
192 | { | 199 | { |
193 | sVertexProgram = &gPipeline.mAvatarEyeballProgram; | 200 | sVertexProgram = &gAvatarEyeballProgram; |
194 | glEnableClientState(GL_NORMAL_ARRAY); | 201 | glEnableClientState(GL_NORMAL_ARRAY); |
195 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 202 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
196 | 203 | ||
197 | if (sShaderLevel > 0) | 204 | if (sShaderLevel > 0) |
198 | { //eyeballs render with the specular shader | 205 | { //eyeballs render with the specular shader |
199 | gPipeline.mAvatarEyeballProgram.bind(); | 206 | gAvatarEyeballProgram.bind(); |
200 | gPipeline.mMaterialIndex = gPipeline.mAvatarEyeballProgram.mAttribute[LLPipeline::GLSL_MATERIAL_COLOR]; | 207 | gMaterialIndex = gAvatarEyeballProgram.mAttribute[LLShaderMgr::MATERIAL_COLOR]; |
201 | gPipeline.mSpecularIndex = gPipeline.mAvatarEyeballProgram.mAttribute[LLPipeline::GLSL_SPECULAR_COLOR]; | 208 | gSpecularIndex = gAvatarEyeballProgram.mAttribute[LLShaderMgr::SPECULAR_COLOR]; |
202 | } | 209 | } |
203 | } | 210 | } |
204 | 211 | ||
@@ -213,7 +220,7 @@ void LLDrawPoolAvatar::beginSkinned() | |||
213 | glEnableClientState(GL_NORMAL_ARRAY); | 220 | glEnableClientState(GL_NORMAL_ARRAY); |
214 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 221 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
215 | 222 | ||
216 | sVertexProgram = &gPipeline.mAvatarProgram; | 223 | sVertexProgram = &gAvatarProgram; |
217 | 224 | ||
218 | if (sShaderLevel > 0) // for hardware blending | 225 | if (sShaderLevel > 0) // for hardware blending |
219 | { | 226 | { |
@@ -221,22 +228,22 @@ void LLDrawPoolAvatar::beginSkinned() | |||
221 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | 228 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
222 | if (sShaderLevel >= SHADER_LEVEL_BUMP) | 229 | if (sShaderLevel >= SHADER_LEVEL_BUMP) |
223 | { | 230 | { |
224 | gPipeline.mMaterialIndex = sVertexProgram->mAttribute[LLPipeline::GLSL_MATERIAL_COLOR]; | 231 | gMaterialIndex = sVertexProgram->mAttribute[LLShaderMgr::MATERIAL_COLOR]; |
225 | gPipeline.mSpecularIndex = sVertexProgram->mAttribute[LLPipeline::GLSL_SPECULAR_COLOR]; | 232 | gSpecularIndex = sVertexProgram->mAttribute[LLShaderMgr::SPECULAR_COLOR]; |
226 | } | 233 | } |
227 | sVertexProgram->bind(); | 234 | sVertexProgram->bind(); |
228 | if (sShaderLevel >= SHADER_LEVEL_CLOTH) | 235 | if (sShaderLevel >= SHADER_LEVEL_CLOTH) |
229 | { | 236 | { |
230 | enable_cloth_weights(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_CLOTHING]); | 237 | enable_cloth_weights(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_CLOTHING]); |
231 | } | 238 | } |
232 | enable_vertex_weighting(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT]); | 239 | enable_vertex_weighting(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT]); |
233 | 240 | ||
234 | if (sShaderLevel >= SHADER_LEVEL_BUMP) | 241 | if (sShaderLevel >= SHADER_LEVEL_BUMP) |
235 | { | 242 | { |
236 | enable_binormals(sVertexProgram->mAttribute[LLPipeline::GLSL_BINORMAL]); | 243 | enable_binormals(sVertexProgram->mAttribute[LLShaderMgr::BINORMAL]); |
237 | } | 244 | } |
238 | 245 | ||
239 | sVertexProgram->enableTexture(LLPipeline::GLSL_BUMP_MAP); | 246 | sVertexProgram->enableTexture(LLShaderMgr::BUMP_MAP); |
240 | glActiveTextureARB(GL_TEXTURE0_ARB); | 247 | glActiveTextureARB(GL_TEXTURE0_ARB); |
241 | } | 248 | } |
242 | } | 249 | } |
@@ -247,17 +254,17 @@ void LLDrawPoolAvatar::endSkinned() | |||
247 | if (sShaderLevel > 0) | 254 | if (sShaderLevel > 0) |
248 | { | 255 | { |
249 | sRenderingSkinned = FALSE; | 256 | sRenderingSkinned = FALSE; |
250 | sVertexProgram->disableTexture(LLPipeline::GLSL_BUMP_MAP); | 257 | sVertexProgram->disableTexture(LLShaderMgr::BUMP_MAP); |
251 | glActiveTextureARB(GL_TEXTURE0_ARB); | 258 | glActiveTextureARB(GL_TEXTURE0_ARB); |
252 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | 259 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
253 | disable_vertex_weighting(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT]); | 260 | disable_vertex_weighting(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT]); |
254 | if (sShaderLevel >= SHADER_LEVEL_BUMP) | 261 | if (sShaderLevel >= SHADER_LEVEL_BUMP) |
255 | { | 262 | { |
256 | disable_binormals(sVertexProgram->mAttribute[LLPipeline::GLSL_BINORMAL]); | 263 | disable_binormals(sVertexProgram->mAttribute[LLShaderMgr::BINORMAL]); |
257 | } | 264 | } |
258 | if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) | 265 | if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) |
259 | { | 266 | { |
260 | disable_cloth_weights(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_CLOTHING]); | 267 | disable_cloth_weights(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_CLOTHING]); |
261 | } | 268 | } |
262 | 269 | ||
263 | sVertexProgram->unbind(); | 270 | sVertexProgram->unbind(); |
@@ -373,7 +380,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) | |||
373 | 380 | ||
374 | if (sShaderLevel > 0) | 381 | if (sShaderLevel > 0) |
375 | { | 382 | { |
376 | gPipeline.mAvatarMatrixParam = sVertexProgram->mUniform[LLPipeline::GLSL_AVATAR_MATRIX]; | 383 | gAvatarMatrixParam = sVertexProgram->mUniform[LLShaderMgr::AVATAR_MATRIX]; |
377 | } | 384 | } |
378 | 385 | ||
379 | if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) | 386 | if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) |
@@ -389,16 +396,16 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) | |||
389 | wind = wind * rot_mat; | 396 | wind = wind * rot_mat; |
390 | wind.mV[VW] = avatarp->mWindVec.mV[VW]; | 397 | wind.mV[VW] = avatarp->mWindVec.mV[VW]; |
391 | 398 | ||
392 | sVertexProgram->vertexAttrib4fv(LLPipeline::GLSL_AVATAR_WIND, wind.mV); | 399 | sVertexProgram->vertexAttrib4fv(LLShaderMgr::AVATAR_WIND, wind.mV); |
393 | F32 phase = -1.f * (avatarp->mRipplePhase); | 400 | F32 phase = -1.f * (avatarp->mRipplePhase); |
394 | 401 | ||
395 | F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); | 402 | F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); |
396 | LLVector4 sin_params(freq, freq, freq, phase); | 403 | LLVector4 sin_params(freq, freq, freq, phase); |
397 | sVertexProgram->vertexAttrib4fv(LLPipeline::GLSL_AVATAR_SINWAVE, sin_params.mV); | 404 | sVertexProgram->vertexAttrib4fv(LLShaderMgr::AVATAR_SINWAVE, sin_params.mV); |
398 | 405 | ||
399 | LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); | 406 | LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); |
400 | gravity = gravity * rot_mat; | 407 | gravity = gravity * rot_mat; |
401 | sVertexProgram->vertexAttrib4fv(LLPipeline::GLSL_AVATAR_GRAVITY, gravity.mV); | 408 | sVertexProgram->vertexAttrib4fv(LLShaderMgr::AVATAR_GRAVITY, gravity.mV); |
402 | } | 409 | } |
403 | 410 | ||
404 | if( !single_avatar || (avatarp == single_avatar) ) | 411 | if( !single_avatar || (avatarp == single_avatar) ) |
@@ -525,11 +532,10 @@ void LLDrawPoolAvatar::renderForSelect() | |||
525 | glEnableClientState(GL_VERTEX_ARRAY); | 532 | glEnableClientState(GL_VERTEX_ARRAY); |
526 | glEnableClientState(GL_NORMAL_ARRAY); | 533 | glEnableClientState(GL_NORMAL_ARRAY); |
527 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 534 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
528 | glGetFloatv(GL_MODELVIEW_MATRIX, (F32*) sModelViewMatrix.mMatrix); | 535 | sVertexProgram = &gAvatarPickProgram; |
529 | sVertexProgram = &gPipeline.mAvatarPickProgram; | ||
530 | if (sShaderLevel > 0) | 536 | if (sShaderLevel > 0) |
531 | { | 537 | { |
532 | gPipeline.mAvatarMatrixParam = sVertexProgram->mUniform[LLPipeline::GLSL_AVATAR_MATRIX]; | 538 | gAvatarMatrixParam = sVertexProgram->mUniform[LLShaderMgr::AVATAR_MATRIX]; |
533 | } | 539 | } |
534 | glAlphaFunc(GL_GEQUAL, 0.2f); | 540 | glAlphaFunc(GL_GEQUAL, 0.2f); |
535 | glBlendFunc(GL_ONE, GL_ZERO); | 541 | glBlendFunc(GL_ONE, GL_ZERO); |
@@ -546,7 +552,7 @@ void LLDrawPoolAvatar::renderForSelect() | |||
546 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | 552 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
547 | sRenderingSkinned = TRUE; | 553 | sRenderingSkinned = TRUE; |
548 | sVertexProgram->bind(); | 554 | sVertexProgram->bind(); |
549 | enable_vertex_weighting(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT]); | 555 | enable_vertex_weighting(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT]); |
550 | } | 556 | } |
551 | 557 | ||
552 | mIndicesDrawn += avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); | 558 | mIndicesDrawn += avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); |
@@ -556,7 +562,7 @@ void LLDrawPoolAvatar::renderForSelect() | |||
556 | { | 562 | { |
557 | sRenderingSkinned = FALSE; | 563 | sRenderingSkinned = FALSE; |
558 | sVertexProgram->unbind(); | 564 | sVertexProgram->unbind(); |
559 | disable_vertex_weighting(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT]); | 565 | disable_vertex_weighting(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT]); |
560 | } | 566 | } |
561 | 567 | ||
562 | glAlphaFunc(GL_GREATER, 0.01f); | 568 | glAlphaFunc(GL_GREATER, 0.01f); |
@@ -596,7 +602,7 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const | |||
596 | 602 | ||
597 | LLVertexBufferAvatar::LLVertexBufferAvatar() | 603 | LLVertexBufferAvatar::LLVertexBufferAvatar() |
598 | : LLVertexBuffer(sDataMask, | 604 | : LLVertexBuffer(sDataMask, |
599 | gPipeline.getVertexShaderLevel(LLPipeline::SHADER_AVATAR) > 0 ? | 605 | LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR) > 0 ? |
600 | GL_STATIC_DRAW_ARB : | 606 | GL_STATIC_DRAW_ARB : |
601 | GL_STREAM_DRAW_ARB) | 607 | GL_STREAM_DRAW_ARB) |
602 | { | 608 | { |
@@ -618,16 +624,16 @@ void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const | |||
618 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | 624 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
619 | glTexCoordPointer(2,GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_TEXCOORD])); | 625 | glTexCoordPointer(2,GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_TEXCOORD])); |
620 | 626 | ||
621 | set_vertex_weights(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT])); | 627 | set_vertex_weights(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT])); |
622 | 628 | ||
623 | if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_BUMP) | 629 | if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_BUMP) |
624 | { | 630 | { |
625 | set_binormals(sVertexProgram->mAttribute[LLPipeline::GLSL_BINORMAL], mStride, (LLVector3*)(base + mOffsets[TYPE_BINORMAL])); | 631 | set_binormals(sVertexProgram->mAttribute[LLShaderMgr::BINORMAL], mStride, (LLVector3*)(base + mOffsets[TYPE_BINORMAL])); |
626 | } | 632 | } |
627 | 633 | ||
628 | if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH) | 634 | if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH) |
629 | { | 635 | { |
630 | set_vertex_clothing_weights(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT])); | 636 | set_vertex_clothing_weights(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT])); |
631 | } | 637 | } |
632 | } | 638 | } |
633 | else | 639 | else |