llavatarjoint.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /**
  2. * @file llavatarjoint.h
  3. * @brief Implementation of LLAvatarJoint 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. #ifndef LL_LLAVATARJOINT_H
  33. #define LL_LLAVATARJOINT_H
  34. #include <vector>
  35. #include "lljoint.h"
  36. #include "llpreprocessor.h"
  37. class LLAvatarJointMesh;
  38. class LLFace;
  39. constexpr F32 DEFAULT_AVATAR_JOINT_LOD = 0.f;
  40. // Sets the OpenGL selection stack name that is pushed and popped with this
  41. // joint state. The default value indicates that no name should be pushed or
  42. // popped.
  43. enum LLJointPickName
  44. {
  45. PN_DEFAULT = -1,
  46. PN_0 = 0,
  47. PN_1 = 1,
  48. PN_2 = 2,
  49. PN_3 = 3,
  50. PN_4 = 4,
  51. PN_5 = 5
  52. };
  53. typedef std::vector<LLAvatarJointMesh*> avatar_joint_mesh_list_t;
  54. class LLAvatarJoint : public LLJoint
  55. {
  56. public:
  57. LLAvatarJoint();
  58. // *TODO: Only used for LLVOAvatarSelf::mScreenp.
  59. // *DOES NOT INITIALIZE mResetAfterRestoreOldXform*
  60. LLAvatarJoint(const std::string& name, LLJoint* parent = NULL);
  61. LL_INLINE LLAvatarJoint* asAvatarJoint() override { return this; }
  62. // Gets the validity of this joint
  63. LL_INLINE bool getValid() { return mValid; }
  64. // Sets the validity of this joint
  65. virtual void setValid(bool valid, bool recursive = false);
  66. // Returns true if this object is transparent.
  67. // This is used to determine in which order to draw objects.
  68. LL_INLINE virtual bool isTransparent() { return mIsTransparent; }
  69. // Returns true if this object should inherit scale modifiers from its
  70. // immediate parent
  71. LL_INLINE virtual bool inheritScale() { return false; }
  72. enum Components
  73. {
  74. SC_BONE = 1,
  75. SC_JOINT = 2,
  76. SC_AXES = 4
  77. };
  78. // Selects which skeleton components to draw
  79. void setSkeletonComponents(U32 comp, bool recursive = true);
  80. // Returns which skeleton components are enables for drawing
  81. LL_INLINE U32 getSkeletonComponents() { return mComponents; }
  82. // Sets the level of detail for this node as a minimum pixel area
  83. // threshold. If the current pixel area for this object is less than the
  84. // specified threshold, the node is not traversed. In addition, if a value
  85. // is specified (not default of 0.0), and the pixel area is larger than the
  86. // specified minimum, the node is rendered, but no other siblings of this
  87. // node under the same parent will be.
  88. LL_INLINE F32 getLOD() { return mMinPixelArea; }
  89. LL_INLINE void setLOD(F32 pixelArea) { mMinPixelArea = pixelArea; }
  90. LL_INLINE void setPickName(LLJointPickName name) { mPickName = name; }
  91. LL_INLINE LLJointPickName getPickName() { return mPickName; }
  92. void setVisible(bool visible, bool recursive);
  93. // Takes meshes in mMeshParts and sets each one as a child joint
  94. void setMeshesToChildren();
  95. // LLViewerJoint interface
  96. virtual U32 render(F32 pixelArea, bool first_pass = true,
  97. bool is_dummy = false) = 0;
  98. virtual void updateFaceSizes(U32& num_vertices, U32& num_indices,
  99. F32 pixel_area);
  100. virtual void updateFaceData(LLFace* face, F32 pixel_area,
  101. bool damp_wind = false,
  102. bool terse_update = false);
  103. virtual bool updateLOD(F32 pixel_area, bool activate);
  104. virtual void updateJointGeometry();
  105. virtual void dump();
  106. LL_INLINE void setMeshID(S32 id) { mMeshID = id; }
  107. protected:
  108. void init();
  109. public:
  110. avatar_joint_mesh_list_t mMeshParts; // LLViewerJointMesh*
  111. static bool sDisableLOD;
  112. protected:
  113. S32 mMeshID;
  114. U32 mComponents;
  115. F32 mMinPixelArea;
  116. LLJointPickName mPickName;
  117. bool mValid;
  118. bool mIsTransparent;
  119. bool mVisible;
  120. };
  121. class LLAvatarJointCollisionVolume : public LLAvatarJoint
  122. {
  123. public:
  124. LLAvatarJointCollisionVolume();
  125. LL_INLINE bool inheritScale() override { return true; }
  126. U32 render(F32 pixelArea, bool first_pass = true,
  127. bool is_dummy = false) override;
  128. void renderCollision();
  129. LLVector3 getVolumePos(const LLVector3& offset);
  130. };
  131. #endif // LL_LLAVATARJOINT_H