diff options
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rwxr-xr-x | indra/newview/llfloatermodelpreview.cpp | 219 |
1 files changed, 88 insertions, 131 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 660157df1e..87ada50e9a 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -258,6 +258,7 @@ LLFloater(key) mLastMouseX = 0; mLastMouseY = 0; mGLName = 0; + mStatusLock = new LLMutex(NULL); } //----------------------------------------------------------------------------- @@ -304,6 +305,8 @@ BOOL LLFloaterModelPreview::postBuild() childSetCommitCallback("lod_file_or_limit", refresh, this); childSetCommitCallback("physics_load_radio", refresh, this); + //childSetCommitCallback("physics_optimize", refresh, this); + //childSetCommitCallback("physics_use_hull", refresh, this); childDisable("upload_skin"); childDisable("upload_joints"); @@ -378,6 +381,9 @@ LLFloaterModelPreview::~LLFloaterModelPreview() { LLImageGL::deleteTextures(1, &mGLName ); } + + delete mStatusLock; + mStatusLock = NULL; } void LLFloaterModelPreview::onViewOptionChecked(const LLSD& userdata) @@ -538,9 +544,10 @@ void LLFloaterModelPreview::draw() childSetTextArg("prim_cost", "[PRIM_COST]", llformat("%d", mModelPreview->mResourceCost)); childSetTextArg("description_label", "[TEXTURES]", llformat("%d", mModelPreview->mTextureSet.size())); - if (mCurRequest.notNull()) + if (!mCurRequest.empty()) { - childSetTextArg("status", "[STATUS]", mCurRequest->mStatusMessage); + LLMutexLock lock(mStatusLock); + childSetTextArg("status", "[STATUS]", mStatusMessage); } U32 resource_cost = mModelPreview->mResourceCost*10; @@ -696,7 +703,22 @@ void LLFloaterModelPreview::onPhysicsParamCommit(LLUICtrl* ctrl, void* data) if (sInstance) { LLCDParam* param = (LLCDParam*) data; - sInstance->mDecompParams[param->mName] = ctrl->getValue(); + std::string name(param->mName); + sInstance->mDecompParams[name] = ctrl->getValue(); + + if (name == "Simplify Method") + { + if (ctrl->getValue().asInteger() == 0) + { + sInstance->childSetVisible("Retain%", true); + sInstance->childSetVisible("Detail Scale", false); + } + else + { + sInstance->childSetVisible("Retain%", false); + sInstance->childSetVisible("Detail Scale", true); + } + } } } @@ -705,11 +727,9 @@ void LLFloaterModelPreview::onPhysicsStageExecute(LLUICtrl* ctrl, void* data) { LLCDStageData* stage = (LLCDStageData*) data; - LLModel* mdl = NULL; - if (sInstance) { - if (sInstance->mCurRequest.notNull()) + if (!sInstance->mCurRequest.empty()) { llinfos << "Decomposition request still pending." << llendl; return; @@ -717,36 +737,15 @@ void LLFloaterModelPreview::onPhysicsStageExecute(LLUICtrl* ctrl, void* data) if (sInstance->mModelPreview) { - S32 idx = sInstance->childGetValue("physics_layer").asInteger(); - if (idx >= 0 && idx < sInstance->mModelPreview->mModel[LLModel::LOD_PHYSICS].size()) + for (S32 i = 0; i < sInstance->mModelPreview->mModel[LLModel::LOD_PHYSICS].size(); ++i) { - mdl = sInstance->mModelPreview->mModel[LLModel::LOD_PHYSICS][idx]; + LLModel* mdl = sInstance->mModelPreview->mModel[LLModel::LOD_PHYSICS][i]; + DecompRequest* request = new DecompRequest(stage->mName, mdl); + sInstance->mCurRequest.insert(request); + gMeshRepo.mDecompThread->submitRequest(request); } } } - - if (mdl) - { - sInstance->mCurRequest = new DecompRequest(stage->mName, mdl); - gMeshRepo.mDecompThread->submitRequest(sInstance->mCurRequest); - } - - const std::string decompose("Decompose"); - - if (decompose == stage->mName) - { //hide decompose panel and show simplify panel - sInstance->childSetVisible("physics step 2", false); - sInstance->childSetVisible("physics step 3", true); - } -} - -//static -void LLFloaterModelPreview::onPhysicsOptimize(LLUICtrl* ctrl, void *data) -{ - //hide step 1 panel and show step 2 panel + info - sInstance->childSetVisible("physics step 1", false); - sInstance->childSetVisible("physics step 2", true); - sInstance->childSetVisible("physics info", true); } //static @@ -768,29 +767,16 @@ void LLFloaterModelPreview::onPhysicsUseLOD(LLUICtrl* ctrl, void* userdata) sInstance->mModelPreview->setPhysicsFromLOD(which_mode); } -//static -void LLFloaterModelPreview::onPhysicsDecomposeBack(LLUICtrl* ctrl, void* userdata) -{ - //hide step 2 panel and info and show step 1 panel - sInstance->childSetVisible("physics step 1", true); - sInstance->childSetVisible("physics step 2", false); - sInstance->childSetVisible("physics info", false); -} - -//static -void LLFloaterModelPreview::onPhysicsSimplifyBack(LLUICtrl* ctrl, void* userdata) -{ - //hide step 3 panel and show step 2 panel - sInstance->childSetVisible("physics step 3", false); - sInstance->childSetVisible("physics step 2", true); -} - //static void LLFloaterModelPreview::onPhysicsStageCancel(LLUICtrl* ctrl, void*data) { - if (sInstance && sInstance->mCurRequest.notNull()) + if (sInstance) { - sInstance->mCurRequest->mContinue = 0; + for (std::set<LLPointer<DecompRequest> >::iterator iter = sInstance->mCurRequest.begin(); + iter != sInstance->mCurRequest.end(); ++iter) + { + (*iter)->mContinue = 0; + } } } @@ -801,10 +787,6 @@ void LLFloaterModelPreview::initDecompControls() childSetCommitCallback("cancel_btn", onPhysicsStageCancel, NULL); childSetCommitCallback("physics_lod_combo", onPhysicsUseLOD, NULL); childSetCommitCallback("physics_browse", onPhysicsBrowse, NULL); - childSetCommitCallback("physics_optimize", onPhysicsOptimize, NULL); - childSetCommitCallback("decompose_back", onPhysicsDecomposeBack, NULL); - childSetCommitCallback("simplify_back", onPhysicsSimplifyBack, NULL); - childSetCommitCallback("physics_layer", refresh, NULL); static const LLCDStageData* stage = NULL; static S32 stage_count = 0; @@ -919,7 +901,6 @@ void LLFloaterModelPreview::initDecompControls() } } - childSetCommitCallback("physics_layer", LLFloaterModelPreview::refresh, LLFloaterModelPreview::sInstance); childSetCommitCallback("physics_explode", LLFloaterModelPreview::onExplodeCommit, this); } @@ -2225,20 +2206,6 @@ void LLModelPreview::rebuildUploadData() scale_spinner->setValue(max_import_scale); } - //refill "layer" combo in physics panel - LLComboBox* combo_box = mFMP->getChild<LLComboBox>("physics_layer"); - if (combo_box) - { - S32 current = combo_box->getCurrentIndex(); - combo_box->removeall(); - - for (S32 i = 0; i < mBaseModel.size(); ++i) - { - LLModel* mdl = mBaseModel[i]; - combo_box->add(mdl->mLabel, i); - } - combo_box->setCurrentByIndex(current); - } } @@ -3216,14 +3183,6 @@ void LLModelPreview::updateStatusMessages() S32 start = 0; S32 end = mModel[LLModel::LOD_PHYSICS].size(); - S32 idx = mFMP->childGetValue("physics_layer").asInteger(); - - if (idx >= 0 && idx < mModel[LLModel::LOD_PHYSICS].size()) - { - start = idx; - end = idx+1; - } - S32 phys_tris = 0; S32 phys_hulls = 0; S32 phys_points = 0; @@ -3289,6 +3248,32 @@ void LLModelPreview::updateStatusMessages() fmp->disableViewOption("show_physics"); fmp->setViewOption("show_physics", false); } + + //bool use_hull = fmp->childGetValue("physics_use_hull").asBoolean(); + + //fmp->childSetEnabled("physics_optimize", !use_hull); + + bool enable = phys_tris > 0 || phys_hulls > 0; + //enable = enable && !use_hull && fmp->childGetValue("physics_optimize").asBoolean(); + + //enable/disable "analysis" UI + LLPanel* panel = fmp->getChild<LLPanel>("physics analysis"); + LLView* child = panel->getFirstChild(); + while (child) + { + child->setEnabled(enable); + child = panel->findNextSibling(child); + } + + enable = phys_hulls > 0; + //enable/disable "simplification" UI + panel = fmp->getChild<LLPanel>("physics simplification"); + child = panel->getFirstChild(); + while (child) + { + child->setEnabled(enable); + child = panel->findNextSibling(child); + } } const char* lod_controls[] = @@ -3736,8 +3721,6 @@ BOOL LLModelPreview::render() //genLODs(); } - S32 physics_idx = mFMP->childGetValue("physics_layer").asInteger(); - if (!mModel[mPreviewLOD].empty()) { bool regen = mVertexBuffer[mPreviewLOD].empty(); @@ -3819,13 +3802,6 @@ BOOL LLModelPreview::render() LLGLEnable blend(GL_BLEND); gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_ZERO); - LLModel* physics_model = NULL; - - if (physics_idx >= 0 && physics_idx < mModel[LLModel::LOD_PHYSICS].size() ) - { - physics_model = mModel[LLModel::LOD_PHYSICS][physics_idx]; - } - for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) { LLModelInstance& instance = *iter; @@ -3853,7 +3829,7 @@ BOOL LLModelPreview::render() std::map<LLPointer<LLModel>, std::vector<LLPointer<LLVertexBuffer> > >::iterator iter = mPhysicsMesh.find(model); if (iter != mPhysicsMesh.end()) - { + { //render hull instead of mesh render_mesh = false; for (U32 i = 0; i < iter->second.size(); ++i) { @@ -3881,16 +3857,6 @@ BOOL LLModelPreview::render() glColor4ubv(hull_colors[i].mV); buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts()); - - if (edges) - { - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glLineWidth(3.f); - glColor4ub(hull_colors[i].mV[0]/2, hull_colors[i].mV[1]/2, hull_colors[i].mV[2]/2, 255); - buff->drawArrays(LLRender::TRIANGLES, 0, buff->getNumVerts()); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glLineWidth(1.f); - } } if (explode > 0.f) @@ -3913,40 +3879,19 @@ BOOL LLModelPreview::render() buffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0); - if (textures) - { - glColor4fv(instance.mMaterial[i].mDiffuseColor.mV); - if (i < instance.mMaterial.size() && instance.mMaterial[i].mDiffuseMap.notNull()) - { - gGL.getTexUnit(0)->bind(instance.mMaterial[i].mDiffuseMap, true); - if (instance.mMaterial[i].mDiffuseMap->getDiscardLevel() > -1) - { - mTextureSet.insert(instance.mMaterial[i].mDiffuseMap); - } - } - } - else - { - glColor4f(1,1,1,1); - } - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - glColor3f(0.4f, 0.4f, 0.4f); - - if (edges || model == physics_model) - { - if (model == physics_model) - { - glColor3f(1.f, 1.f, 0.f); - } + glColor4f(0.4f, 0.4f, 0.0f, 0.4f); + + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); - glLineWidth(3.f); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glLineWidth(1.f); - } + glColor3f(1.f, 1.f, 0.f); + + glLineWidth(3.f); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glLineWidth(1.f); } } @@ -4190,6 +4135,7 @@ LLFloaterModelPreview::DecompRequest::DecompRequest(const std::string& stage, LL mStage = stage; mContinue = 1; mModel = mdl; + mDecompID = &mdl->mDecompID; mParams = sInstance->mDecompParams; //copy out positions and indices @@ -4224,14 +4170,25 @@ LLFloaterModelPreview::DecompRequest::DecompRequest(const std::string& stage, LL } } +void LLFloaterModelPreview::setStatusMessage(const std::string& msg) +{ + LLMutexLock lock(mStatusLock); + mStatusMessage = msg; +} + S32 LLFloaterModelPreview::DecompRequest::statusCallback(const char* status, S32 p1, S32 p2) { setStatusMessage(llformat("%s: %d/%d", status, p1, p2)); + if (LLFloaterModelPreview::sInstance) + { + LLFloaterModelPreview::sInstance->setStatusMessage(mStatusMessage); + } + return mContinue; } void LLFloaterModelPreview::DecompRequest::completed() -{ +{ //called from the main thread mModel->setConvexHullDecomposition(mHull); if (sInstance) @@ -4243,6 +4200,6 @@ void LLFloaterModelPreview::DecompRequest::completed() LLFloaterModelPreview::sInstance->mModelPreview->refresh(); } - sInstance->mCurRequest = NULL; + sInstance->mCurRequest.erase(this); } } |