1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
|
/**
* @file llvoavatar.h
* @brief Declaration of LLVOAvatar class which is a derivation fo
* LLViewerObject
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* 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
*
* 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
*
* 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.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#ifndef LL_LLVOAVATAR_H
#define LL_LLVOAVATAR_H
#include <map>
#include <deque>
#include <string>
#include <vector>
#include "imageids.h" // IMG_INVISIBLE
#include "llchat.h"
#include "lldrawpoolalpha.h"
#include "llviewerobject.h"
#include "llcharacter.h"
#include "llviewerjointmesh.h"
#include "llviewerjointattachment.h"
#include "llrendertarget.h"
#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;
extern const LLUUID ANIM_AGENT_EDITING;
extern const LLUUID ANIM_AGENT_EYE;
extern const LLUUID ANIM_AGENT_FLY_ADJUST;
extern const LLUUID ANIM_AGENT_HAND_MOTION;
extern const LLUUID ANIM_AGENT_HEAD_ROT;
extern const LLUUID ANIM_AGENT_PELVIS_FIX;
extern const LLUUID ANIM_AGENT_TARGET;
extern const LLUUID ANIM_AGENT_WALK_ADJUST;
class LLTexLayerSet;
class LLVoiceVisualizer;
class LLHUDText;
class LLHUDEffectSpiral;
class LLTexGlobalColor;
class LLVOAvatarBoneInfo;
class LLVOAvatarSkeletonInfo;
//------------------------------------------------------------------------
// LLVOAvatar
//------------------------------------------------------------------------
class LLVOAvatar :
public LLViewerObject,
public LLCharacter
{
public:
friend class LLVOAvatarSelf;
protected:
struct LLVOAvatarXmlInfo;
struct LLMaskedMorph;
/********************************************************************************
** **
** INITIALIZATION
**/
public:
LLVOAvatar(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
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.
virtual void initInstance(); // Called after construction to initialize the class.
protected:
virtual ~LLVOAvatar();
BOOL loadSkeletonNode();
BOOL loadMeshNodes();
virtual BOOL loadLayersets();
/** Initialization
** **
*******************************************************************************/
/********************************************************************************
** **
** INHERITED
**/
//--------------------------------------------------------------------
// LLViewerObject interface and related
//--------------------------------------------------------------------
public:
virtual void updateGL();
virtual LLVOAvatar* asAvatar();
virtual U32 processUpdateMessage(LLMessageSystem *mesgsys,
void **user_data,
U32 block_num,
const EObjectUpdateType update_type,
LLDataPacker *dp);
virtual BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
virtual BOOL updateLOD();
BOOL updateJointLODs();
virtual BOOL isActive() const; // Whether this object needs to do an idleUpdate.
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;
virtual const LLVector3 getRenderPosition() const;
virtual void updateDrawable(BOOL force_damped);
virtual LLDrawable* createDrawable(LLPipeline *pipeline);
virtual BOOL updateGeometry(LLDrawable *drawable);
virtual void setPixelAreaAndAngle(LLAgent &agent);
virtual void updateRegion(LLViewerRegion *regionp);
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
//--------------------------------------------------------------------
// LLCharacter interface and related
//--------------------------------------------------------------------
public:
virtual LLVector3 getCharacterPosition();
virtual LLQuaternion getCharacterRotation();
virtual LLVector3 getCharacterVelocity();
virtual LLVector3 getCharacterAngularVelocity();
virtual LLJoint* getCharacterJoint(U32 num);
virtual BOOL allocateCharacterJoints(U32 num);
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();
virtual LLJoint* getJoint(const std::string &name);
virtual LLJoint* getRootJoint() { return &mRoot; }
virtual const char* getAnimationPrefix() { return "avatar"; }
virtual const LLUUID& getID();
virtual LLVector3 getVolumePos(S32 joint_index, LLVector3& volume_offset);
virtual LLJoint* findCollisionVolume(U32 volume_id);
virtual S32 getCollisionVolumeID(std::string &name);
virtual void addDebugText(const std::string& text);
virtual F32 getTimeDilation();
virtual void getGround(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
virtual F32 getPixelArea() const;
virtual LLPolyMesh* getHeadMesh();
virtual LLPolyMesh* getUpperBodyMesh();
virtual LLVector3d getPosGlobalFromAgent(const LLVector3 &position);
virtual LLVector3 getPosAgentFromGlobal(const LLVector3d &position);
virtual void updateVisualParams();
/** Inherited
** **
*******************************************************************************/
/********************************************************************************
** **
** STATE
**/
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
//--------------------------------------------------------------------
// Updates
//--------------------------------------------------------------------
public:
virtual BOOL updateCharacter(LLAgent &agent);
void idleUpdateVoiceVisualizer(bool voice_enabled);
void idleUpdateMisc(bool detailed_update);
virtual void idleUpdateAppearanceAnimation();
void idleUpdateLipSync(bool voice_enabled);
void idleUpdateLoadingEffect();
void idleUpdateWindEffect();
void idleUpdateNameTag(const LLVector3& root_pos_last);
LLVector3 idleUpdateNameTagPosition(const LLVector3& root_pos_last);
void idleUpdateNameTagColor(BOOL new_name, F32 alpha);
void idleUpdateRenderCost();
void idleUpdateTractorBeam();
void idleUpdateBelowWater();
//--------------------------------------------------------------------
// Static preferences (controlled by user settings/menus)
//--------------------------------------------------------------------
public:
static S32 sRenderName;
static BOOL sRenderGroupTitles;
static S32 sMaxVisible;
static F32 sRenderDistance; //distance at which avatars will render (affected by control "RenderAvatarMaxVisible")
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
static BOOL sShowCollisionVolumes; // show skeletal collision volumes
static BOOL sVisibleInFirstPerson;
static S32 sNumLODChangesThisFrame;
static S32 sNumVisibleChatBubbles;
static BOOL sDebugInvisible;
static BOOL sShowAttachmentPoints;
static F32 sLODFactor; // user-settable LOD factor
static BOOL sJointDebug; // output total number of joints being touched for each avatar
static BOOL sDebugAvatarRotation;
//--------------------------------------------------------------------
// Region state
//--------------------------------------------------------------------
public:
LLHost getObjectHost() const;
//--------------------------------------------------------------------
// Loading state
//--------------------------------------------------------------------
public:
BOOL isFullyLoaded() const;
protected:
virtual 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;
/** State
** **
*******************************************************************************/
/********************************************************************************
** **
** SKELETON
**/
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();
virtual BOOL loadAvatar();
BOOL setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent, S32 ¤t_volume_num, S32 ¤t_joint_num);
BOOL buildSkeleton(const LLVOAvatarSkeletonInfo *info);
private:
BOOL mIsBuilt; // state of deferred character building
S32 mNumJoints;
LLViewerJoint* mSkeleton;
//--------------------------------------------------------------------
// Pelvis height adjustment members.
//--------------------------------------------------------------------
public:
LLVector3 mBodySize;
S32 mLastSkeletonSerialNum;
private:
F32 mPelvisToFoot;
//--------------------------------------------------------------------
// Cached pointers to well known joints
//--------------------------------------------------------------------
public:
LLViewerJoint* mPelvisp;
LLViewerJoint* mTorsop;
LLViewerJoint* mChestp;
LLViewerJoint* mNeckp;
LLViewerJoint* mHeadp;
LLViewerJoint* mSkullp;
LLViewerJoint* mEyeLeftp;
LLViewerJoint* mEyeRightp;
LLViewerJoint* mHipLeftp;
LLViewerJoint* mHipRightp;
LLViewerJoint* mKneeLeftp;
LLViewerJoint* mKneeRightp;
LLViewerJoint* mAnkleLeftp;
LLViewerJoint* mAnkleRightp;
LLViewerJoint* mFootLeftp;
LLViewerJoint* mFootRightp;
LLViewerJoint* mWristLeftp;
LLViewerJoint* mWristRightp;
//--------------------------------------------------------------------
// XML parse tree
//--------------------------------------------------------------------
private:
static LLXmlTree sXMLTree; // avatar config file
static LLXmlTree sSkeletonXMLTree; // avatar skeleton file
/** Skeleton
** **
*******************************************************************************/
/********************************************************************************
** **
** RENDERING
**/
public:
U32 renderFootShadows();
U32 renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0);
U32 renderRigid();
U32 renderSkinned(EAvatarRenderPass pass);
U32 renderTransparent(BOOL first_pass);
void renderCollisionVolumes();
static void deleteCachedImages(bool clearAll=true);
static void destroyGL();
static void restoreGL();
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.
//--------------------------------------------------------------------
// Morph masks
//--------------------------------------------------------------------
public:
BOOL morphMaskNeedsUpdate(LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES);
void addMaskedMorph(LLVOAvatarDefines::EBakedTextureIndex index, LLPolyMorphTarget* morph_target, BOOL invert, std::string layer);
void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES);
//--------------------------------------------------------------------
// Visibility
//--------------------------------------------------------------------
protected:
void updateVisibility();
private:
U32 mVisibilityRank;
BOOL mVisible;
//--------------------------------------------------------------------
// Shadowing
//--------------------------------------------------------------------
public:
void updateShadowFaces();
LLDrawable* mShadow;
private:
LLFace* mShadow0Facep;
LLFace* mShadow1Facep;
LLPointer<LLViewerTexture> mShadowImagep;
//--------------------------------------------------------------------
// Impostors
//--------------------------------------------------------------------
public:
BOOL isImpostor() const;
BOOL needsImpostorUpdate() const;
const LLVector3& getImpostorOffset() const;
const LLVector2& getImpostorDim() const;
void getImpostorValues(LLVector3* extents, LLVector3& angle, F32& distance) const;
void cacheImpostorValues();
void setImpostorDim(const LLVector2& dim);
static void resetImpostors();
static void updateImpostors();
LLRenderTarget mImpostor;
BOOL mNeedsImpostorUpdate;
private:
LLVector3 mImpostorOffset;
LLVector2 mImpostorDim;
BOOL mNeedsAnimUpdate;
LLVector3 mImpostorExtents[2];
LLVector3 mImpostorAngle;
F32 mImpostorDistance;
F32 mImpostorPixelArea;
LLVector3 mLastAnimExtents[2];
//--------------------------------------------------------------------
// Wind rippling in clothes
//--------------------------------------------------------------------
public:
LLVector4 mWindVec;
F32 mRipplePhase;
BOOL mBelowWater;
private:
F32 mWindFreq;
LLFrameTimer mRippleTimer;
F32 mRippleTimeLast;
LLVector3 mRippleAccel;
LLVector3 mLastVel;
//--------------------------------------------------------------------
// Culling
//--------------------------------------------------------------------
public:
static void cullAvatarsByPixelArea();
BOOL isCulled() const { return mCulled; }
private:
BOOL mCulled;
//--------------------------------------------------------------------
// Freeze counter
//--------------------------------------------------------------------
public:
static void updateFreezeCounter(S32 counter = 0);
private:
static S32 sFreezeCounter;
//--------------------------------------------------------------------
// Constants
//--------------------------------------------------------------------
public:
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(); }
/** Rendering
** **
*******************************************************************************/
/********************************************************************************
** **
** TEXTURES
**/
//--------------------------------------------------------------------
// Loading status
//--------------------------------------------------------------------
public:
virtual BOOL isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const;
BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex index) const;
protected:
BOOL isFullyBaked();
static BOOL areAllNearbyInstancesBaked(S32& grey_avatars);
//--------------------------------------------------------------------
// Baked textures
//--------------------------------------------------------------------
public:
void releaseComponentTextures(); // ! BACKWARDS COMPATIBILITY !
protected:
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);
typedef std::deque<LLMaskedMorph *> morph_list_t;
struct BakedTextureData
{
LLUUID mLastTextureIndex;
LLTexLayerSet* mTexLayerSet; // Only exists for self
bool mIsLoaded;
bool mIsUsed;
LLVOAvatarDefines::ETextureIndex mTextureIndex;
U32 mMaskTexName;
// 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;
};
typedef std::vector<BakedTextureData> bakedtexturedata_vec_t;
bakedtexturedata_vec_t mBakedTextureDatas;
//--------------------------------------------------------------------
// Local Textures
//--------------------------------------------------------------------
protected:
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, 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);
//--------------------------------------------------------------------
// Layers
//--------------------------------------------------------------------
protected:
void deleteLayerSetCaches(bool clearAll = true);
void addBakedTextureStats(LLViewerFetchedTexture* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level);
//--------------------------------------------------------------------
// Composites
//--------------------------------------------------------------------
public:
virtual void invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result);
virtual void invalidateAll();
virtual void setCompositeUpdatesEnabled(BOOL b);
//--------------------------------------------------------------------
// Static texture/mesh/baked dictionary
//--------------------------------------------------------------------
public:
static BOOL isIndexLocalTexture(LLVOAvatarDefines::ETextureIndex i);
static BOOL isIndexBakedTexture(LLVOAvatarDefines::ETextureIndex i);
private:
static const LLVOAvatarDefines::LLVOAvatarDictionary *getDictionary() { return sAvatarDictionary; }
static LLVOAvatarDefines::LLVOAvatarDictionary* sAvatarDictionary;
static LLVOAvatarSkeletonInfo* sAvatarSkeletonInfo;
static LLVOAvatarXmlInfo* sAvatarXmlInfo;
//--------------------------------------------------------------------
// Messaging
//--------------------------------------------------------------------
public:
void onFirstTEMessageReceived();
private:
BOOL mFirstTEMessageReceived;
BOOL mFirstAppearanceMessageReceived;
/** Textures
** **
*******************************************************************************/
/********************************************************************************
** **
** MESHES
**/
public:
void updateMeshTextures();
void updateSexDependentLayerSets(BOOL upload_bake);
void dirtyMesh(); // Dirty the avatar mesh
void updateMeshData();
protected:
void releaseMeshData();
virtual void restoreMeshData();
private:
BOOL mDirtyMesh;
BOOL mMeshTexturesDirty;
typedef std::multimap<std::string, LLPolyMesh*> polymesh_map_t;
polymesh_map_t mMeshes;
std::vector<LLViewerJoint *> mMeshLOD;
//--------------------------------------------------------------------
// Destroy invisible mesh
//--------------------------------------------------------------------
protected:
BOOL mMeshValid;
LLFrameTimer mMeshInvisibleTime;
/** Meshes
** **
*******************************************************************************/
/********************************************************************************
** **
** APPEARANCE
**/
public:
void processAvatarAppearance(LLMessageSystem* mesgsys);
void hideSkirt();
void startAppearanceAnimation();
//--------------------------------------------------------------------
// Appearance morphing
//--------------------------------------------------------------------
public:
BOOL mAppearanceAnimating;
private:
LLFrameTimer mAppearanceMorphTimer;
F32 mLastAppearanceBlendTime;
//--------------------------------------------------------------------
// Clothing colors (convenience functions to access visual parameters)
//--------------------------------------------------------------------
public:
void setClothesColor(LLVOAvatarDefines::ETextureIndex te, const LLColor4& new_color, BOOL upload_bake);
LLColor4 getClothesColor(LLVOAvatarDefines::ETextureIndex te);
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 upload_bake);
private:
LLTexGlobalColor* mTexSkinColor;
LLTexGlobalColor* mTexHairColor;
LLTexGlobalColor* mTexEyeColor;
//--------------------------------------------------------------------
// Visibility
//--------------------------------------------------------------------
public:
BOOL isVisible() const;
void setVisibilityRank(U32 rank);
U32 getVisibilityRank() const { return mVisibilityRank; } // unused
static S32 sNumVisibleAvatars; // Number of instances of this class
static LLColor4 getDummyColor();
/** Appearance
** **
*******************************************************************************/
/********************************************************************************
** **
** WEARABLES
**/
public:
virtual BOOL isWearingWearableType(EWearableType type ) const;
//--------------------------------------------------------------------
// Attachments
//--------------------------------------------------------------------
public:
void clampAttachmentPositions();
virtual const LLViewerJointAttachment* attachObject(LLViewerObject *viewer_object);
virtual BOOL detachObject(LLViewerObject *viewer_object);
static LLVOAvatar* findAvatarFromAttachment(LLViewerObject* obj);
protected:
LLViewerJointAttachment* getTargetAttachmentPoint(LLViewerObject* viewer_object);
void lazyAttach();
//--------------------------------------------------------------------
// Map of attachment points, by ID
//--------------------------------------------------------------------
public:
S32 getAttachmentCount(); // Warning: order(N) not order(1) // currently used only by -self
typedef std::map<S32, LLViewerJointAttachment*> attachment_map_t;
attachment_map_t mAttachmentPoints;
std::vector<LLPointer<LLViewerObject> > mPendingAttachment;
//--------------------------------------------------------------------
// HUD functions
//--------------------------------------------------------------------
public:
BOOL hasHUDAttachment() const;
LLBBox getHUDBBox() const;
void rebuildHUD();
void resetHUDAttachments();
BOOL canAttachMoreObjects() const;
protected:
U32 getNumAttachments() const; // O(N), not O(1)
/** Wearables
** **
*******************************************************************************/
/********************************************************************************
** **
** ACTIONS
**/
//--------------------------------------------------------------------
// Animations
//--------------------------------------------------------------------
public:
BOOL isAnyAnimationSignaled(const LLUUID *anim_array, const S32 num_anims) const;
void processAnimationStateChanges();
protected:
BOOL processSingleAnimationStateChange(const LLUUID &anim_id, BOOL start);
void resetAnimations();
private:
LLTimer mAnimTimer;
F32 mTimeLast;
//--------------------------------------------------------------------
// Animation state data
//--------------------------------------------------------------------
public:
typedef std::map<LLUUID, S32>::iterator AnimIterator;
std::map<LLUUID, S32> mSignaledAnimations; // requested state of Animation name/value
std::map<LLUUID, S32> mPlayingAnimations; // current state of Animation name/value
typedef std::multimap<LLUUID, LLUUID> AnimationSourceMap;
typedef AnimationSourceMap::iterator AnimSourceIterator;
AnimationSourceMap mAnimationSources; // object ids that triggered anim ids
//--------------------------------------------------------------------
// Chat
//--------------------------------------------------------------------
public:
void addChat(const LLChat& chat);
void clearChat();
void startTyping() { mTyping = TRUE; mTypingTimer.reset(); }
void stopTyping() { mTyping = FALSE; }
private:
BOOL mVisibleChat;
//--------------------------------------------------------------------
// Lip synch morphs
//--------------------------------------------------------------------
private:
bool mLipSyncActive; // we're morphing for lip sync
LLVisualParam* mOohMorph; // cached pointers morphs for lip sync
LLVisualParam* mAahMorph; // cached pointers morphs for lip sync
//--------------------------------------------------------------------
// Flight
//--------------------------------------------------------------------
public:
BOOL mInAir;
LLFrameTimer mTimeInAir;
/** Actions
** **
*******************************************************************************/
/********************************************************************************
** **
** PHYSICS
**/
private:
F32 mSpeedAccum; // measures speed (for diagnostics mostly).
BOOL mTurning; // controls hysteresis on avatar rotation
F32 mSpeed; // misc. animation repeated state
//--------------------------------------------------------------------
// Collision volumes
//--------------------------------------------------------------------
public:
S32 mNumCollisionVolumes;
LLViewerJointCollisionVolume* mCollisionVolumes;
protected:
BOOL allocateCollisionVolumes(U32 num);
//--------------------------------------------------------------------
// Dimensions
//--------------------------------------------------------------------
public:
void resolveHeightGlobal(const LLVector3d &inPos, LLVector3d &outPos, LLVector3 &outNorm);
void resolveHeightAgent(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
void resolveRayCollisionAgent(const LLVector3d start_pt, const LLVector3d end_pt, LLVector3d &out_pos, LLVector3 &out_norm);
void slamPosition(); // Slam position to transmitted position (for teleport);
protected:
void computeBodySize();
//--------------------------------------------------------------------
// Material being stepped on
//--------------------------------------------------------------------
private:
BOOL mStepOnLand;
U8 mStepMaterial;
LLVector3 mStepObjectVelocity;
/** Physics
** **
*******************************************************************************/
/********************************************************************************
** **
** HIERARCHY
**/
public:
virtual BOOL setParent(LLViewerObject* parent);
virtual void addChild(LLViewerObject *childp);
virtual void removeChild(LLViewerObject *childp);
//--------------------------------------------------------------------
// 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
** **
*******************************************************************************/
/********************************************************************************
** **
** NAME
**/
public:
std::string getFullname() const; // Returns "FirstName LastName"
protected:
static void getAnimLabels(LLDynamicArray<std::string>* labels);
static void getAnimNames(LLDynamicArray<std::string>* names);
private:
LLWString mNameString;
std::string mTitle;
bool mNameAway;
bool mNameBusy;
bool mNameMute;
bool mNameAppearance;
bool mNameFriend;
F32 mNameAlpha;
BOOL mRenderGroupTitles;
bool mUseDisplayNames; // IDEVO HACK to force refresh
//--------------------------------------------------------------------
// Display the name (then optionally fade it out)
//--------------------------------------------------------------------
public:
LLFrameTimer mChatTimer;
LLPointer<LLHUDText> mNameText;
private:
LLFrameTimer mTimeVisible;
std::deque<LLChat> mChats;
BOOL mTyping;
LLFrameTimer mTypingTimer;
/** Name
** **
*******************************************************************************/
/********************************************************************************
** **
** SOUNDS
**/
//--------------------------------------------------------------------
// Voice visualizer
//--------------------------------------------------------------------
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;
int mCurrentGesticulationLevel;
//--------------------------------------------------------------------
// Step sound
//--------------------------------------------------------------------
protected:
const LLUUID& getStepSound() const;
private:
// Global table of sound ids per material, and the ground
const static LLUUID sStepSounds[LL_MCODE_END];
const static LLUUID sStepSoundOnLand;
//--------------------------------------------------------------------
// Foot step state (for generating sounds)
//--------------------------------------------------------------------
public:
void setFootPlane(const LLVector4 &plane) { mFootPlane = plane; }
LLVector4 mFootPlane;
private:
BOOL mWasOnGroundLeft;
BOOL mWasOnGroundRight;
/** Sounds
** **
*******************************************************************************/
/********************************************************************************
** **
** DIAGNOSTICS
**/
public:
static void dumpArchetypeXML(void*);
static void dumpBakedStatus();
const std::string getBakedStatusForPrintout() const;
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)
static F32 sGreyTime; // Total seconds with >=1 grey avatars
static F32 sGreyUpdateTime; // Last time stats were updated (to prevent multiple updates per frame)
protected:
S32 getUnbakedPixelAreaRank();
BOOL mHasGrey;
private:
F32 mMinPixelArea;
F32 mMaxPixelArea;
F32 mAdjustedPixelArea;
std::string mDebugText;
/** Diagnostics
** **
*******************************************************************************/
/********************************************************************************
** **
** SUPPORT CLASSES
**/
protected: // Shared with LLVOAvatarSelf
struct LLVOAvatarXmlInfo
{
LLVOAvatarXmlInfo();
~LLVOAvatarXmlInfo();
BOOL parseXmlSkeletonNode(LLXmlTreeNode* root);
BOOL parseXmlMeshNodes(LLXmlTreeNode* root);
BOOL parseXmlColorNodes(LLXmlTreeNode* root);
BOOL parseXmlLayerNodes(LLXmlTreeNode* root);
BOOL parseXmlDriverNodes(LLXmlTreeNode* root);
BOOL parseXmlMorphNodes(LLXmlTreeNode* root);
struct LLVOAvatarMeshInfo
{
typedef std::pair<LLPolyMorphTargetInfo*,BOOL> morph_info_pair_t;
typedef std::vector<morph_info_pair_t> morph_info_list_t;
LLVOAvatarMeshInfo() : mLOD(0), mMinPixelArea(.1f) {}
~LLVOAvatarMeshInfo()
{
morph_info_list_t::iterator iter;
for (iter = mPolyMorphTargetInfoList.begin(); iter != mPolyMorphTargetInfoList.end(); iter++)
{
delete iter->first;
}
mPolyMorphTargetInfoList.clear();
}
std::string mType;
S32 mLOD;
std::string mMeshFileName;
std::string mReferenceMeshName;
F32 mMinPixelArea;
morph_info_list_t mPolyMorphTargetInfoList;
};
typedef std::vector<LLVOAvatarMeshInfo*> mesh_info_list_t;
mesh_info_list_t mMeshInfoList;
typedef std::vector<LLPolySkeletalDistortionInfo*> skeletal_distortion_info_list_t;
skeletal_distortion_info_list_t mSkeletalDistortionInfoList;
struct LLVOAvatarAttachmentInfo
{
LLVOAvatarAttachmentInfo()
: mGroup(-1), mAttachmentID(-1), mPieMenuSlice(-1), mVisibleFirstPerson(FALSE),
mIsHUDAttachment(FALSE), mHasPosition(FALSE), mHasRotation(FALSE) {}
std::string mName;
std::string mJointName;
LLVector3 mPosition;
LLVector3 mRotationEuler;
S32 mGroup;
S32 mAttachmentID;
S32 mPieMenuSlice;
BOOL mVisibleFirstPerson;
BOOL mIsHUDAttachment;
BOOL mHasPosition;
BOOL mHasRotation;
};
typedef std::vector<LLVOAvatarAttachmentInfo*> attachment_info_list_t;
attachment_info_list_t mAttachmentInfoList;
LLTexGlobalColorInfo *mTexSkinColorInfo;
LLTexGlobalColorInfo *mTexHairColorInfo;
LLTexGlobalColorInfo *mTexEyeColorInfo;
typedef std::vector<LLTexLayerSetInfo*> layer_info_list_t;
layer_info_list_t mLayerInfoList;
typedef std::vector<LLDriverParamInfo*> driver_info_list_t;
driver_info_list_t mDriverInfoList;
struct LLVOAvatarMorphInfo
{
LLVOAvatarMorphInfo()
: mInvert(FALSE) {}
std::string mName;
std::string mRegion;
std::string mLayer;
BOOL mInvert;
};
typedef std::vector<LLVOAvatarMorphInfo*> morph_info_list_t;
morph_info_list_t mMorphMaskInfoList;
};
struct LLMaskedMorph
{
LLMaskedMorph(LLPolyMorphTarget *morph_target, BOOL invert, std::string layer) :
mMorphTarget(morph_target),
mInvert(invert),
mLayer(layer)
{
morph_target->addPendingMorphMask();
}
LLPolyMorphTarget *mMorphTarget;
BOOL mInvert;
std::string mLayer;
};
/** Support classes
** **
*******************************************************************************/
}; // LLVOAvatar
//------------------------------------------------------------------------
// Inlines
//------------------------------------------------------------------------
inline BOOL LLVOAvatar::isTextureVisible(LLVOAvatarDefines::ETextureIndex te) const
{
return ((isTextureDefined(te) || isSelf())
&& (getTEImage(te)->getID() != IMG_INVISIBLE
|| LLDrawPoolAlpha::sShowDebugAlpha));
}
#endif // LL_VO_AVATAR_H
|