llviewerjoint.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /**
  2. * @file llviewerjoint.cpp
  3. * @brief Implementation of LLViewerJoint class
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  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
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llviewerjoint.h"
  34. #include "llgl.h"
  35. #include "llrender.h"
  36. #include "llpipeline.h"
  37. #include "llvoavatar.h"
  38. constexpr S32 MIN_PIXEL_AREA_3PASS_HAIR = 64 * 64;
  39. LLViewerJoint::LLViewerJoint()
  40. : LLAvatarJoint()
  41. {
  42. }
  43. LLViewerJoint::LLViewerJoint(const std::string& name, LLJoint* parentp)
  44. : LLAvatarJoint(name, parentp)
  45. {
  46. }
  47. U32 LLViewerJoint::render(F32 pixel_area, bool first_pass, bool is_dummy)
  48. {
  49. U32 triangle_count = 0;
  50. // Ignore invisible objects
  51. if (mValid)
  52. {
  53. // If object is transparent, defer it, otherwise give the joint
  54. // subclass a chance to draw itself
  55. if (is_dummy)
  56. {
  57. triangle_count += drawShape(first_pass, true);
  58. }
  59. else if (LLPipeline::sShadowRender)
  60. {
  61. triangle_count += drawShape(first_pass, is_dummy);
  62. }
  63. else if (isTransparent() && !LLPipeline::sReflectionRender)
  64. {
  65. // Hair and Skirt
  66. if (pixel_area > MIN_PIXEL_AREA_3PASS_HAIR)
  67. {
  68. // Render all three passes
  69. LLGLDisable cull(GL_CULL_FACE);
  70. // First pass renders without writing to the z buffer
  71. {
  72. LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
  73. triangle_count += drawShape(first_pass, is_dummy);
  74. }
  75. // Second pass writes to z buffer only
  76. gGL.setColorMask(false, false);
  77. {
  78. triangle_count += drawShape(false, is_dummy);
  79. }
  80. // Third past respects z buffer and writes color
  81. gGL.setColorMask(true, false);
  82. {
  83. LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
  84. triangle_count += drawShape(false, is_dummy);
  85. }
  86. }
  87. else
  88. {
  89. // Render Inside (no Z buffer write)
  90. glCullFace(GL_FRONT);
  91. {
  92. LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
  93. triangle_count += drawShape(first_pass, is_dummy);
  94. }
  95. // Render Outside (write to the Z buffer)
  96. glCullFace(GL_BACK);
  97. {
  98. triangle_count += drawShape(false, is_dummy);
  99. }
  100. }
  101. }
  102. else
  103. {
  104. // Set up render state
  105. triangle_count += drawShape(first_pass);
  106. }
  107. }
  108. // Render children
  109. for (S32 i = 0, count = mChildren.size(); i < count; ++i)
  110. {
  111. LLJoint* jointp = mChildren[i];
  112. if (!jointp) continue; // Paranoia
  113. LLAvatarJoint* avjointp = jointp->asAvatarJoint();
  114. if (!avjointp) continue;
  115. F32 joint_lod = avjointp->getLOD();
  116. if (pixel_area >= joint_lod || sDisableLOD)
  117. {
  118. triangle_count += avjointp->render(pixel_area, true, is_dummy);
  119. if (joint_lod != DEFAULT_AVATAR_JOINT_LOD)
  120. {
  121. break;
  122. }
  123. }
  124. }
  125. stop_glerror();
  126. return triangle_count;
  127. }