PageRenderTime 49ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llvoavatarself.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 387 lines | 174 code | 63 blank | 150 comment | 0 complexity | 0c191205a81d3a5b6c6284dc551f54e5 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llvoavatarself.h
  3. * @brief Declaration of LLVOAvatar class which is a derivation fo
  4. * LLViewerObject
  5. *
  6. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #ifndef LL_LLVOAVATARSELF_H
  28. #define LL_LLVOAVATARSELF_H
  29. #include "llviewertexture.h"
  30. #include "llvoavatar.h"
  31. struct LocalTextureData;
  32. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. // LLVOAvatarSelf
  34. //
  35. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. class LLVOAvatarSelf :
  37. public LLVOAvatar
  38. {
  39. /********************************************************************************
  40. ** **
  41. ** INITIALIZATION
  42. **/
  43. public:
  44. LLVOAvatarSelf(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
  45. virtual ~LLVOAvatarSelf();
  46. virtual void markDead();
  47. virtual void initInstance(); // Called after construction to initialize the class.
  48. void cleanup();
  49. protected:
  50. /*virtual*/ BOOL loadAvatar();
  51. BOOL loadAvatarSelf();
  52. BOOL buildSkeletonSelf(const LLVOAvatarSkeletonInfo *info);
  53. BOOL buildMenus();
  54. /*virtual*/ BOOL loadLayersets();
  55. /** Initialization
  56. ** **
  57. *******************************************************************************/
  58. /********************************************************************************
  59. ** **
  60. ** INHERITED
  61. **/
  62. //--------------------------------------------------------------------
  63. // LLViewerObject interface and related
  64. //--------------------------------------------------------------------
  65. public:
  66. /*virtual*/ void updateRegion(LLViewerRegion *regionp);
  67. /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
  68. //--------------------------------------------------------------------
  69. // LLCharacter interface and related
  70. //--------------------------------------------------------------------
  71. public:
  72. /*virtual*/ void stopMotionFromSource(const LLUUID& source_id);
  73. /*virtual*/ void requestStopMotion(LLMotion* motion);
  74. /*virtual*/ LLJoint* getJoint(const std::string &name);
  75. void resetJointPositions( void );
  76. /*virtual*/ BOOL setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake = FALSE );
  77. /*virtual*/ BOOL setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake = FALSE );
  78. /*virtual*/ BOOL setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake = FALSE );
  79. /*virtual*/ void updateVisualParams();
  80. /*virtual*/ void idleUpdateAppearanceAnimation();
  81. private:
  82. // helper function. Passed in param is assumed to be in avatar's parameter list.
  83. BOOL setParamWeight(LLViewerVisualParam *param, F32 weight, BOOL upload_bake = FALSE );
  84. /** Initialization
  85. ** **
  86. *******************************************************************************/
  87. /********************************************************************************
  88. ** **
  89. ** STATE
  90. **/
  91. public:
  92. /*virtual*/ bool isSelf() const { return true; }
  93. //--------------------------------------------------------------------
  94. // Updates
  95. //--------------------------------------------------------------------
  96. public:
  97. /*virtual*/ BOOL updateCharacter(LLAgent &agent);
  98. /*virtual*/ void idleUpdateTractorBeam();
  99. //--------------------------------------------------------------------
  100. // Loading state
  101. //--------------------------------------------------------------------
  102. public:
  103. /*virtual*/ BOOL getIsCloud();
  104. //--------------------------------------------------------------------
  105. // Region state
  106. //--------------------------------------------------------------------
  107. void resetRegionCrossingTimer() { mRegionCrossingTimer.reset(); }
  108. private:
  109. U64 mLastRegionHandle;
  110. LLFrameTimer mRegionCrossingTimer;
  111. S32 mRegionCrossingCount;
  112. /** State
  113. ** **
  114. *******************************************************************************/
  115. /********************************************************************************
  116. ** **
  117. ** RENDERING
  118. **/
  119. //--------------------------------------------------------------------
  120. // Render beam
  121. //--------------------------------------------------------------------
  122. protected:
  123. BOOL needsRenderBeam();
  124. private:
  125. LLPointer<LLHUDEffectSpiral> mBeam;
  126. LLFrameTimer mBeamTimer;
  127. //--------------------------------------------------------------------
  128. // LLVOAvatar Constants
  129. //--------------------------------------------------------------------
  130. public:
  131. /*virtual*/ LLViewerTexture::EBoostLevel getAvatarBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_SELF; }
  132. /*virtual*/ LLViewerTexture::EBoostLevel getAvatarBakedBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_BAKED_SELF; }
  133. /*virtual*/ S32 getTexImageSize() const { return LLVOAvatar::getTexImageSize()*4; }
  134. /** Rendering
  135. ** **
  136. *******************************************************************************/
  137. /********************************************************************************
  138. ** **
  139. ** TEXTURES
  140. **/
  141. //--------------------------------------------------------------------
  142. // Loading status
  143. //--------------------------------------------------------------------
  144. public:
  145. /*virtual*/ bool hasPendingBakedUploads() const;
  146. S32 getLocalDiscardLevel(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  147. bool areTexturesCurrent() const;
  148. BOOL isLocalTextureDataAvailable(const LLTexLayerSet* layerset) const;
  149. BOOL isLocalTextureDataFinal(const LLTexLayerSet* layerset) const;
  150. BOOL isBakedTextureFinal(const LLVOAvatarDefines::EBakedTextureIndex index) const;
  151. // If you want to check all textures of a given type, pass gAgentWearables.getWearableCount() for index
  152. /*virtual*/ BOOL isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  153. /*virtual*/ BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const;
  154. /*virtual*/ BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLWearable *wearable) const;
  155. //--------------------------------------------------------------------
  156. // Local Textures
  157. //--------------------------------------------------------------------
  158. public:
  159. BOOL getLocalTextureGL(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture** image_gl_pp, U32 index) const;
  160. LLViewerFetchedTexture* getLocalTextureGL(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  161. const LLUUID& getLocalTextureID(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
  162. void setLocalTextureTE(U8 te, LLViewerTexture* image, U32 index);
  163. /*virtual*/ void setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture* tex, BOOL baked_version_exits, U32 index);
  164. protected:
  165. /*virtual*/ void setBakedReady(LLVOAvatarDefines::ETextureIndex type, BOOL baked_version_exists, U32 index);
  166. void localTextureLoaded(BOOL succcess, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
  167. void getLocalTextureByteCount(S32* gl_byte_count) const;
  168. /*virtual*/ void addLocalTextureStats(LLVOAvatarDefines::ETextureIndex i, LLViewerFetchedTexture* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index);
  169. LLLocalTextureObject* getLocalTextureObject(LLVOAvatarDefines::ETextureIndex i, U32 index) const;
  170. private:
  171. static void onLocalTextureLoaded(BOOL succcess, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
  172. /*virtual*/ void setImage(const U8 te, LLViewerTexture *imagep, const U32 index);
  173. /*virtual*/ LLViewerTexture* getImage(const U8 te, const U32 index) const;
  174. //--------------------------------------------------------------------
  175. // Baked textures
  176. //--------------------------------------------------------------------
  177. public:
  178. LLVOAvatarDefines::ETextureIndex getBakedTE(const LLTexLayerSet* layerset ) const;
  179. void setNewBakedTexture(LLVOAvatarDefines::EBakedTextureIndex i, const LLUUID &uuid);
  180. void setNewBakedTexture(LLVOAvatarDefines::ETextureIndex i, const LLUUID& uuid);
  181. void setCachedBakedTexture(LLVOAvatarDefines::ETextureIndex i, const LLUUID& uuid);
  182. void forceBakeAllTextures(bool slam_for_debug = false);
  183. static void processRebakeAvatarTextures(LLMessageSystem* msg, void**);
  184. BOOL isUsingBakedTextures() const; // e.g. false if in appearance edit mode
  185. protected:
  186. /*virtual*/ void removeMissingBakedTextures();
  187. //--------------------------------------------------------------------
  188. // Layers
  189. //--------------------------------------------------------------------
  190. public:
  191. void requestLayerSetUploads();
  192. void requestLayerSetUpload(LLVOAvatarDefines::EBakedTextureIndex i);
  193. void requestLayerSetUpdate(LLVOAvatarDefines::ETextureIndex i);
  194. LLTexLayerSet* getLayerSet(LLVOAvatarDefines::ETextureIndex index) const;
  195. //--------------------------------------------------------------------
  196. // Composites
  197. //--------------------------------------------------------------------
  198. public:
  199. /* virtual */ void invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result);
  200. /* virtual */ void invalidateAll();
  201. /* virtual */ void setCompositeUpdatesEnabled(bool b); // only works for self
  202. /* virtual */ void setCompositeUpdatesEnabled(U32 index, bool b);
  203. /* virtual */ bool isCompositeUpdateEnabled(U32 index);
  204. void setupComposites();
  205. void updateComposites();
  206. const LLUUID& grabBakedTexture(LLVOAvatarDefines::EBakedTextureIndex baked_index) const;
  207. BOOL canGrabBakedTexture(LLVOAvatarDefines::EBakedTextureIndex baked_index) const;
  208. //--------------------------------------------------------------------
  209. // Scratch textures (used for compositing)
  210. //--------------------------------------------------------------------
  211. public:
  212. static void deleteScratchTextures();
  213. private:
  214. static S32 sScratchTexBytes;
  215. static LLMap< LLGLenum, LLGLuint*> sScratchTexNames;
  216. static LLMap< LLGLenum, F32*> sScratchTexLastBindTime;
  217. /** Textures
  218. ** **
  219. *******************************************************************************/
  220. /********************************************************************************
  221. ** **
  222. ** MESHES
  223. **/
  224. protected:
  225. /*virtual*/ void restoreMeshData();
  226. /** Meshes
  227. ** **
  228. *******************************************************************************/
  229. /********************************************************************************
  230. ** **
  231. ** WEARABLES
  232. **/
  233. public:
  234. /*virtual*/ BOOL isWearingWearableType(LLWearableType::EType type) const;
  235. void wearableUpdated(LLWearableType::EType type, BOOL upload_result);
  236. protected:
  237. U32 getNumWearables(LLVOAvatarDefines::ETextureIndex i) const;
  238. //--------------------------------------------------------------------
  239. // Attachments
  240. //--------------------------------------------------------------------
  241. public:
  242. void updateAttachmentVisibility(U32 camera_mode);
  243. BOOL isWearingAttachment(const LLUUID& inv_item_id) const;
  244. BOOL attachmentWasRequested(const LLUUID& inv_item_id) const;
  245. void addAttachmentRequest(const LLUUID& inv_item_id);
  246. void removeAttachmentRequest(const LLUUID& inv_item_id);
  247. LLViewerObject* getWornAttachment(const LLUUID& inv_item_id);
  248. const std::string getAttachedPointName(const LLUUID& inv_item_id) const;
  249. /*virtual*/ const LLViewerJointAttachment *attachObject(LLViewerObject *viewer_object);
  250. /*virtual*/ BOOL detachObject(LLViewerObject *viewer_object);
  251. static BOOL detachAttachmentIntoInventory(const LLUUID& item_id);
  252. private:
  253. // Track attachments that have been requested but have not arrived yet.
  254. mutable std::map<LLUUID,LLTimer> mAttachmentRequests;
  255. //--------------------------------------------------------------------
  256. // HUDs
  257. //--------------------------------------------------------------------
  258. private:
  259. LLViewerJoint* mScreenp; // special purpose joint for HUD attachments
  260. /** Attachments
  261. ** **
  262. *******************************************************************************/
  263. /********************************************************************************
  264. ** **
  265. ** APPEARANCE
  266. **/
  267. public:
  268. static void onCustomizeStart();
  269. static void onCustomizeEnd();
  270. //--------------------------------------------------------------------
  271. // Visibility
  272. //--------------------------------------------------------------------
  273. public:
  274. bool sendAppearanceMessage(LLMessageSystem *mesgsys) const;
  275. /** Appearance
  276. ** **
  277. *******************************************************************************/
  278. /********************************************************************************
  279. ** **
  280. ** DIAGNOSTICS
  281. **/
  282. //--------------------------------------------------------------------
  283. // General
  284. //--------------------------------------------------------------------
  285. public:
  286. static void dumpTotalLocalTextureByteCount();
  287. void dumpLocalTextures() const;
  288. static void dumpScratchTextureByteCount();
  289. //--------------------------------------------------------------------
  290. // Avatar Rez Metrics
  291. //--------------------------------------------------------------------
  292. public:
  293. struct LLAvatarTexData
  294. {
  295. LLAvatarTexData(const LLUUID& id, LLVOAvatarDefines::ETextureIndex index) :
  296. mAvatarID(id),
  297. mIndex(index)
  298. {}
  299. LLUUID mAvatarID;
  300. LLVOAvatarDefines::ETextureIndex mIndex;
  301. };
  302. void debugWearablesLoaded() { mDebugTimeWearablesLoaded = mDebugSelfLoadTimer.getElapsedTimeF32(); }
  303. void debugAvatarVisible() { mDebugTimeAvatarVisible = mDebugSelfLoadTimer.getElapsedTimeF32(); }
  304. void outputRezDiagnostics() const;
  305. void debugBakedTextureUpload(LLVOAvatarDefines::EBakedTextureIndex index, BOOL finished);
  306. static void debugOnTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
  307. BOOL isAllLocalTextureDataFinal() const;
  308. const LLTexLayerSet* debugGetLayerSet(LLVOAvatarDefines::EBakedTextureIndex index) const { return mBakedTextureDatas[index].mTexLayerSet; }
  309. const std::string debugDumpLocalTextureDataInfo(const LLTexLayerSet* layerset) const; // Lists out state of this particular baked texture layer
  310. const std::string debugDumpAllLocalTextureDataInfo() const; // Lists out which baked textures are at highest LOD
  311. private:
  312. LLFrameTimer mDebugSelfLoadTimer;
  313. F32 mDebugTimeWearablesLoaded;
  314. F32 mDebugTimeAvatarVisible;
  315. F32 mDebugTextureLoadTimes[LLVOAvatarDefines::TEX_NUM_INDICES][MAX_DISCARD_LEVEL+1]; // load time for each texture at each discard level
  316. F32 mDebugBakedTextureTimes[LLVOAvatarDefines::BAKED_NUM_INDICES][2]; // time to start upload and finish upload of each baked texture
  317. void debugTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
  318. /** Diagnostics
  319. ** **
  320. *******************************************************************************/
  321. };
  322. extern LLVOAvatarSelf *gAgentAvatarp;
  323. BOOL isAgentAvatarValid();
  324. #endif // LL_VO_AVATARSELF_H