From 3f9b3e01b9d7ea3a6662adb55027839840198b4c Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 21 Feb 2018 22:02:34 +0000 Subject: MAINT-8264 - prevent at least some cases of LODs getting stuck at too-low values. --- indra/llprimitive/llmodel.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index db6d00bc2c..597cc66088 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -276,6 +276,7 @@ void LLModel::normalizeVolumeFaces() // We shrink the extents so // that they fall within // the unit cube. + // VFExtents change face.mExtents[0].add(trans); face.mExtents[0].mul(scale); -- cgit v1.3 From 68621905004bd783386d37b2d5d4265494ec4c18 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 8 Jun 2018 19:56:34 +0100 Subject: SL-915 - face-level caching, bug fix --- indra/llprimitive/llmodel.cpp | 3 +- indra/llprimitive/llmodel.h | 1 + indra/newview/llskinningutil.cpp | 125 +++++++++++++++++++-------------------- indra/newview/llvoavatar.cpp | 73 ++++++++++++----------- indra/newview/llvoavatar.h | 1 - 5 files changed, 103 insertions(+), 100 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 18f45d3b20..2a55838a4b 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1392,7 +1392,8 @@ bool LLModel::loadDecomposition(LLSD& header, std::istream& is) LLMeshSkinInfo::LLMeshSkinInfo(): mPelvisOffset(0.0), mLockScaleIfJointPosition(false), - mInvalidJointsScrubbed(false) + mInvalidJointsScrubbed(false), + mJointNumsInitialized(false) { } diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index 53585d2e04..d7f006753f 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -56,6 +56,7 @@ public: float mPelvisOffset; bool mLockScaleIfJointPosition; bool mInvalidJointsScrubbed; + bool mJointNumsInitialized; }; class LLModel : public LLVolume diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp index 6484775c40..49d0526245 100644 --- a/indra/newview/llskinningutil.cpp +++ b/indra/newview/llskinningutil.cpp @@ -79,21 +79,10 @@ void LLSkinningUtil::initSkinningMatrixPalette( const LLMeshSkinInfo* skin, LLVOAvatar *avatar) { + initJointNums(const_cast(skin), avatar); for (U32 j = 0; j < count; ++j) { - LLJoint *joint = NULL; - if (skin->mJointNums[j] == -1) - { - joint = avatar->getJoint(skin->mJointNames[j]); - if (joint) - { - skin->mJointNums[j] = joint->getJointNum(); - } - } - else - { - joint = avatar->getJoint(skin->mJointNums[j]); - } + LLJoint *joint = avatar->getJoint(skin->mJointNums[j]); if (joint) { #define MAT_USE_SSE @@ -218,76 +207,84 @@ void LLSkinningUtil::getPerVertexSkinMatrix( // AXON need to remember this has been done void LLSkinningUtil::initJointNums(LLMeshSkinInfo* skin, LLVOAvatar *avatar) { - for (U32 j = 0; j < skin->mJointNames.size(); ++j) + if (!skin->mJointNumsInitialized) { - LLJoint *joint = NULL; - if (skin->mJointNums[j] == -1) + for (U32 j = 0; j < skin->mJointNames.size(); ++j) { - joint = avatar->getJoint(skin->mJointNames[j]); - if (joint) + LLJoint *joint = NULL; + if (skin->mJointNums[j] == -1) { - skin->mJointNums[j] = joint->getJointNum(); + joint = avatar->getJoint(skin->mJointNames[j]); + if (joint) + { + skin->mJointNums[j] = joint->getJointNum(); + } } } + skin->mJointNumsInitialized = true; } } void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *avatar, LLVolumeFace& vol_face) { - // AXON cast - initJointNums(const_cast(skin), avatar); - S32 num_verts = vol_face.mNumVertices; - if (num_verts>0 && vol_face.mWeights && (skin->mJointNames.size()>0)) + if (vol_face.mJointRiggingInfoTab.needsUpdate()) { - if (vol_face.mJointRiggingInfoTab.size()==0) + S32 num_verts = vol_face.mNumVertices; + if (num_verts>0 && vol_face.mWeights && (skin->mJointNames.size()>0)) { - std::set active_joints; - S32 active_verts = 0; - vol_face.mJointRiggingInfoTab.resize(LL_CHARACTER_MAX_ANIMATED_JOINTS); - LLJointRiggingInfoTab &rig_info_tab = vol_face.mJointRiggingInfoTab; - for (S32 i=0; i(skin), avatar); + if (vol_face.mJointRiggingInfoTab.size()==0) { - LLVector4a& pos = vol_face.mPositions[i]; - F32 *w = vol_face.mWeights[i].getF32ptr(); - for (U32 k=0; k<4; ++k) + std::set active_joints; + S32 active_verts = 0; + vol_face.mJointRiggingInfoTab.resize(LL_CHARACTER_MAX_ANIMATED_JOINTS); + LLJointRiggingInfoTab &rig_info_tab = vol_face.mJointRiggingInfoTab; + for (S32 i=0; imJointNums[joint_index]; - if (joint_num >= 0 && joint_num < LL_CHARACTER_MAX_ANIMATED_JOINTS) + LLVector4a& pos = vol_face.mPositions[i]; + F32 *w = vol_face.mWeights[i].getF32ptr(); + for (U32 k=0; k<4; ++k) { - rig_info_tab[joint_num].setIsRiggedTo(true); - active_joints.insert(joint_num); - active_verts++; + S32 joint_index = llfloor(w[k]); + S32 joint_num = skin->mJointNums[joint_index]; + if (joint_num >= 0 && joint_num < LL_CHARACTER_MAX_ANIMATED_JOINTS) + { + rig_info_tab[joint_num].setIsRiggedTo(true); + active_joints.insert(joint_num); + active_verts++; - // AXON can precompute these matMuls. - LLMatrix4a bind_shape; - bind_shape.loadu(skin->mBindShapeMatrix); - LLMatrix4a inv_bind; - inv_bind.loadu(skin->mInvBindMatrix[joint_index]); - LLMatrix4a mat; - matMul(bind_shape, inv_bind, mat); - LLVector4a pos_joint_space; - mat.affineTransform(pos, pos_joint_space); - LLVector4a *extents = rig_info_tab[joint_num].getRiggedExtents(); - update_min_max(extents[0], extents[1], pos_joint_space); + // AXON can precompute these matMuls. + LLMatrix4a bind_shape; + bind_shape.loadu(skin->mBindShapeMatrix); + LLMatrix4a inv_bind; + inv_bind.loadu(skin->mInvBindMatrix[joint_index]); + LLMatrix4a mat; + matMul(bind_shape, inv_bind, mat); + LLVector4a pos_joint_space; + mat.affineTransform(pos, pos_joint_space); + LLVector4a *extents = rig_info_tab[joint_num].getRiggedExtents(); + update_min_max(extents[0], extents[1], pos_joint_space); + } } } + LL_DEBUGS("RigSpammish") << "built rigging info for vf " << &vol_face + << " num_verts " << vol_face.mNumVertices + << " active joints " << active_joints.size() + << " active verts " << active_verts + << LL_ENDL; + vol_face.mJointRiggingInfoTab.setNeedsUpdate(false); } - LL_DEBUGS("RigSpammish") << "built rigging info for vf " << &vol_face - << " num_verts " << vol_face.mNumVertices - << " active joints " << active_joints.size() - << " active verts " << active_verts - << LL_ENDL; } - } - if (vol_face.mJointRiggingInfoTab.size()!=0) - { - LL_DEBUGS("RigSpammish") << "we have rigging info for vf " << &vol_face - << " num_verts " << vol_face.mNumVertices << LL_ENDL; - } - else - { - LL_DEBUGS("RigSpammish") << "no rigging info for vf " << &vol_face - << " num_verts " << vol_face.mNumVertices << LL_ENDL; + if (vol_face.mJointRiggingInfoTab.size()!=0) + { + LL_DEBUGS("RigSpammish") << "we have rigging info for vf " << &vol_face + << " num_verts " << vol_face.mNumVertices << LL_ENDL; + } + else + { + LL_DEBUGS("RigSpammish") << "no rigging info for vf " << &vol_face + << " num_verts " << vol_face.mNumVertices << LL_ENDL; + } + } } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 8c3a180570..8a457e1e53 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -671,8 +671,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mCachedInMuteList(false), mIsControlAvatar(false), mIsUIAvatar(false), - mEnableDefaultMotions(true), - mRiggingInfoNeedsUpdate(true) + mEnableDefaultMotions(true) { LL_DEBUGS("AvatarRender") << "LLVOAvatar Constructor (0x" << this << ") id:" << mID << LL_ENDL; @@ -1371,10 +1370,10 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) { // AXON try to cache unless something has changed about attached rigged meshes. // Needs more logic based on volume states. - //if (mRiggingInfoNeedsUpdate) + //if (mRiggingInfoTab.needsUpdate()) { updateRiggingInfo(); - mRiggingInfoNeedsUpdate = false; + mJointRiggingInfoTab.setNeedsUpdate(false); } for (S32 joint_num = 0; joint_num < LL_CHARACTER_MAX_ANIMATED_JOINTS; joint_num++) { @@ -9479,12 +9478,10 @@ void showRigInfoTabExtents(LLVOAvatar *avatar, LLJointRiggingInfoTab& tab, S32& } } -// virtual -void LLVOAvatar::updateRiggingInfo() +// AXON move to member +void getAssociatedVolumes(LLVOAvatar *av, std::vector& volumes) { - mJointRiggingInfoTab.clear(); - //LL_INFOS() << "starting update rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL; - for ( attachment_map_t::iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); ++iter ) + for ( LLVOAvatar::attachment_map_t::iterator iter = av->mAttachmentPoints.begin(); iter != av->mAttachmentPoints.end(); ++iter ) { LLViewerJointAttachment* attachment = iter->second; LLViewerJointAttachment::attachedobjs_vec_t::iterator attach_end = attachment->mAttachedObjects.end(); @@ -9493,51 +9490,59 @@ void LLVOAvatar::updateRiggingInfo() attach_iter != attach_end; ++attach_iter) { LLViewerObject* attached_object = *attach_iter; - attached_object->updateRiggingInfo(); - mJointRiggingInfoTab.merge(attached_object->mJointRiggingInfoTab); - //LL_INFOS() << "after merge rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL; - - + LLVOVolume *volume = dynamic_cast(attached_object); + if (volume) + { + volumes.push_back(volume); + } LLViewerObject::const_child_list_t& children = attached_object->getChildren(); for (LLViewerObject::const_child_list_t::const_iterator it = children.begin(); it != children.end(); ++it) { LLViewerObject *childp = *it; - childp->updateRiggingInfo(); - mJointRiggingInfoTab.merge(childp->mJointRiggingInfoTab); - //LL_INFOS() << "after merge rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL; + LLVOVolume *volume = dynamic_cast(childp); + if (volume) + { + volumes.push_back(volume); + } } } } - LLControlAvatar *control_av = dynamic_cast(this); + LLControlAvatar *control_av = dynamic_cast(av); if (control_av) { LLVOVolume *volp = control_av->mRootVolp; if (volp && !volp->isAttachment()) { - mJointRiggingInfoTab.merge(volp->mJointRiggingInfoTab); - LL_DEBUGS("RigSpammish") << getFullname() << " mRootVolp " << control_av->mRootVolp << " after cav update rig tab:" << LL_ENDL; - S32 joint_count, box_count; - showRigInfoTabExtents(this, mJointRiggingInfoTab, joint_count, box_count); - LL_DEBUGS("RigSpammish") << "uses " << joint_count << " joints " << " nonzero boxes: " << box_count << LL_ENDL; - //LL_INFOS() << "cav after merge rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL; - + volumes.push_back(volp); LLViewerObject::const_child_list_t& children = volp->getChildren(); for (LLViewerObject::const_child_list_t::const_iterator it = children.begin(); it != children.end(); ++it) { LLViewerObject *childp = *it; - childp->updateRiggingInfo(); - mJointRiggingInfoTab.merge(childp->mJointRiggingInfoTab); - - LL_DEBUGS("RigSpammish") << getFullname() << " after cav child update rig tab:" << LL_ENDL; - S32 joint_count, box_count; - showRigInfoTabExtents(this, mJointRiggingInfoTab, joint_count, box_count); - LL_DEBUGS("RigSpammish") << "uses " << joint_count << " joints " << " nonzero boxes: " << box_count << LL_ENDL; - //LL_INFOS() << "cav after merge rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL; + LLVOVolume *volume = dynamic_cast(childp); + if (volume) + { + volumes.push_back(volume); + } } } } +} + +// virtual +void LLVOAvatar::updateRiggingInfo() +{ + LL_DEBUGS("RigSpammish") << getFullname() << " updating rig tab" << LL_ENDL; + mJointRiggingInfoTab.clear(); + std::vector volumes; + getAssociatedVolumes(this, volumes); + for (std::vector::iterator it = volumes.begin(); it != volumes.end(); ++it) + { + LLVOVolume *vol = *it; + vol->updateRiggingInfo(); + mJointRiggingInfoTab.merge(vol->mJointRiggingInfoTab); + } //LL_INFOS() << "done update rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL; LL_DEBUGS("RigSpammish") << getFullname() << " after update rig tab:" << LL_ENDL; @@ -9549,7 +9554,7 @@ void LLVOAvatar::updateRiggingInfo() // virtual void LLVOAvatar::onActiveOverrideMeshesChanged() { - mRiggingInfoNeedsUpdate = true; + mJointRiggingInfoTab.setNeedsUpdate(true); } U32 LLVOAvatar::getPartitionType() const diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 924b361f59..09712e6d84 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -219,7 +219,6 @@ public: // virtual void updateRiggingInfo(); - bool mRiggingInfoNeedsUpdate; std::set mActiveOverrideMeshes; virtual void onActiveOverrideMeshesChanged(); -- cgit v1.3 From edf6795edaa4ec822ac0e2bc906c71606b84b5c8 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 13 Jun 2018 21:49:24 +0100 Subject: SL-915, MAINT-8554 - cleanup/reorg, added encroachment fix info to DebugAnimatedObjects output --- indra/llcommon/llerror.cpp | 4 +- indra/llmath/llrigginginfo.cpp | 4 -- indra/llmath/llvolume.cpp | 95 --------------------------------------- indra/llmath/llvolume.h | 2 - indra/llmath/v3math.cpp | 36 +++++++++++++++ indra/llmath/v3math.h | 2 + indra/llprimitive/llmodel.cpp | 34 -------------- indra/llprimitive/llmodel.h | 3 -- indra/newview/llcontrolavatar.cpp | 55 +++++------------------ indra/newview/llmeshrepository.h | 1 - indra/newview/llskinningutil.cpp | 4 -- indra/newview/llvoavatar.cpp | 84 +++++----------------------------- indra/newview/llvoavatar.h | 5 ++- 13 files changed, 65 insertions(+), 264 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index f81030b0e7..d0e7c06f36 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -1293,7 +1293,7 @@ namespace LLError #if LL_WINDOWS // VC80 was optimizing the error away. -// #pragma optimize("", off) + #pragma optimize("", off) #endif void crashAndLoop(const std::string& message) { @@ -1311,7 +1311,7 @@ namespace LLError exit(EXIT_FAILURE); } #if LL_WINDOWS -// #pragma optimize("", on) + #pragma optimize("", on) #endif std::string utcTime() diff --git a/indra/llmath/llrigginginfo.cpp b/indra/llmath/llrigginginfo.cpp index 885acb7670..0de07950c1 100644 --- a/indra/llmath/llrigginginfo.cpp +++ b/indra/llmath/llrigginginfo.cpp @@ -27,10 +27,6 @@ #include "llmath.h" #include "llrigginginfo.h" -//#if LL_WINDOWS -//#pragma optimize("", off) -//#endif - //----------------------------------------------------------------------------- // LLJointRiggingInfo //----------------------------------------------------------------------------- diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 2654e204c2..ba284574c8 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -6411,101 +6411,6 @@ void LLVolumeFace::fillFromLegacyData(std::vector& v, } } -// AXON appendFace/appendFaces not used - referenced by corresponding functions in -// LLModel but these are not called anywhere. -void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMatrix4& norm_mat_in) -{ - U16 offset = mNumVertices; - - S32 new_count = face.mNumVertices + mNumVertices; - - if (new_count > 65536) - { - LL_ERRS() << "Cannot append face -- 16-bit overflow will occur." << LL_ENDL; - } - - if (face.mNumVertices == 0) - { - LL_ERRS() << "Cannot append empty face." << LL_ENDL; - } - - U32 old_vsize = mNumVertices*16; - U32 new_vsize = new_count * 16; - U32 old_tcsize = (mNumVertices*sizeof(LLVector2)+0xF) & ~0xF; - U32 new_tcsize = (new_count*sizeof(LLVector2)+0xF) & ~0xF; - U32 new_size = new_vsize * 2 + new_tcsize; - - //allocate new buffer space - LLVector4a* old_buf = mPositions; - mPositions = (LLVector4a*) ll_aligned_malloc<64>(new_size); - mNormals = mPositions + new_count; - mTexCoords = (LLVector2*) (mNormals+new_count); - - mNumAllocatedVertices = new_count; - - LLVector4a::memcpyNonAliased16((F32*) mPositions, (F32*) old_buf, old_vsize); - LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) (old_buf+mNumVertices), old_vsize); - LLVector4a::memcpyNonAliased16((F32*) mTexCoords, (F32*) (old_buf+mNumVertices*2), old_tcsize); - - mNumVertices = new_count; - - //get destination address of appended face - LLVector4a* dst_pos = mPositions+offset; - LLVector2* dst_tc = mTexCoords+offset; - LLVector4a* dst_norm = mNormals+offset; - - //get source addresses of appended face - const LLVector4a* src_pos = face.mPositions; - const LLVector2* src_tc = face.mTexCoords; - const LLVector4a* src_norm = face.mNormals; - - //load aligned matrices - LLMatrix4a mat, norm_mat; - mat.loadu(mat_in); - norm_mat.loadu(norm_mat_in); - - for (U32 i = 0; i < face.mNumVertices; ++i) - { - //transform appended face position and store - mat.affineTransform(src_pos[i], dst_pos[i]); - - //transform appended face normal and store - norm_mat.rotate(src_norm[i], dst_norm[i]); - dst_norm[i].normalize3fast(); - - //copy appended face texture coordinate - dst_tc[i] = src_tc[i]; - - if (offset == 0 && i == 0) - { //initialize bounding box - // VFExtents change - mExtents[0] = mExtents[1] = dst_pos[i]; - } - else - { - //stretch bounding box - // VFExtents change - update_min_max(mExtents[0], mExtents[1], dst_pos[i]); - } - } - LL_DEBUGS("RiggedBox") << "appendFace got extents " << mExtents[0] << ", " << mExtents[1] << " from dst_pos " << LL_ENDL; - - - new_count = mNumIndices + face.mNumIndices; - - //allocate new index buffer - mIndices = (U16*) ll_aligned_realloc_16(mIndices, (new_count*sizeof(U16)+0xF) & ~0xF, (mNumIndices*sizeof(U16)+0xF) & ~0xF); - - //get destination address into new index buffer - U16* dst_idx = mIndices+mNumIndices; - mNumIndices = new_count; - - for (U32 i = 0; i < face.mNumIndices; ++i) - { //copy indices, offsetting by old vertex count - dst_idx[i] = face.mIndices[i]+offset; - } -} - BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) { LL_CHECK_MEMORY diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index f92b43e77d..1d6d35c432 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -872,8 +872,6 @@ public: BOOL create(LLVolume* volume, BOOL partial_build = FALSE); void createTangents(); - void appendFace(const LLVolumeFace& face, LLMatrix4& transform, LLMatrix4& normal_tranform); - void resizeVertices(S32 num_verts); void allocateTangents(S32 num_verts); void allocateWeights(S32 num_verts); diff --git a/indra/llmath/v3math.cpp b/indra/llmath/v3math.cpp index e7107dee16..b04c67d926 100644 --- a/indra/llmath/v3math.cpp +++ b/indra/llmath/v3math.cpp @@ -369,3 +369,39 @@ BOOL LLVector3::parseVector3(const std::string& buf, LLVector3* value) return FALSE; } + +// Displacement from query point to nearest neighbor point on bounding box. +// Returns zero vector for points within or on the box. +LLVector3 point_to_box_offset(LLVector3& pos, const LLVector3* box) +{ + LLVector3 offset; + for (S32 k=0; k<3; k++) + { + offset[k] = 0; + if (pos[k] < box[0][k]) + { + offset[k] = pos[k] - box[0][k]; + } + else if (pos[k] > box[1][k]) + { + offset[k] = pos[k] - box[1][k]; + } + } + return offset; +} + +bool box_valid_and_non_zero(const LLVector3* box) +{ + if (!box[0].isFinite() || !box[1].isFinite()) + { + return false; + } + LLVector3 zero_vec; + zero_vec.clear(); + if ((box[0] != zero_vec) || (box[1] != zero_vec)) + { + return true; + } + return false; +} + diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h index f3fbce4843..6f857d7061 100644 --- a/indra/llmath/v3math.h +++ b/indra/llmath/v3math.h @@ -163,6 +163,8 @@ LLVector3 inverse_projected_vec(const LLVector3 &a, const LLVector3 &b); // Retu LLVector3 parallel_component(const LLVector3 &a, const LLVector3 &b); // Returns vector a projected on vector b (same as projected_vec) LLVector3 orthogonal_component(const LLVector3 &a, const LLVector3 &b); // Returns component of vector a not parallel to vector b (same as projected_vec) LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u); // Returns a vector that is a linear interpolation between a and b +LLVector3 point_to_box_offset(LLVector3& pos, const LLVector3* box); // Displacement from query point to nearest point on bounding box. +bool box_valid_and_non_zero(const LLVector3* box); inline LLVector3::LLVector3(void) { diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 2a55838a4b..a0e835c577 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -401,40 +401,6 @@ void LLModel::setVolumeFaceData( LLVector4a::memcpyNonAliased16((F32*) face.mIndices, (F32*) ind.get(), size); } -void LLModel::appendFaces(LLModel *model, LLMatrix4 &transform, LLMatrix4& norm_mat) -{ - if (mVolumeFaces.empty()) - { - setNumVolumeFaces(1); - } - - LLVolumeFace& face = mVolumeFaces[mVolumeFaces.size()-1]; - - - for (S32 i = 0; i < model->getNumFaces(); ++i) - { - face.appendFace(model->getVolumeFace(i), transform, norm_mat); - } - -} - -void LLModel::appendFace(const LLVolumeFace& src_face, std::string src_material, LLMatrix4& mat, LLMatrix4& norm_mat) -{ - S32 rindex = getNumVolumeFaces()-1; - if (rindex == -1 || - mVolumeFaces[rindex].mNumVertices + src_face.mNumVertices >= 65536) - { //empty or overflow will occur, append new face - LLVolumeFace cur_face; - cur_face.appendFace(src_face, mat, norm_mat); - addFace(cur_face); - mMaterialList.push_back(src_material); - } - else - { //append to existing end face - mVolumeFaces.rbegin()->appendFace(src_face, mat, norm_mat); - } -} - void LLModel::addFace(const LLVolumeFace& face) { if (face.mNumVertices == 0) diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index d7f006753f..cf3288489a 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -158,9 +158,6 @@ public: EModelStatus getStatus() const {return mStatus;} static std::string getStatusString(U32 status) ; - void appendFaces(LLModel* model, LLMatrix4& transform, LLMatrix4& normal_transform); - void appendFace(const LLVolumeFace& src_face, std::string src_material, LLMatrix4& mat, LLMatrix4& norm_mat); - void setNumVolumeFaces(S32 count); void setVolumeFaceData( S32 f, diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index 8291df7705..36e728f26d 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -34,10 +34,6 @@ #include "llmeshrepository.h" #include "llviewerregion.h" -#if LL_WINDOWS - #pragma optimize("", off) -#endif - LLControlAvatar::LLControlAvatar(const LLUUID& id, const LLPCode pcode, LLViewerRegion* regionp) : LLVOAvatar(id, pcode, regionp), mPlaying(false), @@ -68,41 +64,6 @@ void LLControlAvatar::initInstance() hideSkirt(); } -// AXON move to math -bool box_valid_and_non_zero(const LLVector3* box) -{ - if (!box[0].isFinite() || !box[1].isFinite()) - { - return false; - } - LLVector3 zero_vec; - zero_vec.clear(); - if ((box[0] != zero_vec) || (box[1] != zero_vec)) - { - return true; - } - return false; -} - -// AXON move to math -LLVector3 point_to_box_offset(LLVector3& pos, const LLVector3* box) -{ - LLVector3 offset; - for (S32 k=0; k<3; k++) - { - offset[k] = 0; - if (pos[k] < box[0][k]) - { - offset[k] = pos[k] - box[0][k]; - } - else if (pos[k] > box[1][k]) - { - offset[k] = pos[k] - box[1][k]; - } - } - return offset; -} - void LLControlAvatar::matchVolumeTransform() { if (mRootVolp) @@ -157,11 +118,11 @@ void LLControlAvatar::matchVolumeTransform() F32 target_dist = (offset_dist - MAX_LEGAL_OFFSET); pos_box_offset *= target_dist/offset_dist; } - LL_DEBUGS("FixBox") << getFullname() << " fixup needed for offset " - << pos_box_offset[0] << "," << pos_box_offset[1] << "," << pos_box_offset[2] - << " current fixup " - << mPositionConstraintFixup[0] << "," << mPositionConstraintFixup[1] << "," << mPositionConstraintFixup[2] - << " dist " << offset_dist << LL_ENDL; + //LL_DEBUGS("FixBox") << getFullname() << " fixup needed for offset " + // << pos_box_offset[0] << "," << pos_box_offset[1] << "," << pos_box_offset[2] + // << " current fixup " + // << mPositionConstraintFixup[0] << "," << mPositionConstraintFixup[1] << "," << mPositionConstraintFixup[2] + // << " dist " << offset_dist << LL_ENDL; } mPositionConstraintFixup = pos_box_offset; @@ -380,6 +341,12 @@ void LLControlAvatar::updateDebugText() addDebugText(llformat("flags %s", animated_object_flag_string.c_str())); addDebugText(llformat("tris %d (est %.1f, streaming %.1f), verts %d", total_tris, est_tris, est_streaming_tris, total_verts)); addDebugText(llformat("pxarea %s rank %d", LLStringOps::getReadableNumber(getPixelArea()).c_str(), getVisibilityRank())); + if (mPositionConstraintFixup.length() > 0.0f) + { + addDebugText(llformat("pos fix (%.1f %.1f %.1f)", + mPositionConstraintFixup[0], mPositionConstraintFixup[1], mPositionConstraintFixup[2])); + } + #if 0 std::string region_name = "no region"; if (mRootVolp->getRegion()) diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index df8f5c5ff4..cb3903b1d0 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -652,7 +652,6 @@ public: extern LLMeshRepository gMeshRepo; -// AXON make sure this is consistent with the final simulator-side values. const F32 ANIMATED_OBJECT_BASE_COST = 15.0f; const F32 ANIMATED_OBJECT_COST_PER_KTRI = 1.5f; diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp index db9877f302..0878cee1a3 100644 --- a/indra/newview/llskinningutil.cpp +++ b/indra/newview/llskinningutil.cpp @@ -34,10 +34,6 @@ #include "llvolume.h" #include "llrigginginfo.h" -//#if LL_WINDOWS -//#pragma optimize("", off) -//#endif - void LLSkinningUtil::initClass() { } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 6896632597..728155382f 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1346,7 +1346,7 @@ void LLVOAvatar::calculateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) attachment_iter != attachment->mAttachedObjects.end(); ++attachment_iter) { - // AXON is this right? Don't we need to look at children of attached_object as well? + // AXON Don't we need to look at children of attached_object as well? const LLViewerObject* attached_object = (*attachment_iter); if (attached_object && !attached_object->isHUDAttachment()) { @@ -1389,10 +1389,11 @@ void LLVOAvatar::calculateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) { // AXON try to cache unless something has changed about attached rigged meshes. // Needs more logic based on volume states. + //if (mRiggingInfoTab.needsUpdate()) { updateRiggingInfo(); - mJointRiggingInfoTab.setNeedsUpdate(false); + //mJointRiggingInfoTab.setNeedsUpdate(false); } for (S32 joint_num = 0; joint_num < LL_CHARACTER_MAX_ANIMATED_JOINTS; joint_num++) { @@ -1403,12 +1404,6 @@ void LLVOAvatar::calculateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) rig_info = &mJointRiggingInfoTab[joint_num]; } - // FIXME TEMP HACK FOR TESTING - //if (joint) - //{ - // rig_info.setIsRiggedTo(true); - //} - if (joint && rig_info && rig_info->isRiggedTo()) { LLViewerJointAttachment *as_joint_attach = dynamic_cast(joint); @@ -1574,7 +1569,7 @@ void LLVOAvatar::renderBones() } else { - if (jointIsRiggedTo(jointp->getName())) + if (jointIsRiggedTo(jointp)) { occ_color = RIGGED_COLOR_OCCLUDED; visible_color = RIGGED_COLOR_VISIBLE; @@ -2702,7 +2697,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update) { ext[0].load3(mLastAnimExtents[0].mV); ext[1].load3(mLastAnimExtents[1].mV); - // AXON just do this once per frame + // Expensive. Just call this once per frame, in updateSpatialExtents(); //calculateSpatialExtents(ext[0], ext[1]); LLVector4a diff; diff.setSub(ext[1], mImpostorExtents[1]); @@ -5827,73 +5822,17 @@ bool LLVOAvatar::getRiggedMeshID(LLViewerObject* pVO, LLUUID& mesh_id) return false; } -// AXON update to use LLRiggingInfo -bool LLVOAvatar::jointIsRiggedTo(const std::string& joint_name) +bool LLVOAvatar::jointIsRiggedTo(const LLJoint *joint) const { - LLJoint *joint = getJoint(joint_name); if (joint) { - LLJointRiggingInfoTab& tab = mJointRiggingInfoTab; + const LLJointRiggingInfoTab& tab = mJointRiggingInfoTab; S32 joint_num = joint->getJointNum(); if (joint_num < tab.size() && tab[joint_num].isRiggedTo()) { return true; } } - return false; -#if 0 - for (attachment_map_t::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 && jointIsRiggedTo(joint_name, attached_object)) - { - return true; - } - } - } - return false; -#endif -} - -// AXON update to use LLRiggingInfo -bool LLVOAvatar::jointIsRiggedTo(const std::string& joint_name, const LLViewerObject *vo) -{ - // Process all children - LLViewerObject::const_child_list_t& children = vo->getChildren(); - for (LLViewerObject::const_child_list_t::const_iterator it = children.begin(); - it != children.end(); ++it) - { - LLViewerObject *childp = *it; - if (jointIsRiggedTo(joint_name,childp)) - { - return true; - } - } - - const LLVOVolume *vobj = dynamic_cast(vo); - if (!vobj) - { - return false; - } - - const LLMeshSkinInfo* pSkinData = vobj->getSkinInfo(); - - if ( vobj && vobj->isAttachment() && vobj->isMesh() && pSkinData ) - { - if (std::find(pSkinData->mJointNames.begin(), pSkinData->mJointNames.end(), joint_name) != - pSkinData->mJointNames.end()) - { - return true; - } - } - return false; } @@ -9554,10 +9493,9 @@ void showRigInfoTabExtents(LLVOAvatar *avatar, LLJointRiggingInfoTab& tab, S32& } } -// AXON move to member -void getAssociatedVolumes(LLVOAvatar *av, std::vector& volumes) +void LLVOAvatar::getAssociatedVolumes(std::vector& volumes) { - for ( LLVOAvatar::attachment_map_t::iterator iter = av->mAttachmentPoints.begin(); iter != av->mAttachmentPoints.end(); ++iter ) + for ( LLVOAvatar::attachment_map_t::iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); ++iter ) { LLViewerJointAttachment* attachment = iter->second; LLViewerJointAttachment::attachedobjs_vec_t::iterator attach_end = attachment->mAttachedObjects.end(); @@ -9584,7 +9522,7 @@ void getAssociatedVolumes(LLVOAvatar *av, std::vector& volumes) } } } - LLControlAvatar *control_av = dynamic_cast(av); + LLControlAvatar *control_av = dynamic_cast(this); if (control_av) { LLVOVolume *volp = control_av->mRootVolp; @@ -9612,7 +9550,7 @@ void LLVOAvatar::updateRiggingInfo() LL_DEBUGS("RigSpammish") << getFullname() << " updating rig tab" << LL_ENDL; mJointRiggingInfoTab.clear(); std::vector volumes; - getAssociatedVolumes(this, volumes); + getAssociatedVolumes(volumes); for (std::vector::iterator it = volumes.begin(); it != volumes.end(); ++it) { LLVOVolume *vol = *it; diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index d80f0ad713..25c89f96d7 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -208,8 +208,7 @@ public: void addAttachmentOverridesForObject(LLViewerObject *vo, std::set* meshes_seen = NULL, bool recursive = true); void removeAttachmentOverridesForObject(const LLUUID& mesh_id); void removeAttachmentOverridesForObject(LLViewerObject *vo); - bool jointIsRiggedTo(const std::string& joint_name); - bool jointIsRiggedTo(const std::string& joint_name, const LLViewerObject *vo); + bool jointIsRiggedTo(const LLJoint *joint) const; void clearAttachmentOverrides(); void rebuildAttachmentOverrides(); void updateAttachmentOverrides(); @@ -217,6 +216,8 @@ public: void getAttachmentOverrideNames(std::set& pos_names, std::set& scale_names) const; + void getAssociatedVolumes(std::vector& volumes); + // virtual void updateRiggingInfo(); -- cgit v1.3 From 73c76fdccf3da73502403deeab3f2c4e26d68376 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 13 Jul 2018 18:56:08 +0100 Subject: MAINT-8863 - more diagnostics and possible fix --- indra/llprimitive/llmodel.cpp | 3 ++- indra/newview/llskinningutil.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index a0e835c577..37548e3fe3 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1366,7 +1366,8 @@ LLMeshSkinInfo::LLMeshSkinInfo(): LLMeshSkinInfo::LLMeshSkinInfo(LLSD& skin): mPelvisOffset(0.0), mLockScaleIfJointPosition(false), - mInvalidJointsScrubbed(false) + mInvalidJointsScrubbed(false), + mJointNumsInitialized(false) { fromLLSD(skin); } diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp index 0799715ae0..72252aebde 100644 --- a/indra/newview/llskinningutil.cpp +++ b/indra/newview/llskinningutil.cpp @@ -45,6 +45,8 @@ void dump_avatar_and_skin_state(const std::string& reason, LLVOAvatar *avatar, c << " avatar build state: isBuilt() " << avatar->isBuilt() << " mInitFlags " << avatar->mInitFlags << LL_ENDL; LL_WARNS("Avatar") << "Skin num joints " << skin->mJointNames.size() << " " << skin->mJointNums.size() << LL_ENDL; + LL_WARNS("Avatar") << "Skin scrubbed " << skin->mInvalidJointsScrubbed + << " nums init " << skin->mJointNumsInitialized << LL_ENDL; for (S32 j=0; jmJointNames.size(); j++) { LL_WARNS("Avatar") << "skin joint idx " << j << " name [" << skin->mJointNames[j] @@ -283,9 +285,9 @@ void LLSkinningUtil::initJointNums(LLMeshSkinInfo* skin, LLVOAvatar *avatar) } } skin->mJointNumsInitialized = true; - LL_WARNS_ONCE("Avatar") << avatar->getFullname() << " jointNums initialized, avatar built " << avatar->isBuilt() - << " mInitFlags " << avatar->mInitFlags - << " num joints " << skin->mJointNames.size() << LL_ENDL; + LL_WARNS("Avatar") << avatar->getFullname() << " jointNums initialized, avatar built " << avatar->isBuilt() + << " mInitFlags " << avatar->mInitFlags + << " num joints " << skin->mJointNames.size() << LL_ENDL; } } -- cgit v1.3