diff options
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rw-r--r-- | indra/newview/llfloatermodelpreview.cpp | 97 |
1 files changed, 92 insertions, 5 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 6a6766fb3f..f76f39222b 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -503,7 +503,10 @@ void LLFloaterModelPreview::onClickCalculateBtn() mUploadModelUrl.clear(); mModelPhysicsFee.clear(); - gMeshRepo.uploadModel(mModelPreview->mUploadData, mModelPreview->mPreviewScale, + lod_sources_map_t lod_sources; + fillLODSourceStatistics(lod_sources); + + gMeshRepo.uploadModel(mModelPreview->mUploadData, lod_sources, mModelPreview->mPreviewScale, childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions, lock_scale_if_joint_position, mUploadModelUrl, mDestinationFolderId, false, @@ -1087,9 +1090,7 @@ void LLFloaterModelPreview::onPhysicsUseLOD(LLUICtrl* ctrl, void* userdata) } else if (which_mode == cube_mode) { - std::string path = gDirUtilp->getAppRODataDir(); - gDirUtilp->append(path, "cube.dae"); - sInstance->loadModel(LLModel::LOD_PHYSICS, path); + sInstance->loadModel(LLModel::LOD_PHYSICS, getBoundingBoxCubePath()); } LLModelPreview *model_preview = sInstance->mModelPreview; @@ -1317,8 +1318,91 @@ void LLFloaterModelPreview::createSmoothComboBox(LLComboBox* combo_box, float mi std::string label = (++ilabel == SMOOTH_VALUES_NUMBER) ? "10 (max)" : llformat("%.1d", ilabel); combo_box->add(label, value, ADD_BOTTOM, true); } +} +std::string get_source_file_format(const std::string& filename) +{ + const std::string extension = gDirUtilp->getExtension(filename); + if (extension == "gltf" + || extension == "glb") + { + return "gltf"; + } + else if (extension == "dae") + { + return "dae"; + } + else if (extension == "slm") + { + return "slm"; + } + else + { + return "unknown file"; + } +} + +std::string LLFloaterModelPreview::getBoundingBoxCubePath() +{ + std::string path = gDirUtilp->getAppRODataDir(); + gDirUtilp->append(path, "cube.dae"); + return path; +} + +void LLFloaterModelPreview::fillLODSourceStatistics(LLFloaterModelPreview::lod_sources_map_t& lod_sources) const +{ + lod_sources.clear(); + // This doesn't nessesarily reflect the actual source of meshes, just user choices, + // some meshes could have been matched from different lods, but should be good + // enough for statistics. + for (S32 lod = 0; lod <= LLModel::LOD_HIGH; ++lod) + { + const std::string &lod_string = lod_name[lod]; + if (mLODMode[lod] == LLModelPreview::USE_LOD_ABOVE) + { + lod_sources[lod_string] = "lod above"; + } + else if (mLODMode[lod] == LLModelPreview::MESH_OPTIMIZER_AUTO + || mLODMode[lod] == LLModelPreview::MESH_OPTIMIZER_PRECISE + || mLODMode[lod] == LLModelPreview::MESH_OPTIMIZER_SLOPPY) + { + lod_sources[lod_string] = "generated"; + } + else if (mLODMode[lod] == LLModelPreview::LOD_FROM_FILE) + { + const std::string& file = mModelPreview->mLODFile[lod]; + lod_sources[lod_string] = get_source_file_format(file); + } + else + { + lod_sources[lod_string] = "unknown source"; + } + } + if (mModelPreview->mLODFile[LLModel::LOD_PHYSICS].empty()) + { + if (mModelPreview->mPhysicsSearchLOD >= 0 && mModelPreview->mPhysicsSearchLOD <= 3) + { + lod_sources["physics"] = lod_name[mModelPreview->mPhysicsSearchLOD]; + } + else + { + lod_sources["physics"] = "none"; + } + } + else + { + const std::string& file = mModelPreview->mLODFile[LLModel::LOD_PHYSICS]; + const std::string cube = getBoundingBoxCubePath(); + if (cube != file) // check for "cube.dae" + { + lod_sources["physics"] = get_source_file_format(file); + } + else + { + lod_sources["physics"] = "bounding box"; + } + } } //----------------------------------------------------------------------------- @@ -1656,7 +1740,10 @@ void LLFloaterModelPreview::onUpload(void* user_data) mp->mModelPreview->saveUploadData(upload_skinweights, upload_joint_positions, lock_scale_if_joint_position); } - gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, mp->mModelPreview->mPreviewScale, + lod_sources_map_t lod_sources; + mp->fillLODSourceStatistics(lod_sources); + + gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, lod_sources, mp->mModelPreview->mPreviewScale, mp->childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions, lock_scale_if_joint_position, mp->mUploadModelUrl, mp->mDestinationFolderId, |