From 6175e8147ff85073c67de89f08e5ecea891e1ef8 Mon Sep 17 00:00:00 2001 From: leyla_linden Date: Tue, 21 Dec 2010 17:01:03 -0800 Subject: fixed wizard model not previewing issues and added pan/zoom --- indra/newview/llfloatermodelpreview.cpp | 50 +++++----- indra/newview/llfloatermodelwizard.cpp | 103 +++++++++++++++++++++ indra/newview/llfloatermodelwizard.h | 7 ++ .../skins/default/xui/en/floater_model_wizard.xml | 19 +--- 4 files changed, 138 insertions(+), 41 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 85d0ae02cf..0dc021c44b 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -3339,13 +3339,38 @@ void LLModelPreview::updateStatusMessages() } - else if (mFMP->childGetValue("lod_auto_generate").asBoolean()) + else if (mFMP->childGetValue("lod_none").asBoolean()) { for (U32 i = 0; i < num_file_controls; ++i) { mFMP->childDisable(file_controls[i]); } + for (U32 i = 0; i < num_lod_controls; ++i) + { + mFMP->childDisable(lod_controls[i]); + } + + if (!mModel[mPreviewLOD].empty()) + { + mModel[mPreviewLOD].clear(); + mScene[mPreviewLOD].clear(); + mVertexBuffer[mPreviewLOD].clear(); + + //this can cause phasing issues with the UI, so reenter this function and return + updateStatusMessages(); + return; + } + + + } + else + { // auto generate, also the default case for wizard which has no radio selection + for (U32 i = 0; i < num_file_controls; ++i) + { + mFMP->childDisable(file_controls[i]); + } + for (U32 i = 0; i < num_lod_controls; ++i) { mFMP->childEnable(lod_controls[i]); @@ -3380,29 +3405,6 @@ void LLModelPreview::updateStatusMessages() } } } - else - { // "None" is chosen - for (U32 i = 0; i < num_file_controls; ++i) - { - mFMP->childDisable(file_controls[i]); - } - - for (U32 i = 0; i < num_lod_controls; ++i) - { - mFMP->childDisable(lod_controls[i]); - } - - if (!mModel[mPreviewLOD].empty()) - { - mModel[mPreviewLOD].clear(); - mScene[mPreviewLOD].clear(); - mVertexBuffer[mPreviewLOD].clear(); - - //this can cause phasing issues with the UI, so reenter this function and return - updateStatusMessages(); - return; - } - } if (mFMP->childGetValue("physics_load_from_file").asBoolean()) { diff --git a/indra/newview/llfloatermodelwizard.cpp b/indra/newview/llfloatermodelwizard.cpp index 6a92e43d1a..aca5d67e60 100644 --- a/indra/newview/llfloatermodelwizard.cpp +++ b/indra/newview/llfloatermodelwizard.cpp @@ -36,6 +36,8 @@ #include "llfloatermodelpreview.h" #include "llfloaterreg.h" #include "llslider.h" +#include "lltoolmgr.h" +#include "llviewerwindow.h" static const std::string stateNames[]={ @@ -125,6 +127,107 @@ bool LLFloaterModelWizard::onEnableBack() return true; } + +//----------------------------------------------------------------------------- +// handleMouseDown() +//----------------------------------------------------------------------------- +BOOL LLFloaterModelWizard::handleMouseDown(S32 x, S32 y, MASK mask) +{ + if (mPreviewRect.pointInRect(x, y)) + { + bringToFront( x, y ); + gFocusMgr.setMouseCapture(this); + gViewerWindow->hideCursor(); + mLastMouseX = x; + mLastMouseY = y; + return TRUE; + } + + return LLFloater::handleMouseDown(x, y, mask); +} + +//----------------------------------------------------------------------------- +// handleMouseUp() +//----------------------------------------------------------------------------- +BOOL LLFloaterModelWizard::handleMouseUp(S32 x, S32 y, MASK mask) +{ + gFocusMgr.setMouseCapture(FALSE); + gViewerWindow->showCursor(); + return LLFloater::handleMouseUp(x, y, mask); +} + +//----------------------------------------------------------------------------- +// handleHover() +//----------------------------------------------------------------------------- +BOOL LLFloaterModelWizard::handleHover (S32 x, S32 y, MASK mask) +{ + MASK local_mask = mask & ~MASK_ALT; + + if (mModelPreview && hasMouseCapture()) + { + if (local_mask == MASK_PAN) + { + // pan here + mModelPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f); + } + else if (local_mask == MASK_ORBIT) + { + F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f; + F32 pitch_radians = (F32)(y - mLastMouseY) * 0.02f; + + mModelPreview->rotate(yaw_radians, pitch_radians); + } + else + { + + F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f; + F32 zoom_amt = (F32)(y - mLastMouseY) * 0.02f; + + mModelPreview->rotate(yaw_radians, 0.f); + mModelPreview->zoom(zoom_amt); + } + + + mModelPreview->refresh(); + + LLUI::setMousePositionLocal(this, mLastMouseX, mLastMouseY); + } + + if (!mPreviewRect.pointInRect(x, y) || !mModelPreview) + { + return LLFloater::handleHover(x, y, mask); + } + else if (local_mask == MASK_ORBIT) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLCAMERA); + } + else if (local_mask == MASK_PAN) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPAN); + } + else + { + gViewerWindow->setCursor(UI_CURSOR_TOOLZOOMIN); + } + + return TRUE; +} + +//----------------------------------------------------------------------------- +// handleScrollWheel() +//----------------------------------------------------------------------------- +BOOL LLFloaterModelWizard::handleScrollWheel(S32 x, S32 y, S32 clicks) +{ + if (mPreviewRect.pointInRect(x, y) && mModelPreview) + { + mModelPreview->zoom((F32)clicks * -0.2f); + mModelPreview->refresh(); + } + + return TRUE; +} + + BOOL LLFloaterModelWizard::postBuild() { LLView* preview_panel = getChild("preview_panel"); diff --git a/indra/newview/llfloatermodelwizard.h b/indra/newview/llfloatermodelwizard.h index ab69d93b63..b7fd28aa9d 100644 --- a/indra/newview/llfloatermodelwizard.h +++ b/indra/newview/llfloatermodelwizard.h @@ -36,6 +36,11 @@ public: /*virtual*/ BOOL postBuild(); void draw(); + BOOL handleMouseDown(S32 x, S32 y, MASK mask); + BOOL handleMouseUp(S32 x, S32 y, MASK mask); + BOOL handleHover(S32 x, S32 y, MASK mask); + BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); + private: enum EWizardState { @@ -62,6 +67,8 @@ private: LLRect mPreviewRect; int mState; + S32 mLastMouseX; + S32 mLastMouseY; }; diff --git a/indra/newview/skins/default/xui/en/floater_model_wizard.xml b/indra/newview/skins/default/xui/en/floater_model_wizard.xml index 18dc33a23a..f5eda05f1a 100644 --- a/indra/newview/skins/default/xui/en/floater_model_wizard.xml +++ b/indra/newview/skins/default/xui/en/floater_model_wizard.xml @@ -208,23 +208,8 @@ left="10" word_wrap="true"> Note: - Advanced users familiar with 3d content creation tools may prefer to use the Advanced Mesh Import window. +Advanced users familiar with 3d content creation tools may prefer to use the Advanced Mesh Import window. - - - High - - - Medium - - - Lowest - - - Low - - @@ -390,7 +375,7 @@ layout="topleft" left="220" max_val="2" - initial_vauel="1" + initial_value="1" min_val="0" name="accuracy_slider" show_text="false" -- cgit v1.2.3 From e1b1db9575945fa8436b4ebabf55242635b61f38 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Dec 2010 01:05:35 -0600 Subject: SH-636 Update physics tab to new spec, move "completed" physics decomp callbacks to main thread, add object model to decomposition tool, make imported model scales non-uniform. --- indra/newview/llfloatermodelpreview.cpp | 219 +++++++++------------ indra/newview/llfloatermodelpreview.h | 9 +- indra/newview/llmeshrepository.cpp | 55 ++++-- indra/newview/llmeshrepository.h | 10 + .../skins/default/xui/en/floater_model_preview.xml | 160 +++++++-------- 5 files changed, 215 insertions(+), 238 deletions(-) (limited to 'indra/newview') 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 >::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("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("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("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, std::vector > >::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); } } diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index e233f3672a..f7873cddbb 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -199,6 +199,8 @@ protected: void initDecompControls(); + void setStatusMessage(const std::string& msg); + LLModelPreview* mModelPreview; LLPhysicsDecomp::decomp_params mDecompParams; @@ -209,8 +211,9 @@ protected: U32 mGLName; static S32 sUploadAmount; - LLPointer mCurRequest; - + std::set > mCurRequest; + std::string mStatusMessage; + std::map mViewOption; //use "disabled" as false by default @@ -218,7 +221,7 @@ protected: LLMenuButton* mViewOptionMenuButton; LLToggleableMenu* mViewOptionMenu; - + LLMutex* mStatusLock; }; class LLMeshFilePicker : public LLFilePickerThread diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 4873eaeabd..861db7fd5d 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1396,6 +1396,7 @@ LLMeshUploadThread::DecompRequest::DecompRequest(LLModel* mdl, LLModel* base_mod { mStage = "single_hull"; mModel = mdl; + mDecompID = &mdl->mDecompID; mBaseModel = base_model; mThread = thread; @@ -2262,6 +2263,9 @@ void LLMeshRepository::notifyLoadedMeshes() mInventoryQ.pop(); } } + + //call completed callbacks on finished decompositions + mDecompThread->notifyCompleted(); if (!mThread->mWaiting) { //curl thread is churning, wait for it to go idle @@ -3229,9 +3233,8 @@ void LLPhysicsDecomp::doDecomposition() mCurRequest->mHullMesh.clear(); mCurRequest->setStatusMessage("FAIL"); - mCurRequest->completed(); - - mCurRequest = NULL; + + completeCurrent(); } else { @@ -3282,13 +3285,33 @@ void LLPhysicsDecomp::doDecomposition() LLMutexLock lock(mMutex); mCurRequest->setStatusMessage("FAIL"); - mCurRequest->completed(); - - mCurRequest = NULL; + completeCurrent(); + } + } +} + +void LLPhysicsDecomp::completeCurrent() +{ + LLMutexLock lock(mMutex); + mCompletedQ.push(mCurRequest); + mCurRequest = NULL; +} + +void LLPhysicsDecomp::notifyCompleted() +{ + if (!mCompletedQ.empty()) + { + LLMutexLock lock(mMutex); + while (!mCompletedQ.empty()) + { + Request* req = mCompletedQ.front(); + req->completed(); + mCompletedQ.pop(); } } } + void make_box(LLPhysicsDecomp::Request * request) { LLVector3 min,max; @@ -3406,18 +3429,17 @@ void LLPhysicsDecomp::doDecompositionSingleHull() { - LLMutexLock lock(mMutex); - mCurRequest->completed(); - mCurRequest = NULL; + completeCurrent(); + } } + void LLPhysicsDecomp::run() { - LLConvexDecomposition::getInstance()->initThread(); - mInited = true; - LLConvexDecomposition* decomp = LLConvexDecomposition::getInstance(); + decomp->initThread(); + mInited = true; static const LLCDStageData* stages = NULL; static S32 num_stages = 0; @@ -3443,6 +3465,13 @@ void LLPhysicsDecomp::run() mRequestQ.pop(); } + S32& id = *(mCurRequest->mDecompID); + if (id == -1) + { + decomp->genDecomposition(id); + } + decomp->bindDecomposition(id); + if (mCurRequest->mStage == "single_hull") { doDecompositionSingleHull(); @@ -3454,7 +3483,7 @@ void LLPhysicsDecomp::run() } } - LLConvexDecomposition::getInstance()->quitThread(); + decomp->quitThread(); //delete mSignal; delete mMutex; diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 8687ac750b..5b770994a8 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -157,6 +157,7 @@ public: { public: //input params + S32* mDecompID; std::string mStage; std::vector mPositions; std::vector mIndices; @@ -167,8 +168,12 @@ public: std::vector > mHullMesh; LLModel::convex_hull_decomposition mHull; + //status message callback, called from decomposition thread virtual S32 statusCallback(const char* status, S32 p1, S32 p2) = 0; + + //completed callback, called from the main thread virtual void completed() = 0; + virtual void setStatusMessage(const std::string& msg); }; @@ -193,6 +198,9 @@ public: void doDecompositionSingleHull(); virtual void run(); + + void completeCurrent(); + void notifyCompleted(); std::map mStageID; @@ -201,6 +209,8 @@ public: LLPointer mCurRequest; + std::queue > mCompletedQ; + }; class LLMeshRepoThread : public LLThread diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml index ee47e53db9..0fdcf486e7 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -64,7 +64,7 @@ Upload Details + bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3"> Resource Cost: [COST] @@ -222,30 +222,25 @@ label="Physics" name="physics_panel"> - + - - - Step 1: Geometry - - - - - + width="300" + height="80" + visible="true" + border="true" + bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3"> + + + + - -