PageRenderTime 38ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llvoavatar.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 1103 lines | 678 code | 132 blank | 293 comment | 2 complexity | 7ae31b1830d0d5dbfad005df628f7938 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llvoavatar.h
  3. * @brief Declaration of LLVOAvatar class which is a derivation of
  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_LLVOAVATAR_H
  28. #define LL_LLVOAVATAR_H
  29. #include <map>
  30. #include <deque>
  31. #include <string>
  32. #include <vector>
  33. #include <boost/signals2.hpp>
  34. #include "imageids.h" // IMG_INVISIBLE
  35. #include "llchat.h"
  36. #include "lldrawpoolalpha.h"
  37. #include "llviewerobject.h"
  38. #include "llcharacter.h"
  39. #include "llcontrol.h"
  40. #include "llviewerjointmesh.h"
  41. #include "llviewerjointattachment.h"
  42. #include "llrendertarget.h"
  43. #include "llvoavatardefines.h"
  44. #include "lltexglobalcolor.h"
  45. #include "lldriverparam.h"
  46. #include "material_codes.h" // LL_MCODE_END
  47. extern const LLUUID ANIM_AGENT_BODY_NOISE;
  48. extern const LLUUID ANIM_AGENT_BREATHE_ROT;
  49. extern const LLUUID ANIM_AGENT_PHYSICS_MOTION;
  50. extern const LLUUID ANIM_AGENT_EDITING;
  51. extern const LLUUID ANIM_AGENT_EYE;
  52. extern const LLUUID ANIM_AGENT_FLY_ADJUST;
  53. extern const LLUUID ANIM_AGENT_HAND_MOTION;
  54. extern const LLUUID ANIM_AGENT_HEAD_ROT;
  55. extern const LLUUID ANIM_AGENT_PELVIS_FIX;
  56. extern const LLUUID ANIM_AGENT_TARGET;
  57. extern const LLUUID ANIM_AGENT_WALK_ADJUST;
  58. class LLTexLayerSet;
  59. class LLVoiceVisualizer;
  60. class LLHUDNameTag;
  61. class LLHUDEffectSpiral;
  62. class LLTexGlobalColor;
  63. class LLVOAvatarBoneInfo;
  64. class LLVOAvatarSkeletonInfo;
  65. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. // LLVOAvatar
  67. //
  68. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69. class LLVOAvatar :
  70. public LLViewerObject,
  71. public LLCharacter,
  72. public boost::signals2::trackable
  73. {
  74. public:
  75. friend class LLVOAvatarSelf;
  76. protected:
  77. struct LLVOAvatarXmlInfo;
  78. struct LLMaskedMorph;
  79. /********************************************************************************
  80. ** **
  81. ** INITIALIZATION
  82. **/
  83. public:
  84. LLVOAvatar(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
  85. virtual void markDead();
  86. static void initClass(); // Initialize data that's only init'd once per class.
  87. static void cleanupClass(); // Cleanup data that's only init'd once per class.
  88. virtual void initInstance(); // Called after construction to initialize the class.
  89. protected:
  90. virtual ~LLVOAvatar();
  91. BOOL loadSkeletonNode();
  92. BOOL loadMeshNodes();
  93. virtual BOOL loadLayersets();
  94. /** Initialization
  95. ** **
  96. *******************************************************************************/
  97. /********************************************************************************
  98. ** **
  99. ** INHERITED
  100. **/
  101. //--------------------------------------------------------------------
  102. // LLViewerObject interface and related
  103. //--------------------------------------------------------------------
  104. public:
  105. virtual void updateGL();
  106. virtual LLVOAvatar* asAvatar();
  107. virtual U32 processUpdateMessage(LLMessageSystem *mesgsys,
  108. void **user_data,
  109. U32 block_num,
  110. const EObjectUpdateType update_type,
  111. LLDataPacker *dp);
  112. virtual BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
  113. virtual BOOL updateLOD();
  114. BOOL updateJointLODs();
  115. void updateLODRiggedAttachments( void );
  116. virtual BOOL isActive() const; // Whether this object needs to do an idleUpdate.
  117. virtual void updateTextures();
  118. virtual S32 setTETexture(const U8 te, const LLUUID& uuid); // If setting a baked texture, need to request it from a non-local sim.
  119. virtual void onShift(const LLVector4a& shift_vector);
  120. virtual U32 getPartitionType() const;
  121. virtual const LLVector3 getRenderPosition() const;
  122. virtual void updateDrawable(BOOL force_damped);
  123. virtual LLDrawable* createDrawable(LLPipeline *pipeline);
  124. virtual BOOL updateGeometry(LLDrawable *drawable);
  125. virtual void setPixelAreaAndAngle(LLAgent &agent);
  126. virtual void updateRegion(LLViewerRegion *regionp);
  127. virtual void updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax);
  128. virtual void getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax);
  129. virtual BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
  130. S32 face = -1, // which face to check, -1 = ALL_SIDES
  131. BOOL pick_transparent = FALSE,
  132. S32* face_hit = NULL, // which face was hit
  133. LLVector3* intersection = NULL, // return the intersection point
  134. LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
  135. LLVector3* normal = NULL, // return the surface normal at the intersection point
  136. LLVector3* bi_normal = NULL); // return the surface bi-normal at the intersection point
  137. LLViewerObject* lineSegmentIntersectRiggedAttachments(const LLVector3& start, const LLVector3& end,
  138. S32 face = -1, // which face to check, -1 = ALL_SIDES
  139. BOOL pick_transparent = FALSE,
  140. S32* face_hit = NULL, // which face was hit
  141. LLVector3* intersection = NULL, // return the intersection point
  142. LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
  143. LLVector3* normal = NULL, // return the surface normal at the intersection point
  144. LLVector3* bi_normal = NULL); // return the surface bi-normal at the intersection point
  145. //--------------------------------------------------------------------
  146. // LLCharacter interface and related
  147. //--------------------------------------------------------------------
  148. public:
  149. virtual LLVector3 getCharacterPosition();
  150. virtual LLQuaternion getCharacterRotation();
  151. virtual LLVector3 getCharacterVelocity();
  152. virtual LLVector3 getCharacterAngularVelocity();
  153. virtual LLJoint* getCharacterJoint(U32 num);
  154. virtual BOOL allocateCharacterJoints(U32 num);
  155. virtual LLUUID remapMotionID(const LLUUID& id);
  156. virtual BOOL startMotion(const LLUUID& id, F32 time_offset = 0.f);
  157. virtual BOOL stopMotion(const LLUUID& id, BOOL stop_immediate = FALSE);
  158. virtual void stopMotionFromSource(const LLUUID& source_id);
  159. virtual void requestStopMotion(LLMotion* motion);
  160. LLMotion* findMotion(const LLUUID& id) const;
  161. void startDefaultMotions();
  162. void dumpAnimationState();
  163. virtual LLJoint* getJoint(const std::string &name);
  164. virtual LLJoint* getRootJoint() { return &mRoot; }
  165. void resetJointPositions( void );
  166. void resetJointPositionsToDefault( void );
  167. void resetSpecificJointPosition( const std::string& name );
  168. virtual const char* getAnimationPrefix() { return "avatar"; }
  169. virtual const LLUUID& getID();
  170. virtual LLVector3 getVolumePos(S32 joint_index, LLVector3& volume_offset);
  171. virtual LLJoint* findCollisionVolume(U32 volume_id);
  172. virtual S32 getCollisionVolumeID(std::string &name);
  173. virtual void addDebugText(const std::string& text);
  174. virtual F32 getTimeDilation();
  175. virtual void getGround(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
  176. virtual F32 getPixelArea() const;
  177. virtual LLPolyMesh* getHeadMesh();
  178. virtual LLPolyMesh* getUpperBodyMesh();
  179. virtual LLVector3d getPosGlobalFromAgent(const LLVector3 &position);
  180. virtual LLVector3 getPosAgentFromGlobal(const LLVector3d &position);
  181. virtual void updateVisualParams();
  182. /** Inherited
  183. ** **
  184. *******************************************************************************/
  185. /********************************************************************************
  186. ** **
  187. ** STATE
  188. **/
  189. public:
  190. virtual bool isSelf() const { return false; } // True if this avatar is for this viewer's agent
  191. bool isBuilt() const { return mIsBuilt; }
  192. private: //aligned members
  193. LLVector4a mImpostorExtents[2];
  194. private:
  195. BOOL mSupportsAlphaLayers; // For backwards compatibility, TRUE for 1.23+ clients
  196. //--------------------------------------------------------------------
  197. // Updates
  198. //--------------------------------------------------------------------
  199. public:
  200. virtual BOOL updateCharacter(LLAgent &agent);
  201. void idleUpdateVoiceVisualizer(bool voice_enabled);
  202. void idleUpdateMisc(bool detailed_update);
  203. virtual void idleUpdateAppearanceAnimation();
  204. void idleUpdateLipSync(bool voice_enabled);
  205. void idleUpdateLoadingEffect();
  206. void idleUpdateWindEffect();
  207. void idleUpdateNameTag(const LLVector3& root_pos_last);
  208. void idleUpdateNameTagText(BOOL new_name);
  209. LLVector3 idleUpdateNameTagPosition(const LLVector3& root_pos_last);
  210. void idleUpdateNameTagAlpha(BOOL new_name, F32 alpha);
  211. LLColor4 getNameTagColor(bool is_friend);
  212. void clearNameTag();
  213. static void invalidateNameTag(const LLUUID& agent_id);
  214. // force all name tags to rebuild, useful when display names turned on/off
  215. static void invalidateNameTags();
  216. void addNameTagLine(const std::string& line, const LLColor4& color, S32 style, const LLFontGL* font);
  217. void idleUpdateRenderCost();
  218. void idleUpdateBelowWater();
  219. //--------------------------------------------------------------------
  220. // Static preferences (controlled by user settings/menus)
  221. //--------------------------------------------------------------------
  222. public:
  223. static S32 sRenderName;
  224. static BOOL sRenderGroupTitles;
  225. static U32 sMaxVisible; //(affected by control "RenderAvatarMaxVisible")
  226. static F32 sRenderDistance; //distance at which avatars will render.
  227. static BOOL sShowAnimationDebug; // show animation debug info
  228. static BOOL sUseImpostors; //use impostors for far away avatars
  229. static BOOL sShowFootPlane; // show foot collision plane reported by server
  230. static BOOL sShowCollisionVolumes; // show skeletal collision volumes
  231. static BOOL sVisibleInFirstPerson;
  232. static S32 sNumLODChangesThisFrame;
  233. static S32 sNumVisibleChatBubbles;
  234. static BOOL sDebugInvisible;
  235. static BOOL sShowAttachmentPoints;
  236. static F32 sLODFactor; // user-settable LOD factor
  237. static F32 sPhysicsLODFactor; // user-settable physics LOD factor
  238. static BOOL sJointDebug; // output total number of joints being touched for each avatar
  239. static BOOL sDebugAvatarRotation;
  240. //--------------------------------------------------------------------
  241. // Region state
  242. //--------------------------------------------------------------------
  243. public:
  244. LLHost getObjectHost() const;
  245. //--------------------------------------------------------------------
  246. // Loading state
  247. //--------------------------------------------------------------------
  248. public:
  249. BOOL isFullyLoaded() const;
  250. bool isTooComplex() const;
  251. bool visualParamWeightsAreDefault();
  252. protected:
  253. virtual BOOL getIsCloud();
  254. BOOL updateIsFullyLoaded();
  255. BOOL processFullyLoadedChange(bool loading);
  256. void updateRuthTimer(bool loading);
  257. F32 calcMorphAmount();
  258. private:
  259. BOOL mFullyLoaded;
  260. BOOL mPreviousFullyLoaded;
  261. BOOL mFullyLoadedInitialized;
  262. S32 mFullyLoadedFrameCounter;
  263. S32 mVisualComplexity;
  264. LLFrameTimer mFullyLoadedTimer;
  265. LLFrameTimer mRuthTimer;
  266. protected:
  267. LLFrameTimer mInvisibleTimer;
  268. /** State
  269. ** **
  270. *******************************************************************************/
  271. /********************************************************************************
  272. ** **
  273. ** SKELETON
  274. **/
  275. public:
  276. void updateHeadOffset();
  277. F32 getPelvisToFoot() const { return mPelvisToFoot; }
  278. void setPelvisOffset( bool hasOffset, const LLVector3& translation, F32 offset ) ;
  279. bool hasPelvisOffset( void ) { return mHasPelvisOffset; }
  280. void postPelvisSetRecalc( void );
  281. void setPelvisOffset( F32 pelvixFixupAmount );
  282. bool mHasPelvisOffset;
  283. LLVector3 mPelvisOffset;
  284. F32 mLastPelvisToFoot;
  285. F32 mPelvisFixup;
  286. F32 mLastPelvisFixup;
  287. LLVector3 mHeadOffset; // current head position
  288. LLViewerJoint mRoot;
  289. protected:
  290. static BOOL parseSkeletonFile(const std::string& filename);
  291. void buildCharacter();
  292. virtual BOOL loadAvatar();
  293. BOOL setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent, S32 &current_volume_num, S32 &current_joint_num);
  294. BOOL buildSkeleton(const LLVOAvatarSkeletonInfo *info);
  295. private:
  296. BOOL mIsBuilt; // state of deferred character building
  297. S32 mNumJoints;
  298. LLViewerJoint* mSkeleton;
  299. //--------------------------------------------------------------------
  300. // Pelvis height adjustment members.
  301. //--------------------------------------------------------------------
  302. public:
  303. LLVector3 mBodySize;
  304. S32 mLastSkeletonSerialNum;
  305. private:
  306. F32 mPelvisToFoot;
  307. //--------------------------------------------------------------------
  308. // Cached pointers to well known joints
  309. //--------------------------------------------------------------------
  310. public:
  311. LLViewerJoint* mPelvisp;
  312. LLViewerJoint* mTorsop;
  313. LLViewerJoint* mChestp;
  314. LLViewerJoint* mNeckp;
  315. LLViewerJoint* mHeadp;
  316. LLViewerJoint* mSkullp;
  317. LLViewerJoint* mEyeLeftp;
  318. LLViewerJoint* mEyeRightp;
  319. LLViewerJoint* mHipLeftp;
  320. LLViewerJoint* mHipRightp;
  321. LLViewerJoint* mKneeLeftp;
  322. LLViewerJoint* mKneeRightp;
  323. LLViewerJoint* mAnkleLeftp;
  324. LLViewerJoint* mAnkleRightp;
  325. LLViewerJoint* mFootLeftp;
  326. LLViewerJoint* mFootRightp;
  327. LLViewerJoint* mWristLeftp;
  328. LLViewerJoint* mWristRightp;
  329. //--------------------------------------------------------------------
  330. // XML parse tree
  331. //--------------------------------------------------------------------
  332. private:
  333. static LLXmlTree sXMLTree; // avatar config file
  334. static LLXmlTree sSkeletonXMLTree; // avatar skeleton file
  335. /** Skeleton
  336. ** **
  337. *******************************************************************************/
  338. /********************************************************************************
  339. ** **
  340. ** RENDERING
  341. **/
  342. public:
  343. U32 renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0);
  344. U32 renderRigid();
  345. U32 renderSkinned(EAvatarRenderPass pass);
  346. F32 getLastSkinTime() { return mLastSkinTime; }
  347. U32 renderSkinnedAttachments();
  348. U32 renderTransparent(BOOL first_pass);
  349. void renderCollisionVolumes();
  350. static void deleteCachedImages(bool clearAll=true);
  351. static void destroyGL();
  352. static void restoreGL();
  353. BOOL mIsDummy; // for special views
  354. S32 mSpecialRenderMode; // special lighting
  355. private:
  356. bool shouldAlphaMask();
  357. BOOL mNeedsSkin; // avatar has been animated and verts have not been updated
  358. F32 mLastSkinTime; //value of gFrameTimeSeconds at last skin update
  359. S32 mUpdatePeriod;
  360. S32 mNumInitFaces; //number of faces generated when creating the avatar drawable, does not inculde splitted faces due to long vertex buffer.
  361. //--------------------------------------------------------------------
  362. // Morph masks
  363. //--------------------------------------------------------------------
  364. public:
  365. BOOL morphMaskNeedsUpdate(LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES);
  366. void addMaskedMorph(LLVOAvatarDefines::EBakedTextureIndex index, LLPolyMorphTarget* morph_target, BOOL invert, std::string layer);
  367. void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES);
  368. //--------------------------------------------------------------------
  369. // Visibility
  370. //--------------------------------------------------------------------
  371. protected:
  372. void updateVisibility();
  373. private:
  374. U32 mVisibilityRank;
  375. BOOL mVisible;
  376. //--------------------------------------------------------------------
  377. // Shadowing
  378. //--------------------------------------------------------------------
  379. public:
  380. void updateShadowFaces();
  381. LLDrawable* mShadow;
  382. private:
  383. LLFace* mShadow0Facep;
  384. LLFace* mShadow1Facep;
  385. LLPointer<LLViewerTexture> mShadowImagep;
  386. //--------------------------------------------------------------------
  387. // Impostors
  388. //--------------------------------------------------------------------
  389. public:
  390. BOOL isImpostor() const;
  391. BOOL needsImpostorUpdate() const;
  392. const LLVector3& getImpostorOffset() const;
  393. const LLVector2& getImpostorDim() const;
  394. void getImpostorValues(LLVector4a* extents, LLVector3& angle, F32& distance) const;
  395. void cacheImpostorValues();
  396. void setImpostorDim(const LLVector2& dim);
  397. static void resetImpostors();
  398. static void updateImpostors();
  399. LLRenderTarget mImpostor;
  400. BOOL mNeedsImpostorUpdate;
  401. private:
  402. LLVector3 mImpostorOffset;
  403. LLVector2 mImpostorDim;
  404. BOOL mNeedsAnimUpdate;
  405. LLVector3 mImpostorAngle;
  406. F32 mImpostorDistance;
  407. F32 mImpostorPixelArea;
  408. LLVector3 mLastAnimExtents[2];
  409. LLCachedControl<bool> mRenderUnloadedAvatar;
  410. //--------------------------------------------------------------------
  411. // Wind rippling in clothes
  412. //--------------------------------------------------------------------
  413. public:
  414. LLVector4 mWindVec;
  415. F32 mRipplePhase;
  416. BOOL mBelowWater;
  417. private:
  418. F32 mWindFreq;
  419. LLFrameTimer mRippleTimer;
  420. F32 mRippleTimeLast;
  421. LLVector3 mRippleAccel;
  422. LLVector3 mLastVel;
  423. //--------------------------------------------------------------------
  424. // Culling
  425. //--------------------------------------------------------------------
  426. public:
  427. static void cullAvatarsByPixelArea();
  428. BOOL isCulled() const { return mCulled; }
  429. private:
  430. BOOL mCulled;
  431. //--------------------------------------------------------------------
  432. // Freeze counter
  433. //--------------------------------------------------------------------
  434. public:
  435. static void updateFreezeCounter(S32 counter = 0);
  436. private:
  437. static S32 sFreezeCounter;
  438. //--------------------------------------------------------------------
  439. // Constants
  440. //--------------------------------------------------------------------
  441. public:
  442. virtual LLViewerTexture::EBoostLevel getAvatarBoostLevel() const { return LLViewerTexture::BOOST_AVATAR; }
  443. virtual LLViewerTexture::EBoostLevel getAvatarBakedBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_BAKED; }
  444. virtual S32 getTexImageSize() const;
  445. virtual S32 getTexImageArea() const { return getTexImageSize()*getTexImageSize(); }
  446. /** Rendering
  447. ** **
  448. *******************************************************************************/
  449. /********************************************************************************
  450. ** **
  451. ** TEXTURES
  452. **/
  453. //--------------------------------------------------------------------
  454. // Loading status
  455. //--------------------------------------------------------------------
  456. public:
  457. virtual BOOL isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const;
  458. virtual BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const;
  459. virtual BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLWearable *wearable) const;
  460. protected:
  461. BOOL isFullyBaked();
  462. static BOOL areAllNearbyInstancesBaked(S32& grey_avatars);
  463. //--------------------------------------------------------------------
  464. // Baked textures
  465. //--------------------------------------------------------------------
  466. public:
  467. void releaseComponentTextures(); // ! BACKWARDS COMPATIBILITY !
  468. protected:
  469. static void onBakedTextureMasksLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
  470. static void onInitialBakedTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
  471. static void onBakedTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
  472. virtual void removeMissingBakedTextures();
  473. void useBakedTexture(const LLUUID& id);
  474. typedef std::deque<LLMaskedMorph *> morph_list_t;
  475. struct BakedTextureData
  476. {
  477. LLUUID mLastTextureIndex;
  478. LLTexLayerSet* mTexLayerSet; // Only exists for self
  479. bool mIsLoaded;
  480. bool mIsUsed;
  481. LLVOAvatarDefines::ETextureIndex mTextureIndex;
  482. U32 mMaskTexName;
  483. // Stores pointers to the joint meshes that this baked texture deals with
  484. std::vector< LLViewerJointMesh * > mMeshes; // std::vector<LLViewerJointMesh> mJoints[i]->mMeshParts
  485. morph_list_t mMaskedMorphs;
  486. };
  487. typedef std::vector<BakedTextureData> bakedtexturedata_vec_t;
  488. bakedtexturedata_vec_t mBakedTextureDatas;
  489. LLLoadedCallbackEntry::source_callback_list_t mCallbackTextureList ;
  490. BOOL mLoadedCallbacksPaused;
  491. //--------------------------------------------------------------------
  492. // Local Textures
  493. //--------------------------------------------------------------------
  494. protected:
  495. virtual void setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture* tex, BOOL baked_version_exits, U32 index = 0);
  496. virtual void addLocalTextureStats(LLVOAvatarDefines::ETextureIndex type, LLViewerFetchedTexture* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index = 0);
  497. // MULTI-WEARABLE: make self-only?
  498. virtual void setBakedReady(LLVOAvatarDefines::ETextureIndex type, BOOL baked_version_exists, U32 index = 0);
  499. //--------------------------------------------------------------------
  500. // Texture accessors
  501. //--------------------------------------------------------------------
  502. private:
  503. virtual void setImage(const U8 te, LLViewerTexture *imagep, const U32 index);
  504. virtual LLViewerTexture* getImage(const U8 te, const U32 index) const;
  505. virtual const LLTextureEntry* getTexEntry(const U8 te_num) const;
  506. virtual void setTexEntry(const U8 index, const LLTextureEntry &te);
  507. void checkTextureLoading() ;
  508. //--------------------------------------------------------------------
  509. // Layers
  510. //--------------------------------------------------------------------
  511. protected:
  512. void deleteLayerSetCaches(bool clearAll = true);
  513. void addBakedTextureStats(LLViewerFetchedTexture* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level);
  514. //--------------------------------------------------------------------
  515. // Composites
  516. //--------------------------------------------------------------------
  517. public:
  518. virtual void invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result);
  519. virtual void invalidateAll();
  520. virtual void setCompositeUpdatesEnabled(bool b) {}
  521. virtual void setCompositeUpdatesEnabled(U32 index, bool b) {}
  522. virtual bool isCompositeUpdateEnabled(U32 index) { return false; }
  523. //--------------------------------------------------------------------
  524. // Static texture/mesh/baked dictionary
  525. //--------------------------------------------------------------------
  526. public:
  527. static BOOL isIndexLocalTexture(LLVOAvatarDefines::ETextureIndex i);
  528. static BOOL isIndexBakedTexture(LLVOAvatarDefines::ETextureIndex i);
  529. private:
  530. static const LLVOAvatarDefines::LLVOAvatarDictionary *getDictionary() { return sAvatarDictionary; }
  531. static LLVOAvatarDefines::LLVOAvatarDictionary* sAvatarDictionary;
  532. static LLVOAvatarSkeletonInfo* sAvatarSkeletonInfo;
  533. static LLVOAvatarXmlInfo* sAvatarXmlInfo;
  534. //--------------------------------------------------------------------
  535. // Messaging
  536. //--------------------------------------------------------------------
  537. public:
  538. void onFirstTEMessageReceived();
  539. private:
  540. BOOL mFirstTEMessageReceived;
  541. BOOL mFirstAppearanceMessageReceived;
  542. /** Textures
  543. ** **
  544. *******************************************************************************/
  545. /********************************************************************************
  546. ** **
  547. ** MESHES
  548. **/
  549. public:
  550. void updateMeshTextures();
  551. void updateSexDependentLayerSets(BOOL upload_bake);
  552. void dirtyMesh(); // Dirty the avatar mesh
  553. void updateMeshData();
  554. protected:
  555. void releaseMeshData();
  556. virtual void restoreMeshData();
  557. private:
  558. void dirtyMesh(S32 priority); // Dirty the avatar mesh, with priority
  559. S32 mDirtyMesh; // 0 -- not dirty, 1 -- morphed, 2 -- LOD
  560. BOOL mMeshTexturesDirty;
  561. typedef std::multimap<std::string, LLPolyMesh*> polymesh_map_t;
  562. polymesh_map_t mMeshes;
  563. std::vector<LLViewerJoint *> mMeshLOD;
  564. //--------------------------------------------------------------------
  565. // Destroy invisible mesh
  566. //--------------------------------------------------------------------
  567. protected:
  568. BOOL mMeshValid;
  569. LLFrameTimer mMeshInvisibleTime;
  570. /** Meshes
  571. ** **
  572. *******************************************************************************/
  573. /********************************************************************************
  574. ** **
  575. ** APPEARANCE
  576. **/
  577. public:
  578. void processAvatarAppearance(LLMessageSystem* mesgsys);
  579. void hideSkirt();
  580. void startAppearanceAnimation();
  581. //--------------------------------------------------------------------
  582. // Appearance morphing
  583. //--------------------------------------------------------------------
  584. public:
  585. BOOL getIsAppearanceAnimating() const { return mAppearanceAnimating; }
  586. private:
  587. BOOL mAppearanceAnimating;
  588. LLFrameTimer mAppearanceMorphTimer;
  589. F32 mLastAppearanceBlendTime;
  590. //--------------------------------------------------------------------
  591. // Clothing colors (convenience functions to access visual parameters)
  592. //--------------------------------------------------------------------
  593. public:
  594. void setClothesColor(LLVOAvatarDefines::ETextureIndex te, const LLColor4& new_color, BOOL upload_bake);
  595. LLColor4 getClothesColor(LLVOAvatarDefines::ETextureIndex te);
  596. static BOOL teToColorParams(LLVOAvatarDefines::ETextureIndex te, U32 *param_name);
  597. //--------------------------------------------------------------------
  598. // Global colors
  599. //--------------------------------------------------------------------
  600. public:
  601. LLColor4 getGlobalColor(const std::string& color_name ) const;
  602. void onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL upload_bake);
  603. private:
  604. LLTexGlobalColor* mTexSkinColor;
  605. LLTexGlobalColor* mTexHairColor;
  606. LLTexGlobalColor* mTexEyeColor;
  607. //--------------------------------------------------------------------
  608. // Visibility
  609. //--------------------------------------------------------------------
  610. public:
  611. BOOL isVisible() const;
  612. void setVisibilityRank(U32 rank);
  613. U32 getVisibilityRank() const { return mVisibilityRank; } // unused
  614. static S32 sNumVisibleAvatars; // Number of instances of this class
  615. static LLColor4 getDummyColor();
  616. /** Appearance
  617. ** **
  618. *******************************************************************************/
  619. /********************************************************************************
  620. ** **
  621. ** WEARABLES
  622. **/
  623. public:
  624. virtual BOOL isWearingWearableType(LLWearableType::EType type ) const;
  625. //--------------------------------------------------------------------
  626. // Attachments
  627. //--------------------------------------------------------------------
  628. public:
  629. void clampAttachmentPositions();
  630. virtual const LLViewerJointAttachment* attachObject(LLViewerObject *viewer_object);
  631. virtual BOOL detachObject(LLViewerObject *viewer_object);
  632. void cleanupAttachedMesh( LLViewerObject* pVO );
  633. static LLVOAvatar* findAvatarFromAttachment(LLViewerObject* obj);
  634. protected:
  635. LLViewerJointAttachment* getTargetAttachmentPoint(LLViewerObject* viewer_object);
  636. void lazyAttach();
  637. void rebuildRiggedAttachments( void );
  638. //--------------------------------------------------------------------
  639. // Map of attachment points, by ID
  640. //--------------------------------------------------------------------
  641. public:
  642. S32 getAttachmentCount(); // Warning: order(N) not order(1) // currently used only by -self
  643. typedef std::map<S32, LLViewerJointAttachment*> attachment_map_t;
  644. attachment_map_t mAttachmentPoints;
  645. std::vector<LLPointer<LLViewerObject> > mPendingAttachment;
  646. //--------------------------------------------------------------------
  647. // HUD functions
  648. //--------------------------------------------------------------------
  649. public:
  650. BOOL hasHUDAttachment() const;
  651. LLBBox getHUDBBox() const;
  652. void rebuildHUD();
  653. void resetHUDAttachments();
  654. BOOL canAttachMoreObjects() const;
  655. BOOL canAttachMoreObjects(U32 n) const;
  656. protected:
  657. U32 getNumAttachments() const; // O(N), not O(1)
  658. /** Wearables
  659. ** **
  660. *******************************************************************************/
  661. /********************************************************************************
  662. ** **
  663. ** ACTIONS
  664. **/
  665. //--------------------------------------------------------------------
  666. // Animations
  667. //--------------------------------------------------------------------
  668. public:
  669. BOOL isAnyAnimationSignaled(const LLUUID *anim_array, const S32 num_anims) const;
  670. void processAnimationStateChanges();
  671. protected:
  672. BOOL processSingleAnimationStateChange(const LLUUID &anim_id, BOOL start);
  673. void resetAnimations();
  674. private:
  675. LLTimer mAnimTimer;
  676. F32 mTimeLast;
  677. //--------------------------------------------------------------------
  678. // Animation state data
  679. //--------------------------------------------------------------------
  680. public:
  681. typedef std::map<LLUUID, S32>::iterator AnimIterator;
  682. std::map<LLUUID, S32> mSignaledAnimations; // requested state of Animation name/value
  683. std::map<LLUUID, S32> mPlayingAnimations; // current state of Animation name/value
  684. typedef std::multimap<LLUUID, LLUUID> AnimationSourceMap;
  685. typedef AnimationSourceMap::iterator AnimSourceIterator;
  686. AnimationSourceMap mAnimationSources; // object ids that triggered anim ids
  687. //--------------------------------------------------------------------
  688. // Chat
  689. //--------------------------------------------------------------------
  690. public:
  691. void addChat(const LLChat& chat);
  692. void clearChat();
  693. void startTyping() { mTyping = TRUE; mTypingTimer.reset(); }
  694. void stopTyping() { mTyping = FALSE; }
  695. private:
  696. BOOL mVisibleChat;
  697. //--------------------------------------------------------------------
  698. // Lip synch morphs
  699. //--------------------------------------------------------------------
  700. private:
  701. bool mLipSyncActive; // we're morphing for lip sync
  702. LLVisualParam* mOohMorph; // cached pointers morphs for lip sync
  703. LLVisualParam* mAahMorph; // cached pointers morphs for lip sync
  704. //--------------------------------------------------------------------
  705. // Flight
  706. //--------------------------------------------------------------------
  707. public:
  708. BOOL mInAir;
  709. LLFrameTimer mTimeInAir;
  710. /** Actions
  711. ** **
  712. *******************************************************************************/
  713. /********************************************************************************
  714. ** **
  715. ** PHYSICS
  716. **/
  717. private:
  718. F32 mSpeedAccum; // measures speed (for diagnostics mostly).
  719. BOOL mTurning; // controls hysteresis on avatar rotation
  720. F32 mSpeed; // misc. animation repeated state
  721. //--------------------------------------------------------------------
  722. // Collision volumes
  723. //--------------------------------------------------------------------
  724. public:
  725. S32 mNumCollisionVolumes;
  726. LLViewerJointCollisionVolume* mCollisionVolumes;
  727. protected:
  728. BOOL allocateCollisionVolumes(U32 num);
  729. //--------------------------------------------------------------------
  730. // Dimensions
  731. //--------------------------------------------------------------------
  732. public:
  733. void resolveHeightGlobal(const LLVector3d &inPos, LLVector3d &outPos, LLVector3 &outNorm);
  734. bool distanceToGround( const LLVector3d &startPoint, LLVector3d &collisionPoint, F32 distToIntersectionAlongRay );
  735. void resolveHeightAgent(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
  736. void resolveRayCollisionAgent(const LLVector3d start_pt, const LLVector3d end_pt, LLVector3d &out_pos, LLVector3 &out_norm);
  737. void slamPosition(); // Slam position to transmitted position (for teleport);
  738. protected:
  739. void computeBodySize();
  740. //--------------------------------------------------------------------
  741. // Material being stepped on
  742. //--------------------------------------------------------------------
  743. private:
  744. BOOL mStepOnLand;
  745. U8 mStepMaterial;
  746. LLVector3 mStepObjectVelocity;
  747. /** Physics
  748. ** **
  749. *******************************************************************************/
  750. /********************************************************************************
  751. ** **
  752. ** HIERARCHY
  753. **/
  754. public:
  755. virtual BOOL setParent(LLViewerObject* parent);
  756. virtual void addChild(LLViewerObject *childp);
  757. virtual void removeChild(LLViewerObject *childp);
  758. //--------------------------------------------------------------------
  759. // Sitting
  760. //--------------------------------------------------------------------
  761. public:
  762. void sitDown(BOOL bSitting);
  763. BOOL isSitting(){return mIsSitting;}
  764. void sitOnObject(LLViewerObject *sit_object);
  765. void getOffObject();
  766. private:
  767. // set this property only with LLVOAvatar::sitDown method
  768. BOOL mIsSitting;
  769. /** Hierarchy
  770. ** **
  771. *******************************************************************************/
  772. /********************************************************************************
  773. ** **
  774. ** NAME
  775. **/
  776. public:
  777. std::string getFullname() const; // Returns "FirstName LastName"
  778. protected:
  779. static void getAnimLabels(LLDynamicArray<std::string>* labels);
  780. static void getAnimNames(LLDynamicArray<std::string>* names);
  781. private:
  782. std::string mNameString; // UTF-8 title + name + status
  783. std::string mTitle;
  784. bool mNameAway;
  785. bool mNameBusy;
  786. bool mNameMute;
  787. bool mNameAppearance;
  788. bool mNameFriend;
  789. bool mNameCloud;
  790. F32 mNameAlpha;
  791. BOOL mRenderGroupTitles;
  792. //--------------------------------------------------------------------
  793. // Display the name (then optionally fade it out)
  794. //--------------------------------------------------------------------
  795. public:
  796. LLFrameTimer mChatTimer;
  797. LLPointer<LLHUDNameTag> mNameText;
  798. private:
  799. LLFrameTimer mTimeVisible;
  800. std::deque<LLChat> mChats;
  801. BOOL mTyping;
  802. LLFrameTimer mTypingTimer;
  803. /** Name
  804. ** **
  805. *******************************************************************************/
  806. /********************************************************************************
  807. ** **
  808. ** SOUNDS
  809. **/
  810. //--------------------------------------------------------------------
  811. // Voice visualizer
  812. //--------------------------------------------------------------------
  813. public:
  814. // Responsible for detecting the user's voice signal (and when the
  815. // user speaks, it puts a voice symbol over the avatar's head) and gesticulations
  816. LLPointer<LLVoiceVisualizer> mVoiceVisualizer;
  817. int mCurrentGesticulationLevel;
  818. //--------------------------------------------------------------------
  819. // Step sound
  820. //--------------------------------------------------------------------
  821. protected:
  822. const LLUUID& getStepSound() const;
  823. private:
  824. // Global table of sound ids per material, and the ground
  825. const static LLUUID sStepSounds[LL_MCODE_END];
  826. const static LLUUID sStepSoundOnLand;
  827. //--------------------------------------------------------------------
  828. // Foot step state (for generating sounds)
  829. //--------------------------------------------------------------------
  830. public:
  831. void setFootPlane(const LLVector4 &plane) { mFootPlane = plane; }
  832. LLVector4 mFootPlane;
  833. private:
  834. BOOL mWasOnGroundLeft;
  835. BOOL mWasOnGroundRight;
  836. /** Sounds
  837. ** **
  838. *******************************************************************************/
  839. /********************************************************************************
  840. ** **
  841. ** DIAGNOSTICS
  842. **/
  843. //--------------------------------------------------------------------
  844. // General
  845. //--------------------------------------------------------------------
  846. public:
  847. static void dumpArchetypeXML(void*);
  848. static void dumpBakedStatus();
  849. const std::string getBakedStatusForPrintout() const;
  850. void dumpAvatarTEs(const std::string& context) const;
  851. static F32 sUnbakedTime; // Total seconds with >=1 unbaked avatars
  852. static F32 sUnbakedUpdateTime; // Last time stats were updated (to prevent multiple updates per frame)
  853. static F32 sGreyTime; // Total seconds with >=1 grey avatars
  854. static F32 sGreyUpdateTime; // Last time stats were updated (to prevent multiple updates per frame)
  855. protected:
  856. S32 getUnbakedPixelAreaRank();
  857. BOOL mHasGrey;
  858. private:
  859. F32 mMinPixelArea;
  860. F32 mMaxPixelArea;
  861. F32 mAdjustedPixelArea;
  862. std::string mDebugText;
  863. //--------------------------------------------------------------------
  864. // Avatar Rez Metrics
  865. //--------------------------------------------------------------------
  866. public:
  867. F32 debugGetExistenceTimeElapsedF32() const { return mDebugExistenceTimer.getElapsedTimeF32(); }
  868. protected:
  869. LLFrameTimer mRuthDebugTimer; // For tracking how long it takes for av to rez
  870. LLFrameTimer mDebugExistenceTimer; // Debugging for how long the avatar has been in memory.
  871. /** Diagnostics
  872. ** **
  873. *******************************************************************************/
  874. /********************************************************************************
  875. ** **
  876. ** SUPPORT CLASSES
  877. **/
  878. protected: // Shared with LLVOAvatarSelf
  879. struct LLVOAvatarXmlInfo
  880. {
  881. LLVOAvatarXmlInfo();
  882. ~LLVOAvatarXmlInfo();
  883. BOOL parseXmlSkeletonNode(LLXmlTreeNode* root);
  884. BOOL parseXmlMeshNodes(LLXmlTreeNode* root);
  885. BOOL parseXmlColorNodes(LLXmlTreeNode* root);
  886. BOOL parseXmlLayerNodes(LLXmlTreeNode* root);
  887. BOOL parseXmlDriverNodes(LLXmlTreeNode* root);
  888. BOOL parseXmlMorphNodes(LLXmlTreeNode* root);
  889. struct LLVOAvatarMeshInfo
  890. {
  891. typedef std::pair<LLPolyMorphTargetInfo*,BOOL> morph_info_pair_t;
  892. typedef std::vector<morph_info_pair_t> morph_info_list_t;
  893. LLVOAvatarMeshInfo() : mLOD(0), mMinPixelArea(.1f) {}
  894. ~LLVOAvatarMeshInfo()
  895. {
  896. morph_info_list_t::iterator iter;
  897. for (iter = mPolyMorphTargetInfoList.begin(); iter != mPolyMorphTargetInfoList.end(); iter++)
  898. {
  899. delete iter->first;
  900. }
  901. mPolyMorphTargetInfoList.clear();
  902. }
  903. std::string mType;
  904. S32 mLOD;
  905. std::string mMeshFileName;
  906. std::string mReferenceMeshName;
  907. F32 mMinPixelArea;
  908. morph_info_list_t mPolyMorphTargetInfoList;
  909. };
  910. typedef std::vector<LLVOAvatarMeshInfo*> mesh_info_list_t;
  911. mesh_info_list_t mMeshInfoList;
  912. typedef std::vector<LLPolySkeletalDistortionInfo*> skeletal_distortion_info_list_t;
  913. skeletal_distortion_info_list_t mSkeletalDistortionInfoList;
  914. struct LLVOAvatarAttachmentInfo
  915. {
  916. LLVOAvatarAttachmentInfo()
  917. : mGroup(-1), mAttachmentID(-1), mPieMenuSlice(-1), mVisibleFirstPerson(FALSE),
  918. mIsHUDAttachment(FALSE), mHasPosition(FALSE), mHasRotation(FALSE) {}
  919. std::string mName;
  920. std::string mJointName;
  921. LLVector3 mPosition;
  922. LLVector3 mRotationEuler;
  923. S32 mGroup;
  924. S32 mAttachmentID;
  925. S32 mPieMenuSlice;
  926. BOOL mVisibleFirstPerson;
  927. BOOL mIsHUDAttachment;
  928. BOOL mHasPosition;
  929. BOOL mHasRotation;
  930. };
  931. typedef std::vector<LLVOAvatarAttachmentInfo*> attachment_info_list_t;
  932. attachment_info_list_t mAttachmentInfoList;
  933. LLTexGlobalColorInfo *mTexSkinColorInfo;
  934. LLTexGlobalColorInfo *mTexHairColorInfo;
  935. LLTexGlobalColorInfo *mTexEyeColorInfo;
  936. typedef std::vector<LLTexLayerSetInfo*> layer_info_list_t;
  937. layer_info_list_t mLayerInfoList;
  938. typedef std::vector<LLDriverParamInfo*> driver_info_list_t;
  939. driver_info_list_t mDriverInfoList;
  940. struct LLVOAvatarMorphInfo
  941. {
  942. LLVOAvatarMorphInfo()
  943. : mInvert(FALSE) {}
  944. std::string mName;
  945. std::string mRegion;
  946. std::string mLayer;
  947. BOOL mInvert;
  948. };
  949. typedef std::vector<LLVOAvatarMorphInfo*> morph_info_list_t;
  950. morph_info_list_t mMorphMaskInfoList;
  951. };
  952. struct LLMaskedMorph
  953. {
  954. LLMaskedMorph(LLPolyMorphTarget *morph_target, BOOL invert, std::string layer) :
  955. mMorphTarget(morph_target),
  956. mInvert(invert),
  957. mLayer(layer)
  958. {
  959. morph_target->addPendingMorphMask();
  960. }
  961. LLPolyMorphTarget *mMorphTarget;
  962. BOOL mInvert;
  963. std::string mLayer;
  964. };
  965. /** Support classes
  966. ** **
  967. *******************************************************************************/
  968. }; // LLVOAvatar
  969. extern const F32 SELF_ADDITIONAL_PRI;
  970. extern const S32 MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL;
  971. #endif // LL_VO_AVATAR_H