Skip to content

Commit 37a04ba

Browse files
committed
#4544 Add source format information to mesh upload statistics
1 parent 4796180 commit 37a04ba

File tree

4 files changed

+105
-7
lines changed

4 files changed

+105
-7
lines changed

indra/newview/llfloatermodelpreview.cpp

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,10 @@ void LLFloaterModelPreview::onClickCalculateBtn()
503503
mUploadModelUrl.clear();
504504
mModelPhysicsFee.clear();
505505

506-
gMeshRepo.uploadModel(mModelPreview->mUploadData, mModelPreview->mPreviewScale,
506+
lod_sources_map_t lod_sources;
507+
fillLODSourceStatistics(lod_sources);
508+
509+
gMeshRepo.uploadModel(mModelPreview->mUploadData, lod_sources, mModelPreview->mPreviewScale,
507510
childGetValue("upload_textures").asBoolean(),
508511
upload_skinweights, upload_joint_positions, lock_scale_if_joint_position,
509512
mUploadModelUrl, mDestinationFolderId, false,
@@ -1317,8 +1320,84 @@ void LLFloaterModelPreview::createSmoothComboBox(LLComboBox* combo_box, float mi
13171320
std::string label = (++ilabel == SMOOTH_VALUES_NUMBER) ? "10 (max)" : llformat("%.1d", ilabel);
13181321
combo_box->add(label, value, ADD_BOTTOM, true);
13191322
}
1323+
}
1324+
1325+
std::string get_source_file_extr(const std::string& filename)
1326+
{
1327+
if (std::string::npos != filename.rfind(".gltf")
1328+
|| std::string::npos != filename.rfind(".glb"))
1329+
{
1330+
return "gltf";
1331+
}
1332+
else if (std::string::npos != filename.rfind(".dae"))
1333+
{
1334+
return "dae";
1335+
}
1336+
else if (std::string::npos != filename.rfind(".slm"))
1337+
{
1338+
return "slm";
1339+
}
1340+
else
1341+
{
1342+
return "unknown file";
1343+
}
1344+
}
13201345

1346+
void LLFloaterModelPreview::fillLODSourceStatistics(LLFloaterModelPreview::lod_sources_map_t& lod_sources) const
1347+
{
1348+
lod_sources.clear();
13211349

1350+
// This doesn't nessesarily reflect the actual source of meshes, just user choices,
1351+
// some meshes could have been matched from different lods, but should be good
1352+
// enough for statistics.
1353+
for (S32 lod = 0; lod <= LLModel::LOD_HIGH; ++lod)
1354+
{
1355+
const std::string &lod_string = lod_name[lod];
1356+
if (mLODMode[lod] == LLModelPreview::USE_LOD_ABOVE)
1357+
{
1358+
lod_sources[lod_string] = "lod above";
1359+
}
1360+
else if (mLODMode[lod] == LLModelPreview::MESH_OPTIMIZER_AUTO
1361+
|| mLODMode[lod] == LLModelPreview::MESH_OPTIMIZER_PRECISE
1362+
|| mLODMode[lod] == LLModelPreview::MESH_OPTIMIZER_SLOPPY)
1363+
{
1364+
lod_sources[lod_string] = "generated";
1365+
}
1366+
else if (mLODMode[lod] == LLModelPreview::LOD_FROM_FILE)
1367+
{
1368+
const std::string& file = mModelPreview->mLODFile[lod];
1369+
lod_sources[lod_string] = get_source_file_extr(file);
1370+
}
1371+
else
1372+
{
1373+
lod_sources[lod_string] = "unknown source";
1374+
}
1375+
}
1376+
if (mModelPreview->mLODFile[LLModel::LOD_PHYSICS].empty())
1377+
{
1378+
if (mModelPreview->mPhysicsSearchLOD >= 0 && mModelPreview->mPhysicsSearchLOD <= 3)
1379+
{
1380+
lod_sources["physics"] = lod_name[mModelPreview->mPhysicsSearchLOD];
1381+
}
1382+
else
1383+
{
1384+
lod_sources["physics"] = "none";
1385+
}
1386+
}
1387+
else
1388+
{
1389+
const std::string& file = mModelPreview->mLODFile[LLModel::LOD_PHYSICS];
1390+
if (std::string::npos == file.rfind("cube.dae"))
1391+
{
1392+
// There is a chance it will misfire if someone tries to upload a cube.dae mesh,
1393+
// but should be negligible enough.
1394+
lod_sources["physics"] = get_source_file_extr(file);
1395+
}
1396+
else
1397+
{
1398+
lod_sources["physics"] = "bounding box";
1399+
}
1400+
}
13221401
}
13231402

13241403
//-----------------------------------------------------------------------------
@@ -1656,7 +1735,10 @@ void LLFloaterModelPreview::onUpload(void* user_data)
16561735
mp->mModelPreview->saveUploadData(upload_skinweights, upload_joint_positions, lock_scale_if_joint_position);
16571736
}
16581737

1659-
gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, mp->mModelPreview->mPreviewScale,
1738+
lod_sources_map_t lod_sources;
1739+
mp->fillLODSourceStatistics(lod_sources);
1740+
1741+
gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, lod_sources, mp->mModelPreview->mPreviewScale,
16601742
mp->childGetValue("upload_textures").asBoolean(),
16611743
upload_skinweights, upload_joint_positions, lock_scale_if_joint_position,
16621744
mp->mUploadModelUrl, mp->mDestinationFolderId,

indra/newview/llfloatermodelpreview.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ class LLFloaterModelPreview : public LLFloaterModelUploadBase
223223

224224
void createSmoothComboBox(LLComboBox* combo_box, float min, float max);
225225

226+
typedef std::map<std::string, std::string> lod_sources_map_t;
227+
void fillLODSourceStatistics(lod_sources_map_t& lod_sources) const;
228+
226229
LLUUID mDestinationFolderId;
227230
LLButton* mUploadBtn;
228231
LLButton* mCalculateBtn;

indra/newview/llmeshrepository.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,8 @@ EMeshProcessingResult LLMeshRepoThread::physicsShapeReceived(const LLUUID& mesh_
25692569
return MESH_OK;
25702570
}
25712571

2572-
LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, LLVector3& scale, bool upload_textures,
2572+
LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, const LLMeshUploadThread::lod_sources_map_t& sources_list,
2573+
LLVector3& scale, bool upload_textures,
25732574
bool upload_skin, bool upload_joints, bool lock_scale_if_joint_position,
25742575
const std::string & upload_url, LLUUID destination_folder_id, bool do_upload,
25752576
LLHandle<LLWholeModelFeeObserver> fee_observer,
@@ -2584,6 +2585,7 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data,
25842585
mUploadObserverHandle(upload_observer)
25852586
{
25862587
mInstanceList = data;
2588+
mLodSources = sources_list;
25872589
mUploadTextures = upload_textures;
25882590
mUploadSkin = upload_skin;
25892591
mUploadJoints = upload_joints;
@@ -2721,6 +2723,12 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, std::vector<std::string>&
27212723
res["mesh_list"] = LLSD::emptyArray();
27222724
res["texture_list"] = LLSD::emptyArray();
27232725
res["instance_list"] = LLSD::emptyArray();
2726+
LLSD& lod_sources = res["source_format"];
2727+
lod_sources["high"] = 0;
2728+
for (auto &source : mLodSources)
2729+
{
2730+
lod_sources[source.first] = source.second;
2731+
}
27242732
S32 mesh_num = 0;
27252733
S32 texture_num = 0;
27262734

@@ -5026,12 +5034,13 @@ bool LLMeshRepoThread::hasHeader(const LLUUID& mesh_id) const
50265034
return iter != mMeshHeader.end();
50275035
}
50285036

5029-
void LLMeshRepository::uploadModel(std::vector<LLModelInstance>& data, LLVector3& scale, bool upload_textures,
5037+
void LLMeshRepository::uploadModel(std::vector<LLModelInstance>& data, const std::map<std::string, std::string> &lod_sources,
5038+
LLVector3& scale, bool upload_textures,
50305039
bool upload_skin, bool upload_joints, bool lock_scale_if_joint_position,
50315040
std::string upload_url, const LLUUID& destination_folder_id, bool do_upload,
50325041
LLHandle<LLWholeModelFeeObserver> fee_observer, LLHandle<LLWholeModelUploadObserver> upload_observer)
50335042
{
5034-
LLMeshUploadThread* thread = new LLMeshUploadThread(data, scale, upload_textures,
5043+
LLMeshUploadThread* thread = new LLMeshUploadThread(data, lod_sources, scale, upload_textures,
50355044
upload_skin, upload_joints, lock_scale_if_joint_position,
50365045
upload_url, destination_folder_id, do_upload, fee_observer, upload_observer);
50375046
mUploadWaitList.push_back(thread);

indra/newview/llmeshrepository.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,8 @@ class LLMeshUploadThread : public LLThread, public LLCore::HttpHandler
691691
};
692692
typedef std::map<LLPointer<LLModel>, instance_list, LLUploadModelInstanceLess> instance_map;
693693
instance_map mInstance;
694+
typedef std::map<std::string, std::string> lod_sources_map_t;
695+
lod_sources_map_t mLodSources;
694696

695697
LLMutex* mMutex;
696698
S32 mPendingUploads;
@@ -707,7 +709,8 @@ class LLMeshUploadThread : public LLThread, public LLCore::HttpHandler
707709
std::string mWholeModelUploadURL;
708710
LLUUID mDestinationFolderId;
709711

710-
LLMeshUploadThread(instance_list& data, LLVector3& scale, bool upload_textures,
712+
LLMeshUploadThread(instance_list& data, const lod_sources_map_t& sources_list,
713+
LLVector3& scale, bool upload_textures,
711714
bool upload_skin, bool upload_joints, bool lock_scale_if_joint_position,
712715
const std::string & upload_url,
713716
const LLUUID destination_folder_id = LLUUID::null,
@@ -869,7 +872,8 @@ class LLMeshRepository
869872
bool meshUploadEnabled();
870873
bool meshRezEnabled();
871874

872-
void uploadModel(std::vector<LLModelInstance>& data, LLVector3& scale, bool upload_textures,
875+
void uploadModel(std::vector<LLModelInstance>& data, const std::map<std::string, std::string> &lod_sources,
876+
LLVector3& scale, bool upload_textures,
873877
bool upload_skin, bool upload_joints, bool lock_scale_if_joint_position,
874878
std::string upload_url,
875879
const LLUUID& destination_folder_id = LLUUID::null,

0 commit comments

Comments
 (0)