From 430f9420cf0094635b0b0428a29ff7dfaf5718e8 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 7 Jun 2018 22:18:15 +0100 Subject: SL-915 - more on dynamic extent tracking, possible fix for 32-bit crash issues --- indra/llmath/llrigginginfo.cpp | 78 ++++++++++++++++++++++++++++++++++++++---- indra/llmath/llrigginginfo.h | 32 +++++++++++++++-- indra/llmath/llvolume.cpp | 12 +++---- indra/llmath/llvolume.h | 2 +- 4 files changed, 109 insertions(+), 15 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llrigginginfo.cpp b/indra/llmath/llrigginginfo.cpp index 925179c2ba..73e1b096cb 100644 --- a/indra/llmath/llrigginginfo.cpp +++ b/indra/llmath/llrigginginfo.cpp @@ -27,6 +27,10 @@ #include "llmath.h" #include "llrigginginfo.h" +//#if LL_WINDOWS +//#pragma optimize("", off) +//#endif + //----------------------------------------------------------------------------- // LLJointRiggingInfo //----------------------------------------------------------------------------- @@ -80,17 +84,79 @@ void LLJointRiggingInfo::merge(const LLJointRiggingInfo& other) } } -void mergeRigInfoTab(joint_rig_info_tab& dst, const joint_rig_info_tab& src) +LLJointRiggingInfoTab::LLJointRiggingInfoTab(): + mRigInfoPtr(NULL), + mSize(0) +{ +} + +LLJointRiggingInfoTab::~LLJointRiggingInfoTab() +{ + clear(); +} + +// This doesn't preserve data if the size changes. In practice +// this doesn't matter because the size is always either +// LL_CHARACTER_MAX_ANIMATED_JOINTS or 0. +void LLJointRiggingInfoTab::resize(S32 size) +{ + if (size != mSize) + { + clear(); + if (size > 0) + { + mRigInfoPtr = new LLJointRiggingInfo[size]; + mSize = size; + } + } +} + +void LLJointRiggingInfoTab::clear() { + if (mRigInfoPtr) + { + delete[](mRigInfoPtr); + mRigInfoPtr = NULL; + mSize = 0; + } +} + +void showDetails(const LLJointRiggingInfoTab& src, const std::string& str) +{ + S32 count_rigged = 0; + S32 count_box = 0; + LLVector4a zero_vec; + zero_vec.clear(); + for (S32 i=0; i dst.size()) + if (src.size() > size()) { - dst.resize(src.size()); + resize(src.size()); } - S32 size = llmin(src.size(), dst.size()); - for (S32 i=0; i joint_rig_info_tab; +// Using direct memory management instead of std::vector<> to avoid alignment issues. +class LLJointRiggingInfoTab +{ +public: + LLJointRiggingInfoTab(); + ~LLJointRiggingInfoTab(); + void resize(S32 size); + void clear(); + S32 size() const { return mSize; } + void merge(const LLJointRiggingInfoTab& src); + LLJointRiggingInfo& operator[](S32 i) { return mRigInfoPtr[i]; } + const LLJointRiggingInfo& operator[](S32 i) const { return mRigInfoPtr[i]; }; +private: + // Not implemented + LLJointRiggingInfoTab& operator=(const LLJointRiggingInfoTab& src); + LLJointRiggingInfoTab(const LLJointRiggingInfoTab& src); -void mergeRigInfoTab(joint_rig_info_tab& dst, const joint_rig_info_tab& src); + LLJointRiggingInfo *mRigInfoPtr; + S32 mSize; +}; #endif diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 8f08394ce9..2654e204c2 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -4644,7 +4644,6 @@ LLVolumeFace::LLVolumeFace() : mNumVertices(0), mNumAllocatedVertices(0), mNumIndices(0), - mJointRiggingInfoTabPtr(NULL), mPositions(NULL), mNormals(NULL), mTangents(NULL), @@ -4676,7 +4675,6 @@ LLVolumeFace::LLVolumeFace(const LLVolumeFace& src) mTangents(NULL), mTexCoords(NULL), mIndices(NULL), - mJointRiggingInfoTabPtr(NULL), mWeights(NULL), mWeightsScrubbed(FALSE), mOctree(NULL) @@ -4791,9 +4789,6 @@ void LLVolumeFace::freeData() ll_aligned_free_16(mWeights); mWeights = NULL; - free(mJointRiggingInfoTabPtr); - mJointRiggingInfoTabPtr = NULL; - delete mOctree; mOctree = NULL; } @@ -4955,7 +4950,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff) // if (new_face.mNumVertices <= mNumVertices) { - llassert(new_face.mNumIndices == mNumIndices); + llassert(new_face.mNumIndices == mNumIndices); swapData(new_face); } @@ -6292,6 +6287,9 @@ void LLVolumeFace::resizeVertices(S32 num_verts) mNumVertices = num_verts; mNumAllocatedVertices = num_verts; + + // Force update + mJointRiggingInfoTab.clear(); } void LLVolumeFace::pushVertex(const LLVolumeFace::VertexData& cv) @@ -6413,6 +6411,8 @@ 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; diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index d518bcf3ef..f92b43e77d 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -962,7 +962,7 @@ public: // Which joints are rigged to, and the bounding box of any rigged // vertices per joint. - joint_rig_info_tab *mJointRiggingInfoTabPtr; + LLJointRiggingInfoTab mJointRiggingInfoTab; LLOctreeNode* mOctree; -- cgit v1.2.3