summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermodelwizard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatermodelwizard.cpp')
-rw-r--r--indra/newview/llfloatermodelwizard.cpp303
1 files changed, 222 insertions, 81 deletions
diff --git a/indra/newview/llfloatermodelwizard.cpp b/indra/newview/llfloatermodelwizard.cpp
index 707c8288df..b517b78e5a 100644
--- a/indra/newview/llfloatermodelwizard.cpp
+++ b/indra/newview/llfloatermodelwizard.cpp
@@ -46,12 +46,21 @@ static const std::string stateNames[]={
"choose_file",
"optimize",
"physics",
- "physics2",
"review",
"upload"};
+static void swap_controls(LLUICtrl* first_ctrl, LLUICtrl* second_ctrl, bool first_ctr_visible);
+
LLFloaterModelWizard::LLFloaterModelWizard(const LLSD& key)
- : LLFloater(key)
+ : LLFloaterModelUploadBase(key)
+ ,mRecalculateGeometryBtn(NULL)
+ ,mRecalculatePhysicsBtn(NULL)
+ ,mRecalculatingPhysicsBtn(NULL)
+ ,mCalculateWeightsBtn(NULL)
+ ,mCalculatingWeightsBtn(NULL)
+ ,mChooseFilePreviewPanel(NULL)
+ ,mOptimizePreviewPanel(NULL)
+ ,mPhysicsPreviewPanel(NULL)
{
mLastEnabledState = CHOOSE_FILE;
sInstance = this;
@@ -59,7 +68,6 @@ LLFloaterModelWizard::LLFloaterModelWizard(const LLSD& key)
mCommitCallbackRegistrar.add("Wizard.Choose", boost::bind(&LLFloaterModelWizard::setState, this, CHOOSE_FILE));
mCommitCallbackRegistrar.add("Wizard.Optimize", boost::bind(&LLFloaterModelWizard::setState, this, OPTIMIZE));
mCommitCallbackRegistrar.add("Wizard.Physics", boost::bind(&LLFloaterModelWizard::setState, this, PHYSICS));
- mCommitCallbackRegistrar.add("Wizard.Physics2", boost::bind(&LLFloaterModelWizard::setState, this, PHYSICS2));
mCommitCallbackRegistrar.add("Wizard.Review", boost::bind(&LLFloaterModelWizard::setState, this, REVIEW));
mCommitCallbackRegistrar.add("Wizard.Upload", boost::bind(&LLFloaterModelWizard::setState, this, UPLOAD));
}
@@ -81,16 +89,22 @@ void LLFloaterModelWizard::setState(int state)
}
}
+ LLView* current_preview_panel = NULL;
+
if (state == CHOOSE_FILE)
{
mModelPreview->mViewOption["show_physics"] = false;
+ current_preview_panel = mChooseFilePreviewPanel;
+
getChildView("close")->setVisible(false);
getChildView("back")->setVisible(true);
getChildView("back")->setEnabled(false);
getChildView("next")->setVisible(true);
getChildView("upload")->setVisible(false);
getChildView("cancel")->setVisible(true);
+ mCalculateWeightsBtn->setVisible(false);
+ mCalculatingWeightsBtn->setVisible(false);
}
if (state == OPTIMIZE)
@@ -102,12 +116,16 @@ void LLFloaterModelWizard::setState(int state)
mModelPreview->mViewOption["show_physics"] = false;
+ current_preview_panel = mOptimizePreviewPanel;
+
getChildView("back")->setVisible(true);
getChildView("back")->setEnabled(true);
getChildView("close")->setVisible(false);
getChildView("next")->setVisible(true);
getChildView("upload")->setVisible(false);
getChildView("cancel")->setVisible(true);
+ mCalculateWeightsBtn->setVisible(false);
+ mCalculatingWeightsBtn->setVisible(false);
}
if (state == PHYSICS)
@@ -115,34 +133,24 @@ void LLFloaterModelWizard::setState(int state)
if (mLastEnabledState < state)
{
mModelPreview->setPhysicsFromLOD(1);
- }
- mModelPreview->mViewOption["show_physics"] = true;
-
- getChildView("next")->setVisible(true);
- getChildView("upload")->setVisible(false);
- getChildView("close")->setVisible(false);
- getChildView("back")->setVisible(true);
- getChildView("back")->setEnabled(true);
- getChildView("cancel")->setVisible(true);
- }
-
- if (state == PHYSICS2)
- {
- if (mLastEnabledState < state)
- {
- executePhysicsStage("Decompose");
+ // Trigger the recalculate physics when first entering
+ // the Physics step.
+ onClickRecalculatePhysics();
}
mModelPreview->mViewOption["show_physics"] = true;
- getChildView("next")->setVisible(true);
- getChildView("next")->setEnabled(true);
+ current_preview_panel = mPhysicsPreviewPanel;
+
+ getChildView("next")->setVisible(false);
getChildView("upload")->setVisible(false);
getChildView("close")->setVisible(false);
getChildView("back")->setVisible(true);
getChildView("back")->setEnabled(true);
getChildView("cancel")->setVisible(true);
+ mCalculateWeightsBtn->setVisible(true);
+ mCalculatingWeightsBtn->setVisible(false);
}
if (state == REVIEW)
@@ -156,6 +164,8 @@ void LLFloaterModelWizard::setState(int state)
getChildView("back")->setEnabled(true);
getChildView("upload")->setVisible(true);
getChildView("cancel")->setVisible(true);
+ mCalculateWeightsBtn->setVisible(false);
+ mCalculatingWeightsBtn->setVisible(false);
}
if (state == UPLOAD)
@@ -165,8 +175,24 @@ void LLFloaterModelWizard::setState(int state)
getChildView("back")->setVisible(false);
getChildView("upload")->setVisible(false);
getChildView("cancel")->setVisible(false);
+ mCalculateWeightsBtn->setVisible(false);
+ mCalculatingWeightsBtn->setVisible(false);
}
+ if (current_preview_panel)
+ {
+ LLRect rect;
+ current_preview_panel->localRectToOtherView(current_preview_panel->getLocalRect(), &rect, this);
+
+ // Reduce the preview rect by 1 px to fit the borders
+ rect.stretch(-1);
+
+ if (rect != mPreviewRect)
+ {
+ mPreviewRect = rect;
+ mModelPreview->refresh();
+ }
+ }
updateButtons();
}
@@ -198,18 +224,60 @@ void LLFloaterModelWizard::updateButtons()
button->setEnabled(FALSE);
}
}
+}
- LLButton *physics_button = getChild<LLButton>(stateNames[PHYSICS]+"_btn");
-
- if (mState == PHYSICS2)
+void LLFloaterModelWizard::onClickSwitchToAdvanced()
+{
+ LLFloaterModelPreview* floater_preview = LLFloaterReg::getTypedInstance<LLFloaterModelPreview>("upload_model");
+ if (!floater_preview)
{
- physics_button->setVisible(false);
+ llwarns << "FLoater model preview not found." << llendl;
+ return;
}
- else
+
+ // Open floater model preview
+ floater_preview->openFloater();
+
+ // Close the wizard
+ closeFloater();
+
+ std::string filename = getChild<LLUICtrl>("lod_file")->getValue().asString();
+ if (!filename.empty())
{
- physics_button->setVisible(true);
+ // Re-load the model to the floater model preview if it has been loaded
+ // into the wizard.
+ floater_preview->loadModel(3, filename);
}
+}
+
+void LLFloaterModelWizard::onClickRecalculateGeometry()
+{
+ S32 val = getChild<LLUICtrl>("accuracy_slider")->getValue().asInteger();
+
+ mModelPreview->genLODs(-1, NUM_LOD - val);
+
+ mModelPreview->refresh();
+}
+
+void LLFloaterModelWizard::onClickRecalculatePhysics()
+{
+ // Hide the "Recalculate physics" button and show the "Recalculating..."
+ // button instead.
+ swap_controls(mRecalculatePhysicsBtn, mRecalculatingPhysicsBtn, false);
+
+ executePhysicsStage("Decompose");
+}
+void LLFloaterModelWizard::onClickCalculateUploadFee()
+{
+ swap_controls(mCalculateWeightsBtn, mCalculatingWeightsBtn, false);
+
+ mModelPreview->rebuildUploadData();
+
+ mUploadModelUrl.clear();
+
+ gMeshRepo.uploadModel(mModelPreview->mUploadData, mModelPreview->mPreviewScale,
+ true, false, false, mUploadModelUrl, false, getWholeModelFeeObserverHandle());
}
void LLFloaterModelWizard::loadModel()
@@ -344,6 +412,7 @@ BOOL LLFloaterModelWizard::handleScrollWheel(S32 x, S32 y, S32 clicks)
return TRUE;
}
+
void LLFloaterModelWizard::initDecompControls()
{
LLSD key;
@@ -401,12 +470,83 @@ void LLFloaterModelWizard::initDecompControls()
mDecompParams["Simplify Method"] = 0; // set it to retain %
}
+/*virtual*/
+void LLFloaterModelWizard::onPermissionsReceived(const LLSD& result)
+{
+ std::string upload_status = result["mesh_upload_status"].asString();
+ // BAP HACK: handle "" for case that MeshUploadFlag cap is broken.
+ mHasUploadPerm = (("" == upload_status) || ("valid" == upload_status));
+
+ getChildView("warning_label")->setVisible(!mHasUploadPerm);
+ getChildView("warning_text")->setVisible(!mHasUploadPerm);
+}
+
+/*virtual*/
+void LLFloaterModelWizard::setPermissonsErrorStatus(U32 status, const std::string& reason)
+{
+ llwarns << "LLFloaterModelWizard::setPermissonsErrorStatus(" << status << " : " << reason << ")" << llendl;
+}
+
+/*virtual*/
+void LLFloaterModelWizard::onModelPhysicsFeeReceived(const LLSD& result, std::string upload_url)
+{
+ swap_controls(mCalculateWeightsBtn, mCalculatingWeightsBtn, true);
+
+ // Enable the "Upload" buton if we have calculated the upload fee
+ // and have the permission to upload.
+ getChildView("upload")->setEnabled(mHasUploadPerm);
+
+ mUploadModelUrl = upload_url;
+
+ S32 fee = result["upload_price"].asInteger();
+ childSetTextArg("review_fee", "[FEE]", llformat("%d", fee));
+ childSetTextArg("charged_fee", "[FEE]", llformat("%d", fee));
+
+ setState(REVIEW);
+}
+
+/*virtual*/
+void LLFloaterModelWizard::setModelPhysicsFeeErrorStatus(U32 status, const std::string& reason)
+{
+ swap_controls(mCalculateWeightsBtn, mCalculatingWeightsBtn, true);
+
+ // Disable the "Review" step if it has been previously enabled.
+ modelChangedCallback();
+
+ llwarns << "LLFloaterModelWizard::setModelPhysicsFeeErrorStatus(" << status << " : " << reason << ")" << llendl;
+
+ setState(PHYSICS);
+}
+
+/*virtual*/
+void LLFloaterModelWizard::onModelUploadSuccess()
+{
+ // success!
+ setState(UPLOAD);
+}
+
+/*virtual*/
+void LLFloaterModelWizard::onModelUploadFailure()
+{
+ // Failure. Make the user recalculate fees
+ setState(PHYSICS);
+ // Disable the "Review" step if it has been previously enabled.
+ if (mLastEnabledState > PHYSICS)
+ {
+ mLastEnabledState = PHYSICS;
+ }
+
+ updateButtons();
+}
+
//static
void LLFloaterModelWizard::executePhysicsStage(std::string stage_name)
{
if (sInstance)
{
- F64 physics_accuracy = sInstance->getChild<LLSliderCtrl>("physics_slider")->getValue().asReal();
+ // Invert the slider value so that "performance" end is giving the least detailed physics,
+ // and the "accuracy" end is giving the most detailed physics
+ F64 physics_accuracy = 1 - sInstance->getChild<LLSliderCtrl>("physics_slider")->getValue().asReal();
sInstance->mDecompParams["Retain%"] = physics_accuracy;
@@ -471,13 +611,16 @@ void LLFloaterModelWizard::DecompRequest::completed()
{
executePhysicsStage("Simplify");
}
+ else
+ {
+ // Decomp request is complete so we can enable the "Recalculate physics" button again.
+ swap_controls(sInstance->mRecalculatePhysicsBtn, sInstance->mRecalculatingPhysicsBtn, true);
+ }
}
BOOL LLFloaterModelWizard::postBuild()
{
- LLView* preview_panel = getChildView("preview_panel");
-
childSetValue("import_scale", (F32) 0.67335826);
getChild<LLUICtrl>("browse")->setCommitCallback(boost::bind(&LLFloaterModelWizard::loadModel, this));
@@ -488,23 +631,36 @@ BOOL LLFloaterModelWizard::postBuild()
getChild<LLUICtrl>("next")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickNext, this));
getChild<LLUICtrl>("preview_lod_combo")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onPreviewLODCommit, this, _1));
getChild<LLUICtrl>("preview_lod_combo2")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onPreviewLODCommit, this, _1));
- getChild<LLUICtrl>("preview_lod_combo3")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onPreviewLODCommit, this, _1));
- getChild<LLUICtrl>("accuracy_slider")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onAccuracyPerformance, this, _2));
getChild<LLUICtrl>("upload")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onUpload, this));
- getChild<LLUICtrl>("physics_slider")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onPhysicsChanged, this));
+ getChild<LLUICtrl>("switch_to_advanced")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickSwitchToAdvanced, this));
+
+ mRecalculateGeometryBtn = getChild<LLButton>("recalculate_geometry_btn");
+ mRecalculateGeometryBtn->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickRecalculateGeometry, this));
+
+ mRecalculatePhysicsBtn = getChild<LLButton>("recalculate_physics_btn");
+ mRecalculatePhysicsBtn->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickRecalculatePhysics, this));
+
+ mRecalculatingPhysicsBtn = getChild<LLButton>("recalculating_physics_btn");
+
+ mCalculateWeightsBtn = getChild<LLButton>("calculate");
+ mCalculateWeightsBtn->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickCalculateUploadFee, this));
+
+ mCalculatingWeightsBtn = getChild<LLButton>("calculating");
+
+ mChooseFilePreviewPanel = getChild<LLView>("choose_file_preview_panel");
+ mOptimizePreviewPanel = getChild<LLView>("optimize_preview_panel");
+ mPhysicsPreviewPanel = getChild<LLView>("physics_preview_panel");
LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
enable_registrar.add("Next.OnEnable", boost::bind(&LLFloaterModelWizard::onEnableNext, this));
enable_registrar.add("Back.OnEnable", boost::bind(&LLFloaterModelWizard::onEnableBack, this));
-
-
- mPreviewRect = preview_panel->getRect();
mModelPreview = new LLModelPreview(512, 512, this);
mModelPreview->setPreviewTarget(16.f);
mModelPreview->setDetailsCallback(boost::bind(&LLFloaterModelWizard::setDetails, this, _1, _2, _3, _4, _5));
mModelPreview->setModelLoadedCallback(boost::bind(&LLFloaterModelWizard::modelLoadedCallback, this));
+ mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelWizard::modelChangedCallback, this));
mModelPreview->mViewOption["show_textures"] = true;
center();
@@ -517,6 +673,8 @@ BOOL LLFloaterModelWizard::postBuild()
initDecompControls();
+ requestAgentUploadPermissions();
+
return TRUE;
}
@@ -532,22 +690,29 @@ void LLFloaterModelWizard::setDetails(F32 x, F32 y, F32 z, F32 streaming_cost, F
panel->childSetText("dimension_x", llformat("%.1f", x));
panel->childSetText("dimension_y", llformat("%.1f", y));
panel->childSetText("dimension_z", llformat("%.1f", z));
- panel->childSetTextArg("streaming cost", "[COST]", llformat("%.3f", streaming_cost));
- panel->childSetTextArg("physics cost", "[COST]", llformat("%.3f", physics_cost));
}
}
+
+ childSetTextArg("review_prim_equiv", "[EQUIV]", llformat("%d", mModelPreview->mResourceCost));
}
void LLFloaterModelWizard::modelLoadedCallback()
{
mLastEnabledState = CHOOSE_FILE;
- getChild<LLCheckBoxCtrl>("confirm_checkbox")->set(FALSE);
updateButtons();
}
-void LLFloaterModelWizard::onPhysicsChanged()
+void LLFloaterModelWizard::modelChangedCallback()
{
- mLastEnabledState = PHYSICS;
+ // Don't allow to proceed to the "Review" step if the model has changed
+ // but the new upload fee hasn't been calculated yet.
+ if (mLastEnabledState > PHYSICS)
+ {
+ mLastEnabledState = PHYSICS;
+ }
+
+ getChildView("upload")->setEnabled(false);
+
updateButtons();
}
@@ -556,22 +721,10 @@ void LLFloaterModelWizard::onUpload()
mModelPreview->rebuildUploadData();
gMeshRepo.uploadModel(mModelPreview->mUploadData, mModelPreview->mPreviewScale,
- true, false, false);
-
- setState(UPLOAD);
-
-}
-
-void LLFloaterModelWizard::onAccuracyPerformance(const LLSD& data)
-{
- int val = (int) data.asInteger();
-
- mModelPreview->genLODs(-1, NUM_LOD-val);
-
- mModelPreview->refresh();
+ true, false, false, mUploadModelUrl, true,
+ LLHandle<LLWholeModelFeeObserver>(), getWholeModelUploadObserverHandle());
}
-
void LLFloaterModelWizard::onPreviewLODCommit(LLUICtrl* ctrl)
{
if (!mModelPreview)
@@ -601,11 +754,6 @@ void LLFloaterModelWizard::refresh()
getChildView("next")->setEnabled(model_loaded);
}
- if (mState == REVIEW)
- {
- getChildView("upload")->setEnabled(getChild<LLCheckBoxCtrl>("confirm_checkbox")->getValue().asBoolean());
- }
-
}
void LLFloaterModelWizard::draw()
@@ -613,42 +761,35 @@ void LLFloaterModelWizard::draw()
refresh();
LLFloater::draw();
- LLRect r = getRect();
-
- mModelPreview->update();
- if (mModelPreview)
+ if (mModelPreview && mState < REVIEW)
{
+ mModelPreview->update();
+
gGL.color3f(1.f, 1.f, 1.f);
gGL.getTexUnit(0)->bind(mModelPreview);
- LLView *view = getChildView(stateNames[mState]+"_panel");
- LLView* preview_panel = view->getChildView("preview_panel");
-
- LLRect rect = preview_panel->getRect();
- if (rect != mPreviewRect)
- {
- mModelPreview->refresh();
- mPreviewRect = preview_panel->getRect();
- }
-
- LLRect item_rect;
- preview_panel->localRectToOtherView(preview_panel->getLocalRect(), &item_rect, this);
-
gGL.begin( LLRender::QUADS );
{
gGL.texCoord2f(0.f, 1.f);
- gGL.vertex2i(item_rect.mLeft, item_rect.mTop-1);
+ gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mTop);
gGL.texCoord2f(0.f, 0.f);
- gGL.vertex2i(item_rect.mLeft, item_rect.mBottom);
+ gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mBottom);
gGL.texCoord2f(1.f, 0.f);
- gGL.vertex2i(item_rect.mRight-1, item_rect.mBottom);
+ gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mBottom);
gGL.texCoord2f(1.f, 1.f);
- gGL.vertex2i(item_rect.mRight-1, item_rect.mTop-1);
+ gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mTop);
}
gGL.end();
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
}
}
+
+// static
+void swap_controls(LLUICtrl* first_ctrl, LLUICtrl* second_ctrl, bool first_ctr_visible)
+{
+ first_ctrl->setVisible(first_ctr_visible);
+ second_ctrl->setVisible(!first_ctr_visible);
+}