PageRenderTime 56ms CodeModel.GetById 20ms app.highlight 30ms RepoModel.GetById 1ms 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
  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
 28#ifndef LL_LLVOAVATARSELF_H
 29#define LL_LLVOAVATARSELF_H
 30
 31#include "llviewertexture.h"
 32#include "llvoavatar.h"
 33
 34struct LocalTextureData;
 35
 36
 37//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 38// LLVOAvatarSelf
 39//
 40//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 41class LLVOAvatarSelf :
 42	public LLVOAvatar
 43{
 44
 45/********************************************************************************
 46 **                                                                            **
 47 **                    INITIALIZATION
 48 **/
 49
 50public:
 51	LLVOAvatarSelf(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
 52	virtual 				~LLVOAvatarSelf();
 53	virtual void			markDead();
 54	virtual void 			initInstance(); // Called after construction to initialize the class.
 55	void					cleanup();
 56protected:
 57	/*virtual*/ BOOL		loadAvatar();
 58	BOOL					loadAvatarSelf();
 59	BOOL					buildSkeletonSelf(const LLVOAvatarSkeletonInfo *info);
 60	BOOL					buildMenus();
 61	/*virtual*/ BOOL		loadLayersets();
 62
 63/**                    Initialization
 64 **                                                                            **
 65 *******************************************************************************/
 66
 67/********************************************************************************
 68 **                                                                            **
 69 **                    INHERITED
 70 **/
 71
 72	//--------------------------------------------------------------------
 73	// LLViewerObject interface and related
 74	//--------------------------------------------------------------------
 75public:
 76	/*virtual*/ void 		updateRegion(LLViewerRegion *regionp);
 77	/*virtual*/ BOOL   	 	idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 78
 79	//--------------------------------------------------------------------
 80	// LLCharacter interface and related
 81	//--------------------------------------------------------------------
 82public:
 83	/*virtual*/ void 		stopMotionFromSource(const LLUUID& source_id);
 84	/*virtual*/ void 		requestStopMotion(LLMotion* motion);
 85	/*virtual*/ LLJoint*	getJoint(const std::string &name);
 86	
 87				void		resetJointPositions( void );
 88	
 89	/*virtual*/ BOOL setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake = FALSE );
 90	/*virtual*/ BOOL setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake = FALSE );
 91	/*virtual*/ BOOL setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake = FALSE );
 92	/*virtual*/ void updateVisualParams();
 93	/*virtual*/ void idleUpdateAppearanceAnimation();
 94
 95private:
 96	// helper function. Passed in param is assumed to be in avatar's parameter list.
 97	BOOL setParamWeight(LLViewerVisualParam *param, F32 weight, BOOL upload_bake = FALSE );
 98
 99
100/**                    Initialization
101 **                                                                            **
102 *******************************************************************************/
103
104/********************************************************************************
105 **                                                                            **
106 **                    STATE
107 **/
108
109public:
110	/*virtual*/ bool 	isSelf() const { return true; }
111
112	//--------------------------------------------------------------------
113	// Updates
114	//--------------------------------------------------------------------
115public:
116	/*virtual*/ BOOL 	updateCharacter(LLAgent &agent);
117	/*virtual*/ void 	idleUpdateTractorBeam();
118
119	//--------------------------------------------------------------------
120	// Loading state
121	//--------------------------------------------------------------------
122public:
123	/*virtual*/ BOOL    getIsCloud();
124
125	//--------------------------------------------------------------------
126	// Region state
127	//--------------------------------------------------------------------
128	void			resetRegionCrossingTimer()	{ mRegionCrossingTimer.reset();	}
129
130private:
131	U64				mLastRegionHandle;
132	LLFrameTimer	mRegionCrossingTimer;
133	S32				mRegionCrossingCount;
134	
135/**                    State
136 **                                                                            **
137 *******************************************************************************/
138
139/********************************************************************************
140 **                                                                            **
141 **                    RENDERING
142 **/
143
144	//--------------------------------------------------------------------
145	// Render beam
146	//--------------------------------------------------------------------
147protected:
148	BOOL 		needsRenderBeam();
149private:
150	LLPointer<LLHUDEffectSpiral> mBeam;
151	LLFrameTimer mBeamTimer;
152
153	//--------------------------------------------------------------------
154	// LLVOAvatar Constants
155	//--------------------------------------------------------------------
156public:
157	/*virtual*/ LLViewerTexture::EBoostLevel 	getAvatarBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_SELF; }
158	/*virtual*/ LLViewerTexture::EBoostLevel 	getAvatarBakedBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_BAKED_SELF; }
159	/*virtual*/ S32 						getTexImageSize() const { return LLVOAvatar::getTexImageSize()*4; }
160
161/**                    Rendering
162 **                                                                            **
163 *******************************************************************************/
164
165/********************************************************************************
166 **                                                                            **
167 **                    TEXTURES
168 **/
169
170	//--------------------------------------------------------------------
171	// Loading status
172	//--------------------------------------------------------------------
173public:
174	/*virtual*/ bool	hasPendingBakedUploads() const;
175	S32					getLocalDiscardLevel(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
176	bool				areTexturesCurrent() const;
177	BOOL				isLocalTextureDataAvailable(const LLTexLayerSet* layerset) const;
178	BOOL				isLocalTextureDataFinal(const LLTexLayerSet* layerset) const;
179	BOOL				isBakedTextureFinal(const LLVOAvatarDefines::EBakedTextureIndex index) const;
180	// If you want to check all textures of a given type, pass gAgentWearables.getWearableCount() for index
181	/*virtual*/ BOOL    isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
182	/*virtual*/ BOOL	isTextureVisible(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const;
183	/*virtual*/ BOOL	isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLWearable *wearable) const;
184
185
186	//--------------------------------------------------------------------
187	// Local Textures
188	//--------------------------------------------------------------------
189public:
190	BOOL				getLocalTextureGL(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture** image_gl_pp, U32 index) const;
191	LLViewerFetchedTexture*	getLocalTextureGL(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
192	const LLUUID&		getLocalTextureID(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
193	void				setLocalTextureTE(U8 te, LLViewerTexture* image, U32 index);
194	/*virtual*/ void	setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture* tex, BOOL baked_version_exits, U32 index);
195protected:
196	/*virtual*/ void	setBakedReady(LLVOAvatarDefines::ETextureIndex type, BOOL baked_version_exists, U32 index);
197	void				localTextureLoaded(BOOL succcess, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
198	void				getLocalTextureByteCount(S32* gl_byte_count) const;
199	/*virtual*/ void	addLocalTextureStats(LLVOAvatarDefines::ETextureIndex i, LLViewerFetchedTexture* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index);
200	LLLocalTextureObject* getLocalTextureObject(LLVOAvatarDefines::ETextureIndex i, U32 index) const;
201
202private:
203	static void			onLocalTextureLoaded(BOOL succcess, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
204
205	/*virtual*/	void	setImage(const U8 te, LLViewerTexture *imagep, const U32 index); 
206	/*virtual*/ LLViewerTexture* getImage(const U8 te, const U32 index) const;
207
208
209	//--------------------------------------------------------------------
210	// Baked textures
211	//--------------------------------------------------------------------
212public:
213	LLVOAvatarDefines::ETextureIndex getBakedTE(const LLTexLayerSet* layerset ) const;
214	void				setNewBakedTexture(LLVOAvatarDefines::EBakedTextureIndex i, const LLUUID &uuid);
215	void				setNewBakedTexture(LLVOAvatarDefines::ETextureIndex i, const LLUUID& uuid);
216	void				setCachedBakedTexture(LLVOAvatarDefines::ETextureIndex i, const LLUUID& uuid);
217	void				forceBakeAllTextures(bool slam_for_debug = false);
218	static void			processRebakeAvatarTextures(LLMessageSystem* msg, void**);
219	BOOL				isUsingBakedTextures() const; // e.g. false if in appearance edit mode
220protected:
221	/*virtual*/ void	removeMissingBakedTextures();
222
223	//--------------------------------------------------------------------
224	// Layers
225	//--------------------------------------------------------------------
226public:
227	void 				requestLayerSetUploads();
228	void				requestLayerSetUpload(LLVOAvatarDefines::EBakedTextureIndex i);
229	void				requestLayerSetUpdate(LLVOAvatarDefines::ETextureIndex i);
230	LLTexLayerSet*		getLayerSet(LLVOAvatarDefines::ETextureIndex index) const;
231	
232	//--------------------------------------------------------------------
233	// Composites
234	//--------------------------------------------------------------------
235public:
236	/* virtual */ void	invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result);
237	/* virtual */ void	invalidateAll();
238	/* virtual */ void	setCompositeUpdatesEnabled(bool b); // only works for self
239	/* virtual */ void  setCompositeUpdatesEnabled(U32 index, bool b);
240	/* virtual */ bool 	isCompositeUpdateEnabled(U32 index);
241	void				setupComposites();
242	void				updateComposites();
243
244	const LLUUID&		grabBakedTexture(LLVOAvatarDefines::EBakedTextureIndex baked_index) const;
245	BOOL				canGrabBakedTexture(LLVOAvatarDefines::EBakedTextureIndex baked_index) const;
246
247
248	//--------------------------------------------------------------------
249	// Scratch textures (used for compositing)
250	//--------------------------------------------------------------------
251public:
252	static void		deleteScratchTextures();
253private:
254	static S32 		sScratchTexBytes;
255	static LLMap< LLGLenum, LLGLuint*> sScratchTexNames;
256	static LLMap< LLGLenum, F32*> sScratchTexLastBindTime;
257
258/**                    Textures
259 **                                                                            **
260 *******************************************************************************/
261
262/********************************************************************************
263 **                                                                            **
264 **                    MESHES
265 **/
266protected:
267	/*virtual*/ void   restoreMeshData();
268
269/**                    Meshes
270 **                                                                            **
271 *******************************************************************************/
272
273/********************************************************************************
274 **                                                                            **
275 **                    WEARABLES
276 **/
277
278public:
279	/*virtual*/ BOOL	isWearingWearableType(LLWearableType::EType type) const;
280	void				wearableUpdated(LLWearableType::EType type, BOOL upload_result);
281protected:
282	U32 getNumWearables(LLVOAvatarDefines::ETextureIndex i) const;
283
284	//--------------------------------------------------------------------
285	// Attachments
286	//--------------------------------------------------------------------
287public:
288	void 				updateAttachmentVisibility(U32 camera_mode);
289	BOOL 				isWearingAttachment(const LLUUID& inv_item_id) const;
290	BOOL				attachmentWasRequested(const LLUUID& inv_item_id) const;
291	void				addAttachmentRequest(const LLUUID& inv_item_id);
292	void				removeAttachmentRequest(const LLUUID& inv_item_id);
293	LLViewerObject* 	getWornAttachment(const LLUUID& inv_item_id);
294	const std::string   getAttachedPointName(const LLUUID& inv_item_id) const;
295	/*virtual*/ const LLViewerJointAttachment *attachObject(LLViewerObject *viewer_object);
296	/*virtual*/ BOOL 	detachObject(LLViewerObject *viewer_object);
297	static BOOL			detachAttachmentIntoInventory(const LLUUID& item_id);
298
299private:
300	// Track attachments that have been requested but have not arrived yet.
301	mutable std::map<LLUUID,LLTimer> mAttachmentRequests;
302
303	//--------------------------------------------------------------------
304	// HUDs
305	//--------------------------------------------------------------------
306private:
307	LLViewerJoint* 		mScreenp; // special purpose joint for HUD attachments
308	
309/**                    Attachments
310 **                                                                            **
311 *******************************************************************************/
312
313/********************************************************************************
314 **                                                                            **
315 **                    APPEARANCE
316 **/
317
318public:
319	static void		onCustomizeStart();
320	static void		onCustomizeEnd();
321
322	//--------------------------------------------------------------------
323	// Visibility
324	//--------------------------------------------------------------------
325public:
326	bool			sendAppearanceMessage(LLMessageSystem *mesgsys) const;
327
328/**                    Appearance
329 **                                                                            **
330 *******************************************************************************/
331
332/********************************************************************************
333 **                                                                            **
334 **                    DIAGNOSTICS
335 **/
336
337	//--------------------------------------------------------------------
338	// General
339	//--------------------------------------------------------------------
340public:	
341	static void		dumpTotalLocalTextureByteCount();
342	void			dumpLocalTextures() const;
343	static void		dumpScratchTextureByteCount();
344
345	//--------------------------------------------------------------------
346	// Avatar Rez Metrics
347	//--------------------------------------------------------------------
348public:	
349	struct LLAvatarTexData
350	{
351		LLAvatarTexData(const LLUUID& id, LLVOAvatarDefines::ETextureIndex index) : 
352			mAvatarID(id), 
353			mIndex(index) 
354		{}
355		LLUUID			mAvatarID;
356		LLVOAvatarDefines::ETextureIndex	mIndex;
357	};
358	void 					debugWearablesLoaded() { mDebugTimeWearablesLoaded = mDebugSelfLoadTimer.getElapsedTimeF32(); }
359	void 					debugAvatarVisible() { mDebugTimeAvatarVisible = mDebugSelfLoadTimer.getElapsedTimeF32(); }
360	void 					outputRezDiagnostics() const;
361	void 					debugBakedTextureUpload(LLVOAvatarDefines::EBakedTextureIndex index, BOOL finished);
362	static void				debugOnTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
363
364	BOOL					isAllLocalTextureDataFinal() const;
365
366	const LLTexLayerSet*  	debugGetLayerSet(LLVOAvatarDefines::EBakedTextureIndex index) const { return mBakedTextureDatas[index].mTexLayerSet; }
367	const std::string		debugDumpLocalTextureDataInfo(const LLTexLayerSet* layerset) const; // Lists out state of this particular baked texture layer
368	const std::string		debugDumpAllLocalTextureDataInfo() const; // Lists out which baked textures are at highest LOD
369private:
370	LLFrameTimer    		mDebugSelfLoadTimer;
371	F32						mDebugTimeWearablesLoaded;
372	F32 					mDebugTimeAvatarVisible;
373	F32 					mDebugTextureLoadTimes[LLVOAvatarDefines::TEX_NUM_INDICES][MAX_DISCARD_LEVEL+1]; // load time for each texture at each discard level
374	F32 					mDebugBakedTextureTimes[LLVOAvatarDefines::BAKED_NUM_INDICES][2]; // time to start upload and finish upload of each baked texture
375	void					debugTimingLocalTexLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
376
377/**                    Diagnostics
378 **                                                                            **
379 *******************************************************************************/
380
381};
382
383extern LLVOAvatarSelf *gAgentAvatarp;
384
385BOOL isAgentAvatarValid();
386
387#endif // LL_VO_AVATARSELF_H