diff --git a/indra/newview/vjlocalmesh.cpp b/indra/newview/vjlocalmesh.cpp index bff84d9b7a..fc933505d5 100644 --- a/indra/newview/vjlocalmesh.cpp +++ b/indra/newview/vjlocalmesh.cpp @@ -78,16 +78,14 @@ void LLLocalMeshFace::setFaceBoundingBox(LLVector4 data_in, bool initial_values) /* volumeid and volumeparams for vobj. */ /* when applied - fills vobj volume. */ /*==========================================*/ -LLLocalMeshObject::LLLocalMeshObject(std::string name) +LLLocalMeshObject::LLLocalMeshObject(std::string_view name): + mObjectName(name) { - mObjectName = name; mSculptID.generate(); mVolumeParams.setSculptID(mSculptID, LL_SCULPT_TYPE_MESH); } -LLLocalMeshObject::~LLLocalMeshObject() -{ -} +LLLocalMeshObject::~LLLocalMeshObject() = default; void LLLocalMeshObject::computeObjectBoundingBox() { @@ -318,7 +316,7 @@ void LLLocalMeshObject::attachSkinInfo() } } -bool LLLocalMeshObject::getIsRiggedObject() +bool LLLocalMeshObject::getIsRiggedObject() const { bool result = false; auto& main_lod_faces = mFaces[LLLocalMeshFileLOD::LOCAL_LOD_HIGH]; @@ -342,7 +340,7 @@ bool LLLocalMeshObject::getIsRiggedObject() /* owns filenames [main and lods] */ /* owns the loaded local mesh objects */ /*==========================================*/ -LLLocalMeshFile::LLLocalMeshFile(std::string filename, bool try_lods) +LLLocalMeshFile::LLLocalMeshFile(const std::string& filename, bool try_lods) { // initialize safe defaults for (size_t lod_iter = 0; lod_iter < LOCAL_NUM_LODS; ++lod_iter) @@ -361,7 +359,7 @@ LLLocalMeshFile::LLLocalMeshFile(std::string filename, bool try_lods) mLocalMeshFileNeedsUIUpdate = false; mLoadedObjectList.clear(); mSavedObjectSculptIDs.clear(); - + pushLog("LLLocalMeshFile", "Initializing with filename: " + filename); // check if main filename exists, just in case @@ -377,8 +375,7 @@ LLLocalMeshFile::LLLocalMeshFile(std::string filename, bool try_lods) mShortName = boost::filesystem::path(filename).filename().generic_string(); // check if we have a valid extension, can't switch with string can we? - std::string exten_str = boost::filesystem::extension(filename); - if (exten_str == ".dae") + if (std::string exten_str = boost::filesystem::extension(filename); exten_str == ".dae") { mExtension = LLLocalMeshFileExtension::EXTEN_DAE; pushLog("LLLocalMeshFile", "Extension found: COLLADA"); @@ -399,10 +396,7 @@ LLLocalMeshFile::LLLocalMeshFile(std::string filename, bool try_lods) reloadLocalMeshObjects(true); } -LLLocalMeshFile::~LLLocalMeshFile() -{ - -} +LLLocalMeshFile::~LLLocalMeshFile() = default; void LLLocalMeshFile::reloadLocalMeshObjects(bool initial_load) { @@ -500,7 +494,7 @@ void LLLocalMeshFile::reloadLocalMeshObjects(bool initial_load) // int rather than size_t because we're iterating over LODS 3 to 0, stopping at -1 for (signed int lod_idx = LOCAL_LOD_HIGH; lod_idx >= LOCAL_LOD_LOWEST; --lod_idx) { - LLLocalMeshFileLOD current_lod = static_cast(lod_idx); + auto current_lod = static_cast(lod_idx); // do we have a filename for this lod? if (mFilenames[lod_idx].empty()) @@ -653,9 +647,8 @@ bool LLLocalMeshFile::updateLastModified(LLLocalMeshFileLOD lod) const std::time_t temp_time = boost::filesystem::last_write_time(boost::filesystem::path(utf8str_to_utf16str(current_filename))); #endif - LLSD new_last_modified = asctime(localtime(&temp_time)); - if (new_last_modified.asString() != current_last_modified.asString()) + if (LLSD new_last_modified = asctime(localtime(&temp_time)); new_last_modified.asString() != current_last_modified.asString()) { file_updated = true; mLastModified[lod] = new_last_modified; @@ -754,7 +747,7 @@ void LLLocalMeshFile::applyToVObject(LLUUID viewer_object_id, int object_index, continue; } - LLLocalMeshFileLOD current_lod = static_cast(lod_reverse_iter); + auto current_lod = static_cast(lod_reverse_iter); mLoadedObjectList[object_index]->fillVolume(current_lod); } @@ -775,7 +768,7 @@ void LLLocalMeshFile::applyToVObject(LLUUID viewer_object_id, int object_index, // NOTE: this ^^ (or lod change) causes renderer crash on mesh with degenerate primitives. } -void LLLocalMeshFile::pushLog(std::string who, std::string what, bool is_error) +void LLLocalMeshFile::pushLog(const std::string& who, const std::string& what, bool is_error) { std::string log_msg = "[ " + who + " ] "; if (is_error) @@ -806,7 +799,7 @@ LLLocalMeshSystem::~LLLocalMeshSystem() mLoadedFileList.clear(); } -void LLLocalMeshSystem::addFile(std::string filename, bool try_lods) +void LLLocalMeshSystem::addFile(const std::string& filename, bool try_lods) { auto loaded_file = std::make_unique(filename, try_lods); mLoadedFileList.push_back(std::move(loaded_file)); @@ -985,7 +978,7 @@ void LLLocalMeshSystem::triggerFloaterRefresh() } } -std::vector LLLocalMeshSystem::getFileInfoVector() +std::vector LLLocalMeshSystem::getFileInfoVector() const { std::vector result; @@ -997,7 +990,7 @@ std::vector LLLocalMeshSystem::getFileInfo return result; } -std::vector LLLocalMeshSystem::getFileLog(LLUUID local_file_id) +std::vector LLLocalMeshSystem::getFileLog(LLUUID local_file_id) const { std::vector result; diff --git a/indra/newview/vjlocalmesh.h b/indra/newview/vjlocalmesh.h index 857895270e..32261c5cb4 100644 --- a/indra/newview/vjlocalmesh.h +++ b/indra/newview/vjlocalmesh.h @@ -60,11 +60,10 @@ class LLLocalMeshFace std::array mJointWeights; }; - public: void setFaceBoundingBox(LLVector4 data_in, bool initial_values = false); - int getNumVerts() { return mPositions.size(); } - int getNumIndices() { return mIndices.size(); } + int getNumVerts() const { return mPositions.size(); } + int getNumIndices() const { return mIndices.size(); } std::vector& getIndices() { return mIndices; }; std::vector& getPositions() { return mPositions; }; @@ -93,10 +92,9 @@ class LLLocalMeshObject { public: // life cycle management - LLLocalMeshObject(std::string name); + explicit LLLocalMeshObject(std::string_view name); ~LLLocalMeshObject(); - public: // translation and scale void computeObjectBoundingBox(); void computeObjectTransform(const LLMatrix4& scene_transform); @@ -109,13 +107,13 @@ class LLLocalMeshObject // getters std::vector>& getFaces(LLLocalMeshFileLOD lod) { return mFaces[lod]; }; std::pair& getObjectBoundingBox() { return mObjectBoundingBox; }; - std::string getObjectName() { return mObjectName; }; - LLVector4 getObjectTranslation() { return mObjectTranslation; }; - LLVector4 getObjectSize() { return mObjectSize; }; - LLVector4 getObjectScale() { return mObjectScale; }; - LLMeshSkinInfo& getObjectMeshSkinInfo() { return mMeshSkinInfo; }; - LLVolumeParams getVolumeParams() { return mVolumeParams; }; - bool getIsRiggedObject(); + LLVector4 getObjectTranslation() const { return mObjectTranslation; }; + std::string getObjectName() const { return mObjectName; }; + LLVector4 getObjectSize() const { return mObjectSize; }; + LLVector4 getObjectScale() const { return mObjectScale; }; + LLMeshSkinInfo& getObjectMeshSkinInfo() { return mMeshSkinInfo; }; + LLVolumeParams getVolumeParams() const { return mVolumeParams; }; + bool getIsRiggedObject() const; private: // internal data keeping @@ -151,7 +149,7 @@ class LLLocalMeshFile }; // for future gltf support, possibly more. - enum LLLocalMeshFileExtension + enum class LLLocalMeshFileExtension { EXTEN_DAE, EXTEN_NONE @@ -173,16 +171,14 @@ class LLLocalMeshFile std::array mStatus; }; - public: // life cycle management - LLLocalMeshFile(std::string filename, bool try_lods); + LLLocalMeshFile(const std::string& filename, bool try_lods); ~LLLocalMeshFile(); // disallowing copy LLLocalMeshFile(const LLLocalMeshFile& local_mesh_file) = delete; LLLocalMeshFile& operator=(const LLLocalMeshFile& local_mesh_file) = delete; - public: // file loading void reloadLocalMeshObjects(bool initial_load = false); LLLocalMeshFileStatus reloadLocalMeshObjectsCheck(); @@ -193,16 +189,16 @@ class LLLocalMeshFile // info getters bool notifyNeedsUIUpdate(); LLLocalMeshFileInfo getFileInfo(); - std::string getFilename(LLLocalMeshFileLOD lod) { return mFilenames[lod]; }; - LLUUID getFileID() { return mLocalMeshFileID; }; - std::vector getFileLog() { return mLoadingLog; }; + std::string getFilename(LLLocalMeshFileLOD lod) const { return mFilenames[lod]; }; + LLUUID getFileID() const { return mLocalMeshFileID; }; + std::vector getFileLog() const { return mLoadingLog; }; // viewer object void updateVObjects(); void applyToVObject(LLUUID viewer_object_id, int object_index, bool use_scale); // misc - void pushLog(std::string who, std::string what, bool is_error = false); + void pushLog(const std::string& who, const std::string& what, bool is_error = false); private: std::array mFilenames; @@ -227,16 +223,14 @@ class LLLocalMeshFile /* user facing manager class. */ /*=============================*/ class LLLocalMeshSystem : public LLSingleton -{ - - public: +{ // life cycle management LLSINGLETON(LLLocalMeshSystem); + public: ~LLLocalMeshSystem(); - public: // file management - void addFile(std::string filename, bool try_lods); + void addFile(const std::string& filename, bool try_lods); void deleteFile(LLUUID local_file_id); void reloadFile(LLUUID local_file_id); @@ -251,8 +245,8 @@ class LLLocalMeshSystem : public LLSingleton // floater two-way communication void registerFloaterPointer(LLFloaterLocalMesh* floater_ptr); void triggerFloaterRefresh(); - std::vector getFileInfoVector(); - std::vector getFileLog(LLUUID local_file_id); + std::vector getFileInfoVector() const; + std::vector getFileLog(LLUUID local_file_id) const; private: std::vector> mLoadedFileList;