aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvoavatar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llvoavatar.cpp')
-rw-r--r--linden/indra/newview/llvoavatar.cpp456
1 files changed, 293 insertions, 163 deletions
diff --git a/linden/indra/newview/llvoavatar.cpp b/linden/indra/newview/llvoavatar.cpp
index b4357d8..d6c9e2f 100644
--- a/linden/indra/newview/llvoavatar.cpp
+++ b/linden/indra/newview/llvoavatar.cpp
@@ -114,7 +114,7 @@
114#include "llworld.h" 114#include "llworld.h"
115#include "pipeline.h" 115#include "pipeline.h"
116#include "llspatialpartition.h" 116#include "llspatialpartition.h"
117#include "llglslshader.h" 117#include "llviewershadermgr.h"
118#include "llappviewer.h" 118#include "llappviewer.h"
119#include "llsky.h" 119#include "llsky.h"
120#include "llanimstatelabels.h" 120#include "llanimstatelabels.h"
@@ -138,7 +138,7 @@ S32 LLVOAvatar::sFreezeCounter = 0 ;
138//----------------------------------------------------------------------------- 138//-----------------------------------------------------------------------------
139// Constants 139// Constants
140//----------------------------------------------------------------------------- 140//-----------------------------------------------------------------------------
141const F32 MIN_PIXEL_AREA_FOR_COMPOSITE = 200.f; 141const F32 MIN_PIXEL_AREA_FOR_COMPOSITE = 1024;
142 142
143F32 SHADOW_OFFSET_AMT = 0.03f; 143F32 SHADOW_OFFSET_AMT = 0.03f;
144 144
@@ -622,8 +622,6 @@ LLVOAvatar::LLVOAvatar(
622 LLViewerRegion* regionp) 622 LLViewerRegion* regionp)
623 : 623 :
624 LLViewerObject(id, pcode, regionp), 624 LLViewerObject(id, pcode, regionp),
625 mHUDTargetZoom(1.f),
626 mHUDCurZoom(1.f),
627 mLastHeadBakedID( IMG_DEFAULT_AVATAR ), 625 mLastHeadBakedID( IMG_DEFAULT_AVATAR ),
628 mLastUpperBodyBakedID( IMG_DEFAULT_AVATAR ), 626 mLastUpperBodyBakedID( IMG_DEFAULT_AVATAR ),
629 mLastLowerBodyBakedID( IMG_DEFAULT_AVATAR ), 627 mLastLowerBodyBakedID( IMG_DEFAULT_AVATAR ),
@@ -675,6 +673,10 @@ LLVOAvatar::LLVOAvatar(
675 mUpperMaskTexName(0), 673 mUpperMaskTexName(0),
676 mLowerMaskTexName(0), 674 mLowerMaskTexName(0),
677 mCulled( FALSE ), 675 mCulled( FALSE ),
676 mVisibilityRank(0),
677 mFadeTime(0.f),
678 mLastFadeTime(0.f),
679 mLastFadeDistance(1.f),
678 mTexSkinColor( NULL ), 680 mTexSkinColor( NULL ),
679 mTexHairColor( NULL ), 681 mTexHairColor( NULL ),
680 mTexEyeColor( NULL ), 682 mTexEyeColor( NULL ),
@@ -718,8 +720,6 @@ LLVOAvatar::LLVOAvatar(
718 mSpeed = 0.f; 720 mSpeed = 0.f;
719 setAnimationData("Speed", &mSpeed); 721 setAnimationData("Speed", &mSpeed);
720 722
721 strcpy(mAvatarDefinition, AVATAR_DEFAULT_CHAR); /* Flawfinder: ignore */
722
723 if (id == gAgentID) 723 if (id == gAgentID)
724 { 724 {
725 mIsSelf = TRUE; 725 mIsSelf = TRUE;
@@ -735,6 +735,7 @@ LLVOAvatar::LLVOAvatar(
735 mNeedsAnimUpdate = TRUE; 735 mNeedsAnimUpdate = TRUE;
736 736
737 mImpostorDistance = 0; 737 mImpostorDistance = 0;
738 mImpostorPixelArea = 0;
738 739
739 setNumTEs(TEX_NUM_ENTRIES); 740 setNumTEs(TEX_NUM_ENTRIES);
740 741
@@ -1359,9 +1360,9 @@ void LLVOAvatar::initClass()
1359{ 1360{
1360 LLVOAvatar::sMaxOtherAvatarsToComposite = gSavedSettings.getS32("AvatarCompositeLimit"); 1361 LLVOAvatar::sMaxOtherAvatarsToComposite = gSavedSettings.getS32("AvatarCompositeLimit");
1361 1362
1362 char xmlFile[MAX_PATH]; /* Flawfinder: ignore */ 1363 std::string xmlFile;
1363 1364
1364 snprintf(xmlFile, MAX_PATH, "%s_lad.xml", gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,AVATAR_DEFAULT_CHAR).c_str()); /* Flawfinder: ignore */ 1365 xmlFile = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,AVATAR_DEFAULT_CHAR) + "_lad.xml";
1365 BOOL success = sXMLTree.parseFile( xmlFile, FALSE ); 1366 BOOL success = sXMLTree.parseFile( xmlFile, FALSE );
1366 if (!success) 1367 if (!success)
1367 { 1368 {
@@ -1384,7 +1385,7 @@ void LLVOAvatar::initClass()
1384 llerrs << "Invalid avatar file header: " << xmlFile << llendl; 1385 llerrs << "Invalid avatar file header: " << xmlFile << llendl;
1385 } 1386 }
1386 1387
1387 LLString version; 1388 std::string version;
1388 static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version"); 1389 static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version");
1389 if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") ) 1390 if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") )
1390 { 1391 {
@@ -1396,7 +1397,7 @@ void LLVOAvatar::initClass()
1396 root->getFastAttributeS32( wearable_definition_version_string, wearable_def_version ); 1397 root->getFastAttributeS32( wearable_definition_version_string, wearable_def_version );
1397 LLWearable::setCurrentDefinitionVersion( wearable_def_version ); 1398 LLWearable::setCurrentDefinitionVersion( wearable_def_version );
1398 1399
1399 LLString mesh_file_name; 1400 std::string mesh_file_name;
1400 1401
1401 LLXmlTreeNode* skeleton_node = root->getChildByName( "skeleton" ); 1402 LLXmlTreeNode* skeleton_node = root->getChildByName( "skeleton" );
1402 if (!skeleton_node) 1403 if (!skeleton_node)
@@ -1405,7 +1406,7 @@ void LLVOAvatar::initClass()
1405 return; 1406 return;
1406 } 1407 }
1407 1408
1408 LLString skeleton_file_name; 1409 std::string skeleton_file_name;
1409 static LLStdStringHandle file_name_string = LLXmlTree::addAttributeString("file_name"); 1410 static LLStdStringHandle file_name_string = LLXmlTree::addAttributeString("file_name");
1410 if (!skeleton_node->getFastAttributeString(file_name_string, skeleton_file_name)) 1411 if (!skeleton_node->getFastAttributeString(file_name_string, skeleton_file_name))
1411 { 1412 {
@@ -1532,6 +1533,8 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
1532 } 1533 }
1533 } 1534 }
1534 1535
1536 mPixelArea = LLPipeline::calcPixelArea((newMin+newMax)*0.5f, (newMax-newMin)*0.5f, *LLViewerCamera::getInstance());
1537
1535 //stretch bounding box by attachments 1538 //stretch bounding box by attachments
1536 for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); 1539 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
1537 iter != mAttachmentPoints.end(); 1540 iter != mAttachmentPoints.end();
@@ -1570,7 +1573,7 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
1570//----------------------------------------------------------------------------- 1573//-----------------------------------------------------------------------------
1571// parseSkeletonFile() 1574// parseSkeletonFile()
1572//----------------------------------------------------------------------------- 1575//-----------------------------------------------------------------------------
1573BOOL LLVOAvatar::parseSkeletonFile(const LLString& filename) 1576BOOL LLVOAvatar::parseSkeletonFile(const std::string& filename)
1574{ 1577{
1575 LLMemType mt(LLMemType::MTYPE_AVATAR); 1578 LLMemType mt(LLMemType::MTYPE_AVATAR);
1576 1579
@@ -1597,7 +1600,7 @@ BOOL LLVOAvatar::parseSkeletonFile(const LLString& filename)
1597 llerrs << "Invalid avatar skeleton file header: " << filename << llendl; 1600 llerrs << "Invalid avatar skeleton file header: " << filename << llendl;
1598 } 1601 }
1599 1602
1600 LLString version; 1603 std::string version;
1601 static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version"); 1604 static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version");
1602 if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") ) 1605 if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") )
1603 { 1606 {
@@ -1734,6 +1737,27 @@ BOOL LLVOAvatar::buildSkeleton(LLVOAvatarSkeletonInfo *info)
1734} 1737}
1735 1738
1736//----------------------------------------------------------------------------- 1739//-----------------------------------------------------------------------------
1740// LLVOAvatar::startDefaultMotions()
1741//-----------------------------------------------------------------------------
1742void LLVOAvatar::startDefaultMotions()
1743{
1744 //-------------------------------------------------------------------------
1745 // start default motions
1746 //-------------------------------------------------------------------------
1747 startMotion( ANIM_AGENT_HEAD_ROT );
1748 startMotion( ANIM_AGENT_EYE );
1749 startMotion( ANIM_AGENT_BODY_NOISE );
1750 startMotion( ANIM_AGENT_BREATHE_ROT );
1751 startMotion( ANIM_AGENT_HAND_MOTION );
1752 startMotion( ANIM_AGENT_PELVIS_FIX );
1753
1754 //-------------------------------------------------------------------------
1755 // restart any currently active motions
1756 //-------------------------------------------------------------------------
1757 processAnimationStateChanges();
1758}
1759
1760//-----------------------------------------------------------------------------
1737// LLVOAvatar::buildCharacter() 1761// LLVOAvatar::buildCharacter()
1738// Deferred initialization and rebuild of the avatar. 1762// Deferred initialization and rebuild of the avatar.
1739//----------------------------------------------------------------------------- 1763//-----------------------------------------------------------------------------
@@ -1816,7 +1840,6 @@ void LLVOAvatar::buildCharacter()
1816 if ( mIsSelf ) 1840 if ( mIsSelf )
1817 { 1841 {
1818 llerrs << "Unable to load user's avatar" << llendl; 1842 llerrs << "Unable to load user's avatar" << llendl;
1819 //set_avatar_character( &LLString(AVATAR_DEFAULT_CHAR));
1820 } 1843 }
1821 else 1844 else
1822 { 1845 {
@@ -1903,21 +1926,8 @@ void LLVOAvatar::buildCharacter()
1903 mAahMorph = getVisualParam( "Express_Open_Mouth" ); 1926 mAahMorph = getVisualParam( "Express_Open_Mouth" );
1904 } 1927 }
1905 1928
1906 //------------------------------------------------------------------------- 1929 startDefaultMotions();
1907 // start default motions 1930
1908 //-------------------------------------------------------------------------
1909 startMotion( ANIM_AGENT_HEAD_ROT );
1910 startMotion( ANIM_AGENT_EYE );
1911 startMotion( ANIM_AGENT_BODY_NOISE );
1912 startMotion( ANIM_AGENT_BREATHE_ROT );
1913 startMotion( ANIM_AGENT_HAND_MOTION );
1914 startMotion( ANIM_AGENT_PELVIS_FIX );
1915
1916 //-------------------------------------------------------------------------
1917 // restart any currently active motions
1918 //-------------------------------------------------------------------------
1919 processAnimationStateChanges();
1920
1921 mIsBuilt = TRUE; 1931 mIsBuilt = TRUE;
1922 stop_glerror(); 1932 stop_glerror();
1923 1933
@@ -1926,23 +1936,24 @@ void LLVOAvatar::buildCharacter()
1926 //------------------------------------------------------------------------- 1936 //-------------------------------------------------------------------------
1927 if (mIsSelf) 1937 if (mIsSelf)
1928 { 1938 {
1939 // *TODO: Translate
1929 gAttachBodyPartPieMenus[0] = NULL; 1940 gAttachBodyPartPieMenus[0] = NULL;
1930 gAttachBodyPartPieMenus[1] = new LLPieMenu("Right Arm >"); 1941 gAttachBodyPartPieMenus[1] = new LLPieMenu(std::string("Right Arm >"));
1931 gAttachBodyPartPieMenus[2] = new LLPieMenu("Head >"); 1942 gAttachBodyPartPieMenus[2] = new LLPieMenu(std::string("Head >"));
1932 gAttachBodyPartPieMenus[3] = new LLPieMenu("Left Arm >"); 1943 gAttachBodyPartPieMenus[3] = new LLPieMenu(std::string("Left Arm >"));
1933 gAttachBodyPartPieMenus[4] = NULL; 1944 gAttachBodyPartPieMenus[4] = NULL;
1934 gAttachBodyPartPieMenus[5] = new LLPieMenu("Left Leg >"); 1945 gAttachBodyPartPieMenus[5] = new LLPieMenu(std::string("Left Leg >"));
1935 gAttachBodyPartPieMenus[6] = new LLPieMenu("Torso >"); 1946 gAttachBodyPartPieMenus[6] = new LLPieMenu(std::string("Torso >"));
1936 gAttachBodyPartPieMenus[7] = new LLPieMenu("Right Leg >"); 1947 gAttachBodyPartPieMenus[7] = new LLPieMenu(std::string("Right Leg >"));
1937 1948
1938 gDetachBodyPartPieMenus[0] = NULL; 1949 gDetachBodyPartPieMenus[0] = NULL;
1939 gDetachBodyPartPieMenus[1] = new LLPieMenu("Right Arm >"); 1950 gDetachBodyPartPieMenus[1] = new LLPieMenu(std::string("Right Arm >"));
1940 gDetachBodyPartPieMenus[2] = new LLPieMenu("Head >"); 1951 gDetachBodyPartPieMenus[2] = new LLPieMenu(std::string("Head >"));
1941 gDetachBodyPartPieMenus[3] = new LLPieMenu("Left Arm >"); 1952 gDetachBodyPartPieMenus[3] = new LLPieMenu(std::string("Left Arm >"));
1942 gDetachBodyPartPieMenus[4] = NULL; 1953 gDetachBodyPartPieMenus[4] = NULL;
1943 gDetachBodyPartPieMenus[5] = new LLPieMenu("Left Leg >"); 1954 gDetachBodyPartPieMenus[5] = new LLPieMenu(std::string("Left Leg >"));
1944 gDetachBodyPartPieMenus[6] = new LLPieMenu("Torso >"); 1955 gDetachBodyPartPieMenus[6] = new LLPieMenu(std::string("Torso >"));
1945 gDetachBodyPartPieMenus[7] = new LLPieMenu("Right Leg >"); 1956 gDetachBodyPartPieMenus[7] = new LLPieMenu(std::string("Right Leg >"));
1946 1957
1947 for (S32 i = 0; i < 8; i++) 1958 for (S32 i = 0; i < 8; i++)
1948 { 1959 {
@@ -2342,6 +2353,15 @@ U32 LLVOAvatar::processUpdateMessage(LLMessageSystem *mesgsys,
2342 // Do base class updates... 2353 // Do base class updates...
2343 U32 retval = LLViewerObject::processUpdateMessage(mesgsys, user_data, block_num, update_type, dp); 2354 U32 retval = LLViewerObject::processUpdateMessage(mesgsys, user_data, block_num, update_type, dp);
2344 2355
2356 if(retval & LLViewerObject::INVALID_UPDATE)
2357 {
2358 if(this == gAgent.getAvatarObject())
2359 {
2360 //tell sim to cancel this update
2361 gAgent.teleportViaLocation(gAgent.getPositionGlobal());
2362 }
2363 }
2364
2345 //llinfos << getRotation() << llendl; 2365 //llinfos << getRotation() << llendl;
2346 //llinfos << getPosition() << llendl; 2366 //llinfos << getPosition() << llendl;
2347 if (update_type == OUT_FULL ) 2367 if (update_type == OUT_FULL )
@@ -2466,12 +2486,32 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2466 // animate the character 2486 // animate the character
2467 // store off last frame's root position to be consistent with camera position 2487 // store off last frame's root position to be consistent with camera position
2468 LLVector3 root_pos_last = mRoot.getWorldPosition(); 2488 LLVector3 root_pos_last = mRoot.getWorldPosition();
2469 BOOL detailed_update = updateCharacter(agent); 2489 bool detailed_update = updateCharacter(agent);
2470 bool voiceEnabled = gVoiceClient->getVoiceEnabled( mID ) && gVoiceClient->inProximalChannel(); 2490 bool voice_enabled = gVoiceClient->getVoiceEnabled( mID ) && gVoiceClient->inProximalChannel();
2491
2492 if (gNoRender)
2493 {
2494 return TRUE;
2495 }
2496
2497 idleUpdateVoiceVisualizer( voice_enabled );
2498 idleUpdateMisc( detailed_update );
2499 idleUpdateAppearanceAnimation();
2500 idleUpdateLipSync( voice_enabled );
2501 idleUpdateLoadingEffect();
2502 idleUpdateBelowWater(); // wind effect uses this
2503 idleUpdateWindEffect();
2504 idleUpdateNameTag( root_pos_last );
2505 idleUpdateRenderCost();
2506 idleUpdateTractorBeam();
2507 return TRUE;
2508}
2471 2509
2510void LLVOAvatar::idleUpdateVoiceVisualizer(bool voice_enabled)
2511{
2472 // disable voice visualizer when in mouselook 2512 // disable voice visualizer when in mouselook
2473 mVoiceVisualizer->setVoiceEnabled( voiceEnabled && !(mIsSelf && gAgent.cameraMouselook()) ); 2513 mVoiceVisualizer->setVoiceEnabled( voice_enabled && !(mIsSelf && gAgent.cameraMouselook()) );
2474 if ( voiceEnabled ) 2514 if ( voice_enabled )
2475 { 2515 {
2476 //---------------------------------------------------------------- 2516 //----------------------------------------------------------------
2477 // Only do gesture triggering for your own avatar, and only when you're in a proximal channel. 2517 // Only do gesture triggering for your own avatar, and only when you're in a proximal channel.
@@ -2491,7 +2531,7 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2491 { 2531 {
2492 if ( mCurrentGesticulationLevel != VOICE_GESTICULATION_LEVEL_OFF ) 2532 if ( mCurrentGesticulationLevel != VOICE_GESTICULATION_LEVEL_OFF )
2493 { 2533 {
2494 LLString gestureString = "unInitialized"; 2534 std::string gestureString = "unInitialized";
2495 if ( mCurrentGesticulationLevel == 0 ) { gestureString = "/voicelevel1"; } 2535 if ( mCurrentGesticulationLevel == 0 ) { gestureString = "/voicelevel1"; }
2496 else if ( mCurrentGesticulationLevel == 1 ) { gestureString = "/voicelevel2"; } 2536 else if ( mCurrentGesticulationLevel == 1 ) { gestureString = "/voicelevel2"; }
2497 else if ( mCurrentGesticulationLevel == 2 ) { gestureString = "/voicelevel3"; } 2537 else if ( mCurrentGesticulationLevel == 2 ) { gestureString = "/voicelevel3"; }
@@ -2553,7 +2593,10 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2553 mVoiceVisualizer->setVoiceSourceWorldPosition( mRoot.getWorldPosition() + headOffset ); 2593 mVoiceVisualizer->setVoiceSourceWorldPosition( mRoot.getWorldPosition() + headOffset );
2554 2594
2555 }//if ( voiceEnabled ) 2595 }//if ( voiceEnabled )
2556 2596}
2597
2598void LLVOAvatar::idleUpdateMisc(bool detailed_update)
2599{
2557 if (LLVOAvatar::sJointDebug) 2600 if (LLVOAvatar::sJointDebug)
2558 { 2601 {
2559 llinfos << getFullname() << ": joint touches: " << LLJoint::sNumTouches << " updates: " << LLJoint::sNumUpdates << llendl; 2602 llinfos << getFullname() << ": joint touches: " << LLJoint::sNumTouches << " updates: " << LLJoint::sNumUpdates << llendl;
@@ -2562,11 +2605,6 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2562 LLJoint::sNumUpdates = 0; 2605 LLJoint::sNumUpdates = 0;
2563 LLJoint::sNumTouches = 0; 2606 LLJoint::sNumTouches = 0;
2564 2607
2565 if (gNoRender)
2566 {
2567 return TRUE;
2568 }
2569
2570 // *NOTE: this is necessary for the floating name text above your head. 2608 // *NOTE: this is necessary for the floating name text above your head.
2571 if (mDrawable.notNull()) 2609 if (mDrawable.notNull())
2572 { 2610 {
@@ -2628,7 +2666,7 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2628 F32 old_angle = mImpostorAngle.mV[i]; 2666 F32 old_angle = mImpostorAngle.mV[i];
2629 F32 angle_diff = fabsf(cur_angle-old_angle); 2667 F32 angle_diff = fabsf(cur_angle-old_angle);
2630 2668
2631 if (angle_diff > 3.14159f/512.f*distance) 2669 if (angle_diff > 3.14159f/512.f*distance*mUpdatePeriod)
2632 { 2670 {
2633 mNeedsImpostorUpdate = TRUE; 2671 mNeedsImpostorUpdate = TRUE;
2634 } 2672 }
@@ -2662,7 +2700,10 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2662 { 2700 {
2663 gPipeline.markMoved(mDrawable, TRUE); 2701 gPipeline.markMoved(mDrawable, TRUE);
2664 } 2702 }
2703}
2665 2704
2705void LLVOAvatar::idleUpdateAppearanceAnimation()
2706{
2666 // update morphing params 2707 // update morphing params
2667 if (mAppearanceAnimating) 2708 if (mAppearanceAnimating)
2668 { 2709 {
@@ -2725,9 +2766,12 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2725 } 2766 }
2726 dirtyMesh(); 2767 dirtyMesh();
2727 } 2768 }
2769}
2728 2770
2771void LLVOAvatar::idleUpdateLipSync(bool voice_enabled)
2772{
2729 // Use the Lipsync_Ooh and Lipsync_Aah morphs for lip sync 2773 // Use the Lipsync_Ooh and Lipsync_Aah morphs for lip sync
2730 if ( voiceEnabled && (gVoiceClient->lipSyncEnabled()) && gVoiceClient->getIsSpeaking( mID ) ) 2774 if ( voice_enabled && (gVoiceClient->lipSyncEnabled()) && gVoiceClient->getIsSpeaking( mID ) )
2731 { 2775 {
2732 F32 ooh_morph_amount = 0.0f; 2776 F32 ooh_morph_amount = 0.0f;
2733 F32 aah_morph_amount = 0.0f; 2777 F32 aah_morph_amount = 0.0f;
@@ -2754,7 +2798,10 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2754 LLCharacter::updateVisualParams(); 2798 LLCharacter::updateVisualParams();
2755 dirtyMesh(); 2799 dirtyMesh();
2756 } 2800 }
2801}
2757 2802
2803void LLVOAvatar::idleUpdateLoadingEffect()
2804{
2758 // update visibility when avatar is partially loaded 2805 // update visibility when avatar is partially loaded
2759 if (updateIsFullyLoaded()) // changed? 2806 if (updateIsFullyLoaded()) // changed?
2760 { 2807 {
@@ -2794,10 +2841,12 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2794 setParticleSource(particle_parameters, getID()); 2841 setParticleSource(particle_parameters, getID());
2795 } 2842 }
2796 } 2843 }
2797 2844}
2798 2845
2846void LLVOAvatar::idleUpdateWindEffect()
2847{
2799 // update wind effect 2848 // update wind effect
2800 if ((LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR) >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH)) 2849 if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH))
2801 { 2850 {
2802 F32 hover_strength = 0.f; 2851 F32 hover_strength = 0.f;
2803 F32 time_delta = mRippleTimer.getElapsedTimeF32() - mRippleTimeLast; 2852 F32 time_delta = mRippleTimer.getElapsedTimeF32() - mRippleTimeLast;
@@ -2850,7 +2899,10 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2850 mRipplePhase = fmodf(mRipplePhase, F_TWO_PI); 2899 mRipplePhase = fmodf(mRipplePhase, F_TWO_PI);
2851 } 2900 }
2852 } 2901 }
2902}
2853 2903
2904void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
2905{
2854 // update chat bubble 2906 // update chat bubble
2855 //-------------------------------------------------------------------- 2907 //--------------------------------------------------------------------
2856 // draw text label over characters head 2908 // draw text label over characters head
@@ -2863,9 +2915,10 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2863 const F32 time_visible = mTimeVisible.getElapsedTimeF32(); 2915 const F32 time_visible = mTimeVisible.getElapsedTimeF32();
2864 const F32 NAME_SHOW_TIME = gSavedSettings.getF32("RenderNameShowTime"); // seconds 2916 const F32 NAME_SHOW_TIME = gSavedSettings.getF32("RenderNameShowTime"); // seconds
2865 const F32 FADE_DURATION = gSavedSettings.getF32("RenderNameFadeDuration"); // seconds 2917 const F32 FADE_DURATION = gSavedSettings.getF32("RenderNameFadeDuration"); // seconds
2918 BOOL visible_avatar = isVisible() || mNeedsAnimUpdate;
2866 BOOL visible_chat = gSavedSettings.getBOOL("UseChatBubbles") && (mChats.size() || mTyping); 2919 BOOL visible_chat = gSavedSettings.getBOOL("UseChatBubbles") && (mChats.size() || mTyping);
2867 BOOL render_name = visible_chat || 2920 BOOL render_name = visible_chat ||
2868 (visible && 2921 (visible_avatar &&
2869 ((sRenderName == RENDER_NAME_ALWAYS) || 2922 ((sRenderName == RENDER_NAME_ALWAYS) ||
2870 (sRenderName == RENDER_NAME_FADE && time_visible < NAME_SHOW_TIME))); 2923 (sRenderName == RENDER_NAME_FADE && time_visible < NAME_SHOW_TIME)));
2871 // If it's your own avatar, don't draw in mouselook, and don't 2924 // If it's your own avatar, don't draw in mouselook, and don't
@@ -3160,15 +3213,16 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
3160 mNameText = NULL; 3213 mNameText = NULL;
3161 sNumVisibleChatBubbles--; 3214 sNumVisibleChatBubbles--;
3162 } 3215 }
3216}
3163 3217
3164 shame(); 3218void LLVOAvatar::idleUpdateTractorBeam()
3165 3219{
3166 //-------------------------------------------------------------------- 3220 //--------------------------------------------------------------------
3167 // draw tractor beam when editing objects 3221 // draw tractor beam when editing objects
3168 //-------------------------------------------------------------------- 3222 //--------------------------------------------------------------------
3169 if (!mIsSelf) 3223 if (!mIsSelf)
3170 { 3224 {
3171 return TRUE; 3225 return;
3172 } 3226 }
3173 3227
3174 // This is only done for yourself (maybe it should be in the agent?) 3228 // This is only done for yourself (maybe it should be in the agent?)
@@ -3218,7 +3272,8 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
3218 } 3272 }
3219 else 3273 else
3220 { 3274 {
3221 mBeam->setPositionGlobal(gLastHitNonFloraPosGlobal + gLastHitNonFloraObjectOffset); 3275 const LLPickInfo& pick = gViewerWindow->getLastPick();
3276 mBeam->setPositionGlobal(pick.mPosGlobal);
3222 } 3277 }
3223 3278
3224 } 3279 }
@@ -3229,15 +3284,16 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
3229 mBeamTimer.reset(); 3284 mBeamTimer.reset();
3230 } 3285 }
3231 } 3286 }
3287}
3232 3288
3289void LLVOAvatar::idleUpdateBelowWater()
3290{
3233 F32 avatar_height = (F32)(getPositionGlobal().mdV[VZ]); 3291 F32 avatar_height = (F32)(getPositionGlobal().mdV[VZ]);
3234 3292
3235 F32 water_height; 3293 F32 water_height;
3236 water_height = getRegion()->getWaterHeight(); 3294 water_height = getRegion()->getWaterHeight();
3237 3295
3238 mBelowWater = avatar_height < water_height; 3296 mBelowWater = avatar_height < water_height;
3239
3240 return TRUE;
3241} 3297}
3242 3298
3243void LLVOAvatar::slamPosition() 3299void LLVOAvatar::slamPosition()
@@ -3330,32 +3386,43 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
3330 // the rest should only be done occasionally for far away avatars 3386 // the rest should only be done occasionally for far away avatars
3331 //-------------------------------------------------------------------- 3387 //--------------------------------------------------------------------
3332 3388
3333 if (!mIsSelf && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter) 3389 if (visible && !mIsSelf && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter)
3334 { 3390 {
3335 F32 impostor_area = 256.f*512.f*(8.125f - LLVOAvatar::sLODFactor*8.f); 3391 F32 impostor_area = 256.f*512.f*(8.125f - LLVOAvatar::sLODFactor*8.f);
3336 if (LLMuteList::getInstance()->isMuted(getID())) 3392 if (LLMuteList::getInstance()->isMuted(getID()))
3337 { 3393 { // muted avatars update at 16 hz
3338 mUpdatePeriod = 16; 3394 mUpdatePeriod = 16;
3339 visible = (LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0 ? TRUE : FALSE;
3340 } 3395 }
3341 else if (visible && mPixelArea <= impostor_area) 3396 else if (visible && mVisibilityRank <= LLVOAvatar::sMaxVisible * 0.25f)
3342 { 3397 { //first 25% of max visible avatars are not impostored
3343 mUpdatePeriod = llclamp((S32) sqrtf(impostor_area*4.f/mPixelArea), 2, 8); 3398 mUpdatePeriod = 1;
3344 3399 }
3345 visible = (LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0 ? TRUE : FALSE; 3400 else if (visible && mVisibilityRank > LLVOAvatar::sMaxVisible * 0.75f)
3401 { //back 25% of max visible avatars are slow updating impostors
3402 mUpdatePeriod = 8;
3403 }
3404 else if (visible && mImpostorPixelArea <= impostor_area)
3405 { // stuff in between gets an update period based on pixel area
3406 mUpdatePeriod = llclamp((S32) sqrtf(impostor_area*4.f/mImpostorPixelArea), 2, 8);
3407 }
3408 else if (visible && mVisibilityRank > LLVOAvatar::sMaxVisible * 0.25f)
3409 { // force nearby impostors in ultra crowded areas
3410 mUpdatePeriod = 2;
3346 } 3411 }
3347 else 3412 else
3348 { 3413 { // not impostored
3349 mUpdatePeriod = 1; 3414 mUpdatePeriod = 1;
3350 } 3415 }
3351 3416
3352 if (!visible) 3417 visible = (LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0 ? TRUE : FALSE;
3353 {
3354 updateMotions(LLCharacter::HIDDEN_UPDATE);
3355 return FALSE;
3356 }
3357 } 3418 }
3358 3419
3420 if (!visible)
3421 {
3422 updateMotions(LLCharacter::HIDDEN_UPDATE);
3423 return FALSE;
3424 }
3425
3359 // change animation time quanta based on avatar render load 3426 // change animation time quanta based on avatar render load
3360 if (!mIsSelf && !mIsDummy) 3427 if (!mIsSelf && !mIsDummy)
3361 { 3428 {
@@ -3726,32 +3793,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
3726 3793
3727 mRoot.updateWorldMatrixChildren(); 3794 mRoot.updateWorldMatrixChildren();
3728 3795
3729 // Send the speaker position to the spatialized voice system.
3730 if(mIsSelf)
3731 {
3732 LLMatrix3 rot;
3733 LLVector3d pos;
3734#if 1
3735 // character rotation (stable, shouldn't move with animations)
3736 rot = mRoot.getWorldRotation().getMatrix3();
3737#else
3738 // actual head rotation (moves with animations, probably a bit too much)
3739 rot.setRows(
3740 LLVector3::x_axis * mSkullp->getWorldRotation(),
3741 LLVector3::y_axis * mSkullp->getWorldRotation(),
3742 LLVector3::z_axis * mSkullp->getWorldRotation());
3743#endif
3744
3745 pos = getPositionGlobal();
3746 pos += LLVector3d(mHeadOffset);
3747
3748 // MBW -- XXX -- Setting velocity to 0 for now. May figure it out later...
3749 gVoiceClient->setAvatarPosition(
3750 pos, // position
3751 LLVector3::zero, // velocity
3752 rot); // rotation matrix
3753 }
3754
3755 if (!mDebugText.size() && mText.notNull()) 3796 if (!mDebugText.size() && mText.notNull())
3756 { 3797 {
3757 mText->markDead(); 3798 mText->markDead();
@@ -3967,7 +4008,7 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
3967 mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY); 4008 mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
3968 } 4009 }
3969 4010
3970 if (LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR) <= 0) 4011 if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) <= 0)
3971 { 4012 {
3972 if (mNeedsSkin) 4013 if (mNeedsSkin)
3973 { 4014 {
@@ -4222,7 +4263,23 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color)
4222 LLGLEnable test(GL_ALPHA_TEST); 4263 LLGLEnable test(GL_ALPHA_TEST);
4223 gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.f); 4264 gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.f);
4224 4265
4225 gGL.color4f(1,1,1,1); 4266 F32 blend = gFrameTimeSeconds - mFadeTime;
4267
4268 LLGLState gl_blend(GL_BLEND, blend < 1.f ? TRUE : FALSE);
4269 gGL.setSceneBlendType(LLRender::BT_ALPHA);
4270
4271 F32 alpha;
4272 if (mVisibilityRank >= (U32) LLVOAvatar::sMaxVisible)
4273 { //fade out
4274 alpha = 1.f - llmin(blend, 1.f);
4275 }
4276 else
4277 { //fade in
4278 alpha = llmin(blend, 1.f);
4279 }
4280
4281 color.mV[3] = (U8) (alpha*255);
4282
4226 gGL.color4ubv(color.mV); 4283 gGL.color4ubv(color.mV);
4227 mImpostor.bindTexture(); 4284 mImpostor.bindTexture();
4228 gGL.begin(LLVertexBuffer::QUADS); 4285 gGL.begin(LLVertexBuffer::QUADS);
@@ -4348,7 +4405,6 @@ void LLVOAvatar::updateTextures(LLAgent &agent)
4348 4405
4349 const LLTextureEntry *te = getTE(i); 4406 const LLTextureEntry *te = getTE(i);
4350 F32 texel_area_ratio = fabs(te->mScaleS * te->mScaleT); 4407 F32 texel_area_ratio = fabs(te->mScaleS * te->mScaleT);
4351// BOOL boost_aux = (imagep->needsAux() && (!imagep->mFullWidth || !imagep->mFullHeight));
4352 S32 boost_level = mIsSelf ? LLViewerImage::BOOST_AVATAR_BAKED_SELF : LLViewerImage::BOOST_AVATAR_BAKED; 4408 S32 boost_level = mIsSelf ? LLViewerImage::BOOST_AVATAR_BAKED_SELF : LLViewerImage::BOOST_AVATAR_BAKED;
4353 4409
4354 // Spam if this is a baked texture, not set to default image, without valid host info 4410 // Spam if this is a baked texture, not set to default image, without valid host info
@@ -4358,7 +4414,7 @@ void LLVOAvatar::updateTextures(LLAgent &agent)
4358 { 4414 {
4359 llwarns << "LLVOAvatar::updateTextures No host for texture " 4415 llwarns << "LLVOAvatar::updateTextures No host for texture "
4360 << imagep->getID() << " for avatar " 4416 << imagep->getID() << " for avatar "
4361 << (mIsSelf ? "<myself>" : getID().asString().c_str()) 4417 << (mIsSelf ? "<myself>" : getID().asString())
4362 << " on host " << getRegion()->getHost() << llendl; 4418 << " on host " << getRegion()->getHost() << llendl;
4363 } 4419 }
4364 4420
@@ -5440,7 +5496,7 @@ BOOL LLVOAvatar::loadMeshNodes()
5440 iter != sAvatarInfo->mMeshInfoList.end(); iter++) 5496 iter != sAvatarInfo->mMeshInfoList.end(); iter++)
5441 { 5497 {
5442 LLVOAvatarInfo::LLVOAvatarMeshInfo *info = *iter; 5498 LLVOAvatarInfo::LLVOAvatarMeshInfo *info = *iter;
5443 LLString &type = info->mType; 5499 std::string &type = info->mType;
5444 S32 lod = info->mLOD; 5500 S32 lod = info->mLOD;
5445 5501
5446 LLViewerJointMesh* mesh = NULL; 5502 LLViewerJointMesh* mesh = NULL;
@@ -5640,7 +5696,7 @@ BOOL LLVOAvatar::loadMeshNodes()
5640 } 5696 }
5641 5697
5642 // Multimap insert 5698 // Multimap insert
5643 mMeshes.insert(std::pair<LLString, LLPolyMesh*>(info->mMeshFileName, poly_mesh)); 5699 mMeshes.insert(std::make_pair(info->mMeshFileName, poly_mesh));
5644 5700
5645 mesh->setMesh( poly_mesh ); 5701 mesh->setMesh( poly_mesh );
5646 5702
@@ -5718,7 +5774,7 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent)
5718 LLVector3 center = (ext[1] + ext[0]) * 0.5f; 5774 LLVector3 center = (ext[1] + ext[0]) * 0.5f;
5719 LLVector3 size = (ext[1]-ext[0])*0.5f; 5775 LLVector3 size = (ext[1]-ext[0])*0.5f;
5720 5776
5721 mPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance()); 5777 mImpostorPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance());
5722 5778
5723 F32 range = mDrawable->mDistanceWRTCamera; 5779 F32 range = mDrawable->mDistanceWRTCamera;
5724 5780
@@ -6167,9 +6223,11 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
6167 stopMotionFromSource(viewer_object->getID()); 6223 stopMotionFromSource(viewer_object->getID());
6168 LLFollowCamMgr::setCameraActive(viewer_object->getID(), FALSE); 6224 LLFollowCamMgr::setCameraActive(viewer_object->getID(), FALSE);
6169 6225
6170 for (S32 i = 0; i < (S32)viewer_object->mChildList.size(); i++) 6226 LLViewerObject::const_child_list_t& child_list = viewer_object->getChildren();
6227 for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
6228 iter != child_list.end(); iter++)
6171 { 6229 {
6172 LLViewerObject* child_objectp = viewer_object->mChildList[i]; 6230 LLViewerObject* child_objectp = *iter;
6173 // the simulator should automatically handle 6231 // the simulator should automatically handle
6174 // permissions revocation 6232 // permissions revocation
6175 6233
@@ -6211,6 +6269,10 @@ void LLVOAvatar::sitOnObject(LLViewerObject *sit_object)
6211 mDrawable->mXform.setPosition(rel_pos); 6269 mDrawable->mXform.setPosition(rel_pos);
6212 mDrawable->mXform.setRotation(mDrawable->getWorldRotation() * inv_obj_rot); 6270 mDrawable->mXform.setRotation(mDrawable->getWorldRotation() * inv_obj_rot);
6213 6271
6272 //in case the viewerobject is not updated in time
6273 mDrawable->getVObj()->setPosition(sit_object->getWorldPosition()) ;
6274 mDrawable->getVObj()->setRotation(sit_object->getWorldRotation()) ;
6275
6214 gPipeline.markMoved(mDrawable, TRUE); 6276 gPipeline.markMoved(mDrawable, TRUE);
6215 mIsSitting = TRUE; 6277 mIsSitting = TRUE;
6216 mRoot.getXform()->setParent(&sit_object->mDrawable->mXform); // LLVOAvatar::sitOnObject 6278 mRoot.getXform()->setParent(&sit_object->mDrawable->mXform); // LLVOAvatar::sitOnObject
@@ -6252,9 +6314,11 @@ void LLVOAvatar::getOffObject()
6252 stopMotionFromSource(sit_object->getID()); 6314 stopMotionFromSource(sit_object->getID());
6253 LLFollowCamMgr::setCameraActive(sit_object->getID(), FALSE); 6315 LLFollowCamMgr::setCameraActive(sit_object->getID(), FALSE);
6254 6316
6255 for (S32 i = 0; i < (S32)sit_object->mChildList.size(); i++) 6317 LLViewerObject::const_child_list_t& child_list = sit_object->getChildren();
6318 for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
6319 iter != child_list.end(); iter++)
6256 { 6320 {
6257 LLViewerObject* child_objectp = sit_object->mChildList[i]; 6321 LLViewerObject* child_objectp = *iter;
6258 6322
6259 stopMotionFromSource(child_objectp->getID()); 6323 stopMotionFromSource(child_objectp->getID());
6260 LLFollowCamMgr::setCameraActive(child_objectp->getID(), FALSE); 6324 LLFollowCamMgr::setCameraActive(child_objectp->getID(), FALSE);
@@ -6267,7 +6331,11 @@ void LLVOAvatar::getOffObject()
6267 6331
6268 // set *local* position based on last *world* position, since we're unparenting the avatar 6332 // set *local* position based on last *world* position, since we're unparenting the avatar
6269 mDrawable->mXform.setPosition(cur_position_world); 6333 mDrawable->mXform.setPosition(cur_position_world);
6270 mDrawable->mXform.setRotation(cur_rotation_world); 6334 mDrawable->mXform.setRotation(cur_rotation_world);
6335
6336 //in case the viewerobject is not updated from sim in time
6337 mDrawable->getVObj()->setPosition(cur_position_world);
6338 mDrawable->getVObj()->setRotation(cur_rotation_world);
6271 6339
6272 gPipeline.markMoved(mDrawable, TRUE); 6340 gPipeline.markMoved(mDrawable, TRUE);
6273 6341
@@ -6356,7 +6424,7 @@ LLViewerObject* LLVOAvatar::getWornAttachment( const LLUUID& inv_item_id )
6356 return NULL; 6424 return NULL;
6357} 6425}
6358 6426
6359const LLString LLVOAvatar::getAttachedPointName(const LLUUID& inv_item_id) 6427const std::string LLVOAvatar::getAttachedPointName(const LLUUID& inv_item_id)
6360{ 6428{
6361 for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); 6429 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
6362 iter != mAttachmentPoints.end(); ) 6430 iter != mAttachmentPoints.end(); )
@@ -6365,11 +6433,11 @@ const LLString LLVOAvatar::getAttachedPointName(const LLUUID& inv_item_id)
6365 LLViewerJointAttachment* attachment = curiter->second; 6433 LLViewerJointAttachment* attachment = curiter->second;
6366 if( attachment->getItemID() == inv_item_id ) 6434 if( attachment->getItemID() == inv_item_id )
6367 { 6435 {
6368 return (LLString)attachment->getName(); 6436 return attachment->getName();
6369 } 6437 }
6370 } 6438 }
6371 6439
6372 return LLString::null; 6440 return LLStringUtil::null;
6373} 6441}
6374 6442
6375 6443
@@ -6453,7 +6521,7 @@ void LLVOAvatar::updateComposites()
6453 } 6521 }
6454} 6522}
6455 6523
6456LLColor4 LLVOAvatar::getGlobalColor( const LLString& color_name ) 6524LLColor4 LLVOAvatar::getGlobalColor( const std::string& color_name )
6457{ 6525{
6458 if( color_name=="skin_color" && mTexSkinColor ) 6526 if( color_name=="skin_color" && mTexSkinColor )
6459 { 6527 {
@@ -6718,7 +6786,9 @@ void LLVOAvatar::dumpTotalLocalTextureByteCount()
6718 6786
6719BOOL LLVOAvatar::isVisible() 6787BOOL LLVOAvatar::isVisible()
6720{ 6788{
6721 return mDrawable.notNull() && (mDrawable->isVisible() || mIsDummy); 6789 return mDrawable.notNull()
6790 && (mDrawable->isVisible() || mIsDummy)
6791 && (mVisibilityRank < (U32) sMaxVisible || gFrameTimeSeconds - mFadeTime < 1.f);
6722} 6792}
6723 6793
6724 6794
@@ -7152,9 +7222,8 @@ void LLVOAvatar::updateMeshTextures()
7152 { 7222 {
7153 mHeadBakedLoaded = FALSE; 7223 mHeadBakedLoaded = FALSE;
7154 mHeadMaskDiscard = -1; 7224 mHeadMaskDiscard = -1;
7155 baked->setNeedsAux(TRUE); 7225 baked->setLoadedCallback(onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ));
7156 baked->setLoadedCallback(onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, new LLTextureMaskData( mID )); 7226 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, FALSE, new LLUUID( mID ) );
7157 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, new LLUUID( mID ) );
7158 } 7227 }
7159 } 7228 }
7160 else 7229 else
@@ -7203,9 +7272,8 @@ void LLVOAvatar::updateMeshTextures()
7203 { 7272 {
7204 mUpperBakedLoaded = FALSE; 7273 mUpperBakedLoaded = FALSE;
7205 mUpperMaskDiscard = -1; 7274 mUpperMaskDiscard = -1;
7206 baked->setNeedsAux(TRUE); 7275 baked->setLoadedCallback(onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ));
7207 baked->setLoadedCallback(onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, new LLTextureMaskData( mID )); 7276 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, FALSE, new LLUUID( mID ) );
7208 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, new LLUUID( mID ) );
7209 } 7277 }
7210 } 7278 }
7211 else 7279 else
@@ -7251,9 +7319,8 @@ void LLVOAvatar::updateMeshTextures()
7251 { 7319 {
7252 mLowerBakedLoaded = FALSE; 7320 mLowerBakedLoaded = FALSE;
7253 mLowerMaskDiscard = -1; 7321 mLowerMaskDiscard = -1;
7254 baked->setNeedsAux(TRUE); 7322 baked->setLoadedCallback(onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ));
7255 baked->setLoadedCallback(onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, new LLTextureMaskData( mID )); 7323 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, FALSE, new LLUUID( mID ) );
7256 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, new LLUUID( mID ) );
7257 } 7324 }
7258 } 7325 }
7259 else 7326 else
@@ -7297,7 +7364,7 @@ void LLVOAvatar::updateMeshTextures()
7297 else 7364 else
7298 { 7365 {
7299 mEyesBakedLoaded = FALSE; 7366 mEyesBakedLoaded = FALSE;
7300 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, new LLUUID( mID ) ); 7367 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, FALSE, new LLUUID( mID ) );
7301 } 7368 }
7302 } 7369 }
7303 else 7370 else
@@ -7340,7 +7407,7 @@ void LLVOAvatar::updateMeshTextures()
7340 else 7407 else
7341 { 7408 {
7342 mSkirtBakedLoaded = FALSE; 7409 mSkirtBakedLoaded = FALSE;
7343 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, new LLUUID( mID ) ); 7410 baked->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, FALSE, new LLUUID( mID ) );
7344 } 7411 }
7345 } 7412 }
7346 else 7413 else
@@ -7441,7 +7508,7 @@ void LLVOAvatar::setLocalTexture( ELocTexIndex idx, LLViewerImage* tex, BOOL bak
7441 } 7508 }
7442 else 7509 else
7443 { 7510 {
7444 tex->setLoadedCallback( onLocalTextureLoaded, desired_discard, TRUE, new LLAvatarTexData(getID(), idx) ); 7511 tex->setLoadedCallback( onLocalTextureLoaded, desired_discard, TRUE, FALSE, new LLAvatarTexData(getID(), idx) );
7445 } 7512 }
7446 } 7513 }
7447 tex->setMinDiscardLevel(desired_discard); 7514 tex->setMinDiscardLevel(desired_discard);
@@ -7962,7 +8029,7 @@ LLColor4 LLVOAvatar::getClothesColor( ETextureIndex te )
7962 8029
7963 8030
7964 8031
7965void LLVOAvatar::dumpAvatarTEs( const char* context ) 8032void LLVOAvatar::dumpAvatarTEs( const std::string& context )
7966{ 8033{
7967 llinfos << (mIsSelf ? "Self: " : "Other: ") << context << llendl; 8034 llinfos << (mIsSelf ? "Self: " : "Other: ") << context << llendl;
7968 for( S32 i=0; i<TEX_NUM_ENTRIES; i++ ) 8035 for( S32 i=0; i<TEX_NUM_ENTRIES; i++ )
@@ -8242,9 +8309,12 @@ LLBBox LLVOAvatar::getHUDBBox()
8242 bbox.addPointLocal(hud_object->getPosition()); 8309 bbox.addPointLocal(hud_object->getPosition());
8243 // add rotated bounding box for attached object 8310 // add rotated bounding box for attached object
8244 bbox.addBBoxAgent(hud_object->getBoundingBoxAgent()); 8311 bbox.addBBoxAgent(hud_object->getBoundingBoxAgent());
8245 for (U32 i = 0; i < hud_object->mChildList.size(); i++) 8312 LLViewerObject::const_child_list_t& child_list = hud_object->getChildren();
8313 for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
8314 iter != child_list.end(); iter++)
8246 { 8315 {
8247 bbox.addBBoxAgent(hud_object->mChildList[i]->getBoundingBoxAgent()); 8316 LLViewerObject* child_objectp = *iter;
8317 bbox.addBBoxAgent(child_objectp->getBoundingBoxAgent());
8248 } 8318 }
8249 } 8319 }
8250 } 8320 }
@@ -8277,41 +8347,38 @@ void LLVOAvatar::onFirstTEMessageReceived()
8277 { 8347 {
8278 mLastHeadBakedID = getTEImage( TEX_HEAD_BAKED )->getID(); 8348 mLastHeadBakedID = getTEImage( TEX_HEAD_BAKED )->getID();
8279 LLViewerImage* image = getTEImage( TEX_HEAD_BAKED ); 8349 LLViewerImage* image = getTEImage( TEX_HEAD_BAKED );
8280 image->setNeedsAux(TRUE); 8350 image->setLoadedCallback( onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ));
8281 image->setLoadedCallback( onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, new LLTextureMaskData( mID )); 8351 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, FALSE, new LLUUID( mID ) );
8282 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, new LLUUID( mID ) );
8283 } 8352 }
8284 8353
8285 if( upper_baked ) 8354 if( upper_baked )
8286 { 8355 {
8287 mLastUpperBodyBakedID = getTEImage( TEX_UPPER_BAKED )->getID(); 8356 mLastUpperBodyBakedID = getTEImage( TEX_UPPER_BAKED )->getID();
8288 LLViewerImage* image = getTEImage( TEX_UPPER_BAKED ); 8357 LLViewerImage* image = getTEImage( TEX_UPPER_BAKED );
8289 image->setNeedsAux(TRUE); 8358 image->setLoadedCallback( onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ));
8290 image->setLoadedCallback( onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, new LLTextureMaskData( mID )); 8359 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, FALSE, new LLUUID( mID ) );
8291 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, new LLUUID( mID ) );
8292 } 8360 }
8293 8361
8294 if( lower_baked ) 8362 if( lower_baked )
8295 { 8363 {
8296 mLastLowerBodyBakedID = getTEImage( TEX_LOWER_BAKED )->getID(); 8364 mLastLowerBodyBakedID = getTEImage( TEX_LOWER_BAKED )->getID();
8297 LLViewerImage* image = getTEImage( TEX_LOWER_BAKED ); 8365 LLViewerImage* image = getTEImage( TEX_LOWER_BAKED );
8298 image->setNeedsAux(TRUE); 8366 image->setLoadedCallback( onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ));
8299 image->setLoadedCallback( onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, new LLTextureMaskData( mID )); 8367 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, FALSE, new LLUUID( mID ) );
8300 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, new LLUUID( mID ) );
8301 } 8368 }
8302 8369
8303 if( eyes_baked ) 8370 if( eyes_baked )
8304 { 8371 {
8305 mLastEyesBakedID = getTEImage( TEX_EYES_BAKED )->getID(); 8372 mLastEyesBakedID = getTEImage( TEX_EYES_BAKED )->getID();
8306 LLViewerImage* image = getTEImage( TEX_EYES_BAKED ); 8373 LLViewerImage* image = getTEImage( TEX_EYES_BAKED );
8307 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, new LLUUID( mID ) ); 8374 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, FALSE, new LLUUID( mID ) );
8308 } 8375 }
8309 8376
8310 if( skirt_baked ) 8377 if( skirt_baked )
8311 { 8378 {
8312 mLastSkirtBakedID = getTEImage( TEX_SKIRT_BAKED )->getID(); 8379 mLastSkirtBakedID = getTEImage( TEX_SKIRT_BAKED )->getID();
8313 LLViewerImage* image = getTEImage( TEX_SKIRT_BAKED ); 8380 LLViewerImage* image = getTEImage( TEX_SKIRT_BAKED );
8314 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, new LLUUID( mID ) ); 8381 image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, FALSE, new LLUUID( mID ) );
8315 } 8382 }
8316 8383
8317 updateMeshTextures(); 8384 updateMeshTextures();
@@ -8323,6 +8390,12 @@ void LLVOAvatar::onFirstTEMessageReceived()
8323//----------------------------------------------------------------------------- 8390//-----------------------------------------------------------------------------
8324void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) 8391void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
8325{ 8392{
8393 if (gSavedSettings.getBOOL("BlockAvatarAppearanceMessages"))
8394 {
8395 llwarns << "Blocking AvatarAppearance message" << llendl;
8396 return;
8397 }
8398
8326 LLMemType mt(LLMemType::MTYPE_AVATAR); 8399 LLMemType mt(LLMemType::MTYPE_AVATAR);
8327 8400
8328// llinfos << "processAvatarAppearance start " << mID << llendl; 8401// llinfos << "processAvatarAppearance start " << mID << llendl;
@@ -8780,8 +8853,8 @@ void LLVOAvatar::dumpArchetypeXML( void* )
8780 // only body parts, not clothing. 8853 // only body parts, not clothing.
8781 for( S32 type = WT_SHAPE; type <= WT_EYES; type++ ) 8854 for( S32 type = WT_SHAPE; type <= WT_EYES; type++ )
8782 { 8855 {
8783 const char* wearable_name = LLWearable::typeToTypeName( (EWearableType) type ); 8856 const std::string& wearable_name = LLWearable::typeToTypeName( (EWearableType) type );
8784 apr_file_printf( file, "\n\t\t<!-- wearable: %s -->\n", wearable_name ); 8857 apr_file_printf( file, "\n\t\t<!-- wearable: %s -->\n", wearable_name.c_str() );
8785 8858
8786 for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) 8859 for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() )
8787 { 8860 {
@@ -8801,9 +8874,9 @@ void LLVOAvatar::dumpArchetypeXML( void* )
8801 LLViewerImage* te_image = avatar->getTEImage( te ); 8874 LLViewerImage* te_image = avatar->getTEImage( te );
8802 if( te_image ) 8875 if( te_image )
8803 { 8876 {
8804 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 8877 std::string uuid_str;
8805 te_image->getID().toString( uuid_str ); 8878 te_image->getID().toString( uuid_str );
8806 apr_file_printf( file, "\t\t<texture te=\"%i\" uuid=\"%s\"/>\n", te, uuid_str); 8879 apr_file_printf( file, "\t\t<texture te=\"%i\" uuid=\"%s\"/>\n", te, uuid_str.c_str());
8807 } 8880 }
8808 } 8881 }
8809 } 8882 }
@@ -8814,6 +8887,42 @@ void LLVOAvatar::dumpArchetypeXML( void* )
8814} 8887}
8815 8888
8816 8889
8890U32 LLVOAvatar::getVisibilityRank()
8891{
8892 return mVisibilityRank;
8893}
8894
8895void LLVOAvatar::setVisibilityRank(U32 rank)
8896{
8897 BOOL stale = gFrameTimeSeconds - mLastFadeTime > 10.f;
8898
8899 //only raise visibility rank or trigger a fade out every 10 seconds
8900 if (mVisibilityRank >= (U32) LLVOAvatar::sMaxVisible && rank < (U32) LLVOAvatar::sMaxVisible ||
8901 (stale && mVisibilityRank < (U32) LLVOAvatar::sMaxVisible && rank >= (U32) LLVOAvatar::sMaxVisible))
8902 { //remember the time we became visible/invisible based on visibility rank
8903 mVisibilityRank = rank;
8904 mLastFadeTime = gFrameTimeSeconds;
8905 mLastFadeDistance = mDrawable->mDistanceWRTCamera;
8906
8907 F32 blend = gFrameTimeSeconds - mFadeTime;
8908 mFadeTime = gFrameTimeSeconds;
8909 if (blend < 1.f)
8910 { //move the blend time back if a blend is already in progress (prevent flashes)
8911 mFadeTime -= 1.f-blend;
8912 }
8913 }
8914 else if (stale)
8915 {
8916 mLastFadeTime = gFrameTimeSeconds;
8917 mLastFadeDistance = mDrawable->mDistanceWRTCamera;
8918 mVisibilityRank = rank;
8919 }
8920 else
8921 {
8922 mVisibilityRank = llmin(mVisibilityRank, rank);
8923 }
8924}
8925
8817// Assumes LLVOAvatar::sInstances has already been sorted. 8926// Assumes LLVOAvatar::sInstances has already been sorted.
8818S32 LLVOAvatar::getUnbakedPixelAreaRank() 8927S32 LLVOAvatar::getUnbakedPixelAreaRank()
8819{ 8928{
@@ -8843,8 +8952,8 @@ void LLVOAvatar::cullAvatarsByPixelArea()
8843 std::sort(LLCharacter::sInstances.begin(), LLCharacter::sInstances.end(), CompareScreenAreaGreater()); 8952 std::sort(LLCharacter::sInstances.begin(), LLCharacter::sInstances.end(), CompareScreenAreaGreater());
8844 8953
8845 // Update the avatars that have changed status 8954 // Update the avatars that have changed status
8846 S32 rank = 1; 8955 S32 comp_rank = 1;
8847 8956 U32 rank = 0;
8848 for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); 8957 for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
8849 iter != LLCharacter::sInstances.end(); ++iter) 8958 iter != LLCharacter::sInstances.end(); ++iter)
8850 { 8959 {
@@ -8860,8 +8969,8 @@ void LLVOAvatar::cullAvatarsByPixelArea()
8860 } 8969 }
8861 else 8970 else
8862 { 8971 {
8863 culled = (rank > LLVOAvatar::sMaxOtherAvatarsToComposite) || (inst->mPixelArea < MIN_PIXEL_AREA_FOR_COMPOSITE); 8972 culled = (comp_rank > LLVOAvatar::sMaxOtherAvatarsToComposite) || (inst->mPixelArea < MIN_PIXEL_AREA_FOR_COMPOSITE);
8864 rank++; 8973 comp_rank++;
8865 } 8974 }
8866 8975
8867 if( inst->mCulled != culled ) 8976 if( inst->mCulled != culled )
@@ -8872,6 +8981,15 @@ void LLVOAvatar::cullAvatarsByPixelArea()
8872 8981
8873 inst->updateMeshTextures(); 8982 inst->updateMeshTextures();
8874 } 8983 }
8984
8985 if (inst->isSelf())
8986 {
8987 inst->setVisibilityRank(0);
8988 }
8989 else if (inst->mDrawable.notNull() && inst->mDrawable->isVisible())
8990 {
8991 inst->setVisibilityRank(rank++);
8992 }
8875 } 8993 }
8876 8994
8877 if( LLVOAvatar::areAllNearbyInstancesBaked() ) 8995 if( LLVOAvatar::areAllNearbyInstancesBaked() )
@@ -8984,7 +9102,7 @@ void LLVOAvatar::dumpLocalTextures()
8984{ 9102{
8985 llinfos << "Local Textures:" << llendl; 9103 llinfos << "Local Textures:" << llendl;
8986 9104
8987 char* names[] = { 9105 const char* names[] = {
8988 "Shirt ", 9106 "Shirt ",
8989 "UpperTatoo", 9107 "UpperTatoo",
8990 "Pants ", 9108 "Pants ",
@@ -9434,7 +9552,7 @@ BOOL LLVOAvatarInfo::parseXmlColorNodes(LLXmlTreeNode* root)
9434 color_node; 9552 color_node;
9435 color_node = root->getNextNamedChild()) 9553 color_node = root->getNextNamedChild())
9436 { 9554 {
9437 LLString global_color_name; 9555 std::string global_color_name;
9438 static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); 9556 static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
9439 if (color_node->getFastAttributeString( name_string, global_color_name ) ) 9557 if (color_node->getFastAttributeString( name_string, global_color_name ) )
9440 { 9558 {
@@ -9574,9 +9692,9 @@ void LLVOAvatar::updateRegion(LLViewerRegion *regionp)
9574 } 9692 }
9575} 9693}
9576 9694
9577LLString LLVOAvatar::getFullname() const 9695std::string LLVOAvatar::getFullname() const
9578{ 9696{
9579 LLString name; 9697 std::string name;
9580 9698
9581 LLNameValue* first = getNVPair("FirstName"); 9699 LLNameValue* first = getNVPair("FirstName");
9582 LLNameValue* last = getNVPair("LastName"); 9700 LLNameValue* last = getNVPair("LastName");
@@ -9681,7 +9799,7 @@ BOOL LLVOAvatar::updateLOD()
9681 } 9799 }
9682 9800
9683 updateVisibility(); 9801 updateVisibility();
9684 9802
9685 return res; 9803 return res;
9686} 9804}
9687 9805
@@ -9835,15 +9953,26 @@ U32 calc_shame(LLVOVolume* volume, std::set<LLUUID> &textures)
9835 9953
9836 shame += invisi + shiny + glow + alpha*4 + flexi*8 + animtex*4 + particles*16+bump*4+scale+planar; 9954 shame += invisi + shiny + glow + alpha*4 + flexi*8 + animtex*4 + particles*16+bump*4+scale+planar;
9837 9955
9838 for (U32 i = 0; i < drawablep->getChildCount(); ++i) 9956 LLViewerObject::const_child_list_t& child_list = volume->getChildren();
9957 for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
9958 iter != child_list.end(); iter++)
9839 { 9959 {
9840 shame += calc_shame(drawablep->getChild(i)->getVOVolume(), textures); 9960 LLViewerObject* child_objectp = *iter;
9961 LLDrawable* child_drawablep = child_objectp->mDrawable;
9962 if (child_drawablep)
9963 {
9964 LLVOVolume* child_volumep = child_drawablep->getVOVolume();
9965 if (child_volumep)
9966 {
9967 shame += calc_shame(child_volumep, textures);
9968 }
9969 }
9841 } 9970 }
9842 9971
9843 return shame; 9972 return shame;
9844} 9973}
9845 9974
9846void LLVOAvatar::shame() 9975void LLVOAvatar::idleUpdateRenderCost()
9847{ 9976{
9848 if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHAME)) 9977 if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHAME))
9849 { 9978 {
@@ -9884,3 +10013,4 @@ void LLVOAvatar::shame()
9884 mText->setColor(LLColor4(red,green,0,1)); 10013 mText->setColor(LLColor4(red,green,0,1));
9885} 10014}
9886 10015
10016