diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index bfa65666b5..28a030d684 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -219,6 +219,11 @@ LLTextureEntry* LLPrimitive::getTE(const U8 index) const return mTextureList.getTexture(index); } +LLTextureEntry& LLPrimitive::getTEref( const U8 te_num ) const +{ + return mTextureList.getTextureRef( te_num ); +} + //=============================================================== void LLPrimitive::setNumTEs(const U8 num_tes) { @@ -713,7 +718,7 @@ void LLPrimitive::copyTEs(const LLPrimitive *primitivep) } for (i = 0; i < num_tes; i++) { - mTextureList.copyTexture(i, *(primitivep->getTE(i))); + mTextureList.copyTexture(i, primitivep->getTEref(i)); } } @@ -805,7 +810,7 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai if (old_face_mask & cur_mask) { S32 te_index = face_index_from_id(cur_mask, old_faces); - old_tes.copyTexture(face_bit, *(getTE(te_index))); + old_tes.copyTexture(face_bit, getTEref(te_index)); //LL_INFOS() << face_bit << ":" << te_index << ":" << old_tes[face_bit].getID() << LL_ENDL; } } diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 19d9d52817..4250bc1dbd 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -357,7 +357,8 @@ public: // Modify texture entry properties inline BOOL validTE(const U8 te_num) const; - LLTextureEntry* getTE(const U8 te_num) const; + LLTextureEntry* getTE( const U8 te_num ) const; + LLTextureEntry& getTEref( const U8 te_num ) const; virtual void setNumTEs(const U8 num_tes); virtual void setAllTESelected(bool sel); diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index f4f08248b8..b4c6e5c98a 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -137,14 +137,8 @@ S32 LLPrimTextureList::copyTexture(const U8 index, const LLTextureEntry& te) // we're changing an existing entry llassert(mEntryList[index]); delete (mEntryList[index]); - if (&te) - { - mEntryList[index] = te.newCopy(); - } - else - { - mEntryList[index] = LLPrimTextureList::newTextureEntry(); - } + mEntryList[index] = te.newCopy(); + return TEM_CHANGE_TEXTURE; } @@ -176,6 +170,17 @@ LLTextureEntry* LLPrimTextureList::getTexture(const U8 index) const return NULL; } +LLTextureEntry& LLPrimTextureList::getTextureRef( const U8 index ) const +{ + if( index >= mEntryList.size() ) + { + LL_ERRS() << "Texture index out of bounds, index: " << (U32)index << " mEntryList.size(): " << mEntryList.size() << LL_ENDL; + } + + return *mEntryList[ index ]; +} + + //virtual //S32 setTE(const U8 index, const LLTextureEntry& te) = 0; diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h index 49c636e40f..e286770a32 100644 --- a/indra/llprimitive/llprimtexturelist.h +++ b/indra/llprimitive/llprimtexturelist.h @@ -82,7 +82,8 @@ public: // void copyTexture(const U8 index, const LLTextureEntry* entry); // returns pointer to texture at 'index' slot - LLTextureEntry* getTexture(const U8 index) const; + LLTextureEntry* getTexture( const U8 index ) const; + LLTextureEntry& getTextureRef( const U8 index ) const; S32 setID(const U8 index, const LLUUID& id); S32 setColor(const U8 index, const LLColor3& color);