summaryrefslogtreecommitdiff
path: root/indra/newview/llmodelpreview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llmodelpreview.cpp')
-rw-r--r--indra/newview/llmodelpreview.cpp95
1 files changed, 59 insertions, 36 deletions
diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp
index c0de12f58e..04a818b2a4 100644
--- a/indra/newview/llmodelpreview.cpp
+++ b/indra/newview/llmodelpreview.cpp
@@ -127,6 +127,20 @@ std::string stripSuffix(std::string name)
return name;
}
+std::string getLodSuffix(S32 lod)
+{
+ std::string suffix;
+ switch (lod)
+ {
+ case LLModel::LOD_IMPOSTOR: suffix = "_LOD0"; break;
+ case LLModel::LOD_LOW: suffix = "_LOD1"; break;
+ case LLModel::LOD_MEDIUM: suffix = "_LOD2"; break;
+ case LLModel::LOD_PHYSICS: suffix = "_PHYS"; break;
+ case LLModel::LOD_HIGH: break;
+ }
+ return suffix;
+}
+
void FindModel(LLModelLoader::scene& scene, const std::string& name_to_match, LLModel*& baseModelOut, LLMatrix4& matOut)
{
LLModelLoader::scene::iterator base_iter = scene.begin();
@@ -181,6 +195,7 @@ LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp)
mDirty = false;
mGenLOD = false;
mLoading = false;
+ mLookUpLodFiles = false;
mLoadState = LLModelLoader::STARTING;
mGroup = 0;
mLODFrozen = false;
@@ -421,15 +436,7 @@ void LLModelPreview::rebuildUploadData()
extensionLOD = mPhysicsSearchLOD;
}
- std::string toAdd;
- switch (extensionLOD)
- {
- case LLModel::LOD_IMPOSTOR: toAdd = "_LOD0"; break;
- case LLModel::LOD_LOW: toAdd = "_LOD1"; break;
- case LLModel::LOD_MEDIUM: toAdd = "_LOD2"; break;
- case LLModel::LOD_PHYSICS: toAdd = "_PHYS"; break;
- case LLModel::LOD_HIGH: break;
- }
+ std::string toAdd = getLodSuffix(extensionLOD);
if (name_to_match.find(toAdd) == -1)
{
@@ -456,15 +463,7 @@ void LLModelPreview::rebuildUploadData()
std::string name_to_match = instance.mLabel;
llassert(!name_to_match.empty());
- std::string toAdd;
- switch (searchLOD)
- {
- case LLModel::LOD_IMPOSTOR: toAdd = "_LOD0"; break;
- case LLModel::LOD_LOW: toAdd = "_LOD1"; break;
- case LLModel::LOD_MEDIUM: toAdd = "_LOD2"; break;
- case LLModel::LOD_PHYSICS: toAdd = "_PHYS"; break;
- case LLModel::LOD_HIGH: break;
- }
+ std::string toAdd = getLodSuffix(searchLOD);
if (name_to_match.find(toAdd) == -1)
{
@@ -1168,14 +1167,7 @@ void LLModelPreview::loadModelCallback(S32 loaded_lod)
if (loaded_name != name)
{
- switch (loaded_lod)
- {
- case LLModel::LOD_IMPOSTOR: name += "_LOD0"; break;
- case LLModel::LOD_LOW: name += "_LOD1"; break;
- case LLModel::LOD_MEDIUM: name += "_LOD2"; break;
- case LLModel::LOD_PHYSICS: name += "_PHYS"; break;
- case LLModel::LOD_HIGH: break;
- }
+ name += getLodSuffix(loaded_lod);
if (mImporterDebug)
{
@@ -1578,16 +1570,7 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim
volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
mModel[lod][mdl_idx] = new LLModel(volume_params, 0.f);
- std::string name = base->mLabel;
-
- switch (lod)
- {
- case LLModel::LOD_IMPOSTOR: name += "_LOD0"; break;
- case LLModel::LOD_LOW: name += "_LOD1"; break;
- case LLModel::LOD_MEDIUM: name += "_LOD2"; break;
- case LLModel::LOD_PHYSICS: name += "_PHYS"; break;
- case LLModel::LOD_HIGH: break;
- }
+ std::string name = base->mLabel + getLodSuffix(lod);
mModel[lod][mdl_idx]->mLabel = name;
mModel[lod][mdl_idx]->mSubmodelID = base->mSubmodelID;
@@ -2607,10 +2590,45 @@ void LLModelPreview::loadedCallback(
}
pPreview->mModelLoader->clearLog();
pPreview->loadModelCallback(lod); // removes mModelLoader in some cases
+ if (pPreview->mLookUpLodFiles && (lod != LLModel::LOD_HIGH))
+ {
+ pPreview->lookupLODModelFiles(lod);
+ }
}
}
+void LLModelPreview::lookupLODModelFiles(S32 lod)
+{
+ if (lod == LLModel::LOD_PHYSICS)
+ {
+ mLookUpLodFiles = false;
+ return;
+ }
+ S32 next_lod = (lod - 1 >= LLModel::LOD_IMPOSTOR) ? lod - 1 : LLModel::LOD_PHYSICS;
+
+ std::string lod_filename = mLODFile[LLModel::LOD_HIGH];
+ std::string ext = ".dae";
+ std::string::size_type i = lod_filename.rfind(ext);
+ if (i != std::string::npos)
+ {
+ lod_filename.replace(i, lod_filename.size() - ext.size(), getLodSuffix(next_lod) + ext);
+ }
+ if (gDirUtilp->fileExists(lod_filename))
+ {
+ LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance;
+ if (fmp)
+ {
+ fmp->setCtrlLoadFromFile(next_lod);
+ }
+ loadModel(lod_filename, next_lod);
+ }
+ else
+ {
+ lookupLODModelFiles(next_lod);
+ }
+}
+
void LLModelPreview::stateChangedCallback(U32 state, void* opaque)
{
LLModelPreview* pPreview = static_cast< LLModelPreview* >(opaque);
@@ -3509,6 +3527,11 @@ bool LLModelPreview::lodQueryCallback()
preview->mLodsQuery.pop_back();
preview->genLODs(lod);
+ if (preview->mLookUpLodFiles && (lod == LLModel::LOD_HIGH))
+ {
+ preview->lookupLODModelFiles(LLModel::LOD_HIGH);
+ }
+
// return false to continue cycle
return false;
}