From fc6f0f31be53d6adbc8e364ffdd4119943312578 Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Wed, 29 Jun 2011 17:22:18 +0300 Subject: SH-1726 FIXED (Viewer modifications to advanced model upload to accommodate upload fee & prim equivalency) - Changed XUI according to the spec - Added requesting upload permission, physics weight and fee weight - Split requesting fee and uploading model steps in mesh repository --- indra/newview/CMakeLists.txt | 4 + indra/newview/llfloatermodelpreview.cpp | 118 ++++++++++++--- indra/newview/llfloatermodelpreview.h | 22 ++- indra/newview/llfloatermodeluploadbase.cpp | 56 +++++++ indra/newview/llfloatermodeluploadbase.h | 57 ++++++++ indra/newview/llfloatermodelwizard.cpp | 20 ++- indra/newview/llfloatermodelwizard.h | 13 +- indra/newview/llmeshrepository.cpp | 161 +++++++++++++-------- indra/newview/llmeshrepository.h | 15 +- indra/newview/lluploadfloaterobservers.cpp | 56 +++++++ indra/newview/lluploadfloaterobservers.h | 79 ++++++++++ .../skins/default/xui/en/floater_model_preview.xml | 75 +++++----- .../newview/skins/default/xui/en/notifications.xml | 14 ++ 13 files changed, 570 insertions(+), 120 deletions(-) create mode 100644 indra/newview/llfloatermodeluploadbase.cpp create mode 100644 indra/newview/llfloatermodeluploadbase.h create mode 100644 indra/newview/lluploadfloaterobservers.cpp create mode 100644 indra/newview/lluploadfloaterobservers.h (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 523ea8a394..c4018cd79c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -204,6 +204,7 @@ set(viewer_SOURCE_FILES llfloatermediasettings.cpp llfloatermemleak.cpp llfloatermodelpreview.cpp + llfloatermodeluploadbase.cpp llfloatermodelwizard.cpp llfloaternamedesc.cpp llfloaternotificationsconsole.cpp @@ -496,6 +497,7 @@ set(viewer_SOURCE_FILES lltranslate.cpp lluilistener.cpp lluploaddialog.cpp + lluploadfloaterobservers.cpp llurl.cpp llurldispatcher.cpp llurldispatcherlistener.cpp @@ -758,6 +760,7 @@ set(viewer_HEADER_FILES llfloatermediasettings.h llfloatermemleak.h llfloatermodelpreview.h + llfloatermodeluploadbase.h llfloatermodelwizard.h llfloaternamedesc.h llfloaternotificationsconsole.h @@ -1047,6 +1050,7 @@ set(viewer_HEADER_FILES lluiconstants.h lluilistener.h lluploaddialog.h + lluploadfloaterobservers.h llurl.h llurldispatcher.h llurldispatcherlistener.h diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index d000248e8e..ea85dc0052 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -71,6 +71,7 @@ #include "llmatrix4a.h" #include "llmenubutton.h" #include "llmeshrepository.h" +#include "llnotificationsutil.h" #include "llsdutil_math.h" #include "lltextbox.h" #include "lltoolmgr.h" @@ -353,7 +354,9 @@ void LLMeshFilePicker::notify(const std::string& filename) // LLFloaterModelPreview() //----------------------------------------------------------------------------- LLFloaterModelPreview::LLFloaterModelPreview(const LLSD& key) : -LLFloater(key) +LLFloaterModelUploadBase(key), +mUploadBtn(NULL), +mCalculateBtn(NULL) { sInstance = this; mLastMouseX = 0; @@ -422,8 +425,6 @@ BOOL LLFloaterModelPreview::postBuild() childDisable("ok_btn"); - childSetCommitCallback("confirm_checkbox", refresh, this); - mViewOptionMenuButton = getChild("options_gear_btn"); mCommitCallbackRegistrar.add("ModelImport.ViewOption.Action", boost::bind(&LLFloaterModelPreview::onViewOptionChecked, this, _2)); @@ -473,6 +474,13 @@ BOOL LLFloaterModelPreview::postBuild() } } + mUploadBtn = getChild("ok_btn"); + mCalculateBtn = getChild("calculate_btn"); + + mCalculateBtn->setClickedCallback(boost::bind(&LLFloaterModelPreview::onClickCalculateBtn, this)); + + toggleCalculateButton(true); + return TRUE; } @@ -551,6 +559,26 @@ void LLFloaterModelPreview::loadModel(S32 lod, const std::string& file_name) mModelPreview->loadModel(file_name, lod); } +void LLFloaterModelPreview::onClickCalculateBtn() +{ + childSetTextArg("weights", "[EQ]", llformat("%d", mModelPreview->mResourceCost)); + + mModelPreview->rebuildUploadData(); + + bool upload_skinweights = childGetValue("upload_skin").asBoolean(); + bool upload_joint_positions = childGetValue("upload_joints").asBoolean(); + + mUploadModelUrl.clear(); + LLMeshUploadThread* thread = new LLMeshUploadThread(mModelPreview->mUploadData, mModelPreview->mPreviewScale, + childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions, mUploadModelUrl, false); + + thread->setObserverHandle(getWholeModelFeeObserverHandle()); + + gMeshRepo.mUploadWaitList.push_back(thread); + + toggleCalculateButton(false); +} + //static void LLFloaterModelPreview::onImportScaleCommit(LLUICtrl*,void* userdata) { @@ -561,7 +589,8 @@ void LLFloaterModelPreview::onImportScaleCommit(LLUICtrl*,void* userdata) return; } - fp->mModelPreview->calcResourceCost(); + fp->toggleCalculateButton(true); + fp->mModelPreview->refresh(); } //static @@ -573,7 +602,9 @@ void LLFloaterModelPreview::onPelvisOffsetCommit( LLUICtrl*, void* userdata ) { return; } - fp->mModelPreview->calcResourceCost(); + + fp->toggleCalculateButton(true); + fp->mModelPreview->refresh(); } @@ -623,7 +654,8 @@ void LLFloaterModelPreview::onUploadSkinCommit(LLUICtrl*,void* userdata) return; } - fp->mModelPreview->calcResourceCost(); + fp->toggleCalculateButton(true); + fp->mModelPreview->refresh(); fp->mModelPreview->resetPreviewTarget(); fp->mModelPreview->clearBuffers(); @@ -653,6 +685,7 @@ void LLFloaterModelPreview::onGenerateNormalsCommit(LLUICtrl* ctrl, void* userda { LLFloaterModelPreview* fp = (LLFloaterModelPreview*) userdata; + fp->toggleCalculateButton(true); fp->mModelPreview->generateNormals(); } @@ -676,6 +709,8 @@ void LLFloaterModelPreview::onAutoFillCommit(LLUICtrl* ctrl, void* userdata) void LLFloaterModelPreview::onLODParamCommit(LLUICtrl* ctrl, void* userdata) { LLFloaterModelPreview* fp = (LLFloaterModelPreview*) userdata; + + fp->toggleCalculateButton(true); fp->mModelPreview->onLODParamCommit(false); } @@ -683,6 +718,7 @@ void LLFloaterModelPreview::onLODParamCommit(LLUICtrl* ctrl, void* userdata) void LLFloaterModelPreview::onLODParamCommitTriangleLimit(LLUICtrl* ctrl, void* userdata) { LLFloaterModelPreview* fp = (LLFloaterModelPreview*) userdata; + fp->toggleCalculateButton(true); fp->mModelPreview->onLODParamCommit(true); } @@ -714,6 +750,8 @@ void LLFloaterModelPreview::draw() } } + childSetEnabled("ok_btn", mHasUploadPerm); + childSetTextArg("prim_cost", "[PRIM_COST]", llformat("%d", mModelPreview->mResourceCost)); childSetTextArg("description_label", "[TEXTURES]", llformat("%d", mModelPreview->mTextureSet.size())); @@ -871,6 +909,12 @@ BOOL LLFloaterModelPreview::handleScrollWheel(S32 x, S32 y, S32 clicks) return TRUE; } +/*virtual*/ +void LLFloaterModelPreview::onOpen(const LLSD& key) +{ + requestAgentUploadPermissions(); +} + //static void LLFloaterModelPreview::onPhysicsParamCommit(LLUICtrl* ctrl, void* data) { @@ -2926,8 +2970,7 @@ U32 LLModelPreview::calcResourceCost() if (mFMP && mModelLoader) { - const BOOL confirmed_checkbox = mFMP->getChild("confirm_checkbox")->getValue().asBoolean(); - if ( getLoadState() < LLModelLoader::ERROR_PARSING && confirmed_checkbox ) + if ( getLoadState() < LLModelLoader::ERROR_PARSING) { mFMP->childEnable("ok_btn"); } @@ -3038,8 +3081,6 @@ void LLFloaterModelPreview::setDetails(F32 x, F32 y, F32 z, F32 streaming_cost, childSetTextArg("import_dimensions", "[X]", llformat("%.3f", x)); childSetTextArg("import_dimensions", "[Y]", llformat("%.3f", y)); childSetTextArg("import_dimensions", "[Z]", llformat("%.3f", z)); - childSetTextArg("streaming cost", "[COST]", llformat("%.3f", streaming_cost)); - childSetTextArg("physics cost", "[COST]", llformat("%.3f", physics_cost)); } @@ -3069,8 +3110,7 @@ void LLModelPreview::rebuildUploadData() F32 max_scale = 0.f; - const BOOL confirmed_checkbox = mFMP->getChild("confirm_checkbox")->getValue().asBoolean(); - if ( mBaseScene.size() > 0 && confirmed_checkbox ) + if ( mBaseScene.size() > 0) { mFMP->childEnable("ok_btn"); } @@ -3476,8 +3516,7 @@ void LLModelPreview::loadModelCallback(S32 lod) } mLoading = false; - if (mFMP) - mFMP->getChild("confirm_checkbox")->set(FALSE); + refresh(); mModelLoadedSignal(); @@ -4185,8 +4224,7 @@ void LLModelPreview::updateStatusMessages() } } - const BOOL confirmed_checkbox = mFMP->getChild("confirm_checkbox")->getValue().asBoolean(); - if ( upload_ok && !errorStateFromLoader && skinAndRigOk && !has_degenerate && confirmed_checkbox) + if ( upload_ok && !errorStateFromLoader && skinAndRigOk && !has_degenerate) { mFMP->childEnable("ok_btn"); } @@ -5314,7 +5352,7 @@ void LLFloaterModelPreview::onUpload(void* user_data) mp->mModelPreview->saveUploadData(upload_skinweights, upload_joint_positions); gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, mp->mModelPreview->mPreviewScale, - mp->childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions); + mp->childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions, mp->mUploadModelUrl); mp->closeFloater(false); } @@ -5330,6 +5368,7 @@ void LLFloaterModelPreview::onClearMaterials(void* user_data) //static void LLFloaterModelPreview::refresh(LLUICtrl* ctrl, void* user_data) { + sInstance->toggleCalculateButton(true); sInstance->mModelPreview->mDirty = true; } @@ -5382,6 +5421,34 @@ void LLFloaterModelPreview::setStatusMessage(const std::string& msg) mStatusMessage = msg; } +void LLFloaterModelPreview::toggleCalculateButton(bool visible) +{ + mCalculateBtn->setVisible(visible); + mUploadBtn->setVisible(!visible); + mUploadBtn->setEnabled(mHasUploadPerm); + + if (visible) + { + std::string tbd = getString("tbd"); + childSetTextArg("weights", "[EQ]", tbd); + childSetTextArg("weights", "[PH]", tbd); + childSetTextArg("weights", "[FEE]", tbd); + } +} + +void LLFloaterModelPreview::onModelPhysicsFeeReceived(F64 physics, S32 fee, std::string upload_url) +{ + mUploadModelUrl = upload_url; + childSetTextArg("weights", "[PH]", llformat("%.3f", physics)); + childSetTextArg("weights", "[FEE]", llformat("%d", fee)); + childSetVisible("weights", true); +} + +void LLFloaterModelPreview::setModelPhysicsFeeErrorStatus(U32 status, const std::string& reason) +{ + llwarns << "LLFloaterModelPreview::setModelPhysicsFeeErrorStatus(" << status << " : " << reason << ")" << llendl; +} + S32 LLFloaterModelPreview::DecompRequest::statusCallback(const char* status, S32 p1, S32 p2) { if (mContinue) @@ -5421,3 +5488,20 @@ void LLFloaterModelPreview::DecompRequest::completed() llassert(sInstance->mCurRequest.find(this) == sInstance->mCurRequest.end()); } } + +void LLFloaterModelPreview::onPermReceived(const LLSD& result) +{ + std::string upload_status = result["mesh_upload_status"].asString(); + mHasUploadPerm = "valid" == upload_status; + + mUploadBtn->setEnabled(mHasUploadPerm); + getChild("warning_title")->setVisible(mHasUploadPerm); + getChild("warning_message")->setVisible(mHasUploadPerm); +} + +void LLFloaterModelPreview::setPermErrorStatus(U32 status, const std::string& reason) +{ + llwarns << "LLFloaterModelPreview::setPermErrors(" << status << " : " << reason << ")" << llendl; + + LLNotificationsUtil::add("MeshUploadPermError"); +} diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index ab50890fb9..62878812c3 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -140,7 +140,7 @@ private: static bool isAlive(LLModelLoader* loader) ; }; -class LLFloaterModelPreview : public LLFloater +class LLFloaterModelPreview : public LLFloaterModelUploadBase { public: @@ -167,6 +167,8 @@ public: BOOL handleHover(S32 x, S32 y, MASK mask); BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); + /*virtual*/ void onOpen(const LLSD& key); + static void onMouseCaptureLostModelPreview(LLMouseHandler*); static void setUploadAmount(S32 amount) { sUploadAmount = amount; } @@ -194,6 +196,16 @@ public: void enableViewOption(const std::string& option); void disableViewOption(const std::string& option); + // shows warning message if agent has no permissions to upload model + /*virtual*/ void onPermReceived(const LLSD& result); + + // called when error occurs during permissions request + /*virtual*/ void setPermErrorStatus(U32 status, const std::string& reason); + + /*virtual*/ void onModelPhysicsFeeReceived(F64 physics, S32 fee, std::string upload_url); + + /*virtual*/ void setModelPhysicsFeeErrorStatus(U32 status, const std::string& reason); + protected: friend class LLModelPreview; friend class LLMeshFilePicker; @@ -259,6 +271,14 @@ protected: LLToggleableMenu* mViewOptionMenu; LLMutex* mStatusLock; +private: + void onClickCalculateBtn(); + + // Toggles between "Calculate weights & fee" and "Upload" buttons. + void toggleCalculateButton(bool visible); + + LLButton* mUploadBtn; + LLButton* mCalculateBtn; }; class LLMeshFilePicker : public LLFilePickerThread diff --git a/indra/newview/llfloatermodeluploadbase.cpp b/indra/newview/llfloatermodeluploadbase.cpp new file mode 100644 index 0000000000..56c6447792 --- /dev/null +++ b/indra/newview/llfloatermodeluploadbase.cpp @@ -0,0 +1,56 @@ +/** + * @file llfloatermodeluploadbase.cpp + * @brief LLFloaterUploadModelBase class definition + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatermodeluploadbase.h" +#include "llagent.h" +#include "llviewerregion.h" +#include "llnotificationsutil.h" + +LLFloaterModelUploadBase::LLFloaterModelUploadBase(const LLSD& key) +:LLFloater(key), + mHasUploadPerm(false) +{ +} + +void LLFloaterModelUploadBase::requestAgentUploadPermissions() +{ + std::string capability = "MeshUploadFlag"; + std::string url = gAgent.getRegion()->getCapability(capability); + + if (!url.empty()) + { + llinfos<< typeid(*this).name() <<"::requestAgentUploadPermissions() requesting for upload model permissions from: "<< url <rebuildUploadData(); gMeshRepo.uploadModel(mModelPreview->mUploadData, mModelPreview->mPreviewScale, - true, false, false); + true, false, false, mUploadModelUrl, true); setState(UPLOAD); diff --git a/indra/newview/llfloatermodelwizard.h b/indra/newview/llfloatermodelwizard.h index 409451e1b6..9930e0c4e6 100644 --- a/indra/newview/llfloatermodelwizard.h +++ b/indra/newview/llfloatermodelwizard.h @@ -30,12 +30,13 @@ #include "llmeshrepository.h" #include "llmodel.h" #include "llthread.h" +#include "llfloatermodeluploadbase.h" class LLModelPreview; -class LLFloaterModelWizard : public LLFloater +class LLFloaterModelWizard : public LLFloaterModelUploadBase { public: @@ -62,12 +63,20 @@ public: 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); + BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); + + /*virtual*/ void onOpen(const LLSD& key); void setDetails(F32 x, F32 y, F32 z, F32 streaming_cost, F32 physics_cost); void modelLoadedCallback(); void initDecompControls(); + // shows warning message if agent has no permissions to upload model + void onPermReceived(const LLSD& result); + + // called when error occurs during permissions request + void setPermErrorStatus(U32 status, const std::string& reason); + const LLRect& getPreviewRect() const { return mPreviewRect; } LLPhysicsDecomp::decomp_params mDecompParams; diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 4da5da9493..49bcbf860a 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -62,6 +62,7 @@ #include "llinventorymodel.h" #include "llfoldertype.h" #include "llviewerparcelmgr.h" +#include "lluploadfloaterobservers.h" #include "boost/lexical_cast.hpp" @@ -554,10 +555,12 @@ class LLWholeModelFeeResponder: public LLCurl::Responder { LLMeshUploadThread* mThread; LLSD mModelData; + LLHandle mObserverHandle; public: - LLWholeModelFeeResponder(LLMeshUploadThread* thread, LLSD& model_data): + LLWholeModelFeeResponder(LLMeshUploadThread* thread, LLSD& model_data, LLHandle observer_handle): mThread(thread), - mModelData(model_data) + mModelData(model_data), + mObserverHandle(observer_handle) { } virtual void completed(U32 status, @@ -573,11 +576,21 @@ public: llinfos << "completed" << llendl; mThread->mPendingUploads--; dump_llsd_to_file(cc,make_dump_name("whole_model_fee_response_",dump_num)); + if (isGoodStatus(status) && cc["state"].asString() == "upload") { llinfos << "fee request succeeded" << llendl; - mThread->mWholeModelUploadURL = cc["uploader"].asString(); + mThread->mWholeModelUploadURL = cc["uploader"].asString(); + + LLWholeModelFeeObserver* observer = mObserverHandle.get(); + if (observer) + { + S32 fee = cc["upload_price"].asInteger(); + F64 phys = cc["data"]["physics_cost"].asReal(); + + observer->onModelPhysicsFeeReceived(phys, fee, mThread->mWholeModelUploadURL); + } } else { @@ -1376,9 +1389,11 @@ bool LLMeshRepoThread::physicsShapeReceived(const LLUUID& mesh_id, U8* data, S32 } LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, LLVector3& scale, bool upload_textures, - bool upload_skin, bool upload_joints) + bool upload_skin, bool upload_joints, std::string upload_url, bool do_upload) : LLThread("mesh upload"), - mDiscarded(FALSE) + mDiscarded(FALSE), + mDoUpload(do_upload), + mWholeModelUploadURL(upload_url) { mInstanceList = data; mUploadTextures = upload_textures; @@ -1456,7 +1471,14 @@ BOOL LLMeshUploadThread::isDiscarded() void LLMeshUploadThread::run() { - doWholeModelUpload(); + if (mDoUpload) + { + doWholeModelUpload(); + } + else + { + requestWholeModelFee(); + } } void dump_llsd_to_file(const LLSD& content, std::string filename) @@ -1650,69 +1672,54 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures) dest = result; } -void LLMeshUploadThread::doWholeModelUpload() +void LLMeshUploadThread::queueUpModels() { - dump_num++; - - mCurlRequest = new LLCurlRequest(); - - // Queue up models for hull generation (viewer-side) for (instance_map::iterator iter = mInstance.begin(); iter != mInstance.end(); ++iter) - { - LLMeshUploadData data; - data.mBaseModel = iter->first; - - LLModelInstance& instance = *(iter->second.begin()); - - for (S32 i = 0; i < 5; i++) { - data.mModel[i] = instance.mLOD[i]; - } + LLMeshUploadData data; + data.mBaseModel = iter->first; - //queue up models for hull generation - LLModel* physics = NULL; + LLModelInstance& instance = *(iter->second.begin()); - if (data.mModel[LLModel::LOD_PHYSICS].notNull()) - { - physics = data.mModel[LLModel::LOD_PHYSICS]; - } - else if (data.mModel[LLModel::LOD_MEDIUM].notNull()) - { - physics = data.mModel[LLModel::LOD_MEDIUM]; - } - else - { - physics = data.mModel[LLModel::LOD_HIGH]; - } + for (S32 i = 0; i < 5; i++) + { + data.mModel[i] = instance.mLOD[i]; + } - llassert(physics != NULL); - - DecompRequest* request = new DecompRequest(physics, data.mBaseModel, this); - if(request->isValid()) - { - gMeshRepo.mDecompThread->submitRequest(request); - } - } + //queue up models for hull generation + LLModel* physics = NULL; - while (!mPhysicsComplete) - { - apr_sleep(100); - } + if (data.mModel[LLModel::LOD_PHYSICS].notNull()) + { + physics = data.mModel[LLModel::LOD_PHYSICS]; + } + else if (data.mModel[LLModel::LOD_MEDIUM].notNull()) + { + physics = data.mModel[LLModel::LOD_MEDIUM]; + } + else + { + physics = data.mModel[LLModel::LOD_HIGH]; + } - LLSD model_data; - wholeModelToLLSD(model_data,false); - dump_llsd_to_file(model_data,make_dump_name("whole_model_fee_request_",dump_num)); + llassert(physics != NULL); - mPendingUploads++; - LLCurlRequest::headers_t headers; - mCurlRequest->post(mWholeModelFeeCapability, headers, model_data, - new LLWholeModelFeeResponder(this,model_data), mMeshUploadTimeOut); + DecompRequest* request = new DecompRequest(physics, data.mBaseModel, this); + if(request->isValid()) + { + gMeshRepo.mDecompThread->submitRequest(request); + } + } - do - { - mCurlRequest->process(); - } while (mCurlRequest->getQueued() > 0); + while (!mPhysicsComplete) + { + apr_sleep(100); + } +} +void LLMeshUploadThread::doWholeModelUpload() +{ + mCurlRequest = new LLCurlRequest(); if (mWholeModelUploadURL.empty()) { @@ -1720,12 +1727,15 @@ void LLMeshUploadThread::doWholeModelUpload() } else { + queueUpModels(); + LLSD full_model_data; wholeModelToLLSD(full_model_data, true); LLSD body = full_model_data["asset_resources"]; dump_llsd_to_file(body,make_dump_name("whole_model_body_",dump_num)); + LLCurlRequest::headers_t headers; mCurlRequest->post(mWholeModelUploadURL, headers, body, - new LLWholeModelUploadResponder(this, model_data), mMeshUploadTimeOut); + new LLWholeModelUploadResponder(this, full_model_data), mMeshUploadTimeOut); do { mCurlRequest->process(); @@ -1739,6 +1749,35 @@ void LLMeshUploadThread::doWholeModelUpload() mFinished = true; } +void LLMeshUploadThread::requestWholeModelFee() +{ + dump_num++; + + mCurlRequest = new LLCurlRequest(); + + queueUpModels(); + + LLSD model_data; + wholeModelToLLSD(model_data,false); + dump_llsd_to_file(model_data,make_dump_name("whole_model_fee_request_",dump_num)); + + mPendingUploads++; + LLCurlRequest::headers_t headers; + mCurlRequest->post(mWholeModelFeeCapability, headers, model_data, + new LLWholeModelFeeResponder(this,model_data, mObserverHandle), mMeshUploadTimeOut); + + do + { + mCurlRequest->process(); + } while (mCurlRequest->getQueued() > 0); + + delete mCurlRequest; + mCurlRequest = NULL; + + // Currently a no-op. + mFinished = true; +} + void LLMeshUploadThread::uploadModel(LLMeshUploadData& data) { //called from arbitrary thread { @@ -2836,9 +2875,9 @@ LLSD& LLMeshRepoThread::getMeshHeader(const LLUUID& mesh_id) void LLMeshRepository::uploadModel(std::vector& data, LLVector3& scale, bool upload_textures, - bool upload_skin, bool upload_joints) + bool upload_skin, bool upload_joints, std::string upload_url, bool do_upload) { - LLMeshUploadThread* thread = new LLMeshUploadThread(data, scale, upload_textures, upload_skin, upload_joints); + LLMeshUploadThread* thread = new LLMeshUploadThread(data, scale, upload_textures, upload_skin, upload_joints, upload_url, do_upload); mUploadWaitList.push_back(thread); } diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index f56734a7de..03993c6f2c 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -36,6 +36,7 @@ #define LLCONVEXDECOMPINTER_STATIC 1 #include "llconvexdecomposition.h" +#include "lluploadfloaterobservers.h" class LLVOVolume; class LLMeshResponder; @@ -412,7 +413,7 @@ public: std::map mTextureMap; LLMeshUploadThread(instance_list& data, LLVector3& scale, bool upload_textures, - bool upload_skin, bool upload_joints); + bool upload_skin, bool upload_joints, std::string upload_url, bool do_upload = true); ~LLMeshUploadThread(); void uploadTexture(LLTextureUploadData& data); @@ -433,7 +434,11 @@ public: void discard() ; BOOL isDiscarded(); + // Queue up models for hull generation (viewer-side) + void queueUpModels(); + void doWholeModelUpload(); + void requestWholeModelFee(); void wholeModelToLLSD(LLSD& dest, bool include_textures); @@ -441,6 +446,12 @@ public: LLVector3& result_pos, LLQuaternion& result_rot, LLVector3& result_scale); + + void setObserverHandle(LLHandle observer_handle) { mObserverHandle = observer_handle; } + +private: + LLHandle mObserverHandle; + bool mDoUpload; // if FALSE only model data will be requested, otherwise the model will be uploaded }; class LLMeshRepository @@ -491,7 +502,7 @@ public: LLSD& getMeshHeader(const LLUUID& mesh_id); void uploadModel(std::vector& data, LLVector3& scale, bool upload_textures, - bool upload_skin, bool upload_joints); + bool upload_skin, bool upload_joints, std::string upload_url, bool do_upload = true); S32 getMeshSize(const LLUUID& mesh_id, S32 lod); diff --git a/indra/newview/lluploadfloaterobservers.cpp b/indra/newview/lluploadfloaterobservers.cpp new file mode 100644 index 0000000000..2d418ee00d --- /dev/null +++ b/indra/newview/lluploadfloaterobservers.cpp @@ -0,0 +1,56 @@ +/** + * @file lluploadfloaterobservers.cpp + * @brief LLUploadModelPremissionsResponder definition + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "lluploadfloaterobservers.h" + +LLUploadModelPremissionsResponder::LLUploadModelPremissionsResponder(const LLHandle& observer) +:mObserverHandle(observer) +{ +} + +void LLUploadModelPremissionsResponder::error(U32 status, const std::string& reason) +{ + llwarns << "LLUploadModelPremissionsResponder::error("<< status << ": " << reason << ")" << llendl; + + LLUploadPermissionsObserver* observer = mObserverHandle.get(); + + if (observer) + { + observer->setPermErrorStatus(status, reason); + } +} + +void LLUploadModelPremissionsResponder::result(const LLSD& content) +{ + LLUploadPermissionsObserver* observer = mObserverHandle.get(); + + if (observer) + { + observer->onPermReceived(content); + } +} diff --git a/indra/newview/lluploadfloaterobservers.h b/indra/newview/lluploadfloaterobservers.h new file mode 100644 index 0000000000..f27687e12e --- /dev/null +++ b/indra/newview/lluploadfloaterobservers.h @@ -0,0 +1,79 @@ +/** + * @file lluploadfloaterobservers.h + * @brief LLUploadModelPremissionsResponder declaration + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LLUPLOADFLOATEROBSERVERS_H_ +#define LLUPLOADFLOATEROBSERVERS_H_ + +#include "llfloater.h" +#include "llhttpclient.h" +#include "llhandle.h" + +class LLUploadPermissionsObserver +{ +public: + + LLUploadPermissionsObserver(){mUploadPermObserverHandle.bind(this);} + virtual ~LLUploadPermissionsObserver() {} + + virtual void onPermReceived(const LLSD& result) = 0; + virtual void setPermErrorStatus(U32 status, const std::string& reason) = 0; + + LLHandle getPermObserverHandle() const {return mUploadPermObserverHandle;} + +protected: + LLRootHandle mUploadPermObserverHandle; +}; + +class LLWholeModelFeeObserver +{ +public: + LLWholeModelFeeObserver() { mWholeModelFeeObserverHandle.bind(this); } + virtual ~LLWholeModelFeeObserver() {} + + virtual void onModelPhysicsFeeReceived(F64 physics, S32 fee, std::string upload_url) = 0; + virtual void setModelPhysicsFeeErrorStatus(U32 status, const std::string& reason) = 0; + + LLHandle getWholeModelFeeObserverHandle() const { return mWholeModelFeeObserverHandle; } + +protected: + LLRootHandle mWholeModelFeeObserverHandle; +}; + +class LLUploadModelPremissionsResponder : public LLHTTPClient::Responder +{ +public: + + LLUploadModelPremissionsResponder(const LLHandle& observer); + + void error(U32 status, const std::string& reason); + + void result(const LLSD& content); + +private: + LLHandle mObserverHandle; +}; + +#endif /* LLUPLOADFLOATEROBSERVERS_H_ */ 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 f58595b3c5..ab46a13098 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -23,6 +23,7 @@ All Analyzing... Simplifying... + TBD @@ -70,43 +71,29 @@ width="290" height="290" follows="all"/> - - Upload Details - - - Resource Cost: [COST] - - - Physics Cost: [COST] + + + WARNING: - - Upload Fee: N/A + + You will not be able to complete the final upload of this model to the Second Life servers. Find out how to get certifed for mesh model uploads. - - - - - I confirm that I have the appropriate rights to the material contained in this model. [secondlife:///app/floater/learn_more Learn more] - [STATUS] - - -