From fe551e94a8778935bfffa8e730a76e3ff09ce276 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Sun, 7 Dec 2008 22:51:21 -0600 Subject: New enumerator for inventory types. --- linden/indra/llinventory/llinventorytype.h | 86 ++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) (limited to 'linden/indra/llinventory') diff --git a/linden/indra/llinventory/llinventorytype.h b/linden/indra/llinventory/llinventorytype.h index 00a4d28..f228cd0 100644 --- a/linden/indra/llinventory/llinventorytype.h +++ b/linden/indra/llinventory/llinventorytype.h @@ -71,6 +71,92 @@ public: IT_NONE = -1 }; + + /** + * @brief New enumerator for inventory types + * + * This is intended as a replacement to the above EType. + * EType will be phased out in favor of this enum. + * + * This enum acts as a bitfield, which This has several + * useful properties for filtering: + * + * 1. The inventory item's type can be compared by either + * equality or bitwise AND. Bitwise AND allows a quick + * check to see whether the type is one of multiple + * possible types. + * + * 2. It allows for a fast hierarchical organization, by + * defining a broad type (e.g. NIT_BODYPART) whose + * value is the bitwise OR-ing of several more specific + * sub-types (e.g. NIT_SKIN|NIT_HAIR|...). + * + */ + enum NType + { + /* No Type */ + NIT_NONE = 0x0000000, + + /* Body Parts */ + NIT_SHAPE = 1 << 0, + NIT_SKIN = 1 << 1, + NIT_HAIR = 1 << 2, + NIT_EYES = 1 << 3, + NIT_BODYPART = 0x000000f, + + /* Clothing */ + NIT_SHIRT = 1 << 4, + NIT_PANTS = 1 << 5, + NIT_SHOES = 1 << 6, + NIT_SOCKS = 1 << 7, + NIT_JACKET = 1 << 8, + NIT_GLOVES = 1 << 9, + NIT_UNDERSHIRT = 1 << 10, + NIT_UNDERPANTS = 1 << 11, + NIT_SKIRT = 1 << 12, + NIT_CLOTHING = 0x0001ff0, + + /* Body Parts | Clothing */ + NIT_WEARABLE = 0x0001fff, + + /* Images */ + NIT_TEXTURE = 1 << 13, + NIT_SNAPSHOT = 1 << 14, + NIT_IMAGE = 0x0006000, + + /* Calling Cards */ + NIT_CALLCARD_OFF = 1 << 15, + NIT_CALLCARD_ON = 1 << 16, + NIT_CALLCARD = 0x0018000, + + /* Landmarks */ + NIT_LANDMARK_UNUSED = 1 << 17, + NIT_LANDMARK_USED = 1 << 18, + NIT_LANDMARK = 0x0060000, + + /* Sounds */ + NIT_SOUND = 1 << 19, + + /* Animations */ + NIT_ANIMATION = 1 << 20, + + /* Gestures */ + NIT_GESTURE = 1 << 21, + + /* Notecards */ + NIT_NOTECARD = 1 << 22, + + /* Scripts */ + NIT_SCRIPT_LSL2 = 1 << 23, + + /* Objects */ + NIT_OBJECT = 1 << 24, + + /* Bitwise OR-ing of all the above */ + NIT_ALL = 0x1ffffff, + }; + + // machine transation between type and strings static EType lookup(const std::string& name); static const char* lookup(EType type); -- cgit v1.1 From 131cc1d821fafde3aa20bba66f387e092adf6f59 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Sun, 7 Dec 2008 23:35:25 -0600 Subject: Added LLInventoryItem::mNInventoryType (new type) field. Will always by NIT_NONE so far. --- linden/indra/llinventory/llinventory.cpp | 13 +++++++++++++ linden/indra/llinventory/llinventory.h | 3 +++ 2 files changed, 16 insertions(+) (limited to 'linden/indra/llinventory') diff --git a/linden/indra/llinventory/llinventory.cpp b/linden/indra/llinventory/llinventory.cpp index 457a0cb..72eab74 100644 --- a/linden/indra/llinventory/llinventory.cpp +++ b/linden/indra/llinventory/llinventory.cpp @@ -287,6 +287,7 @@ LLInventoryItem::LLInventoryItem( mDescription(desc), mSaleInfo(sale_info), mInventoryType(inv_type), + mNInventoryType(LLInventoryType::NIT_NONE), mFlags(flags), mCreationDate(creation_date_utc) { @@ -301,6 +302,7 @@ LLInventoryItem::LLInventoryItem() : mDescription(), mSaleInfo(), mInventoryType(LLInventoryType::IT_NONE), + mNInventoryType(LLInventoryType::NIT_NONE), mFlags(0), mCreationDate(0) { @@ -325,6 +327,7 @@ void LLInventoryItem::copyItem(const LLInventoryItem* other) mDescription = other->mDescription; mSaleInfo = other->mSaleInfo; mInventoryType = other->mInventoryType; + mNInventoryType = other->mNInventoryType; mFlags = other->mFlags; mCreationDate = other->mCreationDate; } @@ -417,6 +420,11 @@ void LLInventoryItem::setInventoryType(LLInventoryType::EType inv_type) mInventoryType = inv_type; } +void LLInventoryItem::setNInventoryType(LLInventoryType::NType inv_type) +{ + mNInventoryType = inv_type; +} + void LLInventoryItem::setFlags(U32 flags) { mFlags = flags; @@ -443,6 +451,11 @@ LLInventoryType::EType LLInventoryItem::getInventoryType() const return mInventoryType; } +LLInventoryType::NType LLInventoryItem::getNInventoryType() const +{ + return mNInventoryType; +} + U32 LLInventoryItem::getFlags() const { return mFlags; diff --git a/linden/indra/llinventory/llinventory.h b/linden/indra/llinventory/llinventory.h index d3cce6b..ac4e470 100644 --- a/linden/indra/llinventory/llinventory.h +++ b/linden/indra/llinventory/llinventory.h @@ -131,6 +131,7 @@ protected: std::string mDescription; LLSaleInfo mSaleInfo; LLInventoryType::EType mInventoryType; + LLInventoryType::NType mNInventoryType; U32 mFlags; time_t mCreationDate; // seconds from 1/1/1970, UTC @@ -236,6 +237,7 @@ public: const std::string& getDescription() const; const LLSaleInfo& getSaleInfo() const; LLInventoryType::EType getInventoryType() const; + LLInventoryType::NType getNInventoryType() const; U32 getFlags() const; time_t getCreationDate() const; U32 getCRC32() const; // really more of a checksum. @@ -247,6 +249,7 @@ public: void setSaleInfo(const LLSaleInfo& sale_info); void setPermissions(const LLPermissions& perm); void setInventoryType(LLInventoryType::EType inv_type); + void setNInventoryType(LLInventoryType::NType inv_type); void setFlags(U32 flags); void setCreationDate(time_t creation_date_utc); -- cgit v1.1 From 9626acce584391fc90d147310917a1569610d224 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Mon, 8 Dec 2008 01:00:18 -0600 Subject: Moved enum EWearableType to its own file. Was in newview/llwearable.h, now in llinventory/llwearabletype.h. This allows it to be used in llinventory code. --- linden/indra/llinventory/llwearabletype.h | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 linden/indra/llinventory/llwearabletype.h (limited to 'linden/indra/llinventory') diff --git a/linden/indra/llinventory/llwearabletype.h b/linden/indra/llinventory/llwearabletype.h new file mode 100644 index 0000000..b0a40b2 --- /dev/null +++ b/linden/indra/llinventory/llwearabletype.h @@ -0,0 +1,54 @@ +/** + * @file llwearable.h + * @brief EWearableType enum definition + * + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2008, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLWEARABLETYPE_H +#define LL_LLWEARABLETYPE_H + +enum EWearableType // If you change this, update LLWearable::getTypeName(), getTypeLabel(), and LLVOAvatar::getTEWearableType() +{ + WT_SHAPE = 0, + WT_SKIN = 1, + WT_HAIR = 2, + WT_EYES = 3, + WT_SHIRT = 4, + WT_PANTS = 5, + WT_SHOES = 6, + WT_SOCKS = 7, + WT_JACKET = 8, + WT_GLOVES = 9, + WT_UNDERSHIRT = 10, + WT_UNDERPANTS = 11, + WT_SKIRT = 12, + WT_COUNT = 13, + WT_INVALID = 255 +}; + +#endif // LL_LLWEARABLETYPE_H -- cgit v1.1 From e68b9cd2f896ee5412b2dd6fe4bfe1aa55ed48e4 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Mon, 8 Dec 2008 01:16:25 -0600 Subject: Added calc_ntype() function. --- linden/indra/llinventory/llinventory.cpp | 110 +++++++++++++++++++++++++++++++ linden/indra/llinventory/llinventory.h | 5 ++ 2 files changed, 115 insertions(+) (limited to 'linden/indra/llinventory') diff --git a/linden/indra/llinventory/llinventory.cpp b/linden/indra/llinventory/llinventory.cpp index 72eab74..38cb37d 100644 --- a/linden/indra/llinventory/llinventory.cpp +++ b/linden/indra/llinventory/llinventory.cpp @@ -70,6 +70,116 @@ const U8 TASK_INVENTORY_ASSET_KEY = 1; const LLUUID MAGIC_ID("3c115e51-04f4-523c-9fa6-98aff1034730"); +/** + * @brief Return the equivalent new inventory type. + * + * Takes an inventory type, asset type, and inventory flags, + * and returns the equivalent LLInventory::NType. + * + * For example, an inventory type of IT_WEARABLE, asset type + * of AT_BODYPART, and flags indicated WT_SHAPE, would be + * converted to NIT_SHAPE. + * + * Returns the most specific type that can be determined, + * or NIT_NONE if no type could be determined. + * + */ +LLInventoryType::NType calc_ntype( + LLInventoryType::EType inv_type, + LLAssetType::EType asset_type, + U32 flags ) +{ + switch( inv_type ) + { + + // WEARABLES + case LLInventoryType::IT_WEARABLE: + { + switch( asset_type ) + { + // BODY PARTS + case LLAssetType::AT_BODYPART: + { + switch( flags & LLInventoryItem::II_FLAGS_WEARABLES_MASK ) + { + case WT_SHAPE: return LLInventoryType::NIT_SHAPE; + case WT_SKIN: return LLInventoryType::NIT_SKIN; + case WT_HAIR: return LLInventoryType::NIT_HAIR; + case WT_EYES: return LLInventoryType::NIT_EYES; + default: return LLInventoryType::NIT_BODYPART; + } + } + + // CLOTHING + case LLAssetType::AT_CLOTHING: + { + switch( flags & LLInventoryItem::II_FLAGS_WEARABLES_MASK ) + { + case WT_SHIRT: return LLInventoryType::NIT_SHIRT; + case WT_PANTS: return LLInventoryType::NIT_PANTS; + case WT_SHOES: return LLInventoryType::NIT_SHOES; + case WT_SOCKS: return LLInventoryType::NIT_SOCKS; + case WT_JACKET: return LLInventoryType::NIT_JACKET; + case WT_GLOVES: return LLInventoryType::NIT_GLOVES; + case WT_UNDERSHIRT: return LLInventoryType::NIT_UNDERSHIRT; + case WT_UNDERPANTS: return LLInventoryType::NIT_UNDERPANTS; + case WT_SKIRT: return LLInventoryType::NIT_SKIRT; + default: return LLInventoryType::NIT_CLOTHING; + } + } + default: + return LLInventoryType::NIT_WEARABLE; + } + } + + // TEXTURES + case LLInventoryType::IT_TEXTURE: + return LLInventoryType::NIT_TEXTURE; + + // SNAPSHOTS + case LLInventoryType::IT_SNAPSHOT: + return LLInventoryType::NIT_SNAPSHOT; + + // CALLING CARDS + case LLInventoryType::IT_CALLINGCARD: + return LLInventoryType::NIT_CALLCARD; + + // LANDMARKS + case LLInventoryType::IT_LANDMARK: + return LLInventoryType::NIT_LANDMARK; + + // SOUNDS + case LLInventoryType::IT_SOUND: + return LLInventoryType::NIT_SOUND; + + // ANIMATIONS + case LLInventoryType::IT_ANIMATION: + return LLInventoryType::NIT_ANIMATION; + + // GESTURES + case LLInventoryType::IT_GESTURE: + return LLInventoryType::NIT_GESTURE; + + // NOTECARDS + case LLInventoryType::IT_NOTECARD: + return LLInventoryType::NIT_NOTECARD; + + // SCRIPTS + case LLInventoryType::IT_LSL: + return LLInventoryType::NIT_SCRIPT_LSL2; + + // OBJECTS + case LLInventoryType::IT_OBJECT: + case LLInventoryType::IT_ATTACHMENT: + return LLInventoryType::NIT_OBJECT; + + // UNKNOWN TYPE! + default: + return LLInventoryType::NIT_NONE; + } +} + + ///---------------------------------------------------------------------------- /// Class LLInventoryObject ///---------------------------------------------------------------------------- diff --git a/linden/indra/llinventory/llinventory.h b/linden/indra/llinventory/llinventory.h index ac4e470..247e646 100644 --- a/linden/indra/llinventory/llinventory.h +++ b/linden/indra/llinventory/llinventory.h @@ -42,6 +42,7 @@ #include "llsaleinfo.h" #include "llsd.h" #include "lluuid.h" +#include "llwearabletype.h" #include "llxmlnode.h" // consts for Key field in the task inventory update message @@ -56,6 +57,10 @@ enum }; +LLInventoryType::NType calc_ntype( LLInventoryType::EType inv_type, + LLAssetType::EType asset_type, + U32 flags ); + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLInventoryObject -- cgit v1.1 From 87c91cc283340c6b7fce90ac9f80826ba641a36f Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Mon, 8 Dec 2008 01:29:12 -0600 Subject: Added LLInventoryItem::recalcNInventoryType(). --- linden/indra/llinventory/llinventory.cpp | 6 ++++++ linden/indra/llinventory/llinventory.h | 3 +++ 2 files changed, 9 insertions(+) (limited to 'linden/indra/llinventory') diff --git a/linden/indra/llinventory/llinventory.cpp b/linden/indra/llinventory/llinventory.cpp index 38cb37d..8d8008e 100644 --- a/linden/indra/llinventory/llinventory.cpp +++ b/linden/indra/llinventory/llinventory.cpp @@ -509,6 +509,12 @@ U32 LLInventoryItem::getCRC32() const } +void LLInventoryItem::recalcNInventoryType() +{ + setNInventoryType( calc_ntype(mInventoryType, mType, mFlags) ); +} + + void LLInventoryItem::setDescription(const std::string& d) { std::string new_desc(d); diff --git a/linden/indra/llinventory/llinventory.h b/linden/indra/llinventory/llinventory.h index 247e646..34d9445 100644 --- a/linden/indra/llinventory/llinventory.h +++ b/linden/indra/llinventory/llinventory.h @@ -285,6 +285,9 @@ public: LLSD asLLSD() const; bool fromLLSD(LLSD& sd); +private: + void recalcNInventoryType(); + }; BOOL item_dictionary_sort(LLInventoryItem* a,LLInventoryItem* b); -- cgit v1.1 From ecfb4c73e006d33a72f03ce9db2db550737d14c2 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Mon, 8 Dec 2008 02:17:06 -0600 Subject: Recalculate ntype when changing type or flags. --- linden/indra/llinventory/llinventory.cpp | 9 +++++++++ linden/indra/llinventory/llinventory.h | 1 + 2 files changed, 10 insertions(+) (limited to 'linden/indra/llinventory') diff --git a/linden/indra/llinventory/llinventory.cpp b/linden/indra/llinventory/llinventory.cpp index 8d8008e..0a8a1fb 100644 --- a/linden/indra/llinventory/llinventory.cpp +++ b/linden/indra/llinventory/llinventory.cpp @@ -403,6 +403,7 @@ LLInventoryItem::LLInventoryItem( { LLStringUtil::replaceNonstandardASCII(mDescription, ' '); LLStringUtil::replaceChar(mDescription, '|', ' '); + recalcNInventoryType(); } LLInventoryItem::LLInventoryItem() : @@ -531,9 +532,16 @@ void LLInventoryItem::setPermissions(const LLPermissions& perm) mPermissions = perm; } +void LLInventoryItem::setType(LLAssetType::EType type) +{ + mType = type; + recalcNInventoryType(); +} + void LLInventoryItem::setInventoryType(LLInventoryType::EType inv_type) { mInventoryType = inv_type; + recalcNInventoryType(); } void LLInventoryItem::setNInventoryType(LLInventoryType::NType inv_type) @@ -544,6 +552,7 @@ void LLInventoryItem::setNInventoryType(LLInventoryType::NType inv_type) void LLInventoryItem::setFlags(U32 flags) { mFlags = flags; + recalcNInventoryType(); } void LLInventoryItem::setCreationDate(time_t creation_date_utc) diff --git a/linden/indra/llinventory/llinventory.h b/linden/indra/llinventory/llinventory.h index 34d9445..c573f74 100644 --- a/linden/indra/llinventory/llinventory.h +++ b/linden/indra/llinventory/llinventory.h @@ -253,6 +253,7 @@ public: void setDescription(const std::string& new_desc); void setSaleInfo(const LLSaleInfo& sale_info); void setPermissions(const LLPermissions& perm); + void setType(LLAssetType::EType type); void setInventoryType(LLInventoryType::EType inv_type); void setNInventoryType(LLInventoryType::NType inv_type); void setFlags(U32 flags); -- cgit v1.1