summaryrefslogtreecommitdiff
path: root/indra/newview/llvoavatar.cpp
diff options
context:
space:
mode:
authorSimon Linden <simon@lindenlab.com>2013-03-19 16:20:53 -0700
committerSimon Linden <simon@lindenlab.com>2013-03-19 16:20:53 -0700
commitd5561a1ada5cf171c8e281e910a7e989496c3705 (patch)
tree456cbb2374242d5508cc13165c876cd0672f6cd0 /indra/newview/llvoavatar.cpp
parenta8245c51b9cd6fac1d26932dbb1fcf052f00da18 (diff)
parent04e78ce4fdd3bbc0e4daa1daabbff2de1c425601 (diff)
Merge in viewer-beta to get CHUI code
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rwxr-xr-xindra/newview/llvoavatar.cpp634
1 files changed, 299 insertions, 335 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 4efd59685e..7d099d690a 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -62,6 +62,7 @@
#include "llhudmanager.h"
#include "llhudnametag.h"
#include "llhudtext.h" // for mText/mDebugText
+#include "llinitparam.h"
#include "llkeyframefallmotion.h"
#include "llkeyframestandmotion.h"
#include "llkeyframewalkmotion.h"
@@ -191,6 +192,9 @@ const S32 MAX_BUBBLE_CHAT_LENGTH = DB_CHAT_MSG_STR_LEN;
const S32 MAX_BUBBLE_CHAT_UTTERANCES = 12;
const F32 CHAT_FADE_TIME = 8.0;
const F32 BUBBLE_CHAT_TIME = CHAT_FADE_TIME * 3.f;
+const F32 NAMETAG_UPDATE_THRESHOLD = 0.3f;
+const F32 NAMETAG_VERTICAL_SCREEN_OFFSET = 25.f;
+const F32 NAMETAG_VERT_OFFSET_WEIGHT = 0.17f;
const LLColor4 DUMMY_COLOR = LLColor4(0.5,0.5,0.5,1.0);
@@ -222,55 +226,62 @@ struct LLTextureMaskData
**/
//------------------------------------------------------------------------
-// LLVOBoneInfo
+// LLVOAvatarBoneInfo
// Trans/Scale/Rot etc. info about each avatar bone. Used by LLVOAvatarSkeleton.
//------------------------------------------------------------------------
-class LLVOAvatarBoneInfo
+struct LLVOAvatarCollisionVolumeInfo : public LLInitParam::Block<LLVOAvatarCollisionVolumeInfo>
{
- friend class LLVOAvatar;
- friend class LLVOAvatarSkeletonInfo;
-public:
- LLVOAvatarBoneInfo() : mIsJoint(FALSE) {}
- ~LLVOAvatarBoneInfo()
+ LLVOAvatarCollisionVolumeInfo()
+ : name("name"),
+ pos("pos"),
+ rot("rot"),
+ scale("scale")
+ {}
+
+ Mandatory<std::string> name;
+ Mandatory<LLVector3> pos,
+ rot,
+ scale;
+};
+
+struct LLVOAvatarChildJoint : public LLInitParam::ChoiceBlock<LLVOAvatarChildJoint>
{
- std::for_each(mChildList.begin(), mChildList.end(), DeletePointer());
- }
- BOOL parseXml(LLXmlTreeNode* node);
+ Alternative<Lazy<struct LLVOAvatarBoneInfo, IS_A_BLOCK> > bone;
+ Alternative<LLVOAvatarCollisionVolumeInfo> collision_volume;
-private:
- std::string mName;
- BOOL mIsJoint;
- LLVector3 mPos;
- LLVector3 mRot;
- LLVector3 mScale;
- LLVector3 mPivot;
- typedef std::vector<LLVOAvatarBoneInfo*> child_list_t;
- child_list_t mChildList;
+ LLVOAvatarChildJoint()
+ : bone("bone"),
+ collision_volume("collision_volume")
+ {}
+};
+
+struct LLVOAvatarBoneInfo : public LLInitParam::Block<LLVOAvatarBoneInfo, LLVOAvatarCollisionVolumeInfo>
+{
+ LLVOAvatarBoneInfo()
+ : pivot("pivot")
+ {}
+
+ Mandatory<LLVector3> pivot;
+ Multiple<LLVOAvatarChildJoint> children;
};
//------------------------------------------------------------------------
// LLVOAvatarSkeletonInfo
// Overall avatar skeleton
//------------------------------------------------------------------------
-class LLVOAvatarSkeletonInfo
+struct LLVOAvatarSkeletonInfo : public LLInitParam::Block<LLVOAvatarSkeletonInfo>
{
- friend class LLVOAvatar;
-public:
- LLVOAvatarSkeletonInfo() :
- mNumBones(0), mNumCollisionVolumes(0) {}
- ~LLVOAvatarSkeletonInfo()
- {
- std::for_each(mBoneInfoList.begin(), mBoneInfoList.end(), DeletePointer());
- }
- BOOL parseXml(LLXmlTreeNode* node);
- S32 getNumBones() const { return mNumBones; }
- S32 getNumCollisionVolumes() const { return mNumCollisionVolumes; }
+ LLVOAvatarSkeletonInfo()
+ : skeleton_root(""),
+ num_bones("num_bones"),
+ num_collision_volumes("num_collision_volumes"),
+ version("version")
+ {}
-private:
- S32 mNumBones;
- S32 mNumCollisionVolumes;
- typedef std::vector<LLVOAvatarBoneInfo*> bone_info_list_t;
- bone_info_list_t mBoneInfoList;
+ Mandatory<std::string> version;
+ Mandatory<S32> num_bones,
+ num_collision_volumes;
+ Mandatory<LLVOAvatarChildJoint> skeleton_root;
};
//-----------------------------------------------------------------------------
@@ -595,7 +606,7 @@ private:
// Static Data
//-----------------------------------------------------------------------------
LLXmlTree LLVOAvatar::sXMLTree;
-LLXmlTree LLVOAvatar::sSkeletonXMLTree;
+LLXMLNodePtr LLVOAvatar::sSkeletonXMLTree;
LLVOAvatarSkeletonInfo* LLVOAvatar::sAvatarSkeletonInfo = NULL;
LLVOAvatar::LLVOAvatarXmlInfo* LLVOAvatar::sAvatarXmlInfo = NULL;
LLVOAvatarDictionary *LLVOAvatar::sAvatarDictionary = NULL;
@@ -667,7 +678,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
mNameString(),
mTitle(),
mNameAway(false),
- mNameBusy(false),
+ mNameDoNotDisturb(false),
mNameMute(false),
mNameAppearance(false),
mNameFriend(false),
@@ -806,14 +817,14 @@ void LLVOAvatar::debugAvatarRezTime(std::string notification_name, std::string c
//------------------------------------------------------------------------
LLVOAvatar::~LLVOAvatar()
{
- if (!mFullyLoaded)
- {
+ if (!mFullyLoaded)
+ {
debugAvatarRezTime("AvatarRezLeftCloudNotification","left after ruth seconds as cloud");
- }
- else
- {
+ }
+ else
+ {
debugAvatarRezTime("AvatarRezLeftNotification","left sometime after declouding");
- }
+ }
lldebugs << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << llendl;
@@ -1215,18 +1226,6 @@ void LLVOAvatar::initClass()
llerrs << "Error parsing skeleton file: " << skeleton_path << llendl;
}
- // Process XML data
-
- // avatar_skeleton.xml
- if (sAvatarSkeletonInfo)
- { //this can happen if a login attempt failed
- delete sAvatarSkeletonInfo;
- }
- sAvatarSkeletonInfo = new LLVOAvatarSkeletonInfo;
- if (!sAvatarSkeletonInfo->parseXml(sSkeletonXMLTree.getRoot()))
- {
- llerrs << "Error parsing skeleton XML file: " << skeleton_path << llendl;
- }
// parse avatar_lad.xml
if (sAvatarXmlInfo)
{ //this can happen if a login attempt failed
@@ -1275,7 +1274,7 @@ void LLVOAvatar::initClass()
void LLVOAvatar::cleanupClass()
{
deleteAndClear(sAvatarXmlInfo);
- sSkeletonXMLTree.cleanup();
+ sSkeletonXMLTree = NULL;
sXMLTree.cleanup();
}
@@ -1358,7 +1357,7 @@ void LLVOAvatar::initInstance(void)
if (LLCharacter::sInstances.size() == 1)
{
LLKeyframeMotion::setVFS(gStaticVFS);
- registerMotion( ANIM_AGENT_BUSY, LLNullMotion::create );
+ registerMotion( ANIM_AGENT_DO_NOT_DISTURB, LLNullMotion::create );
registerMotion( ANIM_AGENT_CROUCH, LLKeyframeStandMotion::create );
registerMotion( ANIM_AGENT_CROUCHWALK, LLKeyframeWalkMotion::create );
registerMotion( ANIM_AGENT_EXPRESS_AFRAID, LLEmote::create );
@@ -1743,33 +1742,39 @@ BOOL LLVOAvatar::parseSkeletonFile(const std::string& filename)
//-------------------------------------------------------------------------
// parse the file
//-------------------------------------------------------------------------
- BOOL parsesuccess = sSkeletonXMLTree.parseFile( filename, FALSE );
- if (!parsesuccess)
+ LLXMLNodePtr skeleton_xml;
+ BOOL parsesuccess = LLXMLNode::parseFile(filename, skeleton_xml, NULL);
+
+ if (!parsesuccess || skeleton_xml.isNull())
{
llerrs << "Can't parse skeleton file: " << filename << llendl;
return FALSE;
}
- // now sanity check xml file
- LLXmlTreeNode* root = sSkeletonXMLTree.getRoot();
- if (!root)
+ // Process XML data
+ if (sAvatarSkeletonInfo)
+ { //this can happen if a login attempt failed
+ delete sAvatarSkeletonInfo;
+ }
+ sAvatarSkeletonInfo = new LLVOAvatarSkeletonInfo;
+
+ LLXUIParser parser;
+ parser.readXUI(skeleton_xml, *sAvatarSkeletonInfo, filename);
+ if (!sAvatarSkeletonInfo->validateBlock())
{
- llerrs << "No root node found in avatar skeleton file: " << filename << llendl;
- return FALSE;
+ llerrs << "Error parsing skeleton XML file: " << filename << llendl;
}
- if( !root->hasName( "linden_skeleton" ) )
+ if( !skeleton_xml->hasName( "linden_skeleton" ) )
{
llerrs << "Invalid avatar skeleton file header: " << filename << llendl;
return FALSE;
}
- std::string version;
- static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version");
- if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") )
+ if (sAvatarSkeletonInfo->version() != "1.0")
{
- llerrs << "Invalid avatar skeleton file version: " << version << " in file: " << filename << llendl;
+ llerrs << "Invalid avatar skeleton file version: " << sAvatarSkeletonInfo->version() << " in file: " << filename << llendl;
return FALSE;
}
@@ -1778,12 +1783,11 @@ BOOL LLVOAvatar::parseSkeletonFile(const std::string& filename)
//-----------------------------------------------------------------------------
// setupBone()
-//-----------------------------------------------------------------------------
-BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent, S32 &volume_num, S32 &joint_num)
+//-----------------------------------------------------------
+BOOL LLVOAvatar::setupBone(const LLVOAvatarChildJoint& info, LLViewerJoint* parent, S32 &volume_num, S32 &joint_num)
{
LLViewerJoint* joint = NULL;
-
- if (info->mIsJoint)
+ if (info.bone.isChosen())
{
joint = (LLViewerJoint*)getCharacterJoint(joint_num);
if (!joint)
@@ -1791,7 +1795,23 @@ BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent
llwarns << "Too many bones" << llendl;
return FALSE;
}
- joint->setName( info->mName );
+ joint->setName( info.bone().name );
+ joint->setPosition(info.bone().pos);
+ joint->setRotation(mayaQ(info.bone().rot().mV[VX], info.bone().rot().mV[VY], info.bone().rot().mV[VZ], LLQuaternion::XYZ));
+ joint->setScale(info.bone().scale);
+ joint->setSkinOffset( info.bone().pivot );
+ joint_num++;
+
+ for (LLInitParam::ParamIterator<LLVOAvatarChildJoint>::const_iterator child_it = info.bone().children.begin(),
+ end_it = info.bone().children.end();
+ child_it != end_it;
+ ++child_it)
+ {
+ if (!setupBone(*child_it, joint, volume_num, joint_num))
+ {
+ return FALSE;
+ }
+ }
}
else // collision volume
{
@@ -1801,7 +1821,11 @@ BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent
return FALSE;
}
joint = (LLViewerJoint*)(&mCollisionVolumes[volume_num]);
- joint->setName( info->mName );
+ joint->setName( info.collision_volume.name);
+ joint->setPosition(info.collision_volume.pos);
+ joint->setRotation(mayaQ(info.collision_volume.rot().mV[VX], info.collision_volume.rot().mV[VY], info.collision_volume.rot().mV[VZ], LLQuaternion::XYZ));
+ joint->setScale(info.collision_volume.scale);
+ volume_num++;
}
// add to parent
@@ -1810,34 +1834,8 @@ BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent
parent->addChild( joint );
}
- joint->setPosition(info->mPos);
- joint->setRotation(mayaQ(info->mRot.mV[VX], info->mRot.mV[VY],
- info->mRot.mV[VZ], LLQuaternion::XYZ));
- joint->setScale(info->mScale);
-
joint->setDefaultFromCurrentXform();
- if (info->mIsJoint)
- {
- joint->setSkinOffset( info->mPivot );
- joint_num++;
- }
- else // collision volume
- {
- volume_num++;
- }
-
- // setup children
- LLVOAvatarBoneInfo::child_list_t::const_iterator iter;
- for (iter = info->mChildList.begin(); iter != info->mChildList.end(); ++iter)
- {
- LLVOAvatarBoneInfo *child_info = *iter;
- if (!setupBone(child_info, joint, volume_num, joint_num))
- {
- return FALSE;
- }
- }
-
return TRUE;
}
@@ -1849,36 +1847,32 @@ BOOL LLVOAvatar::buildSkeleton(const LLVOAvatarSkeletonInfo *info)
//-------------------------------------------------------------------------
// allocate joints
//-------------------------------------------------------------------------
- if (!allocateCharacterJoints(info->mNumBones))
+ if (!allocateCharacterJoints(info->num_bones))
{
- llerrs << "Can't allocate " << info->mNumBones << " joints" << llendl;
+ llerrs << "Can't allocate " << info->num_bones() << " joints" << llendl;
return FALSE;
}
//-------------------------------------------------------------------------
// allocate volumes
//-------------------------------------------------------------------------
- if (info->mNumCollisionVolumes)
+ if (info->num_collision_volumes)
{
- if (!allocateCollisionVolumes(info->mNumCollisionVolumes))
+ if (!allocateCollisionVolumes(info->num_collision_volumes))
{
- llerrs << "Can't allocate " << info->mNumCollisionVolumes << " collision volumes" << llendl;
+ llerrs << "Can't allocate " << info->num_collision_volumes() << " collision volumes" << llendl;
return FALSE;
}
}
S32 current_joint_num = 0;
S32 current_volume_num = 0;
- LLVOAvatarSkeletonInfo::bone_info_list_t::const_iterator iter;
- for (iter = info->mBoneInfoList.begin(); iter != info->mBoneInfoList.end(); ++iter)
+
+ if (!setupBone(info->skeleton_root, NULL, current_volume_num, current_joint_num))
{
- LLVOAvatarBoneInfo *info = *iter;
- if (!setupBone(info, NULL, current_volume_num, current_joint_num))
- {
llerrs << "Error parsing bone in skeleton file" << llendl;
return FALSE;
}
- }
return TRUE;
}
@@ -2087,15 +2081,15 @@ void LLVOAvatar::releaseMeshData()
LLFace* facep = mDrawable->getFace(0);
if (facep)
{
- facep->setSize(0, 0);
- for(S32 i = mNumInitFaces ; i < mDrawable->getNumFaces(); i++)
- {
- facep = mDrawable->getFace(i);
+ facep->setSize(0, 0);
+ for(S32 i = mNumInitFaces ; i < mDrawable->getNumFaces(); i++)
+ {
+ facep = mDrawable->getFace(i);
if (facep)
{
- facep->setSize(0, 0);
- }
- }
+ facep->setSize(0, 0);
+ }
+ }
}
}
@@ -2341,11 +2335,11 @@ U32 LLVOAvatar::processUpdateMessage(LLMessageSystem *mesgsys,
U32 retval = LLViewerObject::processUpdateMessage(mesgsys, user_data, block_num, update_type, dp);
// Print out arrival information once we have name of avatar.
- if (has_name && getNVPair("FirstName"))
- {
- mDebugExistenceTimer.reset();
+ if (has_name && getNVPair("FirstName"))
+ {
+ mDebugExistenceTimer.reset();
debugAvatarRezTime("AvatarRezArrivedNotification","avatar arrived");
- }
+ }
if(retval & LLViewerObject::INVALID_UPDATE)
{
@@ -2853,8 +2847,8 @@ void LLVOAvatar::idleUpdateLoadingEffect()
{
LL_INFOS("Avatar") << avString() << "self isFullyLoaded, mFirstFullyVisible" << LL_ENDL;
mFirstFullyVisible = FALSE;
- LLAppearanceMgr::instance().onFirstFullyVisible();
- }
+ LLAppearanceMgr::instance().onFirstFullyVisible();
+ }
if (isFullyLoaded() && mFirstFullyVisible && !isSelf())
{
LL_INFOS("Avatar") << avString() << "other isFullyLoaded, mFirstFullyVisible" << LL_ENDL;
@@ -3008,7 +3002,7 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
mVisibleChat = visible_chat;
new_name = TRUE;
}
-
+
if (sRenderGroupTitles != mRenderGroupTitles)
{
mRenderGroupTitles = sRenderGroupTitles;
@@ -3051,7 +3045,7 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
if (!mNameText)
{
mNameText = static_cast<LLHUDNameTag*>( LLHUDObject::addHUDObject(
- LLHUDObject::LL_HUD_NAME_TAG) );
+ LLHUDObject::LL_HUD_NAME_TAG) );
//mNameText->setMass(10.f);
mNameText->setSourceObject(this);
mNameText->setVertAlignment(LLHUDNameTag::ALIGN_VERT_TOP);
@@ -3060,10 +3054,9 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
mNameText->setFadeDistance(CHAT_NORMAL_RADIUS, 5.f);
sNumVisibleChatBubbles++;
new_name = TRUE;
- }
+ }
- LLVector3 name_position = idleUpdateNameTagPosition(root_pos_last);
- mNameText->setPositionAgent(name_position);
+ idleUpdateNameTagPosition(root_pos_last);
idleUpdateNameTagText(new_name);
idleUpdateNameTagAlpha(new_name, alpha);
}
@@ -3078,7 +3071,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
if (!firstname || !lastname) return;
bool is_away = mSignaledAnimations.find(ANIM_AGENT_AWAY) != mSignaledAnimations.end();
- bool is_busy = mSignaledAnimations.find(ANIM_AGENT_BUSY) != mSignaledAnimations.end();
+ bool is_do_not_disturb = mSignaledAnimations.find(ANIM_AGENT_DO_NOT_DISTURB) != mSignaledAnimations.end();
bool is_appearance = mSignaledAnimations.find(ANIM_AGENT_CUSTOMIZE) != mSignaledAnimations.end();
bool is_muted;
if (isSelf())
@@ -3110,7 +3103,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
|| (!title && !mTitle.empty())
|| (title && mTitle != title->getString())
|| is_away != mNameAway
- || is_busy != mNameBusy
+ || is_do_not_disturb != mNameDoNotDisturb
|| is_muted != mNameMute
|| is_appearance != mNameAppearance
|| is_friend != mNameFriend
@@ -3120,7 +3113,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
clearNameTag();
- if (is_away || is_muted || is_busy || is_appearance)
+ if (is_away || is_muted || is_do_not_disturb || is_appearance)
{
std::string line;
if (is_away)
@@ -3128,9 +3121,9 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
line += LLTrans::getString("AvatarAway");
line += ", ";
}
- if (is_busy)
+ if (is_do_not_disturb)
{
- line += LLTrans::getString("AvatarBusy");
+ line += LLTrans::getString("AvatarDoNotDisturb");
line += ", ";
}
if (is_muted)
@@ -3151,7 +3144,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
// trim last ", "
line.resize( line.length() - 2 );
addNameTagLine(line, name_tag_color, LLFontGL::NORMAL,
- LLFontGL::getFontSansSerifSmall());
+ LLFontGL::getFontSansSerifSmall());
}
if (sRenderGroupTitles
@@ -3160,48 +3153,46 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
std::string title_str = title->getString();
LLStringFn::replace_ascii_controlchars(title_str,LL_UNKNOWN_CHAR);
addNameTagLine(title_str, name_tag_color, LLFontGL::NORMAL,
- LLFontGL::getFontSansSerifSmall());
+ LLFontGL::getFontSansSerifSmall());
}
static LLUICachedControl<bool> show_display_names("NameTagShowDisplayNames");
static LLUICachedControl<bool> show_usernames("NameTagShowUsernames");
- if (LLAvatarNameCache::useDisplayNames())
+ if (LLAvatarName::useDisplayNames())
{
LLAvatarName av_name;
if (!LLAvatarNameCache::get(getID(), &av_name))
{
- // ...call this function back when the name arrives
- // and force a rebuild
- LLAvatarNameCache::get(getID(),
- boost::bind(&LLVOAvatar::clearNameTag, this));
+ // Force a rebuild at next idle
+ // Note: do not connect a callback on idle().
+ clearNameTag();
}
// Might be blank if name not available yet, that's OK
if (show_display_names)
{
- addNameTagLine(av_name.mDisplayName, name_tag_color, LLFontGL::NORMAL,
- LLFontGL::getFontSansSerif());
+ addNameTagLine(av_name.getDisplayName(), name_tag_color, LLFontGL::NORMAL,
+ LLFontGL::getFontSansSerif());
}
// Suppress SLID display if display name matches exactly (ugh)
- if (show_usernames && !av_name.mIsDisplayNameDefault)
+ if (show_usernames && !av_name.isDisplayNameDefault())
{
// *HACK: Desaturate the color
LLColor4 username_color = name_tag_color * 0.83f;
- addNameTagLine(av_name.mUsername, username_color, LLFontGL::NORMAL,
- LLFontGL::getFontSansSerifSmall());
+ addNameTagLine(av_name.getUserName(), username_color, LLFontGL::NORMAL,
+ LLFontGL::getFontSansSerifSmall());
}
}
else
{
const LLFontGL* font = LLFontGL::getFontSansSerif();
- std::string full_name =
- LLCacheName::buildFullName( firstname->getString(), lastname->getString() );
+ std::string full_name = LLCacheName::buildFullName( firstname->getString(), lastname->getString() );
addNameTagLine(full_name, name_tag_color, LLFontGL::NORMAL, font);
}
mNameAway = is_away;
- mNameBusy = is_busy;
+ mNameDoNotDisturb = is_do_not_disturb;
mNameMute = is_muted;
mNameAppearance = is_appearance;
mNameFriend = is_friend;
@@ -3216,7 +3207,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
mNameText->setFont(LLFontGL::getFontSansSerif());
mNameText->setTextAlignment(LLHUDNameTag::ALIGN_TEXT_LEFT);
mNameText->setFadeDistance(CHAT_NORMAL_RADIUS * 2.f, 5.f);
-
+
char line[MAX_STRING]; /* Flawfinder: ignore */
line[0] = '\0';
std::deque<LLChat>::iterator chat_iter = mChats.begin();
@@ -3236,13 +3227,13 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
LLFontGL::StyleFlags style;
switch(chat_iter->mChatType)
{
- case CHAT_TYPE_WHISPER:
+ case CHAT_TYPE_WHISPER:
style = LLFontGL::ITALIC;
break;
- case CHAT_TYPE_SHOUT:
+ case CHAT_TYPE_SHOUT:
style = LLFontGL::BOLD;
break;
- default:
+ default:
style = LLFontGL::NORMAL;
break;
}
@@ -3269,13 +3260,13 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
S32 dot_count = (llfloor(mTypingTimer.getElapsedTimeF32() * 3.f) + 2) % 3 + 1;
switch(dot_count)
{
- case 1:
+ case 1:
mNameText->addLine(".", new_chat);
break;
- case 2:
+ case 2:
mNameText->addLine("..", new_chat);
break;
- case 3:
+ case 3:
mNameText->addLine("...", new_chat);
break;
}
@@ -3314,6 +3305,7 @@ void LLVOAvatar::clearNameTag()
mNameText->setLabel("");
mNameText->setString( "" );
}
+ mTimeVisible.reset();
}
//static
@@ -3339,34 +3331,45 @@ void LLVOAvatar::invalidateNameTags()
if (avatar->isDead()) continue;
avatar->clearNameTag();
-
}
}
// Compute name tag position during idle update
-LLVector3 LLVOAvatar::idleUpdateNameTagPosition(const LLVector3& root_pos_last)
+void LLVOAvatar::idleUpdateNameTagPosition(const LLVector3& root_pos_last)
{
LLQuaternion root_rot = mRoot.getWorldRotation();
+ LLQuaternion inv_root_rot = ~root_rot;
LLVector3 pixel_right_vec;
LLVector3 pixel_up_vec;
LLViewerCamera::getInstance()->getPixelVectors(root_pos_last, pixel_up_vec, pixel_right_vec);
LLVector3 camera_to_av = root_pos_last - LLViewerCamera::getInstance()->getOrigin();
camera_to_av.normalize();
- LLVector3 local_camera_at = camera_to_av * ~root_rot;
+ LLVector3 local_camera_at = camera_to_av * inv_root_rot;
LLVector3 local_camera_up = camera_to_av % LLViewerCamera::getInstance()->getLeftAxis();
local_camera_up.normalize();
- local_camera_up = local_camera_up * ~root_rot;
+ local_camera_up = local_camera_up * inv_root_rot;
+
+ LLVector3 avatar_ellipsoid(mBodySize.mV[VX] * 0.4f,
+ mBodySize.mV[VY] * 0.4f,
+ mBodySize.mV[VZ] * NAMETAG_VERT_OFFSET_WEIGHT);
- local_camera_up.scaleVec(mBodySize * 0.5f);
- local_camera_at.scaleVec(mBodySize * 0.5f);
+ local_camera_up.scaleVec(avatar_ellipsoid);
+ local_camera_at.scaleVec(avatar_ellipsoid);
- LLVector3 name_position = mRoot.getWorldPosition();
- name_position[VZ] -= mPelvisToFoot;
- name_position[VZ] += (mBodySize[VZ]* 0.55f);
+ LLVector3 head_offset = (mHeadp->getLastWorldPosition() - mRoot.getLastWorldPosition()) * inv_root_rot;
+
+ if (dist_vec(head_offset, mTargetRootToHeadOffset) > NAMETAG_UPDATE_THRESHOLD)
+ {
+ mTargetRootToHeadOffset = head_offset;
+ }
+
+ mCurRootToHeadOffset = lerp(mCurRootToHeadOffset, mTargetRootToHeadOffset, LLCriticalDamp::getInterpolant(0.2f));
+
+ LLVector3 name_position = mRoot.getLastWorldPosition() + (mCurRootToHeadOffset * root_rot);
name_position += (local_camera_up * root_rot) - (projected_vec(local_camera_at * root_rot, camera_to_av));
- name_position += pixel_up_vec * 15.f;
+ name_position += pixel_up_vec * NAMETAG_VERTICAL_SCREEN_OFFSET;
- return name_position;
+ mNameText->setPositionAgent(name_position);
}
void LLVOAvatar::idleUpdateNameTagAlpha(BOOL new_name, F32 alpha)
@@ -3389,20 +3392,18 @@ LLColor4 LLVOAvatar::getNameTagColor(bool is_friend)
{
color_name = "NameTagFriend";
}
- else if (LLAvatarNameCache::useDisplayNames())
+ else if (LLAvatarName::useDisplayNames())
{
- // ...color based on whether username "matches" a computed display
- // name
+ // ...color based on whether username "matches" a computed display name
LLAvatarName av_name;
- if (LLAvatarNameCache::get(getID(), &av_name)
- && av_name.mIsDisplayNameDefault)
+ if (LLAvatarNameCache::get(getID(), &av_name) && av_name.isDisplayNameDefault())
{
color_name = "NameTagMatch";
}
else
{
color_name = "NameTagMismatch";
- }
+ }
}
else
{
@@ -3447,7 +3448,6 @@ bool LLVOAvatar::isVisuallyMuted() const
U32 max_cost = (U32) (max_render_cost*(LLVOAvatar::sLODFactor+0.5));
ret = LLMuteList::getInstance()->isMuted(getID()) ||
- (mAttachmentGeometryBytes > max_attachment_bytes && max_attachment_bytes > 0) ||
(mAttachmentSurfaceArea > max_attachment_area && max_attachment_area > 0.f) ||
(mVisualComplexity > max_cost && max_render_cost > 0);
}
@@ -3491,8 +3491,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
}
}
- LLVector3d root_pos_global;
-
if (!mIsBuilt)
{
return FALSE;
@@ -3507,7 +3505,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
mTimeVisible.reset();
}
-
//--------------------------------------------------------------------
// the rest should only be done occasionally for far away avatars
//--------------------------------------------------------------------
@@ -3910,10 +3907,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
if ( playSound )
{
-// F32 gain = clamp_rescale( mSpeedAccum,
-// AUDIO_STEP_LO_SPEED, AUDIO_STEP_HI_SPEED,
-// AUDIO_STEP_LO_GAIN, AUDIO_STEP_HI_GAIN );
-
const F32 STEP_VOLUME = 0.1f;
const LLUUID& step_sound_id = getStepSound();
@@ -4130,13 +4123,6 @@ void LLVOAvatar::updateVisibility()
{
releaseMeshData();
}
- // this breaks off-screen chat bubbles
- //if (mNameText)
- //{
- // mNameText->markDead();
- // mNameText = NULL;
- // sNumVisibleChatBubbles--;
- //}
}
mVisible = visible;
@@ -4172,11 +4158,11 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
{ //LOD changed or new mesh created, allocate new vertex buffer if needed
if (needs_rebuild || mDirtyMesh >= 2 || mVisibilityRank <= 4)
{
- updateMeshData();
+ updateMeshData();
mDirtyMesh = 0;
- mNeedsSkin = TRUE;
- mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
- }
+ mNeedsSkin = TRUE;
+ mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
+ }
}
if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) <= 0)
@@ -4205,13 +4191,13 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
if (face)
{
LLVertexBuffer* vb = face->getVertexBuffer();
- if (vb)
- {
- vb->flush();
- }
+ if (vb)
+ {
+ vb->flush();
}
}
}
+ }
else
{
mNeedsSkin = FALSE;
@@ -5863,7 +5849,6 @@ BOOL LLVOAvatar::updateJointLODs()
F32 avatar_num_factor = clamp_rescale((F32)sNumVisibleAvatars, 8, 25, 1.f, avatar_num_min_factor);
F32 area_scale = 0.16f;
- {
if (isSelf())
{
if(gAgentCamera.cameraCustomizeAvatar() || gAgentCamera.cameraMouselook())
@@ -5893,7 +5878,6 @@ BOOL LLVOAvatar::updateJointLODs()
dirtyMesh(2);
return TRUE;
}
- }
return FALSE;
}
@@ -6184,14 +6168,9 @@ void LLVOAvatar::cleanupAttachedMesh( LLViewerObject* pVO )
if ( pVObj )
{
const LLMeshSkinInfo* pSkinData = gMeshRepo.getSkinInfo( pVObj->getVolume()->getParams().getSculptID(), pVObj );
- if ( pSkinData )
- {
- const int jointCnt = pSkinData->mJointNames.size();
- bool fullRig = ( jointCnt>=20 ) ? true : false;
- if ( fullRig )
- {
- const int bindCnt = pSkinData->mAlternateBindMatrix.size();
- if ( bindCnt > 0 )
+ if (pSkinData
+ && pSkinData->mJointNames.size() > 20 // full rig
+ && pSkinData->mAlternateBindMatrix.size() > 0)
{
LLVOAvatar::resetJointPositionsToDefault();
//Need to handle the repositioning of the cam, updating rig data etc during outfit editing
@@ -6206,8 +6185,6 @@ void LLVOAvatar::cleanupAttachedMesh( LLViewerObject* pVO )
}
}
}
- }
-}
//-----------------------------------------------------------------------------
// detachObject()
//-----------------------------------------------------------------------------
@@ -6357,11 +6334,7 @@ void LLVOAvatar::getOffObject()
at_axis.mV[VZ] = 0.f;
at_axis.normalize();
gAgent.resetAxes(at_axis);
-
- //reset orientation
-// mRoot.setRotation(avWorldRot);
gAgentCamera.setThirdPersonHeadOffset(LLVector3(0.f, 0.f, 1.f));
-
gAgentCamera.setSitCamera(LLUUID::null);
}
}
@@ -6411,7 +6384,6 @@ LLColor4 LLVOAvatar::getGlobalColor( const std::string& color_name ) const
}
else
{
-// return LLColor4( .5f, .5f, .5f, .5f );
return LLColor4( 0.f, 1.f, 1.f, 1.f ); // good debugging color
}
}
@@ -6576,8 +6548,8 @@ BOOL LLVOAvatar::processFullyLoadedChange(bool loading)
mFullyLoaded = (mFullyLoadedTimer.getElapsedTimeF32() > PAUSE);
- if (!mPreviousFullyLoaded && !loading && mFullyLoaded)
- {
+ if (!mPreviousFullyLoaded && !loading && mFullyLoaded)
+ {
debugAvatarRezTime("AvatarRezNotification","fully loaded");
}
@@ -7170,10 +7142,6 @@ LLBBox LLVOAvatar::getHUDBBox() const
return bbox;
}
-void LLVOAvatar::rebuildHUD()
-{
-}
-
//-----------------------------------------------------------------------------
// onFirstTEMessageReceived()
//-----------------------------------------------------------------------------
@@ -7297,7 +7265,10 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
&& baked_index != BAKED_SKIRT)
{
setTEImage(mBakedTextureDatas[baked_index].mTextureIndex,
- LLViewerTextureManager::getFetchedTexture(mBakedTextureDatas[baked_index].mLastTextureIndex, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE));
+ LLViewerTextureManager::getFetchedTexture(mBakedTextureDatas[baked_index].mLastTextureIndex,
+ TRUE,
+ LLViewerTexture::BOOST_NONE,
+ LLViewerTexture::LOD_TEXTURE));
}
}
@@ -7555,7 +7526,7 @@ void LLVOAvatar::onInitialBakedTextureLoaded( BOOL success, LLViewerFetchedTextu
LLUUID *avatar_idp = (LLUUID *)userdata;
LLVOAvatar *selfp = (LLVOAvatar *)gObjectList.findObject(*avatar_idp);
-
+
if (selfp)
{
LL_DEBUGS("Avatar") << selfp->avString() << "discard_level " << discard_level << " success " << success << " final " << final << LL_ENDL;
@@ -7606,13 +7577,6 @@ void LLVOAvatar::onBakedTextureLoaded(BOOL success,
// Called when baked texture is loaded and also when we start up with a baked texture
void LLVOAvatar::useBakedTexture( const LLUUID& id )
{
-
-
- /* if(id == head_baked->getID())
- mHeadBakedLoaded = TRUE;
- mLastHeadBakedID = id;
- mHeadMesh0.setTexture( head_baked );
- mHeadMesh1.setTexture( head_baked ); */
for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
{
LLViewerTexture* image_baked = getImage( mBakedTextureDatas[i].mTextureIndex, 0 );
@@ -7856,111 +7820,111 @@ LLVOAvatar::LLVOAvatarXmlInfo::~LLVOAvatarXmlInfo()
std::for_each(mMorphMaskInfoList.begin(), mMorphMaskInfoList.end(), DeletePointer());
}
-//-----------------------------------------------------------------------------
-// LLVOAvatarBoneInfo::parseXml()
-//-----------------------------------------------------------------------------
-BOOL LLVOAvatarBoneInfo::parseXml(LLXmlTreeNode* node)
-{
- if (node->hasName("bone"))
- {
- mIsJoint = TRUE;
- static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
- if (!node->getFastAttributeString(name_string, mName))
- {
- llwarns << "Bone without name" << llendl;
- return FALSE;
- }
- }
- else if (node->hasName("collision_volume"))
- {
- mIsJoint = FALSE;
- static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
- if (!node->getFastAttributeString(name_string, mName))
- {
- mName = "Collision Volume";
- }
- }
- else
- {
- llwarns << "Invalid node " << node->getName() << llendl;
- return FALSE;
- }
-
- static LLStdStringHandle pos_string = LLXmlTree::addAttributeString("pos");
- if (!node->getFastAttributeVector3(pos_string, mPos))
- {
- llwarns << "Bone without position" << llendl;
- return FALSE;
- }
-
- static LLStdStringHandle rot_string = LLXmlTree::addAttributeString("rot");
- if (!node->getFastAttributeVector3(rot_string, mRot))
- {
- llwarns << "Bone without rotation" << llendl;
- return FALSE;
- }
-
- static LLStdStringHandle scale_string = LLXmlTree::addAttributeString("scale");
- if (!node->getFastAttributeVector3(scale_string, mScale))
- {
- llwarns << "Bone without scale" << llendl;
- return FALSE;
- }
-
- if (mIsJoint)
- {
- static LLStdStringHandle pivot_string = LLXmlTree::addAttributeString("pivot");
- if (!node->getFastAttributeVector3(pivot_string, mPivot))
- {
- llwarns << "Bone without pivot" << llendl;
- return FALSE;
- }
- }
-
- // parse children
- LLXmlTreeNode* child;
- for( child = node->getFirstChild(); child; child = node->getNextChild() )
- {
- LLVOAvatarBoneInfo *child_info = new LLVOAvatarBoneInfo;
- if (!child_info->parseXml(child))
- {
- delete child_info;
- return FALSE;
- }
- mChildList.push_back(child_info);
- }
- return TRUE;
-}
-
-//-----------------------------------------------------------------------------
-// LLVOAvatarSkeletonInfo::parseXml()
-//-----------------------------------------------------------------------------
-BOOL LLVOAvatarSkeletonInfo::parseXml(LLXmlTreeNode* node)
-{
- static LLStdStringHandle num_bones_string = LLXmlTree::addAttributeString("num_bones");
- if (!node->getFastAttributeS32(num_bones_string, mNumBones))
- {
- llwarns << "Couldn't find number of bones." << llendl;
- return FALSE;
- }
-
- static LLStdStringHandle num_collision_volumes_string = LLXmlTree::addAttributeString("num_collision_volumes");
- node->getFastAttributeS32(num_collision_volumes_string, mNumCollisionVolumes);
-
- LLXmlTreeNode* child;
- for( child = node->getFirstChild(); child; child = node->getNextChild() )
- {
- LLVOAvatarBoneInfo *info = new LLVOAvatarBoneInfo;
- if (!info->parseXml(child))
- {
- delete info;
- llwarns << "Error parsing bone in skeleton file" << llendl;
- return FALSE;
- }
- mBoneInfoList.push_back(info);
- }
- return TRUE;
-}
+////-----------------------------------------------------------------------------
+//// LLVOAvatarBoneInfo::parseXml()
+////-----------------------------------------------------------------------------
+//BOOL LLVOAvatarBoneInfo::parseXml(LLXmlTreeNode* node)
+//{
+// if (node->hasName("bone"))
+// {
+// mIsJoint = TRUE;
+// static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
+// if (!node->getFastAttributeString(name_string, mName))
+// {
+// llwarns << "Bone without name" << llendl;
+// return FALSE;
+// }
+// }
+// else if (node->hasName("collision_volume"))
+// {
+// mIsJoint = FALSE;
+// static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
+// if (!node->getFastAttributeString(name_string, mName))
+// {
+// mName = "Collision Volume";
+// }
+// }
+// else
+// {
+// llwarns << "Invalid node " << node->getName() << llendl;
+// return FALSE;
+// }
+//
+// static LLStdStringHandle pos_string = LLXmlTree::addAttributeString("pos");
+// if (!node->getFastAttributeVector3(pos_string, mPos))
+// {
+// llwarns << "Bone without position" << llendl;
+// return FALSE;
+// }
+//
+// static LLStdStringHandle rot_string = LLXmlTree::addAttributeString("rot");
+// if (!node->getFastAttributeVector3(rot_string, mRot))
+// {
+// llwarns << "Bone without rotation" << llendl;
+// return FALSE;
+// }
+//
+// static LLStdStringHandle scale_string = LLXmlTree::addAttributeString("scale");
+// if (!node->getFastAttributeVector3(scale_string, mScale))
+// {
+// llwarns << "Bone without scale" << llendl;
+// return FALSE;
+// }
+//
+// if (mIsJoint)
+// {
+// static LLStdStringHandle pivot_string = LLXmlTree::addAttributeString("pivot");
+// if (!node->getFastAttributeVector3(pivot_string, mPivot))
+// {
+// llwarns << "Bone without pivot" << llendl;
+// return FALSE;
+// }
+// }
+//
+// // parse children
+// LLXmlTreeNode* child;
+// for( child = node->getFirstChild(); child; child = node->getNextChild() )
+// {
+// LLVOAvatarBoneInfo *child_info = new LLVOAvatarBoneInfo;
+// if (!child_info->parseXml(child))
+// {
+// delete child_info;
+// return FALSE;
+// }
+// mChildList.push_back(child_info);
+// }
+// return TRUE;
+//}
+//
+////-----------------------------------------------------------------------------
+//// LLVOAvatarSkeletonInfo::parseXml()
+////-----------------------------------------------------------------------------
+//BOOL LLVOAvatarSkeletonInfo::parseXml(LLXmlTreeNode* node)
+//{
+// static LLStdStringHandle num_bones_string = LLXmlTree::addAttributeString("num_bones");
+// if (!node->getFastAttributeS32(num_bones_string, mNumBones))
+// {
+// llwarns << "Couldn't find number of bones." << llendl;
+// return FALSE;
+// }
+//
+// static LLStdStringHandle num_collision_volumes_string = LLXmlTree::addAttributeString("num_collision_volumes");
+// node->getFastAttributeS32(num_collision_volumes_string, mNumCollisionVolumes);
+//
+// LLXmlTreeNode* child;
+// for( child = node->getFirstChild(); child; child = node->getNextChild() )
+// {
+// LLVOAvatarBoneInfo *info = new LLVOAvatarBoneInfo;
+// if (!info->parseXml(child))
+// {
+// delete info;
+// llwarns << "Error parsing bone in skeleton file" << llendl;
+// return FALSE;
+// }
+// mBoneInfoList.push_back(info);
+// }
+// return TRUE;
+//}
//-----------------------------------------------------------------------------
// parseXmlSkeletonNode(): parses <skeleton> nodes from XML tree