summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermodelpreview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rwxr-xr-xindra/newview/llfloatermodelpreview.cpp100
1 files changed, 64 insertions, 36 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 2f59621e28..0f2924d8aa 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -276,7 +276,10 @@ BOOL LLFloaterModelPreview::postBuild()
return FALSE;
}
- setViewOption("show_textures", true);
+
+
+
+
childSetAction("lod_browse", onBrowseLOD, this);
@@ -394,13 +397,22 @@ LLFloaterModelPreview::~LLFloaterModelPreview()
void LLFloaterModelPreview::onViewOptionChecked(const LLSD& userdata)
{
- mViewOption[userdata.asString()] = !mViewOption[userdata.asString()];
- mModelPreview->refresh();
+ if (mModelPreview)
+ {
+ mModelPreview->mViewOption[userdata.asString()] = !mModelPreview->mViewOption[userdata.asString()];
+
+ mModelPreview->refresh();
+ }
}
bool LLFloaterModelPreview::isViewOptionChecked(const LLSD& userdata)
{
- return mViewOption[userdata.asString()];
+ if (mModelPreview)
+ {
+ return mModelPreview->mViewOption[userdata.asString()];
+ }
+
+ return false;
}
bool LLFloaterModelPreview::isViewOptionEnabled(const LLSD& userdata)
@@ -423,11 +435,6 @@ void LLFloaterModelPreview::disableViewOption(const std::string& option)
setViewOptionEnabled(option, false);
}
-void LLFloaterModelPreview::setViewOption(const std::string& option, bool value)
-{
- mViewOption[option] = value;
-}
-
void LLFloaterModelPreview::loadModel(S32 lod)
{
mModelPreview->mLoading = true;
@@ -1633,6 +1640,35 @@ void LLModelLoader::run()
}
}
+//called in the main thread
+void LLModelLoader::loadTextures()
+{
+ BOOL is_paused = isPaused() ;
+ pause() ; //pause the loader
+
+ for(scene::iterator iter = mScene.begin(); iter != mScene.end(); ++iter)
+ {
+ for(U32 i = 0 ; i < iter->second.size(); i++)
+ {
+ for(U32 j = 0 ; j < iter->second[i].mMaterial.size() ; j++)
+ {
+ if(!iter->second[i].mMaterial[j].mDiffuseMapFilename.empty())
+ {
+ iter->second[i].mMaterial[j].mDiffuseMap =
+ LLViewerTextureManager::getFetchedTextureFromUrl("file://" + iter->second[i].mMaterial[j].mDiffuseMapFilename, TRUE, LLViewerTexture::BOOST_PREVIEW);
+ iter->second[i].mMaterial[j].mDiffuseMap->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, TRUE, FALSE, mPreview, NULL, FALSE);
+ iter->second[i].mMaterial[j].mDiffuseMap->forceToSaveRawImage();
+ }
+ }
+ }
+ }
+
+ if(!is_paused)
+ {
+ unpause() ;
+ }
+}
+
bool LLModelLoader::isNodeAJoint( domNode* pNode )
{
if ( pNode->getName() == NULL)
@@ -1938,14 +1974,8 @@ LLImportMaterial LLModelLoader::profileToMaterial(domProfile_COMMON* material)
// we only support init_from now - embedded data will come later
domImage::domInit_from* init = image->getInit_from();
if (init)
- {
- std::string filename = cdom::uriToNativePath(init->getValue().str());
-
- mat.mDiffuseMap = LLViewerTextureManager::getFetchedTextureFromUrl("file://" + filename, TRUE, LLViewerTexture::BOOST_PREVIEW);
- mat.mDiffuseMap->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, TRUE, FALSE, this->mPreview, NULL, FALSE);
-
- mat.mDiffuseMap->forceToSaveRawImage();
- mat.mDiffuseMapFilename = filename;
+ {
+ mat.mDiffuseMapFilename = cdom::uriToNativePath(init->getValue().str());
mat.mDiffuseMapLabel = getElementLabel(material);
}
}
@@ -2062,6 +2092,8 @@ LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp)
mBuildBorderMode = GLOD_BORDER_UNLOCK;
mBuildOperator = GLOD_OPERATOR_EDGE_COLLAPSE;
+ mViewOption["show_textures"] = false;
+
mFMP = fmp;
glodInit();
@@ -2098,6 +2130,7 @@ U32 LLModelPreview::calcResourceCost()
F32 debug_scale = mFMP->childGetValue("import_scale").asReal();
F32 streaming_cost = 0.f;
+ F32 physics_cost = 0.f;
for (U32 i = 0; i < mUploadData.size(); ++i)
{
LLModelInstance& instance = mUploadData[i];
@@ -2152,6 +2185,7 @@ U32 LLModelPreview::calcResourceCost()
//mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[HULLS]", llformat("%d",num_hulls));
//mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[POINTS]", llformat("%d",num_points));
mFMP->childSetTextArg("streaming cost", "[COST]", llformat("%.3f", streaming_cost));
+ mFMP->childSetTextArg("physics cost", "[COST]", llformat("%.3f", physics_cost));
F32 scale = mFMP->childGetValue("import_scale").asReal()*2.f;
mFMP->childSetTextArg("import_dimensions", "[X]", llformat("%.3f", mPreviewScale[0]*scale));
mFMP->childSetTextArg("import_dimensions", "[Y]", llformat("%.3f", mPreviewScale[1]*scale));
@@ -2397,6 +2431,7 @@ void LLModelPreview::loadModelCallback(S32 lod)
return;
}
+ mModelLoader->loadTextures() ;
mModel[lod] = mModelLoader->mModelList;
mScene[lod] = mModelLoader->mScene;
mVertexBuffer[lod].clear();
@@ -3310,13 +3345,14 @@ void LLModelPreview::updateStatusMessages()
if (!fmp->isViewOptionEnabled("show_physics"))
{
fmp->enableViewOption("show_physics");
- fmp->setViewOption("show_physics", true);
+ mViewOption["show_physics"] = true;
}
}
else
{
fmp->disableViewOption("show_physics");
- fmp->setViewOption("show_physics", false);
+ mViewOption["show_physics"] = false;
+
}
//bool use_hull = fmp->childGetValue("physics_use_hull").asBoolean();
@@ -3641,21 +3677,11 @@ BOOL LLModelPreview::render()
LLMutexLock lock(this);
mNeedsUpdate = FALSE;
- bool edges = false;
- bool joint_positions = false;
- bool skin_weight = false;
- bool textures = false;
- bool physics = false;
-
- LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance;
- if (fmp)
- {
- edges = fmp->isViewOptionChecked("show_edges");
- joint_positions = fmp->isViewOptionChecked("show_joint_positions");
- skin_weight = fmp->isViewOptionChecked("show_skin_weight");
- textures = fmp->isViewOptionChecked("show_textures");
- physics = fmp->isViewOptionChecked("show_physics");
- }
+ bool edges = mViewOption["show_edges"];
+ bool joint_positions = mViewOption["show_joint_positions"];
+ bool skin_weight = mViewOption["show_skin_weight"];
+ bool textures = mViewOption["show_textures"];
+ bool physics = mViewOption["show_physics"];
S32 width = getWidth();
S32 height = getHeight();
@@ -3688,6 +3714,8 @@ BOOL LLModelPreview::render()
gGL.popMatrix();
}
+ LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance;
+
bool has_skin_weights = false;
bool upload_skin = mFMP->childGetValue("upload_skin").asBoolean();
bool upload_joints = mFMP->childGetValue("upload_joints").asBoolean();
@@ -3719,7 +3747,7 @@ BOOL LLModelPreview::render()
mFMP->childDisable("upload_skin");
if (fmp)
{
- fmp->setViewOption("show_skin_weight", false);
+ mViewOption["show_skin_weight"] = false;
fmp->disableViewOption("show_skin_weight");
fmp->disableViewOption("show_joint_positions");
}
@@ -3848,7 +3876,7 @@ BOOL LLModelPreview::render()
gGL.getTexUnit(0)->bind(instance.mMaterial[i].mDiffuseMap, true);
if (instance.mMaterial[i].mDiffuseMap->getDiscardLevel() > -1)
{
- mTextureSet.insert(instance.mMaterial[i].mDiffuseMap);
+ mTextureSet.insert(instance.mMaterial[i].mDiffuseMap.get());
}
}
}