diff options
Diffstat (limited to 'indra/llmath')
| -rw-r--r-- | indra/llmath/llrigginginfo.cpp | 78 | ||||
| -rw-r--r-- | indra/llmath/llrigginginfo.h | 32 | ||||
| -rw-r--r-- | indra/llmath/llvolume.cpp | 12 | ||||
| -rw-r--r-- | indra/llmath/llvolume.h | 2 | 
4 files changed, 109 insertions, 15 deletions
| 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<src.size(); i++) +    { +        if (src[i].isRiggedTo()) +        { +            count_rigged++; +            if ((!src[i].getRiggedExtents()[0].equals3(zero_vec)) || +                (!src[i].getRiggedExtents()[1].equals3(zero_vec))) +            { +                count_box++; +            } +       } +    } +    LL_DEBUGS("RigSpammish") << "details: " << str << " has " << count_rigged << " rigged joints, of which " << count_box << " are non-empty" << LL_ENDL; +} + +void LLJointRiggingInfoTab::merge(const LLJointRiggingInfoTab& src) +{ +    //showDetails(*this, "input this");      // Size should be either LL_CHARACTER_MAX_ANIMATED_JOINTS, or 0 if      // no data. Not necessarily the same for both inputs. -    if (src.size() > 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<size; i++) +    S32 min_size = llmin(size(), src.size()); +    for (S32 i=0; i<min_size; i++)      { -        dst[i].merge(src[i]); +        (*this)[i].merge(src[i]);      } +    //showDetails(src, "input src"); +    //showDetails(*this, "output this"); +  } diff --git a/indra/llmath/llrigginginfo.h b/indra/llmath/llrigginginfo.h index 7b36880a39..b09746a5b7 100644 --- a/indra/llmath/llrigginginfo.h +++ b/indra/llmath/llrigginginfo.h @@ -44,6 +44,17 @@ public:      LLVector4a *getRiggedExtents();      const LLVector4a *getRiggedExtents() const;      void merge(const LLJointRiggingInfo& other); + +	void* operator new(size_t size) +	{ +		return ll_aligned_malloc_16(size); +	} + +	void operator delete(void* ptr) +	{ +		ll_aligned_free_16(ptr); +	} +  private:  	LL_ALIGN_16(LLVector4a mRiggedExtents[2]);      bool mIsRiggedTo; @@ -51,8 +62,25 @@ private:  // For storing all the rigging info associated with a given avatar or  // object, keyed by joint_num. -typedef std::vector<LLJointRiggingInfo> 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<LLVolumeFace::VertexData>& 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<LLVolumeTriangle>* mOctree; | 
