diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llvoavatar.cpp | 760 |
1 files changed, 427 insertions, 333 deletions
diff --git a/linden/indra/newview/llvoavatar.cpp b/linden/indra/newview/llvoavatar.cpp index ece24e0..7113177 100644 --- a/linden/indra/newview/llvoavatar.cpp +++ b/linden/indra/newview/llvoavatar.cpp | |||
@@ -47,7 +47,6 @@ | |||
47 | #include "timing.h" | 47 | #include "timing.h" |
48 | 48 | ||
49 | #include "llagent.h" // Get state values from here | 49 | #include "llagent.h" // Get state values from here |
50 | #include "llagparray.h" | ||
51 | #include "llviewercontrol.h" | 50 | #include "llviewercontrol.h" |
52 | #include "llcriticaldamp.h" | 51 | #include "llcriticaldamp.h" |
53 | #include "lldir.h" | 52 | #include "lldir.h" |
@@ -210,7 +209,7 @@ const F32 UNDERWATER_FREQUENCY_DAMP = 0.33f; | |||
210 | const F32 APPEARANCE_MORPH_TIME = 0.65f; | 209 | const F32 APPEARANCE_MORPH_TIME = 0.65f; |
211 | const F32 CAMERA_SHAKE_ACCEL_THRESHOLD_SQUARED = 5.f * 5.f; | 210 | const F32 CAMERA_SHAKE_ACCEL_THRESHOLD_SQUARED = 5.f * 5.f; |
212 | const F32 TIME_BEFORE_MESH_CLEANUP = 5.f; // seconds | 211 | const F32 TIME_BEFORE_MESH_CLEANUP = 5.f; // seconds |
213 | const S32 AVATAR_AGP_RELEASE_THRESHOLD = 10; // number of avatar instances before releasing AGP memory | 212 | const S32 AVATAR_RELEASE_THRESHOLD = 10; // number of avatar instances before releasing memory |
214 | const F32 FOOT_GROUND_COLLISION_TOLERANCE = 0.25f; | 213 | const F32 FOOT_GROUND_COLLISION_TOLERANCE = 0.25f; |
215 | const F32 AVATAR_LOD_TWEAK_RANGE = 0.7f; | 214 | const F32 AVATAR_LOD_TWEAK_RANGE = 0.7f; |
216 | const S32 MAX_LOD_CHANGES_PER_FRAME = 2; | 215 | const S32 MAX_LOD_CHANGES_PER_FRAME = 2; |
@@ -768,9 +767,9 @@ LLVOAvatar::LLVOAvatar( | |||
768 | mLastSkirtBakedID( IMG_DEFAULT_AVATAR ), | 767 | mLastSkirtBakedID( IMG_DEFAULT_AVATAR ), |
769 | mIsDummy(FALSE), | 768 | mIsDummy(FALSE), |
770 | mSpecialRenderMode(0), | 769 | mSpecialRenderMode(0), |
770 | mTurning(FALSE), | ||
771 | mPelvisToFoot(0.f), | 771 | mPelvisToFoot(0.f), |
772 | mLastSkeletonSerialNum( 0 ), | 772 | mLastSkeletonSerialNum( 0 ), |
773 | mTurning(FALSE), | ||
774 | mHeadOffset(), | 773 | mHeadOffset(), |
775 | mIsSitting(FALSE), | 774 | mIsSitting(FALSE), |
776 | mTimeVisible(), | 775 | mTimeVisible(), |
@@ -789,7 +788,6 @@ LLVOAvatar::LLVOAvatar( | |||
789 | mEyesLayerSet( NULL ), | 788 | mEyesLayerSet( NULL ), |
790 | mSkirtLayerSet( NULL ), | 789 | mSkirtLayerSet( NULL ), |
791 | mRenderPriority(1.0f), | 790 | mRenderPriority(1.0f), |
792 | mNumAGPVertices(0), | ||
793 | mNameString(), | 791 | mNameString(), |
794 | mTitle(), | 792 | mTitle(), |
795 | mNameAway(FALSE), | 793 | mNameAway(FALSE), |
@@ -848,7 +846,7 @@ LLVOAvatar::LLVOAvatar( | |||
848 | mSpeed = 0.f; | 846 | mSpeed = 0.f; |
849 | setAnimationData("Speed", &mSpeed); | 847 | setAnimationData("Speed", &mSpeed); |
850 | 848 | ||
851 | strcpy(mAvatarDefinition, AVATAR_DEFAULT_CHAR); | 849 | strcpy(mAvatarDefinition, AVATAR_DEFAULT_CHAR); /* Flawfinder: ignore */ |
852 | 850 | ||
853 | if (id == gAgentID) | 851 | if (id == gAgentID) |
854 | { | 852 | { |
@@ -1007,7 +1005,7 @@ LLVOAvatar::LLVOAvatar( | |||
1007 | //------------------------------------------------------------------------- | 1005 | //------------------------------------------------------------------------- |
1008 | // register motions | 1006 | // register motions |
1009 | //------------------------------------------------------------------------- | 1007 | //------------------------------------------------------------------------- |
1010 | if (LLCharacter::sInstances.getLength() == 1) | 1008 | if (LLCharacter::sInstances.size() == 1) |
1011 | { | 1009 | { |
1012 | LLKeyframeMotion::setVFS(gStaticVFS); | 1010 | LLKeyframeMotion::setVFS(gStaticVFS); |
1013 | addMotion( ANIM_AGENT_BUSY, LLNullMotion::create ); | 1011 | addMotion( ANIM_AGENT_BUSY, LLNullMotion::create ); |
@@ -1151,7 +1149,8 @@ void LLVOAvatar::markDead() | |||
1151 | BOOL LLVOAvatar::isFullyBaked() | 1149 | BOOL LLVOAvatar::isFullyBaked() |
1152 | { | 1150 | { |
1153 | if (mIsDummy) return TRUE; | 1151 | if (mIsDummy) return TRUE; |
1154 | 1152 | if (getNumTEs() == 0) return FALSE; | |
1153 | |||
1155 | BOOL head_baked = ( getTEImage( TEX_HEAD_BAKED )->getID() != IMG_DEFAULT_AVATAR ); | 1154 | BOOL head_baked = ( getTEImage( TEX_HEAD_BAKED )->getID() != IMG_DEFAULT_AVATAR ); |
1156 | BOOL upper_baked = ( getTEImage( TEX_UPPER_BAKED )->getID() != IMG_DEFAULT_AVATAR ); | 1155 | BOOL upper_baked = ( getTEImage( TEX_UPPER_BAKED )->getID() != IMG_DEFAULT_AVATAR ); |
1157 | BOOL lower_baked = ( getTEImage( TEX_LOWER_BAKED )->getID() != IMG_DEFAULT_AVATAR ); | 1156 | BOOL lower_baked = ( getTEImage( TEX_LOWER_BAKED )->getID() != IMG_DEFAULT_AVATAR ); |
@@ -1180,10 +1179,10 @@ void LLVOAvatar::deleteLayerSetCaches() | |||
1180 | // static | 1179 | // static |
1181 | BOOL LLVOAvatar::areAllNearbyInstancesBaked() | 1180 | BOOL LLVOAvatar::areAllNearbyInstancesBaked() |
1182 | { | 1181 | { |
1183 | for( LLVOAvatar* inst = (LLVOAvatar*)LLCharacter::sInstances.getFirstData(); | 1182 | for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); |
1184 | inst; | 1183 | iter != LLCharacter::sInstances.end(); ++iter) |
1185 | inst = (LLVOAvatar*)LLCharacter::sInstances.getNextData() ) | ||
1186 | { | 1184 | { |
1185 | LLVOAvatar* inst = (LLVOAvatar*) *iter; | ||
1187 | if( inst->isDead() ) | 1186 | if( inst->isDead() ) |
1188 | { | 1187 | { |
1189 | continue; | 1188 | continue; |
@@ -1213,10 +1212,10 @@ void LLVOAvatar::dumpBakedStatus() | |||
1213 | { | 1212 | { |
1214 | LLVector3d camera_pos_global = gAgent.getCameraPositionGlobal(); | 1213 | LLVector3d camera_pos_global = gAgent.getCameraPositionGlobal(); |
1215 | 1214 | ||
1216 | for( LLVOAvatar* inst = (LLVOAvatar*)LLCharacter::sInstances.getFirstData(); | 1215 | for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); |
1217 | inst; | 1216 | iter != LLCharacter::sInstances.end(); ++iter) |
1218 | inst = (LLVOAvatar*)LLCharacter::sInstances.getNextData() ) | ||
1219 | { | 1217 | { |
1218 | LLVOAvatar* inst = (LLVOAvatar*) *iter; | ||
1220 | llinfos << "Avatar "; | 1219 | llinfos << "Avatar "; |
1221 | 1220 | ||
1222 | LLNameValue* firstname = inst->getNVPair("FirstName"); | 1221 | LLNameValue* firstname = inst->getNVPair("FirstName"); |
@@ -1405,11 +1404,10 @@ void LLVOAvatar::initVertexPrograms() | |||
1405 | //static | 1404 | //static |
1406 | void LLVOAvatar::restoreGL() | 1405 | void LLVOAvatar::restoreGL() |
1407 | { | 1406 | { |
1408 | LLVOAvatar* inst; | 1407 | for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); |
1409 | for( inst = (LLVOAvatar*)LLCharacter::sInstances.getFirstData(); | 1408 | iter != LLCharacter::sInstances.end(); ++iter) |
1410 | inst; | ||
1411 | inst = (LLVOAvatar*)LLCharacter::sInstances.getNextData() ) | ||
1412 | { | 1409 | { |
1410 | LLVOAvatar* inst = (LLVOAvatar*) *iter; | ||
1413 | inst->setCompositeUpdatesEnabled( TRUE ); | 1411 | inst->setCompositeUpdatesEnabled( TRUE ); |
1414 | inst->invalidateComposite( inst->mHeadLayerSet, FALSE ); | 1412 | inst->invalidateComposite( inst->mHeadLayerSet, FALSE ); |
1415 | inst->invalidateComposite( inst->mLowerBodyLayerSet, FALSE ); | 1413 | inst->invalidateComposite( inst->mLowerBodyLayerSet, FALSE ); |
@@ -1433,10 +1431,10 @@ void LLVOAvatar::deleteCachedImages() | |||
1433 | if (LLTexLayerSet::sHasCaches) | 1431 | if (LLTexLayerSet::sHasCaches) |
1434 | { | 1432 | { |
1435 | lldebugs << "Deleting layer set caches" << llendl; | 1433 | lldebugs << "Deleting layer set caches" << llendl; |
1436 | for( LLVOAvatar* inst = (LLVOAvatar*)LLCharacter::sInstances.getFirstData(); | 1434 | for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); |
1437 | inst; | 1435 | iter != LLCharacter::sInstances.end(); ++iter) |
1438 | inst = (LLVOAvatar*)LLCharacter::sInstances.getNextData() ) | ||
1439 | { | 1436 | { |
1437 | LLVOAvatar* inst = (LLVOAvatar*) *iter; | ||
1440 | inst->deleteLayerSetCaches(); | 1438 | inst->deleteLayerSetCaches(); |
1441 | } | 1439 | } |
1442 | LLTexLayerSet::sHasCaches = FALSE; | 1440 | LLTexLayerSet::sHasCaches = FALSE; |
@@ -1472,9 +1470,9 @@ void LLVOAvatar::initClass() | |||
1472 | { | 1470 | { |
1473 | LLVOAvatar::sMaxOtherAvatarsToComposite = gSavedSettings.getS32("AvatarCompositeLimit"); | 1471 | LLVOAvatar::sMaxOtherAvatarsToComposite = gSavedSettings.getS32("AvatarCompositeLimit"); |
1474 | 1472 | ||
1475 | char xmlFile[MAX_PATH]; | 1473 | char xmlFile[MAX_PATH]; /* Flawfinder: ignore */ |
1476 | 1474 | ||
1477 | sprintf(xmlFile, "%s_lad.xml", gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,AVATAR_DEFAULT_CHAR).c_str()); | 1475 | snprintf(xmlFile, MAX_PATH, "%s_lad.xml", gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,AVATAR_DEFAULT_CHAR).c_str()); /* Flawfinder: ignore */ |
1478 | BOOL success = sXMLTree.parseFile( xmlFile, FALSE ); | 1476 | BOOL success = sXMLTree.parseFile( xmlFile, FALSE ); |
1479 | if (!success) | 1477 | if (!success) |
1480 | { | 1478 | { |
@@ -1537,30 +1535,30 @@ void LLVOAvatar::initClass() | |||
1537 | sSkeletonInfo = new LLVOAvatarSkeletonInfo; | 1535 | sSkeletonInfo = new LLVOAvatarSkeletonInfo; |
1538 | if (!sSkeletonInfo->parseXml(sSkeletonXMLTree.getRoot())) | 1536 | if (!sSkeletonInfo->parseXml(sSkeletonXMLTree.getRoot())) |
1539 | { | 1537 | { |
1540 | llerrs << "Error parsing skeleton XML file" << llendl; | 1538 | llerrs << "Error parsing skeleton XML file: " << skeleton_path << llendl; |
1541 | } | 1539 | } |
1542 | // parse avatar_lad.xml | 1540 | // parse avatar_lad.xml |
1543 | llassert(!sAvatarInfo); | 1541 | llassert(!sAvatarInfo); |
1544 | sAvatarInfo = new LLVOAvatarInfo; | 1542 | sAvatarInfo = new LLVOAvatarInfo; |
1545 | if (!sAvatarInfo->parseXmlSkeletonNode(root)) | 1543 | if (!sAvatarInfo->parseXmlSkeletonNode(root)) |
1546 | { | 1544 | { |
1547 | llerrs << "Error parsing skeleton node in avatar XML file" << llendl; | 1545 | llerrs << "Error parsing skeleton node in avatar XML file: " << skeleton_path << llendl; |
1548 | } | 1546 | } |
1549 | if (!sAvatarInfo->parseXmlMeshNodes(root)) | 1547 | if (!sAvatarInfo->parseXmlMeshNodes(root)) |
1550 | { | 1548 | { |
1551 | llerrs << "Error parsing skeleton node in avatar XML file" << llendl; | 1549 | llerrs << "Error parsing skeleton node in avatar XML file: " << skeleton_path << llendl; |
1552 | } | 1550 | } |
1553 | if (!sAvatarInfo->parseXmlColorNodes(root)) | 1551 | if (!sAvatarInfo->parseXmlColorNodes(root)) |
1554 | { | 1552 | { |
1555 | llerrs << "Error parsing skeleton node in avatar XML file" << llendl; | 1553 | llerrs << "Error parsing skeleton node in avatar XML file: " << skeleton_path << llendl; |
1556 | } | 1554 | } |
1557 | if (!sAvatarInfo->parseXmlLayerNodes(root)) | 1555 | if (!sAvatarInfo->parseXmlLayerNodes(root)) |
1558 | { | 1556 | { |
1559 | llerrs << "Error parsing skeleton node in avatar XML file" << llendl; | 1557 | llerrs << "Error parsing skeleton node in avatar XML file: " << skeleton_path << llendl; |
1560 | } | 1558 | } |
1561 | if (!sAvatarInfo->parseXmlDriverNodes(root)) | 1559 | if (!sAvatarInfo->parseXmlDriverNodes(root)) |
1562 | { | 1560 | { |
1563 | llerrs << "Error parsing skeleton node in avatar XML file" << llendl; | 1561 | llerrs << "Error parsing skeleton node in avatar XML file: " << skeleton_path << llendl; |
1564 | } | 1562 | } |
1565 | } | 1563 | } |
1566 | 1564 | ||
@@ -1576,6 +1574,19 @@ void LLVOAvatar::cleanupClass() | |||
1576 | } | 1574 | } |
1577 | 1575 | ||
1578 | 1576 | ||
1577 | void LLVOAvatar::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax) | ||
1578 | { | ||
1579 | LLVector3 center = getRenderPosition(); | ||
1580 | LLVector3 size = getScale(); | ||
1581 | //maximum amount an animation can move avatar from drawable position | ||
1582 | LLVector3 animation_buffer(5, 5, 5); | ||
1583 | |||
1584 | newMin.setVec((center-size)-animation_buffer); | ||
1585 | newMax.setVec(center+size+animation_buffer); | ||
1586 | mDrawable->setPositionGroup((newMin + newMax) * 0.5f); | ||
1587 | } | ||
1588 | |||
1589 | |||
1579 | //----------------------------------------------------------------------------- | 1590 | //----------------------------------------------------------------------------- |
1580 | // parseSkeletonFile() | 1591 | // parseSkeletonFile() |
1581 | //----------------------------------------------------------------------------- | 1592 | //----------------------------------------------------------------------------- |
@@ -1728,10 +1739,16 @@ BOOL LLVOAvatar::buildSkeleton(LLVOAvatarSkeletonInfo *info) | |||
1728 | } | 1739 | } |
1729 | 1740 | ||
1730 | // add special-purpose "screen" joint | 1741 | // add special-purpose "screen" joint |
1731 | mScreenp = new LLViewerJoint("mScreen", NULL); | 1742 | if (mIsSelf) |
1732 | // for now, put screen at origin, as it is only used during special | 1743 | { |
1733 | // HUD rendering mode | 1744 | mScreenp = new LLViewerJoint("mScreen", NULL); |
1734 | mScreenp->setWorldPosition(LLVector3::zero); | 1745 | // for now, put screen at origin, as it is only used during special |
1746 | // HUD rendering mode | ||
1747 | F32 aspect = gCamera->getAspect(); | ||
1748 | LLVector3 scale(1.f, aspect, 1.f); | ||
1749 | mScreenp->setScale(scale); | ||
1750 | mScreenp->setWorldPosition(LLVector3::zero); | ||
1751 | } | ||
1735 | 1752 | ||
1736 | return TRUE; | 1753 | return TRUE; |
1737 | } | 1754 | } |
@@ -1812,7 +1829,7 @@ void LLVOAvatar::buildCharacter() | |||
1812 | return; | 1829 | return; |
1813 | } | 1830 | } |
1814 | 1831 | ||
1815 | gPrintMessagesThisFrame = TRUE; | 1832 | // gPrintMessagesThisFrame = TRUE; |
1816 | lldebugs << "Avatar load took " << timer.getElapsedTimeF32() << " seconds." << llendl; | 1833 | lldebugs << "Avatar load took " << timer.getElapsedTimeF32() << " seconds." << llendl; |
1817 | 1834 | ||
1818 | if ( ! status ) | 1835 | if ( ! status ) |
@@ -1944,9 +1961,10 @@ void LLVOAvatar::buildCharacter() | |||
1944 | { | 1961 | { |
1945 | LLMenuItemCallGL* item; | 1962 | LLMenuItemCallGL* item; |
1946 | item = new LLMenuItemCallGL(attachment->getName(), | 1963 | item = new LLMenuItemCallGL(attachment->getName(), |
1947 | &handle_attach_to_avatar, | 1964 | NULL, |
1948 | object_selected_and_point_valid, | 1965 | object_selected_and_point_valid); |
1949 | attachment); | 1966 | item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", mAttachmentPoints.reverseLookup(attachment)); |
1967 | |||
1950 | gAttachPieMenu->append(item); | 1968 | gAttachPieMenu->append(item); |
1951 | 1969 | ||
1952 | attachment_found = TRUE; | 1970 | attachment_found = TRUE; |
@@ -1998,9 +2016,9 @@ void LLVOAvatar::buildCharacter() | |||
1998 | { | 2016 | { |
1999 | LLMenuItemCallGL* item; | 2017 | LLMenuItemCallGL* item; |
2000 | item = new LLMenuItemCallGL(attachment->getName(), | 2018 | item = new LLMenuItemCallGL(attachment->getName(), |
2001 | &handle_attach_to_avatar, | 2019 | NULL, |
2002 | object_selected_and_point_valid, | 2020 | object_selected_and_point_valid); |
2003 | attachment); | 2021 | item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", mAttachmentPoints.reverseLookup(attachment)); |
2004 | gAttachScreenPieMenu->append(item); | 2022 | gAttachScreenPieMenu->append(item); |
2005 | gDetachScreenPieMenu->append(new LLMenuItemCallGL(attachment->getName(), | 2023 | gDetachScreenPieMenu->append(new LLMenuItemCallGL(attachment->getName(), |
2006 | &handle_detach_from_avatar, object_attached, attachment)); | 2024 | &handle_detach_from_avatar, object_attached, attachment)); |
@@ -2017,8 +2035,11 @@ void LLVOAvatar::buildCharacter() | |||
2017 | { | 2035 | { |
2018 | continue; | 2036 | continue; |
2019 | } | 2037 | } |
2020 | gAttachSubMenu->append(new LLMenuItemCallGL(attachment->getName(), | 2038 | LLMenuItemCallGL* item = new LLMenuItemCallGL(attachment->getName(), |
2021 | &handle_attach_to_avatar, object_selected_and_point_valid, &attach_label, attachment)); | 2039 | NULL, &object_selected_and_point_valid, &attach_label, attachment); |
2040 | item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", mAttachmentPoints.reverseLookup(attachment)); | ||
2041 | gAttachSubMenu->append(item); | ||
2042 | |||
2022 | gDetachSubMenu->append(new LLMenuItemCallGL(attachment->getName(), | 2043 | gDetachSubMenu->append(new LLMenuItemCallGL(attachment->getName(), |
2023 | &handle_detach_from_avatar, object_attached, &detach_label, attachment)); | 2044 | &handle_detach_from_avatar, object_attached, &detach_label, attachment)); |
2024 | 2045 | ||
@@ -2068,8 +2089,10 @@ void LLVOAvatar::buildCharacter() | |||
2068 | 2089 | ||
2069 | LLViewerJointAttachment* attachment = attach_it->second; | 2090 | LLViewerJointAttachment* attachment = attach_it->second; |
2070 | 2091 | ||
2071 | gAttachBodyPartPieMenus[group]->append(new LLMenuItemCallGL(attachment->getName(), | 2092 | LLMenuItemCallGL* item = new LLMenuItemCallGL(attachment->getName(), |
2072 | &handle_attach_to_avatar, object_selected_and_point_valid, attachment)); | 2093 | NULL, object_selected_and_point_valid); |
2094 | gAttachBodyPartPieMenus[group]->append(item); | ||
2095 | item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", mAttachmentPoints.reverseLookup(attachment)); | ||
2073 | gDetachBodyPartPieMenus[group]->append(new LLMenuItemCallGL(attachment->getName(), | 2096 | gDetachBodyPartPieMenus[group]->append(new LLMenuItemCallGL(attachment->getName(), |
2074 | &handle_detach_from_avatar, object_attached, attachment)); | 2097 | &handle_detach_from_avatar, object_attached, attachment)); |
2075 | 2098 | ||
@@ -2089,7 +2112,7 @@ void LLVOAvatar::releaseMeshData() | |||
2089 | { | 2112 | { |
2090 | LLMemType mt(LLMemType::MTYPE_AVATAR); | 2113 | LLMemType mt(LLMemType::MTYPE_AVATAR); |
2091 | 2114 | ||
2092 | if (sInstances.getLength() < AVATAR_AGP_RELEASE_THRESHOLD || mIsDummy) | 2115 | if (sInstances.size() < AVATAR_RELEASE_THRESHOLD || mIsDummy) |
2093 | { | 2116 | { |
2094 | return; | 2117 | return; |
2095 | } | 2118 | } |
@@ -2106,18 +2129,11 @@ void LLVOAvatar::releaseMeshData() | |||
2106 | mEyeBallRightLOD.setValid(FALSE, TRUE); | 2129 | mEyeBallRightLOD.setValid(FALSE, TRUE); |
2107 | mSkirtLOD.setValid(FALSE, TRUE); | 2130 | mSkirtLOD.setValid(FALSE, TRUE); |
2108 | 2131 | ||
2109 | //cleanup AGP data | 2132 | //cleanup data |
2110 | if (mDrawable.notNull()) | 2133 | if (mDrawable.notNull()) |
2111 | { | 2134 | { |
2112 | LLFace* facep = mDrawable->getFace(0); | 2135 | LLFace* facep = mDrawable->getFace(0); |
2113 | facep->setSize(0, 0); | 2136 | facep->setSize(0, 0); |
2114 | mNumAGPVertices = 0; | ||
2115 | |||
2116 | // You need to reset the vertex data in order to guarantee | ||
2117 | // that the data is deallocated, AND you start at the 0 index | ||
2118 | // when you restore the face. We're assuming ONLY ONE FACE per | ||
2119 | // avatar pool, this logic is broken if that isn't the case! | ||
2120 | facep->getPool()->resetVertexData(0); | ||
2121 | } | 2137 | } |
2122 | 2138 | ||
2123 | for (LLViewerJointAttachment *attachmentPoint = mAttachmentPoints.getFirstData(); | 2139 | for (LLViewerJointAttachment *attachmentPoint = mAttachmentPoints.getFirstData(); |
@@ -2161,7 +2177,7 @@ void LLVOAvatar::restoreMeshData() | |||
2161 | } | 2177 | } |
2162 | 2178 | ||
2163 | // force mesh update as LOD might not have changed to trigger this | 2179 | // force mesh update as LOD might not have changed to trigger this |
2164 | updateMeshData(); | 2180 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE); |
2165 | } | 2181 | } |
2166 | 2182 | ||
2167 | //----------------------------------------------------------------------------- | 2183 | //----------------------------------------------------------------------------- |
@@ -2174,29 +2190,28 @@ void LLVOAvatar::updateMeshData() | |||
2174 | LLFace* facep = mDrawable->getFace(0); | 2190 | LLFace* facep = mDrawable->getFace(0); |
2175 | 2191 | ||
2176 | U32 num_vertices = 0; | 2192 | U32 num_vertices = 0; |
2193 | U32 num_indices = 0; | ||
2177 | 2194 | ||
2178 | // this order is determined by number of LODS | 2195 | // this order is determined by number of LODS |
2179 | // if a mesh earlier in this list changed LODs while a later mesh doesn't, | 2196 | // if a mesh earlier in this list changed LODs while a later mesh doesn't, |
2180 | // the later mesh's index offset will be inaccurate | 2197 | // the later mesh's index offset will be inaccurate |
2181 | mEyeBallLeftLOD.updateFaceSizes(num_vertices, mAdjustedPixelArea); | 2198 | mEyeBallLeftLOD.updateFaceSizes(num_vertices, num_indices, mAdjustedPixelArea); |
2182 | mEyeBallRightLOD.updateFaceSizes(num_vertices, mAdjustedPixelArea); | 2199 | mEyeBallRightLOD.updateFaceSizes(num_vertices, num_indices, mAdjustedPixelArea); |
2183 | mEyeLashLOD.updateFaceSizes(num_vertices, mAdjustedPixelArea); | 2200 | mEyeLashLOD.updateFaceSizes(num_vertices, num_indices, mAdjustedPixelArea); |
2184 | mHeadLOD.updateFaceSizes(num_vertices, mAdjustedPixelArea); | 2201 | mHeadLOD.updateFaceSizes(num_vertices, num_indices, mAdjustedPixelArea); |
2185 | mLowerBodyLOD.updateFaceSizes(num_vertices, mAdjustedPixelArea); | 2202 | mLowerBodyLOD.updateFaceSizes(num_vertices, num_indices, mAdjustedPixelArea); |
2186 | mSkirtLOD.updateFaceSizes(num_vertices, mAdjustedPixelArea); | 2203 | mSkirtLOD.updateFaceSizes(num_vertices, num_indices, mAdjustedPixelArea); |
2187 | mUpperBodyLOD.updateFaceSizes(num_vertices, mAdjustedPixelArea); | 2204 | mUpperBodyLOD.updateFaceSizes(num_vertices, num_indices, mAdjustedPixelArea); |
2188 | mHairLOD.updateFaceSizes(num_vertices, mAdjustedPixelArea); | 2205 | mHairLOD.updateFaceSizes(num_vertices, num_indices, mAdjustedPixelArea); |
2189 | 2206 | ||
2190 | if (num_vertices != mNumAGPVertices) | 2207 | // resize immediately |
2191 | { | 2208 | facep->setSize(num_vertices, num_indices); |
2192 | // resize immediately | 2209 | |
2193 | // llinfos << "Resizing avatar AGP buffer!" << llendl; | 2210 | facep->mVertexBuffer = new LLVertexBufferAvatar(); |
2194 | facep->getPool()->resetVertexData(num_vertices); | 2211 | facep->mVertexBuffer->allocateBuffer(num_vertices, num_indices, TRUE); |
2195 | facep->setSize(0,0); | 2212 | facep->setGeomIndex(0); |
2196 | facep->setSize(num_vertices, 0); | 2213 | facep->setIndicesIndex(0); |
2197 | mNumAGPVertices = num_vertices; | 2214 | |
2198 | } | ||
2199 | |||
2200 | // This is a hack! Avatars have their own pool, so we are detecting | 2215 | // This is a hack! Avatars have their own pool, so we are detecting |
2201 | // the case of more than one avatar in the pool (thus > 0 instead of >= 0) | 2216 | // the case of more than one avatar in the pool (thus > 0 instead of >= 0) |
2202 | if (facep->getGeomIndex() > 0) | 2217 | if (facep->getGeomIndex() > 0) |
@@ -2379,13 +2394,8 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
2379 | setPixelAreaAndAngle(gAgent); | 2394 | setPixelAreaAndAngle(gAgent); |
2380 | 2395 | ||
2381 | // Update the LOD of the joints | 2396 | // Update the LOD of the joints |
2382 | static const F32 UPDATE_TIME = .5f; | 2397 | //static const F32 UPDATE_TIME = .5f; |
2383 | if (mUpdateLODTimer.hasExpired()) | 2398 | |
2384 | { | ||
2385 | mUpdateLODTimer.setTimerExpirySec(UPDATE_TIME * (.75f + ll_frand(0.5f))); | ||
2386 | updateJointLODs(); | ||
2387 | } | ||
2388 | |||
2389 | // force asynchronous drawable update | 2399 | // force asynchronous drawable update |
2390 | if(mDrawable.notNull() && !gNoRender) | 2400 | if(mDrawable.notNull() && !gNoRender) |
2391 | { | 2401 | { |
@@ -2445,6 +2455,17 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
2445 | 2455 | ||
2446 | updateCharacter(agent); | 2456 | updateCharacter(agent); |
2447 | 2457 | ||
2458 | |||
2459 | |||
2460 | if (LLVOAvatar::sJointDebug) | ||
2461 | { | ||
2462 | llinfos << getNVPair("FirstName")->getString() << getNVPair("LastName")->getString() << ": joint touches: " << LLJoint::sNumTouches << " updates: " << LLJoint::sNumUpdates << llendl; | ||
2463 | } | ||
2464 | |||
2465 | LLJoint::sNumUpdates = 0; | ||
2466 | LLJoint::sNumTouches = 0; | ||
2467 | |||
2468 | |||
2448 | if (gNoRender) | 2469 | if (gNoRender) |
2449 | { | 2470 | { |
2450 | return TRUE; | 2471 | return TRUE; |
@@ -2453,7 +2474,7 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
2453 | // *NOTE: this is necessary for the floating name text above your head. | 2474 | // *NOTE: this is necessary for the floating name text above your head. |
2454 | if (mDrawable.notNull()) | 2475 | if (mDrawable.notNull()) |
2455 | { | 2476 | { |
2456 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); | 2477 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_SHADOW, TRUE); |
2457 | } | 2478 | } |
2458 | 2479 | ||
2459 | // update attachments positions | 2480 | // update attachments positions |
@@ -2463,11 +2484,15 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
2463 | attachment; | 2484 | attachment; |
2464 | attachment = mAttachmentPoints.getNextData()) | 2485 | attachment = mAttachmentPoints.getNextData()) |
2465 | { | 2486 | { |
2466 | LLViewerObject *attached_object = attachment->getObject(0); | 2487 | LLViewerObject *attached_object = attachment->getObject(); |
2467 | if (attached_object && !attached_object->isDead() && attachment->getValid()) | 2488 | |
2489 | BOOL visibleAttachment = isVisible() || !(attached_object && attached_object->mDrawable->getSpatialBridge() | ||
2490 | && (attached_object->mDrawable->getSpatialBridge()->getRadius() < 2.0)); | ||
2491 | |||
2492 | if (visibleAttachment && attached_object && !attached_object->isDead() && attachment->getValid()) | ||
2468 | { | 2493 | { |
2469 | // if selecting any attachments, update all of them as non-damped | 2494 | // if selecting any attachments, update all of them as non-damped |
2470 | if (gSelectMgr->getObjectCount() && gSelectMgr->selectionIsAttachment()) | 2495 | if (gSelectMgr->getSelection()->getObjectCount() && gSelectMgr->getSelection()->isAttachment()) |
2471 | { | 2496 | { |
2472 | gPipeline.updateMoveNormalAsync(attached_object->mDrawable); | 2497 | gPipeline.updateMoveNormalAsync(attached_object->mDrawable); |
2473 | } | 2498 | } |
@@ -2618,9 +2643,9 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
2618 | const F32 FADE_DURATION = gSavedSettings.getF32("RenderNameFadeDuration"); // seconds | 2643 | const F32 FADE_DURATION = gSavedSettings.getF32("RenderNameFadeDuration"); // seconds |
2619 | BOOL visible_chat = gSavedSettings.getBOOL("UseChatBubbles") && (mChats.size() || mTyping); | 2644 | BOOL visible_chat = gSavedSettings.getBOOL("UseChatBubbles") && (mChats.size() || mTyping); |
2620 | BOOL render_name = visible_chat || | 2645 | BOOL render_name = visible_chat || |
2621 | (mVisible && | 2646 | (isVisible() && |
2622 | (sRenderName == RENDER_NAME_ALWAYS) || | 2647 | ((sRenderName == RENDER_NAME_ALWAYS) || |
2623 | (sRenderName == RENDER_NAME_FADE && time_visible < NAME_SHOW_TIME)); | 2648 | (sRenderName == RENDER_NAME_FADE && time_visible < NAME_SHOW_TIME))); |
2624 | // If it's your own avatar, don't draw in mouselook, and don't | 2649 | // If it's your own avatar, don't draw in mouselook, and don't |
2625 | // draw if we're specifically hiding our own name. | 2650 | // draw if we're specifically hiding our own name. |
2626 | if (mIsSelf) | 2651 | if (mIsSelf) |
@@ -2737,53 +2762,55 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
2737 | (is_away != mNameAway || is_busy != mNameBusy || is_muted != mNameMute) | 2762 | (is_away != mNameAway || is_busy != mNameBusy || is_muted != mNameMute) |
2738 | || is_appearance != mNameAppearance) | 2763 | || is_appearance != mNameAppearance) |
2739 | { | 2764 | { |
2740 | char line[MAX_STRING]; | 2765 | char line[MAX_STRING]; /* Flawfinder: ignore */ |
2741 | if (title && title->getString() && title->getString()[0] != '\0') | 2766 | if (title && title->getString() && title->getString()[0] != '\0') |
2742 | { | 2767 | { |
2743 | strcpy(line, title->getString() ); | 2768 | strncpy(line, title->getString(), MAX_STRING -1 ); /* Flawfinder: ignore */ |
2744 | strcat(line, "\n"); | 2769 | line[MAX_STRING -1] = '\0'; |
2745 | strcat(line, firstname->getString() ); | 2770 | strcat(line, "\n"); /* Flawfinder: ignore */ |
2771 | strncat(line, firstname->getString(), MAX_STRING - strlen(line) -1 ); /* Flawfinder: ignore */ | ||
2746 | } | 2772 | } |
2747 | else | 2773 | else |
2748 | { | 2774 | { |
2749 | strcpy(line, firstname->getString() ); | 2775 | strncpy(line, firstname->getString(), MAX_STRING -1 ); /* Flawfinder: ignore */ |
2776 | line[MAX_STRING -1] = '\0'; | ||
2750 | } | 2777 | } |
2751 | 2778 | ||
2752 | strcat(line, " "); | 2779 | strcat(line, " "); /* Flawfinder: ignore */ |
2753 | strcat(line, lastname->getString()); | 2780 | strncat(line, lastname->getString(), MAX_STRING - strlen(line) -1); /* Flawfinder: ignore */ |
2754 | BOOL need_comma = FALSE; | 2781 | BOOL need_comma = FALSE; |
2755 | 2782 | ||
2756 | if (is_away || is_muted || is_busy) | 2783 | if (is_away || is_muted || is_busy) |
2757 | { | 2784 | { |
2758 | strcat(line, " ("); | 2785 | strcat(line, " ("); /* Flawfinder: ignore */ |
2759 | if (is_away) | 2786 | if (is_away) |
2760 | { | 2787 | { |
2761 | strcat(line, "Away"); | 2788 | strcat(line, "Away"); /* Flawfinder: ignore */ |
2762 | need_comma = TRUE; | 2789 | need_comma = TRUE; |
2763 | } | 2790 | } |
2764 | if (is_busy) | 2791 | if (is_busy) |
2765 | { | 2792 | { |
2766 | if (need_comma) | 2793 | if (need_comma) |
2767 | { | 2794 | { |
2768 | strcat(line, ", "); | 2795 | strcat(line, ", "); /* Flawfinder: ignore */ |
2769 | } | 2796 | } |
2770 | strcat(line, "Busy"); | 2797 | strcat(line, "Busy"); /* Flawfinder: ignore */ |
2771 | need_comma = TRUE; | 2798 | need_comma = TRUE; |
2772 | } | 2799 | } |
2773 | if (is_muted) | 2800 | if (is_muted) |
2774 | { | 2801 | { |
2775 | if (need_comma) | 2802 | if (need_comma) |
2776 | { | 2803 | { |
2777 | strcat(line, ", "); | 2804 | strcat(line, ", "); /* Flawfinder: ignore */ |
2778 | } | 2805 | } |
2779 | strcat(line, "Muted"); | 2806 | strcat(line, "Muted"); /* Flawfinder: ignore */ |
2780 | need_comma = TRUE; | 2807 | need_comma = TRUE; |
2781 | } | 2808 | } |
2782 | strcat(line,")"); | 2809 | strcat(line,")"); /* Flawfinder: ignore */ |
2783 | } | 2810 | } |
2784 | if (is_appearance) | 2811 | if (is_appearance) |
2785 | { | 2812 | { |
2786 | strcat(line, "\n(Editing Appearance)"); | 2813 | strcat(line, "\n(Editing Appearance)"); /* Flawfinder: ignore */ |
2787 | } | 2814 | } |
2788 | mNameAway = is_away; | 2815 | mNameAway = is_away; |
2789 | mNameBusy = is_busy; | 2816 | mNameBusy = is_busy; |
@@ -2805,7 +2832,7 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
2805 | mNameText->setLabel(mNameString); | 2832 | mNameText->setLabel(mNameString); |
2806 | } | 2833 | } |
2807 | 2834 | ||
2808 | char line[MAX_STRING]; | 2835 | char line[MAX_STRING]; /* Flawfinder: ignore */ |
2809 | line[0] = '\0'; | 2836 | line[0] = '\0'; |
2810 | std::deque<LLChat>::iterator chat_iter = mChats.begin(); | 2837 | std::deque<LLChat>::iterator chat_iter = mChats.begin(); |
2811 | mNameText->clearString(); | 2838 | mNameText->clearString(); |
@@ -2922,22 +2949,24 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | |||
2922 | 2949 | ||
2923 | if (!mBeam.isNull()) | 2950 | if (!mBeam.isNull()) |
2924 | { | 2951 | { |
2952 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | ||
2953 | |||
2925 | if (gAgent.mPointAt.notNull()) | 2954 | if (gAgent.mPointAt.notNull()) |
2926 | { | 2955 | { |
2927 | // get point from pointat effect | 2956 | // get point from pointat effect |
2928 | mBeam->setPositionGlobal(gAgent.mPointAt->getPointAtPosGlobal()); | 2957 | mBeam->setPositionGlobal(gAgent.mPointAt->getPointAtPosGlobal()); |
2929 | mBeam->triggerLocal(); | 2958 | mBeam->triggerLocal(); |
2930 | } | 2959 | } |
2931 | else if (gSelectMgr->getFirstRootObject() && | 2960 | else if (selection->getFirstRootObject() && |
2932 | gSelectMgr->getSelectType() != SELECT_TYPE_HUD) | 2961 | selection->getSelectType() != SELECT_TYPE_HUD) |
2933 | { | 2962 | { |
2934 | LLViewerObject* objectp = gSelectMgr->getFirstRootObject(); | 2963 | LLViewerObject* objectp = selection->getFirstRootObject(); |
2935 | mBeam->setTargetObject(objectp); | 2964 | mBeam->setTargetObject(objectp); |
2936 | } | 2965 | } |
2937 | else | 2966 | else |
2938 | { | 2967 | { |
2939 | mBeam->setTargetObject(NULL); | 2968 | mBeam->setTargetObject(NULL); |
2940 | LLTool *tool = gToolMgr->getCurrentTool( gKeyboard->currentMask(TRUE) ); | 2969 | LLTool *tool = gToolMgr->getCurrentTool(); |
2941 | if (tool->isEditing()) | 2970 | if (tool->isEditing()) |
2942 | { | 2971 | { |
2943 | if (tool->getEditingObject()) | 2972 | if (tool->getEditingObject()) |
@@ -2993,6 +3022,16 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
2993 | { | 3022 | { |
2994 | LLMemType mt(LLMemType::MTYPE_AVATAR); | 3023 | LLMemType mt(LLMemType::MTYPE_AVATAR); |
2995 | 3024 | ||
3025 | // update screen joint size | ||
3026 | if (mScreenp) | ||
3027 | { | ||
3028 | F32 aspect = gCamera->getAspect(); | ||
3029 | LLVector3 scale(1.f, aspect, 1.f); | ||
3030 | mScreenp->setScale(scale); | ||
3031 | mScreenp->updateWorldMatrixChildren(); | ||
3032 | resetHUDAttachments(); | ||
3033 | } | ||
3034 | |||
2996 | // clear debug text | 3035 | // clear debug text |
2997 | mDebugText.clear(); | 3036 | mDebugText.clear(); |
2998 | 3037 | ||
@@ -3005,28 +3044,30 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
3005 | { | 3044 | { |
3006 | if (motionp->getMinPixelArea() < getPixelArea()) | 3045 | if (motionp->getMinPixelArea() < getPixelArea()) |
3007 | { | 3046 | { |
3008 | char output[256]; | 3047 | char output[MAX_STRING]; /* Flawfinder: ignore */ |
3009 | if (motionp->getName().empty()) | 3048 | if (motionp->getName().empty()) |
3010 | { | 3049 | { |
3011 | sprintf(output, "%s - %d", motionp->getID().getString().c_str(), (U32)motionp->getPriority()); | 3050 | snprintf( /* Flawfinder: ignore */ |
3051 | output, | ||
3052 | MAX_STRING, | ||
3053 | "%s - %d", | ||
3054 | motionp->getID().asString().c_str(), | ||
3055 | (U32)motionp->getPriority()); | ||
3012 | } | 3056 | } |
3013 | else | 3057 | else |
3014 | { | 3058 | { |
3015 | sprintf(output, "%s - %d", motionp->getName().c_str(), (U32)motionp->getPriority()); | 3059 | snprintf( /* Flawfinder: ignore */ |
3060 | output, | ||
3061 | MAX_STRING, | ||
3062 | "%s - %d", | ||
3063 | motionp->getName().c_str(), | ||
3064 | (U32)motionp->getPriority()); | ||
3016 | } | 3065 | } |
3017 | addDebugText(output); | 3066 | addDebugText(output); |
3018 | } | 3067 | } |
3019 | } | 3068 | } |
3020 | } | 3069 | } |
3021 | 3070 | ||
3022 | if (LLVOAvatar::sJointDebug) | ||
3023 | { | ||
3024 | llinfos << getNVPair("FirstName")->getString() << ": joint touches: " << LLJoint::sNumTouches << " updates: " << LLJoint::sNumUpdates << llendl; | ||
3025 | |||
3026 | LLJoint::sNumUpdates = 0; | ||
3027 | LLJoint::sNumTouches = 0; | ||
3028 | } | ||
3029 | // llinfos << mPixelArea << llendl; | ||
3030 | if (gNoRender) | 3071 | if (gNoRender) |
3031 | { | 3072 | { |
3032 | // Hack if we're running drones... | 3073 | // Hack if we're running drones... |
@@ -3045,10 +3086,15 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
3045 | return; | 3086 | return; |
3046 | } | 3087 | } |
3047 | 3088 | ||
3089 | if (!mIsSelf && !isVisible()) | ||
3090 | { | ||
3091 | return; | ||
3092 | } | ||
3093 | |||
3048 | // change animation time quanta based on avatar render load | 3094 | // change animation time quanta based on avatar render load |
3049 | if (!mIsSelf) | 3095 | if (!mIsSelf) |
3050 | { | 3096 | { |
3051 | F32 time_quantum = clamp_rescale((F32)sInstances.getLength(), 10.f, 35.f, 0.f, 0.25f); | 3097 | F32 time_quantum = clamp_rescale((F32)sInstances.size(), 10.f, 35.f, 0.f, 0.25f); |
3052 | F32 pixel_area_scale = clamp_rescale(mPixelArea, 100, 5000, 1.f, 0.f); | 3098 | F32 pixel_area_scale = clamp_rescale(mPixelArea, 100, 5000, 1.f, 0.f); |
3053 | F32 time_step = time_quantum * pixel_area_scale; | 3099 | F32 time_step = time_quantum * pixel_area_scale; |
3054 | if (time_step != 0.f) | 3100 | if (time_step != 0.f) |
@@ -3077,10 +3123,6 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
3077 | mTimeVisible.reset(); | 3123 | mTimeVisible.reset(); |
3078 | } | 3124 | } |
3079 | 3125 | ||
3080 | // update screen joint size | ||
3081 | mScreenp->setScale(LLVector3(1.f, gCamera->getAspect(), 1.f)); | ||
3082 | mScreenp->updateWorldMatrixChildren(); | ||
3083 | |||
3084 | //-------------------------------------------------------------------- | 3126 | //-------------------------------------------------------------------- |
3085 | // create local variables in world coords for region position values | 3127 | // create local variables in world coords for region position values |
3086 | //-------------------------------------------------------------------- | 3128 | //-------------------------------------------------------------------- |
@@ -3091,6 +3133,8 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
3091 | xyVel.mV[VZ] = 0.0f; | 3133 | xyVel.mV[VZ] = 0.0f; |
3092 | speed = xyVel.magVec(); | 3134 | speed = xyVel.magVec(); |
3093 | 3135 | ||
3136 | BOOL throttle = TRUE; | ||
3137 | |||
3094 | if (!(mIsSitting && getParent())) | 3138 | if (!(mIsSitting && getParent())) |
3095 | { | 3139 | { |
3096 | //-------------------------------------------------------------------- | 3140 | //-------------------------------------------------------------------- |
@@ -3101,6 +3145,7 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
3101 | if (mTimeLast == 0.0f) | 3145 | if (mTimeLast == 0.0f) |
3102 | { | 3146 | { |
3103 | mTimeLast = animation_time; | 3147 | mTimeLast = animation_time; |
3148 | throttle = FALSE; | ||
3104 | 3149 | ||
3105 | // put the pelvis at slaved position/mRotation | 3150 | // put the pelvis at slaved position/mRotation |
3106 | mRoot.setWorldPosition( getPositionAgent() ); // first frame | 3151 | mRoot.setWorldPosition( getPositionAgent() ); // first frame |
@@ -3144,7 +3189,16 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
3144 | // correct for the fact that the pelvis is not necessarily the center | 3189 | // correct for the fact that the pelvis is not necessarily the center |
3145 | // of the agent's physical representation | 3190 | // of the agent's physical representation |
3146 | root_pos.mdV[VZ] -= (0.5f * mBodySize.mV[VZ]) - mPelvisToFoot; | 3191 | root_pos.mdV[VZ] -= (0.5f * mBodySize.mV[VZ]) - mPelvisToFoot; |
3147 | mRoot.setWorldPosition(gAgent.getPosAgentFromGlobal(root_pos) ); // regular update | 3192 | |
3193 | |||
3194 | LLVector3 newPosition = gAgent.getPosAgentFromGlobal(root_pos); | ||
3195 | |||
3196 | if (newPosition != mRoot.getXform()->getWorldPosition()) | ||
3197 | { | ||
3198 | mRoot.touch(); | ||
3199 | mRoot.setWorldPosition(newPosition ); // regular update | ||
3200 | } | ||
3201 | |||
3148 | 3202 | ||
3149 | //-------------------------------------------------------------------- | 3203 | //-------------------------------------------------------------------- |
3150 | // Propagate viewer object rotation to root of avatar | 3204 | // Propagate viewer object rotation to root of avatar |
@@ -3314,9 +3368,10 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
3314 | //} | 3368 | //} |
3315 | //end Ventrella | 3369 | //end Ventrella |
3316 | 3370 | ||
3317 | F32 u = llclamp((deltaTime / pelvis_lag_time), 0.0f, 1.0f); | 3371 | F32 u = llclamp((deltaTime / pelvis_lag_time), 0.0f, 1.0f); |
3318 | 3372 | ||
3319 | mRoot.setWorldRotation( slerp(u, mRoot.getWorldRotation(), wQv) ); | 3373 | mRoot.setWorldRotation( slerp(u, mRoot.getWorldRotation(), wQv) ); |
3374 | |||
3320 | } | 3375 | } |
3321 | } | 3376 | } |
3322 | else if (mDrawable.notNull()) | 3377 | else if (mDrawable.notNull()) |
@@ -3328,8 +3383,17 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
3328 | //-------------------------------------------------------------------- | 3383 | //-------------------------------------------------------------------- |
3329 | // the rest should only be done when close enough to see it | 3384 | // the rest should only be done when close enough to see it |
3330 | //-------------------------------------------------------------------- | 3385 | //-------------------------------------------------------------------- |
3386 | |||
3387 | |||
3388 | if (mPixelArea > 12.0f) | ||
3389 | throttle = FALSE; | ||
3390 | if (mPixelArea < 400.0f) | ||
3391 | { | ||
3392 | throttle = (LLDrawable::getCurrentFrame()+mID.mData[0])%2 != 0; | ||
3393 | } | ||
3394 | |||
3331 | if ( !(mIsSitting && getParent()) && | 3395 | if ( !(mIsSitting && getParent()) && |
3332 | ((mPixelArea < 12.0f) || | 3396 | (throttle || |
3333 | (!isVisible() && (mPixelArea < MIN_PIXEL_AREA_FOR_COMPOSITE))) ) | 3397 | (!isVisible() && (mPixelArea < MIN_PIXEL_AREA_FOR_COMPOSITE))) ) |
3334 | { | 3398 | { |
3335 | mRoot.setWorldRotation( getRotation() ); | 3399 | mRoot.setWorldRotation( getRotation() ); |
@@ -3433,7 +3497,7 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) | |||
3433 | } | 3497 | } |
3434 | } | 3498 | } |
3435 | } | 3499 | } |
3436 | 3500 | ||
3437 | mRoot.updateWorldMatrixChildren(); | 3501 | mRoot.updateWorldMatrixChildren(); |
3438 | 3502 | ||
3439 | if (!mDebugText.size() && mText.notNull()) | 3503 | if (!mDebugText.size() && mText.notNull()) |
@@ -3490,10 +3554,8 @@ void LLVOAvatar::updateVisibility(BOOL force_invisible) | |||
3490 | else if (!force_invisible) | 3554 | else if (!force_invisible) |
3491 | { | 3555 | { |
3492 | // calculate avatar distance wrt head | 3556 | // calculate avatar distance wrt head |
3493 | LLVector3 pos = mDrawable->getPositionAgent(); | 3557 | mDrawable->updateDistance(*gCamera); |
3494 | pos -= gCamera->getOrigin(); | 3558 | |
3495 | mDrawable->mDistanceWRTCamera = pos.magVec(); | ||
3496 | |||
3497 | if (!mDrawable->getSpatialGroup() || mDrawable->getSpatialGroup()->isVisible()) | 3559 | if (!mDrawable->getSpatialGroup() || mDrawable->getSpatialGroup()->isVisible()) |
3498 | { | 3560 | { |
3499 | visible = TRUE; | 3561 | visible = TRUE; |
@@ -3565,9 +3627,9 @@ void LLVOAvatar::updateVisibility(BOOL force_invisible) | |||
3565 | attachment; | 3627 | attachment; |
3566 | attachment = mAttachmentPoints.getNextData()) | 3628 | attachment = mAttachmentPoints.getNextData()) |
3567 | { | 3629 | { |
3568 | if (attachment->getObject(0)) | 3630 | if (attachment->getObject()) |
3569 | { | 3631 | { |
3570 | if(attachment->getObject(0)->mDrawable->isVisible()) | 3632 | if(attachment->getObject()->mDrawable->isVisible()) |
3571 | { | 3633 | { |
3572 | llinfos << attachment->getName() << " visible" << llendl; | 3634 | llinfos << attachment->getName() << " visible" << llendl; |
3573 | } | 3635 | } |
@@ -3591,7 +3653,6 @@ void LLVOAvatar::updateVisibility(BOOL force_invisible) | |||
3591 | { | 3653 | { |
3592 | restoreMeshData(); | 3654 | restoreMeshData(); |
3593 | } | 3655 | } |
3594 | gPipeline.markVisible(mDrawable); | ||
3595 | } | 3656 | } |
3596 | else | 3657 | else |
3597 | { | 3658 | { |
@@ -3618,11 +3679,12 @@ void LLVOAvatar::updateVisibility(BOOL force_invisible) | |||
3618 | void LLVOAvatar::updateAllAvatarVisiblity() | 3679 | void LLVOAvatar::updateAllAvatarVisiblity() |
3619 | { | 3680 | { |
3620 | LLVOAvatar::sNumVisibleAvatars = 0; | 3681 | LLVOAvatar::sNumVisibleAvatars = 0; |
3621 | LLVOAvatar *avatarp; | 3682 | |
3622 | |||
3623 | F32 render_priority = (F32)LLVOAvatar::sMaxVisible; | 3683 | F32 render_priority = (F32)LLVOAvatar::sMaxVisible; |
3624 | for (avatarp = (LLVOAvatar*)sInstances.getFirstData(); avatarp; avatarp = (LLVOAvatar*)sInstances.getNextData()) | 3684 | for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); |
3685 | iter != LLCharacter::sInstances.end(); ++iter) | ||
3625 | { | 3686 | { |
3687 | LLVOAvatar* avatarp = (LLVOAvatar*) *iter; | ||
3626 | if (avatarp->isDead()) | 3688 | if (avatarp->isDead()) |
3627 | { | 3689 | { |
3628 | continue; | 3690 | continue; |
@@ -3661,7 +3723,7 @@ BOOL LLVOAvatar::needsRenderBeam() | |||
3661 | { | 3723 | { |
3662 | return FALSE; | 3724 | return FALSE; |
3663 | } | 3725 | } |
3664 | LLTool *tool = gToolMgr->getCurrentTool( gKeyboard->currentMask(TRUE) ); | 3726 | LLTool *tool = gToolMgr->getCurrentTool(); |
3665 | 3727 | ||
3666 | BOOL is_touching_or_grabbing = (tool == gToolGrab && gToolGrab->isEditing()); | 3728 | BOOL is_touching_or_grabbing = (tool == gToolGrab && gToolGrab->isEditing()); |
3667 | if (gToolGrab->getEditingObject() && | 3729 | if (gToolGrab->getEditingObject() && |
@@ -3760,26 +3822,22 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) | |||
3760 | 3822 | ||
3761 | if (pass == AVATAR_RENDER_PASS_SINGLE) | 3823 | if (pass == AVATAR_RENDER_PASS_SINGLE) |
3762 | { | 3824 | { |
3825 | BOOL first_pass = TRUE; | ||
3763 | if (!mIsSelf || gAgent.needsRenderHead()) | 3826 | if (!mIsSelf || gAgent.needsRenderHead()) |
3764 | { | 3827 | { |
3765 | num_indices += mHeadLOD.render(mAdjustedPixelArea); | 3828 | num_indices += mHeadLOD.render(mAdjustedPixelArea); |
3829 | first_pass = FALSE; | ||
3766 | } | 3830 | } |
3767 | num_indices += mUpperBodyLOD.render(mAdjustedPixelArea); | 3831 | num_indices += mUpperBodyLOD.render(mAdjustedPixelArea, first_pass); |
3768 | num_indices += mLowerBodyLOD.render(mAdjustedPixelArea); | 3832 | num_indices += mLowerBodyLOD.render(mAdjustedPixelArea, FALSE); |
3769 | if( isWearingWearableType( WT_SKIRT ) ) | ||
3770 | { | ||
3771 | glAlphaFunc(GL_GREATER,0.25f); | ||
3772 | num_indices += mSkirtLOD.render(mAdjustedPixelArea); | ||
3773 | glAlphaFunc(GL_GREATER,0.01f); | ||
3774 | } | ||
3775 | 3833 | ||
3776 | if (!mIsSelf || gAgent.needsRenderHead()) | ||
3777 | { | 3834 | { |
3778 | num_indices += mEyeLashLOD.render(mAdjustedPixelArea); | 3835 | LLGLEnable blend(GL_BLEND); |
3779 | num_indices += mHairLOD.render(mAdjustedPixelArea); | 3836 | LLGLEnable test(GL_ALPHA_TEST); |
3837 | num_indices += renderTransparent(); | ||
3780 | } | 3838 | } |
3781 | } | 3839 | } |
3782 | else if (pass == AVATAR_RENDER_PASS_CLOTHING_INNER) | 3840 | /*else if (pass == AVATAR_RENDER_PASS_CLOTHING_INNER) |
3783 | { | 3841 | { |
3784 | if (!mIsSelf || gAgent.needsRenderHead()) | 3842 | if (!mIsSelf || gAgent.needsRenderHead()) |
3785 | { | 3843 | { |
@@ -3812,7 +3870,7 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) | |||
3812 | LLViewerJointMesh::sClothingMaskImageName = mLowerMaskTexName; | 3870 | LLViewerJointMesh::sClothingMaskImageName = mLowerMaskTexName; |
3813 | num_indices += mLowerBodyLOD.render(mAdjustedPixelArea); | 3871 | num_indices += mLowerBodyLOD.render(mAdjustedPixelArea); |
3814 | LLViewerJointMesh::sClothingMaskImageName = 0; | 3872 | LLViewerJointMesh::sClothingMaskImageName = 0; |
3815 | } | 3873 | }*/ |
3816 | 3874 | ||
3817 | LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE; | 3875 | LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE; |
3818 | 3876 | ||
@@ -3823,6 +3881,27 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) | |||
3823 | return num_indices; | 3881 | return num_indices; |
3824 | } | 3882 | } |
3825 | 3883 | ||
3884 | U32 LLVOAvatar::renderTransparent() | ||
3885 | { | ||
3886 | U32 num_indices = 0; | ||
3887 | BOOL first_pass = FALSE; | ||
3888 | if( isWearingWearableType( WT_SKIRT ) ) | ||
3889 | { | ||
3890 | glAlphaFunc(GL_GREATER,0.25f); | ||
3891 | num_indices += mSkirtLOD.render(mAdjustedPixelArea, FALSE); | ||
3892 | first_pass = FALSE; | ||
3893 | glAlphaFunc(GL_GREATER,0.01f); | ||
3894 | } | ||
3895 | |||
3896 | if (!mIsSelf || gAgent.needsRenderHead()) | ||
3897 | { | ||
3898 | num_indices += mEyeLashLOD.render(mAdjustedPixelArea, first_pass); | ||
3899 | num_indices += mHairLOD.render(mAdjustedPixelArea, FALSE); | ||
3900 | } | ||
3901 | |||
3902 | return num_indices; | ||
3903 | } | ||
3904 | |||
3826 | //----------------------------------------------------------------------------- | 3905 | //----------------------------------------------------------------------------- |
3827 | // renderRigid() | 3906 | // renderRigid() |
3828 | //----------------------------------------------------------------------------- | 3907 | //----------------------------------------------------------------------------- |
@@ -3851,6 +3930,39 @@ U32 LLVOAvatar::renderRigid() | |||
3851 | return num_indices; | 3930 | return num_indices; |
3852 | } | 3931 | } |
3853 | 3932 | ||
3933 | U32 LLVOAvatar::renderFootShadows() | ||
3934 | { | ||
3935 | U32 num_indices = 0; | ||
3936 | |||
3937 | if (!mIsBuilt) | ||
3938 | { | ||
3939 | return 0; | ||
3940 | } | ||
3941 | |||
3942 | if (mIsSelf && (!gAgent.needsRenderAvatar() || !gAgent.needsRenderHead())) | ||
3943 | { | ||
3944 | return 0; | ||
3945 | } | ||
3946 | |||
3947 | if (!mIsBuilt) | ||
3948 | { | ||
3949 | return 0; | ||
3950 | } | ||
3951 | |||
3952 | U32 foot_mask = LLVertexBuffer::MAP_VERTEX | | ||
3953 | LLVertexBuffer::MAP_TEXCOORD; | ||
3954 | |||
3955 | //render foot shadows | ||
3956 | LLGLEnable blend(GL_BLEND); | ||
3957 | mShadowImagep->bind(); | ||
3958 | glColor4fv(mShadow0Facep->getRenderColor().mV); | ||
3959 | mShadow0Facep->renderIndexed(foot_mask); | ||
3960 | glColor4fv(mShadow1Facep->getRenderColor().mV); | ||
3961 | mShadow1Facep->renderIndexed(foot_mask); | ||
3962 | |||
3963 | return num_indices; | ||
3964 | } | ||
3965 | |||
3854 | //----------------------------------------------------------------------------- | 3966 | //----------------------------------------------------------------------------- |
3855 | // renderCollisionVolumes() | 3967 | // renderCollisionVolumes() |
3856 | //----------------------------------------------------------------------------- | 3968 | //----------------------------------------------------------------------------- |
@@ -3867,6 +3979,7 @@ void LLVOAvatar::renderCollisionVolumes() | |||
3867 | //------------------------------------------------------------------------ | 3979 | //------------------------------------------------------------------------ |
3868 | void LLVOAvatar::updateTextures(LLAgent &agent) | 3980 | void LLVOAvatar::updateTextures(LLAgent &agent) |
3869 | { | 3981 | { |
3982 | // LLFastTimer ftm(LLFastTimer::FTM_TEMP5); | ||
3870 | BOOL render_avatar = TRUE; | 3983 | BOOL render_avatar = TRUE; |
3871 | 3984 | ||
3872 | if (mIsDummy || gNoRender) | 3985 | if (mIsDummy || gNoRender) |
@@ -3941,6 +4054,8 @@ void LLVOAvatar::updateTextures(LLAgent &agent) | |||
3941 | } | 4054 | } |
3942 | */ | 4055 | */ |
3943 | 4056 | ||
4057 | mMaxPixelArea = 0.f; | ||
4058 | mMinPixelArea = 99999999.f; | ||
3944 | for (U32 i = 0; i < getNumTEs(); i++) | 4059 | for (U32 i = 0; i < getNumTEs(); i++) |
3945 | { | 4060 | { |
3946 | LLViewerImage *imagep = getTEImage(i); | 4061 | LLViewerImage *imagep = getTEImage(i); |
@@ -3965,9 +4080,10 @@ void LLVOAvatar::updateTextures(LLAgent &agent) | |||
3965 | && imagep->getID() != IMG_DEFAULT_AVATAR | 4080 | && imagep->getID() != IMG_DEFAULT_AVATAR |
3966 | && !imagep->getTargetHost().isOk()) | 4081 | && !imagep->getTargetHost().isOk()) |
3967 | { | 4082 | { |
3968 | llwarns << "LLVOAvatar::updateTextures No host for texture " << imagep->getID() | 4083 | llwarns << "LLVOAvatar::updateTextures No host for texture " |
3969 | << " for avatar " << (mIsSelf ? "<myself>" : getID().getString()) | 4084 | << imagep->getID() << " for avatar " |
3970 | << " on host " << getRegion()->getHost() << llendl; | 4085 | << (mIsSelf ? "<myself>" : getID().asString().c_str()) |
4086 | << " on host " << getRegion()->getHost() << llendl; | ||
3971 | } | 4087 | } |
3972 | 4088 | ||
3973 | switch( i ) | 4089 | switch( i ) |
@@ -4037,40 +4153,35 @@ void LLVOAvatar::updateTextures(LLAgent &agent) | |||
4037 | case TEX_HEAD_BAKED: | 4153 | case TEX_HEAD_BAKED: |
4038 | if (head_baked) | 4154 | if (head_baked) |
4039 | { | 4155 | { |
4040 | imagep->setBoostLevel(boost_level); | 4156 | addBakedTextureStats( imagep, mPixelArea, texel_area_ratio, boost_level ); |
4041 | imagep->addTextureStats(mPixelArea, texel_area_ratio); | ||
4042 | } | 4157 | } |
4043 | break; | 4158 | break; |
4044 | 4159 | ||
4045 | case TEX_UPPER_BAKED: | 4160 | case TEX_UPPER_BAKED: |
4046 | if (upper_baked) | 4161 | if (upper_baked) |
4047 | { | 4162 | { |
4048 | imagep->setBoostLevel(boost_level); | 4163 | addBakedTextureStats( imagep, mPixelArea, texel_area_ratio, boost_level ); |
4049 | imagep->addTextureStats(mPixelArea, texel_area_ratio); | ||
4050 | } | 4164 | } |
4051 | break; | 4165 | break; |
4052 | 4166 | ||
4053 | case TEX_LOWER_BAKED: | 4167 | case TEX_LOWER_BAKED: |
4054 | if (lower_baked) | 4168 | if (lower_baked) |
4055 | { | 4169 | { |
4056 | imagep->setBoostLevel(boost_level); | 4170 | addBakedTextureStats( imagep, mPixelArea, texel_area_ratio, boost_level ); |
4057 | imagep->addTextureStats(mPixelArea, texel_area_ratio); | ||
4058 | } | 4171 | } |
4059 | break; | 4172 | break; |
4060 | 4173 | ||
4061 | case TEX_EYES_BAKED: | 4174 | case TEX_EYES_BAKED: |
4062 | if (eyes_baked) | 4175 | if (eyes_baked) |
4063 | { | 4176 | { |
4064 | imagep->setBoostLevel(boost_level); | 4177 | addBakedTextureStats( imagep, mPixelArea, texel_area_ratio, boost_level ); |
4065 | imagep->addTextureStats(mPixelArea, texel_area_ratio); | ||
4066 | } | 4178 | } |
4067 | break; | 4179 | break; |
4068 | 4180 | ||
4069 | case TEX_SKIRT_BAKED: | 4181 | case TEX_SKIRT_BAKED: |
4070 | if (skirt_baked) | 4182 | if (skirt_baked) |
4071 | { | 4183 | { |
4072 | imagep->setBoostLevel(boost_level); | 4184 | addBakedTextureStats( imagep, mPixelArea, texel_area_ratio, boost_level ); |
4073 | imagep->addTextureStats(mPixelArea, texel_area_ratio); | ||
4074 | } | 4185 | } |
4075 | break; | 4186 | break; |
4076 | 4187 | ||
@@ -4078,15 +4189,8 @@ void LLVOAvatar::updateTextures(LLAgent &agent) | |||
4078 | // Hair is neither a local texture used for baking, nor the output | 4189 | // Hair is neither a local texture used for baking, nor the output |
4079 | // of the baking process. It's just a texture that happens to be | 4190 | // of the baking process. It's just a texture that happens to be |
4080 | // used to draw avatars. Hence BOOST_AVATAR. JC | 4191 | // used to draw avatars. Hence BOOST_AVATAR. JC |
4081 | if (mIsSelf) | 4192 | boost_level = mIsSelf ? LLViewerImage::BOOST_AVATAR_SELF : LLViewerImage::BOOST_AVATAR; |
4082 | { | 4193 | addBakedTextureStats( imagep, mPixelArea, texel_area_ratio, boost_level ); |
4083 | imagep->setBoostLevel(LLViewerImage::BOOST_AVATAR_SELF); | ||
4084 | } | ||
4085 | else | ||
4086 | { | ||
4087 | imagep->setBoostLevel(LLViewerImage::BOOST_AVATAR); | ||
4088 | } | ||
4089 | imagep->addTextureStats(mPixelArea, texel_area_ratio); | ||
4090 | break; | 4194 | break; |
4091 | 4195 | ||
4092 | default: | 4196 | default: |
@@ -4096,6 +4200,11 @@ void LLVOAvatar::updateTextures(LLAgent &agent) | |||
4096 | } | 4200 | } |
4097 | } | 4201 | } |
4098 | 4202 | ||
4203 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) | ||
4204 | { | ||
4205 | setDebugText(llformat("%4.0f:%4.0f", fsqrtf(mMinPixelArea),fsqrtf(mMaxPixelArea))); | ||
4206 | } | ||
4207 | |||
4099 | if( render_avatar ) | 4208 | if( render_avatar ) |
4100 | { | 4209 | { |
4101 | mShadowImagep->addTextureStats(mPixelArea, 1.f); | 4210 | mShadowImagep->addTextureStats(mPixelArea, 1.f); |
@@ -4125,6 +4234,15 @@ void LLVOAvatar::addLocalTextureStats( LLVOAvatar::ELocTexIndex idx, LLViewerIma | |||
4125 | } | 4234 | } |
4126 | } | 4235 | } |
4127 | 4236 | ||
4237 | |||
4238 | void LLVOAvatar::addBakedTextureStats( LLViewerImage* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level) | ||
4239 | { | ||
4240 | mMaxPixelArea = llmax(pixel_area, mMaxPixelArea); | ||
4241 | mMinPixelArea = llmin(pixel_area, mMinPixelArea); | ||
4242 | imagep->addTextureStats(pixel_area, texel_area_ratio); | ||
4243 | imagep->setBoostLevel(boost_level); | ||
4244 | } | ||
4245 | |||
4128 | //----------------------------------------------------------------------------- | 4246 | //----------------------------------------------------------------------------- |
4129 | // resolveHeight() | 4247 | // resolveHeight() |
4130 | //----------------------------------------------------------------------------- | 4248 | //----------------------------------------------------------------------------- |
@@ -4409,14 +4527,7 @@ BOOL LLVOAvatar::stopMotion(const LLUUID& id, BOOL stop_immediate) | |||
4409 | { | 4527 | { |
4410 | if (mIsSelf) | 4528 | if (mIsSelf) |
4411 | { | 4529 | { |
4412 | if (id == ANIM_AGENT_STAND) | 4530 | gAgent.onAnimStop(id); |
4413 | { | ||
4414 | LLAgent::stopFidget(); | ||
4415 | } | ||
4416 | else if (id == ANIM_AGENT_AWAY) | ||
4417 | { | ||
4418 | gAgent.clearAFK(); | ||
4419 | } | ||
4420 | } | 4531 | } |
4421 | 4532 | ||
4422 | if (id == ANIM_AGENT_WALK) | 4533 | if (id == ANIM_AGENT_WALK) |
@@ -4609,7 +4720,7 @@ F32 LLVOAvatar::getTimeDilation() | |||
4609 | //----------------------------------------------------------------------------- | 4720 | //----------------------------------------------------------------------------- |
4610 | // LLVOAvatar::getPixelArea() | 4721 | // LLVOAvatar::getPixelArea() |
4611 | //----------------------------------------------------------------------------- | 4722 | //----------------------------------------------------------------------------- |
4612 | F32 LLVOAvatar::getPixelArea() | 4723 | F32 LLVOAvatar::getPixelArea() const |
4613 | { | 4724 | { |
4614 | if (mIsDummy) | 4725 | if (mIsDummy) |
4615 | { | 4726 | { |
@@ -4971,6 +5082,11 @@ BOOL LLVOAvatar::loadSkeletonNode () | |||
4971 | iter != sAvatarInfo->mAttachmentInfoList.end(); iter++) | 5082 | iter != sAvatarInfo->mAttachmentInfoList.end(); iter++) |
4972 | { | 5083 | { |
4973 | LLVOAvatarInfo::LLVOAvatarAttachmentInfo *info = *iter; | 5084 | LLVOAvatarInfo::LLVOAvatarAttachmentInfo *info = *iter; |
5085 | if (!isSelf() && info->mJointName == "mScreen") | ||
5086 | { //don't process screen joint for other avatars | ||
5087 | continue; | ||
5088 | } | ||
5089 | |||
4974 | LLViewerJointAttachment* attachment = new LLViewerJointAttachment(); | 5090 | LLViewerJointAttachment* attachment = new LLViewerJointAttachment(); |
4975 | 5091 | ||
4976 | attachment->setName(info->mName); | 5092 | attachment->setName(info->mName); |
@@ -5321,15 +5437,6 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent) | |||
5321 | { | 5437 | { |
5322 | LLMemType mt(LLMemType::MTYPE_AVATAR); | 5438 | LLMemType mt(LLMemType::MTYPE_AVATAR); |
5323 | 5439 | ||
5324 | LLVector3 viewer_pos_agent = agent.getCameraPositionAgent(); | ||
5325 | LLVector3 pos_agent; | ||
5326 | |||
5327 | pos_agent = getRenderPosition(); | ||
5328 | |||
5329 | F32 dx = viewer_pos_agent.mV[VX] - pos_agent.mV[VX]; | ||
5330 | F32 dy = viewer_pos_agent.mV[VY] - pos_agent.mV[VY]; | ||
5331 | F32 dz = viewer_pos_agent.mV[VZ] - pos_agent.mV[VZ]; | ||
5332 | |||
5333 | F32 max_scale = getMaxScale(); | 5440 | F32 max_scale = getMaxScale(); |
5334 | F32 mid_scale = getMidScale(); | 5441 | F32 mid_scale = getMidScale(); |
5335 | F32 min_scale = llmin( getScale().mV[VX], llmin( getScale().mV[VY], getScale().mV[VZ] ) ); | 5442 | F32 min_scale = llmin( getScale().mV[VX], llmin( getScale().mV[VY], getScale().mV[VZ] ) ); |
@@ -5338,7 +5445,7 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent) | |||
5338 | // to try to get a min distance from face, subtract min_scale/2 from the range. | 5445 | // to try to get a min distance from face, subtract min_scale/2 from the range. |
5339 | // This means we'll load too much detail sometimes, but that's better than not enough | 5446 | // This means we'll load too much detail sometimes, but that's better than not enough |
5340 | // I don't think there's a better way to do this without calculating distance per-poly | 5447 | // I don't think there's a better way to do this without calculating distance per-poly |
5341 | F32 range = sqrt(dx*dx + dy*dy + dz*dz) - min_scale/2; | 5448 | F32 range = (getRenderPosition()-gCamera->getOrigin()).magVec() - min_scale/2; |
5342 | 5449 | ||
5343 | if (range < 0.001f) // range == zero | 5450 | if (range < 0.001f) // range == zero |
5344 | { | 5451 | { |
@@ -5373,17 +5480,11 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent) | |||
5373 | //----------------------------------------------------------------------------- | 5480 | //----------------------------------------------------------------------------- |
5374 | // updateJointLODs() | 5481 | // updateJointLODs() |
5375 | //----------------------------------------------------------------------------- | 5482 | //----------------------------------------------------------------------------- |
5376 | void LLVOAvatar::updateJointLODs() | 5483 | BOOL LLVOAvatar::updateJointLODs() |
5377 | { | 5484 | { |
5378 | if (!mMeshValid) | ||
5379 | { | ||
5380 | return; | ||
5381 | } | ||
5382 | |||
5383 | F32 lod_factor = (sLODFactor * AVATAR_LOD_TWEAK_RANGE + (1.f - AVATAR_LOD_TWEAK_RANGE)); | 5485 | F32 lod_factor = (sLODFactor * AVATAR_LOD_TWEAK_RANGE + (1.f - AVATAR_LOD_TWEAK_RANGE)); |
5384 | F32 avatar_num_min_factor = clamp_rescale(sLODFactor, 0.f, 1.f, 0.25f, 0.6f); | 5486 | F32 avatar_num_min_factor = clamp_rescale(sLODFactor, 0.f, 1.f, 0.25f, 0.6f); |
5385 | F32 avatar_num_factor = clamp_rescale((F32)sNumVisibleAvatars, 8, 25, 1.f, avatar_num_min_factor); | 5487 | F32 avatar_num_factor = clamp_rescale((F32)sNumVisibleAvatars, 8, 25, 1.f, avatar_num_min_factor); |
5386 | |||
5387 | { | 5488 | { |
5388 | if (mIsSelf) | 5489 | if (mIsSelf) |
5389 | { | 5490 | { |
@@ -5406,16 +5507,17 @@ void LLVOAvatar::updateJointLODs() | |||
5406 | mAdjustedPixelArea = (F32)mPixelArea * lod_factor * lod_factor * avatar_num_factor * avatar_num_factor; | 5507 | mAdjustedPixelArea = (F32)mPixelArea * lod_factor * lod_factor * avatar_num_factor * avatar_num_factor; |
5407 | } | 5508 | } |
5408 | 5509 | ||
5409 | // now select meshes to render based on adjusted pixel area, and perform AGP data push as necessary | 5510 | // now select meshes to render based on adjusted pixel area |
5410 | BOOL res = mRoot.updateLOD(mAdjustedPixelArea, TRUE); | 5511 | BOOL res = mRoot.updateLOD(mAdjustedPixelArea, TRUE); |
5411 | if (res) | 5512 | if (res) |
5412 | { | 5513 | { |
5413 | sNumLODChangesThisFrame++; | 5514 | sNumLODChangesThisFrame++; |
5414 | updateMeshData(); | 5515 | dirtyMesh(); |
5516 | return TRUE; | ||
5415 | } | 5517 | } |
5416 | } | 5518 | } |
5417 | 5519 | ||
5418 | return; | 5520 | return FALSE; |
5419 | } | 5521 | } |
5420 | 5522 | ||
5421 | //----------------------------------------------------------------------------- | 5523 | //----------------------------------------------------------------------------- |
@@ -5426,24 +5528,22 @@ LLDrawable *LLVOAvatar::createDrawable(LLPipeline *pipeline) | |||
5426 | pipeline->allocDrawable(this); | 5528 | pipeline->allocDrawable(this); |
5427 | mDrawable->setLit(FALSE); | 5529 | mDrawable->setLit(FALSE); |
5428 | 5530 | ||
5429 | LLDrawPool *poolp = gPipeline.getPool(LLDrawPool::POOL_AVATAR); | 5531 | LLDrawPoolAvatar *poolp = (LLDrawPoolAvatar*) gPipeline.getPool(LLDrawPool::POOL_AVATAR); |
5430 | 5532 | ||
5431 | // Only a single face (one per avatar) | 5533 | // Only a single face (one per avatar) |
5432 | mDrawable->setState(LLDrawable::ACTIVE); | 5534 | mDrawable->setState(LLDrawable::ACTIVE); |
5433 | mDrawable->addFace(poolp, NULL); | 5535 | mDrawable->addFace(poolp, NULL); |
5536 | mDrawable->setRenderType(LLPipeline::RENDER_TYPE_AVATAR); | ||
5434 | 5537 | ||
5435 | poolp = gPipeline.getPool(LLDrawPool::POOL_ALPHA); | ||
5436 | |||
5437 | LLFace *facep; | 5538 | LLFace *facep; |
5438 | 5539 | ||
5439 | // Add faces for the foot shadows | 5540 | // Add faces for the foot shadows |
5440 | facep = mDrawable->addFace(poolp, mShadowImagep); | 5541 | facep = mDrawable->addFace((LLFacePool*) NULL, mShadowImagep); |
5441 | mShadow0Facep = facep; | 5542 | mShadow0Facep = facep; |
5442 | 5543 | ||
5443 | facep = mDrawable->addFace(poolp, mShadowImagep); | 5544 | facep = mDrawable->addFace((LLFacePool*) NULL, mShadowImagep); |
5444 | mShadow1Facep = facep; | 5545 | mShadow1Facep = facep; |
5445 | 5546 | ||
5446 | gPipeline.markMaterialed(mDrawable); | ||
5447 | dirtyMesh(); | 5547 | dirtyMesh(); |
5448 | return mDrawable; | 5548 | return mDrawable; |
5449 | } | 5549 | } |
@@ -5454,6 +5554,7 @@ LLDrawable *LLVOAvatar::createDrawable(LLPipeline *pipeline) | |||
5454 | //----------------------------------------------------------------------------- | 5554 | //----------------------------------------------------------------------------- |
5455 | BOOL LLVOAvatar::updateGeometry(LLDrawable *drawable) | 5555 | BOOL LLVOAvatar::updateGeometry(LLDrawable *drawable) |
5456 | { | 5556 | { |
5557 | LLFastTimer ftm(LLFastTimer::FTM_UPDATE_AVATAR); | ||
5457 | if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_AVATAR))) | 5558 | if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_AVATAR))) |
5458 | { | 5559 | { |
5459 | return TRUE; | 5560 | return TRUE; |
@@ -5469,30 +5570,9 @@ BOOL LLVOAvatar::updateGeometry(LLDrawable *drawable) | |||
5469 | llerrs << "LLVOAvatar::updateGeometry() called with NULL drawable" << llendl; | 5570 | llerrs << "LLVOAvatar::updateGeometry() called with NULL drawable" << llendl; |
5470 | } | 5571 | } |
5471 | 5572 | ||
5472 | // Update the shadow, tractor, and text label geometry. | ||
5473 | |||
5474 | updateShadowFaces(); | ||
5475 | |||
5476 | if (!drawable->isVisible()) | ||
5477 | { | ||
5478 | return TRUE; | ||
5479 | } | ||
5480 | |||
5481 | LLFace* facep = drawable->getFace(0); | ||
5482 | if (!mDirtyMesh && !facep->getDirty()) | ||
5483 | { | ||
5484 | return TRUE; | ||
5485 | } | ||
5486 | |||
5487 | // U32 num_vertices = 0; | ||
5488 | |||
5489 | updateMeshData(); | ||
5490 | |||
5491 | mDirtyMesh = FALSE; | ||
5492 | return TRUE; | 5573 | return TRUE; |
5493 | } | 5574 | } |
5494 | 5575 | ||
5495 | |||
5496 | //----------------------------------------------------------------------------- | 5576 | //----------------------------------------------------------------------------- |
5497 | // updateShadowFaces() | 5577 | // updateShadowFaces() |
5498 | //----------------------------------------------------------------------------- | 5578 | //----------------------------------------------------------------------------- |
@@ -5708,28 +5788,26 @@ void LLVOAvatar::removeChild(LLViewerObject *childp) | |||
5708 | detachObject(childp); | 5788 | detachObject(childp); |
5709 | } | 5789 | } |
5710 | 5790 | ||
5711 | //----------------------------------------------------------------------------- | 5791 | LLViewerJointAttachment* LLVOAvatar::getTargetAttachmentPoint(LLViewerObject* viewer_object) |
5712 | // attachObject() | ||
5713 | //----------------------------------------------------------------------------- | ||
5714 | BOOL LLVOAvatar::attachObject(LLViewerObject *viewer_object) | ||
5715 | { | 5792 | { |
5716 | S32 attachmentID = ATTACHMENT_ID_FROM_STATE(viewer_object->getState()); | 5793 | S32 attachmentID = ATTACHMENT_ID_FROM_STATE(viewer_object->getState()); |
5717 | //clamp((S32)(viewer_object->getState() & AGENT_ATTACH_MASK) >> AGENT_ATTACH_OFFSET, 1, 0xff); | ||
5718 | |||
5719 | //if (mIsSelf) | ||
5720 | //{ | ||
5721 | // gSelectMgr->deselectObjectAndFamily(viewer_object); | ||
5722 | //} | ||
5723 | 5794 | ||
5724 | LLViewerJointAttachment* attachment = mAttachmentPoints.getIfThere(attachmentID); | 5795 | LLViewerJointAttachment* attachment = mAttachmentPoints.getIfThere(attachmentID); |
5725 | 5796 | ||
5726 | if (!attachment) | 5797 | if (!attachment) |
5727 | { | 5798 | { |
5728 | llwarns << "Tried to attach object to invalid attachment point: " << attachmentID << llendl; | 5799 | llwarns << "Object attachment point invalid: " << attachmentID << llendl; |
5729 | return FALSE; | ||
5730 | } | 5800 | } |
5731 | 5801 | ||
5732 | // LLQuaternion object_world_rot = viewer_object->getWorldRotation(); | 5802 | return attachment; |
5803 | } | ||
5804 | |||
5805 | //----------------------------------------------------------------------------- | ||
5806 | // attachObject() | ||
5807 | //----------------------------------------------------------------------------- | ||
5808 | BOOL LLVOAvatar::attachObject(LLViewerObject *viewer_object) | ||
5809 | { | ||
5810 | LLViewerJointAttachment* attachment = getTargetAttachmentPoint(viewer_object); | ||
5733 | 5811 | ||
5734 | if (!attachment->addObject(viewer_object)) | 5812 | if (!attachment->addObject(viewer_object)) |
5735 | { | 5813 | { |
@@ -5742,10 +5820,6 @@ BOOL LLVOAvatar::attachObject(LLViewerObject *viewer_object) | |||
5742 | gSelectMgr->updatePointAt(); | 5820 | gSelectMgr->updatePointAt(); |
5743 | } | 5821 | } |
5744 | 5822 | ||
5745 | // LLQuaternion desired_rot = (object_world_rot * ~attachment->getWorldRotation()); | ||
5746 | |||
5747 | lldebugs << "Attaching object (" << attachmentID << ") item_id=" << attachment->getItemID() << " task_id=" << viewer_object->getID() << "to " << attachment->getName() << llendl; | ||
5748 | |||
5749 | if (mIsSelf) | 5823 | if (mIsSelf) |
5750 | { | 5824 | { |
5751 | updateAttachmentVisibility(gAgent.getCameraMode()); | 5825 | updateAttachmentVisibility(gAgent.getCameraMode()); |
@@ -5778,6 +5852,23 @@ void LLVOAvatar::lazyAttach() | |||
5778 | } | 5852 | } |
5779 | } | 5853 | } |
5780 | 5854 | ||
5855 | void LLVOAvatar::resetHUDAttachments() | ||
5856 | { | ||
5857 | for(LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); | ||
5858 | attachment; | ||
5859 | attachment = mAttachmentPoints.getNextData()) | ||
5860 | { | ||
5861 | if (attachment->getIsHUDAttachment()) | ||
5862 | { | ||
5863 | LLViewerObject* obj = attachment->getObject(); | ||
5864 | if (obj && obj->mDrawable.notNull()) | ||
5865 | { | ||
5866 | gPipeline.markMoved(obj->mDrawable); | ||
5867 | } | ||
5868 | } | ||
5869 | } | ||
5870 | } | ||
5871 | |||
5781 | //----------------------------------------------------------------------------- | 5872 | //----------------------------------------------------------------------------- |
5782 | // detachObject() | 5873 | // detachObject() |
5783 | //----------------------------------------------------------------------------- | 5874 | //----------------------------------------------------------------------------- |
@@ -5788,7 +5879,7 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object) | |||
5788 | attachment = mAttachmentPoints.getNextData()) | 5879 | attachment = mAttachmentPoints.getNextData()) |
5789 | { | 5880 | { |
5790 | // only one object per attachment point for now | 5881 | // only one object per attachment point for now |
5791 | if (attachment->getObject(0) == viewer_object) | 5882 | if (attachment->getObject() == viewer_object) |
5792 | { | 5883 | { |
5793 | LLUUID item_id = attachment->getItemID(); | 5884 | LLUUID item_id = attachment->getItemID(); |
5794 | attachment->removeObject(viewer_object); | 5885 | attachment->removeObject(viewer_object); |
@@ -5981,7 +6072,7 @@ LLViewerObject* LLVOAvatar::getWornAttachment( const LLUUID& inv_item_id ) | |||
5981 | { | 6072 | { |
5982 | if( attachment_point->getItemID() == inv_item_id ) | 6073 | if( attachment_point->getItemID() == inv_item_id ) |
5983 | { | 6074 | { |
5984 | return attachment_point->getObject(0); | 6075 | return attachment_point->getObject(); |
5985 | } | 6076 | } |
5986 | } | 6077 | } |
5987 | return NULL; | 6078 | return NULL; |
@@ -6319,10 +6410,10 @@ const LLUUID& LLVOAvatar::getLocalTextureID( S32 index ) | |||
6319 | void LLVOAvatar::dumpTotalLocalTextureByteCount() | 6410 | void LLVOAvatar::dumpTotalLocalTextureByteCount() |
6320 | { | 6411 | { |
6321 | S32 total_gl_bytes = 0; | 6412 | S32 total_gl_bytes = 0; |
6322 | for( LLVOAvatar* cur = (LLVOAvatar*)LLCharacter::sInstances.getFirstData(); | 6413 | for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); |
6323 | cur; | 6414 | iter != LLCharacter::sInstances.end(); ++iter) |
6324 | cur = (LLVOAvatar*)LLCharacter::sInstances.getNextData() ) | ||
6325 | { | 6415 | { |
6416 | LLVOAvatar* cur = (LLVOAvatar*) *iter; | ||
6326 | S32 gl_bytes = 0; | 6417 | S32 gl_bytes = 0; |
6327 | cur->getLocalTextureByteCount(&gl_bytes ); | 6418 | cur->getLocalTextureByteCount(&gl_bytes ); |
6328 | total_gl_bytes += gl_bytes; | 6419 | total_gl_bytes += gl_bytes; |
@@ -7722,7 +7813,7 @@ BOOL LLVOAvatar::hasHUDAttachment() | |||
7722 | attachment; | 7813 | attachment; |
7723 | attachment = mAttachmentPoints.getNextData()) | 7814 | attachment = mAttachmentPoints.getNextData()) |
7724 | { | 7815 | { |
7725 | if (attachment->getIsHUDAttachment() && attachment->getObject(0)) | 7816 | if (attachment->getIsHUDAttachment() && attachment->getObject()) |
7726 | { | 7817 | { |
7727 | return TRUE; | 7818 | return TRUE; |
7728 | } | 7819 | } |
@@ -7737,9 +7828,9 @@ LLBBox LLVOAvatar::getHUDBBox() | |||
7737 | attachment; | 7828 | attachment; |
7738 | attachment = mAttachmentPoints.getNextData()) | 7829 | attachment = mAttachmentPoints.getNextData()) |
7739 | { | 7830 | { |
7740 | if (attachment->getIsHUDAttachment() && attachment->getObject(0)) | 7831 | if (attachment->getIsHUDAttachment() && attachment->getObject()) |
7741 | { | 7832 | { |
7742 | LLViewerObject* hud_object = attachment->getObject(0); | 7833 | LLViewerObject* hud_object = attachment->getObject(); |
7743 | 7834 | ||
7744 | // initialize bounding box to contain identity orientation and center point for attached object | 7835 | // initialize bounding box to contain identity orientation and center point for attached object |
7745 | bbox.addPointLocal(hud_object->getPosition()); | 7836 | bbox.addPointLocal(hud_object->getPosition()); |
@@ -7757,52 +7848,6 @@ LLBBox LLVOAvatar::getHUDBBox() | |||
7757 | 7848 | ||
7758 | void LLVOAvatar::rebuildHUD() | 7849 | void LLVOAvatar::rebuildHUD() |
7759 | { | 7850 | { |
7760 | if (!mIsSelf) | ||
7761 | { | ||
7762 | return; | ||
7763 | } | ||
7764 | |||
7765 | for(LLViewerJointAttachment *attachment = mAttachmentPoints.getFirstData(); | ||
7766 | attachment; | ||
7767 | attachment = mAttachmentPoints.getNextData()) | ||
7768 | { | ||
7769 | if (attachment->getIsHUDAttachment() && attachment->getObject(0)) | ||
7770 | { | ||
7771 | LLViewerObject* hud_object = attachment->getObject(0); | ||
7772 | LLDrawable* hud_drawable = hud_object->mDrawable; | ||
7773 | |||
7774 | if (hud_drawable) | ||
7775 | { | ||
7776 | // this assumes that an AGP sync will happen because face has been backlisted, | ||
7777 | // so that pool has been rebuilt this frame and is scheduled for a sync | ||
7778 | for(S32 face_index = 0; face_index < hud_drawable->getNumFaces(); ++face_index) | ||
7779 | { | ||
7780 | LLFace* facep = hud_drawable->getFace(face_index); | ||
7781 | if (facep->isState(LLFace::BACKLIST)) | ||
7782 | { | ||
7783 | facep->restore(); | ||
7784 | } | ||
7785 | } | ||
7786 | } | ||
7787 | for (U32 child_num = 0; child_num < hud_object->mChildList.size(); ++child_num) | ||
7788 | { | ||
7789 | LLViewerObject* childp = hud_object->mChildList[child_num]; | ||
7790 | LLDrawable* child_drawable = childp->mDrawable; | ||
7791 | |||
7792 | if (child_drawable) | ||
7793 | { | ||
7794 | for(S32 face_index = 0; face_index < child_drawable->getNumFaces(); ++face_index) | ||
7795 | { | ||
7796 | LLFace* facep = child_drawable->getFace(face_index); | ||
7797 | if (facep->isState(LLFace::BACKLIST)) | ||
7798 | { | ||
7799 | facep->restore(); | ||
7800 | } | ||
7801 | } | ||
7802 | } | ||
7803 | } | ||
7804 | } | ||
7805 | } | ||
7806 | } | 7851 | } |
7807 | 7852 | ||
7808 | //----------------------------------------------------------------------------- | 7853 | //----------------------------------------------------------------------------- |
@@ -8059,8 +8104,7 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerImage *src_vi, | |||
8059 | { | 8104 | { |
8060 | if (!aux_src->getData()) | 8105 | if (!aux_src->getData()) |
8061 | { | 8106 | { |
8062 | llwarns << "No auxiliary source data for onBakedTextureMasksLoaded" << llendl; | 8107 | llerrs << "No auxiliary source data for onBakedTextureMasksLoaded" << llendl; |
8063 | src_vi->startImageDecode(); | ||
8064 | return; | 8108 | return; |
8065 | } | 8109 | } |
8066 | 8110 | ||
@@ -8351,7 +8395,7 @@ void LLVOAvatar::dumpArchetypeXML( void* ) | |||
8351 | LLViewerImage* te_image = avatar->getTEImage( te ); | 8395 | LLViewerImage* te_image = avatar->getTEImage( te ); |
8352 | if( te_image ) | 8396 | if( te_image ) |
8353 | { | 8397 | { |
8354 | char uuid_str[UUID_STR_LENGTH]; | 8398 | char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ |
8355 | te_image->getID().toString( uuid_str ); | 8399 | te_image->getID().toString( uuid_str ); |
8356 | apr_file_printf( file, "\t\t<texture te=\"%i\" uuid=\"%s\"/>\n", te, uuid_str); | 8400 | apr_file_printf( file, "\t\t<texture te=\"%i\" uuid=\"%s\"/>\n", te, uuid_str); |
8357 | } | 8401 | } |
@@ -8368,10 +8412,10 @@ void LLVOAvatar::dumpArchetypeXML( void* ) | |||
8368 | S32 LLVOAvatar::getUnbakedPixelAreaRank() | 8412 | S32 LLVOAvatar::getUnbakedPixelAreaRank() |
8369 | { | 8413 | { |
8370 | S32 rank = 1; | 8414 | S32 rank = 1; |
8371 | for( LLVOAvatar* inst = (LLVOAvatar*)LLCharacter::sInstances.getFirstData(); | 8415 | for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); |
8372 | inst; | 8416 | iter != LLCharacter::sInstances.end(); ++iter) |
8373 | inst = (LLVOAvatar*)LLCharacter::sInstances.getNextData() ) | ||
8374 | { | 8417 | { |
8418 | LLVOAvatar* inst = (LLVOAvatar*) *iter; | ||
8375 | if( inst == this ) | 8419 | if( inst == this ) |
8376 | { | 8420 | { |
8377 | return rank; | 8421 | return rank; |
@@ -8390,16 +8434,15 @@ S32 LLVOAvatar::getUnbakedPixelAreaRank() | |||
8390 | // static | 8434 | // static |
8391 | void LLVOAvatar::cullAvatarsByPixelArea() | 8435 | void LLVOAvatar::cullAvatarsByPixelArea() |
8392 | { | 8436 | { |
8393 | LLVOAvatar::sInstances.bubbleSortList(); | 8437 | std::sort(LLCharacter::sInstances.begin(), LLCharacter::sInstances.end(), CompareScreenAreaGreater()); |
8394 | 8438 | ||
8395 | |||
8396 | // Update the avatars that have changed status | 8439 | // Update the avatars that have changed status |
8397 | S32 rank = 1; | 8440 | S32 rank = 1; |
8398 | 8441 | ||
8399 | for( LLVOAvatar* inst = (LLVOAvatar*)LLCharacter::sInstances.getFirstData(); | 8442 | for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); |
8400 | inst; | 8443 | iter != LLCharacter::sInstances.end(); ++iter) |
8401 | inst = (LLVOAvatar*)LLCharacter::sInstances.getNextData() ) | ||
8402 | { | 8444 | { |
8445 | LLVOAvatar* inst = (LLVOAvatar*) *iter; | ||
8403 | BOOL culled; | 8446 | BOOL culled; |
8404 | if( inst->isDead() ) | 8447 | if( inst->isDead() ) |
8405 | { | 8448 | { |
@@ -8589,8 +8632,6 @@ void LLVOAvatar::dumpLocalTextures() | |||
8589 | else | 8632 | else |
8590 | { | 8633 | { |
8591 | LLViewerImage* image = mLocalTexture[i]; | 8634 | LLViewerImage* image = mLocalTexture[i]; |
8592 | F32 data_progress = 0.0f; | ||
8593 | F32 decode_progress = image->getDecodeProgress(&data_progress); | ||
8594 | 8635 | ||
8595 | llinfos << "LocTex " << names[i] << ": " | 8636 | llinfos << "LocTex " << names[i] << ": " |
8596 | << "Discard " << image->getDiscardLevel() << ", " | 8637 | << "Discard " << image->getDiscardLevel() << ", " |
@@ -8600,10 +8641,7 @@ void LLVOAvatar::dumpLocalTextures() | |||
8600 | // makes textures easier to steal | 8641 | // makes textures easier to steal |
8601 | << image->getID() << " " | 8642 | << image->getID() << " " |
8602 | #endif | 8643 | #endif |
8603 | << "Data: " << (data_progress * 100) << "% " | 8644 | << "Priority: " << image->getDecodePriority() |
8604 | << "Decode: " << (decode_progress * 100) << "% " | ||
8605 | << "Priority: " << image->getDecodePriority() << " " | ||
8606 | << (image->needsDecode() ? "pending decode" : "not pending decode") | ||
8607 | << llendl; | 8645 | << llendl; |
8608 | } | 8646 | } |
8609 | } | 8647 | } |
@@ -8705,7 +8743,7 @@ BOOL LLVOAvatarBoneInfo::parseXml(LLXmlTreeNode* node) | |||
8705 | } | 8743 | } |
8706 | else | 8744 | else |
8707 | { | 8745 | { |
8708 | llerrs << "Invalid node " << node->getName() << llendl; | 8746 | llwarns << "Invalid node " << node->getName() << llendl; |
8709 | return FALSE; | 8747 | return FALSE; |
8710 | } | 8748 | } |
8711 | 8749 | ||
@@ -8763,7 +8801,7 @@ BOOL LLVOAvatarSkeletonInfo::parseXml(LLXmlTreeNode* node) | |||
8763 | static LLStdStringHandle num_bones_string = LLXmlTree::addAttributeString("num_bones"); | 8801 | static LLStdStringHandle num_bones_string = LLXmlTree::addAttributeString("num_bones"); |
8764 | if (!node->getFastAttributeS32(num_bones_string, mNumBones)) | 8802 | if (!node->getFastAttributeS32(num_bones_string, mNumBones)) |
8765 | { | 8803 | { |
8766 | llerrs << "Couldn't find number of bones." << llendl; | 8804 | llwarns << "Couldn't find number of bones." << llendl; |
8767 | return FALSE; | 8805 | return FALSE; |
8768 | } | 8806 | } |
8769 | 8807 | ||
@@ -8777,7 +8815,8 @@ BOOL LLVOAvatarSkeletonInfo::parseXml(LLXmlTreeNode* node) | |||
8777 | if (!info->parseXml(child)) | 8815 | if (!info->parseXml(child)) |
8778 | { | 8816 | { |
8779 | delete info; | 8817 | delete info; |
8780 | llerrs << "Error parsing bone in skeleton file" << llendl; | 8818 | llwarns << "Error parsing bone in skeleton file" << llendl; |
8819 | return FALSE; | ||
8781 | } | 8820 | } |
8782 | mBoneInfoList.push_back(info); | 8821 | mBoneInfoList.push_back(info); |
8783 | } | 8822 | } |
@@ -9099,7 +9138,7 @@ BOOL LLVOAvatarInfo::parseXmlDriverNodes(LLXmlTreeNode* root) | |||
9099 | 9138 | ||
9100 | void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | 9139 | void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) |
9101 | { | 9140 | { |
9102 | char filename[MAX_PATH]; | 9141 | char filename[MAX_PATH]; /* Flawfinder: ignore */ |
9103 | 9142 | ||
9104 | // reset animated morphs | 9143 | // reset animated morphs |
9105 | setVisualParamWeight("Blink_Left", 0.f); | 9144 | setVisualParamWeight("Blink_Left", 0.f); |
@@ -9119,7 +9158,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9119 | setVisualParamWeight("Hands_Spread_R", 0.f); | 9158 | setVisualParamWeight("Hands_Spread_R", 0.f); |
9120 | updateVisualParams(); | 9159 | updateVisualParams(); |
9121 | 9160 | ||
9122 | sprintf(filename, "%s\\%s_skeleton.xsf", path.c_str(), file_base.c_str()); | 9161 | snprintf(filename, MAX_PATH, "%s\\%s_skeleton.xsf", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */ |
9123 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W); | 9162 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W); |
9124 | if (!fp) | 9163 | if (!fp) |
9125 | { | 9164 | { |
@@ -9131,7 +9170,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9131 | apr_file_printf(fp, "</SKELETON>\n"); | 9170 | apr_file_printf(fp, "</SKELETON>\n"); |
9132 | apr_file_close(fp); | 9171 | apr_file_close(fp); |
9133 | 9172 | ||
9134 | sprintf(filename, "%s\\%s_mesh_body.xmf", path.c_str(), file_base.c_str()); | 9173 | snprintf(filename, MAX_PATH, "%s\\%s_mesh_body.xmf", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */ |
9135 | //gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"avatar.cal").c_str() | 9174 | //gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"avatar.cal").c_str() |
9136 | fp = ll_apr_file_open(filename, LL_APR_W); | 9175 | fp = ll_apr_file_open(filename, LL_APR_W); |
9137 | if (!fp) | 9176 | if (!fp) |
@@ -9162,7 +9201,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9162 | 9201 | ||
9163 | for (S32 i = 0; i < (has_skirt ? BAKED_TEXTURE_COUNT : BAKED_TEXTURE_COUNT - 1); i++) | 9202 | for (S32 i = 0; i < (has_skirt ? BAKED_TEXTURE_COUNT : BAKED_TEXTURE_COUNT - 1); i++) |
9164 | { | 9203 | { |
9165 | sprintf(filename, "%s\\%s_material_tex_%d.tga", path.c_str(), file_base.c_str(), i); | 9204 | snprintf(filename, MAX_PATH, "%s\\%s_material_tex_%d.tga", path.c_str(), file_base.c_str(), i); /* Flawfinder: ignore */ |
9166 | 9205 | ||
9167 | LLViewerImage* viewer_imagep = mTEImages[sBakedTextureIndices[i]]; | 9206 | LLViewerImage* viewer_imagep = mTEImages[sBakedTextureIndices[i]]; |
9168 | if (!viewer_imagep->getHasGLTexture()) | 9207 | if (!viewer_imagep->getHasGLTexture()) |
@@ -9177,7 +9216,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9177 | } | 9216 | } |
9178 | 9217 | ||
9179 | // output image for hair | 9218 | // output image for hair |
9180 | sprintf(filename, "%s\\%s_material_tex_5.tga", path.c_str(), file_base.c_str()); | 9219 | snprintf(filename, MAX_PATH, "%s\\%s_material_tex_5.tga", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */ |
9181 | LLViewerImage* viewer_imagep = mTEImages[TEX_HAIR]; | 9220 | LLViewerImage* viewer_imagep = mTEImages[TEX_HAIR]; |
9182 | if (!viewer_imagep->getHasGLTexture()) | 9221 | if (!viewer_imagep->getHasGLTexture()) |
9183 | { | 9222 | { |
@@ -9192,7 +9231,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9192 | } | 9231 | } |
9193 | 9232 | ||
9194 | // save out attachments | 9233 | // save out attachments |
9195 | sprintf(filename, "%s\\%s_mesh_attachments.xmf", path.c_str(), file_base.c_str()); | 9234 | snprintf(filename, MAX_PATH, "%s\\%s_mesh_attachments.xmf", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */ |
9196 | fp = ll_apr_file_open(filename, LL_APR_W); | 9235 | fp = ll_apr_file_open(filename, LL_APR_W); |
9197 | if (!fp) | 9236 | if (!fp) |
9198 | { | 9237 | { |
@@ -9208,7 +9247,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9208 | attachment; | 9247 | attachment; |
9209 | attachment = mAttachmentPoints.getNextData()) | 9248 | attachment = mAttachmentPoints.getNextData()) |
9210 | { | 9249 | { |
9211 | LLViewerObject *attached_object = attachment->getObject(0); | 9250 | LLViewerObject *attached_object = attachment->getObject(); |
9212 | if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull() && | 9251 | if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull() && |
9213 | attached_object->getPCode() == LL_PCODE_VOLUME) | 9252 | attached_object->getPCode() == LL_PCODE_VOLUME) |
9214 | { | 9253 | { |
@@ -9229,7 +9268,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9229 | attachment; | 9268 | attachment; |
9230 | attachment = mAttachmentPoints.getNextData()) | 9269 | attachment = mAttachmentPoints.getNextData()) |
9231 | { | 9270 | { |
9232 | LLViewerObject *attached_object = attachment->getObject(0); | 9271 | LLViewerObject *attached_object = attachment->getObject(); |
9233 | if (attached_object && !attached_object->isDead() && attached_object->getPCode() == LL_PCODE_VOLUME) | 9272 | if (attached_object && !attached_object->isDead() && attached_object->getPCode() == LL_PCODE_VOLUME) |
9234 | { | 9273 | { |
9235 | LLVOVolume* attached_volume = (LLVOVolume*)attached_object; | 9274 | LLVOVolume* attached_volume = (LLVOVolume*)attached_object; |
@@ -9254,7 +9293,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9254 | getSex() == SEX_MALE ? (LLKeyframeMotion*)findMotion(ANIM_AGENT_WALK) : (LLKeyframeMotion*)findMotion(ANIM_AGENT_FEMALE_WALK); | 9293 | getSex() == SEX_MALE ? (LLKeyframeMotion*)findMotion(ANIM_AGENT_WALK) : (LLKeyframeMotion*)findMotion(ANIM_AGENT_FEMALE_WALK); |
9255 | if (FALSE)//(walk_motion) | 9294 | if (FALSE)//(walk_motion) |
9256 | { | 9295 | { |
9257 | sprintf(filename, "%s\\%s_anim.xaf", path.c_str(), file_base.c_str()); | 9296 | snprintf(filename, MAX_PATH, "%s\\%s_anim.xaf", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */ |
9258 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W); | 9297 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W); |
9259 | if (!fp) | 9298 | if (!fp) |
9260 | { | 9299 | { |
@@ -9268,7 +9307,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9268 | } | 9307 | } |
9269 | 9308 | ||
9270 | // finally, write out .cfg file | 9309 | // finally, write out .cfg file |
9271 | sprintf(filename, "%s\\%s_avatar.cfg", path.c_str(), file_base.c_str()); | 9310 | snprintf(filename, MAX_PATH, "%s\\%s_avatar.cfg", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */ |
9272 | fp = ll_apr_file_open(filename, LL_APR_W); | 9311 | fp = ll_apr_file_open(filename, LL_APR_W); |
9273 | if (!fp) | 9312 | if (!fp) |
9274 | { | 9313 | { |
@@ -9289,7 +9328,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9289 | 9328 | ||
9290 | for(S32 i = 0; i < 6; i++) | 9329 | for(S32 i = 0; i < 6; i++) |
9291 | { | 9330 | { |
9292 | sprintf(filename, "%s\\%s_material_%d.xrf", path.c_str(), file_base.c_str(), i); | 9331 | snprintf(filename, MAX_PATH, "%s\\%s_material_%d.xrf", path.c_str(), file_base.c_str(), i); /* Flawfinder: ignore */ |
9293 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W); | 9332 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W); |
9294 | if (!fp) | 9333 | if (!fp) |
9295 | { | 9334 | { |
@@ -9316,7 +9355,7 @@ void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base) | |||
9316 | { | 9355 | { |
9317 | LLMaterialExportInfo* export_info = material_it->second; | 9356 | LLMaterialExportInfo* export_info = material_it->second; |
9318 | 9357 | ||
9319 | sprintf(filename, "%s\\%s_material_%d.xrf", path.c_str(), file_base.c_str(), export_info->mMaterialIndex); | 9358 | snprintf(filename, MAX_PATH, "%s\\%s_material_%d.xrf", path.c_str(), file_base.c_str(), export_info->mMaterialIndex); /* Flawfinder: ignore */ |
9320 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W); | 9359 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W); |
9321 | if (!fp) | 9360 | if (!fp) |
9322 | { | 9361 | { |
@@ -9441,3 +9480,58 @@ LLHost LLVOAvatar::getObjectHost() const | |||
9441 | return LLHost::invalid; | 9480 | return LLHost::invalid; |
9442 | } | 9481 | } |
9443 | } | 9482 | } |
9483 | |||
9484 | BOOL LLVOAvatar::updateLOD() | ||
9485 | { | ||
9486 | BOOL res = updateJointLODs(); | ||
9487 | |||
9488 | LLFace* facep = mDrawable->getFace(0); | ||
9489 | if (facep->mVertexBuffer.isNull() || | ||
9490 | LLVertexBuffer::sEnableVBOs && | ||
9491 | ((facep->mVertexBuffer->getUsage() == GL_STATIC_DRAW ? TRUE : FALSE) != | ||
9492 | (facep->getPool()->getVertexShaderLevel() > 0 ? TRUE : FALSE))) | ||
9493 | { | ||
9494 | mDirtyMesh = TRUE; | ||
9495 | } | ||
9496 | |||
9497 | if (mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY)) | ||
9498 | { //LOD changed or new mesh created, allocate new vertex buffer if needed | ||
9499 | updateMeshData(); | ||
9500 | mDirtyMesh = FALSE; | ||
9501 | mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY); | ||
9502 | } | ||
9503 | |||
9504 | if (facep->getPool()->getVertexShaderLevel() <= 0) | ||
9505 | { | ||
9506 | //generate animated mesh | ||
9507 | mLowerBodyLOD.updateGeometry(); | ||
9508 | mUpperBodyLOD.updateGeometry(); | ||
9509 | |||
9510 | if( isWearingWearableType( WT_SKIRT ) ) | ||
9511 | { | ||
9512 | mSkirtLOD.updateGeometry(); | ||
9513 | } | ||
9514 | |||
9515 | if (!mIsSelf || gAgent.needsRenderHead()) | ||
9516 | { | ||
9517 | mEyeLashLOD.updateGeometry(); | ||
9518 | mHeadLOD.updateGeometry(); | ||
9519 | mHairLOD.updateGeometry(); | ||
9520 | } | ||
9521 | } | ||
9522 | |||
9523 | // Update the shadow, tractor, and text label geometry. | ||
9524 | if (mDrawable->isState(LLDrawable::REBUILD_SHADOW)) | ||
9525 | { | ||
9526 | updateShadowFaces(); | ||
9527 | mDrawable->clearState(LLDrawable::REBUILD_SHADOW); | ||
9528 | } | ||
9529 | |||
9530 | return res; | ||
9531 | } | ||
9532 | |||
9533 | U32 LLVOAvatar::getPartitionType() const | ||
9534 | { //avatars merely exist as drawables in the bridge partition | ||
9535 | return LLPipeline::PARTITION_BRIDGE; | ||
9536 | } | ||
9537 | |||