summaryrefslogtreecommitdiff
path: root/indra/newview/llvoavatar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rw-r--r--indra/newview/llvoavatar.cpp277
1 files changed, 224 insertions, 53 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 7ae1f672e8..7e9a6f64f2 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -63,6 +63,7 @@
#include "llkeyframefallmotion.h"
#include "llkeyframestandmotion.h"
#include "llkeyframewalkmotion.h"
+#include "llmeshrepository.h"
#include "llmutelist.h"
#include "llmoveview.h"
#include "llnotificationsutil.h"
@@ -80,6 +81,7 @@
#include "llviewermenu.h"
#include "llviewerobjectlist.h"
#include "llviewerparcelmgr.h"
+#include "llviewershadermgr.h"
#include "llviewerstats.h"
#include "llvoavatarself.h"
#include "llvovolume.h"
@@ -674,12 +676,14 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
mTexHairColor( NULL ),
mTexEyeColor( NULL ),
mNeedsSkin(FALSE),
+ mLastSkinTime(0.f),
mUpdatePeriod(1),
mFullyLoaded(FALSE),
mPreviousFullyLoaded(FALSE),
mFullyLoadedInitialized(FALSE),
mSupportsAlphaLayers(FALSE),
- mLoadedCallbacksPaused(FALSE)
+ mLoadedCallbacksPaused(FALSE),
+ mHasPelvisOffset( FALSE )
{
LLMemType mt(LLMemType::MTYPE_AVATAR);
//VTResume(); // VTune
@@ -754,6 +758,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
mRuthTimer.reset();
mRuthDebugTimer.reset();
mDebugExistenceTimer.reset();
+ mPelvisOffset = LLVector3(0.0f,0.0f,0.0f);
}
//------------------------------------------------------------------------
@@ -1338,41 +1343,46 @@ void LLVOAvatar::updateDrawable(BOOL force_damped)
clearChanged(SHIFTED);
}
-void LLVOAvatar::onShift(const LLVector3& shift_vector)
+void LLVOAvatar::onShift(const LLVector4a& shift_vector)
{
- mLastAnimExtents[0] += shift_vector;
- mLastAnimExtents[1] += shift_vector;
+ const LLVector3& shift = reinterpret_cast<const LLVector3&>(shift_vector);
+ mLastAnimExtents[0] += shift;
+ mLastAnimExtents[1] += shift;
mNeedsImpostorUpdate = TRUE;
mNeedsAnimUpdate = TRUE;
}
-void LLVOAvatar::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax)
+void LLVOAvatar::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax)
{
if (isImpostor() && !needsImpostorUpdate())
{
LLVector3 delta = getRenderPosition() -
- ((LLVector3(mDrawable->getPositionGroup())-mImpostorOffset));
+ ((LLVector3(mDrawable->getPositionGroup().getF32ptr())-mImpostorOffset));
- newMin = mLastAnimExtents[0] + delta;
- newMax = mLastAnimExtents[1] + delta;
+ newMin.load3( (mLastAnimExtents[0] + delta).mV);
+ newMax.load3( (mLastAnimExtents[1] + delta).mV);
}
else
{
getSpatialExtents(newMin,newMax);
- mLastAnimExtents[0] = newMin;
- mLastAnimExtents[1] = newMax;
- LLVector3 pos_group = (newMin+newMax)*0.5f;
- mImpostorOffset = pos_group-getRenderPosition();
+ mLastAnimExtents[0].set(newMin.getF32ptr());
+ mLastAnimExtents[1].set(newMax.getF32ptr());
+ LLVector4a pos_group;
+ pos_group.setAdd(newMin,newMax);
+ pos_group.mul(0.5f);
+ mImpostorOffset = LLVector3(pos_group.getF32ptr())-getRenderPosition();
mDrawable->setPositionGroup(pos_group);
}
}
-void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
+void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
{
- LLVector3 buffer(0.25f, 0.25f, 0.25f);
- LLVector3 pos = getRenderPosition();
- newMin = pos - buffer;
- newMax = pos + buffer;
+ LLVector4a buffer(0.25f);
+ LLVector4a pos;
+ pos.load3(getRenderPosition().mV);
+ newMin.setSub(pos, buffer);
+ newMax.setAdd(pos, buffer);
+
float max_attachment_span = DEFAULT_MAX_PRIM_SCALE * 5.0f;
//stretch bounding box by joint positions
@@ -1381,12 +1391,20 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
LLPolyMesh* mesh = i->second;
for (S32 joint_num = 0; joint_num < mesh->mJointRenderData.count(); joint_num++)
{
- update_min_max(newMin, newMax,
- mesh->mJointRenderData[joint_num]->mWorldMatrix->getTranslation());
+ LLVector4a trans;
+ trans.load3( mesh->mJointRenderData[joint_num]->mWorldMatrix->getTranslation().mV);
+ update_min_max(newMin, newMax, trans);
}
}
- mPixelArea = LLPipeline::calcPixelArea((newMin+newMax)*0.5f, (newMax-newMin)*0.5f, *LLViewerCamera::getInstance());
+ LLVector4a center, size;
+ center.setAdd(newMin, newMax);
+ center.mul(0.5f);
+
+ size.setSub(newMax,newMin);
+ size.mul(0.5f);
+
+ mPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance());
//stretch bounding box by attachments
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
@@ -1413,15 +1431,17 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
LLSpatialBridge* bridge = drawable->getSpatialBridge();
if (bridge)
{
- const LLVector3* ext = bridge->getSpatialExtents();
- LLVector3 distance = (ext[1] - ext[0]);
+ const LLVector4a* ext = bridge->getSpatialExtents();
+ LLVector4a distance;
+ distance.setSub(ext[1], ext[0]);
+ LLVector4a max_span(max_attachment_span);
+
+ S32 lt = distance.lessThan(max_span).getGatheredBits() & 0x7;
// Only add the prim to spatial extents calculations if it isn't a megaprim.
// max_attachment_span calculated at the start of the function
// (currently 5 times our max prim size)
- if (distance.mV[0] < max_attachment_span
- && distance.mV[1] < max_attachment_span
- && distance.mV[2] < max_attachment_span)
+ if (lt == 0x7)
{
update_min_max(newMin,newMax,ext[0]);
update_min_max(newMin,newMax,ext[1]);
@@ -1433,8 +1453,9 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax)
}
//pad bounding box
- newMin -= buffer;
- newMax += buffer;
+
+ newMin.sub(buffer);
+ newMax.add(buffer);
}
//-----------------------------------------------------------------------------
@@ -1609,7 +1630,8 @@ BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent
info->mRot.mV[VZ], LLQuaternion::XYZ));
joint->setScale(info->mScale);
-
+ joint->setDefaultFromCurrentXform();
+
if (info->mIsJoint)
{
joint->setSkinOffset( info->mPivot );
@@ -2479,7 +2501,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
if (isImpostor() && !mNeedsImpostorUpdate)
{
- LLVector3 ext[2];
+ LLVector4a ext[2];
F32 distance;
LLVector3 angle;
@@ -2508,12 +2530,22 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
}
else
{
+ //VECTORIZE THIS
getSpatialExtents(ext[0], ext[1]);
- if ((ext[1]-mImpostorExtents[1]).length() > 0.05f ||
- (ext[0]-mImpostorExtents[0]).length() > 0.05f)
+ LLVector4a diff;
+ diff.setSub(ext[1], mImpostorExtents[1]);
+ if (diff.getLength3().getF32() > 0.05f)
{
mNeedsImpostorUpdate = TRUE;
}
+ else
+ {
+ diff.setSub(ext[0], mImpostorExtents[0]);
+ if (diff.getLength3().getF32() > 0.05f)
+ {
+ mNeedsImpostorUpdate = TRUE;
+ }
+ }
}
}
}
@@ -3415,8 +3447,15 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
LLVector3d ground_under_pelvis;
if (isSelf())
- {
- gAgent.setPositionAgent(getRenderPosition());
+ {
+ if ( !mHasPelvisOffset )
+ {
+ gAgent.setPositionAgent(getRenderPosition());
+ }
+ else
+ {
+ gAgent.setPositionAgent( getRenderPosition() + mPelvisOffset );
+ }
}
root_pos = gAgent.getPosGlobalFromAgent(getRenderPosition());
@@ -3433,16 +3472,23 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
mInAir = in_air;
// correct for the fact that the pelvis is not necessarily the center
- // of the agent's physical representation
+ // of the agent's physical representation
root_pos.mdV[VZ] -= (0.5f * mBodySize.mV[VZ]) - mPelvisToFoot;
-
LLVector3 newPosition = gAgent.getPosAgentFromGlobal(root_pos);
if (newPosition != mRoot.getXform()->getWorldPosition())
{
- mRoot.touch();
- mRoot.setWorldPosition(newPosition ); // regular update
+ if ( !mHasPelvisOffset )
+ {
+ mRoot.touch();
+ mRoot.setWorldPosition( newPosition ); // regular update
+ }
+ else
+ {
+ mRoot.touch();
+ mRoot.setWorldPosition( newPosition + mPelvisOffset );
+ }
}
@@ -3743,7 +3789,27 @@ void LLVOAvatar::updateHeadOffset()
mHeadOffset = lerp(midEyePt, mHeadOffset, u);
}
}
-
+//------------------------------------------------------------------------
+// setPelvisOffset
+//------------------------------------------------------------------------
+void LLVOAvatar::setPelvisOffset( bool hasOffset, const LLVector3& offsetAmount )
+{
+ mHasPelvisOffset = hasOffset;
+ if ( mHasPelvisOffset )
+ {
+ mPelvisOffset = offsetAmount;
+ }
+}
+//------------------------------------------------------------------------
+// postPelvisSetRecalc
+//------------------------------------------------------------------------
+void LLVOAvatar::postPelvisSetRecalc( void )
+{
+ computeBodySize();
+ mRoot.updateWorldMatrixChildren();
+ dirtyMesh();
+ updateHeadOffset();
+}
//------------------------------------------------------------------------
// updateVisibility()
//------------------------------------------------------------------------
@@ -3893,6 +3959,46 @@ bool LLVOAvatar::shouldAlphaMask()
}
+U32 LLVOAvatar::renderSkinnedAttachments()
+{
+ /*U32 num_indices = 0;
+
+ const U32 data_mask = LLVertexBuffer::MAP_VERTEX |
+ LLVertexBuffer::MAP_NORMAL |
+ LLVertexBuffer::MAP_TEXCOORD0 |
+ LLVertexBuffer::MAP_COLOR |
+ LLVertexBuffer::MAP_WEIGHT4;
+
+ for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
+ iter != mAttachmentPoints.end();
+ ++iter)
+ {
+ LLViewerJointAttachment* attachment = iter->second;
+ for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
+ attachment_iter != attachment->mAttachedObjects.end();
+ ++attachment_iter)
+ {
+ const LLViewerObject* attached_object = (*attachment_iter);
+ if (attached_object && !attached_object->isHUDAttachment())
+ {
+ const LLDrawable* drawable = attached_object->mDrawable;
+ if (drawable)
+ {
+ for (S32 i = 0; i < drawable->getNumFaces(); ++i)
+ {
+ LLFace* face = drawable->getFace(i);
+ if (face->isState(LLFace::RIGGED))
+ {
+
+ }
+ }
+ }
+ }
+
+ return num_indices;*/
+ return 0;
+}
+
//-----------------------------------------------------------------------------
// renderSkinned()
//-----------------------------------------------------------------------------
@@ -3940,7 +4046,8 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
mMeshLOD[MESH_ID_HAIR]->updateJointGeometry();
}
mNeedsSkin = FALSE;
-
+ mLastSkinTime = gFrameTimeSeconds;
+
LLVertexBuffer* vb = mDrawable->getFace(0)->mVertexBuffer;
if (vb)
{
@@ -4288,7 +4395,7 @@ void LLVOAvatar::updateTextures()
if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
{
- setDebugText(llformat("%4.0f:%4.0f", fsqrtf(mMinPixelArea),fsqrtf(mMaxPixelArea)));
+ setDebugText(llformat("%4.0f:%4.0f", (F32) sqrt(mMinPixelArea),(F32) sqrt(mMaxPixelArea)));
}
}
@@ -4832,6 +4939,52 @@ LLJoint *LLVOAvatar::getJoint( const std::string &name )
}
//-----------------------------------------------------------------------------
+// resetJointPositions
+//-----------------------------------------------------------------------------
+void LLVOAvatar::resetJointPositions( void )
+{
+ for(S32 i = 0; i < (S32)mNumJoints; ++i)
+ {
+ mSkeleton[i].restoreOldXform();
+ }
+ mHasPelvisOffset = false;
+}
+//-----------------------------------------------------------------------------
+// resetJointPositionsToDefault
+//-----------------------------------------------------------------------------
+void LLVOAvatar::resetJointPositionsToDefault( void )
+{
+ const LLVector3& avPos = getCharacterPosition();
+
+ //Reposition the pelvis
+ LLJoint* pPelvis = mRoot.findJoint("mPelvis");
+ if ( pPelvis )
+ {
+ pPelvis->setPosition( avPos + pPelvis->getPosition() );
+ }
+ else
+ {
+ llwarns<<"Can't get pelvis joint."<<llendl;
+ return;
+ }
+
+ //Subsequent joints are relative to pelvis
+ for( S32 i = 0; i < (S32)mNumJoints; ++i )
+ {
+ LLJoint* pJoint = (LLJoint*)&mSkeleton[i];
+ //restore joints to default positions, however skip over the pelvis
+ if ( pJoint && pPelvis != pJoint )
+ {
+ pJoint->restoreToDefaultXform();
+ }
+ }
+ //make sure we don't apply the joint offset
+ mHasPelvisOffset = false;
+ postPelvisSetRecalc();
+}
+
+
+//-----------------------------------------------------------------------------
// getCharacterPosition()
//-----------------------------------------------------------------------------
LLVector3 LLVOAvatar::getCharacterPosition()
@@ -5493,9 +5646,13 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent)
return;
}
- const LLVector3* ext = mDrawable->getSpatialExtents();
- LLVector3 center = (ext[1] + ext[0]) * 0.5f;
- LLVector3 size = (ext[1]-ext[0])*0.5f;
+ const LLVector4a* ext = mDrawable->getSpatialExtents();
+ LLVector4a center;
+ center.setAdd(ext[1], ext[0]);
+ center.mul(0.5f);
+ LLVector4a size;
+ size.setSub(ext[1], ext[0]);
+ size.mul(0.5f);
mImpostorPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance());
@@ -5507,7 +5664,7 @@ void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent)
}
else
{
- F32 radius = size.length();
+ F32 radius = size.getLength3().getF32();
mAppAngle = (F32) atan2( radius, range) * RAD_TO_DEG;
}
@@ -5704,8 +5861,7 @@ LLViewerJointAttachment* LLVOAvatar::getTargetAttachmentPoint(LLViewerObject* vi
// correctly, but putting this check in here to be safe.
if (attachmentID & ATTACHMENT_ADD)
{
- llwarns << "Got an attachment with ATTACHMENT_ADD mask, removing ( attach pt:" << attachmentID << " )" << llendl;
- attachmentID &= ~ATTACHMENT_ADD;
+ llwarns << "Got an attachment with ATTACHMENT_ADD mask, removing ( attach pt:" << attachmentID << " )" << llendl; attachmentID &= ~ATTACHMENT_ADD;
}
LLViewerJointAttachment* attachment = get_if_there(mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL);
@@ -5836,6 +5992,14 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
return TRUE;
}
}
+
+ std::vector<LLPointer<LLViewerObject> >::iterator iter = std::find(mPendingAttachment.begin(), mPendingAttachment.end(), viewer_object);
+ if (iter != mPendingAttachment.end())
+ {
+ mPendingAttachment.erase(iter);
+ return TRUE;
+ }
+
return FALSE;
}
@@ -7990,9 +8154,9 @@ void LLVOAvatar::cacheImpostorValues()
getImpostorValues(mImpostorExtents, mImpostorAngle, mImpostorDistance);
}
-void LLVOAvatar::getImpostorValues(LLVector3* extents, LLVector3& angle, F32& distance) const
+void LLVOAvatar::getImpostorValues(LLVector4a* extents, LLVector3& angle, F32& distance) const
{
- const LLVector3* ext = mDrawable->getSpatialExtents();
+ const LLVector4a* ext = mDrawable->getSpatialExtents();
extents[0] = ext[0];
extents[1] = ext[1];
@@ -8006,7 +8170,7 @@ void LLVOAvatar::getImpostorValues(LLVector3* extents, LLVector3& angle, F32& di
void LLVOAvatar::idleUpdateRenderCost()
{
- static const U32 ARC_BODY_PART_COST = 20;
+ static const U32 ARC_BODY_PART_COST = 200;
static const U32 ARC_LIMIT = 2048;
static std::set<LLUUID> all_textures;
@@ -8017,7 +8181,7 @@ void LLVOAvatar::idleUpdateRenderCost()
}
U32 cost = 0;
- std::set<LLUUID> textures;
+ LLVOVolume::texture_cost_t textures;
for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++)
{
@@ -8055,16 +8219,24 @@ void LLVOAvatar::idleUpdateRenderCost()
}
}
}
+
}
+
+ for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter)
+ {
+ // add the cost of each individual texture in the linkset
+ cost += iter->second;
+ }
+
// Diagnostic output to identify all avatar-related textures.
// Does not affect rendering cost calculation.
// Could be wrapped in a debug option if output becomes problematic.
if (isSelf())
{
// print any attachment textures we didn't already know about.
- for (std::set<LLUUID>::iterator it = textures.begin(); it != textures.end(); ++it)
+ for (LLVOVolume::texture_cost_t::iterator it = textures.begin(); it != textures.end(); ++it)
{
- LLUUID image_id = *it;
+ LLUUID image_id = it->first;
if( image_id.isNull() || image_id == IMG_DEFAULT || image_id == IMG_DEFAULT_AVATAR)
continue;
if (all_textures.find(image_id) == all_textures.end())
@@ -8095,7 +8267,6 @@ void LLVOAvatar::idleUpdateRenderCost()
}
}
}
- cost += textures.size() * LLVOVolume::ARC_TEXTURE_COST;
setDebugText(llformat("%d", cost));
F32 green = 1.f-llclamp(((F32) cost-(F32)ARC_LIMIT)/(F32)ARC_LIMIT, 0.f, 1.f);