V2 llprimitive merge
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include "llstring.h"
|
||||
#include "lldatapacker.h"
|
||||
#include "llsdutil_math.h"
|
||||
#include "llprimtexturelist.h"
|
||||
|
||||
/**
|
||||
* exported constants
|
||||
@@ -112,6 +113,7 @@ const F32 FLEXIBLE_OBJECT_DEFAULT_LENGTH = 1.0f;
|
||||
const BOOL FLEXIBLE_OBJECT_DEFAULT_USING_COLLISION_SPHERE = FALSE;
|
||||
const BOOL FLEXIBLE_OBJECT_DEFAULT_RENDERING_COLLISION_SPHERE = FALSE;
|
||||
|
||||
const S32 MAX_FACE_BITS = 9;
|
||||
|
||||
const char *SCULPT_DEFAULT_TEXTURE = "be293869-d0d9-0a69-5989-ad27f1946fd4"; // old inverted texture: "7595d345-a24c-e7ef-f0bd-78793792133e";
|
||||
|
||||
@@ -130,7 +132,7 @@ void LLPrimitive::setVolumeManager( LLVolumeMgr* volume_manager )
|
||||
{
|
||||
if ( !volume_manager || sVolumeManager )
|
||||
{
|
||||
llerrs << "Unable to set LLPrimitive::sVolumeManager to NULL" << llendl;
|
||||
llerrs << "LLPrimitive::sVolumeManager attempting to be set to NULL or it already has been set." << llendl;
|
||||
}
|
||||
sVolumeManager = volume_manager;
|
||||
}
|
||||
@@ -151,7 +153,9 @@ bool LLPrimitive::cleanupVolumeManager()
|
||||
|
||||
//===============================================================
|
||||
LLPrimitive::LLPrimitive()
|
||||
: mMiscFlags(0)
|
||||
: mTextureList(),
|
||||
mNumTEs(0),
|
||||
mMiscFlags(0)
|
||||
{
|
||||
mPrimitiveCode = 0;
|
||||
|
||||
@@ -168,20 +172,12 @@ LLPrimitive::LLPrimitive()
|
||||
mAngularVelocity.setVec(0.f,0.f,0.f);
|
||||
|
||||
mScale.setVec(1.f,1.f,1.f);
|
||||
|
||||
mNumTEs = 0;
|
||||
mTextureList = NULL;
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
LLPrimitive::~LLPrimitive()
|
||||
{
|
||||
if (mTextureList)
|
||||
{
|
||||
delete [] mTextureList;
|
||||
mTextureList = NULL;
|
||||
}
|
||||
|
||||
clearTextureList();
|
||||
// Cleanup handled by volume manager
|
||||
if (mVolumep)
|
||||
{
|
||||
@@ -190,6 +186,10 @@ LLPrimitive::~LLPrimitive()
|
||||
mVolumep = NULL;
|
||||
}
|
||||
|
||||
void LLPrimitive::clearTextureList()
|
||||
{
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
// static
|
||||
LLPrimitive *LLPrimitive::createPrimitive(LLPCode p_code)
|
||||
@@ -213,15 +213,7 @@ LLPrimitive *LLPrimitive::createPrimitive(LLPCode p_code)
|
||||
void LLPrimitive::init_primitive(LLPCode p_code)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_PRIMITIVE);
|
||||
if (mNumTEs)
|
||||
{
|
||||
if (mTextureList)
|
||||
{
|
||||
delete [] mTextureList;
|
||||
}
|
||||
mTextureList = new LLTextureEntry[mNumTEs];
|
||||
}
|
||||
|
||||
clearTextureList();
|
||||
mPrimitiveCode = p_code;
|
||||
}
|
||||
|
||||
@@ -231,342 +223,146 @@ void LLPrimitive::setPCode(const U8 p_code)
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
const LLTextureEntry * LLPrimitive::getTE(const U8 te_num) const
|
||||
const LLTextureEntry* LLPrimitive::getTE(const U8 index) const
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (mNumTEs && (te_num< mNumTEs))
|
||||
{
|
||||
return(&mTextureList[te_num]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
return mTextureList.getTexture(index);
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
void LLPrimitive::setNumTEs(const U8 num_tes)
|
||||
{
|
||||
if (num_tes == mNumTEs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Right now, we don't try and preserve entries when the number of faces
|
||||
// changes.
|
||||
|
||||
LLMemType m1(LLMemType::MTYPE_PRIMITIVE);
|
||||
if (num_tes)
|
||||
{
|
||||
LLTextureEntry *new_tes;
|
||||
new_tes = new LLTextureEntry[num_tes];
|
||||
U32 i;
|
||||
for (i = 0; i < num_tes; i++)
|
||||
{
|
||||
if (i < mNumTEs)
|
||||
{
|
||||
new_tes[i] = mTextureList[i];
|
||||
}
|
||||
else if (mNumTEs)
|
||||
{
|
||||
new_tes[i] = mTextureList[mNumTEs - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_tes[i] = LLTextureEntry();
|
||||
}
|
||||
}
|
||||
delete[] mTextureList;
|
||||
mTextureList = new_tes;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete[] mTextureList;
|
||||
mTextureList = NULL;
|
||||
}
|
||||
|
||||
|
||||
mNumTEs = num_tes;
|
||||
mTextureList.setSize(num_tes);
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
void LLPrimitive::setAllTETextures(const LLUUID &tex_id)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
for (i = 0; i < mNumTEs; i++)
|
||||
{
|
||||
mTextureList[i].setID(tex_id);
|
||||
}
|
||||
mTextureList.setAllIDs(tex_id);
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
void LLPrimitive::setTE(const U8 index, const LLTextureEntry &te)
|
||||
void LLPrimitive::setTE(const U8 index, const LLTextureEntry& te)
|
||||
{
|
||||
mTextureList[index] = te;
|
||||
mTextureList.copyTexture(index, te);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTETexture(const U8 te, const LLUUID &tex_id)
|
||||
S32 LLPrimitive::setTETexture(const U8 index, const LLUUID &id)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setID(tex_id);
|
||||
return mTextureList.setID(index, id);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEColor(const U8 te, const LLColor4 &color)
|
||||
S32 LLPrimitive::setTEColor(const U8 index, const LLColor4 &color)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setColor(color);
|
||||
return mTextureList.setColor(index, color);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEColor(const U8 te, const LLColor3 &color)
|
||||
S32 LLPrimitive::setTEColor(const U8 index, const LLColor3 &color)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setColor(color);
|
||||
return mTextureList.setColor(index, color);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEAlpha(const U8 te, const F32 alpha)
|
||||
S32 LLPrimitive::setTEAlpha(const U8 index, const F32 alpha)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setAlpha(alpha);
|
||||
return mTextureList.setAlpha(index, alpha);
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
S32 LLPrimitive::setTEScale(const U8 te, const F32 s, const F32 t)
|
||||
S32 LLPrimitive::setTEScale(const U8 index, const F32 s, const F32 t)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "Setting nonexistent face" << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setScale(s,t);
|
||||
return mTextureList.setScale(index, s, t);
|
||||
}
|
||||
|
||||
|
||||
// BUG: slow - done this way because texture entries have some
|
||||
// voodoo related to texture coords
|
||||
S32 LLPrimitive::setTEScaleS(const U8 te, const F32 s)
|
||||
S32 LLPrimitive::setTEScaleS(const U8 index, const F32 s)
|
||||
{
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "Setting nonexistent face" << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
F32 ignore, t;
|
||||
mTextureList[te].getScale(&ignore, &t);
|
||||
return mTextureList[te].setScale(s,t);
|
||||
return mTextureList.setScaleS(index, s);
|
||||
}
|
||||
|
||||
|
||||
// BUG: slow - done this way because texture entries have some
|
||||
// voodoo related to texture coords
|
||||
S32 LLPrimitive::setTEScaleT(const U8 te, const F32 t)
|
||||
S32 LLPrimitive::setTEScaleT(const U8 index, const F32 t)
|
||||
{
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "Setting nonexistent face" << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
F32 s, ignore;
|
||||
mTextureList[te].getScale(&s, &ignore);
|
||||
return mTextureList[te].setScale(s,t);
|
||||
return mTextureList.setScaleT(index, t);
|
||||
}
|
||||
|
||||
|
||||
//===============================================================
|
||||
S32 LLPrimitive::setTEOffset(const U8 te, const F32 s, const F32 t)
|
||||
S32 LLPrimitive::setTEOffset(const U8 index, const F32 s, const F32 t)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "Setting nonexistent face" << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setOffset(s,t);
|
||||
return mTextureList.setOffset(index, s, t);
|
||||
}
|
||||
|
||||
|
||||
// BUG: slow - done this way because texture entries have some
|
||||
// voodoo related to texture coords
|
||||
S32 LLPrimitive::setTEOffsetS(const U8 te, const F32 s)
|
||||
S32 LLPrimitive::setTEOffsetS(const U8 index, const F32 s)
|
||||
{
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "Setting nonexistent face" << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
F32 ignore, t;
|
||||
mTextureList[te].getOffset(&ignore, &t);
|
||||
return mTextureList[te].setOffset(s,t);
|
||||
return mTextureList.setOffsetS(index, s);
|
||||
}
|
||||
|
||||
|
||||
// BUG: slow - done this way because texture entries have some
|
||||
// voodoo related to texture coords
|
||||
S32 LLPrimitive::setTEOffsetT(const U8 te, const F32 t)
|
||||
S32 LLPrimitive::setTEOffsetT(const U8 index, const F32 t)
|
||||
{
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "Setting nonexistent face" << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
F32 s, ignore;
|
||||
mTextureList[te].getOffset(&s, &ignore);
|
||||
return mTextureList[te].setOffset(s,t);
|
||||
return mTextureList.setOffsetT(index, t);
|
||||
}
|
||||
|
||||
|
||||
//===============================================================
|
||||
S32 LLPrimitive::setTERotation(const U8 te, const F32 r)
|
||||
S32 LLPrimitive::setTERotation(const U8 index, const F32 r)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "Setting nonexistent face" << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setRotation(r);
|
||||
return mTextureList.setRotation(index, r);
|
||||
}
|
||||
|
||||
|
||||
//===============================================================
|
||||
S32 LLPrimitive::setTEBumpShinyFullbright(const U8 te, const U8 bump)
|
||||
S32 LLPrimitive::setTEBumpShinyFullbright(const U8 index, const U8 bump)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setBumpShinyFullbright( bump );
|
||||
return mTextureList.setBumpShinyFullbright(index, bump);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEMediaTexGen(const U8 te, const U8 media)
|
||||
S32 LLPrimitive::setTEMediaTexGen(const U8 index, const U8 media)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setMediaTexGen( media );
|
||||
return mTextureList.setMediaTexGen(index, media);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEBumpmap(const U8 te, const U8 bump)
|
||||
S32 LLPrimitive::setTEBumpmap(const U8 index, const U8 bump)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setBumpmap( bump );
|
||||
return mTextureList.setBumpMap(index, bump);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEBumpShiny(const U8 te, const U8 bump_shiny)
|
||||
S32 LLPrimitive::setTEBumpShiny(const U8 index, const U8 bump_shiny)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setBumpShiny( bump_shiny );
|
||||
return mTextureList.setBumpShiny(index, bump_shiny);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTETexGen(const U8 te, const U8 texgen)
|
||||
S32 LLPrimitive::setTETexGen(const U8 index, const U8 texgen)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setTexGen( texgen );
|
||||
return mTextureList.setTexGen(index, texgen);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEShiny(const U8 te, const U8 shiny)
|
||||
S32 LLPrimitive::setTEShiny(const U8 index, const U8 shiny)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setShiny( shiny );
|
||||
return mTextureList.setShiny(index, shiny);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEFullbright(const U8 te, const U8 fullbright)
|
||||
S32 LLPrimitive::setTEFullbright(const U8 index, const U8 fullbright)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setFullbright( fullbright );
|
||||
return mTextureList.setFullbright(index, fullbright);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEMediaFlags(const U8 te, const U8 media_flags)
|
||||
S32 LLPrimitive::setTEMediaFlags(const U8 index, const U8 media_flags)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setMediaFlags( media_flags );
|
||||
return mTextureList.setMediaFlags(index, media_flags);
|
||||
}
|
||||
|
||||
S32 LLPrimitive::setTEGlow(const U8 te, const F32 glow)
|
||||
S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow)
|
||||
{
|
||||
// if we're asking for a non-existent face, return null
|
||||
if (te >= mNumTEs)
|
||||
{
|
||||
llwarns << "setting non-existent te " << te << llendl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mTextureList[te].setGlow( glow );
|
||||
return mTextureList.setGlow(index, glow);
|
||||
}
|
||||
|
||||
|
||||
@@ -878,25 +674,18 @@ std::string LLPrimitive::pCodeToString(const LLPCode pcode)
|
||||
void LLPrimitive::copyTEs(const LLPrimitive *primitivep)
|
||||
{
|
||||
U32 i;
|
||||
if (primitivep->getNumTEs() != getNumTEs())
|
||||
if (primitivep->getExpectedNumTEs() != getExpectedNumTEs())
|
||||
{
|
||||
llwarns << "Primitives don't have same number of TE's" << llendl;
|
||||
llwarns << "Primitives don't have same expected number of TE's" << llendl;
|
||||
}
|
||||
U32 num_tes = llmin(primitivep->getExpectedNumTEs(), getExpectedNumTEs());
|
||||
if (mTextureList.size() < getExpectedNumTEs())
|
||||
{
|
||||
mTextureList.setSize(getExpectedNumTEs());
|
||||
}
|
||||
U32 num_tes = llmin(primitivep->getNumTEs(), getNumTEs());
|
||||
for (i = 0; i < num_tes; i++)
|
||||
{
|
||||
const LLTextureEntry *tep = primitivep->getTE(i);
|
||||
F32 s, t;
|
||||
setTETexture(i, tep->getID());
|
||||
setTEColor(i, tep->getColor());
|
||||
tep->getScale(&s, &t);
|
||||
setTEScale(i, s, t);
|
||||
tep->getOffset(&s, &t);
|
||||
setTEOffset(i, s, t);
|
||||
setTERotation(i, tep->getRotation());
|
||||
setTEBumpShinyFullbright(i, tep->getBumpShinyFullbright());
|
||||
setTEMediaTexGen(i, tep->getMediaTexGen());
|
||||
setTEGlow(i, tep->getGlow());
|
||||
mTextureList.copyTexture(i, *(primitivep->getTE(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -958,16 +747,201 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
|
||||
|
||||
U32 old_face_mask = mVolumep->mFaceMask;
|
||||
|
||||
S32 face_bit = 0;
|
||||
S32 cur_mask = 0;
|
||||
|
||||
// Grab copies of the old faces from the original shape, ordered by type.
|
||||
// We will use these to figure out what old texture info gets mapped to new
|
||||
// faces in the new shape.
|
||||
std::vector<LLProfile::Face> old_faces;
|
||||
for (S32 face = 0; face < mVolumep->getNumFaces(); face++)
|
||||
{
|
||||
old_faces.push_back(mVolumep->getProfile().mFaces[face]);
|
||||
}
|
||||
|
||||
// Copy the old texture info off to the side, but not in the order in which
|
||||
// they live in the mTextureList, rather in order of ther "face id" which
|
||||
// is the corresponding value of LLVolueParams::LLProfile::mFaces::mIndex.
|
||||
//
|
||||
// Hence, some elements of old_tes::mEntryList will be invalid. It is
|
||||
// initialized to a size of 9 (max number of possible faces on a volume?)
|
||||
// and only the ones with valid types are filled in.
|
||||
LLPrimTextureList old_tes;
|
||||
old_tes.setSize(9);
|
||||
for (face_bit = 0; face_bit < 9; face_bit++)
|
||||
{
|
||||
cur_mask = 0x1 << face_bit;
|
||||
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)));
|
||||
//llinfos << face_bit << ":" << te_index << ":" << old_tes[face_bit].getID() << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// build the new object
|
||||
sVolumeManager->unrefVolume(mVolumep);
|
||||
mVolumep = volumep;
|
||||
|
||||
U32 new_face_mask = mVolumep->mFaceMask;
|
||||
if (old_face_mask != new_face_mask)
|
||||
U32 new_face_mask = mVolumep->mFaceMask;
|
||||
S32 i;
|
||||
|
||||
if (old_face_mask == new_face_mask)
|
||||
{
|
||||
// nothing to do
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (mVolumep->getNumFaces() == 0 && new_face_mask != 0)
|
||||
{
|
||||
llwarns << "Object with 0 faces found...INCORRECT!" << llendl;
|
||||
setNumTEs(mVolumep->getNumFaces());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// initialize face_mapping
|
||||
S32 face_mapping[9];
|
||||
for (face_bit = 0; face_bit < 9; face_bit++)
|
||||
{
|
||||
face_mapping[face_bit] = face_bit;
|
||||
}
|
||||
|
||||
// The new shape may have more faces than the original, but we can't just
|
||||
// add them to the end -- the ordering matters and it may be that we must
|
||||
// insert the new faces in the middle of the list. When we add a face it
|
||||
// will pick up the texture/color info of one of the old faces an so we
|
||||
// now figure out which old face info gets mapped to each new face, and
|
||||
// store in the face_mapping lookup table.
|
||||
for (face_bit = 0; face_bit < 9; face_bit++)
|
||||
{
|
||||
cur_mask = 0x1 << face_bit;
|
||||
if (!(new_face_mask & cur_mask))
|
||||
{
|
||||
// Face doesn't exist in new map.
|
||||
face_mapping[face_bit] = -1;
|
||||
continue;
|
||||
}
|
||||
else if (old_face_mask & cur_mask)
|
||||
{
|
||||
// Face exists in new and old map.
|
||||
face_mapping[face_bit] = face_bit;
|
||||
continue;
|
||||
}
|
||||
|
||||
// OK, how we've got a mismatch, where we have to fill a new face with one from
|
||||
// the old face.
|
||||
if (cur_mask & (LL_FACE_PATH_BEGIN | LL_FACE_PATH_END | LL_FACE_INNER_SIDE))
|
||||
{
|
||||
// It's a top/bottom/hollow interior face.
|
||||
if (old_face_mask & LL_FACE_PATH_END)
|
||||
{
|
||||
face_mapping[face_bit] = 1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
S32 cur_outer_mask = LL_FACE_OUTER_SIDE_0;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (old_face_mask & cur_outer_mask)
|
||||
{
|
||||
face_mapping[face_bit] = 5 + i;
|
||||
break;
|
||||
}
|
||||
cur_outer_mask <<= 1;
|
||||
}
|
||||
if (i == 4)
|
||||
{
|
||||
llwarns << "No path end or outer face in volume!" << llendl;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (cur_mask & (LL_FACE_PROFILE_BEGIN | LL_FACE_PROFILE_END))
|
||||
{
|
||||
// A cut slice. Use the hollow interior if we have it.
|
||||
if (old_face_mask & LL_FACE_INNER_SIDE)
|
||||
{
|
||||
face_mapping[face_bit] = 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
// No interior, use the bottom face.
|
||||
// Could figure out which of the outer faces was nearest, but that would be harder.
|
||||
if (old_face_mask & LL_FACE_PATH_END)
|
||||
{
|
||||
face_mapping[face_bit] = 1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
S32 cur_outer_mask = LL_FACE_OUTER_SIDE_0;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (old_face_mask & cur_outer_mask)
|
||||
{
|
||||
face_mapping[face_bit] = 5 + i;
|
||||
break;
|
||||
}
|
||||
cur_outer_mask <<= 1;
|
||||
}
|
||||
if (i == 4)
|
||||
{
|
||||
llwarns << "No path end or outer face in volume!" << llendl;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// OK, the face that's missing is an outer face...
|
||||
// Pull from the nearest adjacent outer face (there's always guaranteed to be one...
|
||||
S32 cur_outer = face_bit - 5;
|
||||
S32 min_dist = 5;
|
||||
S32 min_outer_bit = -1;
|
||||
S32 i;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (old_face_mask & (LL_FACE_OUTER_SIDE_0 << i))
|
||||
{
|
||||
S32 dist = abs(i - cur_outer);
|
||||
if (dist < min_dist)
|
||||
{
|
||||
min_dist = dist;
|
||||
min_outer_bit = i + 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (-1 == min_outer_bit)
|
||||
{
|
||||
llinfos << (LLVolume *)mVolumep << llendl;
|
||||
llwarns << "Bad! No outer faces, impossible!" << llendl;
|
||||
}
|
||||
face_mapping[face_bit] = min_outer_bit;
|
||||
}
|
||||
|
||||
|
||||
setNumTEs(mVolumep->getNumFaces());
|
||||
for (face_bit = 0; face_bit < 9; face_bit++)
|
||||
{
|
||||
// For each possible face type on the new shape we check to see if that
|
||||
// face exists and if it does we create a texture entry that is a copy
|
||||
// of one of the originals. Since the originals might not have a
|
||||
// matching face, we use the face_mapping lookup table to figure out
|
||||
// which face information to copy.
|
||||
cur_mask = 0x1 << face_bit;
|
||||
if (new_face_mask & cur_mask)
|
||||
{
|
||||
if (-1 == face_mapping[face_bit])
|
||||
{
|
||||
llwarns << "No mapping from old face to new face!" << llendl;
|
||||
}
|
||||
|
||||
S32 te_num = face_index_from_id(cur_mask, mVolumep->getProfile().mFaces);
|
||||
setTE(te_num, *(old_tes.getTexture(face_mapping[face_bit])));
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -984,50 +958,6 @@ BOOL LLPrimitive::setMaterial(U8 material)
|
||||
}
|
||||
}
|
||||
|
||||
void LLPrimitive::setTEArrays(const U8 size,
|
||||
const LLUUID* image_ids,
|
||||
const F32* scale_s,
|
||||
const F32* scale_t)
|
||||
{
|
||||
S32 cur_size = size;
|
||||
if (cur_size > getNumTEs())
|
||||
{
|
||||
llwarns << "Trying to set more TEs than exist!" << llendl;
|
||||
cur_size = getNumTEs();
|
||||
}
|
||||
|
||||
S32 i;
|
||||
// Copy over image information
|
||||
for (i = 0; i < cur_size; i++)
|
||||
{
|
||||
// This is very BAD!!!!!!
|
||||
if (image_ids != NULL)
|
||||
{
|
||||
setTETexture(i,image_ids[i]);
|
||||
}
|
||||
if (scale_s && scale_t)
|
||||
{
|
||||
setTEScale(i, scale_s[i], scale_t[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (i < getNumTEs())
|
||||
{
|
||||
cur_size--;
|
||||
for (i=i; i < getNumTEs(); i++) // the i=i removes a gcc warning
|
||||
{
|
||||
if (image_ids != NULL)
|
||||
{
|
||||
setTETexture(i, image_ids[cur_size]);
|
||||
}
|
||||
if (scale_s && scale_t)
|
||||
{
|
||||
setTEScale(i, scale_s[cur_size], scale_t[cur_size]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const F32 LL_MAX_SCALE_S = 100.0f;
|
||||
const F32 LL_MAX_SCALE_T = 100.0f;
|
||||
S32 LLPrimitive::packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const
|
||||
@@ -1405,6 +1335,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, con
|
||||
color.mV[VALPHA] = F32(255 - coloru.mV[VALPHA]) / 255.f;
|
||||
|
||||
retval |= setTEColor(i, color);
|
||||
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -1504,11 +1435,24 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
|
||||
return retval;
|
||||
}
|
||||
|
||||
void LLPrimitive::setTextureList(LLTextureEntry *listp)
|
||||
U8 LLPrimitive::getExpectedNumTEs() const
|
||||
{
|
||||
LLTextureEntry* old_texture_list = mTextureList;
|
||||
mTextureList = listp;
|
||||
delete[] old_texture_list;
|
||||
U8 expected_face_count = 0;
|
||||
if (mVolumep)
|
||||
{
|
||||
expected_face_count = mVolumep->getNumFaces();
|
||||
}
|
||||
return expected_face_count;
|
||||
}
|
||||
|
||||
void LLPrimitive::copyTextureList(const LLPrimTextureList& other_list)
|
||||
{
|
||||
mTextureList.copy(other_list);
|
||||
}
|
||||
|
||||
void LLPrimitive::takeTextureList(LLPrimTextureList& other_list)
|
||||
{
|
||||
mTextureList.take(other_list);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
Reference in New Issue
Block a user