summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llinventorymodel.cpp2
-rw-r--r--indra/newview/llmeshrepository.cpp151
2 files changed, 114 insertions, 39 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index b5180854ef..318beafe65 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -632,10 +632,12 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
}
// We're hiding mesh types
+#if 0
if (item->getType() == LLAssetType::AT_MESH)
{
return mask;
}
+#endif
LLViewerInventoryItem* old_item = getItem(item->getUUID());
LLPointer<LLViewerInventoryItem> new_item;
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index d9a58d56fe..f3b1aa9a1b 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -498,18 +498,29 @@ public:
//assert_main_thread();
llinfos << "completed" << llendl;
mThread->mPendingUploads--;
- dumpLLSDToFile(content,"whole_model_response.xml");
+ dumpLLSDToFile(content,"whole_model_fee_response.xml");
+ if (isGoodStatus(status))
+ {
+ mThread->mWholeModelUploadURL = content["uploader"].asString();
+ }
+ else
+ {
+ llinfos << "upload failed" << llendl;
+ mThread->mWholeModelUploadURL = "";
+ }
- mThread->mWholeModelUploadURL = content["uploader"].asString();
}
};
class LLWholeModelUploadResponder: public LLCurl::Responder
{
LLMeshUploadThread* mThread;
+ LLSD mPostData;
+
public:
- LLWholeModelUploadResponder(LLMeshUploadThread* thread):
- mThread(thread)
+ LLWholeModelUploadResponder(LLMeshUploadThread* thread, LLSD& post_data):
+ mThread(thread),
+ mPostData(post_data)
{
}
virtual void completed(U32 status,
@@ -520,6 +531,10 @@ public:
llinfos << "upload completed" << llendl;
mThread->mPendingUploads--;
dumpLLSDToFile(content,"whole_model_upload_response.xml");
+ // requested "mesh" asset type isn't actually the type
+ // of the resultant object, fix it up here.
+ mPostData["asset_type"] = "object";
+ gMeshRepo.updateInventory(LLMeshRepository::inventory_data(mPostData,content));
}
};
@@ -1386,13 +1401,13 @@ void LLMeshUploadThread::run()
}
}
-#if 1
void dumpLLSDToFile(const LLSD& content, std::string filename)
{
+#if 1
std::ofstream of(filename.c_str());
LLSDSerialize::toPrettyXML(content,of);
-}
#endif
+}
void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
{
@@ -1404,31 +1419,61 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
result["folder_id"] = gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT);
result["asset_type"] = "mesh";
result["inventory_type"] = "object";
- result["name"] = "your name here";
+ result["name"] = "mesh model";
result["description"] = "your description here";
// TODO "optional" fields from the spec
res["mesh_list"] = LLSD::emptyArray();
-// TODO Textures
- //res["texture_list"] = LLSD::emptyArray();
+ res["texture_list"] = LLSD::emptyArray();
S32 mesh_num = 0;
S32 texture_num = 0;
std::set<LLViewerTexture* > textures;
+ std::map<LLViewerTexture*,S32> texture_index;
for (instance_map::iterator iter = mInstance.begin(); iter != mInstance.end(); ++iter)
{
LLMeshUploadData data;
data.mBaseModel = iter->first;
-
LLModelInstance& instance = *(iter->second.begin());
+ LLModel* model = instance.mModel;
+ LLSD mesh_entry;
+
+ std::string model_name = data.mBaseModel->getName();
+
+ if (!model_name.empty())
+ {
+ result["name"] = model_name;
+ }
for (S32 i = 0; i < 5; i++)
{
data.mModel[i] = instance.mLOD[i];
}
+ LLVolumeParams volume_params;
+ volume_params.setType( LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE );
+ volume_params.setBeginAndEndS( 0.f, 1.f );
+ volume_params.setBeginAndEndT( 0.f, 1.f );
+ volume_params.setRatio ( 1, 1 );
+ volume_params.setShear ( 0, 0 );
+ volume_params.setSculptID(instance.mMeshID, LL_SCULPT_TYPE_MESH);
+ mesh_entry["shape"] = volume_params.asLLSD();
+ mesh_entry["material"] = LL_MCODE_WOOD;
+ mesh_entry["group-id"] = gAgent.getGroupID();
+ LLPermissions perm;
+ perm.setOwnerAndGroup(gAgent.getID(), gAgent.getID(), LLUUID::null, false);
+ perm.setCreator(gAgent.getID());
+
+ perm.initMasks(PERM_ITEM_UNRESTRICTED | PERM_MOVE, //base
+ PERM_ITEM_UNRESTRICTED | PERM_MOVE, //owner
+ LLFloaterPerms::getEveryonePerms(),
+ LLFloaterPerms::getGroupPerms(),
+ LLFloaterPerms::getNextOwnerPerms());
+ mesh_entry["permissions"] = ll_create_sd_from_permissions(perm);
+ mesh_entry["physics_shape_type"] = (U8)(LLViewerObject::PHYSICS_SHAPE_CONVEX_HULL);
+
std::stringstream ostr;
LLModel::Decomposition& decomp =
@@ -1451,19 +1496,12 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
data.mAssetData = ostr.str();
- LLSD mesh_entry;
-
LLVector3 pos, scale;
LLQuaternion rot;
LLMatrix4 transformation = instance.mTransform;
decomposeMeshMatrix(transformation,pos,rot,scale);
-#if 0
- mesh_entry["childpos"] = ll_sd_from_vector3(pos);
- mesh_entry["childrot"] = ll_sd_from_quaternion(rot);
- mesh_entry["scale"] = ll_sd_from_vector3(scale);
-#endif
- mesh_entry["position"] = ll_sd_from_vector3(LLVector3());
+ mesh_entry["position"] = ll_sd_from_vector3(pos);
mesh_entry["rotation"] = ll_sd_from_quaternion(rot);
mesh_entry["scale"] = ll_sd_from_vector3(scale);
@@ -1471,23 +1509,31 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
std::string str = ostr.str();
mesh_entry["mesh_data"] = LLSD::Binary(str.begin(),str.end());
- res["mesh_list"][mesh_num] = mesh_entry;
-
// TODO how do textures in the list map to textures in the meshes?
if (mUploadTextures)
{
- for (std::vector<LLImportMaterial>::iterator material_iter = instance.mMaterial.begin();
- material_iter != instance.mMaterial.end(); ++material_iter)
- {
+ mesh_entry["face_list"] = LLSD::emptyArray();
- if (textures.find(material_iter->mDiffuseMap.get()) == textures.end())
+ S32 face_num = 0;
+
+ for (S32 face_num = 0; face_num < model->getNumVolumeFaces(); face_num++)
+ {
+ LLImportMaterial& material = instance.mMaterial[face_num];
+ LLSD face_entry = LLSD::emptyMap();
+
+ LLViewerFetchedTexture *texture = material.mDiffuseMap.get();
+
+ if (texture != NULL)
{
- textures.insert(material_iter->mDiffuseMap.get());
+ if (textures.find(texture) == textures.end())
+ {
+ textures.insert(texture);
+ }
std::stringstream ostr;
if (include_textures) // otherwise data is blank.
{
- LLTextureUploadData data(material_iter->mDiffuseMap.get(), material_iter->mDiffuseMapLabel);
+ LLTextureUploadData data(texture, material.mDiffuseMapLabel);
if (!data.mTexture->isRawImageValid())
{
data.mTexture->reloadRawImage(data.mTexture->getDiscardLevel());
@@ -1497,21 +1543,34 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
LLViewerTextureList::convertToUploadFile(data.mTexture->getRawImage());
ostr.write((const char*) upload_file->getData(), upload_file->getDataSize());
}
- LLSD texture_entry;
- texture_entry["texture_data"] = ostr.str();
- res["texture_list"][texture_num] = texture_entry;
- texture_num++;
+
+ if (texture_index.find(texture) == texture_index.end())
+ {
+ texture_index[texture] = texture_num;
+ std::string str = ostr.str();
+ res["texture_list"][texture_num] = LLSD::Binary(str.begin(),str.end());
+ texture_num++;
+ }
+
+ face_entry["image"] = texture_index[texture];
+ face_entry["scales"] = 1.0;
+ face_entry["scalet"] = 1.0;
+ face_entry["offsets"] = 0.0;
+ face_entry["offsett"] = 0.0;
+ face_entry["imagerot"] = 0.0;
}
+ mesh_entry["face_list"][face_num] = face_entry;
}
+
}
+ res["mesh_list"][mesh_num] = mesh_entry;
+
mesh_num++;
}
result["asset_resources"] = res;
-#if 1
dumpLLSDToFile(result,"whole_model.xml");
-#endif
dest = result;
}
@@ -1563,9 +1622,9 @@ void LLMeshUploadThread::doWholeModelUpload()
apr_sleep(100);
}
- bool do_include_textures = false; // not needed for initial cost/validation check.
LLSD model_data;
- wholeModelToLLSD(model_data, do_include_textures);
+ wholeModelToLLSD(model_data,false);
+ dumpLLSDToFile(model_data,"whole_model_fee_request.xml");
mPendingUploads++;
LLCurlRequest::headers_t headers;
@@ -1577,12 +1636,24 @@ void LLMeshUploadThread::doWholeModelUpload()
mCurlRequest->process();
} while (mCurlRequest->getQueued() > 0);
- mCurlRequest->post(mWholeModelUploadURL, headers, model_data["asset_resources"], new LLWholeModelUploadResponder(this));
-
- do
+
+ if (mWholeModelUploadURL.empty())
{
- mCurlRequest->process();
- } while (mCurlRequest->getQueued() > 0);
+ llinfos << "unable to upload, fee request failed" << llendl;
+ }
+ else
+ {
+ LLSD full_model_data;
+ wholeModelToLLSD(full_model_data, true);
+ LLSD body = full_model_data["asset_resources"];
+ dumpLLSDToFile(body,"whole_model_body.xml");
+ mCurlRequest->post(mWholeModelUploadURL, headers, body,
+ new LLWholeModelUploadResponder(this, model_data));
+ do
+ {
+ mCurlRequest->process();
+ } while (mCurlRequest->getQueued() > 0);
+ }
delete mCurlRequest;
mCurlRequest = NULL;
@@ -3243,6 +3314,8 @@ bool LLImportMaterial::operator<(const LLImportMaterial &rhs) const
void LLMeshRepository::updateInventory(inventory_data data)
{
LLMutexLock lock(mMeshMutex);
+ dumpLLSDToFile(data.mPostData,"update_inventory_post_data.xml");
+ dumpLLSDToFile(data.mResponse,"update_inventory_response.xml");
mInventoryQ.push(data);
}