summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfloatermodelpreview.cpp26
-rw-r--r--indra/newview/llfloatermodelpreview.h4
-rw-r--r--indra/newview/llmodelpreview.cpp95
-rw-r--r--indra/newview/llmodelpreview.h3
-rw-r--r--indra/newview/llviewermenufile.cpp2
5 files changed, 93 insertions, 37 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index a52cf981c7..f667116ca4 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -395,6 +395,12 @@ void LLFloaterModelPreview::disableViewOption(const std::string& option)
setViewOptionEnabled(option, false);
}
+void LLFloaterModelPreview::loadHighLodModel()
+{
+ mModelPreview->mLookUpLodFiles = true;
+ loadModel(3);
+}
+
void LLFloaterModelPreview::loadModel(S32 lod)
{
mModelPreview->mLoading = true;
@@ -1593,6 +1599,26 @@ LLFloaterModelPreview::DecompRequest::DecompRequest(const std::string& stage, LL
assignData(mdl) ;
}
+void LLFloaterModelPreview::setCtrlLoadFromFile(S32 lod)
+{
+ if (lod == LLModel::LOD_PHYSICS)
+ {
+ LLComboBox* lod_combo = findChild<LLComboBox>("physics_lod_combo");
+ if (lod_combo)
+ {
+ lod_combo->setCurrentByIndex(5);
+ }
+ }
+ else
+ {
+ LLComboBox* lod_combo = findChild<LLComboBox>("lod_source_" + lod_name[lod]);
+ if (lod_combo)
+ {
+ lod_combo->setCurrentByIndex(0);
+ }
+ }
+}
+
void LLFloaterModelPreview::setStatusMessage(const std::string& msg)
{
LLMutexLock lock(mStatusLock);
diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h
index 7b344ef2b2..bee64fb501 100644
--- a/indra/newview/llfloatermodelpreview.h
+++ b/indra/newview/llfloatermodelpreview.h
@@ -102,6 +102,8 @@ public:
void loadModel(S32 lod);
void loadModel(S32 lod, const std::string& file_name, bool force_disable_slm = false);
+
+ void loadHighLodModel();
void onViewOptionChecked(LLUICtrl* ctrl);
void onUploadOptionChecked(LLUICtrl* ctrl);
@@ -174,6 +176,8 @@ protected:
void setStatusMessage(const std::string& msg);
void addStringToLogTab(const std::string& str, bool flash);
+ void setCtrlLoadFromFile(S32 lod);
+
LLModelPreview* mModelPreview;
LLPhysicsDecomp::decomp_params mDecompParams;
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;
}
diff --git a/indra/newview/llmodelpreview.h b/indra/newview/llmodelpreview.h
index 4c03849d6b..9b8200ab8a 100644
--- a/indra/newview/llmodelpreview.h
+++ b/indra/newview/llmodelpreview.h
@@ -206,6 +206,8 @@ protected:
static LLJoint* lookupJointByName(const std::string&, void* opaque);
static U32 loadTextures(LLImportMaterial& material, void* opaque);
+ void lookupLODModelFiles(S32 lod);
+
private:
//Utility function for controller vertex compare
bool verifyCount(int expected, int result);
@@ -243,6 +245,7 @@ protected:
U32 mLoadState;
bool mResetJoints;
bool mModelNoErrors;
+ bool mLookUpLodFiles;
std::map<std::string, bool> mViewOption;
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index d1d3a7fc12..7706828cec 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -552,7 +552,7 @@ class LLFileUploadModel : public view_listener_t
LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) LLFloaterReg::getInstance("upload_model");
if (fmp && !fmp->isModelLoading())
{
- fmp->loadModel(3);
+ fmp->loadHighLodModel();
}
return TRUE;