aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvoavatar.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llvoavatar.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llvoavatar.cpp')
-rw-r--r--linden/indra/newview/llvoavatar.cpp1249
1 files changed, 621 insertions, 628 deletions
diff --git a/linden/indra/newview/llvoavatar.cpp b/linden/indra/newview/llvoavatar.cpp
index 6798b4d..5d04009 100644
--- a/linden/indra/newview/llvoavatar.cpp
+++ b/linden/indra/newview/llvoavatar.cpp
@@ -37,6 +37,7 @@
37 37
38#include "llvoavatar.h" 38#include "llvoavatar.h"
39 39
40#include "llglimmediate.h"
40#include "audioengine.h" 41#include "audioengine.h"
41#include "imageids.h" 42#include "imageids.h"
42#include "indra_constants.h" 43#include "indra_constants.h"
@@ -113,6 +114,7 @@
113#include "llwearablelist.h" 114#include "llwearablelist.h"
114#include "llworld.h" 115#include "llworld.h"
115#include "pipeline.h" 116#include "pipeline.h"
117#include "llspatialpartition.h"
116#include "llglslshader.h" 118#include "llglslshader.h"
117#include "llappviewer.h" 119#include "llappviewer.h"
118#include "lscript_byteformat.h" 120#include "lscript_byteformat.h"
@@ -255,6 +257,7 @@ S32 LLVOAvatar::sMaxOtherAvatarsToComposite = 1; // Only this many avatars (oth
255LLMap< LLGLenum, LLGLuint*> LLVOAvatar::sScratchTexNames; 257LLMap< LLGLenum, LLGLuint*> LLVOAvatar::sScratchTexNames;
256LLMap< LLGLenum, F32*> LLVOAvatar::sScratchTexLastBindTime; 258LLMap< LLGLenum, F32*> LLVOAvatar::sScratchTexLastBindTime;
257S32 LLVOAvatar::sScratchTexBytes = 0; 259S32 LLVOAvatar::sScratchTexBytes = 0;
260F32 LLVOAvatar::sRenderDistance = 256.f;
258S32 LLVOAvatar::sNumVisibleAvatars = 0; 261S32 LLVOAvatar::sNumVisibleAvatars = 0;
259S32 LLVOAvatar::sNumLODChangesThisFrame = 0; 262S32 LLVOAvatar::sNumLODChangesThisFrame = 0;
260 263
@@ -279,8 +282,8 @@ BOOL LLVOAvatar::sShowAnimationDebug = FALSE;
279BOOL LLVOAvatar::sShowFootPlane = FALSE; 282BOOL LLVOAvatar::sShowFootPlane = FALSE;
280BOOL LLVOAvatar::sShowCollisionVolumes = FALSE; 283BOOL LLVOAvatar::sShowCollisionVolumes = FALSE;
281BOOL LLVOAvatar::sVisibleInFirstPerson = FALSE; 284BOOL LLVOAvatar::sVisibleInFirstPerson = FALSE;
282BOOL LLVOAvatar::sAvatarLoadTest = FALSE;
283F32 LLVOAvatar::sLODFactor = 1.f; 285F32 LLVOAvatar::sLODFactor = 1.f;
286BOOL LLVOAvatar::sUseImpostors = TRUE;
284BOOL LLVOAvatar::sJointDebug = FALSE; 287BOOL LLVOAvatar::sJointDebug = FALSE;
285 288
286S32 LLVOAvatar::sCurJoint = 0; 289S32 LLVOAvatar::sCurJoint = 0;
@@ -679,7 +682,9 @@ LLVOAvatar::LLVOAvatar(
679 mCulled( FALSE ), 682 mCulled( FALSE ),
680 mTexSkinColor( NULL ), 683 mTexSkinColor( NULL ),
681 mTexHairColor( NULL ), 684 mTexHairColor( NULL ),
682 mTexEyeColor( NULL ) 685 mTexEyeColor( NULL ),
686 mNeedsSkin(FALSE),
687 mUpdatePeriod(1)
683{ 688{
684 LLMemType mt(LLMemType::MTYPE_AVATAR); 689 LLMemType mt(LLMemType::MTYPE_AVATAR);
685 690
@@ -730,6 +735,11 @@ LLVOAvatar::LLVOAvatar(
730 mIsSelf = FALSE; 735 mIsSelf = FALSE;
731 } 736 }
732 737
738 mNeedsImpostorUpdate = TRUE;
739 mNeedsAnimUpdate = TRUE;
740
741 mImpostorDistance = 0;
742
733 setNumTEs(TEX_NUM_ENTRIES); 743 setNumTEs(TEX_NUM_ENTRIES);
734 744
735 mbCanSelect = TRUE; 745 mbCanSelect = TRUE;
@@ -986,7 +996,8 @@ LLVOAvatar::~LLVOAvatar()
986 delete mSkirtLayerSet; 996 delete mSkirtLayerSet;
987 mSkirtLayerSet = NULL; 997 mSkirtLayerSet = NULL;
988 998
989 mAttachmentPoints.deleteAllData(); 999 std::for_each(mAttachmentPoints.begin(), mAttachmentPoints.end(), DeletePairedPointer());
1000 mAttachmentPoints.clear();
990 1001
991 delete mTexSkinColor; 1002 delete mTexSkinColor;
992 mTexSkinColor = NULL; 1003 mTexSkinColor = NULL;
@@ -996,6 +1007,7 @@ LLVOAvatar::~LLVOAvatar()
996 mTexEyeColor = NULL; 1007 mTexEyeColor = NULL;
997 1008
998 std::for_each(mMeshes.begin(), mMeshes.end(), DeletePairedPointer()); 1009 std::for_each(mMeshes.begin(), mMeshes.end(), DeletePairedPointer());
1010 mMeshes.clear();
999 1011
1000 mDead = TRUE; 1012 mDead = TRUE;
1001 1013
@@ -1269,16 +1281,6 @@ void LLVOAvatar::dumpBakedStatus()
1269} 1281}
1270 1282
1271//static 1283//static
1272void LLVOAvatar::cleanupVertexPrograms()
1273{
1274}
1275
1276//static
1277void LLVOAvatar::initVertexPrograms()
1278{
1279}
1280
1281//static
1282void LLVOAvatar::restoreGL() 1284void LLVOAvatar::restoreGL()
1283{ 1285{
1284 for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); 1286 for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
@@ -1299,7 +1301,19 @@ void LLVOAvatar::restoreGL()
1299void LLVOAvatar::destroyGL() 1301void LLVOAvatar::destroyGL()
1300{ 1302{
1301 deleteCachedImages(); 1303 deleteCachedImages();
1302 cleanupVertexPrograms(); 1304
1305 resetImpostors();
1306}
1307
1308//static
1309void LLVOAvatar::resetImpostors()
1310{
1311 for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
1312 iter != LLCharacter::sInstances.end(); ++iter)
1313 {
1314 LLVOAvatar* avatar = (LLVOAvatar*) *iter;
1315 avatar->mImpostor.release();
1316 }
1303} 1317}
1304 1318
1305// static 1319// static
@@ -1452,17 +1466,106 @@ void LLVOAvatar::cleanupClass()
1452 sXMLTree.cleanup(); 1466 sXMLTree.cleanup();
1453} 1467}
1454 1468
1469const LLVector3 LLVOAvatar::getRenderPosition() const
1470{
1471 if (mDrawable.isNull() || mDrawable->getGeneration() < 0)
1472 {
1473 return getPositionAgent();
1474 }
1475 else if (isRoot())
1476 {
1477 return mDrawable->getPositionAgent();
1478 }
1479 else
1480 {
1481 return getPosition() * mDrawable->getParent()->getRenderMatrix();
1482 }
1483}
1484
1485void LLVOAvatar::updateDrawable(BOOL force_damped)
1486{
1487 clearChanged(SHIFTED);
1488}
1489
1490void LLVOAvatar::onShift(const LLVector3& shift_vector)
1491{
1492 mLastAnimExtents[0] += shift_vector;
1493 mLastAnimExtents[1] += shift_vector;
1494 mNeedsImpostorUpdate = TRUE;
1495 mNeedsAnimUpdate = TRUE;
1496}
1455 1497
1456void LLVOAvatar::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax) 1498void LLVOAvatar::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax)
1457{ 1499{
1458 LLVector3 center = getRenderPosition(); 1500 if (isImpostor() && !needsImpostorUpdate())
1459 LLVector3 size = getScale(); 1501 {
1460 //maximum amount an animation can move avatar from drawable position 1502 LLVector3 delta = getRenderPosition() -
1461 LLVector3 animation_buffer(5, 5, 5); 1503 ((LLVector3(mDrawable->getPositionGroup())-mImpostorOffset));
1504
1505 newMin = mLastAnimExtents[0] + delta;
1506 newMax = mLastAnimExtents[1] + delta;
1507 }
1508 else
1509 {
1510 getSpatialExtents(newMin,newMax);
1511 mLastAnimExtents[0] = newMin;
1512 mLastAnimExtents[1] = newMax;
1513 LLVector3 pos_group = (newMin+newMax)*0.5f;
1514 mImpostorOffset = pos_group-getRenderPosition();
1515 mDrawable->setPositionGroup(pos_group);
1516 }
1517}
1518
1519void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
1520{
1521 LLVector3 buffer(0.25f, 0.25f, 0.25f);
1522 LLVector3 pos = getRenderPosition();
1523 newMin = pos - buffer;
1524 newMax = pos + buffer;
1525
1526 //stretch bounding box by joint positions
1527 for (mesh_map_t::iterator i = mMeshes.begin(); i != mMeshes.end(); ++i)
1528 {
1529 LLPolyMesh* mesh = i->second;
1530 for (S32 joint_num = 0; joint_num < mesh->mJointRenderData.count(); joint_num++)
1531 {
1532 update_min_max(newMin, newMax,
1533 mesh->mJointRenderData[joint_num]->mWorldMatrix->getTranslation());
1534 }
1535 }
1536
1537 //stretch bounding box by attachments
1538 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
1539 iter != mAttachmentPoints.end();
1540 ++iter)
1541 {
1542 LLViewerJointAttachment* attachment = iter->second;
1543
1544 if(!attachment->getValid())
1545 {
1546 continue ;
1547 }
1548
1549 LLViewerObject* object = attachment->getObject();
1550 if (object && !object->isHUDAttachment())
1551 {
1552 LLDrawable* drawable = object->mDrawable;
1553 if (drawable)
1554 {
1555 LLSpatialBridge* bridge = drawable->getSpatialBridge();
1556 if (bridge)
1557 {
1558 const LLVector3* ext = bridge->getSpatialExtents();
1559 update_min_max(newMin,newMax,ext[0]);
1560 update_min_max(newMin,newMax,ext[1]);
1561 }
1562 }
1563 }
1564 }
1462 1565
1463 newMin.setVec((center-size)-animation_buffer); 1566 //pad bounding box
1464 newMax.setVec(center+size+animation_buffer); 1567 newMin -= buffer;
1465 mDrawable->setPositionGroup((newMin + newMax) * 0.5f); 1568 newMax += buffer;
1466} 1569}
1467 1570
1468 1571
@@ -1832,17 +1935,18 @@ void LLVOAvatar::buildCharacter()
1832 else 1935 else
1833 { 1936 {
1834 BOOL attachment_found = FALSE; 1937 BOOL attachment_found = FALSE;
1835 for (LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); 1938 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
1836 attachment; 1939 iter != mAttachmentPoints.end(); )
1837 attachment = mAttachmentPoints.getNextData())
1838 { 1940 {
1941 attachment_map_t::iterator curiter = iter++;
1942 LLViewerJointAttachment* attachment = curiter->second;
1839 if (attachment->getGroup() == i) 1943 if (attachment->getGroup() == i)
1840 { 1944 {
1841 LLMenuItemCallGL* item; 1945 LLMenuItemCallGL* item;
1842 item = new LLMenuItemCallGL(attachment->getName(), 1946 item = new LLMenuItemCallGL(attachment->getName(),
1843 NULL, 1947 NULL,
1844 object_selected_and_point_valid); 1948 object_selected_and_point_valid);
1845 item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", mAttachmentPoints.reverseLookup(attachment)); 1949 item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", curiter->first);
1846 1950
1847 gAttachPieMenu->append(item); 1951 gAttachPieMenu->append(item);
1848 1952
@@ -1865,10 +1969,11 @@ void LLVOAvatar::buildCharacter()
1865 else 1969 else
1866 { 1970 {
1867 BOOL attachment_found = FALSE; 1971 BOOL attachment_found = FALSE;
1868 for (LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); 1972 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
1869 attachment; 1973 iter != mAttachmentPoints.end(); )
1870 attachment = mAttachmentPoints.getNextData())
1871 { 1974 {
1975 attachment_map_t::iterator curiter = iter++;
1976 LLViewerJointAttachment* attachment = curiter->second;
1872 if (attachment->getGroup() == i) 1977 if (attachment->getGroup() == i)
1873 { 1978 {
1874 gDetachPieMenu->append(new LLMenuItemCallGL(attachment->getName(), 1979 gDetachPieMenu->append(new LLMenuItemCallGL(attachment->getName(),
@@ -1887,17 +1992,18 @@ void LLVOAvatar::buildCharacter()
1887 } 1992 }
1888 1993
1889 // add screen attachments 1994 // add screen attachments
1890 for (LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); 1995 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
1891 attachment; 1996 iter != mAttachmentPoints.end(); )
1892 attachment = mAttachmentPoints.getNextData())
1893 { 1997 {
1998 attachment_map_t::iterator curiter = iter++;
1999 LLViewerJointAttachment* attachment = curiter->second;
1894 if (attachment->getGroup() == 8) 2000 if (attachment->getGroup() == 8)
1895 { 2001 {
1896 LLMenuItemCallGL* item; 2002 LLMenuItemCallGL* item;
1897 item = new LLMenuItemCallGL(attachment->getName(), 2003 item = new LLMenuItemCallGL(attachment->getName(),
1898 NULL, 2004 NULL,
1899 object_selected_and_point_valid); 2005 object_selected_and_point_valid);
1900 item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", mAttachmentPoints.reverseLookup(attachment)); 2006 item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", curiter->first);
1901 gAttachScreenPieMenu->append(item); 2007 gAttachScreenPieMenu->append(item);
1902 gDetachScreenPieMenu->append(new LLMenuItemCallGL(attachment->getName(), 2008 gDetachScreenPieMenu->append(new LLMenuItemCallGL(attachment->getName(),
1903 &handle_detach_from_avatar, object_attached, attachment)); 2009 &handle_detach_from_avatar, object_attached, attachment));
@@ -1906,17 +2012,19 @@ void LLVOAvatar::buildCharacter()
1906 2012
1907 for (S32 pass = 0; pass < 2; pass++) 2013 for (S32 pass = 0; pass < 2; pass++)
1908 { 2014 {
1909 for (LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); 2015 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
1910 attachment; 2016 iter != mAttachmentPoints.end(); )
1911 attachment = mAttachmentPoints.getNextData())
1912 { 2017 {
2018 attachment_map_t::iterator curiter = iter++;
2019 LLViewerJointAttachment* attachment = curiter->second;
1913 if (attachment->getIsHUDAttachment() != (pass == 1)) 2020 if (attachment->getIsHUDAttachment() != (pass == 1))
1914 { 2021 {
1915 continue; 2022 continue;
1916 } 2023 }
1917 LLMenuItemCallGL* item = new LLMenuItemCallGL(attachment->getName(), 2024 LLMenuItemCallGL* item = new LLMenuItemCallGL(attachment->getName(),
1918 NULL, &object_selected_and_point_valid, &attach_label, attachment); 2025 NULL, &object_selected_and_point_valid,
1919 item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", mAttachmentPoints.reverseLookup(attachment)); 2026 &attach_label, attachment);
2027 item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", curiter->first);
1920 gAttachSubMenu->append(item); 2028 gAttachSubMenu->append(item);
1921 2029
1922 gDetachSubMenu->append(new LLMenuItemCallGL(attachment->getName(), 2030 gDetachSubMenu->append(new LLMenuItemCallGL(attachment->getName(),
@@ -1939,26 +2047,29 @@ void LLVOAvatar::buildCharacter()
1939 continue; 2047 continue;
1940 } 2048 }
1941 2049
1942 std::multimap<S32, LLViewerJointAttachment*> attachment_pie_menu_map; 2050 std::multimap<S32, S32> attachment_pie_menu_map;
1943 2051
1944 // gather up all attachment points assigned to this group, and throw into map sorted by pie slice number 2052 // gather up all attachment points assigned to this group, and throw into map sorted by pie slice number
1945 for (LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); 2053 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
1946 attachment; 2054 iter != mAttachmentPoints.end(); )
1947 attachment = mAttachmentPoints.getNextData())
1948 { 2055 {
2056 attachment_map_t::iterator curiter = iter++;
2057 LLViewerJointAttachment* attachment = curiter->second;
1949 if(attachment->getGroup() == group) 2058 if(attachment->getGroup() == group)
1950 { 2059 {
1951 // use multimap to provide a partial order off of the pie slice key 2060 // use multimap to provide a partial order off of the pie slice key
1952 attachment_pie_menu_map.insert(std::pair<S32, LLViewerJointAttachment*>(attachment->getPieSlice(), attachment)); 2061 S32 pie_index = attachment->getPieSlice();
2062 attachment_pie_menu_map.insert(std::make_pair(pie_index, curiter->first));
1953 } 2063 }
1954 } 2064 }
1955 2065
1956 // add in requested order to pie menu, inserting separators as necessary 2066 // add in requested order to pie menu, inserting separators as necessary
1957 std::multimap<S32, LLViewerJointAttachment*>::iterator attach_it;
1958 S32 cur_pie_slice = 0; 2067 S32 cur_pie_slice = 0;
1959 for (attach_it = attachment_pie_menu_map.begin(); attach_it != attachment_pie_menu_map.end(); ++attach_it) 2068 for (std::multimap<S32, S32>::iterator attach_it = attachment_pie_menu_map.begin();
2069 attach_it != attachment_pie_menu_map.end(); ++attach_it)
1960 { 2070 {
1961 S32 requested_pie_slice = attach_it->first; 2071 S32 requested_pie_slice = attach_it->first;
2072 S32 attach_index = attach_it->second;
1962 while (cur_pie_slice < requested_pie_slice) 2073 while (cur_pie_slice < requested_pie_slice)
1963 { 2074 {
1964 gAttachBodyPartPieMenus[group]->appendSeparator(); 2075 gAttachBodyPartPieMenus[group]->appendSeparator();
@@ -1966,16 +2077,18 @@ void LLVOAvatar::buildCharacter()
1966 cur_pie_slice++; 2077 cur_pie_slice++;
1967 } 2078 }
1968 2079
1969 LLViewerJointAttachment* attachment = attach_it->second; 2080 LLViewerJointAttachment* attachment = get_if_there(mAttachmentPoints, attach_index, (LLViewerJointAttachment*)NULL);
1970 2081 if (attachment)
1971 LLMenuItemCallGL* item = new LLMenuItemCallGL(attachment->getName(), 2082 {
1972 NULL, object_selected_and_point_valid); 2083 LLMenuItemCallGL* item = new LLMenuItemCallGL(attachment->getName(),
1973 gAttachBodyPartPieMenus[group]->append(item); 2084 NULL, object_selected_and_point_valid);
1974 item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", mAttachmentPoints.reverseLookup(attachment)); 2085 gAttachBodyPartPieMenus[group]->append(item);
1975 gDetachBodyPartPieMenus[group]->append(new LLMenuItemCallGL(attachment->getName(), 2086 item->addListener(gMenuHolder->getListenerByName("Object.AttachToAvatar"), "on_click", attach_index);
1976 &handle_detach_from_avatar, object_attached, attachment)); 2087 gDetachBodyPartPieMenus[group]->append(new LLMenuItemCallGL(attachment->getName(),
1977 2088 &handle_detach_from_avatar,
1978 cur_pie_slice++; 2089 object_attached, attachment));
2090 cur_pie_slice++;
2091 }
1979 } 2092 }
1980 } 2093 }
1981 } 2094 }
@@ -2015,13 +2128,14 @@ void LLVOAvatar::releaseMeshData()
2015 facep->setSize(0, 0); 2128 facep->setSize(0, 0);
2016 } 2129 }
2017 2130
2018 for (LLViewerJointAttachment *attachmentPoint = mAttachmentPoints.getFirstData(); 2131 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
2019 attachmentPoint; 2132 iter != mAttachmentPoints.end(); )
2020 attachmentPoint = mAttachmentPoints.getNextData())
2021 { 2133 {
2022 if (!attachmentPoint->getIsHUDAttachment()) 2134 attachment_map_t::iterator curiter = iter++;
2135 LLViewerJointAttachment* attachment = curiter->second;
2136 if (!attachment->getIsHUDAttachment())
2023 { 2137 {
2024 attachmentPoint->setAttachmentVisibility(FALSE); 2138 attachment->setAttachmentVisibility(FALSE);
2025 } 2139 }
2026 } 2140 }
2027 mMeshValid = FALSE; 2141 mMeshValid = FALSE;
@@ -2044,13 +2158,14 @@ void LLVOAvatar::restoreMeshData()
2044 } 2158 }
2045 else 2159 else
2046 { 2160 {
2047 for (LLViewerJointAttachment *attachmentPoint = mAttachmentPoints.getFirstData(); 2161 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
2048 attachmentPoint; 2162 iter != mAttachmentPoints.end(); )
2049 attachmentPoint = mAttachmentPoints.getNextData())
2050 { 2163 {
2051 if (!attachmentPoint->getIsHUDAttachment()) 2164 attachment_map_t::iterator curiter = iter++;
2165 LLViewerJointAttachment* attachment = curiter->second;
2166 if (!attachment->getIsHUDAttachment())
2052 { 2167 {
2053 attachmentPoint->setAttachmentVisibility(TRUE); 2168 attachment->setAttachmentVisibility(TRUE);
2054 } 2169 }
2055 } 2170 }
2056 } 2171 }
@@ -2066,6 +2181,7 @@ void LLVOAvatar::updateMeshData()
2066{ 2181{
2067 if (mDrawable.notNull()) 2182 if (mDrawable.notNull())
2068 { 2183 {
2184 stop_glerror();
2069 LLFace* facep = mDrawable->getFace(0); 2185 LLFace* facep = mDrawable->getFace(0);
2070 2186
2071 U32 num_vertices = 0; 2187 U32 num_vertices = 0;
@@ -2088,6 +2204,7 @@ void LLVOAvatar::updateMeshData()
2088 2204
2089 facep->mVertexBuffer = new LLVertexBufferAvatar(); 2205 facep->mVertexBuffer = new LLVertexBufferAvatar();
2090 facep->mVertexBuffer->allocateBuffer(num_vertices, num_indices, TRUE); 2206 facep->mVertexBuffer->allocateBuffer(num_vertices, num_indices, TRUE);
2207
2091 facep->setGeomIndex(0); 2208 facep->setGeomIndex(0);
2092 facep->setIndicesIndex(0); 2209 facep->setIndicesIndex(0);
2093 2210
@@ -2106,6 +2223,9 @@ void LLVOAvatar::updateMeshData()
2106 mSkirtLOD.updateFaceData(facep, mAdjustedPixelArea); 2223 mSkirtLOD.updateFaceData(facep, mAdjustedPixelArea);
2107 mUpperBodyLOD.updateFaceData(facep, mAdjustedPixelArea); 2224 mUpperBodyLOD.updateFaceData(facep, mAdjustedPixelArea);
2108 mHairLOD.updateFaceData(facep, mAdjustedPixelArea, TRUE); 2225 mHairLOD.updateFaceData(facep, mAdjustedPixelArea, TRUE);
2226
2227 stop_glerror();
2228 facep->mVertexBuffer->setBuffer(0);
2109 } 2229 }
2110} 2230}
2111 2231
@@ -2272,9 +2392,6 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2272 // force immediate pixel area update on avatars using last frames data (before drawable or camera updates) 2392 // force immediate pixel area update on avatars using last frames data (before drawable or camera updates)
2273 setPixelAreaAndAngle(gAgent); 2393 setPixelAreaAndAngle(gAgent);
2274 2394
2275 // Update the LOD of the joints
2276 //static const F32 UPDATE_TIME = .5f;
2277
2278 // force asynchronous drawable update 2395 // force asynchronous drawable update
2279 if(mDrawable.notNull() && !gNoRender) 2396 if(mDrawable.notNull() && !gNoRender)
2280 { 2397 {
@@ -2332,86 +2449,87 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2332 // store off last frame's root position to be consistent with camera position 2449 // store off last frame's root position to be consistent with camera position
2333 LLVector3 root_pos_last = mRoot.getWorldPosition(); 2450 LLVector3 root_pos_last = mRoot.getWorldPosition();
2334 2451
2335 updateCharacter(agent); 2452 BOOL detailed_update = updateCharacter(agent);
2336 2453
2337 //Ventrella 2454 {
2338 bool voiceEnabled = gVoiceClient->getVoiceEnabled( mID ) && gVoiceClient->inProximalChannel(); 2455 //Ventrella
2339 // disable voice visualizer when in mouselook 2456 bool voiceEnabled = gVoiceClient->getVoiceEnabled( mID ) && gVoiceClient->inProximalChannel();
2340 mVoiceVisualizer->setVoiceEnabled( voiceEnabled && !(mIsSelf && gAgent.cameraMouselook()) ); 2457 // disable voice visualizer when in mouselook
2341 if ( voiceEnabled ) 2458 mVoiceVisualizer->setVoiceEnabled( voiceEnabled && !(mIsSelf && gAgent.cameraMouselook()) );
2342 { 2459 if ( voiceEnabled )
2343 //---------------------------------------------------------------- 2460 {
2344 // Only do gesture triggering for your own avatar, and only when you're in a proximal channel. 2461 //----------------------------------------------------------------
2345 //---------------------------------------------------------------- 2462 // Only do gesture triggering for your own avatar, and only when you're in a proximal channel.
2346 if( mIsSelf ) 2463 //----------------------------------------------------------------
2347 { 2464 if( mIsSelf )
2348 //----------------------------------------------------------------------------------------
2349 // The following takes the voice signal and uses that to trigger gesticulations.
2350 //----------------------------------------------------------------------------------------
2351 int lastGesticulationLevel = mCurrentGesticulationLevel;
2352 mCurrentGesticulationLevel = mVoiceVisualizer->getCurrentGesticulationLevel();
2353
2354 //---------------------------------------------------------------------------------------------------
2355 // If "current gesticulation level" changes, we catch this, and trigger the new gesture
2356 //---------------------------------------------------------------------------------------------------
2357 if ( lastGesticulationLevel != mCurrentGesticulationLevel )
2358 { 2465 {
2359 if ( mCurrentGesticulationLevel != VOICE_GESTICULATION_LEVEL_OFF ) 2466 //----------------------------------------------------------------------------------------
2467 // The following takes the voice signal and uses that to trigger gesticulations.
2468 //----------------------------------------------------------------------------------------
2469 int lastGesticulationLevel = mCurrentGesticulationLevel;
2470 mCurrentGesticulationLevel = mVoiceVisualizer->getCurrentGesticulationLevel();
2471
2472 //---------------------------------------------------------------------------------------------------
2473 // If "current gesticulation level" changes, we catch this, and trigger the new gesture
2474 //---------------------------------------------------------------------------------------------------
2475 if ( lastGesticulationLevel != mCurrentGesticulationLevel )
2360 { 2476 {
2361 LLString gestureString = "unInitialized"; 2477 if ( mCurrentGesticulationLevel != VOICE_GESTICULATION_LEVEL_OFF )
2362 if ( mCurrentGesticulationLevel == 0 ) { gestureString = "/voicelevel1"; } 2478 {
2363 else if ( mCurrentGesticulationLevel == 1 ) { gestureString = "/voicelevel2"; } 2479 LLString gestureString = "unInitialized";
2364 else if ( mCurrentGesticulationLevel == 2 ) { gestureString = "/voicelevel3"; } 2480 if ( mCurrentGesticulationLevel == 0 ) { gestureString = "/voicelevel1"; }
2365 else { printf( "oops - CurrentGesticulationLevel can be only 0, 1, or 2\n" ); } 2481 else if ( mCurrentGesticulationLevel == 1 ) { gestureString = "/voicelevel2"; }
2366 2482 else if ( mCurrentGesticulationLevel == 2 ) { gestureString = "/voicelevel3"; }
2367 // this is the call that Karl S. created for triggering gestures from within the code. 2483 else { llinfos << "oops - CurrentGesticulationLevel can be only 0, 1, or 2" << llendl; }
2368 gGestureManager.triggerAndReviseString( gestureString ); 2484
2485 // this is the call that Karl S. created for triggering gestures from within the code.
2486 gGestureManager.triggerAndReviseString( gestureString );
2487 }
2369 } 2488 }
2370 }
2371
2372 } //if( mIsSelf )
2373
2374 //-----------------------------------------------------------------------------------------------------------------
2375 // If the avatar is speaking, then the voice amplitude signal is passed to the voice visualizer.
2376 // Also, here we trigger voice visualizer start and stop speaking, so it can animate the voice symbol.
2377 //
2378 // Notice the calls to "gAwayTimer.reset()". This resets the timer that determines how long the avatar has been
2379 // "away", so that the avatar doesn't lapse into away-mode (and slump over) while the user is still talking.
2380 //-----------------------------------------------------------------------------------------------------------------
2381 if ( gVoiceClient->getIsSpeaking( mID ) )
2382 {
2383 if ( ! mVoiceVisualizer->getCurrentlySpeaking() )
2384 {
2385 mVoiceVisualizer->setStartSpeaking();
2386 2489
2387 //printf( "gAwayTimer.reset();\n" ); 2490 } //if( mIsSelf )
2388 } 2491
2492 //-----------------------------------------------------------------------------------------------------------------
2493 // If the avatar is speaking, then the voice amplitude signal is passed to the voice visualizer.
2494 // Also, here we trigger voice visualizer start and stop speaking, so it can animate the voice symbol.
2495 //
2496 // Notice the calls to "gAwayTimer.reset()". This resets the timer that determines how long the avatar has been
2497 // "away", so that the avatar doesn't lapse into away-mode (and slump over) while the user is still talking.
2498 //-----------------------------------------------------------------------------------------------------------------
2499 if ( gVoiceClient->getIsSpeaking( mID ) )
2500 {
2501 if ( ! mVoiceVisualizer->getCurrentlySpeaking() )
2502 {
2503 mVoiceVisualizer->setStartSpeaking();
2504
2505 //printf( "gAwayTimer.reset();\n" );
2506 }
2389 2507
2390 mVoiceVisualizer->setSpeakingAmplitude( gVoiceClient->getCurrentPower( mID ) ); 2508 mVoiceVisualizer->setSpeakingAmplitude( gVoiceClient->getCurrentPower( mID ) );
2391 2509
2392 if( mIsSelf ) 2510 if( mIsSelf )
2393 { 2511 {
2394 gAgent.clearAFK(); 2512 gAgent.clearAFK();
2513 }
2395 } 2514 }
2396 } 2515 else
2397 else
2398 {
2399 if ( mVoiceVisualizer->getCurrentlySpeaking() )
2400 { 2516 {
2401 mVoiceVisualizer->setStopSpeaking(); 2517 if ( mVoiceVisualizer->getCurrentlySpeaking() )
2518 {
2519 mVoiceVisualizer->setStopSpeaking();
2520 }
2402 } 2521 }
2403 }
2404 2522
2405 //-------------------------------------------------------------------------------------------- 2523 //--------------------------------------------------------------------------------------------
2406 // here we get the approximate head position and set as sound source for the voice symbol 2524 // here we get the approximate head position and set as sound source for the voice symbol
2407 // (the following version uses a tweak of "mHeadOffset" which handle sitting vs. standing) 2525 // (the following version uses a tweak of "mHeadOffset" which handle sitting vs. standing)
2408 //-------------------------------------------------------------------------------------------- 2526 //--------------------------------------------------------------------------------------------
2409 LLVector3 headOffset = LLVector3( 0.0f, 0.0f, mHeadOffset.mV[2] ); 2527 LLVector3 headOffset = LLVector3( 0.0f, 0.0f, mHeadOffset.mV[2] );
2410 mVoiceVisualizer->setVoiceSourceWorldPosition( mRoot.getWorldPosition() + headOffset ); 2528 mVoiceVisualizer->setVoiceSourceWorldPosition( mRoot.getWorldPosition() + headOffset );
2411 2529
2412 }//if ( voiceEnabled ) 2530 }//if ( voiceEnabled )
2531 }
2413 //End Ventrella 2532 //End Ventrella
2414
2415 2533
2416 if (LLVOAvatar::sJointDebug) 2534 if (LLVOAvatar::sJointDebug)
2417 { 2535 {
@@ -2432,17 +2550,22 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2432 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_SHADOW, TRUE); 2550 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_SHADOW, TRUE);
2433 } 2551 }
2434 2552
2553 BOOL visible = isVisible() || mNeedsAnimUpdate;
2554
2435 // update attachments positions 2555 // update attachments positions
2556 if (detailed_update || !sUseImpostors)
2436 { 2557 {
2437 LLFastTimer t(LLFastTimer::FTM_ATTACHMENT_UPDATE); 2558 LLFastTimer t(LLFastTimer::FTM_ATTACHMENT_UPDATE);
2438 for(LLViewerJointAttachment *attachment = mAttachmentPoints.getFirstData(); 2559 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
2439 attachment; 2560 iter != mAttachmentPoints.end(); )
2440 attachment = mAttachmentPoints.getNextData())
2441 { 2561 {
2562 attachment_map_t::iterator curiter = iter++;
2563 LLViewerJointAttachment* attachment = curiter->second;
2442 LLViewerObject *attached_object = attachment->getObject(); 2564 LLViewerObject *attached_object = attachment->getObject();
2443 2565
2444 BOOL visibleAttachment = isVisible() || !(attached_object && attached_object->mDrawable->getSpatialBridge() 2566 BOOL visibleAttachment = visible || (attached_object &&
2445 && (attached_object->mDrawable->getSpatialBridge()->getRadius() < 2.0)); 2567 !(attached_object->mDrawable->getSpatialBridge() &&
2568 attached_object->mDrawable->getSpatialBridge()->getRadius() < 2.0));
2446 2569
2447 if (visibleAttachment && attached_object && !attached_object->isDead() && attachment->getValid()) 2570 if (visibleAttachment && attached_object && !attached_object->isDead() && attachment->getValid())
2448 { 2571 {
@@ -2455,10 +2578,61 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2455 { 2578 {
2456 gPipeline.updateMoveDampedAsync(attached_object->mDrawable); 2579 gPipeline.updateMoveDampedAsync(attached_object->mDrawable);
2457 } 2580 }
2458 attached_object->updateText(); 2581
2582 LLSpatialBridge* bridge = attached_object->mDrawable->getSpatialBridge();
2583 if (bridge)
2584 {
2585 gPipeline.updateMoveNormalAsync(bridge);
2586 }
2587 attached_object->updateText();
2459 } 2588 }
2460 } 2589 }
2461 } 2590 }
2591
2592 mNeedsAnimUpdate = FALSE;
2593
2594 if (isImpostor() && !mNeedsImpostorUpdate)
2595 {
2596 LLVector3 ext[2];
2597 F32 distance;
2598 LLVector3 angle;
2599
2600 getImpostorValues(ext, angle, distance);
2601
2602 for (U32 i = 0; i < 3 && !mNeedsImpostorUpdate; i++)
2603 {
2604 F32 cur_angle = angle.mV[i];
2605 F32 old_angle = mImpostorAngle.mV[i];
2606 F32 angle_diff = fabsf(cur_angle-old_angle);
2607
2608 if (angle_diff > 3.14159f/16.f)
2609 {
2610 mNeedsImpostorUpdate = TRUE;
2611 }
2612 }
2613
2614 if (detailed_update && !mNeedsImpostorUpdate)
2615 { //update impostor if view angle, distance, or bounding box change
2616 //significantly
2617
2618 F32 dist_diff = fabsf(distance-mImpostorDistance);
2619 if (dist_diff/mImpostorDistance > 0.1f)
2620 {
2621 mNeedsImpostorUpdate = TRUE;
2622 }
2623 else
2624 {
2625 getSpatialExtents(ext[0], ext[1]);
2626 if ((ext[1]-mImpostorExtents[1]).magVec() > 0.05f ||
2627 (ext[0]-mImpostorExtents[0]).magVec() > 0.05f)
2628 {
2629 mNeedsImpostorUpdate = TRUE;
2630 }
2631 }
2632 }
2633 }
2634
2635 mDrawable->movePartition();
2462 2636
2463 //force a move if sitting on an active object 2637 //force a move if sitting on an active object
2464 if (getParent() && ((LLViewerObject*) getParent())->mDrawable->isActive()) 2638 if (getParent() && ((LLViewerObject*) getParent())->mDrawable->isActive())
@@ -2598,7 +2772,7 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
2598 const F32 FADE_DURATION = gSavedSettings.getF32("RenderNameFadeDuration"); // seconds 2772 const F32 FADE_DURATION = gSavedSettings.getF32("RenderNameFadeDuration"); // seconds
2599 BOOL visible_chat = gSavedSettings.getBOOL("UseChatBubbles") && (mChats.size() || mTyping); 2773 BOOL visible_chat = gSavedSettings.getBOOL("UseChatBubbles") && (mChats.size() || mTyping);
2600 BOOL render_name = visible_chat || 2774 BOOL render_name = visible_chat ||
2601 (isVisible() && 2775 (visible &&
2602 ((sRenderName == RENDER_NAME_ALWAYS) || 2776 ((sRenderName == RENDER_NAME_ALWAYS) ||
2603 (sRenderName == RENDER_NAME_FADE && time_visible < NAME_SHOW_TIME))); 2777 (sRenderName == RENDER_NAME_FADE && time_visible < NAME_SHOW_TIME)));
2604 // If it's your own avatar, don't draw in mouselook, and don't 2778 // If it's your own avatar, don't draw in mouselook, and don't
@@ -2981,10 +3155,9 @@ void LLVOAvatar::slamPosition()
2981// updateCharacter() 3155// updateCharacter()
2982// called on both your avatar and other avatars 3156// called on both your avatar and other avatars
2983//------------------------------------------------------------------------ 3157//------------------------------------------------------------------------
2984void LLVOAvatar::updateCharacter(LLAgent &agent) 3158BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
2985{ 3159{
2986 LLMemType mt(LLMemType::MTYPE_AVATAR); 3160 LLMemType mt(LLMemType::MTYPE_AVATAR);
2987
2988 // update screen joint size 3161 // update screen joint size
2989 if (mScreenp) 3162 if (mScreenp)
2990 { 3163 {
@@ -3030,7 +3203,7 @@ void LLVOAvatar::updateCharacter(LLAgent &agent)
3030 { 3203 {
3031 gAgent.setPositionAgent(getPositionAgent()); 3204 gAgent.setPositionAgent(getPositionAgent());
3032 } 3205 }
3033 return; 3206 return FALSE;
3034 } 3207 }
3035 3208
3036 3209
@@ -3038,19 +3211,51 @@ void LLVOAvatar::updateCharacter(LLAgent &agent)
3038 3211
3039 if (!mIsBuilt) 3212 if (!mIsBuilt)
3040 { 3213 {
3041 return; 3214 return FALSE;
3042 } 3215 }
3043 3216
3217 BOOL visible = isVisible();
3218
3044 // For fading out the names above heads, only let the timer 3219 // For fading out the names above heads, only let the timer
3045 // run if we're visible. 3220 // run if we're visible.
3046 if (mDrawable.notNull() && !mDrawable->isVisible()) 3221 if (mDrawable.notNull() && !visible)
3047 { 3222 {
3048 mTimeVisible.reset(); 3223 mTimeVisible.reset();
3049 } 3224 }
3050 3225
3051 if (!mIsSelf && !isVisible()) 3226
3227 //--------------------------------------------------------------------
3228 // the rest should only be done occasionally for far away avatars
3229 //--------------------------------------------------------------------
3230
3231 if (!mIsSelf && sUseImpostors && !mNeedsAnimUpdate)
3052 { 3232 {
3053 return; 3233 F32 impostor_area = 256.f*512.f*(8.125f - LLVOAvatar::sLODFactor*8.f);
3234 if (visible && mPixelArea <= impostor_area)
3235 {
3236 mUpdatePeriod = llclamp((S32) sqrtf(impostor_area*4.f/mPixelArea), 2, 8);
3237
3238 visible = (LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0 ? TRUE : FALSE;
3239 }
3240 else
3241 {
3242 mUpdatePeriod = 1;
3243 }
3244
3245 if (!visible)
3246 {
3247 if (!mMotionController.isPaused())
3248 {
3249 mMotionController.pause();
3250 mMotionController.updateMotion();
3251 mMotionController.unpause();
3252 }
3253 else
3254 {
3255 mMotionController.updateMotion();
3256 }
3257 return FALSE;
3258 }
3054 } 3259 }
3055 3260
3056 // change animation time quanta based on avatar render load 3261 // change animation time quanta based on avatar render load
@@ -3321,27 +3526,6 @@ void LLVOAvatar::updateCharacter(LLAgent &agent)
3321 mRoot.setRotation(mDrawable->getRotation()); 3526 mRoot.setRotation(mDrawable->getRotation());
3322 } 3527 }
3323 3528
3324 //--------------------------------------------------------------------
3325 // the rest should only be done when close enough to see it
3326 //--------------------------------------------------------------------
3327
3328
3329 if (mPixelArea > 12.0f)
3330 throttle = FALSE;
3331 if (mPixelArea < 400.0f)
3332 {
3333 throttle = (LLDrawable::getCurrentFrame()+mID.mData[0])%2 != 0;
3334 }
3335
3336 if ( !(mIsSitting && getParent()) &&
3337 (throttle ||
3338 (!isVisible() && (mPixelArea < MIN_PIXEL_AREA_FOR_COMPOSITE))) )
3339 {
3340 mRoot.setWorldRotation( getRotation() );
3341 mRoot.updateWorldMatrixChildren();
3342 return;
3343 }
3344
3345 //------------------------------------------------------------------------- 3529 //-------------------------------------------------------------------------
3346 // Update character motions 3530 // Update character motions
3347 //------------------------------------------------------------------------- 3531 //-------------------------------------------------------------------------
@@ -3479,6 +3663,11 @@ void LLVOAvatar::updateCharacter(LLAgent &agent)
3479 { 3663 {
3480 setDebugText(mDebugText); 3664 setDebugText(mDebugText);
3481 } 3665 }
3666
3667 //mesh vertices need to be reskinned
3668 mNeedsSkin = TRUE;
3669
3670 return TRUE;
3482} 3671}
3483 3672
3484//----------------------------------------------------------------------------- 3673//-----------------------------------------------------------------------------
@@ -3509,7 +3698,7 @@ void LLVOAvatar::updateHeadOffset()
3509//------------------------------------------------------------------------ 3698//------------------------------------------------------------------------
3510// updateVisibility() 3699// updateVisibility()
3511//------------------------------------------------------------------------ 3700//------------------------------------------------------------------------
3512void LLVOAvatar::updateVisibility(BOOL force_invisible) 3701void LLVOAvatar::updateVisibility()
3513{ 3702{
3514 BOOL visible = FALSE; 3703 BOOL visible = FALSE;
3515 3704
@@ -3521,7 +3710,7 @@ void LLVOAvatar::updateVisibility(BOOL force_invisible)
3521 { 3710 {
3522 visible = FALSE; 3711 visible = FALSE;
3523 } 3712 }
3524 else if (!force_invisible) 3713 else
3525 { 3714 {
3526 // calculate avatar distance wrt head 3715 // calculate avatar distance wrt head
3527 mDrawable->updateDistance(*gCamera); 3716 mDrawable->updateDistance(*gCamera);
@@ -3593,10 +3782,11 @@ void LLVOAvatar::updateVisibility(BOOL force_invisible)
3593 llinfos << "PA: " << getPositionAgent() << llendl; 3782 llinfos << "PA: " << getPositionAgent() << llendl;
3594 /*llinfos << "SPA: " << sel_pos_agent << llendl; 3783 /*llinfos << "SPA: " << sel_pos_agent << llendl;
3595 llinfos << "WPA: " << wrist_right_pos_agent << llendl;*/ 3784 llinfos << "WPA: " << wrist_right_pos_agent << llendl;*/
3596 for (LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); 3785 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
3597 attachment; 3786 iter != mAttachmentPoints.end(); )
3598 attachment = mAttachmentPoints.getNextData())
3599 { 3787 {
3788 attachment_map_t::iterator curiter = iter++;
3789 LLViewerJointAttachment* attachment = curiter->second;
3600 if (attachment->getObject()) 3790 if (attachment->getObject())
3601 { 3791 {
3602 if(attachment->getObject()->mDrawable->isVisible()) 3792 if(attachment->getObject()->mDrawable->isVisible())
@@ -3643,48 +3833,6 @@ void LLVOAvatar::updateVisibility(BOOL force_invisible)
3643} 3833}
3644 3834
3645//------------------------------------------------------------------------ 3835//------------------------------------------------------------------------
3646// updateAllVisibility()
3647//------------------------------------------------------------------------
3648//static
3649void LLVOAvatar::updateAllAvatarVisiblity()
3650{
3651 LLVOAvatar::sNumVisibleAvatars = 0;
3652
3653 F32 render_priority = (F32)LLVOAvatar::sMaxVisible;
3654 for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
3655 iter != LLCharacter::sInstances.end(); ++iter)
3656 {
3657 LLVOAvatar* avatarp = (LLVOAvatar*) *iter;
3658 if (avatarp->isDead())
3659 {
3660 continue;
3661 }
3662 if (avatarp->isSelf())
3663 {
3664 avatarp->mRenderPriority = 1000.f;
3665 }
3666 else
3667 {
3668 avatarp->mRenderPriority = render_priority * 10.f; // 500 -> 10
3669 if (render_priority > 0.f)
3670 {
3671 render_priority -= 1.f;
3672 }
3673 }
3674 avatarp->updateVisibility(LLVOAvatar::sNumVisibleAvatars > LLVOAvatar::sMaxVisible);
3675
3676 if (avatarp->mDrawable.isNull())
3677 {
3678 llwarns << "Avatar with no drawable" << llendl;
3679 }
3680 else if (avatarp->mDrawable->isVisible())
3681 {
3682 LLVOAvatar::sNumVisibleAvatars++;
3683 }
3684 }
3685}
3686
3687//------------------------------------------------------------------------
3688// needsRenderBeam() 3836// needsRenderBeam()
3689//------------------------------------------------------------------------ 3837//------------------------------------------------------------------------
3690BOOL LLVOAvatar::needsRenderBeam() 3838BOOL LLVOAvatar::needsRenderBeam()
@@ -3717,6 +3865,47 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
3717 return num_indices; 3865 return num_indices;
3718 } 3866 }
3719 3867
3868 if (mDirtyMesh || mDrawable->isState(LLDrawable::REBUILD_GEOMETRY))
3869 { //LOD changed or new mesh created, allocate new vertex buffer if needed
3870 updateMeshData();
3871 mDirtyMesh = FALSE;
3872 mNeedsSkin = TRUE;
3873 mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
3874 }
3875
3876 if (LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR) <= 0)
3877 {
3878 if (mNeedsSkin)
3879 {
3880 //generate animated mesh
3881 mLowerBodyLOD.updateGeometry();
3882 mUpperBodyLOD.updateGeometry();
3883
3884 if( isWearingWearableType( WT_SKIRT ) )
3885 {
3886 mSkirtLOD.updateGeometry();
3887 }
3888
3889 if (!mIsSelf || gAgent.needsRenderHead())
3890 {
3891 mEyeLashLOD.updateGeometry();
3892 mHeadLOD.updateGeometry();
3893 mHairLOD.updateGeometry();
3894 }
3895 mNeedsSkin = FALSE;
3896
3897 LLVertexBuffer* vb = mDrawable->getFace(0)->mVertexBuffer;
3898 if (vb)
3899 {
3900 vb->setBuffer(0);
3901 }
3902 }
3903 }
3904 else
3905 {
3906 mNeedsSkin = FALSE;
3907 }
3908
3720 if (sDebugInvisible) 3909 if (sDebugInvisible)
3721 { 3910 {
3722 LLNameValue* firstname = getNVPair("FirstName"); 3911 LLNameValue* firstname = getNVPair("FirstName");
@@ -3761,27 +3950,27 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
3761 LLVector3 collide_point = slaved_pos; 3950 LLVector3 collide_point = slaved_pos;
3762 collide_point.mV[VZ] -= foot_plane_normal.mV[VZ] * (dist_from_plane + COLLISION_TOLERANCE - FOOT_COLLIDE_FUDGE); 3951 collide_point.mV[VZ] -= foot_plane_normal.mV[VZ] * (dist_from_plane + COLLISION_TOLERANCE - FOOT_COLLIDE_FUDGE);
3763 3952
3764 glBegin(GL_LINES); 3953 gGL.begin(GL_LINES);
3765 { 3954 {
3766 F32 SQUARE_SIZE = 0.2f; 3955 F32 SQUARE_SIZE = 0.2f;
3767 glColor4f(1.f, 0.f, 0.f, 1.f); 3956 gGL.color4f(1.f, 0.f, 0.f, 1.f);
3768 3957
3769 glVertex3f(collide_point.mV[VX] - SQUARE_SIZE, collide_point.mV[VY] - SQUARE_SIZE, collide_point.mV[VZ]); 3958 gGL.vertex3f(collide_point.mV[VX] - SQUARE_SIZE, collide_point.mV[VY] - SQUARE_SIZE, collide_point.mV[VZ]);
3770 glVertex3f(collide_point.mV[VX] + SQUARE_SIZE, collide_point.mV[VY] - SQUARE_SIZE, collide_point.mV[VZ]); 3959 gGL.vertex3f(collide_point.mV[VX] + SQUARE_SIZE, collide_point.mV[VY] - SQUARE_SIZE, collide_point.mV[VZ]);
3771 3960
3772 glVertex3f(collide_point.mV[VX] + SQUARE_SIZE, collide_point.mV[VY] - SQUARE_SIZE, collide_point.mV[VZ]); 3961 gGL.vertex3f(collide_point.mV[VX] + SQUARE_SIZE, collide_point.mV[VY] - SQUARE_SIZE, collide_point.mV[VZ]);
3773 glVertex3f(collide_point.mV[VX] + SQUARE_SIZE, collide_point.mV[VY] + SQUARE_SIZE, collide_point.mV[VZ]); 3962 gGL.vertex3f(collide_point.mV[VX] + SQUARE_SIZE, collide_point.mV[VY] + SQUARE_SIZE, collide_point.mV[VZ]);
3774 3963
3775 glVertex3f(collide_point.mV[VX] + SQUARE_SIZE, collide_point.mV[VY] + SQUARE_SIZE, collide_point.mV[VZ]); 3964 gGL.vertex3f(collide_point.mV[VX] + SQUARE_SIZE, collide_point.mV[VY] + SQUARE_SIZE, collide_point.mV[VZ]);
3776 glVertex3f(collide_point.mV[VX] - SQUARE_SIZE, collide_point.mV[VY] + SQUARE_SIZE, collide_point.mV[VZ]); 3965 gGL.vertex3f(collide_point.mV[VX] - SQUARE_SIZE, collide_point.mV[VY] + SQUARE_SIZE, collide_point.mV[VZ]);
3777 3966
3778 glVertex3f(collide_point.mV[VX] - SQUARE_SIZE, collide_point.mV[VY] + SQUARE_SIZE, collide_point.mV[VZ]); 3967 gGL.vertex3f(collide_point.mV[VX] - SQUARE_SIZE, collide_point.mV[VY] + SQUARE_SIZE, collide_point.mV[VZ]);
3779 glVertex3f(collide_point.mV[VX] - SQUARE_SIZE, collide_point.mV[VY] - SQUARE_SIZE, collide_point.mV[VZ]); 3968 gGL.vertex3f(collide_point.mV[VX] - SQUARE_SIZE, collide_point.mV[VY] - SQUARE_SIZE, collide_point.mV[VZ]);
3780 3969
3781 glVertex3f(collide_point.mV[VX], collide_point.mV[VY], collide_point.mV[VZ]); 3970 gGL.vertex3f(collide_point.mV[VX], collide_point.mV[VY], collide_point.mV[VZ]);
3782 glVertex3f(collide_point.mV[VX] + mFootPlane.mV[VX], collide_point.mV[VY] + mFootPlane.mV[VY], collide_point.mV[VZ] + mFootPlane.mV[VZ]); 3971 gGL.vertex3f(collide_point.mV[VX] + mFootPlane.mV[VX], collide_point.mV[VY] + mFootPlane.mV[VY], collide_point.mV[VZ] + mFootPlane.mV[VZ]);
3783 3972
3784 }glEnd(); 3973 }gGL.end();
3785 } 3974 }
3786 //-------------------------------------------------------------------- 3975 //--------------------------------------------------------------------
3787 // render all geomety attached to the skeleton 3976 // render all geomety attached to the skeleton
@@ -3807,41 +3996,7 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
3807 num_indices += renderTransparent(); 3996 num_indices += renderTransparent();
3808 } 3997 }
3809 } 3998 }
3810 /*else if (pass == AVATAR_RENDER_PASS_CLOTHING_INNER) 3999
3811 {
3812 if (!mIsSelf || gAgent.needsRenderHead())
3813 {
3814 num_indices += mHeadLOD.render(mAdjustedPixelArea);
3815 }
3816 LLViewerJointMesh::sClothingInnerColor = mTexSkinColor->getColor() * 0.5f;
3817 LLViewerJointMesh::sClothingMaskImageName = mUpperMaskTexName;
3818 num_indices += mUpperBodyLOD.render(mAdjustedPixelArea);
3819 LLViewerJointMesh::sClothingMaskImageName = mLowerMaskTexName;
3820 num_indices += mLowerBodyLOD.render(mAdjustedPixelArea);
3821 LLViewerJointMesh::sClothingMaskImageName = 0;
3822 if( isWearingWearableType( WT_SKIRT ) )
3823 {
3824 glAlphaFunc(GL_GREATER,0.25f);
3825 num_indices += mSkirtLOD.render(mAdjustedPixelArea);
3826 glAlphaFunc(GL_GREATER,0.01f);
3827 }
3828
3829 if (!mIsSelf || gAgent.needsRenderHead())
3830 {
3831 num_indices += mEyeLashLOD.render(mAdjustedPixelArea);
3832 num_indices += mHairLOD.render(mAdjustedPixelArea);
3833 }
3834 }
3835 else if (pass == AVATAR_RENDER_PASS_CLOTHING_OUTER)
3836 {
3837 LLViewerJointMesh::sClothingInnerColor = mTexSkinColor->getColor() * 0.5f;
3838 LLViewerJointMesh::sClothingMaskImageName = mUpperMaskTexName;
3839 num_indices += mUpperBodyLOD.render(mAdjustedPixelArea);
3840 LLViewerJointMesh::sClothingMaskImageName = mLowerMaskTexName;
3841 num_indices += mLowerBodyLOD.render(mAdjustedPixelArea);
3842 LLViewerJointMesh::sClothingMaskImageName = 0;
3843 }*/
3844
3845 LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE; 4000 LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE;
3846 4001
3847 //llinfos << "Avatar render: " << render_timer.getElapsedTimeF32() << llendl; 4002 //llinfos << "Avatar render: " << render_timer.getElapsedTimeF32() << llendl;
@@ -3865,8 +4020,16 @@ U32 LLVOAvatar::renderTransparent()
3865 4020
3866 if (!mIsSelf || gAgent.needsRenderHead()) 4021 if (!mIsSelf || gAgent.needsRenderHead())
3867 { 4022 {
4023 if (LLPipeline::sImpostorRender)
4024 {
4025 glAlphaFunc(GL_GREATER, 0.5f);
4026 }
3868 num_indices += mEyeLashLOD.render(mAdjustedPixelArea, first_pass); 4027 num_indices += mEyeLashLOD.render(mAdjustedPixelArea, first_pass);
3869 num_indices += mHairLOD.render(mAdjustedPixelArea, FALSE); 4028 num_indices += mHairLOD.render(mAdjustedPixelArea, FALSE);
4029 if (LLPipeline::sImpostorRender)
4030 {
4031 glAlphaFunc(GL_GREATER, 0.01f);
4032 }
3870 } 4033 }
3871 4034
3872 return num_indices; 4035 return num_indices;
@@ -3919,9 +4082,17 @@ U32 LLVOAvatar::renderFootShadows()
3919 return 0; 4082 return 0;
3920 } 4083 }
3921 4084
4085 // Update the shadow, tractor, and text label geometry.
4086 if (mDrawable->isState(LLDrawable::REBUILD_SHADOW) && !isImpostor())
4087 {
4088 updateShadowFaces();
4089 mDrawable->clearState(LLDrawable::REBUILD_SHADOW);
4090 }
4091
3922 U32 foot_mask = LLVertexBuffer::MAP_VERTEX | 4092 U32 foot_mask = LLVertexBuffer::MAP_VERTEX |
3923 LLVertexBuffer::MAP_TEXCOORD; 4093 LLVertexBuffer::MAP_TEXCOORD;
3924 4094
4095 LLGLDepthTest test(GL_TRUE, GL_FALSE);
3925 //render foot shadows 4096 //render foot shadows
3926 LLGLEnable blend(GL_BLEND); 4097 LLGLEnable blend(GL_BLEND);
3927 mShadowImagep->bind(); 4098 mShadowImagep->bind();
@@ -3933,6 +4104,38 @@ U32 LLVOAvatar::renderFootShadows()
3933 return num_indices; 4104 return num_indices;
3934} 4105}
3935 4106
4107U32 LLVOAvatar::renderImpostor(LLColor4U color)
4108{
4109 if (!mImpostor.isComplete())
4110 {
4111 return 0;
4112 }
4113
4114 LLVector3 pos(getRenderPosition()+mImpostorOffset);
4115 LLVector3 left = gCamera->getLeftAxis()*mImpostorDim.mV[0];
4116 LLVector3 up = gCamera->getUpAxis()*mImpostorDim.mV[1];
4117
4118 LLGLEnable test(GL_ALPHA_TEST);
4119 glAlphaFunc(GL_GREATER, 0.f);
4120
4121 gGL.start();
4122 gGL.color4ubv(color.mV);
4123 mImpostor.bindTexture();
4124 gGL.begin(GL_QUADS);
4125 gGL.texCoord2f(0,0);
4126 gGL.vertex3fv((pos+left-up).mV);
4127 gGL.texCoord2f(1,0);
4128 gGL.vertex3fv((pos-left-up).mV);
4129 gGL.texCoord2f(1,1);
4130 gGL.vertex3fv((pos-left+up).mV);
4131 gGL.texCoord2f(0,1);
4132 gGL.vertex3fv((pos+left+up).mV);
4133 gGL.end();
4134 gGL.stop();
4135
4136 return 6;
4137}
4138
3936//----------------------------------------------------------------------------- 4139//-----------------------------------------------------------------------------
3937// renderCollisionVolumes() 4140// renderCollisionVolumes()
3938//----------------------------------------------------------------------------- 4141//-----------------------------------------------------------------------------
@@ -3949,7 +4152,6 @@ void LLVOAvatar::renderCollisionVolumes()
3949//------------------------------------------------------------------------ 4152//------------------------------------------------------------------------
3950void LLVOAvatar::updateTextures(LLAgent &agent) 4153void LLVOAvatar::updateTextures(LLAgent &agent)
3951{ 4154{
3952// LLFastTimer ftm(LLFastTimer::FTM_TEMP5);
3953 BOOL render_avatar = TRUE; 4155 BOOL render_avatar = TRUE;
3954 4156
3955 if (mIsDummy || gNoRender) 4157 if (mIsDummy || gNoRender)
@@ -5103,7 +5305,7 @@ BOOL LLVOAvatar::loadSkeletonNode ()
5103 delete attachment; 5305 delete attachment;
5104 continue; 5306 continue;
5105 } 5307 }
5106 if (mAttachmentPoints.checkData(attachmentID)) 5308 if (mAttachmentPoints.find(attachmentID) != mAttachmentPoints.end())
5107 { 5309 {
5108 llwarns << "Attachment point redefined with id " << attachmentID << " on attachment point " << info->mName << llendl; 5310 llwarns << "Attachment point redefined with id " << attachmentID << " on attachment point " << info->mName << llendl;
5109 delete attachment; 5311 delete attachment;
@@ -5407,38 +5609,23 @@ BOOL LLVOAvatar::isActive() const
5407void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent) 5609void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent)
5408{ 5610{
5409 LLMemType mt(LLMemType::MTYPE_AVATAR); 5611 LLMemType mt(LLMemType::MTYPE_AVATAR);
5410
5411 F32 max_scale = getMaxScale();
5412 F32 mid_scale = getMidScale();
5413 F32 min_scale = llmin( getScale().mV[VX], llmin( getScale().mV[VY], getScale().mV[VZ] ) );
5414 5612
5415 // IW: esitmate - when close to large objects, computing range based on distance from center is no good 5613 const LLVector3* ext = mDrawable->getSpatialExtents();
5416 // to try to get a min distance from face, subtract min_scale/2 from the range. 5614 LLVector3 center = (ext[1] + ext[0]) * 0.5f;
5417 // This means we'll load too much detail sometimes, but that's better than not enough 5615 LLVector3 size = (ext[1]-ext[0])*0.5f;
5418 // I don't think there's a better way to do this without calculating distance per-poly 5616
5419 F32 range = (getRenderPosition()-gCamera->getOrigin()).magVec() - min_scale/2; 5617 mPixelArea = LLPipeline::calcPixelArea(center, size, *gCamera);
5618
5619 F32 range = mDrawable->mDistanceWRTCamera;
5420 5620
5421 if (range < 0.001f) // range == zero 5621 if (range < 0.001f) // range == zero
5422 { 5622 {
5423 mAppAngle = 180.f; 5623 mAppAngle = 180.f;
5424 mPixelArea = gCamera->getViewHeightInPixels() *
5425 gCamera->getViewHeightInPixels() *
5426 gCamera->getAspect();
5427 } 5624 }
5428 else 5625 else
5429 { 5626 {
5430 mAppAngle = (F32) atan2( max_scale, range) * RAD_TO_DEG; 5627 F32 radius = size.magVec();
5431 5628 mAppAngle = (F32) atan2( radius, range) * RAD_TO_DEG;
5432 F32 pixels_per_meter = gCamera->getPixelMeterRatio() / range;
5433
5434 mPixelArea = (pixels_per_meter * max_scale) * (pixels_per_meter * mid_scale);
5435// if( !mIsSelf )
5436// {
5437// llinfos << "range " << range << llendl;
5438// llinfos << "pixels_per_meter " << pixels_per_meter << llendl;
5439// llinfos << "scale " << max_scale << "x" << mid_scale << llendl;
5440// llinfos << "pixel area " << mPixelArea << llendl;
5441// }
5442 } 5629 }
5443 5630
5444 // We always want to look good to ourselves 5631 // We always want to look good to ourselves
@@ -5551,10 +5738,11 @@ void LLVOAvatar::updateShadowFaces()
5551{ 5738{
5552 LLFace *face0p = mShadow0Facep; 5739 LLFace *face0p = mShadow0Facep;
5553 LLFace *face1p = mShadow1Facep; 5740 LLFace *face1p = mShadow1Facep;
5741
5554 // 5742 //
5555 // render avatar shadows 5743 // render avatar shadows
5556 // 5744 //
5557 if (mInAir) 5745 if (mInAir || mUpdatePeriod >= VOAVATAR_IMPOSTOR_PERIOD)
5558 { 5746 {
5559 face0p->setSize(0, 0); 5747 face0p->setSize(0, 0);
5560 face1p->setSize(0, 0); 5748 face1p->setSize(0, 0);
@@ -5567,7 +5755,7 @@ void LLVOAvatar::updateShadowFaces()
5567 F32 cos_elev = sqrt(1 - cos_angle * cos_angle); 5755 F32 cos_elev = sqrt(1 - cos_angle * cos_angle);
5568 if (cos_angle < 0) cos_elev = -cos_elev; 5756 if (cos_angle < 0) cos_elev = -cos_elev;
5569 sprite.setSize(0.4f + cos_elev * 0.8f, 0.3f); 5757 sprite.setSize(0.4f + cos_elev * 0.8f, 0.3f);
5570 LLVector3 sun_vec = gSky.mVOSkyp->getToSun(); 5758 LLVector3 sun_vec = gSky.mVOSkyp ? gSky.mVOSkyp->getToSun() : LLVector3(0.f, 0.f, 0.f);
5571 5759
5572 if (mShadowImagep->getHasGLTexture()) 5760 if (mShadowImagep->getHasGLTexture())
5573 { 5761 {
@@ -5755,7 +5943,14 @@ void LLVOAvatar::setParent(LLViewerObject* parent)
5755void LLVOAvatar::addChild(LLViewerObject *childp) 5943void LLVOAvatar::addChild(LLViewerObject *childp)
5756{ 5944{
5757 LLViewerObject::addChild(childp); 5945 LLViewerObject::addChild(childp);
5758 attachObject(childp); 5946 if (childp->mDrawable)
5947 {
5948 attachObject(childp);
5949 }
5950 else
5951 {
5952 mPendingAttachment.push_back(childp);
5953 }
5759} 5954}
5760 5955
5761void LLVOAvatar::removeChild(LLViewerObject *childp) 5956void LLVOAvatar::removeChild(LLViewerObject *childp)
@@ -5768,7 +5963,7 @@ LLViewerJointAttachment* LLVOAvatar::getTargetAttachmentPoint(LLViewerObject* vi
5768{ 5963{
5769 S32 attachmentID = ATTACHMENT_ID_FROM_STATE(viewer_object->getState()); 5964 S32 attachmentID = ATTACHMENT_ID_FROM_STATE(viewer_object->getState());
5770 5965
5771 LLViewerJointAttachment* attachment = mAttachmentPoints.getIfThere(attachmentID); 5966 LLViewerJointAttachment* attachment = get_if_there(mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL);
5772 5967
5773 if (!attachment) 5968 if (!attachment)
5774 { 5969 {
@@ -5813,27 +6008,24 @@ BOOL LLVOAvatar::attachObject(LLViewerObject *viewer_object)
5813//----------------------------------------------------------------------------- 6008//-----------------------------------------------------------------------------
5814void LLVOAvatar::lazyAttach() 6009void LLVOAvatar::lazyAttach()
5815{ 6010{
5816 for(LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); 6011 for (U32 i = 0; i < mPendingAttachment.size(); i++)
5817 attachment; 6012 {
5818 attachment = mAttachmentPoints.getNextData()) 6013 if (mPendingAttachment[i]->mDrawable)
5819 { 6014 {
5820 if (attachment->getAttachmentDirty()) 6015 attachObject(mPendingAttachment[i]);
5821 {
5822 attachment->lazyAttach();
5823 if (mIsSelf)
5824 {
5825 updateAttachmentVisibility(gAgent.getCameraMode());
5826 }
5827 }
5828 } 6016 }
6017 }
6018
6019 mPendingAttachment.clear();
5829} 6020}
5830 6021
5831void LLVOAvatar::resetHUDAttachments() 6022void LLVOAvatar::resetHUDAttachments()
5832{ 6023{
5833 for(LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); 6024 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
5834 attachment; 6025 iter != mAttachmentPoints.end(); )
5835 attachment = mAttachmentPoints.getNextData())
5836 { 6026 {
6027 attachment_map_t::iterator curiter = iter++;
6028 LLViewerJointAttachment* attachment = curiter->second;
5837 if (attachment->getIsHUDAttachment()) 6029 if (attachment->getIsHUDAttachment())
5838 { 6030 {
5839 LLViewerObject* obj = attachment->getObject(); 6031 LLViewerObject* obj = attachment->getObject();
@@ -5850,10 +6042,11 @@ void LLVOAvatar::resetHUDAttachments()
5850//----------------------------------------------------------------------------- 6042//-----------------------------------------------------------------------------
5851BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object) 6043BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
5852{ 6044{
5853 for(LLViewerJointAttachment* attachment = mAttachmentPoints.getFirstData(); 6045 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
5854 attachment; 6046 iter != mAttachmentPoints.end(); )
5855 attachment = mAttachmentPoints.getNextData())
5856 { 6047 {
6048 attachment_map_t::iterator curiter = iter++;
6049 LLViewerJointAttachment* attachment = curiter->second;
5857 // only one object per attachment point for now 6050 // only one object per attachment point for now
5858 if (attachment->getObject() == viewer_object) 6051 if (attachment->getObject() == viewer_object)
5859 { 6052 {
@@ -5862,7 +6055,7 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
5862 if (mIsSelf) 6055 if (mIsSelf)
5863 { 6056 {
5864 // the simulator should automatically handle 6057 // the simulator should automatically handle
5865 // permissiosn revokation 6058 // permission revocation
5866 6059
5867 stopMotionFromSource(viewer_object->getID()); 6060 stopMotionFromSource(viewer_object->getID());
5868 LLFollowCamMgr::setCameraActive(viewer_object->getID(), FALSE); 6061 LLFollowCamMgr::setCameraActive(viewer_object->getID(), FALSE);
@@ -5871,7 +6064,7 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
5871 { 6064 {
5872 LLViewerObject* child_objectp = viewer_object->mChildList[i]; 6065 LLViewerObject* child_objectp = viewer_object->mChildList[i];
5873 // the simulator should automatically handle 6066 // the simulator should automatically handle
5874 // permissions revokation 6067 // permissions revocation
5875 6068
5876 stopMotionFromSource(child_objectp->getID()); 6069 stopMotionFromSource(child_objectp->getID());
5877 LLFollowCamMgr::setCameraActive(child_objectp->getID(), FALSE); 6070 LLFollowCamMgr::setCameraActive(child_objectp->getID(), FALSE);
@@ -6025,11 +6218,12 @@ LLVOAvatar* LLVOAvatar::findAvatarFromAttachment( LLViewerObject* obj )
6025//----------------------------------------------------------------------------- 6218//-----------------------------------------------------------------------------
6026BOOL LLVOAvatar::isWearingAttachment( const LLUUID& inv_item_id ) 6219BOOL LLVOAvatar::isWearingAttachment( const LLUUID& inv_item_id )
6027{ 6220{
6028 for (LLViewerJointAttachment *attachment_point = mAttachmentPoints.getFirstData(); 6221 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
6029 attachment_point; 6222 iter != mAttachmentPoints.end(); )
6030 attachment_point = mAttachmentPoints.getNextData())
6031 { 6223 {
6032 if( attachment_point->getItemID() == inv_item_id ) 6224 attachment_map_t::iterator curiter = iter++;
6225 LLViewerJointAttachment* attachment = curiter->second;
6226 if( attachment->getItemID() == inv_item_id )
6033 { 6227 {
6034 return TRUE; 6228 return TRUE;
6035 } 6229 }
@@ -6042,13 +6236,14 @@ BOOL LLVOAvatar::isWearingAttachment( const LLUUID& inv_item_id )
6042//----------------------------------------------------------------------------- 6236//-----------------------------------------------------------------------------
6043LLViewerObject* LLVOAvatar::getWornAttachment( const LLUUID& inv_item_id ) 6237LLViewerObject* LLVOAvatar::getWornAttachment( const LLUUID& inv_item_id )
6044{ 6238{
6045 for (LLViewerJointAttachment *attachment_point = mAttachmentPoints.getFirstData(); 6239 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
6046 attachment_point; 6240 iter != mAttachmentPoints.end(); )
6047 attachment_point = mAttachmentPoints.getNextData())
6048 { 6241 {
6049 if( attachment_point->getItemID() == inv_item_id ) 6242 attachment_map_t::iterator curiter = iter++;
6243 LLViewerJointAttachment* attachment = curiter->second;
6244 if( attachment->getItemID() == inv_item_id )
6050 { 6245 {
6051 return attachment_point->getObject(); 6246 return attachment->getObject();
6052 } 6247 }
6053 } 6248 }
6054 return NULL; 6249 return NULL;
@@ -6056,13 +6251,14 @@ LLViewerObject* LLVOAvatar::getWornAttachment( const LLUUID& inv_item_id )
6056 6251
6057const LLString LLVOAvatar::getAttachedPointName(const LLUUID& inv_item_id) 6252const LLString LLVOAvatar::getAttachedPointName(const LLUUID& inv_item_id)
6058{ 6253{
6059 for (LLViewerJointAttachment *attachment_point = mAttachmentPoints.getFirstData(); 6254 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
6060 attachment_point; 6255 iter != mAttachmentPoints.end(); )
6061 attachment_point = mAttachmentPoints.getNextData())
6062 { 6256 {
6063 if( attachment_point->getItemID() == inv_item_id ) 6257 attachment_map_t::iterator curiter = iter++;
6258 LLViewerJointAttachment* attachment = curiter->second;
6259 if( attachment->getItemID() == inv_item_id )
6064 { 6260 {
6065 return (LLString)attachment_point->getName(); 6261 return (LLString)attachment->getName();
6066 } 6262 }
6067 } 6263 }
6068 6264
@@ -7617,30 +7813,31 @@ void LLVOAvatar::dumpAvatarTEs( const char* context )
7617//----------------------------------------------------------------------------- 7813//-----------------------------------------------------------------------------
7618void LLVOAvatar::updateAttachmentVisibility(U32 camera_mode) 7814void LLVOAvatar::updateAttachmentVisibility(U32 camera_mode)
7619{ 7815{
7620 for (LLViewerJointAttachment *attachmentPoint = mAttachmentPoints.getFirstData(); 7816 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
7621 attachmentPoint; 7817 iter != mAttachmentPoints.end(); )
7622 attachmentPoint = mAttachmentPoints.getNextData())
7623 { 7818 {
7624 if (attachmentPoint->getIsHUDAttachment()) 7819 attachment_map_t::iterator curiter = iter++;
7820 LLViewerJointAttachment* attachment = curiter->second;
7821 if (attachment->getIsHUDAttachment())
7625 { 7822 {
7626 attachmentPoint->setAttachmentVisibility(TRUE); 7823 attachment->setAttachmentVisibility(TRUE);
7627 } 7824 }
7628 else 7825 else
7629 { 7826 {
7630 switch (camera_mode) 7827 switch (camera_mode)
7631 { 7828 {
7632 case CAMERA_MODE_MOUSELOOK: 7829 case CAMERA_MODE_MOUSELOOK:
7633 if (LLVOAvatar::sVisibleInFirstPerson && attachmentPoint->getVisibleInFirstPerson()) 7830 if (LLVOAvatar::sVisibleInFirstPerson && attachment->getVisibleInFirstPerson())
7634 { 7831 {
7635 attachmentPoint->setAttachmentVisibility(TRUE); 7832 attachment->setAttachmentVisibility(TRUE);
7636 } 7833 }
7637 else 7834 else
7638 { 7835 {
7639 attachmentPoint->setAttachmentVisibility(FALSE); 7836 attachment->setAttachmentVisibility(FALSE);
7640 } 7837 }
7641 break; 7838 break;
7642 default: 7839 default:
7643 attachmentPoint->setAttachmentVisibility(TRUE); 7840 attachment->setAttachmentVisibility(TRUE);
7644 break; 7841 break;
7645 } 7842 }
7646 } 7843 }
@@ -7789,39 +7986,45 @@ BOOL LLVOAvatar::isWearingWearableType( EWearableType type )
7789//----------------------------------------------------------------------------- 7986//-----------------------------------------------------------------------------
7790void LLVOAvatar::clampAttachmentPositions() 7987void LLVOAvatar::clampAttachmentPositions()
7791{ 7988{
7792 if (isDead()) return; 7989 if (isDead())
7793 for(LLViewerJointAttachment *attachment = mAttachmentPoints.getFirstData(); 7990 {
7794 attachment; 7991 return;
7795 attachment = mAttachmentPoints.getNextData()) 7992 }
7993 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
7994 iter != mAttachmentPoints.end(); )
7995 {
7996 attachment_map_t::iterator curiter = iter++;
7997 LLViewerJointAttachment* attachment = curiter->second;
7998 if (attachment)
7796 { 7999 {
7797 if (attachment) 8000 attachment->clampObjectPosition();
7798 {
7799 attachment->clampObjectPosition();
7800 }
7801 } 8001 }
8002 }
7802} 8003}
7803 8004
7804BOOL LLVOAvatar::hasHUDAttachment() 8005BOOL LLVOAvatar::hasHUDAttachment()
7805{ 8006{
7806 for(LLViewerJointAttachment *attachment = mAttachmentPoints.getFirstData(); 8007 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
7807 attachment; 8008 iter != mAttachmentPoints.end(); )
7808 attachment = mAttachmentPoints.getNextData()) 8009 {
8010 attachment_map_t::iterator curiter = iter++;
8011 LLViewerJointAttachment* attachment = curiter->second;
8012 if (attachment->getIsHUDAttachment() && attachment->getObject())
7809 { 8013 {
7810 if (attachment->getIsHUDAttachment() && attachment->getObject()) 8014 return TRUE;
7811 {
7812 return TRUE;
7813 }
7814 } 8015 }
8016 }
7815 return FALSE; 8017 return FALSE;
7816} 8018}
7817 8019
7818LLBBox LLVOAvatar::getHUDBBox() 8020LLBBox LLVOAvatar::getHUDBBox()
7819{ 8021{
7820 LLBBox bbox; 8022 LLBBox bbox;
7821 for(LLViewerJointAttachment *attachment = mAttachmentPoints.getFirstData(); 8023 for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
7822 attachment; 8024 iter != mAttachmentPoints.end(); )
7823 attachment = mAttachmentPoints.getNextData())
7824 { 8025 {
8026 attachment_map_t::iterator curiter = iter++;
8027 LLViewerJointAttachment* attachment = curiter->second;
7825 if (attachment->getIsHUDAttachment() && attachment->getObject()) 8028 if (attachment->getIsHUDAttachment() && attachment->getObject())
7826 { 8029 {
7827 LLViewerObject* hud_object = attachment->getObject(); 8030 LLViewerObject* hud_object = attachment->getObject();
@@ -9130,255 +9333,10 @@ BOOL LLVOAvatarInfo::parseXmlDriverNodes(LLXmlTreeNode* root)
9130 return TRUE; 9333 return TRUE;
9131} 9334}
9132 9335
9133void LLVOAvatar::writeCAL3D(std::string& path, std::string& file_base)
9134{
9135 char filename[MAX_PATH]; /* Flawfinder: ignore */
9136
9137 // reset animated morphs
9138 setVisualParamWeight("Blink_Left", 0.f);
9139 setVisualParamWeight("Blink_Right", 0.f);
9140 setVisualParamWeight("Hands_Relaxed", 1.f);
9141 setVisualParamWeight("Hands_Point", 0.f);
9142 setVisualParamWeight("Hands_Fist", 0.f);
9143 setVisualParamWeight("Hands_Relaxed_L", 0.f);
9144 setVisualParamWeight("Hands_Point_L", 0.f);
9145 setVisualParamWeight("Hands_Fist_L", 0.f);
9146 setVisualParamWeight("Hands_Relaxed_R", 0.f);
9147 setVisualParamWeight("Hands_Point_R", 0.f);
9148 setVisualParamWeight("Hands_Fist_R", 0.f);
9149 setVisualParamWeight("Hands_Salute_R", 0.f);
9150 setVisualParamWeight("Hands_Typing", 0.f);
9151 setVisualParamWeight("Hands_Peace_R", 0.f);
9152 setVisualParamWeight("Hands_Spread_R", 0.f);
9153 updateVisualParams();
9154
9155 snprintf(filename, MAX_PATH, "%s\\%s_skeleton.xsf", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */
9156 apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W);
9157 if (!fp)
9158 {
9159 llwarns << "Unable to write avatar file " << filename << llendl;
9160 return;
9161 }
9162 apr_file_printf(fp, "<SKELETON VERSION=\"1000\" NUMBONES=\"%d\">\n", sSkeletonInfo->getNumBones() - sSkeletonInfo->getNumCollisionVolumes());
9163 mRoot.writeCAL3D(fp);
9164 apr_file_printf(fp, "</SKELETON>\n");
9165 apr_file_close(fp);
9166
9167 snprintf(filename, MAX_PATH, "%s\\%s_mesh_body.xmf", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */
9168 //gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"avatar.cal").c_str()
9169 fp = ll_apr_file_open(filename, LL_APR_W);
9170 if (!fp)
9171 {
9172 llwarns << "Unable to write avatar file " << filename << llendl;
9173 return;
9174 }
9175
9176 BOOL has_skirt = isWearingWearableType(WT_SKIRT);
9177
9178 apr_file_printf(fp, "<MESH VERSION=\"1000\" NUMSUBMESH=\"%d\">\n", has_skirt ? 8 : 7);
9179 mHairMesh0.writeCAL3D(fp, 5, this);
9180 mHeadMesh0.writeCAL3D(fp, 0, this);
9181 mEyeLashMesh0.writeCAL3D(fp, 0, this);
9182 mUpperBodyMesh0.writeCAL3D(fp, 1, this);
9183 mLowerBodyMesh0.writeCAL3D(fp, 2, this);
9184 mEyeBallLeftMesh0.writeCAL3D(fp, 3, this);
9185 mEyeBallRightMesh0.writeCAL3D(fp, 3, this);
9186 if (has_skirt)
9187 {
9188 mSkirtMesh0.writeCAL3D(fp, 4, this);
9189 }
9190 apr_file_printf(fp, "</MESH>\n");
9191 apr_file_close(fp);
9192
9193 // write out material files
9194 LLPointer<LLImageTGA> tga_image = new LLImageTGA;
9195
9196 for (S32 i = 0; i < (has_skirt ? BAKED_TEXTURE_COUNT : BAKED_TEXTURE_COUNT - 1); i++)
9197 {
9198 snprintf(filename, MAX_PATH, "%s\\%s_material_tex_%d.tga", path.c_str(), file_base.c_str(), i); /* Flawfinder: ignore */
9199
9200 LLViewerImage* viewer_imagep = mTEImages[sBakedTextureIndices[i]];
9201 if (!viewer_imagep->getHasGLTexture())
9202 {
9203 llinfos << "No image data available for " << filename << llendl;
9204 continue;
9205 }
9206 LLPointer<LLImageRaw> raw_image = new LLImageRaw;
9207 viewer_imagep->readBackRaw(-1, raw_image, false);
9208 BOOL success = tga_image->encode(raw_image);
9209 success = tga_image->save(filename);
9210 }
9211
9212 // output image for hair
9213 snprintf(filename, MAX_PATH, "%s\\%s_material_tex_5.tga", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */
9214 LLViewerImage* viewer_imagep = mTEImages[TEX_HAIR];
9215 if (!viewer_imagep->getHasGLTexture())
9216 {
9217 llinfos << "No image data available for " << filename << llendl;
9218 }
9219 else
9220 {
9221 LLPointer<LLImageRaw> raw_image = new LLImageRaw;
9222 viewer_imagep->readBackRaw(-1, raw_image, false);
9223 BOOL success = tga_image->encode(raw_image);
9224 success = tga_image->save(filename);
9225 }
9226
9227 // save out attachments
9228 snprintf(filename, MAX_PATH, "%s\\%s_mesh_attachments.xmf", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */
9229 fp = ll_apr_file_open(filename, LL_APR_W);
9230 if (!fp)
9231 {
9232 llwarns << "Unable to write attachments file " << filename << llendl;
9233 return;
9234 }
9235
9236 typedef std::multimap<LLUUID, LLMaterialExportInfo*>::iterator material_it_t;
9237 std::multimap<LLUUID, LLMaterialExportInfo*> material_map;
9238
9239 S32 num_attachment_objects = 0;
9240 for(LLViewerJointAttachment *attachment = mAttachmentPoints.getFirstData();
9241 attachment;
9242 attachment = mAttachmentPoints.getNextData())
9243 {
9244 LLViewerObject *attached_object = attachment->getObject();
9245 if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull() &&
9246 attached_object->getPCode() == LL_PCODE_VOLUME)
9247 {
9248 num_attachment_objects += attached_object->mDrawable->getNumFaces();
9249 for (U32 i = 0; i < attached_object->mChildList.size(); i++)
9250 {
9251 LLViewerObject* child_object = attached_object->mChildList[i];
9252 num_attachment_objects += child_object->mDrawable->getNumFaces();
9253 }
9254 }
9255 }
9256
9257 apr_file_printf(fp, "<MESH VERSION=\"1000\" NUMSUBMESH=\"%d\">\n", num_attachment_objects);
9258
9259 S32 material_index = 6;
9260 S32 texture_index = 6;
9261 for(LLViewerJointAttachment *attachment = mAttachmentPoints.getFirstData();
9262 attachment;
9263 attachment = mAttachmentPoints.getNextData())
9264 {
9265 LLViewerObject *attached_object = attachment->getObject();
9266 if (attached_object && !attached_object->isDead() && attached_object->getPCode() == LL_PCODE_VOLUME)
9267 {
9268 LLVOVolume* attached_volume = (LLVOVolume*)attached_object;
9269 LLVector3 pos = attachment->getPosition();
9270 LLJoint* cur_joint = attachment->getParent();
9271 while (cur_joint)
9272 {
9273 pos += cur_joint->getSkinOffset();
9274 cur_joint = (LLViewerJoint*)cur_joint->getParent();
9275 }
9276 pos *= 100.f;
9277 S32 attached_joint_num = attachment->getParent()->mJointNum;
9278 LLQuaternion rot = attachment->getRotation();
9279 attached_volume->writeCAL3D(fp, path, file_base, attached_joint_num, pos, rot, material_index, texture_index, material_map);
9280 }
9281 }
9282 apr_file_printf(fp, "</MESH>\n");
9283 apr_file_close(fp);
9284
9285 // now dump sample animation
9286 LLKeyframeMotion* walk_motion =
9287 getSex() == SEX_MALE ? (LLKeyframeMotion*)findMotion(ANIM_AGENT_WALK) : (LLKeyframeMotion*)findMotion(ANIM_AGENT_FEMALE_WALK);
9288 if (FALSE)//(walk_motion)
9289 {
9290 snprintf(filename, MAX_PATH, "%s\\%s_anim.xaf", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */
9291 apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W);
9292 if (!fp)
9293 {
9294 llwarns << "Unable to write avatar animation file " << filename << llendl;
9295 return;
9296 }
9297
9298 walk_motion->writeCAL3D(fp);
9299
9300 apr_file_close(fp);
9301 }
9302
9303 // finally, write out .cfg file
9304 snprintf(filename, MAX_PATH, "%s\\%s_avatar.cfg", path.c_str(), file_base.c_str()); /* Flawfinder: ignore */
9305 fp = ll_apr_file_open(filename, LL_APR_W);
9306 if (!fp)
9307 {
9308 llwarns << "Unable to write avatar config file " << filename << llendl;
9309 return;
9310 }
9311
9312 // this version exports animation
9313 //apr_file_printf(fp, "#\n# cal3d model configuration file\n#\n# model: %s_avatar\n#\n\nscale=1.0\n\nskeleton=%s_skeleton.xsf\n\nanimation=%s_anim.xaf\n\n", file_base.c_str(), file_base.c_str(), file_base.c_str());
9314 apr_file_printf(fp, "#\n# cal3d model configuration file\n#\n# model: %s_avatar\n#\n\nscale=1.0\n\nskeleton=%s_skeleton.xsf\n\n", file_base.c_str(), file_base.c_str());
9315 apr_file_printf(fp, "mesh=%s_mesh_body.xmf\nmesh=%s_mesh_attachments.xmf\n", file_base.c_str(), file_base.c_str());
9316
9317 for (S32 i = 0; i < material_index; i++)
9318 {
9319 apr_file_printf(fp, "material=%s_material_%d.xrf\n", file_base.c_str(), i);
9320 }
9321 apr_file_close(fp);
9322
9323 for(S32 i = 0; i < 6; i++)
9324 {
9325 snprintf(filename, MAX_PATH, "%s\\%s_material_%d.xrf", path.c_str(), file_base.c_str(), i); /* Flawfinder: ignore */
9326 apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W);
9327 if (!fp)
9328 {
9329 llwarns << "Unable to write material definition file " << filename << llendl;
9330 return;
9331 }
9332
9333 // for hair material, use hair color...otherwise use white for entire body
9334 LLColor4U material_color = (i == 5) ? mTexHairColor->getColor() : LLColor4U::white;
9335
9336 apr_file_printf(fp, "<HEADER MAGIC=\"XRF\" VERSION=\"900\" />\n<MATERIAL NUMMAPS=\"1\">\n");
9337 apr_file_printf(fp, " <AMBIENT>%d %d %d %d</AMBIENT>\n", material_color.mV[VX], material_color.mV[VY], material_color.mV[VZ], material_color.mV[VW]);
9338 apr_file_printf(fp, " <DIFFUSE>%d %d %d %d</DIFFUSE>\n", material_color.mV[VX], material_color.mV[VY], material_color.mV[VZ], material_color.mV[VW]);
9339 apr_file_printf(fp, " <SPECULAR>0 0 0 0</SPECULAR>\n");
9340 apr_file_printf(fp, " <SHININESS>1.0</SHININESS>\n");
9341 apr_file_printf(fp, " <MAP>%s_material_tex_%d.tga</MAP>\n", file_base.c_str(), i);
9342 apr_file_printf(fp, "</MATERIAL>\n");
9343
9344 apr_file_close(fp);
9345 }
9346
9347 // write out material files
9348 for(material_it_t material_it = material_map.begin(); material_it != material_map.end(); ++material_it)
9349 {
9350 LLMaterialExportInfo* export_info = material_it->second;
9351
9352 snprintf(filename, MAX_PATH, "%s\\%s_material_%d.xrf", path.c_str(), file_base.c_str(), export_info->mMaterialIndex); /* Flawfinder: ignore */
9353 apr_file_t* fp = ll_apr_file_open(filename, LL_APR_W);
9354 if (!fp)
9355 {
9356 llwarns << "Unable to write material definition file " << filename << llendl;
9357 return;
9358 }
9359
9360 LLColor4U material_color = export_info->mColor;
9361
9362 apr_file_printf(fp, "<HEADER MAGIC=\"XRF\" VERSION=\"900\" />\n<MATERIAL NUMMAPS=\"1\">\n");
9363 apr_file_printf(fp, " <AMBIENT>%d %d %d %d</AMBIENT>\n", material_color.mV[VX], material_color.mV[VY], material_color.mV[VZ], material_color.mV[VW]);
9364 apr_file_printf(fp, " <DIFFUSE>%d %d %d %d</DIFFUSE>\n", material_color.mV[VX], material_color.mV[VY], material_color.mV[VZ], material_color.mV[VW]);
9365 apr_file_printf(fp, " <SPECULAR>0 0 0 0</SPECULAR>\n");
9366 apr_file_printf(fp, " <SHININESS>1.0</SHININESS>\n");
9367 apr_file_printf(fp, " <MAP>%s_material_tex_%d.tga</MAP>\n", file_base.c_str(), export_info->mTextureIndex);
9368 apr_file_printf(fp, "</MATERIAL>\n");
9369
9370 apr_file_close(fp);
9371 }
9372
9373
9374 std::for_each(material_map.begin(), material_map.end(), DeletePairedPointer());
9375 material_map.clear();
9376}
9377
9378// warning: order(N) not order(1) 9336// warning: order(N) not order(1)
9379S32 LLVOAvatar::getAttachmentCount() 9337S32 LLVOAvatar::getAttachmentCount()
9380{ 9338{
9381 S32 count = mAttachmentPoints.getLength(); 9339 S32 count = mAttachmentPoints.size();
9382 return count; 9340 return count;
9383} 9341}
9384 9342
@@ -9492,40 +9450,75 @@ BOOL LLVOAvatar::updateLOD()
9492 { //LOD changed or new mesh created, allocate new vertex buffer if needed 9450 { //LOD changed or new mesh created, allocate new vertex buffer if needed
9493 updateMeshData(); 9451 updateMeshData();
9494 mDirtyMesh = FALSE; 9452 mDirtyMesh = FALSE;
9453 mNeedsSkin = TRUE;
9495 mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY); 9454 mDrawable->clearState(LLDrawable::REBUILD_GEOMETRY);
9496 } 9455 }
9497 9456
9498 if (facep->getPool()->getVertexShaderLevel() <= 0)
9499 {
9500 //generate animated mesh
9501 mLowerBodyLOD.updateGeometry();
9502 mUpperBodyLOD.updateGeometry();
9503 9457
9504 if( isWearingWearableType( WT_SKIRT ) ) 9458 return res;
9505 { 9459}
9506 mSkirtLOD.updateGeometry();
9507 }
9508 9460
9509 if (!mIsSelf || gAgent.needsRenderHead()) 9461U32 LLVOAvatar::getPartitionType() const
9462{ //avatars merely exist as drawables in the bridge partition
9463 return LLViewerRegion::PARTITION_BRIDGE;
9464}
9465
9466//static
9467void LLVOAvatar::updateImpostors()
9468{
9469 for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
9470 iter != LLCharacter::sInstances.end(); ++iter)
9471 {
9472 LLVOAvatar* avatar = (LLVOAvatar*) *iter;
9473
9474 if (!avatar->isDead() && avatar->needsImpostorUpdate() && avatar->isVisible() && avatar->isImpostor())
9510 { 9475 {
9511 mEyeLashLOD.updateGeometry(); 9476 gPipeline.generateImpostor(avatar);
9512 mHeadLOD.updateGeometry();
9513 mHairLOD.updateGeometry();
9514 } 9477 }
9515 } 9478 }
9479}
9516 9480
9517 // Update the shadow, tractor, and text label geometry. 9481BOOL LLVOAvatar::isImpostor() const
9518 if (mDrawable->isState(LLDrawable::REBUILD_SHADOW)) 9482{
9519 { 9483 return (sUseImpostors && mUpdatePeriod >= VOAVATAR_IMPOSTOR_PERIOD) ? TRUE : FALSE;
9520 updateShadowFaces(); 9484}
9521 mDrawable->clearState(LLDrawable::REBUILD_SHADOW);
9522 }
9523 9485
9524 return res; 9486
9487BOOL LLVOAvatar::needsImpostorUpdate() const
9488{
9489 return mNeedsImpostorUpdate;
9525} 9490}
9526 9491
9527U32 LLVOAvatar::getPartitionType() const 9492const LLVector3& LLVOAvatar::getImpostorOffset() const
9528{ //avatars merely exist as drawables in the bridge partition 9493{
9529 return LLPipeline::PARTITION_BRIDGE; 9494 return mImpostorOffset;
9495}
9496
9497const LLVector2& LLVOAvatar::getImpostorDim() const
9498{
9499 return mImpostorDim;
9500}
9501
9502void LLVOAvatar::setImpostorDim(const LLVector2& dim)
9503{
9504 mImpostorDim = dim;
9505}
9506
9507void LLVOAvatar::cacheImpostorValues()
9508{
9509 getImpostorValues(mImpostorExtents, mImpostorAngle, mImpostorDistance);
9510}
9511
9512void LLVOAvatar::getImpostorValues(LLVector3* extents, LLVector3& angle, F32& distance)
9513{
9514 const LLVector3* ext = mDrawable->getSpatialExtents();
9515 extents[0] = ext[0];
9516 extents[1] = ext[1];
9517
9518 LLVector3 at = gCamera->getOrigin()-(getRenderPosition()+mImpostorOffset);
9519 distance = at.normVec();
9520 angle.mV[0] = acosf(at.mV[0]);
9521 angle.mV[1] = acosf(at.mV[1]);
9522 angle.mV[2] = acosf(at.mV[2]);
9530} 9523}
9531 9524