diff options
Diffstat (limited to 'indra/newview/llvoavatar.h')
-rw-r--r-- | indra/newview/llvoavatar.h | 206 |
1 files changed, 119 insertions, 87 deletions
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 301c032b25..d51b8701af 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -1,33 +1,27 @@ /** * @file llvoavatar.h - * @brief Declaration of LLVOAvatar class which is a derivation fo + * @brief Declaration of LLVOAvatar class which is a derivation of * LLViewerObject * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -39,6 +33,7 @@ #include <string> #include <vector> +#include "imageids.h" // IMG_INVISIBLE #include "llchat.h" #include "lldrawpoolalpha.h" #include "llviewerobject.h" @@ -49,6 +44,7 @@ #include "llvoavatardefines.h" #include "lltexglobalcolor.h" #include "lldriverparam.h" +#include "material_codes.h" // LL_MCODE_END extern const LLUUID ANIM_AGENT_BODY_NOISE; extern const LLUUID ANIM_AGENT_BREATHE_ROT; @@ -69,9 +65,10 @@ class LLTexGlobalColor; class LLVOAvatarBoneInfo; class LLVOAvatarSkeletonInfo; -//------------------------------------------------------------------------ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLVOAvatar -//------------------------------------------------------------------------ +// +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLVOAvatar : public LLViewerObject, public LLCharacter @@ -92,7 +89,7 @@ public: virtual void markDead(); static void initClass(); // Initialize data that's only init'd once per class. static void cleanupClass(); // Cleanup data that's only init'd once per class. - void initInstance(); // Called after construction to initialize the class. + virtual void initInstance(); // Called after construction to initialize the class. protected: virtual ~LLVOAvatar(); BOOL loadSkeletonNode(); @@ -112,6 +109,8 @@ protected: // LLViewerObject interface and related //-------------------------------------------------------------------- public: + virtual void updateGL(); + virtual LLVOAvatar* asAvatar(); virtual U32 processUpdateMessage(LLMessageSystem *mesgsys, void **user_data, U32 block_num, @@ -121,7 +120,7 @@ public: virtual BOOL updateLOD(); BOOL updateJointLODs(); virtual BOOL isActive() const; // Whether this object needs to do an idleUpdate. - virtual void updateTextures(LLAgent &agent); + virtual void updateTextures(); virtual S32 setTETexture(const U8 te, const LLUUID& uuid); // If setting a baked texture, need to request it from a non-local sim. virtual void onShift(const LLVector3& shift_vector); virtual U32 getPartitionType() const; @@ -134,13 +133,13 @@ public: virtual void updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax); virtual void getSpatialExtents(LLVector3& newMin, LLVector3& newMax); virtual BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, - S32 face = -1, // which face to check, -1 = ALL_SIDES - BOOL pick_transparent = FALSE, - S32* face_hit = NULL, // which face was hit - LLVector3* intersection = NULL, // return the intersection point - LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point - LLVector3* normal = NULL, // return the surface normal at the intersection point - LLVector3* bi_normal = NULL); // return the surface bi-normal at the intersection point + S32 face = -1, // which face to check, -1 = ALL_SIDES + BOOL pick_transparent = FALSE, + S32* face_hit = NULL, // which face was hit + LLVector3* intersection = NULL, // return the intersection point + LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point + LLVector3* normal = NULL, // return the surface normal at the intersection point + LLVector3* bi_normal = NULL); // return the surface bi-normal at the intersection point //-------------------------------------------------------------------- // LLCharacter interface and related @@ -153,12 +152,14 @@ public: virtual LLJoint* getCharacterJoint(U32 num); virtual BOOL allocateCharacterJoints(U32 num); + virtual LLUUID remapMotionID(const LLUUID& id); virtual BOOL startMotion(const LLUUID& id, F32 time_offset = 0.f); virtual BOOL stopMotion(const LLUUID& id, BOOL stop_immediate = FALSE); virtual void stopMotionFromSource(const LLUUID& source_id); virtual void requestStopMotion(LLMotion* motion); LLMotion* findMotion(const LLUUID& id) const; void startDefaultMotions(); + void dumpAnimationState(); virtual LLJoint* getJoint(const std::string &name); virtual LLJoint* getRootJoint() { return &mRoot; } @@ -190,6 +191,7 @@ public: public: virtual bool isSelf() const { return false; } // True if this avatar is for this viewer's agent + bool isBuilt() const { return mIsBuilt; } private: BOOL mSupportsAlphaLayers; // For backwards compatibility, TRUE for 1.23+ clients @@ -200,13 +202,12 @@ public: virtual BOOL updateCharacter(LLAgent &agent); void idleUpdateVoiceVisualizer(bool voice_enabled); void idleUpdateMisc(bool detailed_update); - void idleUpdateAppearanceAnimation(); + virtual void idleUpdateAppearanceAnimation(); void idleUpdateLipSync(bool voice_enabled); void idleUpdateLoadingEffect(); void idleUpdateWindEffect(); void idleUpdateNameTag(const LLVector3& root_pos_last); void idleUpdateRenderCost(); - void idleUpdateTractorBeam(); void idleUpdateBelowWater(); //-------------------------------------------------------------------- @@ -215,8 +216,8 @@ public: public: static S32 sRenderName; static BOOL sRenderGroupTitles; - static S32 sMaxVisible; - static F32 sRenderDistance; //distance at which avatars will render (affected by control "RenderAvatarMaxVisible") + static U32 sMaxVisible; //(affected by control "RenderAvatarMaxVisible") + static F32 sRenderDistance; //distance at which avatars will render. static BOOL sShowAnimationDebug; // show animation debug info static BOOL sUseImpostors; //use impostors for far away avatars static BOOL sShowFootPlane; // show foot collision plane reported by server @@ -241,15 +242,23 @@ public: //-------------------------------------------------------------------- public: BOOL isFullyLoaded() const; - virtual BOOL updateIsFullyLoaded(); + bool visualParamWeightsAreDefault(); +protected: + virtual BOOL getIsCloud(); + BOOL updateIsFullyLoaded(); BOOL processFullyLoadedChange(bool loading); + void updateRuthTimer(bool loading); + F32 calcMorphAmount(); private: BOOL mFullyLoaded; BOOL mPreviousFullyLoaded; BOOL mFullyLoadedInitialized; S32 mFullyLoadedFrameCounter; LLFrameTimer mFullyLoadedTimer; - + LLFrameTimer mRuthTimer; +protected: + LLFrameTimer mInvisibleTimer; + /** State ** ** *******************************************************************************/ @@ -262,12 +271,14 @@ private: public: void updateHeadOffset(); F32 getPelvisToFoot() const { return mPelvisToFoot; } + LLVector3 mHeadOffset; // current head position LLViewerJoint mRoot; protected: static BOOL parseSkeletonFile(const std::string& filename); void buildCharacter(); - BOOL loadAvatar(); + virtual BOOL loadAvatar(); + BOOL setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent, S32 ¤t_volume_num, S32 ¤t_joint_num); BOOL buildSkeleton(const LLVOAvatarSkeletonInfo *info); private: @@ -324,8 +335,7 @@ private: **/ public: - U32 renderFootShadows(); - U32 renderImpostor(LLColor4U color = LLColor4U(255,255,255,255)); + U32 renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0); U32 renderRigid(); U32 renderSkinned(EAvatarRenderPass pass); U32 renderTransparent(BOOL first_pass); @@ -336,6 +346,8 @@ public: BOOL mIsDummy; // for special views S32 mSpecialRenderMode; // special lighting private: + bool shouldAlphaMask(); + BOOL mNeedsSkin; // avatar has been animated and verts have not been updated S32 mUpdatePeriod; S32 mNumInitFaces; //number of faces generated when creating the avatar drawable, does not inculde splitted faces due to long vertex buffer. @@ -344,10 +356,8 @@ private: // Morph masks //-------------------------------------------------------------------- public: - void invalidateMorphMasks(LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES); BOOL morphMaskNeedsUpdate(LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES); void addMaskedMorph(LLVOAvatarDefines::EBakedTextureIndex index, LLPolyMorphTarget* morph_target, BOOL invert, std::string layer); - void setMorphMasksValid(BOOL new_status, LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES); void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES); //-------------------------------------------------------------------- @@ -368,7 +378,7 @@ public: private: LLFace* mShadow0Facep; LLFace* mShadow1Facep; - LLPointer<LLViewerImage> mShadowImagep; + LLPointer<LLViewerTexture> mShadowImagep; //-------------------------------------------------------------------- // Impostors @@ -430,8 +440,8 @@ private: // Constants //-------------------------------------------------------------------- public: - virtual LLViewerImage::EBoostLevel getAvatarBoostLevel() const { return LLViewerImage::BOOST_AVATAR; } - virtual LLViewerImage::EBoostLevel getAvatarBakedBoostLevel() const { return LLViewerImage::BOOST_AVATAR_BAKED; } + virtual LLViewerTexture::EBoostLevel getAvatarBoostLevel() const { return LLViewerTexture::BOOST_AVATAR; } + virtual LLViewerTexture::EBoostLevel getAvatarBakedBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_BAKED; } virtual S32 getTexImageSize() const; virtual S32 getTexImageArea() const { return getTexImageSize()*getTexImageSize(); } @@ -448,8 +458,10 @@ public: // Loading status //-------------------------------------------------------------------- public: - virtual BOOL isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const; - BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex index) const; + virtual BOOL isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const; + virtual BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const; + virtual BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLWearable *wearable) const; + protected: BOOL isFullyBaked(); static BOOL areAllNearbyInstancesBaked(S32& grey_avatars); @@ -460,9 +472,9 @@ protected: public: void releaseComponentTextures(); // ! BACKWARDS COMPATIBILITY ! protected: - static void onBakedTextureMasksLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); - static void onInitialBakedTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); - static void onBakedTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); + static void onBakedTextureMasksLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); + static void onInitialBakedTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); + static void onBakedTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); virtual void removeMissingBakedTextures(); void useBakedTexture(const LLUUID& id); @@ -478,43 +490,47 @@ protected: // Stores pointers to the joint meshes that this baked texture deals with std::vector< LLViewerJointMesh * > mMeshes; // std::vector<LLViewerJointMesh> mJoints[i]->mMeshParts morph_list_t mMaskedMorphs; - BOOL mMorphMasksValid; }; typedef std::vector<BakedTextureData> bakedtexturedata_vec_t; bakedtexturedata_vec_t mBakedTextureDatas; - + LLLoadedCallbackEntry::source_callback_list_t mCallbackTextureList ; + BOOL mLoadedCallbacksPaused; //-------------------------------------------------------------------- // Local Textures //-------------------------------------------------------------------- protected: - virtual void setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerImage* tex, BOOL baked_version_exits, U32 index = 0); - virtual void addLocalTextureStats(LLVOAvatarDefines::ETextureIndex type, LLViewerImage* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index = 0); + virtual void setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture* tex, BOOL baked_version_exits, U32 index = 0); + virtual void addLocalTextureStats(LLVOAvatarDefines::ETextureIndex type, LLViewerFetchedTexture* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index = 0); + // MULTI-WEARABLE: make self-only? + virtual void setBakedReady(LLVOAvatarDefines::ETextureIndex type, BOOL baked_version_exists, U32 index = 0); //-------------------------------------------------------------------- // Texture accessors //-------------------------------------------------------------------- private: - virtual void setImage(const U8 te, LLViewerImage *imagep); - virtual LLViewerImage* getImage(const U8 te) const; + virtual void setImage(const U8 te, LLViewerTexture *imagep, const U32 index); + virtual LLViewerTexture* getImage(const U8 te, const U32 index) const; virtual const LLTextureEntry* getTexEntry(const U8 te_num) const; virtual void setTexEntry(const U8 index, const LLTextureEntry &te); - + void checkTextureLoading() ; //-------------------------------------------------------------------- // Layers //-------------------------------------------------------------------- protected: void deleteLayerSetCaches(bool clearAll = true); - void addBakedTextureStats(LLViewerImage* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level); + void addBakedTextureStats(LLViewerFetchedTexture* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level); //-------------------------------------------------------------------- // Composites //-------------------------------------------------------------------- public: - virtual void invalidateComposite(LLTexLayerSet* layerset, BOOL set_by_user); + virtual void invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result); virtual void invalidateAll(); - virtual void setCompositeUpdatesEnabled(BOOL b); + virtual void setCompositeUpdatesEnabled(bool b) {} + virtual void setCompositeUpdatesEnabled(U32 index, bool b) {} + virtual bool isCompositeUpdateEnabled(U32 index) { return false; } //-------------------------------------------------------------------- // Static texture/mesh/baked dictionary @@ -548,14 +564,16 @@ private: public: void updateMeshTextures(); - void updateSexDependentLayerSets(BOOL set_by_user); + void updateSexDependentLayerSets(BOOL upload_bake); void dirtyMesh(); // Dirty the avatar mesh void updateMeshData(); protected: void releaseMeshData(); - /*virtual*/ void restoreMeshData(); + virtual void restoreMeshData(); private: - BOOL mDirtyMesh; + void dirtyMesh(S32 priority); // Dirty the avatar mesh, with priority + S32 mDirtyMesh; // 0 -- not dirty, 1 -- morphed, 2 -- LOD + BOOL mMeshTexturesDirty; typedef std::multimap<std::string, LLPolyMesh*> polymesh_map_t; polymesh_map_t mMeshes; @@ -580,32 +598,32 @@ protected: public: void processAvatarAppearance(LLMessageSystem* mesgsys); void hideSkirt(); - void startAppearanceAnimation(BOOL set_by_user, BOOL play_sound); + void startAppearanceAnimation(); //-------------------------------------------------------------------- // Appearance morphing //-------------------------------------------------------------------- public: - BOOL mAppearanceAnimating; + BOOL getIsAppearanceAnimating() const { return mAppearanceAnimating; } private: + BOOL mAppearanceAnimating; LLFrameTimer mAppearanceMorphTimer; - BOOL mAppearanceAnimSetByUser; F32 mLastAppearanceBlendTime; //-------------------------------------------------------------------- // Clothing colors (convenience functions to access visual parameters) //-------------------------------------------------------------------- public: - void setClothesColor(LLVOAvatarDefines::ETextureIndex te, const LLColor4& new_color, BOOL set_by_user); + void setClothesColor(LLVOAvatarDefines::ETextureIndex te, const LLColor4& new_color, BOOL upload_bake); LLColor4 getClothesColor(LLVOAvatarDefines::ETextureIndex te); - BOOL teToColorParams(LLVOAvatarDefines::ETextureIndex te, const char* param_name[3]); + static BOOL teToColorParams(LLVOAvatarDefines::ETextureIndex te, U32 *param_name); //-------------------------------------------------------------------- // Global colors //-------------------------------------------------------------------- public: LLColor4 getGlobalColor(const std::string& color_name ) const; - void onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL set_by_user); + void onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL upload_bake); private: LLTexGlobalColor* mTexSkinColor; LLTexGlobalColor* mTexHairColor; @@ -630,15 +648,15 @@ public: **/ public: - BOOL isWearingWearableType(EWearableType type ) const; + virtual BOOL isWearingWearableType(LLWearableType::EType type ) const; //-------------------------------------------------------------------- // Attachments //-------------------------------------------------------------------- public: void clampAttachmentPositions(); - virtual LLViewerJointAttachment* attachObject(LLViewerObject *viewer_object); - BOOL detachObject(LLViewerObject *viewer_object); + virtual const LLViewerJointAttachment* attachObject(LLViewerObject *viewer_object); + virtual BOOL detachObject(LLViewerObject *viewer_object); static LLVOAvatar* findAvatarFromAttachment(LLViewerObject* obj); protected: LLViewerJointAttachment* getTargetAttachmentPoint(LLViewerObject* viewer_object); @@ -661,6 +679,10 @@ public: LLBBox getHUDBBox() const; void rebuildHUD(); void resetHUDAttachments(); + BOOL canAttachMoreObjects() const; + BOOL canAttachMoreObjects(U32 n) const; +protected: + U32 getNumAttachments() const; // O(N), not O(1) /** Wearables ** ** @@ -774,7 +796,7 @@ private: **/ public: - virtual void setParent(LLViewerObject* parent); + virtual BOOL setParent(LLViewerObject* parent); virtual void addChild(LLViewerObject *childp); virtual void removeChild(LLViewerObject *childp); @@ -782,8 +804,12 @@ public: // Sitting //-------------------------------------------------------------------- public: + void sitDown(BOOL bSitting); + BOOL isSitting(){return mIsSitting;} void sitOnObject(LLViewerObject *sit_object); void getOffObject(); +private: + // set this property only with LLVOAvatar::sitDown method BOOL mIsSitting; /** Hierarchy @@ -807,6 +833,7 @@ private: BOOL mNameBusy; BOOL mNameMute; BOOL mNameAppearance; + BOOL mNameCloud; BOOL mRenderGroupTitles; //-------------------------------------------------------------------- @@ -836,7 +863,7 @@ private: public: // Responsible for detecting the user's voice signal (and when the // user speaks, it puts a voice symbol over the avatar's head) and gesticulations - LLVoiceVisualizer* mVoiceVisualizer; + LLPointer<LLVoiceVisualizer> mVoiceVisualizer; int mCurrentGesticulationLevel; //-------------------------------------------------------------------- @@ -868,11 +895,14 @@ private: ** DIAGNOSTICS **/ + //-------------------------------------------------------------------- + // General + //-------------------------------------------------------------------- public: static void dumpArchetypeXML(void*); static void dumpBakedStatus(); const std::string getBakedStatusForPrintout() const; - void dumpAvatarTEs(const std::string& context); + void dumpAvatarTEs(const std::string& context) const; static F32 sUnbakedTime; // Total seconds with >=1 unbaked avatars static F32 sUnbakedUpdateTime; // Last time stats were updated (to prevent multiple updates per frame) @@ -887,6 +917,16 @@ private: F32 mAdjustedPixelArea; std::string mDebugText; + + //-------------------------------------------------------------------- + // Avatar Rez Metrics + //-------------------------------------------------------------------- +public: + F32 debugGetExistenceTimeElapsedF32() const { return mDebugExistenceTimer.getElapsedTimeF32(); } +protected: + LLFrameTimer mRuthDebugTimer; // For tracking how long it takes for av to rez + LLFrameTimer mDebugExistenceTimer; // Debugging for how long the avatar has been in memory. + /** Diagnostics ** ** *******************************************************************************/ @@ -1003,15 +1043,7 @@ protected: // Shared with LLVOAvatarSelf *******************************************************************************/ }; // LLVOAvatar - -//------------------------------------------------------------------------ -// Inlines -//------------------------------------------------------------------------ -inline BOOL LLVOAvatar::isTextureVisible(LLVOAvatarDefines::ETextureIndex te) const -{ - return ((isTextureDefined(te) || isSelf()) - && (getTEImage(te)->getID() != IMG_INVISIBLE - || LLDrawPoolAlpha::sShowDebugAlpha)); -} +extern const F32 SELF_ADDITIONAL_PRI; +extern const S32 MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL; #endif // LL_VO_AVATAR_H |