aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldrawpoolavatar.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/lldrawpoolavatar.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-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/lldrawpoolavatar.cpp')
-rw-r--r--linden/indra/newview/lldrawpoolavatar.cpp368
1 files changed, 281 insertions, 87 deletions
diff --git a/linden/indra/newview/lldrawpoolavatar.cpp b/linden/indra/newview/lldrawpoolavatar.cpp
index 7ab6428..80c7d73 100644
--- a/linden/indra/newview/lldrawpoolavatar.cpp
+++ b/linden/indra/newview/lldrawpoolavatar.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,
@@ -47,12 +48,19 @@
47#include "pipeline.h" 48#include "pipeline.h"
48#include "llviewershadermgr.h" 49#include "llviewershadermgr.h"
49#include "llappviewer.h" 50#include "llappviewer.h"
51#include "llrendersphere.h"
52#include "llviewerpartsim.h"
50 53
51static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK; 54static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK;
52static U32 sBufferUsage = GL_STREAM_DRAW_ARB; 55static U32 sBufferUsage = GL_STREAM_DRAW_ARB;
53static U32 sShaderLevel = 0; 56static U32 sShaderLevel = 0;
54static LLGLSLShader* sVertexProgram = NULL; 57static LLGLSLShader* sVertexProgram = NULL;
55 58
59BOOL LLDrawPoolAvatar::sSkipOpaque = FALSE;
60BOOL LLDrawPoolAvatar::sSkipTransparent = FALSE;
61
62extern BOOL gUseGLPick;
63
56F32 CLOTHING_GRAVITY_EFFECT = 0.7f; 64F32 CLOTHING_GRAVITY_EFFECT = 0.7f;
57F32 CLOTHING_ACCEL_FORCE_FACTOR = 0.2f; 65F32 CLOTHING_ACCEL_FORCE_FACTOR = 0.2f;
58const S32 NUM_TEST_AVATARS = 30; 66const S32 NUM_TEST_AVATARS = 30;
@@ -84,6 +92,8 @@ S32 AVATAR_VERTEX_BYTES = 48;
84 92
85BOOL gAvatarEmbossBumpMap = FALSE; 93BOOL gAvatarEmbossBumpMap = FALSE;
86static BOOL sRenderingSkinned = FALSE; 94static BOOL sRenderingSkinned = FALSE;
95S32 normal_channel = -1;
96S32 specular_channel = -1;
87 97
88LLDrawPoolAvatar::LLDrawPoolAvatar() : 98LLDrawPoolAvatar::LLDrawPoolAvatar() :
89LLFacePool(POOL_AVATAR) 99LLFacePool(POOL_AVATAR)
@@ -110,6 +120,7 @@ S32 LLDrawPoolAvatar::getVertexShaderLevel() const
110void LLDrawPoolAvatar::prerender() 120void LLDrawPoolAvatar::prerender()
111{ 121{
112 mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR); 122 mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR);
123
113 sShaderLevel = mVertexShaderLevel; 124 sShaderLevel = mVertexShaderLevel;
114 125
115 if (sShaderLevel > 0) 126 if (sShaderLevel > 0)
@@ -138,6 +149,177 @@ LLMatrix4& LLDrawPoolAvatar::getModelView()
138// render() 149// render()
139//----------------------------------------------------------------------------- 150//-----------------------------------------------------------------------------
140 151
152
153S32 LLDrawPoolAvatar::getNumDeferredPasses()
154{
155 return getNumPasses();
156}
157
158void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
159{
160 LLFastTimer t(LLFastTimer::FTM_RENDER_CHARACTERS);
161
162 if (LLPipeline::sImpostorRender)
163 {
164 beginDeferredSkinned();
165 return;
166 }
167
168 switch (pass)
169 {
170 case 0:
171 beginDeferredImpostor();
172 break;
173 case 1:
174 beginDeferredRigid();
175 break;
176 case 2:
177 beginDeferredSkinned();
178 break;
179 }
180}
181
182void LLDrawPoolAvatar::endDeferredPass(S32 pass)
183{
184 LLFastTimer t(LLFastTimer::FTM_RENDER_CHARACTERS);
185
186 if (LLPipeline::sImpostorRender)
187 {
188 endDeferredSkinned();
189 return;
190 }
191
192 switch (pass)
193 {
194 case 0:
195 endDeferredImpostor();
196 break;
197 case 1:
198 endDeferredRigid();
199 break;
200 case 2:
201 endDeferredSkinned();
202 break;
203 }
204}
205
206void LLDrawPoolAvatar::renderDeferred(S32 pass)
207{
208 render(pass);
209}
210
211S32 LLDrawPoolAvatar::getNumPostDeferredPasses()
212{
213 return 1;
214}
215
216void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass)
217{
218 sSkipOpaque = TRUE;
219 sShaderLevel = mVertexShaderLevel;
220 sVertexProgram = &gDeferredAvatarAlphaProgram;
221
222 sRenderingSkinned = TRUE;
223
224 gPipeline.bindDeferredShader(*sVertexProgram);
225
226 enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
227}
228
229void LLDrawPoolAvatar::endPostDeferredPass(S32 pass)
230{
231 // if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done
232 sRenderingSkinned = FALSE;
233 sSkipOpaque = FALSE;
234 disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
235
236 gPipeline.unbindDeferredShader(*sVertexProgram);
237
238 sShaderLevel = mVertexShaderLevel;
239}
240
241void LLDrawPoolAvatar::renderPostDeferred(S32 pass)
242{
243 render(2); //pass 2 = skinned
244}
245
246
247S32 LLDrawPoolAvatar::getNumShadowPasses()
248{
249 return 1;
250}
251
252void LLDrawPoolAvatar::beginShadowPass(S32 pass)
253{
254 LLFastTimer t(LLFastTimer::FTM_SHADOW_AVATAR);
255
256 sVertexProgram = &gDeferredAvatarShadowProgram;
257 if (sShaderLevel > 0)
258 {
259 gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
260 }
261 gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f);
262
263 glColor4f(1,1,1,1);
264
265 if ((sShaderLevel > 0)) // for hardware blending
266 {
267 sRenderingSkinned = TRUE;
268 sVertexProgram->bind();
269 enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
270 }
271
272}
273
274void LLDrawPoolAvatar::endShadowPass(S32 pass)
275{
276 LLFastTimer t(LLFastTimer::FTM_SHADOW_AVATAR);
277
278 if (sShaderLevel > 0)
279 {
280 sRenderingSkinned = FALSE;
281 sVertexProgram->unbind();
282 disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
283 }
284
285 gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
286}
287
288void LLDrawPoolAvatar::renderShadow(S32 pass)
289{
290 LLFastTimer t(LLFastTimer::FTM_SHADOW_AVATAR);
291 if (!gRenderAvatar)
292 {
293 return;
294 }
295
296 if (mDrawFace.empty())
297 {
298 return;
299 }
300
301 const LLFace *facep = mDrawFace[0];
302 if (!facep->getDrawable())
303 {
304 return;
305 }
306 LLVOAvatar *avatarp = (LLVOAvatar *)facep->getDrawable()->getVObj().get();
307
308 if (avatarp->isDead() || avatarp->mIsDummy || avatarp->mDrawable.isNull())
309 {
310 return;
311 }
312
313 BOOL impostor = avatarp->isImpostor();
314 if (impostor)
315 {
316 return;
317 }
318
319 avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
320
321}
322
141S32 LLDrawPoolAvatar::getNumPasses() 323S32 LLDrawPoolAvatar::getNumPasses()
142{ 324{
143 return LLPipeline::sImpostorRender ? 1 : 3; 325 return LLPipeline::sImpostorRender ? 1 : 3;
@@ -253,6 +435,46 @@ void LLDrawPoolAvatar::endRigid()
253 } 435 }
254} 436}
255 437
438void LLDrawPoolAvatar::beginDeferredImpostor()
439{
440 if (!LLPipeline::sReflectionRender)
441 {
442 LLVOAvatar::sRenderDistance = llclamp(LLVOAvatar::sRenderDistance, 16.f, 256.f);
443 LLVOAvatar::sNumVisibleAvatars = 0;
444 }
445
446 sVertexProgram = &gDeferredImpostorProgram;
447
448 normal_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL);
449 specular_channel = sVertexProgram->enableTexture(LLViewerShaderMgr::SPECULAR_MAP);
450
451 sVertexProgram->bind();
452}
453
454void LLDrawPoolAvatar::endDeferredImpostor()
455{
456 sShaderLevel = mVertexShaderLevel;
457 sVertexProgram->disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL);
458 sVertexProgram->disableTexture(LLViewerShaderMgr::SPECULAR_MAP);
459 sVertexProgram->unbind();
460 gGL.getTexUnit(0)->activate();
461}
462
463void LLDrawPoolAvatar::beginDeferredRigid()
464{
465 sVertexProgram = &gDeferredDiffuseProgram;
466
467 sVertexProgram->bind();
468}
469
470void LLDrawPoolAvatar::endDeferredRigid()
471{
472 sShaderLevel = mVertexShaderLevel;
473 sVertexProgram->unbind();
474 gGL.getTexUnit(0)->activate();
475}
476
477
256void LLDrawPoolAvatar::beginSkinned() 478void LLDrawPoolAvatar::beginSkinned()
257{ 479{
258 if (sShaderLevel > 0) 480 if (sShaderLevel > 0)
@@ -282,7 +504,7 @@ void LLDrawPoolAvatar::beginSkinned()
282 if (sShaderLevel > 0) // for hardware blending 504 if (sShaderLevel > 0) // for hardware blending
283 { 505 {
284 sRenderingSkinned = TRUE; 506 sRenderingSkinned = TRUE;
285 507
286 sVertexProgram->bind(); 508 sVertexProgram->bind();
287 if (sShaderLevel >= SHADER_LEVEL_CLOTH) 509 if (sShaderLevel >= SHADER_LEVEL_CLOTH)
288 { 510 {
@@ -343,6 +565,34 @@ void LLDrawPoolAvatar::endSkinned()
343 gGL.getTexUnit(0)->activate(); 565 gGL.getTexUnit(0)->activate();
344} 566}
345 567
568void LLDrawPoolAvatar::beginDeferredSkinned()
569{
570 sSkipTransparent = TRUE;
571 sShaderLevel = mVertexShaderLevel;
572 sVertexProgram = &gDeferredAvatarProgram;
573
574 sRenderingSkinned = TRUE;
575
576 sVertexProgram->bind();
577
578 enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
579
580 gGL.getTexUnit(0)->activate();
581}
582
583void LLDrawPoolAvatar::endDeferredSkinned()
584{
585 sSkipTransparent = FALSE;
586 // if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done
587 sRenderingSkinned = FALSE;
588 disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
589 sVertexProgram->unbind();
590
591 sShaderLevel = mVertexShaderLevel;
592
593 gGL.getTexUnit(0)->activate();
594}
595
346 596
347void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) 597void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
348{ 598{
@@ -392,27 +642,25 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
392 return; 642 return;
393 } 643 }
394 644
395 if (!single_avatar && !avatarp->isFullyLoaded()) 645 if (!single_avatar && !avatarp->isFullyLoaded() )
396 { 646 {
397 647 if (pass==1 && (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) || LLViewerPartSim::getMaxPartCount() <= 0))
398 /* // debug code to draw a cube in place of avatar
399 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
400 LLVector3 pos = avatarp->getPositionAgent();
401
402 gGL.color4f(1.0f, 0.0f, 0.0f, 0.8f);
403 gGL.begin(GL_LINES);
404 { 648 {
405 gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV); 649 // debug code to draw a sphere in place of avatar
406 gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV); 650 gGL.getTexUnit(0)->bind(LLViewerImage::sWhiteImagep.get());
407 gGL.vertex3fv((pos - LLVector3(0.f, 0.2f, 0.f)).mV); 651 gGL.setColorMask(true, true);
408 gGL.vertex3fv((pos + LLVector3(0.f, 0.2f, 0.f)).mV); 652 LLVector3 pos = avatarp->getPositionAgent();
409 gGL.vertex3fv((pos - LLVector3(0.f, 0.f, 0.2f)).mV); 653 gGL.color4f(1.0f, 1.0f, 1.0f, 0.7f);
410 gGL.vertex3fv((pos + LLVector3(0.f, 0.f, 0.2f)).mV); 654
655 gGL.pushMatrix();
656 gGL.translatef((F32)(pos.mV[VX]),
657 (F32)(pos.mV[VY]),
658 (F32)(pos.mV[VZ]));
659 gGL.scalef(0.15f, 0.15f, 0.3f);
660 gSphere.render();
661 gGL.popMatrix();
662 gGL.setColorMask(true, false);
411 } 663 }
412 gGL.end();
413 */
414
415
416 // don't render please 664 // don't render please
417 return; 665 return;
418 } 666 }
@@ -440,9 +688,20 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
440 688
441 if (impostor) 689 if (impostor)
442 { 690 {
691 if (LLPipeline::sRenderDeferred && avatarp->mImpostor.isComplete())
692 {
693 if (normal_channel > -1)
694 {
695 avatarp->mImpostor.bindTexture(2, normal_channel);
696 }
697 if (specular_channel > -1)
698 {
699 avatarp->mImpostor.bindTexture(1, specular_channel);
700 }
701 }
443 avatarp->renderImpostor(); 702 avatarp->renderImpostor();
444 } 703 }
445 else if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS)) 704 else if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS) && !LLPipeline::sRenderDeferred)
446 { 705 {
447 avatarp->renderFootShadows(); 706 avatarp->renderFootShadows();
448 } 707 }
@@ -493,67 +752,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
493 752
494 if( !single_avatar || (avatarp == single_avatar) ) 753 if( !single_avatar || (avatarp == single_avatar) )
495 { 754 {
496 if (LLVOAvatar::sShowCollisionVolumes)
497 {
498 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
499 avatarp->renderCollisionVolumes();
500 }
501
502 if (avatarp->mIsSelf && LLAgent::sDebugDisplayTarget)
503 {
504 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
505 LLVector3 pos = avatarp->getPositionAgent();
506
507 gGL.color4f(1.0f, 0.0f, 0.0f, 0.8f);
508 gGL.begin(LLRender::LINES);
509 {
510 gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV);
511 gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV);
512 gGL.vertex3fv((pos - LLVector3(0.f, 0.2f, 0.f)).mV);
513 gGL.vertex3fv((pos + LLVector3(0.f, 0.2f, 0.f)).mV);
514 gGL.vertex3fv((pos - LLVector3(0.f, 0.f, 0.2f)).mV);
515 gGL.vertex3fv((pos + LLVector3(0.f, 0.f, 0.2f)).mV);
516 }gGL.end();
517
518 pos = avatarp->mDrawable->getPositionAgent();
519 gGL.color4f(1.0f, 0.0f, 0.0f, 0.8f);
520 gGL.begin(LLRender::LINES);
521 {
522 gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV);
523 gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV);
524 gGL.vertex3fv((pos - LLVector3(0.f, 0.2f, 0.f)).mV);
525 gGL.vertex3fv((pos + LLVector3(0.f, 0.2f, 0.f)).mV);
526 gGL.vertex3fv((pos - LLVector3(0.f, 0.f, 0.2f)).mV);
527 gGL.vertex3fv((pos + LLVector3(0.f, 0.f, 0.2f)).mV);
528 }gGL.end();
529
530 pos = avatarp->mRoot.getWorldPosition();
531 gGL.color4f(1.0f, 1.0f, 1.0f, 0.8f);
532 gGL.begin(LLRender::LINES);
533 {
534 gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV);
535 gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV);
536 gGL.vertex3fv((pos - LLVector3(0.f, 0.2f, 0.f)).mV);
537 gGL.vertex3fv((pos + LLVector3(0.f, 0.2f, 0.f)).mV);
538 gGL.vertex3fv((pos - LLVector3(0.f, 0.f, 0.2f)).mV);
539 gGL.vertex3fv((pos + LLVector3(0.f, 0.f, 0.2f)).mV);
540 }gGL.end();
541
542 pos = avatarp->mPelvisp->getWorldPosition();
543 gGL.color4f(0.0f, 0.0f, 1.0f, 0.8f);
544 gGL.begin(LLRender::LINES);
545 {
546 gGL.vertex3fv((pos - LLVector3(0.2f, 0.f, 0.f)).mV);
547 gGL.vertex3fv((pos + LLVector3(0.2f, 0.f, 0.f)).mV);
548 gGL.vertex3fv((pos - LLVector3(0.f, 0.2f, 0.f)).mV);
549 gGL.vertex3fv((pos + LLVector3(0.f, 0.2f, 0.f)).mV);
550 gGL.vertex3fv((pos - LLVector3(0.f, 0.f, 0.2f)).mV);
551 gGL.vertex3fv((pos + LLVector3(0.f, 0.f, 0.2f)).mV);
552 }gGL.end();
553
554 color.setColor(1.0f, 1.0f, 1.0f, 1.0f);
555 }
556
557 avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); 755 avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
558 } 756 }
559} 757}
@@ -679,11 +877,7 @@ void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const
679 877
680 glVertexPointer(3,GL_FLOAT, mStride, (void*)(base + 0)); 878 glVertexPointer(3,GL_FLOAT, mStride, (void*)(base + 0));
681 glNormalPointer(GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_NORMAL])); 879 glNormalPointer(GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_NORMAL]));
682 880 glTexCoordPointer(2,GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_TEXCOORD0]));
683 glClientActiveTextureARB(GL_TEXTURE1_ARB);
684 glTexCoordPointer(2,GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_TEXCOORD2]));
685 glClientActiveTextureARB(GL_TEXTURE0_ARB);
686 glTexCoordPointer(2,GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_TEXCOORD]));
687 881
688 set_vertex_weights(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT])); 882 set_vertex_weights(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT]));
689 883