diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-10-17 16:56:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 16:56:21 +0300 |
commit | 0ef7a9b39cf72da1211039ab22bdf8f9f6a2c984 (patch) | |
tree | 6f51ef179497265b5bff2a355471ae5dc9643ad2 /indra/llinventory | |
parent | 9e24b300d02e5627ea0d304d412cb683ec2de3a4 (diff) | |
parent | d3d349ae0f17a72481f30b9354b9367b1cd3b639 (diff) |
Merge pull request #2856 from secondlife/marchcat/c-develop
Develop → Maint C sync
Diffstat (limited to 'indra/llinventory')
25 files changed, 1462 insertions, 765 deletions
diff --git a/indra/llinventory/llfoldertype.cpp b/indra/llinventory/llfoldertype.cpp index 8f968ae2fd..74eb801cfd 100644 --- a/indra/llinventory/llfoldertype.cpp +++ b/indra/llinventory/llfoldertype.cpp @@ -29,6 +29,7 @@ #include "llfoldertype.h" #include "lldictionary.h" #include "llmemory.h" +#include "llsd.h" #include "llsingleton.h" ///---------------------------------------------------------------------------- @@ -84,47 +85,47 @@ protected: LLFolderDictionary::LLFolderDictionary() { // TYPE NAME, PROTECTED, AUTOMATIC, SINGLETON - addEntry(LLFolderType::FT_TEXTURE, new FolderEntry("texture", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_SOUND, new FolderEntry("sound", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_CALLINGCARD, new FolderEntry("callcard", TRUE, TRUE, FALSE)); - addEntry(LLFolderType::FT_LANDMARK, new FolderEntry("landmark", TRUE, FALSE, FALSE)); - addEntry(LLFolderType::FT_CLOTHING, new FolderEntry("clothing", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_OBJECT, new FolderEntry("object", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_NOTECARD, new FolderEntry("notecard", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_ROOT_INVENTORY, new FolderEntry("root_inv", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_LSL_TEXT, new FolderEntry("lsltext", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_BODYPART, new FolderEntry("bodypart", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_TRASH, new FolderEntry("trash", TRUE, FALSE, TRUE)); - addEntry(LLFolderType::FT_SNAPSHOT_CATEGORY, new FolderEntry("snapshot", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_LOST_AND_FOUND, new FolderEntry("lstndfnd", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_ANIMATION, new FolderEntry("animatn", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_GESTURE, new FolderEntry("gesture", TRUE, TRUE, TRUE)); - addEntry(LLFolderType::FT_FAVORITE, new FolderEntry("favorite", TRUE, FALSE, TRUE)); + addEntry(LLFolderType::FT_TEXTURE, new FolderEntry("texture", true, true, true)); + addEntry(LLFolderType::FT_SOUND, new FolderEntry("sound", true, true, true)); + addEntry(LLFolderType::FT_CALLINGCARD, new FolderEntry("callcard", true, true, false)); + addEntry(LLFolderType::FT_LANDMARK, new FolderEntry("landmark", true, false, false)); + addEntry(LLFolderType::FT_CLOTHING, new FolderEntry("clothing", true, true, true)); + addEntry(LLFolderType::FT_OBJECT, new FolderEntry("object", true, true, true)); + addEntry(LLFolderType::FT_NOTECARD, new FolderEntry("notecard", true, true, true)); + addEntry(LLFolderType::FT_ROOT_INVENTORY, new FolderEntry("root_inv", true, true, true)); + addEntry(LLFolderType::FT_LSL_TEXT, new FolderEntry("lsltext", true, true, true)); + addEntry(LLFolderType::FT_BODYPART, new FolderEntry("bodypart", true, true, true)); + addEntry(LLFolderType::FT_TRASH, new FolderEntry("trash", true, false, true)); + addEntry(LLFolderType::FT_SNAPSHOT_CATEGORY, new FolderEntry("snapshot", true, true, true)); + addEntry(LLFolderType::FT_LOST_AND_FOUND, new FolderEntry("lstndfnd", true, true, true)); + addEntry(LLFolderType::FT_ANIMATION, new FolderEntry("animatn", true, true, true)); + addEntry(LLFolderType::FT_GESTURE, new FolderEntry("gesture", true, true, true)); + addEntry(LLFolderType::FT_FAVORITE, new FolderEntry("favorite", true, false, true)); for (S32 ensemble_num = S32(LLFolderType::FT_ENSEMBLE_START); ensemble_num <= S32(LLFolderType::FT_ENSEMBLE_END); ensemble_num++) { - addEntry(LLFolderType::EType(ensemble_num), new FolderEntry("ensemble", FALSE, FALSE, FALSE)); // Not used + addEntry(LLFolderType::EType(ensemble_num), new FolderEntry("ensemble", false, false, false)); // Not used } - addEntry(LLFolderType::FT_CURRENT_OUTFIT, new FolderEntry("current", TRUE, FALSE, TRUE)); - addEntry(LLFolderType::FT_OUTFIT, new FolderEntry("outfit", FALSE, FALSE, FALSE)); - addEntry(LLFolderType::FT_MY_OUTFITS, new FolderEntry("my_otfts", TRUE, FALSE, TRUE)); + addEntry(LLFolderType::FT_CURRENT_OUTFIT, new FolderEntry("current", true, false, true)); + addEntry(LLFolderType::FT_OUTFIT, new FolderEntry("outfit", false, false, false)); + addEntry(LLFolderType::FT_MY_OUTFITS, new FolderEntry("my_otfts", true, false, true)); - addEntry(LLFolderType::FT_MESH, new FolderEntry("mesh", TRUE, FALSE, FALSE)); // Not used? + addEntry(LLFolderType::FT_MESH, new FolderEntry("mesh", true, false, false)); // Not used? - addEntry(LLFolderType::FT_INBOX, new FolderEntry("inbox", TRUE, FALSE, TRUE)); - addEntry(LLFolderType::FT_OUTBOX, new FolderEntry("outbox", TRUE, FALSE, FALSE)); + addEntry(LLFolderType::FT_INBOX, new FolderEntry("inbox", true, false, true)); + addEntry(LLFolderType::FT_OUTBOX, new FolderEntry("outbox", true, false, false)); - addEntry(LLFolderType::FT_BASIC_ROOT, new FolderEntry("basic_rt", TRUE, FALSE, FALSE)); + addEntry(LLFolderType::FT_BASIC_ROOT, new FolderEntry("basic_rt", true, false, false)); - addEntry(LLFolderType::FT_MARKETPLACE_LISTINGS, new FolderEntry("merchant", FALSE, FALSE, FALSE)); - addEntry(LLFolderType::FT_MARKETPLACE_STOCK, new FolderEntry("stock", FALSE, FALSE, FALSE)); - addEntry(LLFolderType::FT_MARKETPLACE_VERSION, new FolderEntry("version", FALSE, FALSE, FALSE)); + addEntry(LLFolderType::FT_MARKETPLACE_LISTINGS, new FolderEntry("merchant", false, false, false)); + addEntry(LLFolderType::FT_MARKETPLACE_STOCK, new FolderEntry("stock", false, false, false)); + addEntry(LLFolderType::FT_MARKETPLACE_VERSION, new FolderEntry("version", false, false, false)); - addEntry(LLFolderType::FT_SETTINGS, new FolderEntry("settings", TRUE, FALSE, TRUE)); - addEntry(LLFolderType::FT_MATERIAL, new FolderEntry("material", TRUE, FALSE, TRUE)); + addEntry(LLFolderType::FT_SETTINGS, new FolderEntry("settings", true, false, true)); + addEntry(LLFolderType::FT_MATERIAL, new FolderEntry("material", true, false, true)); - addEntry(LLFolderType::FT_NONE, new FolderEntry("-1", FALSE, FALSE, FALSE)); + addEntry(LLFolderType::FT_NONE, new FolderEntry("-1", false, false, false)); }; // static @@ -220,3 +221,21 @@ const std::string &LLFolderType::badLookup() static const std::string sBadLookup = "llfoldertype_bad_lookup"; return sBadLookup; } + +LLSD LLFolderType::getTypeNames() +{ + LLSD type_names; + const LLFolderDictionary *dict = LLFolderDictionary::getInstance(); + for (S32 type = 0; type < FT_COUNT; ++type) + { + if (lookupIsEnsembleType(LLFolderType::EType(type))) continue; + + const FolderEntry *entry = dict->lookup(LLFolderType::EType(type)); + //skip llfoldertype_bad_lookup + if (entry) + { + type_names.append(entry->mName); + } + } + return type_names; +} diff --git a/indra/llinventory/llfoldertype.h b/indra/llinventory/llfoldertype.h index 46a1b92a96..dd12693f66 100644 --- a/indra/llinventory/llfoldertype.h +++ b/indra/llinventory/llfoldertype.h @@ -115,6 +115,8 @@ public: static const std::string& badLookup(); // error string when a lookup fails + static LLSD getTypeNames(); + protected: LLFolderType() {} ~LLFolderType() {} diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index 16a308ed72..16c112d411 100644 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -143,7 +143,7 @@ LLAssetType::EType LLInventoryObject::getActualType() const return mType; } -BOOL LLInventoryObject::getIsLinkType() const +bool LLInventoryObject::getIsLinkType() const { return LLAssetType::lookupIsLinkType(mType); } @@ -197,7 +197,7 @@ void LLInventoryObject::setType(LLAssetType::EType type) // virtual -BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream) +bool LLInventoryObject::importLegacyStream(std::istream& input_stream) { // *NOTE: Changing the buffer size will require changing the scanf // calls below. @@ -297,10 +297,10 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream) << "' in LLInventoryObject::importLegacyStream() for object " << mUUID << LL_ENDL; } } - return TRUE; + return true; } -BOOL LLInventoryObject::exportLegacyStream(std::ostream& output_stream, BOOL) const +bool LLInventoryObject::exportLegacyStream(std::ostream& output_stream, bool) const { std::string uuid_str; output_stream << "\tinv_object\t0\n\t{\n"; @@ -311,16 +311,16 @@ BOOL LLInventoryObject::exportLegacyStream(std::ostream& output_stream, BOOL) co output_stream << "\t\ttype\t" << LLAssetType::lookup(mType) << "\n"; output_stream << "\t\tname\t" << mName.c_str() << "|\n"; output_stream << "\t}\n"; - return TRUE; + return true; } -void LLInventoryObject::updateParentOnServer(BOOL) const +void LLInventoryObject::updateParentOnServer(bool) const { // don't do nothin' LL_WARNS() << "LLInventoryObject::updateParentOnServer() called. Doesn't do anything." << LL_ENDL; } -void LLInventoryObject::updateServer(BOOL) const +void LLInventoryObject::updateServer(bool) const { // don't do nothin' LL_WARNS() << "LLInventoryObject::updateServer() called. Doesn't do anything." << LL_ENDL; @@ -607,7 +607,7 @@ void LLInventoryItem::packMessage(LLMessageSystem* msg) const } // virtual -BOOL LLInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num) +bool LLInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num) { msg->getUUIDFast(block, _PREHASH_ItemID, mUUID, block_num); msg->getUUIDFast(block, _PREHASH_FolderID, mParentUUID, block_num); @@ -643,13 +643,13 @@ BOOL LLInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32 if(local_crc == remote_crc) { LL_DEBUGS() << "crc matches" << LL_ENDL; - return TRUE; + return true; } else { LL_WARNS() << "inventory crc mismatch: local=" << std::hex << local_crc << " remote=" << remote_crc << std::dec << LL_ENDL; - return FALSE; + return false; } #else return (local_crc == remote_crc); @@ -657,7 +657,7 @@ BOOL LLInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32 } // virtual -BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) +bool LLInventoryItem::importLegacyStream(std::istream& input_stream) { // *NOTE: Changing the buffer size will require changing the scanf // calls below. @@ -665,7 +665,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) char keyword[MAX_STRING]; /* Flawfinder: ignore */ char valuestr[MAX_STRING]; /* Flawfinder: ignore */ char junk[MAX_STRING]; /* Flawfinder: ignore */ - BOOL success = TRUE; + bool success = true; keyword[0] = '\0'; valuestr[0] = '\0'; @@ -705,7 +705,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) // the permissions. Thus, we read that out, and fix legacy // objects. It's possible this op would fail, but it // should pick up the vast majority of the tasks. - BOOL has_perm_mask = FALSE; + bool has_perm_mask = false; U32 perm_mask = 0; success = mSaleInfo.importLegacyStream(input_stream, has_perm_mask, perm_mask); if(has_perm_mask) @@ -864,7 +864,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) return success; } -BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key) const +bool LLInventoryItem::exportLegacyStream(std::ostream& output_stream, bool include_asset_key) const { std::string uuid_str; output_stream << "\tinv_item\t0\n\t{\n"; @@ -923,7 +923,7 @@ BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL inclu output_stream << "\t\tdesc\t" << mDescription.c_str() << "|\n"; output_stream << "\t\tcreation_date\t" << mCreationDate << "\n"; output_stream << "\t}\n"; - return TRUE; + return true; } LLSD LLInventoryItem::asLLSD() const @@ -1060,7 +1060,7 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd, bool is_new) // the permissions. Thus, we read that out, and fix legacy // objects. It's possible this op would fail, but it // should pick up the vast majority of the tasks. - BOOL has_perm_mask = FALSE; + bool has_perm_mask = false; U32 perm_mask = 0; if (!mSaleInfo.fromLLSD(i->second, has_perm_mask, perm_mask)) { @@ -1366,7 +1366,7 @@ void LLInventoryCategory::unpackMessage(LLMessageSystem* msg, } // virtual -BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream) +bool LLInventoryCategory::importLegacyStream(std::istream& input_stream) { // *NOTE: Changing the buffer size will require changing the scanf // calls below. @@ -1474,10 +1474,10 @@ BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream) << "' in inventory import category " << mUUID << LL_ENDL; } } - return TRUE; + return true; } -BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL) const +bool LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, bool) const { std::string uuid_str; output_stream << "\tinv_category\t0\n\t{\n"; @@ -1498,7 +1498,7 @@ BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL) output_stream << "|\n"; } output_stream << "\t}\n"; - return TRUE; + return true; } LLSD LLInventoryCategory::exportLLSD() const diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h index 0e77d49d73..2044b0102c 100644 --- a/indra/llinventory/llinventory.h +++ b/indra/llinventory/llinventory.h @@ -75,7 +75,7 @@ public: virtual const std::string& getName() const; virtual LLAssetType::EType getType() const; LLAssetType::EType getActualType() const; // bypasses indirection for linked items - BOOL getIsLinkType() const; + bool getIsLinkType() const; virtual time_t getCreationDate() const; //-------------------------------------------------------------------- @@ -100,11 +100,11 @@ public: // between simulator and viewer. //-------------------------------------------------------------------- - virtual BOOL importLegacyStream(std::istream& input_stream); - virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const; + virtual bool importLegacyStream(std::istream& input_stream); + virtual bool exportLegacyStream(std::ostream& output_stream, bool include_asset_key = true) const; - virtual void updateParentOnServer(BOOL) const; - virtual void updateServer(BOOL) const; + virtual void updateParentOnServer(bool) const; + virtual void updateServer(bool) const; //-------------------------------------------------------------------- // Member Variables @@ -193,17 +193,17 @@ public: // Assumes you have already called nextBlock(). virtual void packMessage(LLMessageSystem* msg) const; - // Returns TRUE if the inventory item came through the network correctly. + // Returns true if the inventory item came through the network correctly. // Uses a simple crc check which is defeatable, but we want to detect // network mangling somehow. - virtual BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0); + virtual bool unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0); //-------------------------------------------------------------------- // File Support //-------------------------------------------------------------------- public: - virtual BOOL importLegacyStream(std::istream& input_stream); - virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const; + virtual bool importLegacyStream(std::istream& input_stream); + virtual bool exportLegacyStream(std::ostream& output_stream, bool include_asset_key = true) const; //-------------------------------------------------------------------- // Helper Functions @@ -270,8 +270,8 @@ public: // File Support //-------------------------------------------------------------------- public: - virtual BOOL importLegacyStream(std::istream& input_stream); - virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const; + virtual bool importLegacyStream(std::istream& input_stream); + virtual bool exportLegacyStream(std::ostream& output_stream, bool include_asset_key = true) const; LLSD exportLLSD() const; bool importLLSD(const LLSD& cat_data); diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp index 303dd8b711..8fa8983d3c 100644 --- a/indra/llinventory/llinventorytype.cpp +++ b/indra/llinventory/llinventorytype.cpp @@ -53,6 +53,7 @@ struct InventoryEntry : public LLDictionaryEntry LLAssetType::EType t = (LLAssetType::EType)va_arg(argp,int); mAssetTypes.push_back(t); } + va_end(argp); } const std::string mHumanName; @@ -83,6 +84,8 @@ LLInventoryDictionary::LLInventoryDictionary() addEntry(LLInventoryType::IT_ANIMATION, new InventoryEntry("animation", "animation", 1, LLAssetType::AT_ANIMATION)); addEntry(LLInventoryType::IT_GESTURE, new InventoryEntry("gesture", "gesture", 1, LLAssetType::AT_GESTURE)); addEntry(LLInventoryType::IT_MESH, new InventoryEntry("mesh", "mesh", 1, LLAssetType::AT_MESH)); + addEntry(LLInventoryType::IT_GLTF, new InventoryEntry("gltf", "gltf", 1, LLAssetType::AT_GLTF)); + addEntry(LLInventoryType::IT_GLTF_BIN, new InventoryEntry("glbin", "glbin", 1, LLAssetType::AT_GLTF_BIN)); addEntry(LLInventoryType::IT_WIDGET, new InventoryEntry("widget", "widget", 1, LLAssetType::AT_WIDGET)); addEntry(LLInventoryType::IT_PERSON, new InventoryEntry("person", "person", 1, LLAssetType::AT_PERSON)); addEntry(LLInventoryType::IT_SETTINGS, new InventoryEntry("settings", "settings", 1, LLAssetType::AT_SETTINGS)); @@ -153,9 +156,12 @@ DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] = LLInventoryType::IT_NONE, // 52 AT_RESERVED_3 LLInventoryType::IT_NONE, // 53 AT_RESERVED_4 LLInventoryType::IT_NONE, // 54 AT_RESERVED_5 + LLInventoryType::IT_NONE, // 55 AT_RESERVED_6 - LLInventoryType::IT_SETTINGS, // 55 AT_SETTINGS <- why doesnt this match the value in llassettype.h? -brad + LLInventoryType::IT_SETTINGS, // 56 AT_SETTINGS LLInventoryType::IT_MATERIAL, // 57 AT_MATERIAL + LLInventoryType::IT_GLTF, // 58 AT_GLTF + LLInventoryType::IT_GLTF_BIN, // 59 AT_GLTF_BIN }; // static diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h index fd80a0be04..c90f8aa107 100644 --- a/indra/llinventory/llinventorytype.h +++ b/indra/llinventory/llinventorytype.h @@ -66,7 +66,9 @@ public: IT_PERSON = 24, IT_SETTINGS = 25, IT_MATERIAL = 26, - IT_COUNT = 27, + IT_GLTF = 27, + IT_GLTF_BIN = 28, + IT_COUNT = 29, IT_UNKNOWN = 255, IT_NONE = -1 diff --git a/indra/llinventory/llnotecard.cpp b/indra/llinventory/llnotecard.cpp index cc40a0c6b8..d73e9c8966 100644 --- a/indra/llinventory/llnotecard.cpp +++ b/indra/llinventory/llnotecard.cpp @@ -162,25 +162,25 @@ bool LLNotecard::importStream(std::istream& str) if(str.fail()) { LL_WARNS() << "Invalid Linden text file header " << LL_ENDL; - return FALSE; + return false; } if( 1 != mVersion && 2 != mVersion) { LL_WARNS() << "Invalid Linden text file version: " << mVersion << LL_ENDL; - return FALSE; + return false; } str >> std::ws >> "{\n"; if(str.fail()) { LL_WARNS() << "Invalid Linden text file format" << LL_ENDL; - return FALSE; + return false; } if(!importEmbeddedItemsStream(str)) { - return FALSE; + return false; } char line_buf[STD_STRING_BUF_SIZE]; /* Flawfinder: ignore */ @@ -188,7 +188,7 @@ bool LLNotecard::importStream(std::istream& str) if(str.fail()) { LL_WARNS() << "Invalid Linden text length field" << LL_ENDL; - return FALSE; + return false; } line_buf[STD_STRING_STR_LEN] = '\0'; @@ -196,23 +196,23 @@ bool LLNotecard::importStream(std::istream& str) if( 1 != sscanf(line_buf, "Text length %d", &text_len) ) { LL_WARNS() << "Invalid Linden text length field" << LL_ENDL; - return FALSE; + return false; } if(text_len > mMaxText || text_len < 0) { LL_WARNS() << "Invalid Linden text length: " << text_len << LL_ENDL; - return FALSE; + return false; } - BOOL success = TRUE; + bool success = true; char* text = new char[text_len + 1]; fullread(str, text, text_len); if(str.fail()) { LL_WARNS() << "Invalid Linden text: text shorter than text length: " << text_len << LL_ENDL; - success = FALSE; + success = false; } text[text_len] = '\0'; @@ -247,7 +247,7 @@ bool LLNotecard::exportEmbeddedItemsStream( std::ostream& out_stream ) out_stream << llformat("ext char index %d\n", idx ); if( !item->exportLegacyStream( out_stream ) ) { - return FALSE; + return false; } out_stream << "}\n"; } @@ -256,7 +256,7 @@ bool LLNotecard::exportEmbeddedItemsStream( std::ostream& out_stream ) out_stream << "}\n"; - return TRUE; + return true; } bool LLNotecard::exportStream( std::ostream& out_stream ) @@ -266,14 +266,14 @@ bool LLNotecard::exportStream( std::ostream& out_stream ) if( !exportEmbeddedItemsStream( out_stream ) ) { - return FALSE; + return false; } out_stream << llformat("Text length %d\n", mText.length() ); out_stream << mText; out_stream << "}\n"; - return TRUE; + return true; } //////////////////////////////////////////////////////////////////////////// diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index 0cb9070ff6..71dc8cff34 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -119,15 +119,15 @@ LLParcel::ECategory category_ui_string_to_category(const std::string& s); LLParcel::LLParcel() { - init(LLUUID::null, TRUE, FALSE, FALSE, 0, 0, 0, 0, 0, 1.f, 0); + init(LLUUID::null, true, false, false, 0, 0, 0, 0, 0, 1.f, 0); } LLParcel::LLParcel(const LLUUID &owner_id, - BOOL modify, BOOL terraform, BOOL damage, + bool modify, bool terraform, bool damage, time_t claim_date, S32 claim_price_per_meter, S32 rent_price_per_meter, S32 area, S32 sim_object_limit, F32 parcel_object_bonus, - BOOL is_group_owned) + bool is_group_owned) { init( owner_id, modify, terraform, damage, claim_date, claim_price_per_meter, rent_price_per_meter, area, sim_object_limit, parcel_object_bonus, @@ -142,10 +142,10 @@ LLParcel::~LLParcel() } void LLParcel::init(const LLUUID &owner_id, - BOOL modify, BOOL terraform, BOOL damage, + bool modify, bool terraform, bool damage, time_t claim_date, S32 claim_price_per_meter, S32 rent_price_per_meter, S32 area, S32 sim_object_limit, F32 parcel_object_bonus, - BOOL is_group_owned) + bool is_group_owned) { mID.setNull(); mOwnerID = owner_id; @@ -172,7 +172,7 @@ void LLParcel::init(const LLUUID &owner_id, mSaleTimerExpires.stop(); mGraceExtension = 0; //mExpireAction = STEA_REVERT; - //mRecordTransaction = FALSE; + //mRecordTransaction = false; mAuctionID = 0; mInEscrow = false; @@ -191,13 +191,13 @@ void LLParcel::init(const LLUUID &owner_id, setMediaType(LLStringUtil::null); mMediaID.setNull(); mMediaAutoScale = 0; - mMediaLoop = TRUE; + mMediaLoop = 1; mMediaWidth = 0; mMediaHeight = 0; setMediaCurrentURL(LLStringUtil::null); - mMediaAllowNavigate = TRUE; + mMediaAllowNavigate = 1; mMediaURLTimeout = 0.0f; - mMediaPreventCameraZoom = FALSE; + mMediaPreventCameraZoom = 0; mGroupID.setNull(); @@ -219,26 +219,26 @@ void LLParcel::init(const LLUUID &owner_id, setSelectedPrimCount(0); setTempPrimCount(0); setCleanOtherTime(0); - setRegionPushOverride(FALSE); - setRegionDenyAnonymousOverride(FALSE); - setRegionDenyAgeUnverifiedOverride(FALSE); + setRegionPushOverride(false); + setRegionDenyAnonymousOverride(false); + setRegionDenyAgeUnverifiedOverride(false); setParcelPrimBonus(parcel_object_bonus); setPreviousOwnerID(LLUUID::null); - setPreviouslyGroupOwned(FALSE); + setPreviouslyGroupOwned(false); - setSeeAVs(TRUE); - setAllowGroupAVSounds(TRUE); - setAllowAnyAVSounds(TRUE); - setHaveNewParcelLimitData(FALSE); + setSeeAVs(true); + setAllowGroupAVSounds(true); + setAllowAnyAVSounds(true); + setHaveNewParcelLimitData(false); - setRegionAllowEnvironmentOverride(FALSE); + setRegionAllowEnvironmentOverride(false); setParcelEnvironmentVersion(INVALID_PARCEL_ENVIRONMENT_VERSION); setObscureMOAP(false); } -void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned) +void LLParcel::overrideOwner(const LLUUID& owner_id, bool is_group_owned) { // Override with system permission (LLUUID::null) // Overridden parcels have no group @@ -352,7 +352,7 @@ void LLParcel::setAllParcelFlags(U32 flags) mParcelFlags = flags; } -void LLParcel::setParcelFlag(U32 flag, BOOL b) +void LLParcel::setParcelFlag(U32 flag, bool b) { if (b) { @@ -365,25 +365,25 @@ void LLParcel::setParcelFlag(U32 flag, BOOL b) } -BOOL LLParcel::allowModifyBy(const LLUUID &agent_id, const LLUUID &group_id) const +bool LLParcel::allowModifyBy(const LLUUID &agent_id, const LLUUID &group_id) const { if (agent_id == LLUUID::null) { // system always can enter - return TRUE; + return true; } else if (isPublic()) { - return TRUE; + return true; } else if (agent_id == mOwnerID) { // owner can always perform operations - return TRUE; + return true; } else if (mParcelFlags & PF_CREATE_OBJECTS) { - return TRUE; + return true; } else if ((mParcelFlags & PF_CREATE_GROUP_OBJECTS) && group_id.notNull() ) @@ -391,22 +391,22 @@ BOOL LLParcel::allowModifyBy(const LLUUID &agent_id, const LLUUID &group_id) con return (getGroupID() == group_id); } - return FALSE; + return false; } -BOOL LLParcel::allowTerraformBy(const LLUUID &agent_id) const +bool LLParcel::allowTerraformBy(const LLUUID &agent_id) const { if (agent_id == LLUUID::null) { // system always can enter - return TRUE; + return true; } else if(OS_LEASED == mStatus) { if(agent_id == mOwnerID) { // owner can modify leased land - return TRUE; + return true; } else { @@ -416,7 +416,7 @@ BOOL LLParcel::allowTerraformBy(const LLUUID &agent_id) const } else { - return FALSE; + return false; } } @@ -441,7 +441,7 @@ void LLParcel::setDiscountRate(F32 rate) // File input and output //----------------------------------------------------------- -BOOL LLParcel::importAccessEntry(std::istream& input_stream, LLAccessEntry* entry) +bool LLParcel::importAccessEntry(std::istream& input_stream, LLAccessEntry* entry) { skip_to_end_of_next_keyword("{", input_stream); while (input_stream.good()) @@ -561,9 +561,9 @@ void LLParcel::unpackMessage(LLMessageSystem* msg) msg->getStringFast( _PREHASH_ParcelData,_PREHASH_MediaURL, buffer ); setMediaURL(buffer); - BOOL see_avs = TRUE; // All default to true for legacy server behavior - BOOL any_av_sounds = TRUE; - BOOL group_av_sounds = TRUE; + bool see_avs = true; // All default to true for legacy server behavior + bool any_av_sounds = true; + bool group_av_sounds = true; bool have_new_parcel_limit_data = (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_SeeAVs) > 0); // New version of server should send all 3 of these values have_new_parcel_limit_data &= (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_AnyAVSounds) > 0); have_new_parcel_limit_data &= (msg->getSizeFast(_PREHASH_ParcelData, _PREHASH_GroupAVSounds) > 0); @@ -728,21 +728,21 @@ void LLParcel::expirePasses(S32 now) bool LLParcel::operator==(const LLParcel &rhs) const { if (mOwnerID != rhs.mOwnerID) - return FALSE; + return false; if (mParcelFlags != rhs.mParcelFlags) - return FALSE; + return false; if (mClaimDate != rhs.mClaimDate) - return FALSE; + return false; if (mClaimPricePerMeter != rhs.mClaimPricePerMeter) - return FALSE; + return false; if (mRentPricePerMeter != rhs.mRentPricePerMeter) - return FALSE; + return false; - return TRUE; + return true; } // Calculate rent @@ -787,16 +787,16 @@ void LLParcel::extendAABB(const LLVector3& box_min, const LLVector3& box_max) } } -BOOL LLParcel::addToAccessList(const LLUUID& agent_id, S32 time) +bool LLParcel::addToAccessList(const LLUUID& agent_id, S32 time) { if (mAccessList.size() >= (U32) PARCEL_MAX_ACCESS_LIST) { - return FALSE; + return false; } if (agent_id == getOwnerID()) { // Can't add owner to these lists - return FALSE; + return false; } LLAccessEntry::map::iterator itor = mAccessList.begin(); while (itor != mAccessList.end()) @@ -811,7 +811,7 @@ BOOL LLParcel::addToAccessList(const LLUUID& agent_id, S32 time) else { // existing one expires later - return FALSE; + return false; } } else @@ -825,20 +825,20 @@ BOOL LLParcel::addToAccessList(const LLUUID& agent_id, S32 time) new_entry.mTime = time; new_entry.mFlags = 0x0; mAccessList[new_entry.mID] = new_entry; - return TRUE; + return true; } -BOOL LLParcel::addToBanList(const LLUUID& agent_id, S32 time) +bool LLParcel::addToBanList(const LLUUID& agent_id, S32 time) { if (mBanList.size() >= (U32) PARCEL_MAX_ACCESS_LIST) { // Not using ban list, so not a rational thing to do - return FALSE; + return false; } if (agent_id == getOwnerID()) { // Can't add owner to these lists - return FALSE; + return false; } LLAccessEntry::map::iterator itor = mBanList.begin(); @@ -854,7 +854,7 @@ BOOL LLParcel::addToBanList(const LLUUID& agent_id, S32 time) else { // existing one expires later - return FALSE; + return false; } } else @@ -868,13 +868,13 @@ BOOL LLParcel::addToBanList(const LLUUID& agent_id, S32 time) new_entry.mTime = time; new_entry.mFlags = 0x0; mBanList[new_entry.mID] = new_entry; - return TRUE; + return true; } -BOOL remove_from_access_array(std::map<LLUUID,LLAccessEntry>* list, +bool remove_from_access_array(std::map<LLUUID,LLAccessEntry>* list, const LLUUID& agent_id) { - BOOL removed = FALSE; + bool removed = false; LLAccessEntry::map::iterator itor = list->begin(); while (itor != list->end()) { @@ -882,7 +882,7 @@ BOOL remove_from_access_array(std::map<LLUUID,LLAccessEntry>* list, if (entry.mID == agent_id) { list->erase(itor++); - removed = TRUE; + removed = true; } else { @@ -892,12 +892,12 @@ BOOL remove_from_access_array(std::map<LLUUID,LLAccessEntry>* list, return removed; } -BOOL LLParcel::removeFromAccessList(const LLUUID& agent_id) +bool LLParcel::removeFromAccessList(const LLUUID& agent_id) { return remove_from_access_array(&mAccessList, agent_id); } -BOOL LLParcel::removeFromBanList(const LLUUID& agent_id) +bool LLParcel::removeFromBanList(const LLUUID& agent_id) { return remove_from_access_array(&mBanList, agent_id); } @@ -947,13 +947,13 @@ const std::string& LLParcel::getActionString(LLParcel::EAction action) return PARCEL_ACTION_STRING[index]; } -BOOL LLParcel::isSaleTimerExpired(const U64& time) +bool LLParcel::isSaleTimerExpired(const U64& time) { - if (mSaleTimerExpires.getStarted() == FALSE) + if (!mSaleTimerExpires.getStarted()) { - return FALSE; + return false; } - BOOL expired = mSaleTimerExpires.checkExpirationAndReset(0.0); + bool expired = mSaleTimerExpires.checkExpirationAndReset(0.0); if (expired) { mSaleTimerExpires.stop(); @@ -961,13 +961,13 @@ BOOL LLParcel::isSaleTimerExpired(const U64& time) return expired; } -BOOL LLParcel::isMediaResetTimerExpired(const U64& time) +bool LLParcel::isMediaResetTimerExpired(const U64& time) { - if (mMediaResetTimer.getStarted() == FALSE) + if (!mMediaResetTimer.getStarted()) { - return FALSE; + return false; } - BOOL expired = mMediaResetTimer.checkExpirationAndReset(0.0); + bool expired = mMediaResetTimer.checkExpirationAndReset(0.0); if (expired) { mMediaResetTimer.stop(); @@ -976,7 +976,7 @@ BOOL LLParcel::isMediaResetTimerExpired(const U64& time) } -void LLParcel::startSale(const LLUUID& buyer_id, BOOL is_buyer_group) +void LLParcel::startSale(const LLUUID& buyer_id, bool is_buyer_group) { // TODO -- this and all Sale related methods need to move out of the LLParcel // base class and into server-side-only LLSimParcel class @@ -1011,11 +1011,11 @@ void LLParcel::expireSale( mSaleTimerExpires.setTimerExpirySec(0.0); mSaleTimerExpires.stop(); setPreviousOwnerID(LLUUID::null); - setPreviouslyGroupOwned(FALSE); - setSellWithObjects(FALSE); + setPreviouslyGroupOwned(false); + setSellWithObjects(false); type = TRANS_LAND_RELEASE; mStatus = OS_NONE; - flags = pack_transaction_flags(mGroupOwned, FALSE); + flags = pack_transaction_flags(mGroupOwned, false); mAuthBuyerID.setNull(); from_id = mOwnerID; mOwnerID.setNull(); @@ -1037,12 +1037,12 @@ void LLParcel::completeSale( // Purchased parcels are assumed to no longer be for sale. // Otherwise someone can snipe the sale. - setForSale(FALSE); + setForSale(false); setAuctionID(0); // Turn off show directory, since it's a recurring fee that // the buyer may not want. - setParcelFlag(PF_SHOW_DIRECTORY, FALSE); + setParcelFlag(PF_SHOW_DIRECTORY, false); //should be cleared on sale. mAccessList.clear(); @@ -1062,23 +1062,23 @@ void LLParcel::clearSale() mStatus = OS_LEASED; } mAuthBuyerID.setNull(); - setForSale(FALSE); + setForSale(false); setAuctionID(0); setPreviousOwnerID(LLUUID::null); - setPreviouslyGroupOwned(FALSE); - setSellWithObjects(FALSE); + setPreviouslyGroupOwned(false); + setSellWithObjects(false); } -BOOL LLParcel::isPublic() const +bool LLParcel::isPublic() const { return (mOwnerID.isNull()); } -BOOL LLParcel::isBuyerAuthorized(const LLUUID& buyer_id) const +bool LLParcel::isBuyerAuthorized(const LLUUID& buyer_id) const { if(mAuthBuyerID.isNull()) { - return TRUE; + return true; } return (mAuthBuyerID == buyer_id); } @@ -1093,15 +1093,15 @@ void LLParcel::clearParcel() setMediaID(LLUUID::null); setMediaDesc(LLStringUtil::null); setMediaAutoScale(0); - setMediaLoop(TRUE); + setMediaLoop(1); mMediaWidth = 0; mMediaHeight = 0; setMediaCurrentURL(LLStringUtil::null); - setMediaAllowNavigate(TRUE); - setMediaPreventCameraZoom(FALSE); + setMediaAllowNavigate(1); + setMediaPreventCameraZoom(0); setMediaURLTimeout(0.0f); setMusicURL(LLStringUtil::null); - setInEscrow(FALSE); + setInEscrow(false); setAuthorizedBuyerID(LLUUID::null); setCategory(C_NONE); setSnapshotID(LLUUID::null); @@ -1268,7 +1268,7 @@ void LLParcel::setExperienceKeyType( const LLUUID& experience_key, U32 type ) U32 LLParcel::countExperienceKeyType( U32 type ) { - return std::count_if( + return (U32)std::count_if( boost::begin(mExperienceKeys | boost::adaptors::map_values), boost::end(mExperienceKeys | boost::adaptors::map_values), [type](U32 key){ return (key == type); }); diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 8717f38ecf..5f116872b2 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -37,98 +37,98 @@ #include "llsettingsdaycycle.h" // Grid out of which parcels taken is stepped every 4 meters. -const F32 PARCEL_GRID_STEP_METERS = 4.f; +constexpr F32 PARCEL_GRID_STEP_METERS = 4.f; // Area of one "square" of parcel -const S32 PARCEL_UNIT_AREA = 16; +constexpr S32 PARCEL_UNIT_AREA = 16; // Height _above_ground_ that parcel boundary ends -const F32 PARCEL_HEIGHT = 50.f; +constexpr F32 PARCEL_HEIGHT = 50.f; //Height above ground which parcel boundries exist for explicitly banned avatars -const F32 BAN_HEIGHT = 5000.f; +constexpr F32 BAN_HEIGHT = 5000.f; // Maximum number of entries in an access list -const S32 PARCEL_MAX_ACCESS_LIST = 300; +constexpr S32 PARCEL_MAX_ACCESS_LIST = 300; //Maximum number of entires in an update packet //for access/ban lists. -const F32 PARCEL_MAX_ENTRIES_PER_PACKET = 48.f; +constexpr F32 PARCEL_MAX_ENTRIES_PER_PACKET = 48.f; // Maximum number of experiences -const S32 PARCEL_MAX_EXPERIENCE_LIST = 24; +constexpr S32 PARCEL_MAX_EXPERIENCE_LIST = 24; // Weekly charge for listing a parcel in the directory -const S32 PARCEL_DIRECTORY_FEE = 30; +constexpr S32 PARCEL_DIRECTORY_FEE = 30; -const S32 PARCEL_PASS_PRICE_DEFAULT = 10; -const F32 PARCEL_PASS_HOURS_DEFAULT = 1.f; +constexpr S32 PARCEL_PASS_PRICE_DEFAULT = 10; +constexpr F32 PARCEL_PASS_HOURS_DEFAULT = 1.f; // Number of "chunks" in which parcel overlay data is sent // Chunk 0 = southern rows, entire width -const S32 PARCEL_OVERLAY_CHUNKS = 4; +constexpr S32 PARCEL_OVERLAY_CHUNKS = 4; // Bottom three bits are a color index for the land overlay -const U8 PARCEL_COLOR_MASK = 0x07; -const U8 PARCEL_PUBLIC = 0x00; -const U8 PARCEL_OWNED = 0x01; -const U8 PARCEL_GROUP = 0x02; -const U8 PARCEL_SELF = 0x03; -const U8 PARCEL_FOR_SALE = 0x04; -const U8 PARCEL_AUCTION = 0x05; +constexpr U8 PARCEL_COLOR_MASK = 0x07; +constexpr U8 PARCEL_PUBLIC = 0x00; +constexpr U8 PARCEL_OWNED = 0x01; +constexpr U8 PARCEL_GROUP = 0x02; +constexpr U8 PARCEL_SELF = 0x03; +constexpr U8 PARCEL_FOR_SALE = 0x04; +constexpr U8 PARCEL_AUCTION = 0x05; // unused 0x06 // unused 0x07 // flag, unused 0x08 -const U8 PARCEL_HIDDENAVS = 0x10; // avatars not visible outside of parcel. Used for 'see avs' feature, but must be off for compatibility -const U8 PARCEL_SOUND_LOCAL = 0x20; -const U8 PARCEL_WEST_LINE = 0x40; // flag, property line on west edge -const U8 PARCEL_SOUTH_LINE = 0x80; // flag, property line on south edge +constexpr U8 PARCEL_HIDDENAVS = 0x10; // avatars not visible outside of parcel. Used for 'see avs' feature, but must be off for compatibility +constexpr U8 PARCEL_SOUND_LOCAL = 0x20; +constexpr U8 PARCEL_WEST_LINE = 0x40; // flag, property line on west edge +constexpr U8 PARCEL_SOUTH_LINE = 0x80; // flag, property line on south edge // Transmission results for parcel properties -const S32 PARCEL_RESULT_NO_DATA = -1; -const S32 PARCEL_RESULT_SUCCESS = 0; // got exactly one parcel -const S32 PARCEL_RESULT_MULTIPLE = 1; // got multiple parcels - -const S32 SELECTED_PARCEL_SEQ_ID = -10000; -const S32 COLLISION_NOT_IN_GROUP_PARCEL_SEQ_ID = -20000; -const S32 COLLISION_BANNED_PARCEL_SEQ_ID = -30000; -const S32 COLLISION_NOT_ON_LIST_PARCEL_SEQ_ID = -40000; -const S32 HOVERED_PARCEL_SEQ_ID = -50000; - -const U32 RT_NONE = 0x1 << 0; -const U32 RT_OWNER = 0x1 << 1; -const U32 RT_GROUP = 0x1 << 2; -const U32 RT_OTHER = 0x1 << 3; -const U32 RT_LIST = 0x1 << 4; -const U32 RT_SELL = 0x1 << 5; - -const S32 INVALID_PARCEL_ID = -1; - -const S32 INVALID_PARCEL_ENVIRONMENT_VERSION = -2; +constexpr S32 PARCEL_RESULT_NO_DATA = -1; +constexpr S32 PARCEL_RESULT_SUCCESS = 0; // got exactly one parcel +constexpr S32 PARCEL_RESULT_MULTIPLE = 1; // got multiple parcels + +constexpr S32 SELECTED_PARCEL_SEQ_ID = -10000; +constexpr S32 COLLISION_NOT_IN_GROUP_PARCEL_SEQ_ID = -20000; +constexpr S32 COLLISION_BANNED_PARCEL_SEQ_ID = -30000; +constexpr S32 COLLISION_NOT_ON_LIST_PARCEL_SEQ_ID = -40000; +constexpr S32 HOVERED_PARCEL_SEQ_ID = -50000; + +constexpr U32 RT_NONE = 0x1 << 0; +constexpr U32 RT_OWNER = 0x1 << 1; +constexpr U32 RT_GROUP = 0x1 << 2; +constexpr U32 RT_OTHER = 0x1 << 3; +constexpr U32 RT_LIST = 0x1 << 4; +constexpr U32 RT_SELL = 0x1 << 5; + +constexpr S32 INVALID_PARCEL_ID = -1; + +constexpr S32 INVALID_PARCEL_ENVIRONMENT_VERSION = -2; // if Region settings are used, parcel env. version is -1 -const S32 UNSET_PARCEL_ENVIRONMENT_VERSION = -1; +constexpr S32 UNSET_PARCEL_ENVIRONMENT_VERSION = -1; // Timeouts for parcels // default is 21 days * 24h/d * 60m/h * 60s/m *1000000 usec/s = 1814400000000 -const U64 DEFAULT_USEC_CONVERSION_TIMEOUT = U64L(1814400000000); +constexpr U64 DEFAULT_USEC_CONVERSION_TIMEOUT = U64L(1814400000000); // ***** TESTING is 10 minutes //const U64 DEFAULT_USEC_CONVERSION_TIMEOUT = U64L(600000000); // group is 60 days * 24h/d * 60m/h * 60s/m *1000000 usec/s = 5184000000000 -const U64 GROUP_USEC_CONVERSION_TIMEOUT = U64L(5184000000000); +constexpr U64 GROUP_USEC_CONVERSION_TIMEOUT = U64L(5184000000000); // ***** TESTING is 10 minutes //const U64 GROUP_USEC_CONVERSION_TIMEOUT = U64L(600000000); // default sale timeout is 2 days -> 172800000000 -const U64 DEFAULT_USEC_SALE_TIMEOUT = U64L(172800000000); +constexpr U64 DEFAULT_USEC_SALE_TIMEOUT = U64L(172800000000); // ***** TESTING is 10 minutes //const U64 DEFAULT_USEC_SALE_TIMEOUT = U64L(600000000); // more grace period extensions. -const U64 SEVEN_DAYS_IN_USEC = U64L(604800000000); +constexpr U64 SEVEN_DAYS_IN_USEC = U64L(604800000000); // if more than 100,000s before sale revert, and no extra extension // has been given, go ahead and extend it more. That's about 1.2 days. -const S32 EXTEND_GRACE_IF_MORE_THAN_SEC = 100000; +constexpr S32 EXTEND_GRACE_IF_MORE_THAN_SEC = 100000; @@ -209,37 +209,37 @@ public: LLParcel(); LLParcel( const LLUUID &owner_id, - BOOL modify, - BOOL terraform, - BOOL damage, + bool modify, + bool terraform, + bool damage, time_t claim_date, S32 claim_price, S32 rent_price, S32 area, S32 sim_object_limit, F32 parcel_object_bonus, - BOOL is_group_owned = FALSE); + bool is_group_owned = false); virtual ~LLParcel(); void init( const LLUUID &owner_id, - BOOL modify, - BOOL terraform, - BOOL damage, + bool modify, + bool terraform, + bool damage, time_t claim_date, S32 claim_price, S32 rent_price, S32 area, S32 sim_object_limit, F32 parcel_object_bonus, - BOOL is_group_owned = FALSE); + bool is_group_owned = false); // TODO: make an actual copy constructor for this void overrideParcelFlags(U32 flags); // if you specify an agent id here, the group id will be zeroed void overrideOwner( const LLUUID& owner_id, - BOOL is_group_owned = FALSE); + bool is_group_owned = false); void overrideSaleTimerExpires(F32 secs_left) { mSaleTimerExpires.setTimerExpirySec(secs_left); } // MANIPULATORS @@ -250,9 +250,9 @@ public: void setMediaURL(const std::string& url); void setMediaType(const std::string& type); void setMediaDesc(const std::string& desc); - void setMediaID(const LLUUID& id) { mMediaID = id; } - void setMediaAutoScale ( U8 flagIn ) { mMediaAutoScale = flagIn; } - void setMediaLoop (U8 loop) { mMediaLoop = loop; } + void setMediaID(const LLUUID& id) { mMediaID = id; } + void setMediaAutoScale ( U8 flagIn ) { mMediaAutoScale = flagIn; } + void setMediaLoop(U8 loop) { mMediaLoop = loop; } void setMediaWidth(S32 width); void setMediaHeight(S32 height); void setMediaCurrentURL(const std::string& url); @@ -277,35 +277,35 @@ public: void setUserLocation(const LLVector3& pos) { mUserLocation = pos; } void setUserLookAt(const LLVector3& rot) { mUserLookAt = rot; } void setLandingType(const ELandingType type) { mLandingType = type; } - void setSeeAVs(BOOL see_avs) { mSeeAVs = see_avs; } + void setSeeAVs(bool see_avs) { mSeeAVs = see_avs; } void setHaveNewParcelLimitData(bool have_new_parcel_data) { mHaveNewParcelLimitData = have_new_parcel_data; } // Remove this once hidden AV feature is fully available grid-wide void setAuctionID(U32 auction_id) { mAuctionID = auction_id;} void setAllParcelFlags(U32 flags); - void setParcelFlag(U32 flag, BOOL b); + void setParcelFlag(U32 flag, bool b); virtual void setArea(S32 area, S32 sim_object_limit); void setDiscountRate(F32 rate); - void setAllowModify(BOOL b) { setParcelFlag(PF_CREATE_OBJECTS, b); } - void setAllowGroupModify(BOOL b) { setParcelFlag(PF_CREATE_GROUP_OBJECTS, b); } - void setAllowAllObjectEntry(BOOL b) { setParcelFlag(PF_ALLOW_ALL_OBJECT_ENTRY, b); } - void setAllowGroupObjectEntry(BOOL b) { setParcelFlag(PF_ALLOW_GROUP_OBJECT_ENTRY, b); } - void setAllowTerraform(BOOL b){setParcelFlag(PF_ALLOW_TERRAFORM, b); } - void setAllowDamage(BOOL b) { setParcelFlag(PF_ALLOW_DAMAGE, b); } - void setAllowFly(BOOL b) { setParcelFlag(PF_ALLOW_FLY, b); } - void setAllowGroupScripts(BOOL b) { setParcelFlag(PF_ALLOW_GROUP_SCRIPTS, b); } - void setAllowOtherScripts(BOOL b) { setParcelFlag(PF_ALLOW_OTHER_SCRIPTS, b); } - void setAllowDeedToGroup(BOOL b) { setParcelFlag(PF_ALLOW_DEED_TO_GROUP, b); } - void setContributeWithDeed(BOOL b) { setParcelFlag(PF_CONTRIBUTE_WITH_DEED, b); } - void setForSale(BOOL b) { setParcelFlag(PF_FOR_SALE, b); } - void setSoundOnly(BOOL b) { setParcelFlag(PF_SOUND_LOCAL, b); } - void setDenyAnonymous(BOOL b) { setParcelFlag(PF_DENY_ANONYMOUS, b); } - void setDenyAgeUnverified(BOOL b) { setParcelFlag(PF_DENY_AGEUNVERIFIED, b); } - void setRestrictPushObject(BOOL b) { setParcelFlag(PF_RESTRICT_PUSHOBJECT, b); } - void setAllowGroupAVSounds(BOOL b) { mAllowGroupAVSounds = b; } - void setAllowAnyAVSounds(BOOL b) { mAllowAnyAVSounds = b; } + void setAllowModify(bool b) { setParcelFlag(PF_CREATE_OBJECTS, b); } + void setAllowGroupModify(bool b) { setParcelFlag(PF_CREATE_GROUP_OBJECTS, b); } + void setAllowAllObjectEntry(bool b) { setParcelFlag(PF_ALLOW_ALL_OBJECT_ENTRY, b); } + void setAllowGroupObjectEntry(bool b) { setParcelFlag(PF_ALLOW_GROUP_OBJECT_ENTRY, b); } + void setAllowTerraform(bool b){setParcelFlag(PF_ALLOW_TERRAFORM, b); } + void setAllowDamage(bool b) { setParcelFlag(PF_ALLOW_DAMAGE, b); } + void setAllowFly(bool b) { setParcelFlag(PF_ALLOW_FLY, b); } + void setAllowGroupScripts(bool b) { setParcelFlag(PF_ALLOW_GROUP_SCRIPTS, b); } + void setAllowOtherScripts(bool b) { setParcelFlag(PF_ALLOW_OTHER_SCRIPTS, b); } + void setAllowDeedToGroup(bool b) { setParcelFlag(PF_ALLOW_DEED_TO_GROUP, b); } + void setContributeWithDeed(bool b) { setParcelFlag(PF_CONTRIBUTE_WITH_DEED, b); } + void setForSale(bool b) { setParcelFlag(PF_FOR_SALE, b); } + void setSoundOnly(bool b) { setParcelFlag(PF_SOUND_LOCAL, b); } + void setDenyAnonymous(bool b) { setParcelFlag(PF_DENY_ANONYMOUS, b); } + void setDenyAgeUnverified(bool b) { setParcelFlag(PF_DENY_AGEUNVERIFIED, b); } + void setRestrictPushObject(bool b) { setParcelFlag(PF_RESTRICT_PUSHOBJECT, b); } + void setAllowGroupAVSounds(bool b) { mAllowGroupAVSounds = b; } + void setAllowAnyAVSounds(bool b) { mAllowAnyAVSounds = b; } void setObscureMOAP(bool b) { mObscureMOAP = b; } void setDrawDistance(F32 dist) { mDrawDistance = dist; } @@ -315,9 +315,9 @@ public: void setPassPrice(S32 price) { mPassPrice = price; } void setPassHours(F32 hours) { mPassHours = hours; } -// BOOL importStream(std::istream& input_stream); - BOOL importAccessEntry(std::istream& input_stream, LLAccessEntry* entry); - // BOOL exportStream(std::ostream& output_stream); +// bool importStream(std::istream& input_stream); + bool importAccessEntry(std::istream& input_stream, LLAccessEntry* entry); + // bool exportStream(std::ostream& output_stream); void packMessage(LLMessageSystem* msg); void packMessage(LLSD& msg); @@ -343,11 +343,11 @@ public: // time earlier than "now". void expirePasses(S32 now); - // Add to list, suppressing duplicates. Returns TRUE if added. - BOOL addToAccessList(const LLUUID& agent_id, S32 time); - BOOL addToBanList(const LLUUID& agent_id, S32 time); - BOOL removeFromAccessList(const LLUUID& agent_id); - BOOL removeFromBanList(const LLUUID& agent_id); + // Add to list, suppressing duplicates. Returns true if added. + bool addToAccessList(const LLUUID& agent_id, S32 time); + bool addToBanList(const LLUUID& agent_id, S32 time); + bool removeFromAccessList(const LLUUID& agent_id); + bool removeFromBanList(const LLUUID& agent_id); // ACCESSORS const LLUUID& getID() const { return mID; } @@ -372,19 +372,19 @@ public: const LLUUID& getGroupID() const { return mGroupID; } S32 getPassPrice() const { return mPassPrice; } F32 getPassHours() const { return mPassHours; } - BOOL getIsGroupOwned() const { return mGroupOwned; } + bool getIsGroupOwned() const { return mGroupOwned; } U32 getAuctionID() const { return mAuctionID; } bool isInEscrow() const { return mInEscrow; } - BOOL isPublic() const; + bool isPublic() const; // Region-local user-specified position const LLVector3& getUserLocation() const { return mUserLocation; } const LLVector3& getUserLookAt() const { return mUserLookAt; } ELandingType getLandingType() const { return mLandingType; } - BOOL getSeeAVs() const { return mSeeAVs; } - BOOL getHaveNewParcelLimitData() const { return mHaveNewParcelLimitData; } + bool getSeeAVs() const { return mSeeAVs; } + bool getHaveNewParcelLimitData() const { return mHaveNewParcelLimitData; } // User-specified snapshot const LLUUID& getSnapshotID() const { return mSnapshotID; } @@ -395,7 +395,7 @@ public: const LLUUID& getAuthorizedBuyerID() const { return mAuthBuyerID; } // helper function - BOOL isBuyerAuthorized(const LLUUID& buyer_id) const; + bool isBuyerAuthorized(const LLUUID& buyer_id) const; // The buyer of a plot is set when someone indicates they want to // buy the plot, and the system is simply waiting for tier-up @@ -419,10 +419,10 @@ public: // dealing with sales and parcel conversion. // - // the isSaleTimerExpired will trivially return FALSE if there is + // the isSaleTimerExpired will trivially return false if there is // no sale going on. Pass in the current time in usec which will // be used for comparison. - BOOL isSaleTimerExpired(const U64& time); + bool isSaleTimerExpired(const U64& time); F32 getSaleTimerExpires() { return mSaleTimerExpires.getRemainingTimeF32(); } @@ -431,7 +431,7 @@ public: // need to record a few things with the parcel when a sale // starts. - void startSale(const LLUUID& buyer_id, BOOL is_buyer_group); + void startSale(const LLUUID& buyer_id, bool is_buyer_group); // do the expiration logic, which needs to return values usable in // a L$ transaction. @@ -440,86 +440,54 @@ public: void clearSale(); - BOOL isMediaResetTimerExpired(const U64& time); + bool isMediaResetTimerExpired(const U64& time); // more accessors - U32 getParcelFlags() const { return mParcelFlags; } + U32 getParcelFlags() const { return mParcelFlags; } - BOOL getParcelFlag(U32 flag) const - { return (mParcelFlags & flag) ? TRUE : FALSE; } + bool getParcelFlag(U32 flag) const { return (mParcelFlags & flag) != 0; } // objects can be added or modified by anyone (only parcel owner if disabled) - BOOL getAllowModify() const - { return (mParcelFlags & PF_CREATE_OBJECTS) ? TRUE : FALSE; } + bool getAllowModify() const { return getParcelFlag(PF_CREATE_OBJECTS); } // objects can be added or modified by group members - BOOL getAllowGroupModify() const - { return (mParcelFlags & PF_CREATE_GROUP_OBJECTS) ? TRUE : FALSE; } + bool getAllowGroupModify() const { return getParcelFlag(PF_CREATE_GROUP_OBJECTS); } // the parcel can be deeded to the group - BOOL getAllowDeedToGroup() const - { return (mParcelFlags & PF_ALLOW_DEED_TO_GROUP) ? TRUE : FALSE; } + bool getAllowDeedToGroup() const { return getParcelFlag(PF_ALLOW_DEED_TO_GROUP); } // Does the owner want to make a contribution along with the deed. - BOOL getContributeWithDeed() const - { return (mParcelFlags & PF_CONTRIBUTE_WITH_DEED) ? TRUE : FALSE; } + bool getContributeWithDeed() const { return getParcelFlag(PF_CONTRIBUTE_WITH_DEED); } // heightfield can be modified - BOOL getAllowTerraform() const - { return (mParcelFlags & PF_ALLOW_TERRAFORM) ? TRUE : FALSE; } + bool getAllowTerraform() const { return getParcelFlag(PF_ALLOW_TERRAFORM); } // avatars can be hurt here - BOOL getAllowDamage() const - { return (mParcelFlags & PF_ALLOW_DAMAGE) ? TRUE : FALSE; } - - BOOL getAllowFly() const - { return (mParcelFlags & PF_ALLOW_FLY) ? TRUE : FALSE; } - - BOOL getAllowGroupScripts() const - { return (mParcelFlags & PF_ALLOW_GROUP_SCRIPTS) ? TRUE : FALSE; } - - BOOL getAllowOtherScripts() const - { return (mParcelFlags & PF_ALLOW_OTHER_SCRIPTS) ? TRUE : FALSE; } - - BOOL getAllowAllObjectEntry() const - { return (mParcelFlags & PF_ALLOW_ALL_OBJECT_ENTRY) ? TRUE : FALSE; } - - BOOL getAllowGroupObjectEntry() const - { return (mParcelFlags & PF_ALLOW_GROUP_OBJECT_ENTRY) ? TRUE : FALSE; } - - BOOL getForSale() const - { return (mParcelFlags & PF_FOR_SALE) ? TRUE : FALSE; } - BOOL getSoundLocal() const - { return (mParcelFlags & PF_SOUND_LOCAL) ? TRUE : FALSE; } - BOOL getParcelFlagAllowVoice() const - { return (mParcelFlags & PF_ALLOW_VOICE_CHAT) ? TRUE : FALSE; } - BOOL getParcelFlagUseEstateVoiceChannel() const - { return (mParcelFlags & PF_USE_ESTATE_VOICE_CHAN) ? TRUE : FALSE; } - BOOL getAllowPublish() const - { return (mParcelFlags & PF_ALLOW_PUBLISH) ? TRUE : FALSE; } - BOOL getMaturePublish() const - { return (mParcelFlags & PF_MATURE_PUBLISH) ? TRUE : FALSE; } - BOOL getRestrictPushObject() const - { return (mParcelFlags & PF_RESTRICT_PUSHOBJECT) ? TRUE : FALSE; } - BOOL getRegionPushOverride() const - { return mRegionPushOverride; } - BOOL getRegionDenyAnonymousOverride() const - { return mRegionDenyAnonymousOverride; } - BOOL getRegionDenyAgeUnverifiedOverride() const - { return mRegionDenyAgeUnverifiedOverride; } - BOOL getRegionAllowAccessOverride() const - { return mRegionAllowAccessoverride; } - BOOL getRegionAllowEnvironmentOverride() const - { return mRegionAllowEnvironmentOverride; } - S32 getParcelEnvironmentVersion() const - { return mCurrentEnvironmentVersion; } - - - BOOL getAllowGroupAVSounds() const { return mAllowGroupAVSounds; } - BOOL getAllowAnyAVSounds() const { return mAllowAnyAVSounds; } - - bool getObscureMOAP() const { return mObscureMOAP; } + bool getAllowDamage() const { return getParcelFlag(PF_ALLOW_DAMAGE); } + + bool getAllowFly() const { return getParcelFlag(PF_ALLOW_FLY); } + bool getAllowGroupScripts() const { return getParcelFlag(PF_ALLOW_GROUP_SCRIPTS); } + bool getAllowOtherScripts() const { return getParcelFlag(PF_ALLOW_OTHER_SCRIPTS); } + bool getAllowAllObjectEntry() const { return getParcelFlag(PF_ALLOW_ALL_OBJECT_ENTRY); } + bool getAllowGroupObjectEntry() const { return getParcelFlag(PF_ALLOW_GROUP_OBJECT_ENTRY); } + bool getForSale() const { return getParcelFlag(PF_FOR_SALE); } + bool getSoundLocal() const { return getParcelFlag(PF_SOUND_LOCAL); } + bool getParcelFlagAllowVoice() const { return getParcelFlag(PF_ALLOW_VOICE_CHAT); } + bool getParcelFlagUseEstateVoiceChannel() const { return getParcelFlag(PF_USE_ESTATE_VOICE_CHAN); } + bool getAllowPublish() const { return getParcelFlag(PF_ALLOW_PUBLISH); } + bool getMaturePublish() const { return getParcelFlag(PF_MATURE_PUBLISH); } + bool getRestrictPushObject() const { return getParcelFlag(PF_RESTRICT_PUSHOBJECT); } + + bool getRegionPushOverride() const { return mRegionPushOverride; } + bool getRegionDenyAnonymousOverride() const { return mRegionDenyAnonymousOverride; } + bool getRegionDenyAgeUnverifiedOverride() const { return mRegionDenyAgeUnverifiedOverride; } + bool getRegionAllowAccessOverride() const { return mRegionAllowAccessoverride; } + bool getRegionAllowEnvironmentOverride() const { return mRegionAllowEnvironmentOverride; } + S32 getParcelEnvironmentVersion() const { return mCurrentEnvironmentVersion; } + bool getAllowGroupAVSounds() const { return mAllowGroupAVSounds; } + bool getAllowAnyAVSounds() const { return mAllowAnyAVSounds; } + bool getObscureMOAP() const { return mObscureMOAP; } F32 getDrawDistance() const { return mDrawDistance; } S32 getSalePrice() const { return mSalePrice; } @@ -537,10 +505,10 @@ public: S32 getClaimPrice() const { return mClaimPricePerMeter * mArea; } // Can this agent create objects here? - BOOL allowModifyBy(const LLUUID &agent_id, const LLUUID &group_id) const; + bool allowModifyBy(const LLUUID &agent_id, const LLUUID &group_id) const; // Can this agent change the shape of the land? - BOOL allowTerraformBy(const LLUUID &agent_id) const; + bool allowTerraformBy(const LLUUID &agent_id) const; bool operator==(const LLParcel &rhs) const; @@ -582,30 +550,30 @@ public: void setParcelPrimBonus(F32 bonus) { mParcelPrimBonus = bonus; } void setCleanOtherTime(S32 time) { mCleanOtherTime = time; } - void setRegionPushOverride(BOOL override) {mRegionPushOverride = override; } - void setRegionDenyAnonymousOverride(BOOL override) { mRegionDenyAnonymousOverride = override; } - void setRegionDenyAgeUnverifiedOverride(BOOL override) { mRegionDenyAgeUnverifiedOverride = override; } - void setRegionAllowAccessOverride(BOOL override) { mRegionAllowAccessoverride = override; } - void setRegionAllowEnvironmentOverride(BOOL override) { mRegionAllowEnvironmentOverride = override; } + void setRegionPushOverride(bool override) {mRegionPushOverride = override; } + void setRegionDenyAnonymousOverride(bool override) { mRegionDenyAnonymousOverride = override; } + void setRegionDenyAgeUnverifiedOverride(bool override) { mRegionDenyAgeUnverifiedOverride = override; } + void setRegionAllowAccessOverride(bool override) { mRegionAllowAccessoverride = override; } + void setRegionAllowEnvironmentOverride(bool override) { mRegionAllowEnvironmentOverride = override; } void setParcelEnvironmentVersion(S32 version) { mCurrentEnvironmentVersion = version; } // Accessors for parcel sellWithObjects void setPreviousOwnerID(LLUUID prev_owner) { mPreviousOwnerID = prev_owner; } - void setPreviouslyGroupOwned(BOOL b) { mPreviouslyGroupOwned = b; } - void setSellWithObjects(BOOL b) { setParcelFlag(PF_SELL_PARCEL_OBJECTS, b); } + void setPreviouslyGroupOwned(bool b) { mPreviouslyGroupOwned = b; } + void setSellWithObjects(bool b) { setParcelFlag(PF_SELL_PARCEL_OBJECTS, b); } LLUUID getPreviousOwnerID() const { return mPreviousOwnerID; } - BOOL getPreviouslyGroupOwned() const { return mPreviouslyGroupOwned; } - BOOL getSellWithObjects() const { return (mParcelFlags & PF_SELL_PARCEL_OBJECTS) ? TRUE : FALSE; } + bool getPreviouslyGroupOwned() const { return mPreviouslyGroupOwned; } + bool getSellWithObjects() const { return getParcelFlag(PF_SELL_PARCEL_OBJECTS); } protected: LLUUID mID; LLUUID mOwnerID; LLUUID mGroupID; - BOOL mGroupOwned; // TRUE if mOwnerID is a group_id + bool mGroupOwned; // true if mOwnerID is a group_id LLUUID mPreviousOwnerID; - BOOL mPreviouslyGroupOwned; + bool mPreviouslyGroupOwned; EOwnershipStatus mStatus; ECategory mCategory; @@ -614,8 +582,8 @@ protected: LLVector3 mUserLocation; LLVector3 mUserLookAt; ELandingType mLandingType; - BOOL mSeeAVs; // Avatars on this parcel are visible from outside it - BOOL mHaveNewParcelLimitData; // Remove once hidden AV feature is grid-wide + bool mSeeAVs; // Avatars on this parcel are visible from outside it + bool mHaveNewParcelLimitData; // Remove once hidden AV feature is grid-wide LLTimer mSaleTimerExpires; LLTimer mMediaResetTimer; @@ -666,13 +634,13 @@ protected: S32 mTempPrimCount; F32 mParcelPrimBonus; S32 mCleanOtherTime; - BOOL mRegionPushOverride; - BOOL mRegionDenyAnonymousOverride; - BOOL mRegionDenyAgeUnverifiedOverride; - BOOL mRegionAllowAccessoverride; - BOOL mRegionAllowEnvironmentOverride; - BOOL mAllowGroupAVSounds; - BOOL mAllowAnyAVSounds; + bool mRegionPushOverride; + bool mRegionDenyAnonymousOverride; + bool mRegionDenyAgeUnverifiedOverride; + bool mRegionAllowAccessoverride; + bool mRegionAllowEnvironmentOverride; + bool mAllowGroupAVSounds; + bool mAllowAnyAVSounds; bool mObscureMOAP; S32 mCurrentEnvironmentVersion; @@ -692,13 +660,11 @@ public: void setExperienceKeyType(const LLUUID& experience_key, U32 type); U32 countExperienceKeyType(U32 type); - U32 getExperienceKeyType(const LLUUID& experience_key)const; LLAccessEntry::map getExperienceKeysByType(U32 type)const; void clearExperienceKeysByType(U32 type); private: xp_type_map_t mExperienceKeys; - }; diff --git a/indra/llinventory/llpermissions.cpp b/indra/llinventory/llpermissions.cpp index 65df5ebb91..c8963881df 100644 --- a/indra/llinventory/llpermissions.cpp +++ b/indra/llinventory/llpermissions.cpp @@ -87,21 +87,21 @@ void LLPermissions::initMasks(LLInventoryType::EType type) } } -BOOL LLPermissions::getOwnership(LLUUID& owner_id, BOOL& is_group_owned) const +bool LLPermissions::getOwnership(LLUUID& owner_id, bool& is_group_owned) const { if(mOwner.notNull()) { owner_id = mOwner; - is_group_owned = FALSE; - return TRUE; + is_group_owned = false; + return true; } else if(mIsGroupOwned) { owner_id = mGroup; - is_group_owned = TRUE; - return TRUE; + is_group_owned = true; + return true; } - return FALSE; + return false; } LLUUID LLPermissions::getSafeOwner() const @@ -232,13 +232,13 @@ void LLPermissions::accumulate(const LLPermissions& perm) // saves last owner, sets current owner, and sets the group. note // that this function has to more cleverly apply the fair use // permissions. -BOOL LLPermissions::setOwnerAndGroup( +bool LLPermissions::setOwnerAndGroup( const LLUUID& agent, const LLUUID& owner, const LLUUID& group, bool is_atomic) { - BOOL allowed = FALSE; + bool allowed = false; if( agent.isNull() || mOwner.isNull() || ((agent == mOwner) && ((owner == mOwner) || (mMaskOwner & PERM_TRANSFER)) ) ) @@ -246,7 +246,7 @@ BOOL LLPermissions::setOwnerAndGroup( // ...system can alway set owner // ...public objects can be claimed by anyone // ...otherwise, agent must own it and have transfer ability - allowed = TRUE; + allowed = true; } if (allowed) @@ -301,7 +301,7 @@ void LLPermissions::yesReallySetOwner(const LLUUID& owner, bool group_owned) mIsGroupOwned = group_owned; } -BOOL LLPermissions::deedToGroup(const LLUUID& agent, const LLUUID& group) +bool LLPermissions::deedToGroup(const LLUUID& agent, const LLUUID& group) { if(group.notNull() && (agent.isNull() || ((group == mGroup) && (mMaskOwner & PERM_TRANSFER) @@ -318,18 +318,18 @@ BOOL LLPermissions::deedToGroup(const LLUUID& agent, const LLUUID& group) mIsGroupOwned = true; fixFairUse(); fix(); - return TRUE; + return true; } - return FALSE; + return false; } -BOOL LLPermissions::setBaseBits(const LLUUID& agent, BOOL set, PermissionMask bits) +bool LLPermissions::setBaseBits(const LLUUID& agent, bool set, PermissionMask bits) { - BOOL ownership = FALSE; + bool ownership = false; if(agent.isNull()) { // only the system is always allowed to change base bits - ownership = TRUE; + ownership = true; } if (ownership) @@ -351,19 +351,19 @@ BOOL LLPermissions::setBaseBits(const LLUUID& agent, BOOL set, PermissionMask bi // Note: If you attempt to set bits that the base bits doesn't allow, // the function will succeed, but those bits will not be set. -BOOL LLPermissions::setOwnerBits(const LLUUID& agent, BOOL set, PermissionMask bits) +bool LLPermissions::setOwnerBits(const LLUUID& agent, bool set, PermissionMask bits) { - BOOL ownership = FALSE; + bool ownership = false; if(agent.isNull()) { // ...system always allowed to change things - ownership = TRUE; + ownership = true; } else if (agent == mOwner) { // ...owner bits can only be set by owner - ownership = TRUE; + ownership = true; } // If we have correct ownership and @@ -383,15 +383,15 @@ BOOL LLPermissions::setOwnerBits(const LLUUID& agent, BOOL set, PermissionMask b return (ownership); } -BOOL LLPermissions::setGroupBits(const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits) +bool LLPermissions::setGroupBits(const LLUUID& agent, const LLUUID& group, bool set, PermissionMask bits) { - BOOL ownership = FALSE; + bool ownership = false; if((agent.isNull()) || (agent == mOwner) || ((group == mGroup) && (!mGroup.isNull()))) { // The group bits can be set by the system, the owner, or a // group member. - ownership = TRUE; + ownership = true; } if (ownership) @@ -412,15 +412,15 @@ BOOL LLPermissions::setGroupBits(const LLUUID& agent, const LLUUID& group, BOOL // Note: If you attempt to set bits that the creator or owner doesn't allow, // the function will succeed, but those bits will not be set. -BOOL LLPermissions::setEveryoneBits(const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits) +bool LLPermissions::setEveryoneBits(const LLUUID& agent, const LLUUID& group, bool set, PermissionMask bits) { - BOOL ownership = FALSE; + bool ownership = false; if((agent.isNull()) || (agent == mOwner) || ((group == mGroup) && (!mGroup.isNull()))) { // The everyone bits can be set by the system, the owner, or a // group member. - ownership = TRUE; + ownership = true; } if (ownership) { @@ -441,15 +441,15 @@ BOOL LLPermissions::setEveryoneBits(const LLUUID& agent, const LLUUID& group, BO // Note: If you attempt to set bits that the creator or owner doesn't allow, // the function will succeed, but those bits will not be set. -BOOL LLPermissions::setNextOwnerBits(const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits) +bool LLPermissions::setNextOwnerBits(const LLUUID& agent, const LLUUID& group, bool set, PermissionMask bits) { - BOOL ownership = FALSE; + bool ownership = false; if((agent.isNull()) || (agent == mOwner) || ((group == mGroup) && (!mGroup.isNull()))) { // The next owner bits can be set by the system, the owner, or // a group member. - ownership = TRUE; + ownership = true; } if (ownership) { @@ -478,7 +478,7 @@ bool LLPermissions::allowOperationBy(PermissionBit op, const LLUUID& requester, { // ...system making request // ...not owned - return TRUE; + return true; } else if (mIsGroupOwned && (mGroup == requester)) { @@ -513,7 +513,7 @@ LLSD LLPermissions::packMessage() const result["group-mask"] = (S32)mMaskGroup; result["everyone-mask"] = (S32)mMaskEveryone; result["next-owner-mask"]= (S32)mMaskNextOwner; - result["group-owned"] = (BOOL)mIsGroupOwned; + result["group-owned"] = (bool)mIsGroupOwned; return result; } @@ -531,7 +531,7 @@ void LLPermissions::packMessage(LLMessageSystem* msg) const msg->addU32Fast(_PREHASH_GroupMask, mMaskGroup ); msg->addU32Fast(_PREHASH_EveryoneMask, mMaskEveryone ); msg->addU32Fast(_PREHASH_NextOwnerMask, mMaskNextOwner ); - msg->addBOOLFast(_PREHASH_GroupOwned, (BOOL)mIsGroupOwned); + msg->addBOOLFast(_PREHASH_GroupOwned, mIsGroupOwned); } void LLPermissions::unpackMessage(LLSD perms) @@ -559,13 +559,13 @@ void LLPermissions::unpackMessage(LLMessageSystem* msg, const char* block, S32 b msg->getU32Fast(block, _PREHASH_GroupMask, mMaskGroup, block_num ); msg->getU32Fast(block, _PREHASH_EveryoneMask, mMaskEveryone, block_num ); msg->getU32Fast(block, _PREHASH_NextOwnerMask, mMaskNextOwner, block_num ); - BOOL tmp; + bool tmp; msg->getBOOLFast(block, _PREHASH_GroupOwned, tmp, block_num); - mIsGroupOwned = (bool)tmp; + mIsGroupOwned = tmp; } -BOOL LLPermissions::importLegacyStream(std::istream& input_stream) +bool LLPermissions::importLegacyStream(std::istream& input_stream) { init(LLUUID::null, LLUUID::null, LLUUID::null, LLUUID::null); const S32 BUFSIZE = 16384; @@ -661,11 +661,11 @@ BOOL LLPermissions::importLegacyStream(std::istream& input_stream) } } fix(); - return TRUE; + return true; } -BOOL LLPermissions::exportLegacyStream(std::ostream& output_stream) const +bool LLPermissions::exportLegacyStream(std::ostream& output_stream) const { std::string uuid_str; @@ -701,12 +701,9 @@ BOOL LLPermissions::exportLegacyStream(std::ostream& output_stream) const output_stream << "\t\tgroup_owned\t1\n"; } output_stream << "\t}\n"; - return TRUE; + return true; } -// Deleted LLPermissions::exportFileXML() and LLPermissions::importXML() -// because I can't find any non-test code references to it. 2009-05-04 JC - bool LLPermissions::operator==(const LLPermissions &rhs) const { return @@ -791,21 +788,21 @@ U8 LLAggregatePermissions::getU8() const return byte; } -BOOL LLAggregatePermissions::isEmpty() const +bool LLAggregatePermissions::isEmpty() const { for(S32 i = 0; i < PI_END; ++i) { if(mBits[i] != AP_EMPTY) { - return FALSE; + return false; } } - return TRUE; + return true; } void LLAggregatePermissions::aggregate(PermissionMask mask) { - BOOL is_allowed = mask & PERM_COPY; + bool is_allowed = mask & PERM_COPY; aggregateBit(PI_COPY, is_allowed); is_allowed = mask & PERM_MODIFY; aggregateBit(PI_MODIFY, is_allowed); @@ -821,7 +818,7 @@ void LLAggregatePermissions::aggregate(const LLAggregatePermissions& ag) } } -void LLAggregatePermissions::aggregateBit(EPermIndex idx, BOOL allowed) +void LLAggregatePermissions::aggregateBit(EPermIndex idx, bool allowed) { //if(AP_SOME == mBits[idx]) return; // P4 branch prediction optimization switch(mBits[idx]) diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h index b6071118ff..a68abcfa34 100644 --- a/indra/llinventory/llpermissions.h +++ b/indra/llinventory/llpermissions.h @@ -151,18 +151,18 @@ public: U32 getMaskEveryone() const { return mMaskEveryone; } U32 getMaskNextOwner() const { return mMaskNextOwner; } - // return TRUE if the object has any owner + // return true if the object has any owner bool isOwned() const { return (mOwner.notNull() || mIsGroupOwned); } - // return TRUE if group_id is owner. + // return true if group_id is owner. bool isGroupOwned() const { return mIsGroupOwned; } - // This API returns TRUE if the object is owned at all, and FALSE + // This API returns true if the object is owned at all, and false // otherwise. If it is owned at all, owner id is filled with // either the owner id or the group id, and the is_group_owned // parameter is appropriately filled. The values of owner_id and // is_group_owned are not changed if the object is not owned. - BOOL getOwnership(LLUUID& owner_id, BOOL& is_group_owned) const; + bool getOwnership(LLUUID& owner_id, bool& is_group_owned) const; // Gets the 'safe' owner. This should never return LLUUID::null. // If no group owned, return the agent owner id normally. @@ -218,7 +218,7 @@ public: // Currently, the only way to have a collection is when an object // has inventory and is then itself rolled up into an inventory // item. - BOOL setOwnerAndGroup(const LLUUID& agent, const LLUUID& owner, const LLUUID& group, bool is_atomic); + bool setOwnerAndGroup(const LLUUID& agent, const LLUUID& owner, const LLUUID& group, bool is_atomic); // only call this if you know what you're doing // there are usually perm-bit consequences when the @@ -237,18 +237,18 @@ public: // checked manipulators (since that is how it is used.) If the // agent is the system or (group == mGroup and group modify and // owner transfer) then this function will deed the permissions, - // set the next owner mask, and return TRUE. Otherwise, no change - // is effected, and the function returns FALSE. - BOOL deedToGroup(const LLUUID& agent, const LLUUID& group); - // Attempt to set or clear the given bitmask. Returns TRUE if you + // set the next owner mask, and return true. Otherwise, no change + // is effected, and the function returns false. + bool deedToGroup(const LLUUID& agent, const LLUUID& group); + // Attempt to set or clear the given bitmask. Returns true if you // are allowed to modify the permissions. If you attempt to turn // on bits not allowed by the base bits, the function will return - // TRUE, but those bits will not be set. - BOOL setBaseBits( const LLUUID& agent, BOOL set, PermissionMask bits); - BOOL setOwnerBits( const LLUUID& agent, BOOL set, PermissionMask bits); - BOOL setGroupBits( const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits); - BOOL setEveryoneBits(const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits); - BOOL setNextOwnerBits(const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits); + // true, but those bits will not be set. + bool setBaseBits( const LLUUID& agent, bool set, PermissionMask bits); + bool setOwnerBits( const LLUUID& agent, bool set, PermissionMask bits); + bool setGroupBits( const LLUUID& agent, const LLUUID& group, bool set, PermissionMask bits); + bool setEveryoneBits(const LLUUID& agent, const LLUUID& group, bool set, PermissionMask bits); + bool setNextOwnerBits(const LLUUID& agent, const LLUUID& group, bool set, PermissionMask bits); // This is currently only used in the Viewer to handle calling cards // where the creator is actually used to store the target. Use with care. @@ -270,6 +270,7 @@ public: inline bool allowModifyBy(const LLUUID &agent_id) const; inline bool allowCopyBy(const LLUUID& agent_id) const; inline bool allowMoveBy(const LLUUID& agent_id) const; + inline bool allowModifyBy(const LLUUID &agent_id, const LLUUID& group) const; inline bool allowCopyBy(const LLUUID& agent_id, const LLUUID& group) const; inline bool allowMoveBy(const LLUUID &agent_id, const LLUUID &group) const; @@ -278,27 +279,11 @@ public: // current owner is allowed to transfer to the specified agent id. inline bool allowTransferTo(const LLUUID &agent_id) const; - // - // DEPRECATED. - // - // These return true if the given agent can perform the function. - // They also return true if the object isn't owned, or the - // requesting agent is a system agent. See llpermissionsflags.h - // for bits. - //BOOL allowDeleteBy(const LLUUID& agent_id) const { return allowModifyBy(agent_id); } - //BOOL allowEditBy(const LLUUID& agent_id) const { return allowModifyBy(agent_id); } - // saves last owner and sets current owner - //BOOL setOwner(const LLUUID& agent, const LLUUID& owner); - // This method saves the last owner, sets the current owner to the - // one provided, and sets the base mask as indicated. - //BOOL setOwner(const LLUUID& agent, const LLUUID& owner, U32 new_base_mask); - - // Attempt to set or clear the given bitmask. Returns TRUE if you - // are allowed to modify the permissions. If you attempt to turn - // on bits not allowed by the base bits, the function will return - // TRUE, but those bits will not be set. - //BOOL setGroupBits( const LLUUID& agent, BOOL set, PermissionMask bits); - //BOOL setEveryoneBits(const LLUUID& agent, BOOL set, PermissionMask bits); + // Returns true if the object can exported by the given agent + // (e.g. saved as a local .gltf file) + // The current test should return true if the agent is the owner + // AND the creator of the object. + inline bool allowExportBy(const LLUUID& agent_id) const; // // MISC METHODS and OPERATORS @@ -311,8 +296,8 @@ public: void packMessage(LLMessageSystem* msg) const; void unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0); - BOOL importLegacyStream(std::istream& input_stream); - BOOL exportLegacyStream(std::ostream& output_stream) const; + bool importLegacyStream(std::istream& input_stream); + bool exportLegacyStream(std::ostream& output_stream) const; bool operator==(const LLPermissions &rhs) const; bool operator!=(const LLPermissions &rhs) const; @@ -353,6 +338,11 @@ bool LLPermissions::allowMoveBy(const LLUUID& agent) const return allowOperationBy(PERM_MOVE, agent, LLUUID::null); } +bool LLPermissions::allowExportBy(const LLUUID& agent) const +{ + return agent == mOwner && agent == mCreator; +} + bool LLPermissions::allowTransferTo(const LLUUID &agent_id) const { if (mIsGroupOwned) @@ -361,7 +351,7 @@ bool LLPermissions::allowTransferTo(const LLUUID &agent_id) const } else { - return ((mOwner == agent_id) ? TRUE : allowOperationBy(PERM_TRANSFER, mOwner)); + return ((mOwner == agent_id) ? true : allowOperationBy(PERM_TRANSFER, mOwner)); } } @@ -401,8 +391,8 @@ public: // LSB is to the right U8 getU8() const; - // return TRUE is the aggregate permissions are empty, otherwise FALSE. - BOOL isEmpty() const ; + // return true is the aggregate permissions are empty, otherwise false. + bool isEmpty() const ; // pass in a PERM_COPY, PERM_TRANSFER, etc, and an EValue // enumeration to specifically set that value. Not implemented @@ -432,7 +422,7 @@ protected: PI_END = 3, PI_COUNT = 3 }; - void aggregateBit(EPermIndex idx, BOOL allowed); + void aggregateBit(EPermIndex idx, bool allowed); void aggregateIndex(EPermIndex idx, U8 bits); static EPermIndex perm2PermIndex(PermissionBit bit); diff --git a/indra/llinventory/llpermissionsflags.h b/indra/llinventory/llpermissionsflags.h index aaf1fd3afb..0ab4de0ab2 100644 --- a/indra/llinventory/llpermissionsflags.h +++ b/indra/llinventory/llpermissionsflags.h @@ -37,48 +37,48 @@ typedef U32 PermissionBit; // Do you have permission to transfer ownership of the object or // item. Fair use rules dictate that if you cannot copy, you can // always transfer. -const PermissionBit PERM_TRANSFER = (1 << 13); // 0x00002000 +constexpr PermissionBit PERM_TRANSFER = (1 << 13); // 0x00002000 // objects, scale or change textures // parcels, allow building on it -const PermissionBit PERM_MODIFY = (1 << 14); // 0x00004000 +constexpr PermissionBit PERM_MODIFY = (1 << 14); // 0x00004000 // objects, allow copy -const PermissionBit PERM_COPY = (1 << 15); // 0x00008000 +constexpr PermissionBit PERM_COPY = (1 << 15); // 0x00008000 // parcels, allow entry, deprecated -//const PermissionBit PERM_ENTER = (1 << 16); // 0x00010000 +//constexpr PermissionBit PERM_ENTER = (1 << 16); // 0x00010000 // parcels, allow terraform, deprecated -//const PermissionBit PERM_TERRAFORM = (1 << 17); // 0x00020000 +//constexpr PermissionBit PERM_TERRAFORM = (1 << 17); // 0x00020000 // NOTA BENE: This flag is NO LONGER USED!!! However, it is possible that some // objects in the universe have it set so DON"T USE IT going forward. -//const PermissionBit PERM_OWNER_DEBIT = (1 << 18); // 0x00040000 +//constexpr PermissionBit PERM_OWNER_DEBIT = (1 << 18); // 0x00040000 // objects, can grab/translate/rotate -const PermissionBit PERM_MOVE = (1 << 19); // 0x00080000 +constexpr PermissionBit PERM_MOVE = (1 << 19); // 0x00080000 // parcels, avatars take damage, deprecated //const PermissionBit PERM_DAMAGE = (1 << 20); // 0x00100000 // don't use bit 31 -- printf/scanf with "%x" assume signed numbers -const PermissionBit PERM_RESERVED = ((U32)1) << 31; +constexpr PermissionBit PERM_RESERVED = ((U32)1) << 31; -const PermissionMask PERM_NONE = 0x00000000; -const PermissionMask PERM_ALL = 0x7FFFFFFF; -//const PermissionMask PERM_ALL_PARCEL = PERM_MODIFY | PERM_ENTER | PERM_TERRAFORM | PERM_DAMAGE; -const PermissionMask PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER; +constexpr PermissionMask PERM_NONE = 0x00000000; +constexpr PermissionMask PERM_ALL = 0x7FFFFFFF; +//constexpr PermissionMask PERM_ALL_PARCEL = PERM_MODIFY | PERM_ENTER | PERM_TERRAFORM | PERM_DAMAGE; +constexpr PermissionMask PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER; // Useful stuff for transmission. // Which permissions field are we trying to change? -const U8 PERM_BASE = 0x01; +constexpr U8 PERM_BASE = 0x01; // TODO: Add another PERM_OWNER operation type for allowOperationBy DK 04/03/06 -const U8 PERM_OWNER = 0x02; -const U8 PERM_GROUP = 0x04; -const U8 PERM_EVERYONE = 0x08; -const U8 PERM_NEXT_OWNER = 0x10; +constexpr U8 PERM_OWNER = 0x02; +constexpr U8 PERM_GROUP = 0x04; +constexpr U8 PERM_EVERYONE = 0x08; +constexpr U8 PERM_NEXT_OWNER = 0x10; // This is just a quickie debugging key // no modify: PERM_ALL & ~PERM_MODIFY = 0x7fffbfff diff --git a/indra/llinventory/llsaleinfo.cpp b/indra/llinventory/llsaleinfo.cpp index d38ffcc4bf..98836b178e 100644 --- a/indra/llinventory/llsaleinfo.cpp +++ b/indra/llinventory/llsaleinfo.cpp @@ -66,7 +66,7 @@ LLSaleInfo::LLSaleInfo(EForSale sale_type, S32 sale_price) : mSalePrice = llclamp(mSalePrice, 0, S32_MAX); } -BOOL LLSaleInfo::isForSale() const +bool LLSaleInfo::isForSale() const { return (FS_NOT != mSaleType); } @@ -78,13 +78,13 @@ U32 LLSaleInfo::getCRC32() const return rv; } -BOOL LLSaleInfo::exportLegacyStream(std::ostream& output_stream) const +bool LLSaleInfo::exportLegacyStream(std::ostream& output_stream) const { output_stream << "\tsale_info\t0\n\t{\n"; output_stream << "\t\tsale_type\t" << lookup(mSaleType) << "\n"; output_stream << "\t\tsale_price\t" << mSalePrice << "\n"; output_stream <<"\t}\n"; - return TRUE; + return true; } LLSD LLSaleInfo::asLLSD() const @@ -95,7 +95,7 @@ LLSD LLSaleInfo::asLLSD() const return sd; } -bool LLSaleInfo::fromLLSD(const LLSD& sd, BOOL& has_perm_mask, U32& perm_mask) +bool LLSaleInfo::fromLLSD(const LLSD& sd, bool& has_perm_mask, U32& perm_mask) { const char *w; @@ -113,22 +113,22 @@ bool LLSaleInfo::fromLLSD(const LLSD& sd, BOOL& has_perm_mask, U32& perm_mask) w = "perm_mask"; if (sd.has(w)) { - has_perm_mask = TRUE; + has_perm_mask = true; perm_mask = ll_U32_from_sd(sd[w]); } return true; } -BOOL LLSaleInfo::importLegacyStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask) +bool LLSaleInfo::importLegacyStream(std::istream& input_stream, bool& has_perm_mask, U32& perm_mask) { - has_perm_mask = FALSE; + has_perm_mask = false; // *NOTE: Changing the buffer size will require changing the scanf // calls below. char buffer[MAX_STRING]; /* Flawfinder: ignore */ char keyword[MAX_STRING]; /* Flawfinder: ignore */ char valuestr[MAX_STRING]; /* Flawfinder: ignore */ - BOOL success = TRUE; + bool success = true; keyword[0] = '\0'; valuestr[0] = '\0'; @@ -163,7 +163,7 @@ BOOL LLSaleInfo::importLegacyStream(std::istream& input_stream, BOOL& has_perm_m else if (!strcmp("perm_mask", keyword)) { //LL_INFOS() << "found deprecated keyword perm_mask" << LL_ENDL; - has_perm_mask = TRUE; + has_perm_mask = true; sscanf(valuestr, "%x", &perm_mask); } else diff --git a/indra/llinventory/llsaleinfo.h b/indra/llinventory/llsaleinfo.h index 961b6f4236..44eb841641 100644 --- a/indra/llinventory/llsaleinfo.h +++ b/indra/llinventory/llsaleinfo.h @@ -74,7 +74,7 @@ public: LLSaleInfo(EForSale sale_type, S32 sale_price); // accessors - BOOL isForSale() const; + bool isForSale() const; EForSale getSaleType() const { return mSaleType; } S32 getSalePrice() const { return mSalePrice; } U32 getCRC32() const; @@ -84,11 +84,11 @@ public: void setSalePrice(S32 price); //void setNextOwnerPermMask(U32 mask) { mNextOwnerPermMask = mask; } - BOOL exportLegacyStream(std::ostream& output_stream) const; + bool exportLegacyStream(std::ostream& output_stream) const; LLSD asLLSD() const; operator LLSD() const { return asLLSD(); } - bool fromLLSD(const LLSD& sd, BOOL& has_perm_mask, U32& perm_mask); - BOOL importLegacyStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask); + bool fromLLSD(const LLSD& sd, bool& has_perm_mask, U32& perm_mask); + bool importLegacyStream(std::istream& input_stream, bool& has_perm_mask, U32& perm_mask); LLSD packMessage() const; void unpackMessage(LLSD sales); diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index c1893eff41..0ee71de3a1 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -69,25 +69,99 @@ const U32 LLSettingsBase::Validator::VALIDATION_PARTIAL(0x01 << 0); LLSettingsBase::LLSettingsBase(): mSettings(LLSD::emptyMap()), mDirty(true), - mBlendedFactor(0.0) + mLLSDDirty(true), + mReplaced(false), + mBlendedFactor(0.0), + mSettingFlags(0) { } LLSettingsBase::LLSettingsBase(const LLSD setting) : mSettings(setting), + mLLSDDirty(true), mDirty(true), - mBlendedFactor(0.0) + mReplaced(false), + mBlendedFactor(0.0), + mSettingFlags(0) { } +//virtual +void LLSettingsBase::loadValuesFromLLSD() +{ + mLLSDDirty = false; + + mAssetId = mSettings[SETTING_ASSETID].asUUID(); + mSettingId = getValue(SETTING_ID).asUUID(); + mSettingName = getValue(SETTING_NAME).asString(); + if (mSettings.has(SETTING_FLAGS)) + { + mSettingFlags = (U32)mSettings[SETTING_FLAGS].asInteger(); + } + else + { + mSettingFlags = 0; + } +} + +//virtual +void LLSettingsBase::saveValuesToLLSD() +{ + mLLSDDirty = false; + + mSettings[SETTING_NAME] = mSettingName; + if (mAssetId.isNull()) + { + mSettings.erase(SETTING_ASSETID); + } + else + { + mSettings[SETTING_ASSETID] = mAssetId; + } + mSettings[SETTING_FLAGS] = LLSD::Integer(mSettingFlags); +} + +void LLSettingsBase::saveValuesIfNeeded() +{ + if (mLLSDDirty) + { + saveValuesToLLSD(); + } +} + //========================================================================= -void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F64 mix) +void LLSettingsBase::lerpSettings(LLSettingsBase &other, F64 mix) { - mSettings = interpolateSDMap(mSettings, other.mSettings, other.getParameterMap(), mix); + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + saveValuesIfNeeded(); + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); + mSettings = interpolateSDMap(mSettings, other.getSettings(), other.getParameterMap(), mix, skip, slerps); setDirtyFlag(true); + loadValuesFromLLSD(); +} + +void LLSettingsBase::lerpVector2(LLVector2& a, const LLVector2& b, F32 mix) +{ + a.mV[0] = lerp(a.mV[0], b.mV[0], mix); + a.mV[1] = lerp(a.mV[1], b.mV[1], mix); +} + +void LLSettingsBase::lerpVector3(LLVector3& a, const LLVector3& b, F32 mix) +{ + a.mV[0] = lerp(a.mV[0], b.mV[0], mix); + a.mV[1] = lerp(a.mV[1], b.mV[1], mix); + a.mV[2] = lerp(a.mV[2], b.mV[2], mix); +} + +void LLSettingsBase::lerpColor(LLColor3& a, const LLColor3& b, F32 mix) +{ + a.mV[0] = lerp(a.mV[0], b.mV[0], mix); + a.mV[1] = lerp(a.mV[1], b.mV[1], mix); + a.mV[2] = lerp(a.mV[2], b.mV[2], mix); } -LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) const +LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) { LLSD newSettings; @@ -161,13 +235,10 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons return newSettings; } -LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, F64 mix) const +LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, F64 mix, const stringset_t& skip, const stringset_t& slerps) { LLSD newSettings; - stringset_t skip = getSkipInterpolateKeys(); - stringset_t slerps = getSlerpKeys(); - llassert(mix >= 0.0f && mix <= 1.0f); for (LLSD::map_const_iterator it = settings.beginMap(); it != settings.endMap(); ++it) @@ -204,7 +275,7 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, c } } - newSettings[key_name] = interpolateSDValue(key_name, value, other_value, defaults, mix, slerps); + newSettings[key_name] = interpolateSDValue(key_name, value, other_value, defaults, mix, skip, slerps); } // Special handling cases @@ -233,12 +304,12 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, c if (def_iter != defaults.end()) { // Blend against default value - newSettings[key_name] = interpolateSDValue(key_name, def_iter->second.getDefaultValue(), (*it).second, defaults, mix, slerps); + newSettings[key_name] = interpolateSDValue(key_name, def_iter->second.getDefaultValue(), (*it).second, defaults, mix, skip, slerps); } else if ((*it).second.type() == LLSD::TypeMap) { // interpolate in case there are defaults inside (part of legacy) - newSettings[key_name] = interpolateSDValue(key_name, LLSDMap(), (*it).second, defaults, mix, slerps); + newSettings[key_name] = interpolateSDValue(key_name, LLSDMap(), (*it).second, defaults, mix, skip, slerps); } // else do nothing when no known defaults // TODO: Should I blend this out instead? @@ -260,7 +331,7 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, c return newSettings; } -LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD &value, const LLSD &other_value, const parammapping_t& defaults, BlendFactor mix, const stringset_t& slerps) const +LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD &value, const LLSD &other_value, const parammapping_t& defaults, BlendFactor mix, const stringset_t& skip, const stringset_t& slerps) { LLSD new_value; @@ -278,15 +349,15 @@ LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD { case LLSD::TypeInteger: // lerp between the two values rounding the result to the nearest integer. - new_value = LLSD::Integer(llroundf(lerp(value.asReal(), other_value.asReal(), mix))); + new_value = LLSD::Integer(llroundf(lerp((F32)value.asReal(), (F32)other_value.asReal(), (F32)mix))); break; case LLSD::TypeReal: // lerp between the two values. - new_value = LLSD::Real(lerp(value.asReal(), other_value.asReal(), mix)); + new_value = LLSD::Real(lerp((F32)value.asReal(), (F32)other_value.asReal(), (F32)mix)); break; case LLSD::TypeMap: // deep copy. - new_value = interpolateSDMap(value, other_value, defaults, mix); + new_value = interpolateSDMap(value, other_value, defaults, mix, skip, slerps); break; case LLSD::TypeArray: @@ -297,7 +368,7 @@ LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD { LLQuaternion a(value); LLQuaternion b(other_value); - LLQuaternion q = slerp(mix, a, b); + LLQuaternion q = slerp((F32)mix, a, b); new_array = q.getValue(); } else @@ -308,7 +379,7 @@ LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD for (size_t i = 0; i < len; ++i) { - new_array[i] = lerp(value[i].asReal(), other_value[i].asReal(), mix); + new_array[i] = lerp((F32)value[i].asReal(), (F32)other_value[i].asReal(), (F32)mix); } } @@ -348,21 +419,24 @@ LLSettingsBase::stringset_t LLSettingsBase::getSkipInterpolateKeys() const return skipSet; } -LLSD LLSettingsBase::getSettings() const +LLSD& LLSettingsBase::getSettings() { + saveValuesIfNeeded(); return mSettings; } -LLSD LLSettingsBase::cloneSettings() const +LLSD LLSettingsBase::cloneSettings() { - U32 flags = getFlags(); - LLSD settings (combineSDMaps(getSettings(), LLSD())); - if (flags) + saveValuesIfNeeded(); + LLSD settings(combineSDMaps(getSettings(), LLSD())); + if (U32 flags = getFlags()) + { settings[SETTING_FLAGS] = LLSD::Integer(flags); + } return settings; } -size_t LLSettingsBase::getHash() const +size_t LLSettingsBase::getHash() { // get a shallow copy of the LLSD filtering out values to not include in the hash LLSD hash_settings = llsd_shallow(getSettings(), LLSDMap(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)("*", true)); @@ -380,7 +454,9 @@ bool LLSettingsBase::validate() mSettings[SETTING_TYPE] = getSettingsType(); } + saveValuesIfNeeded(); LLSD result = LLSettingsBase::settingValidation(mSettings, validations); + loadValuesFromLLSD(); if (result["errors"].size() > 0) { @@ -693,7 +769,7 @@ void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf) F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_in) { - LLSettingsBase::TrackPosition blendf = blendf_in; + LLSettingsBase::TrackPosition blendf = (F32)blendf_in; llassert(!isnan(blendf)); if (blendf >= 1.0) { @@ -703,7 +779,7 @@ F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_ if (mTarget) { - mTarget->replaceSettings(mInitial->getSettings()); + mTarget->replaceSettings(mInitial); mTarget->blend(mFinal, blendf); } else @@ -718,7 +794,7 @@ void LLSettingsBlender::triggerComplete() { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; if (mTarget) - mTarget->replaceSettings(mFinal->getSettings()); + mTarget->replaceSettings(mFinal); LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon mTarget->update(); mOnFinished(shared_from_this()); @@ -744,7 +820,7 @@ bool LLSettingsBlenderTimeDelta::applyTimeDelta(const LLSettingsBase::Seconds& t return false; } - LLSettingsBase::BlendFactor blendf = calculateBlend(mTimeSpent, mBlendSpan); + LLSettingsBase::BlendFactor blendf = calculateBlend((F32)mTimeSpent.value(), mBlendSpan); if (fabs(mLastBlendF - blendf) < mBlendFMinDelta) { diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index a5499c4eb6..816ff3e111 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -109,72 +109,59 @@ public: virtual bool isDirty() const { return mDirty; } virtual bool isVeryDirty() const { return mReplaced; } inline void setDirtyFlag(bool dirty) { mDirty = dirty; clearAssetId(); } + inline void setReplaced() { mReplaced = true; } - size_t getHash() const; // Hash will not include Name, ID or a previously stored Hash + size_t getHash(); // Hash will not include Name, ID or a previously stored Hash inline LLUUID getId() const { - return getValue(SETTING_ID).asUUID(); + return mSettingId; } inline std::string getName() const { - return getValue(SETTING_NAME).asString(); + return mSettingName; } inline void setName(std::string val) { - setValue(SETTING_NAME, val); + mSettingName = val; + setDirtyFlag(true); + setLLSDDirty(); } inline LLUUID getAssetId() const { - if (mSettings.has(SETTING_ASSETID)) - return mSettings[SETTING_ASSETID].asUUID(); - return LLUUID(); + return mAssetId; } inline U32 getFlags() const { - if (mSettings.has(SETTING_FLAGS)) - return static_cast<U32>(mSettings[SETTING_FLAGS].asInteger()); - return 0; + return mSettingFlags; } inline void setFlags(U32 value) { - setLLSD(SETTING_FLAGS, LLSD::Integer(value)); + mSettingFlags = value; + setDirtyFlag(true); + setLLSDDirty(); } inline bool getFlag(U32 flag) const { - if (mSettings.has(SETTING_FLAGS)) - return ((U32)mSettings[SETTING_FLAGS].asInteger() & flag) == flag; - return false; + return (mSettingFlags & flag) == flag; } inline void setFlag(U32 flag) { - U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0); - - flags |= flag; - - if (flags) - mSettings[SETTING_FLAGS] = LLSD::Integer(flags); - else - mSettings.erase(SETTING_FLAGS); + mSettingFlags |= flag; + setLLSDDirty(); } inline void clearFlag(U32 flag) { - U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0); - - flags &= ~flag; - - if (flags) - mSettings[SETTING_FLAGS] = LLSD::Integer(flags); - else - mSettings.erase(SETTING_FLAGS); + mSettingFlags &= ~flag; + setLLSDDirty(); } virtual void replaceSettings(LLSD settings) @@ -183,14 +170,41 @@ public: setDirtyFlag(true); mReplaced = true; mSettings = settings; + loadValuesFromLLSD(); + } + + virtual void replaceSettings(const ptr_t& other) + { + mBlendedFactor = 0.0; + setDirtyFlag(true); + mReplaced = true; + mSettingFlags = other->getFlags(); + mSettingName = other->getName(); + mSettingId = other->getId(); + mAssetId = other->getAssetId(); + setLLSDDirty(); + } + + void setSettings(LLSD settings) + { + setDirtyFlag(true); + mSettings = settings; + loadValuesFromLLSD(); } - virtual LLSD getSettings() const; + // if you are using getSettings to edit them, call setSettings(settings), + // replaceSettings(settings) or loadValuesFromLLSD() afterwards + virtual LLSD& getSettings(); + virtual void setLLSDDirty() + { + mLLSDDirty = true; + } //--------------------------------------------------------------------- // inline void setLLSD(const std::string &name, const LLSD &value) { + saveValuesIfNeeded(); mSettings[name] = value; mDirty = true; if (name != SETTING_ASSETID) @@ -202,8 +216,9 @@ public: setLLSD(name, value); } - inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const + inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) { + saveValuesIfNeeded(); if (!mSettings.has(name)) return deflt; return mSettings[name]; @@ -259,11 +274,11 @@ public: (const_cast<LLSettingsBase *>(this))->updateSettings(); } - virtual void blend(const ptr_t &end, BlendFactor blendf) = 0; + virtual void blend(ptr_t &end, BlendFactor blendf) = 0; virtual bool validate(); - virtual ptr_t buildDerivedClone() const = 0; + virtual ptr_t buildDerivedClone() = 0; class Validator { @@ -310,17 +325,24 @@ public: inline void setAssetId(LLUUID value) { // note that this skips setLLSD - mSettings[SETTING_ASSETID] = value; + mAssetId = value; + mLLSDDirty = true; } inline void clearAssetId() { - if (mSettings.has(SETTING_ASSETID)) - mSettings.erase(SETTING_ASSETID); + mAssetId.setNull(); + mLLSDDirty = true; } // Calculate any custom settings that may need to be cached. virtual void updateSettings() { mDirty = false; mReplaced = false; } + LLSD cloneSettings(); + + static void lerpVector2(LLVector2& a, const LLVector2& b, F32 mix); + static void lerpVector3(LLVector3& a, const LLVector3& b, F32 mix); + static void lerpColor(LLColor3& a, const LLColor3& b, F32 mix); + protected: LLSettingsBase(); @@ -331,7 +353,7 @@ protected: typedef std::set<std::string> stringset_t; // combining settings objects. Customize for specific setting types - virtual void lerpSettings(const LLSettingsBase &other, BlendFactor mix); + virtual void lerpSettings(LLSettingsBase &other, BlendFactor mix); // combining settings maps where it can based on mix rate // @settings initial value (mix==0) @@ -339,8 +361,8 @@ protected: // @defaults list of default values for legacy fields and (re)setting shaders // @mix from 0 to 1, ratio or rate of transition from initial 'settings' to 'other' // return interpolated and combined LLSD map - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, BlendFactor mix) const; - LLSD interpolateSDValue(const std::string& name, const LLSD &value, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& slerps) const; + static LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& skip, const stringset_t& slerps); + static LLSD interpolateSDValue(const std::string& name, const LLSD &value, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& skip, const stringset_t& slerps); /// when lerping between settings, some may require special handling. /// Get a list of these key to be skipped by the default settings lerp. @@ -353,32 +375,40 @@ protected: virtual validation_list_t getValidationList() const = 0; - // Apply any settings that need special handling. - virtual void applySpecial(void *, bool force = false) { }; + // Apply settings. + virtual void applyToUniforms(void *) { }; + virtual void applySpecial(void*, bool force = false) { }; virtual parammapping_t getParameterMap() const { return parammapping_t(); } - LLSD mSettings; - - LLSD cloneSettings() const; - inline void setBlendFactor(BlendFactor blendfactor) { mBlendedFactor = blendfactor; } - void replaceWith(LLSettingsBase::ptr_t other) + virtual void replaceWith(const LLSettingsBase::ptr_t other) { - replaceSettings(other->cloneSettings()); + replaceSettings(other); setBlendFactor(other->getBlendFactor()); } + virtual void loadValuesFromLLSD(); + virtual void saveValuesToLLSD(); + void saveValuesIfNeeded(); + + LLUUID mAssetId; + LLUUID mSettingId; + std::string mSettingName; + U32 mSettingFlags; + private: + bool mLLSDDirty; bool mDirty; bool mReplaced; // super dirty! - LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; + static LLSD combineSDMaps(const LLSD &first, const LLSD &other); + LLSD mSettings; BlendFactor mBlendedFactor; }; @@ -475,7 +505,7 @@ public: LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target, const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& blend_span) : LLSettingsBlender(target, initsetting, endsetting), - mBlendSpan(blend_span), + mBlendSpan((F32)blend_span.value()), mLastUpdate(0.0f), mTimeSpent(0.0f), mBlendFMinDelta(MIN_BLEND_DELTA), diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index ef6a187d06..2baf140e6a 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -28,7 +28,6 @@ #include "llsettingsdaycycle.h" #include "llerror.h" #include <algorithm> -#include <boost/make_shared.hpp> #include "lltrace.h" #include "llfasttimer.h" #include "v3colorutil.h" @@ -111,10 +110,10 @@ const LLSettingsDay::Seconds LLSettingsDay::MINIMUM_DAYOFFSET(0); const LLSettingsDay::Seconds LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset) const LLSettingsDay::Seconds LLSettingsDay::MAXIMUM_DAYOFFSET(86400); // 24 hours -const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0 -const S32 LLSettingsDay::TRACK_GROUND_LEVEL(1); -const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water -const S32 LLSettingsDay::FRAME_MAX(56); +const U32 LLSettingsDay::TRACK_WATER(0); // water track is 0 +const U32 LLSettingsDay::TRACK_GROUND_LEVEL(1); +const U32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water +const U32 LLSettingsDay::FRAME_MAX(56); const F32 LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR(0.02501f); @@ -125,33 +124,38 @@ static const F32 DEFAULT_MULTISLIDER_INCREMENT(0.005f); //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : LLSettingsBase(data), - mInitialized(false) + mInitialized(false), + mDaySettings(LLSD::emptyMap()) { mDayTracks.resize(TRACK_MAX); + loadValuesFromLLSD(); } LLSettingsDay::LLSettingsDay() : LLSettingsBase(), - mInitialized(false) + mInitialized(false), + mDaySettings(LLSD::emptyMap()) { mDayTracks.resize(TRACK_MAX); + replaceSettings(defaults()); } //========================================================================= -LLSD LLSettingsDay::getSettings() const +LLSD& LLSettingsDay::getSettings() { - LLSD settings(LLSD::emptyMap()); + mDaySettings = LLSD::emptyMap(); + LLSD& settings = LLSettingsBase::getSettings(); - if (mSettings.has(SETTING_NAME)) - settings[SETTING_NAME] = mSettings[SETTING_NAME]; + if (settings.has(SETTING_NAME)) + mDaySettings[SETTING_NAME] = settings[SETTING_NAME]; - if (mSettings.has(SETTING_ID)) - settings[SETTING_ID] = mSettings[SETTING_ID]; + if (settings.has(SETTING_ID)) + mDaySettings[SETTING_ID] = settings[SETTING_ID]; - if (mSettings.has(SETTING_ASSETID)) - settings[SETTING_ASSETID] = mSettings[SETTING_ASSETID]; + if (settings.has(SETTING_ASSETID)) + mDaySettings[SETTING_ASSETID] = settings[SETTING_ASSETID]; - settings[SETTING_TYPE] = getSettingsType(); + mDaySettings[SETTING_TYPE] = getSettingsType(); std::map<std::string, LLSettingsBase::ptr_t> in_use; @@ -175,7 +179,7 @@ LLSD LLSettingsDay::getSettings() const } tracks.append(trackout); } - settings[SETTING_TRACKS] = tracks; + mDaySettings[SETTING_TRACKS] = tracks; LLSD frames(LLSD::emptyMap()); for (std::map<std::string, LLSettingsBase::ptr_t>::iterator itFrame = in_use.begin(); itFrame != in_use.end(); ++itFrame) @@ -185,9 +189,15 @@ LLSD LLSettingsDay::getSettings() const frames[(*itFrame).first] = framesettings; } - settings[SETTING_FRAMES] = frames; + mDaySettings[SETTING_FRAMES] = frames; - return settings; + return mDaySettings; +} + +void LLSettingsDay::setLLSDDirty() +{ + mDaySettings = LLSD::emptyMap(); + LLSettingsBase::setLLSDDirty(); } bool LLSettingsDay::initialize(bool validate_frames) @@ -393,6 +403,8 @@ bool LLSettingsDay::initialize(bool validate_frames) mSettings[SETTING_ASSETID] = assetid; } + loadValuesFromLLSD(); + mInitialized = true; return true; } @@ -450,7 +462,7 @@ LLSD LLSettingsDay::defaults() return dfltsetting; } -void LLSettingsDay::blend(const LLSettingsBase::ptr_t &other, F64 mix) +void LLSettingsDay::blend(LLSettingsBase::ptr_t &other, F64 mix) { LL_ERRS("DAYCYCLE") << "Day cycles are not blendable!" << LL_ENDL; } @@ -462,7 +474,7 @@ namespace // Trim extra tracks. while (value.size() > LLSettingsDay::TRACK_MAX) { - value.erase(value.size() - 1); + value.erase(static_cast<LLSD::Integer>(value.size()) - 1); } S32 framecount(0); @@ -500,7 +512,7 @@ namespace continue; } - LLSettingsBase::TrackPosition frame = elem[LLSettingsDay::SETTING_KEYKFRAME].asReal(); + LLSettingsBase::TrackPosition frame = (F32)elem[LLSettingsDay::SETTING_KEYKFRAME].asReal(); if ((frame < 0.0) || (frame > 1.0)) { frame = llclamp(frame, 0.0f, 1.0f); @@ -511,7 +523,7 @@ namespace } - int waterTracks = value[0].size(); + int waterTracks = static_cast<int>(value[0].size()); int skyTracks = framecount - waterTracks; if (waterTracks < 1) diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 4a46eba6fe..d37423ea9a 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -59,10 +59,10 @@ public: static const Seconds DEFAULT_DAYOFFSET; static const Seconds MAXIMUM_DAYOFFSET; - static const S32 TRACK_WATER; - static const S32 TRACK_GROUND_LEVEL; - static const S32 TRACK_MAX; - static const S32 FRAME_MAX; + static const U32 TRACK_WATER; + static const U32 TRACK_GROUND_LEVEL; + static const U32 TRACK_MAX; + static const U32 FRAME_MAX; static const F32 DEFAULT_FRAME_SLOP_FACTOR; @@ -81,9 +81,10 @@ public: bool initialize(bool validate_frames = false); - virtual ptr_t buildClone() const = 0; - virtual ptr_t buildDeepCloneAndUncompress() const = 0; - virtual LLSD getSettings() const SETTINGS_OVERRIDE; + virtual ptr_t buildClone() = 0; + virtual ptr_t buildDeepCloneAndUncompress() = 0; + virtual LLSD& getSettings() SETTINGS_OVERRIDE; + virtual void setLLSDDirty() override; virtual LLSettingsType::type_e getSettingsTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_DAYCYCLE; } @@ -91,7 +92,7 @@ public: virtual std::string getSettingsType() const SETTINGS_OVERRIDE { return std::string("daycycle"); } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix) SETTINGS_OVERRIDE; + virtual void blend(LLSettingsBase::ptr_t &other, F64 mix) SETTINGS_OVERRIDE; static LLSD defaults(); @@ -127,7 +128,7 @@ public: virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); - virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } LLSettingsBase::TrackPosition getUpperBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); LLSettingsBase::TrackPosition getLowerBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe); @@ -143,6 +144,7 @@ protected: private: CycleList_t mDayTracks; + LLSD mDaySettings; LLSettingsBase::Seconds mLastUpdateTime; diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index e14b2f25ed..3685915ffd 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -407,10 +407,11 @@ LLSettingsSky::LLSettingsSky(const LLSD &data) : mNextRainbowTextureId(), mNextHaloTextureId() { + loadValuesFromLLSD(); } LLSettingsSky::LLSettingsSky(): - LLSettingsBase(), + LLSettingsBase(LLSettingsSky::defaults()), mNextSunTextureId(), mNextMoonTextureId(), mNextCloudTextureId(), @@ -418,6 +419,7 @@ LLSettingsSky::LLSettingsSky(): mNextRainbowTextureId(), mNextHaloTextureId() { + replaceSettings(defaults()); } void LLSettingsSky::replaceSettings(LLSD settings) @@ -431,7 +433,80 @@ void LLSettingsSky::replaceSettings(LLSD settings) mNextHaloTextureId.setNull(); } -void LLSettingsSky::replaceWithSky(LLSettingsSky::ptr_t pother) +void LLSettingsSky::replaceSettings(const LLSettingsBase::ptr_t& other_sky) +{ + LLSettingsBase::replaceSettings(other_sky); + + llassert(getSettingsType() == other_sky->getSettingsType()); + + LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(other_sky); + + mCanAutoAdjust = other->mCanAutoAdjust; + mReflectionProbeAmbiance = other->mReflectionProbeAmbiance; + + mSunScale = other->mSunScale; + mSunRotation = other->mSunRotation; + mSunlightColor = other->mSunlightColor; + mStarBrightness = other->mStarBrightness; + mMoonBrightness = other->mMoonBrightness; + mMoonScale = other->mMoonScale; + mMoonRotation = other->mMoonRotation; + mMaxY = other->mMaxY; + mGlow = other->mGlow; + mGamma = other->mGamma; + mCloudVariance = other->mCloudVariance; + mCloudShadow = other->mCloudShadow; + mScrollRate = other->mScrollRate; + mCloudScale = other->mCloudScale; + mCloudPosDensity1 = other->mCloudPosDensity1; + mCloudPosDensity2 = other->mCloudPosDensity2; + mCloudColor = other->mCloudColor; + + mAbsorptionConfigs = other->mAbsorptionConfigs; + mMieConfigs = other->mMieConfigs; + mRayleighConfigs = other->mRayleighConfigs; + + mSunArcRadians = other->mSunArcRadians; + mSkyTopRadius = other->mSkyTopRadius; + mSkyBottomRadius = other->mSkyBottomRadius; + mSkyMoistureLevel = other->mSkyMoistureLevel; + mSkyDropletRadius = other->mSkyDropletRadius; + mSkyIceLevel = other->mSkyIceLevel; + mPlanetRadius = other->mPlanetRadius; + + mHasLegacyHaze = other->mHasLegacyHaze; + mDistanceMultiplier = other->mDistanceMultiplier; + mDensityMultiplier = other->mDensityMultiplier; + mHazeHorizon = other->mHazeHorizon; + mHazeDensity = other->mHazeDensity; + mBlueHorizon = other->mBlueHorizon; + mBlueDensity = other->mBlueDensity; + mAmbientColor = other->mAmbientColor; + + mLegacyDistanceMultiplier = other->mLegacyDistanceMultiplier; + mLegacyDensityMultiplier = other->mLegacyDensityMultiplier; + mLegacyHazeHorizon = other->mLegacyHazeHorizon; + mLegacyHazeDensity = other->mLegacyHazeDensity; + mLegacyBlueHorizon = other->mLegacyBlueHorizon; + mLegacyBlueDensity = other->mLegacyBlueDensity; + mLegacyAmbientColor = other->mLegacyAmbientColor; + + mSunTextureId = other->mSunTextureId; + mMoonTextureId = other->mMoonTextureId; + mCloudTextureId = other->mCloudTextureId; + mHaloTextureId = other->mHaloTextureId; + mRainbowTextureId = other->mRainbowTextureId; + mBloomTextureId = other->mBloomTextureId; + + mNextSunTextureId.setNull(); + mNextMoonTextureId.setNull(); + mNextCloudTextureId.setNull(); + mNextBloomTextureId.setNull(); + mNextRainbowTextureId.setNull(); + mNextHaloTextureId.setNull(); +} + +void LLSettingsSky::replaceWithSky(const LLSettingsSky::ptr_t& pother) { replaceWith(pother); @@ -443,61 +518,158 @@ void LLSettingsSky::replaceWithSky(LLSettingsSky::ptr_t pother) mNextHaloTextureId = pother->mNextHaloTextureId; } -void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) +bool lerp_legacy_color(LLColor3& a, bool& a_has_legacy, const LLColor3& b, bool b_has_legacy, const LLColor3& def, F32 mix) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; - llassert(getSettingsType() == end->getSettingsType()); + if (b_has_legacy) + { + if (a_has_legacy) + { + LLSettingsBase::lerpColor(a, b, mix); + } + else + { + a = def; + LLSettingsBase::lerpColor(a, b, mix); + a_has_legacy = true; + } + } + else if (a_has_legacy) + { + LLSettingsBase::lerpColor(a, def, mix); + } + else + { + LLSettingsBase::lerpColor(a, b, mix); + } + return a_has_legacy; +} - LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(end); - if (other) +bool lerp_legacy_float(F32& a, bool& a_has_legacy, F32 b, bool b_has_legacy, F32 def, F32 mix) +{ + if (b_has_legacy) { - if (other->mSettings.has(SETTING_LEGACY_HAZE)) + if (a_has_legacy) { - if (!mSettings.has(SETTING_LEGACY_HAZE) || !mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) - { - // Special case since SETTING_AMBIENT is both in outer and legacy maps, we prioritize legacy one - // see getAmbientColor(), we are about to replaceSettings(), so we are free to set it - setAmbientColor(getAmbientColor()); - } + a = lerp(a, b, mix); } else { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) - { - // Special case due to ambient's duality - // We need to match 'other's' structure for interpolation. - // We are free to change mSettings, since we are about to reset it - mSettings[SETTING_AMBIENT] = getAmbientColor().getValue(); - mSettings[SETTING_LEGACY_HAZE].erase(SETTING_AMBIENT); - } + a = lerp(def, b, mix); + a_has_legacy = true; } + } + else if (!a_has_legacy) + { + a = lerp(a, b, mix); + } + else + { + a = lerp(a, def, mix); + } + return a_has_legacy; +} +void LLSettingsSky::blend(LLSettingsBase::ptr_t &end, F64 blendf) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + llassert(getSettingsType() == end->getSettingsType()); + + LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(end); + if (other) + { LLUUID cloud_noise_id = getCloudNoiseTextureId(); LLUUID cloud_noise_id_next = other->getCloudNoiseTextureId(); - F64 cloud_shadow = 0; if (!cloud_noise_id.isNull() && cloud_noise_id_next.isNull()) { // If there is no cloud texture in destination, reduce coverage to imitate disappearance // See LLDrawPoolWLSky::renderSkyClouds... we don't blend present texture with null // Note: Probably can be done by shader - cloud_shadow = lerp(mSettings[SETTING_CLOUD_SHADOW].asReal(), (F64)0.f, blendf); + mCloudShadow = lerp(mCloudShadow, 0.f, (F32)blendf); cloud_noise_id_next = cloud_noise_id; } else if (cloud_noise_id.isNull() && !cloud_noise_id_next.isNull()) { // Source has no cloud texture, reduce initial coverage to imitate appearance // use same texture as destination - cloud_shadow = lerp((F64)0.f, other->mSettings[SETTING_CLOUD_SHADOW].asReal(), blendf); + mCloudShadow = lerp(0.f, mCloudShadow, (F32)blendf); setCloudNoiseTextureId(cloud_noise_id_next); } else { - cloud_shadow = lerp(mSettings[SETTING_CLOUD_SHADOW].asReal(), other->mSettings[SETTING_CLOUD_SHADOW].asReal(), blendf); + mCloudShadow = lerp(mCloudShadow, (F32)other->mCloudShadow, (F32)blendf); + } + + mSettingFlags |= other->mSettingFlags; + + mCanAutoAdjust = false; // no point? + + mSunRotation = slerp((F32)blendf, mSunRotation, other->mSunRotation); + mMoonRotation = slerp((F32)blendf, mMoonRotation, other->mMoonRotation); + lerpColor(mSunlightColor, other->mSunlightColor, (F32)blendf); + lerpColor(mGlow, other->mGlow, (F32)blendf); + mReflectionProbeAmbiance = lerp(mReflectionProbeAmbiance, other->mReflectionProbeAmbiance, (F32)blendf); + mSunScale = lerp(mSunScale, other->mSunScale, (F32)blendf); + mStarBrightness = lerp(mStarBrightness, other->mStarBrightness, (F32)blendf); + mMoonBrightness = lerp(mMoonBrightness, other->mMoonBrightness, (F32)blendf); + mMoonScale = lerp(mMoonScale, other->mMoonScale, (F32)blendf); + mMaxY = lerp(mMaxY, other->mMaxY, (F32)blendf); + mGamma = lerp(mGamma, other->mGamma, (F32)blendf); + mCloudVariance = lerp(mCloudVariance, other->mCloudVariance, (F32)blendf); + mCloudShadow = lerp(mCloudShadow, other->mCloudShadow, (F32)blendf); + mCloudScale = lerp(mCloudScale, other->mCloudScale, (F32)blendf); + lerpVector2(mScrollRate, other->mScrollRate, (F32)blendf); + lerpColor(mCloudPosDensity1, other->mCloudPosDensity1, (F32)blendf); + lerpColor(mCloudPosDensity2, other->mCloudPosDensity2, (F32)blendf); + lerpColor(mCloudColor, other->mCloudColor, (F32)blendf); + + mSunArcRadians = lerp(mSunArcRadians, other->mSunArcRadians, (F32)blendf); + mSkyTopRadius = lerp(mSkyTopRadius, other->mSkyTopRadius, (F32)blendf); + mSkyBottomRadius = lerp(mSkyBottomRadius, other->mSkyBottomRadius, (F32)blendf); + mSkyMoistureLevel = lerp(mSkyMoistureLevel, other->mSkyMoistureLevel, (F32)blendf); + mSkyDropletRadius = lerp(mSkyDropletRadius, other->mSkyDropletRadius, (F32)blendf); + mSkyIceLevel = lerp(mSkyIceLevel, other->mSkyIceLevel, (F32)blendf); + mPlanetRadius = lerp(mPlanetRadius, other->mPlanetRadius, (F32)blendf); + + // Legacy settings + + if (other->mHasLegacyHaze) + { + if (!mHasLegacyHaze || !mLegacyAmbientColor) + { + // Special case since SETTING_AMBIENT is both in outer and legacy maps, + // we prioritize legacy one + setAmbientColor(other->getAmbientColor()); + mLegacyAmbientColor = true; + mHasLegacyHaze = true; + } + } + else + { + if (mLegacyAmbientColor) + { + // Special case due to ambient's duality + mLegacyAmbientColor = false; + } } - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); - blenddata[SETTING_CLOUD_SHADOW] = LLSD::Real(cloud_shadow); - replaceSettings(blenddata); + mHasLegacyHaze |= lerp_legacy_float(mHazeHorizon, mLegacyHazeHorizon, other->mHazeHorizon, other->mLegacyHazeHorizon, 0.19f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_float(mHazeDensity, mLegacyHazeDensity, other->mHazeDensity, other->mLegacyHazeDensity, 0.7f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_float(mDistanceMultiplier, mLegacyDistanceMultiplier, other->mDistanceMultiplier, other->mLegacyDistanceMultiplier, 0.8f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_float(mDensityMultiplier, mLegacyDensityMultiplier, other->mDensityMultiplier, other->mLegacyDensityMultiplier, 0.0001f, (F32)blendf); + mHasLegacyHaze |= lerp_legacy_color(mBlueHorizon, mLegacyBlueHorizon, other->mBlueHorizon, other->mLegacyBlueHorizon, LLColor3(0.4954f, 0.4954f, 0.6399f), (F32)blendf); + mHasLegacyHaze |= lerp_legacy_color(mBlueDensity, mLegacyBlueDensity, other->mBlueDensity, other->mLegacyBlueDensity, LLColor3(0.2447f, 0.4487f, 0.7599f), (F32)blendf); + + parammapping_t defaults = other->getParameterMap(); + stringset_t skip = getSkipInterpolateKeys(); + stringset_t slerps = getSlerpKeys(); + mAbsorptionConfigs = interpolateSDMap(mAbsorptionConfigs, other->mAbsorptionConfigs, defaults, blendf, skip, slerps); + mMieConfigs = interpolateSDMap(mMieConfigs, other->mMieConfigs, defaults, blendf, skip, slerps); + mRayleighConfigs = interpolateSDMap(mRayleighConfigs, other->mRayleighConfigs, defaults, blendf, skip, slerps); + + setDirtyFlag(true); + setReplaced(); + setLLSDDirty(); + mNextSunTextureId = other->getSunTextureId(); mNextMoonTextureId = other->getMoonTextureId(); mNextCloudTextureId = cloud_noise_id_next; @@ -923,8 +1095,8 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy) if (legacy.has(SETTING_LEGACY_EAST_ANGLE) && legacy.has(SETTING_LEGACY_SUN_ANGLE)) { // get counter-clockwise radian angle from clockwise legacy WL east angle... - F32 azimuth = -legacy[SETTING_LEGACY_EAST_ANGLE].asReal(); - F32 altitude = legacy[SETTING_LEGACY_SUN_ANGLE].asReal(); + F32 azimuth = -(F32)legacy[SETTING_LEGACY_EAST_ANGLE].asReal(); + F32 altitude = (F32)legacy[SETTING_LEGACY_SUN_ANGLE].asReal(); LLQuaternion sunquat = convert_azimuth_and_altitude_to_quat(azimuth, altitude); // original WL moon dir was diametrically opposed to the sun dir @@ -955,10 +1127,188 @@ void LLSettingsSky::updateSettings() calculateLightSettings(); } + +F32 get_float(bool &use_legacy, LLSD& settings, std::string key, F32 default_value) +{ + if (settings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && settings[LLSettingsSky::SETTING_LEGACY_HAZE].has(key)) + { + use_legacy = true; + return (F32)settings[LLSettingsSky::SETTING_LEGACY_HAZE][key].asReal(); + } + if (settings.has(key)) + { + return (F32)settings[key].asReal(); + } + use_legacy = true; + return default_value; +} + +LLColor3 get_color(bool& use_legacy, LLSD& settings, const std::string& key, const LLColor3& default_value) +{ + if (settings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && settings[LLSettingsSky::SETTING_LEGACY_HAZE].has(key)) + { + use_legacy = true; + return LLColor3(settings[LLSettingsSky::SETTING_LEGACY_HAZE][key]); + } + use_legacy = false; + if (settings.has(key)) + { + return LLColor3(settings[key]); + } + use_legacy = true; + return default_value; +} + + +void LLSettingsSky::loadValuesFromLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::loadValuesFromLLSD(); + + LLSD& settings = getSettings(); + mCanAutoAdjust = !settings.has(SETTING_REFLECTION_PROBE_AMBIANCE); + if (mCanAutoAdjust) + { + mReflectionProbeAmbiance = 0; + } + else + { + mReflectionProbeAmbiance = (F32)settings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); + } + + mSunTextureId = settings[SETTING_SUN_TEXTUREID].asUUID(); + mMoonTextureId = settings[SETTING_MOON_TEXTUREID].asUUID(); + mCloudTextureId = settings[SETTING_CLOUD_TEXTUREID].asUUID(); + mHaloTextureId = settings[SETTING_HALO_TEXTUREID].asUUID(); + mRainbowTextureId = settings[SETTING_RAINBOW_TEXTUREID].asUUID(); + mBloomTextureId = settings[SETTING_BLOOM_TEXTUREID].asUUID(); + + mSunScale = (F32)settings[SETTING_SUN_SCALE].asReal(); + mSunRotation = LLQuaternion(settings[SETTING_SUN_ROTATION]); + mSunlightColor = LLColor3(settings[SETTING_SUNLIGHT_COLOR]); + mStarBrightness = (F32)settings[SETTING_STAR_BRIGHTNESS].asReal(); + mMoonBrightness = (F32)settings[SETTING_MOON_BRIGHTNESS].asReal(); + mMoonScale = (F32)settings[SETTING_MOON_SCALE].asReal(); + mMoonRotation = LLQuaternion(settings[SETTING_MOON_ROTATION]); + mMaxY = (F32)settings[SETTING_MAX_Y].asReal(); + mGlow = LLColor3(settings[SETTING_GLOW]); + mGamma = (F32)settings[SETTING_GAMMA].asReal(); + mCloudVariance = (F32)settings[SETTING_CLOUD_VARIANCE].asReal(); + mCloudShadow = (F32)settings[SETTING_CLOUD_SHADOW].asReal(); + mScrollRate = LLVector2(settings[SETTING_CLOUD_SCROLL_RATE]); + mCloudScale = (F32)settings[SETTING_CLOUD_SCALE].asReal(); + mCloudPosDensity1 = LLColor3(settings[SETTING_CLOUD_POS_DENSITY1]); + mCloudPosDensity2 = LLColor3(settings[SETTING_CLOUD_POS_DENSITY2]); + mCloudColor = LLColor3(settings[SETTING_CLOUD_COLOR]); + mAbsorptionConfigs = settings[SETTING_ABSORPTION_CONFIG]; + mMieConfigs = settings[SETTING_MIE_CONFIG]; + mRayleighConfigs = settings[SETTING_RAYLEIGH_CONFIG]; + mSunArcRadians = (F32)settings[SETTING_SUN_ARC_RADIANS].asReal(); + mSkyTopRadius = (F32)settings[SETTING_SKY_TOP_RADIUS].asReal(); + mSkyBottomRadius = (F32)settings[SETTING_SKY_BOTTOM_RADIUS].asReal(); + mSkyMoistureLevel = (F32)settings[SETTING_SKY_MOISTURE_LEVEL].asReal(); + mSkyDropletRadius = (F32)settings[SETTING_SKY_DROPLET_RADIUS].asReal(); + mSkyIceLevel = (F32)settings[SETTING_SKY_ICE_LEVEL].asReal(); + mPlanetRadius = (F32)settings[SETTING_PLANET_RADIUS].asReal(); + + // special case for legacy handling + mHasLegacyHaze = settings.has(LLSettingsSky::SETTING_LEGACY_HAZE); + mDistanceMultiplier = get_float(mLegacyDistanceMultiplier, settings, SETTING_DISTANCE_MULTIPLIER, 0.8f); + mDensityMultiplier = get_float(mLegacyDensityMultiplier, settings, SETTING_DENSITY_MULTIPLIER, 0.0001f); + mHazeHorizon = get_float(mLegacyHazeHorizon, settings, SETTING_HAZE_HORIZON, 0.19f); + mHazeDensity = get_float(mLegacyHazeDensity, settings, SETTING_HAZE_DENSITY, 0.7f); + mBlueHorizon = get_color(mLegacyBlueHorizon, settings, SETTING_BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f)); + mBlueDensity = get_color(mLegacyBlueDensity, settings, SETTING_BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f)); + mAmbientColor = get_color(mLegacyAmbientColor, settings, SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); + // one of these values might be true despite not having SETTING_LEGACY_HAZE if defaults were used + mHasLegacyHaze |= mLegacyDistanceMultiplier + || mLegacyDensityMultiplier + || mLegacyHazeHorizon + || mLegacyHazeDensity + || mLegacyBlueHorizon + || mLegacyBlueDensity + || mLegacyAmbientColor; +} + +void set_legacy(LLSD &settings, LLSD &legacy, const std::string& key, bool has_value, const LLSD & value) +{ + if (has_value) + { + legacy[key] = value; + } + else + { + settings[key] = value; + legacy.erase(key); + } +} + +void LLSettingsSky::saveValuesToLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::saveValuesToLLSD(); + + LLSD& settings = getSettings(); + + if (mCanAutoAdjust) + { + settings.erase(SETTING_REFLECTION_PROBE_AMBIANCE); + } + else + { + settings[SETTING_REFLECTION_PROBE_AMBIANCE] = mReflectionProbeAmbiance; + } + settings[SETTING_SUN_TEXTUREID] = mSunTextureId; + settings[SETTING_MOON_TEXTUREID] = mMoonTextureId; + settings[SETTING_CLOUD_TEXTUREID] = mCloudTextureId; + settings[SETTING_HALO_TEXTUREID] = mHaloTextureId; + settings[SETTING_RAINBOW_TEXTUREID] = mRainbowTextureId; + settings[SETTING_BLOOM_TEXTUREID] = mBloomTextureId; + + settings[SETTING_SUN_SCALE] = mSunScale; + settings[SETTING_SUN_ROTATION] = mSunRotation.getValue(); + settings[SETTING_SUNLIGHT_COLOR] = mSunlightColor.getValue(); + settings[SETTING_STAR_BRIGHTNESS] = mStarBrightness; + settings[SETTING_MOON_BRIGHTNESS] = mMoonBrightness; + settings[SETTING_MOON_SCALE] = mMoonScale; + settings[SETTING_MOON_ROTATION] = mMoonRotation.getValue(); + settings[SETTING_MAX_Y] = mMaxY; + settings[SETTING_GLOW] = mGlow.getValue(); + settings[SETTING_GAMMA] = mGamma; + settings[SETTING_CLOUD_VARIANCE] = mCloudVariance; + settings[SETTING_CLOUD_SHADOW] = mCloudShadow; + settings[SETTING_CLOUD_SCROLL_RATE] = mScrollRate.getValue(); + settings[SETTING_CLOUD_SCALE] = mCloudScale; + settings[SETTING_CLOUD_POS_DENSITY1] = mCloudPosDensity1.getValue(); + settings[SETTING_CLOUD_POS_DENSITY2] = mCloudPosDensity2.getValue(); + settings[SETTING_CLOUD_COLOR] = mCloudColor.getValue(); + settings[SETTING_ABSORPTION_CONFIG] = mAbsorptionConfigs; + settings[SETTING_MIE_CONFIG] = mMieConfigs; + settings[SETTING_RAYLEIGH_CONFIG] = mRayleighConfigs; + settings[SETTING_SUN_ARC_RADIANS] = mSunArcRadians; + settings[SETTING_SKY_TOP_RADIUS] = mSkyTopRadius; + settings[SETTING_SKY_BOTTOM_RADIUS] = mSkyBottomRadius; + settings[SETTING_SKY_MOISTURE_LEVEL] = mSkyMoistureLevel; + settings[SETTING_SKY_DROPLET_RADIUS] = mSkyDropletRadius; + settings[SETTING_SKY_ICE_LEVEL] = mSkyIceLevel; + settings[SETTING_PLANET_RADIUS] = mPlanetRadius; + + LLSD& legacy = settings[SETTING_LEGACY_HAZE]; + set_legacy(settings, legacy, SETTING_DISTANCE_MULTIPLIER, mLegacyDistanceMultiplier, LLSD::Real(mDistanceMultiplier)); + set_legacy(settings, legacy, SETTING_DENSITY_MULTIPLIER, mLegacyDensityMultiplier, LLSD::Real(mDensityMultiplier)); + set_legacy(settings, legacy, SETTING_HAZE_HORIZON, mLegacyHazeHorizon, LLSD::Real(mHazeHorizon)); + set_legacy(settings, legacy, SETTING_HAZE_DENSITY, mLegacyHazeDensity, LLSD::Real(mHazeDensity)); + set_legacy(settings, legacy, SETTING_BLUE_HORIZON, mLegacyBlueHorizon, mBlueHorizon.getValue()); + set_legacy(settings, legacy, SETTING_BLUE_DENSITY, mLegacyBlueDensity, mBlueDensity.getValue()); + set_legacy(settings, legacy, SETTING_AMBIENT, mLegacyAmbientColor, mAmbientColor.getValue()); +} + F32 LLSettingsSky::getSunMoonGlowFactor() const { return getIsSunUp() ? 1.0f : - getIsMoonUp() ? getMoonBrightness() * 0.25 : 0.0f; + getIsMoonUp() ? getMoonBrightness() * 0.25f : 0.0f; } bool LLSettingsSky::getIsSunUp() const @@ -1024,37 +1374,40 @@ LLColor3 LLSettingsSky::getLightDiffuse() const return LLColor3::white; } -LLColor3 LLSettingsSky::getColor(const std::string& key, const LLColor3& default_value) const +LLColor3 LLSettingsSky::getColor(const std::string& key, const LLColor3& default_value) { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(key)) + LLSD& settings = getSettings(); + if (settings.has(SETTING_LEGACY_HAZE) && settings[SETTING_LEGACY_HAZE].has(key)) { - return LLColor3(mSettings[SETTING_LEGACY_HAZE][key]); + return LLColor3(settings[SETTING_LEGACY_HAZE][key]); } - if (mSettings.has(key)) + if (settings.has(key)) { - return LLColor3(mSettings[key]); + return LLColor3(settings[key]); } return default_value; } -F32 LLSettingsSky::getFloat(const std::string& key, F32 default_value) const +F32 LLSettingsSky::getFloat(const std::string& key, F32 default_value) { LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(key)) + + LLSD& settings = getSettings(); + if (settings.has(SETTING_LEGACY_HAZE) && settings[SETTING_LEGACY_HAZE].has(key)) { - return mSettings[SETTING_LEGACY_HAZE][key].asReal(); + return (F32)settings[SETTING_LEGACY_HAZE][key].asReal(); } - if (mSettings.has(key)) + if (settings.has(key)) { - return mSettings[key].asReal(); + return (F32)settings[key].asReal(); } return default_value; } LLColor3 LLSettingsSky::getAmbientColor() const { - return getColor(SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); + return mAmbientColor; } LLColor3 LLSettingsSky::getAmbientColorClamped() const @@ -1072,119 +1425,143 @@ LLColor3 LLSettingsSky::getAmbientColorClamped() const LLColor3 LLSettingsSky::getBlueDensity() const { - return getColor(SETTING_BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f)); + return mBlueDensity; } LLColor3 LLSettingsSky::getBlueHorizon() const { - return getColor(SETTING_BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f)); + return mBlueHorizon; } F32 LLSettingsSky::getHazeDensity() const { - return getFloat(SETTING_HAZE_DENSITY, 0.7f); + return mHazeDensity; } F32 LLSettingsSky::getHazeHorizon() const { - return getFloat(SETTING_HAZE_HORIZON, 0.19f); + return mHazeHorizon; } F32 LLSettingsSky::getDensityMultiplier() const { - return getFloat(SETTING_DENSITY_MULTIPLIER, 0.0001f); + return mDensityMultiplier; } F32 LLSettingsSky::getDistanceMultiplier() const { - return getFloat(SETTING_DISTANCE_MULTIPLIER, 0.8f); + return mDistanceMultiplier; } void LLSettingsSky::setPlanetRadius(F32 radius) { - mSettings[SETTING_PLANET_RADIUS] = radius; + mPlanetRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSkyBottomRadius(F32 radius) { - mSettings[SETTING_SKY_BOTTOM_RADIUS] = radius; + mSkyBottomRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSkyTopRadius(F32 radius) { - mSettings[SETTING_SKY_TOP_RADIUS] = radius; + mSkyTopRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSunArcRadians(F32 radians) { - mSettings[SETTING_SUN_ARC_RADIANS] = radians; + mSunArcRadians = radians; + setDirtyFlag(true); } void LLSettingsSky::setMieAnisotropy(F32 aniso_factor) { getMieConfig()[SETTING_MIE_ANISOTROPY_FACTOR] = aniso_factor; + setDirtyFlag(true); } void LLSettingsSky::setSkyMoistureLevel(F32 moisture_level) { - setValue(SETTING_SKY_MOISTURE_LEVEL, moisture_level); + mSkyMoistureLevel = moisture_level; + setDirtyFlag(true); } void LLSettingsSky::setSkyDropletRadius(F32 radius) { - setValue(SETTING_SKY_DROPLET_RADIUS,radius); + mSkyDropletRadius = radius; + setDirtyFlag(true); } void LLSettingsSky::setSkyIceLevel(F32 ice_level) { - setValue(SETTING_SKY_ICE_LEVEL, ice_level); + mSkyIceLevel = ice_level; + setDirtyFlag(true); } void LLSettingsSky::setReflectionProbeAmbiance(F32 ambiance) { - setValue(SETTING_REFLECTION_PROBE_AMBIANCE, ambiance); + mReflectionProbeAmbiance = ambiance; + mCanAutoAdjust = false; + setLLSDDirty(); } void LLSettingsSky::setAmbientColor(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_AMBIENT] = val.getValue(); + mAmbientColor = val; + mLegacyAmbientColor = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setBlueDensity(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_DENSITY] = val.getValue(); + mBlueDensity = val; + mLegacyBlueDensity = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setBlueHorizon(const LLColor3 &val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_HORIZON] = val.getValue(); + mBlueHorizon = val; + mLegacyBlueHorizon = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setDensityMultiplier(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER] = val; + mDensityMultiplier = val; + mLegacyDensityMultiplier = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setDistanceMultiplier(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_DISTANCE_MULTIPLIER] = val; + mDistanceMultiplier = val; + mLegacyDistanceMultiplier = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setHazeDensity(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_DENSITY] = val; + mHazeDensity = val; + mLegacyHazeDensity = true; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setHazeHorizon(F32 val) { - mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_HORIZON] = val; + mHazeHorizon = val; + mLegacyHazeHorizon = true; setDirtyFlag(true); + setLLSDDirty(); } // Get total from rayleigh and mie density values for normalization @@ -1299,7 +1676,7 @@ LLColor3 LLSettingsSky::getMoonlightColor() const return getSunlightColor(); //moon and sun share light color } -void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) const +void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) { F32 max_color = llmax(color.mV[0], color.mV[1], color.mV[2]); if (max_color > scale) @@ -1307,7 +1684,7 @@ void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) const color *= scale/max_color; } LLColor3 linear(color); - linear *= 1.0 / scale; + linear *= 1.0f / scale; linear = smear(1.0f) - linear; linear = componentPow(linear, gamma); linear *= scale; @@ -1353,7 +1730,7 @@ void LLSettingsSky::calculateLightSettings() const F32 haze_horizon = getHazeHorizon(); - sunlight *= 1.0 - cloud_shadow; + sunlight *= 1.0f - cloud_shadow; sunlight += tmpAmbient; mHazeColor = getBlueHorizon() * getBlueDensity() * sunlight; @@ -1415,22 +1792,22 @@ LLUUID LLSettingsSky::GetDefaultHaloTextureId() F32 LLSettingsSky::getPlanetRadius() const { - return mSettings[SETTING_PLANET_RADIUS].asReal(); + return mPlanetRadius; } F32 LLSettingsSky::getSkyMoistureLevel() const { - return mSettings[SETTING_SKY_MOISTURE_LEVEL].asReal(); + return mSkyMoistureLevel; } F32 LLSettingsSky::getSkyDropletRadius() const { - return mSettings[SETTING_SKY_DROPLET_RADIUS].asReal(); + return mSkyDropletRadius; } F32 LLSettingsSky::getSkyIceLevel() const { - return mSettings[SETTING_SKY_ICE_LEVEL].asReal(); + return mSkyIceLevel; } F32 LLSettingsSky::getReflectionProbeAmbiance(bool auto_adjust) const @@ -1440,188 +1817,201 @@ F32 LLSettingsSky::getReflectionProbeAmbiance(bool auto_adjust) const return sAutoAdjustProbeAmbiance; } - return mSettings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); + return mReflectionProbeAmbiance; } F32 LLSettingsSky::getSkyBottomRadius() const { - return mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal(); + return mSkyBottomRadius; } F32 LLSettingsSky::getSkyTopRadius() const { - return mSettings[SETTING_SKY_TOP_RADIUS].asReal(); + return mSkyTopRadius; } F32 LLSettingsSky::getSunArcRadians() const { - return mSettings[SETTING_SUN_ARC_RADIANS].asReal(); + return mSunArcRadians; } F32 LLSettingsSky::getMieAnisotropy() const { - return getMieConfig()[SETTING_MIE_ANISOTROPY_FACTOR].asReal(); + return (F32)getMieConfig()[SETTING_MIE_ANISOTROPY_FACTOR].asReal(); } LLSD LLSettingsSky::getRayleighConfig() const { - LLSD copy = *(mSettings[SETTING_RAYLEIGH_CONFIG].beginArray()); + LLSD copy = *(mRayleighConfigs.beginArray()); return copy; } LLSD LLSettingsSky::getMieConfig() const { - LLSD copy = *(mSettings[SETTING_MIE_CONFIG].beginArray()); + LLSD copy = *(mMieConfigs.beginArray()); return copy; } LLSD LLSettingsSky::getAbsorptionConfig() const { - LLSD copy = *(mSettings[SETTING_ABSORPTION_CONFIG].beginArray()); + LLSD copy = *(mAbsorptionConfigs.beginArray()); return copy; } LLSD LLSettingsSky::getRayleighConfigs() const { - return mSettings[SETTING_RAYLEIGH_CONFIG]; + return mRayleighConfigs; } LLSD LLSettingsSky::getMieConfigs() const { - return mSettings[SETTING_MIE_CONFIG]; + return mMieConfigs; } LLSD LLSettingsSky::getAbsorptionConfigs() const { - return mSettings[SETTING_ABSORPTION_CONFIG]; + return mAbsorptionConfigs; } void LLSettingsSky::setRayleighConfigs(const LLSD& rayleighConfig) { - mSettings[SETTING_RAYLEIGH_CONFIG] = rayleighConfig; + mRayleighConfigs = rayleighConfig; + setLLSDDirty(); } void LLSettingsSky::setMieConfigs(const LLSD& mieConfig) { - mSettings[SETTING_MIE_CONFIG] = mieConfig; + mMieConfigs = mieConfig; + setLLSDDirty(); } void LLSettingsSky::setAbsorptionConfigs(const LLSD& absorptionConfig) { - mSettings[SETTING_ABSORPTION_CONFIG] = absorptionConfig; + mAbsorptionConfigs = absorptionConfig; + setLLSDDirty(); } LLUUID LLSettingsSky::getBloomTextureId() const { - return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); + return mBloomTextureId; } LLUUID LLSettingsSky::getRainbowTextureId() const { - return mSettings[SETTING_RAINBOW_TEXTUREID].asUUID(); + return mRainbowTextureId; } LLUUID LLSettingsSky::getHaloTextureId() const { - return mSettings[SETTING_HALO_TEXTUREID].asUUID(); + return mHaloTextureId; } //--------------------------------------------------------------------- LLColor3 LLSettingsSky::getCloudColor() const { - return LLColor3(mSettings[SETTING_CLOUD_COLOR]); + return mCloudColor; } void LLSettingsSky::setCloudColor(const LLColor3 &val) { - setValue(SETTING_CLOUD_COLOR, val); + mCloudColor = val; + setLLSDDirty(); } LLUUID LLSettingsSky::getCloudNoiseTextureId() const { - return mSettings[SETTING_CLOUD_TEXTUREID].asUUID(); + return mCloudTextureId; } void LLSettingsSky::setCloudNoiseTextureId(const LLUUID &id) { - setValue(SETTING_CLOUD_TEXTUREID, id); + mCloudTextureId = id; + setLLSDDirty(); } LLColor3 LLSettingsSky::getCloudPosDensity1() const { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]); + return mCloudPosDensity1; } void LLSettingsSky::setCloudPosDensity1(const LLColor3 &val) { - setValue(SETTING_CLOUD_POS_DENSITY1, val); + mCloudPosDensity1 = val; + setLLSDDirty(); } LLColor3 LLSettingsSky::getCloudPosDensity2() const { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY2]); + return mCloudPosDensity2; } void LLSettingsSky::setCloudPosDensity2(const LLColor3 &val) { - setValue(SETTING_CLOUD_POS_DENSITY2, val); + mCloudPosDensity2 = val; + setLLSDDirty(); } F32 LLSettingsSky::getCloudScale() const { - return mSettings[SETTING_CLOUD_SCALE].asReal(); + return mCloudScale; } void LLSettingsSky::setCloudScale(F32 val) { - setValue(SETTING_CLOUD_SCALE, val); + mCloudScale = val; + setLLSDDirty(); } LLVector2 LLSettingsSky::getCloudScrollRate() const { - return LLVector2(mSettings[SETTING_CLOUD_SCROLL_RATE]); + return mScrollRate; } void LLSettingsSky::setCloudScrollRate(const LLVector2 &val) { - setValue(SETTING_CLOUD_SCROLL_RATE, val); + mScrollRate = val; + setLLSDDirty(); } void LLSettingsSky::setCloudScrollRateX(F32 val) { - mSettings[SETTING_CLOUD_SCROLL_RATE][0] = val; + mScrollRate.mV[0] = val; setDirtyFlag(true); + setLLSDDirty(); } void LLSettingsSky::setCloudScrollRateY(F32 val) { - mSettings[SETTING_CLOUD_SCROLL_RATE][1] = val; + mScrollRate.mV[1] = val; setDirtyFlag(true); + setLLSDDirty(); } F32 LLSettingsSky::getCloudShadow() const { - return mSettings[SETTING_CLOUD_SHADOW].asReal(); + return mCloudShadow; } void LLSettingsSky::setCloudShadow(F32 val) { - setValue(SETTING_CLOUD_SHADOW, val); + mCloudShadow = val; + setLLSDDirty(); } F32 LLSettingsSky::getCloudVariance() const { - return mSettings[SETTING_CLOUD_VARIANCE].asReal(); + return mCloudVariance; } void LLSettingsSky::setCloudVariance(F32 val) { - setValue(SETTING_CLOUD_VARIANCE, val); + mCloudVariance = val; + setLLSDDirty(); } F32 LLSettingsSky::getDomeOffset() const { - //return mSettings[SETTING_DOME_OFFSET].asReal(); + //return (F32)mSettings[SETTING_DOME_OFFSET].asReal(); return DOME_OFFSET; } @@ -1633,88 +2023,95 @@ F32 LLSettingsSky::getDomeRadius() const F32 LLSettingsSky::getGamma() const { - return mSettings[SETTING_GAMMA].asReal(); + return mGamma; } void LLSettingsSky::setGamma(F32 val) { - mSettings[SETTING_GAMMA] = LLSD::Real(val); + mGamma = val; setDirtyFlag(true); + setLLSDDirty(); } - LLColor3 LLSettingsSky::getGlow() const { - return LLColor3(mSettings[SETTING_GLOW]); + return mGlow; } void LLSettingsSky::setGlow(const LLColor3 &val) { - setValue(SETTING_GLOW, val); + mGlow = val; + setLLSDDirty(); } F32 LLSettingsSky::getMaxY() const { - return mSettings[SETTING_MAX_Y].asReal(); + return mMaxY; } void LLSettingsSky::setMaxY(F32 val) { - setValue(SETTING_MAX_Y, val); + mMaxY = val; + setLLSDDirty(); } LLQuaternion LLSettingsSky::getMoonRotation() const { - return LLQuaternion(mSettings[SETTING_MOON_ROTATION]); + return mMoonRotation; } void LLSettingsSky::setMoonRotation(const LLQuaternion &val) { - setValue(SETTING_MOON_ROTATION, val); + mMoonRotation = val; + setLLSDDirty(); } F32 LLSettingsSky::getMoonScale() const { - return mSettings[SETTING_MOON_SCALE].asReal(); + return mMoonScale; } void LLSettingsSky::setMoonScale(F32 val) { - setValue(SETTING_MOON_SCALE, val); + mMoonScale = val; + setLLSDDirty(); } LLUUID LLSettingsSky::getMoonTextureId() const { - return mSettings[SETTING_MOON_TEXTUREID].asUUID(); + return mMoonTextureId; } void LLSettingsSky::setMoonTextureId(LLUUID id) { - setValue(SETTING_MOON_TEXTUREID, id); + mMoonTextureId = id; + setLLSDDirty(); } -F32 LLSettingsSky::getMoonBrightness() const +F32 LLSettingsSky::getMoonBrightness() const { - return mSettings[SETTING_MOON_BRIGHTNESS].asReal(); + return mMoonBrightness; } void LLSettingsSky::setMoonBrightness(F32 brightness_factor) { - setValue(SETTING_MOON_BRIGHTNESS, brightness_factor); + mMoonBrightness = brightness_factor; + setLLSDDirty(); } F32 LLSettingsSky::getStarBrightness() const { - return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); + return mStarBrightness; } void LLSettingsSky::setStarBrightness(F32 val) { - setValue(SETTING_STAR_BRIGHTNESS, val); + mStarBrightness = val; + setLLSDDirty(); } LLColor3 LLSettingsSky::getSunlightColor() const { - return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]); + return mSunlightColor; } LLColor3 LLSettingsSky::getSunlightColorClamped() const @@ -1733,38 +2130,41 @@ LLColor3 LLSettingsSky::getSunlightColorClamped() const void LLSettingsSky::setSunlightColor(const LLColor3 &val) { - setValue(SETTING_SUNLIGHT_COLOR, val); + mSunlightColor = val; + setLLSDDirty(); } LLQuaternion LLSettingsSky::getSunRotation() const { - return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); + return mSunRotation; } void LLSettingsSky::setSunRotation(const LLQuaternion &val) { - setValue(SETTING_SUN_ROTATION, val); + mSunRotation = val; + setLLSDDirty(); } - F32 LLSettingsSky::getSunScale() const { - return mSettings[SETTING_SUN_SCALE].asReal(); + return mSunScale; } void LLSettingsSky::setSunScale(F32 val) { - setValue(SETTING_SUN_SCALE, val); + mSunScale = val; + setLLSDDirty(); } LLUUID LLSettingsSky::getSunTextureId() const { - return mSettings[SETTING_SUN_TEXTUREID].asUUID(); + return mSunTextureId; } void LLSettingsSky::setSunTextureId(LLUUID id) { - setValue(SETTING_SUN_TEXTUREID, id); + mSunTextureId = id; + setLLSDDirty(); } LLUUID LLSettingsSky::getNextSunTextureId() const @@ -1790,5 +2190,5 @@ LLUUID LLSettingsSky::getNextBloomTextureId() const // if true, this sky is a candidate for auto-adjustment bool LLSettingsSky::canAutoAdjust() const { - return !mSettings.has(SETTING_REFLECTION_PROBE_AMBIANCE); + return mCanAutoAdjust; } diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 222ab040cb..38c0368423 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -62,7 +62,7 @@ public: static const std::string SETTING_DOME_OFFSET; static const std::string SETTING_DOME_RADIUS; static const std::string SETTING_GAMMA; - static const std::string SETTING_GLOW; + static const std::string SETTING_GLOW; static const std::string SETTING_LIGHT_NORMAL; static const std::string SETTING_MAX_Y; static const std::string SETTING_MOON_ROTATION; @@ -92,7 +92,7 @@ public: static const std::string SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR; static const std::string SETTING_DENSITY_PROFILE_LINEAR_TERM; static const std::string SETTING_DENSITY_PROFILE_CONSTANT_TERM; - + static const std::string SETTING_SKY_MOISTURE_LEVEL; static const std::string SETTING_SKY_DROPLET_RADIUS; static const std::string SETTING_SKY_ICE_LEVEL; @@ -111,25 +111,29 @@ public: LLSettingsSky(const LLSD &data); virtual ~LLSettingsSky() { }; - virtual ptr_t buildClone() const = 0; + virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- virtual std::string getSettingsType() const SETTINGS_OVERRIDE { return std::string("sky"); } virtual LLSettingsType::type_e getSettingsTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_SKY; } - // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; + // Settings status + virtual void blend(LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; virtual void replaceSettings(LLSD settings) SETTINGS_OVERRIDE; + virtual void replaceSettings(const LLSettingsBase::ptr_t& other_sky) override; - void replaceWithSky(LLSettingsSky::ptr_t pother); + void replaceWithSky(const LLSettingsSky::ptr_t& pother); static LLSD defaults(const LLSettingsBase::TrackPosition& position = 0.0f); + void loadValuesFromLLSD() override; + void saveValuesToLLSD() override; + F32 getPlanetRadius() const; F32 getSkyBottomRadius() const; F32 getSkyTopRadius() const; F32 getSunArcRadians() const; - F32 getMieAnisotropy() const; + F32 getMieAnisotropy() const; F32 getSkyMoistureLevel() const; F32 getSkyDropletRadius() const; @@ -196,7 +200,7 @@ public: F32 getCloudShadow() const; void setCloudShadow(F32 val); - + F32 getCloudVariance() const; void setCloudVariance(F32 val); @@ -295,7 +299,7 @@ public: // color based on brightness LLColor3 getMoonlightColor() const; - + LLColor4 getMoonAmbient() const; LLColor3 getMoonDiffuse() const; LLColor4 getSunAmbient() const; @@ -306,7 +310,7 @@ public: LLColor3 getSunlightColorClamped() const; LLColor3 getAmbientColorClamped() const; - virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } static LLUUID GetDefaultAssetId(); static LLUUID GetDefaultSunTextureId(); @@ -348,6 +352,12 @@ protected: virtual stringset_t getSlerpKeys() const SETTINGS_OVERRIDE; virtual stringset_t getSkipInterpolateKeys() const SETTINGS_OVERRIDE; + LLUUID mSunTextureId; + LLUUID mMoonTextureId; + LLUUID mCloudTextureId; + LLUUID mBloomTextureId; + LLUUID mRainbowTextureId; + LLUUID mHaloTextureId; LLUUID mNextSunTextureId; LLUUID mNextMoonTextureId; LLUUID mNextCloudTextureId; @@ -355,17 +365,64 @@ protected: LLUUID mNextRainbowTextureId; LLUUID mNextHaloTextureId; + bool mCanAutoAdjust; + LLQuaternion mSunRotation; + LLQuaternion mMoonRotation; + LLColor3 mSunlightColor; + LLColor3 mGlow; + F32 mReflectionProbeAmbiance; + F32 mSunScale; + F32 mStarBrightness; + F32 mMoonBrightness; + F32 mMoonScale; + F32 mMaxY; + F32 mGamma; + F32 mCloudVariance; + F32 mCloudShadow; + F32 mCloudScale; + LLVector2 mScrollRate; + LLColor3 mCloudPosDensity1; + LLColor3 mCloudPosDensity2; + LLColor3 mCloudColor; + LLSD mAbsorptionConfigs; + LLSD mMieConfigs; + LLSD mRayleighConfigs; + F32 mSunArcRadians; + F32 mSkyTopRadius; + F32 mSkyBottomRadius; + F32 mSkyMoistureLevel; + F32 mSkyDropletRadius; + F32 mSkyIceLevel; + F32 mPlanetRadius; + + F32 mHazeHorizon; + F32 mHazeDensity; + F32 mDistanceMultiplier; + F32 mDensityMultiplier; + LLColor3 mBlueHorizon; + LLColor3 mBlueDensity; + LLColor3 mAmbientColor; + + bool mHasLegacyHaze; + bool mLegacyHazeHorizon; + bool mLegacyHazeDensity; + bool mLegacyDistanceMultiplier; + bool mLegacyDensityMultiplier; + bool mLegacyBlueHorizon; + bool mLegacyBlueDensity; + bool mLegacyAmbientColor; + private: static LLSD rayleighConfigDefault(); static LLSD absorptionConfigDefault(); static LLSD mieConfigDefault(); - LLColor3 getColor(const std::string& key, const LLColor3& default_value) const; - F32 getFloat(const std::string& key, F32 default_value) const; + LLColor3 getColor(const std::string& key, const LLColor3& default_value); + F32 getFloat(const std::string& key, F32 default_value); void calculateHeavenlyBodyPositions() const; void calculateLightSettings() const; - void clampColor(LLColor3& color, F32 gamma, const F32 scale = 1.0f) const; + static void clampColor(LLColor3& color, F32 gamma, const F32 scale = 1.0f); mutable LLVector3 mSunDirection; mutable LLVector3 mMoonDirection; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 4cd84970ff..08e18ea26e 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -27,7 +27,6 @@ #include "llsettingswater.h" #include <algorithm> -#include <boost/make_shared.hpp> #include "lltrace.h" #include "llfasttimer.h" #include "v3colorutil.h" @@ -69,14 +68,18 @@ static const LLUUID DEFAULT_OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf8631 //========================================================================= LLSettingsWater::LLSettingsWater(const LLSD &data) : LLSettingsBase(data), - mNextNormalMapID() + mNextNormalMapID(), + mNextTransparentTextureID() { + loadValuesFromLLSD(); } LLSettingsWater::LLSettingsWater() : LLSettingsBase(), - mNextNormalMapID() + mNextNormalMapID(), + mNextTransparentTextureID() { + replaceSettings(defaults()); } //========================================================================= @@ -110,6 +113,53 @@ LLSD LLSettingsWater::defaults(const LLSettingsBase::TrackPosition& position) return dfltsetting; } +void LLSettingsWater::loadValuesFromLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::loadValuesFromLLSD(); + + LLSD& settings = getSettings(); + + mBlurMultiplier = (F32)settings[SETTING_BLUR_MULTIPLIER].asReal(); + mWaterFogColor = LLColor3(settings[SETTING_FOG_COLOR]); + mWaterFogDensity = (F32)settings[SETTING_FOG_DENSITY].asReal(); + mFogMod = (F32)settings[SETTING_FOG_MOD].asReal(); + mFresnelOffset = (F32)settings[SETTING_FRESNEL_OFFSET].asReal(); + mFresnelScale = (F32)settings[SETTING_FRESNEL_SCALE].asReal(); + mNormalScale = LLVector3(settings[SETTING_NORMAL_SCALE]); + mScaleAbove = (F32)settings[SETTING_SCALE_ABOVE].asReal(); + mScaleBelow = (F32)settings[SETTING_SCALE_BELOW].asReal(); + mWave1Dir = LLVector2(settings[SETTING_WAVE1_DIR]); + mWave2Dir = LLVector2(settings[SETTING_WAVE2_DIR]); + + mNormalMapID = getNormalMapID(); + mTransparentTextureID = getTransparentTextureID(); +} + +void LLSettingsWater::saveValuesToLLSD() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; + + LLSettingsBase::saveValuesToLLSD(); + + LLSD & settings = getSettings(); + settings[SETTING_BLUR_MULTIPLIER] = LLSD::Real(mBlurMultiplier); + settings[SETTING_FOG_COLOR] = mWaterFogColor.getValue(); + settings[SETTING_FOG_DENSITY] = LLSD::Real(mWaterFogDensity); + settings[SETTING_FOG_MOD] = LLSD::Real(mFogMod); + settings[SETTING_FRESNEL_OFFSET] = LLSD::Real(mFresnelOffset); + settings[SETTING_FRESNEL_SCALE] = LLSD::Real(mFresnelScale); + settings[SETTING_NORMAL_SCALE] = mNormalScale.getValue(); + settings[SETTING_SCALE_ABOVE] = LLSD::Real(mScaleAbove); + settings[SETTING_SCALE_BELOW] = LLSD::Real(mScaleBelow); + settings[SETTING_WAVE1_DIR] = mWave1Dir.getValue(); + settings[SETTING_WAVE2_DIR] = mWave2Dir.getValue(); + + settings[SETTING_NORMAL_MAP] = mNormalMapID; + settings[SETTING_TRANSPARENT_TEXTURE] = mTransparentTextureID; +} + LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) { bool converted_something(false); @@ -181,13 +231,30 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy) return newsettings; } -void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) +void LLSettingsWater::blend(LLSettingsBase::ptr_t &end, F64 blendf) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast<LLSettingsWater>(end); if (other) { - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); - replaceSettings(blenddata); + mSettingFlags |= other->mSettingFlags; + + mBlurMultiplier = lerp((F32)blendf, mBlurMultiplier, other->mBlurMultiplier); + lerpColor(mWaterFogColor, other->mWaterFogColor, (F32)blendf); + mWaterFogDensity = lerp((F32)blendf, mWaterFogDensity, other->mWaterFogDensity); + mFogMod = lerp((F32)blendf, mFogMod, other->mFogMod); + mFresnelOffset = lerp((F32)blendf, mFresnelOffset, other->mFresnelOffset); + mFresnelScale = lerp((F32)blendf, mFresnelScale, other->mFresnelScale); + lerpVector3(mNormalScale, other->mNormalScale, (F32)blendf); + mScaleAbove = lerp((F32)blendf, mScaleAbove, other->mScaleAbove); + mScaleBelow = lerp((F32)blendf, mScaleBelow, other->mScaleBelow); + lerpVector2(mWave1Dir, other->mWave1Dir, (F32)blendf); + lerpVector2(mWave2Dir, other->mWave2Dir, (F32)blendf); + + setDirtyFlag(true); + setReplaced(); + setLLSDDirty(); + mNextNormalMapID = other->getNormalMapID(); mNextTransparentTextureID = other->getTransparentTextureID(); } @@ -205,7 +272,34 @@ void LLSettingsWater::replaceSettings(LLSD settings) mNextTransparentTextureID.setNull(); } -void LLSettingsWater::replaceWithWater(LLSettingsWater::ptr_t other) +void LLSettingsWater::replaceSettings(const LLSettingsBase::ptr_t& other_water) +{ + LLSettingsBase::replaceSettings(other_water); + + llassert(getSettingsType() == other_water->getSettingsType()); + + LLSettingsWater::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsWater>(other_water); + + mBlurMultiplier = other->mBlurMultiplier; + mWaterFogColor = other->mWaterFogColor; + mWaterFogDensity = other->mWaterFogDensity; + mFogMod = other->mFogMod; + mFresnelOffset = other->mFresnelOffset; + mFresnelScale = other->mFresnelScale; + mNormalScale = other->mNormalScale; + mScaleAbove = other->mScaleAbove; + mScaleBelow = other->mScaleBelow; + mWave1Dir = other->mWave1Dir; + mWave2Dir = other->mWave2Dir; + + mNormalMapID = other->mNormalMapID; + mTransparentTextureID = other->mTransparentTextureID; + + mNextNormalMapID.setNull(); + mNextTransparentTextureID.setNull(); +} + +void LLSettingsWater::replaceWithWater(const LLSettingsWater::ptr_t& other) { replaceWith(other); diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 0b29d8ca19..82fc37cfb3 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -55,151 +55,181 @@ public: LLSettingsWater(const LLSD &data); virtual ~LLSettingsWater() { }; - virtual ptr_t buildClone() const = 0; + virtual ptr_t buildClone() = 0; //--------------------------------------------------------------------- virtual std::string getSettingsType() const SETTINGS_OVERRIDE { return std::string("water"); } virtual LLSettingsType::type_e getSettingsTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_WATER; } // Settings status - virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; + virtual void blend(LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; virtual void replaceSettings(LLSD settings) SETTINGS_OVERRIDE; - void replaceWithWater(LLSettingsWater::ptr_t other); + virtual void replaceSettings(const LLSettingsBase::ptr_t& other_water) override; + void replaceWithWater(const LLSettingsWater::ptr_t& other); static LLSD defaults(const LLSettingsBase::TrackPosition& position = 0.0f); + void loadValuesFromLLSD() override; + void saveValuesToLLSD() override; + //--------------------------------------------------------------------- F32 getBlurMultiplier() const { - return mSettings[SETTING_BLUR_MULTIPLIER].asReal(); + return mBlurMultiplier; } void setBlurMultiplier(F32 val) { - setValue(SETTING_BLUR_MULTIPLIER, val); + mBlurMultiplier = val; + setDirtyFlag(true); + setLLSDDirty(); } LLColor3 getWaterFogColor() const { - return LLColor3(mSettings[SETTING_FOG_COLOR]); + return mWaterFogColor; } void setWaterFogColor(LLColor3 val) { - setValue(SETTING_FOG_COLOR, val); + mWaterFogColor = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getWaterFogDensity() const { - return mSettings[SETTING_FOG_DENSITY].asReal(); + return mWaterFogDensity; } F32 getModifiedWaterFogDensity(bool underwater) const; void setWaterFogDensity(F32 val) { - setValue(SETTING_FOG_DENSITY, val); + mWaterFogDensity = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getFogMod() const { - return mSettings[SETTING_FOG_MOD].asReal(); + return mFogMod; } void setFogMod(F32 val) { - setValue(SETTING_FOG_MOD, val); + mFogMod = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getFresnelOffset() const { - return mSettings[SETTING_FRESNEL_OFFSET].asReal(); + return mFresnelOffset; } void setFresnelOffset(F32 val) { - setValue(SETTING_FRESNEL_OFFSET, val); + mFresnelOffset = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getFresnelScale() const { - return mSettings[SETTING_FRESNEL_SCALE].asReal(); + return mFresnelScale; } void setFresnelScale(F32 val) { - setValue(SETTING_FRESNEL_SCALE, val); + mFresnelScale = val; + setDirtyFlag(true); + setLLSDDirty(); } LLUUID getTransparentTextureID() const { - return mSettings[SETTING_TRANSPARENT_TEXTURE].asUUID(); + return mTransparentTextureID; } void setTransparentTextureID(LLUUID val) { - setValue(SETTING_TRANSPARENT_TEXTURE, val); + mTransparentTextureID = val; + setDirtyFlag(true); + setLLSDDirty(); } LLUUID getNormalMapID() const { - return mSettings[SETTING_NORMAL_MAP].asUUID(); + return mNormalMapID; } void setNormalMapID(LLUUID val) { - setValue(SETTING_NORMAL_MAP, val); + mNormalMapID = val; + setDirtyFlag(true); + setLLSDDirty(); } LLVector3 getNormalScale() const { - return LLVector3(mSettings[SETTING_NORMAL_SCALE]); + return mNormalScale; } void setNormalScale(LLVector3 val) { - setValue(SETTING_NORMAL_SCALE, val); + mNormalScale = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getScaleAbove() const { - return mSettings[SETTING_SCALE_ABOVE].asReal(); + return mScaleAbove; } void setScaleAbove(F32 val) { - setValue(SETTING_SCALE_ABOVE, val); + mScaleAbove = val; + setDirtyFlag(true); + setLLSDDirty(); } F32 getScaleBelow() const { - return mSettings[SETTING_SCALE_BELOW].asReal(); + return mScaleBelow; } void setScaleBelow(F32 val) { - setValue(SETTING_SCALE_BELOW, val); + mScaleBelow = val; + setDirtyFlag(true); + setLLSDDirty(); } LLVector2 getWave1Dir() const { - return LLVector2(mSettings[SETTING_WAVE1_DIR]); + return mWave1Dir; } void setWave1Dir(LLVector2 val) { - setValue(SETTING_WAVE1_DIR, val); + mWave1Dir = val; + setDirtyFlag(true); + setLLSDDirty(); } LLVector2 getWave2Dir() const { - return LLVector2(mSettings[SETTING_WAVE2_DIR]); + return mWave2Dir; } void setWave2Dir(LLVector2 val) { - setValue(SETTING_WAVE2_DIR, val); + mWave2Dir = val; + setDirtyFlag(true); + setLLSDDirty(); } //------------------------------------------- @@ -218,7 +248,7 @@ public: static LLSD translateLegacySettings(LLSD legacy); - virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); } + virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); } static LLUUID GetDefaultAssetId(); static LLUUID GetDefaultWaterNormalAssetId(); @@ -241,9 +271,22 @@ protected: LLSettingsWater(); + LLUUID mTransparentTextureID; + LLUUID mNormalMapID; LLUUID mNextTransparentTextureID; LLUUID mNextNormalMapID; + F32 mBlurMultiplier; + LLColor3 mWaterFogColor; + F32 mWaterFogDensity; + F32 mFogMod; + F32 mFresnelOffset; + F32 mFresnelScale; + LLVector3 mNormalScale; + F32 mScaleAbove; + F32 mScaleBelow; + LLVector2 mWave1Dir; + LLVector2 mWave2Dir; }; #endif diff --git a/indra/llinventory/lltransactionflags.cpp b/indra/llinventory/lltransactionflags.cpp index fc3e684a65..3719a295c3 100644 --- a/indra/llinventory/lltransactionflags.cpp +++ b/indra/llinventory/lltransactionflags.cpp @@ -38,7 +38,7 @@ const U8 TRANSACTION_FLAG_OWNER_GROUP = 4; const U8 TRANSACTION_FLAG_SIMULTANEOUS_CONTRIBUTION = 8; const U8 TRANSACTION_FLAG_SIMULTANEOUS_CONTRIBUTION_REMOVAL = 16; -U8 pack_transaction_flags(BOOL is_source_group, BOOL is_dest_group) +U8 pack_transaction_flags(bool is_source_group, bool is_dest_group) { U8 rv = 0; if(is_source_group) rv |= TRANSACTION_FLAG_SOURCE_GROUP; @@ -46,17 +46,17 @@ U8 pack_transaction_flags(BOOL is_source_group, BOOL is_dest_group) return rv; } -BOOL is_tf_source_group(TransactionFlags flags) +bool is_tf_source_group(TransactionFlags flags) { return ((flags & TRANSACTION_FLAG_SOURCE_GROUP) == TRANSACTION_FLAG_SOURCE_GROUP); } -BOOL is_tf_dest_group(TransactionFlags flags) +bool is_tf_dest_group(TransactionFlags flags) { return ((flags & TRANSACTION_FLAG_DEST_GROUP) == TRANSACTION_FLAG_DEST_GROUP); } -BOOL is_tf_owner_group(TransactionFlags flags) +bool is_tf_owner_group(TransactionFlags flags) { return ((flags & TRANSACTION_FLAG_OWNER_GROUP) == TRANSACTION_FLAG_OWNER_GROUP); } @@ -79,6 +79,7 @@ void append_reason( break; case TRANS_GROUP_LAND_DEED: ostr << " for deeding land"; + break; default: break; } diff --git a/indra/llinventory/lltransactionflags.h b/indra/llinventory/lltransactionflags.h index bb267ad2be..3c61b785a3 100644 --- a/indra/llinventory/lltransactionflags.h +++ b/indra/llinventory/lltransactionflags.h @@ -39,10 +39,10 @@ extern const TransactionFlags TRANSACTION_FLAG_SIMULTANEOUS_CONTRIBUTION; extern const TransactionFlags TRANSACTION_FLAG_SIMULTANEOUS_CONTRIBUTION_REMOVAL; // very simple helper functions -TransactionFlags pack_transaction_flags(BOOL is_source_group, BOOL is_dest_group); -BOOL is_tf_source_group(TransactionFlags flags); -BOOL is_tf_dest_group(TransactionFlags flags); -BOOL is_tf_owner_group(TransactionFlags flags); +TransactionFlags pack_transaction_flags(bool is_source_group, bool is_dest_group); +bool is_tf_source_group(TransactionFlags flags); +bool is_tf_dest_group(TransactionFlags flags); +bool is_tf_owner_group(TransactionFlags flags); // stupid helper functions which should be replaced with some kind of // internationalizeable message. diff --git a/indra/llinventory/tests/inventorymisc_test.cpp b/indra/llinventory/tests/inventorymisc_test.cpp index a2a6aa339f..9779cb8fbc 100644 --- a/indra/llinventory/tests/inventorymisc_test.cpp +++ b/indra/llinventory/tests/inventorymisc_test.cpp @@ -61,7 +61,7 @@ LLPointer<LLInventoryItem> create_random_inventory_item() S32 price = rand(); LLSaleInfo sale_info(LLSaleInfo::FS_COPY, price); U32 flags = rand(); - S32 creation = time(NULL); + S32 creation = (S32)time(NULL); LLPointer<LLInventoryItem> item = new LLInventoryItem( item_id, @@ -195,7 +195,7 @@ namespace tut src->setSaleInfo(new_sale_info); U32 new_flags = rand(); - S32 new_creation = time(NULL); + S32 new_creation = (S32)time(NULL); LLPermissions new_perm; @@ -266,7 +266,7 @@ namespace tut src->setSaleInfo(new_sale_info); U32 new_flags = rand(); - S32 new_creation = time(NULL); + S32 new_creation = (S32)time(NULL); LLPermissions new_perm; @@ -374,7 +374,7 @@ namespace tut LLPointer<LLInventoryItem> src1 = create_random_inventory_item(); std::ostringstream ostream; - src1->exportLegacyStream(ostream, TRUE); + src1->exportLegacyStream(ostream, true); std::istringstream istream(ostream.str()); LLPointer<LLInventoryItem> src2 = new LLInventoryItem(); @@ -496,7 +496,7 @@ namespace tut LLPointer<LLInventoryCategory> src1 = create_random_inventory_cat(); std::ostringstream ostream; - src1->exportLegacyStream(ostream, TRUE); + src1->exportLegacyStream(ostream, true); std::istringstream istream(ostream.str()); LLPointer<LLInventoryCategory> src2 = new LLInventoryCategory(); |