diff options
Diffstat (limited to 'indra/newview/llvoavatardefines.h')
-rw-r--r-- | indra/newview/llvoavatardefines.h | 183 |
1 files changed, 104 insertions, 79 deletions
diff --git a/indra/newview/llvoavatardefines.h b/indra/newview/llvoavatardefines.h index bc1a1f1c1f..cf3d318159 100644 --- a/indra/newview/llvoavatardefines.h +++ b/indra/newview/llvoavatardefines.h @@ -5,7 +5,7 @@ * * $LicenseInfo:firstyear=2001&license=viewergpl$ * - * Copyright (c) 2001-2007, Linden Research, Inc. + * Copyright (c) 2001-2009, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -13,12 +13,13 @@ * ("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://secondlife.com/developers/opensource/gplv2 + * 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://secondlife.com/developers/opensource/flossexception + * 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, @@ -36,6 +37,7 @@ #include <vector> #include "llwearable.h" #include "llviewerjoint.h" +#include "lldictionary.h" namespace LLVOAvatarDefines { @@ -45,7 +47,7 @@ extern const S32 SCRATCH_TEX_HEIGHT; extern const S32 IMPOSTOR_PERIOD; //-------------------------------------------------------------------- -// texture entry assignment +// Enums //-------------------------------------------------------------------- enum ETextureIndex { @@ -57,9 +59,9 @@ enum ETextureIndex TEX_UPPER_BODYPAINT, TEX_LOWER_BODYPAINT, TEX_LOWER_SHOES, - TEX_HEAD_BAKED, // Pre-composited - TEX_UPPER_BAKED, // Pre-composited - TEX_LOWER_BAKED, // Pre-composited + TEX_HEAD_BAKED, // Pre-composited + TEX_UPPER_BAKED, // Pre-composited + TEX_LOWER_BAKED, // Pre-composited TEX_EYES_BAKED, // Pre-composited TEX_LOWER_SOCKS, TEX_UPPER_JACKET, @@ -68,14 +70,19 @@ enum ETextureIndex TEX_UPPER_UNDERSHIRT, TEX_LOWER_UNDERPANTS, TEX_SKIRT, - TEX_SKIRT_BAKED, // Pre-composited + TEX_SKIRT_BAKED, // Pre-composited TEX_HAIR_BAKED, // Pre-composited + TEX_LOWER_ALPHA, + TEX_UPPER_ALPHA, + TEX_HEAD_ALPHA, + TEX_EYES_ALPHA, + TEX_HAIR_ALPHA, + TEX_HEAD_TATTOO, + TEX_UPPER_TATTOO, + TEX_LOWER_TATTOO, TEX_NUM_INDICES -}; // "Note: if TEX_NUM_ENTRIES changes, update AGENT_TEXTURES in llagentinfo.h, mTextureIndexBaked, and BAKED_TEXTURE_COUNT" -// Seraph - Above comment about order is probably obsolete. +}; -typedef std::vector<ETextureIndex> texture_vec_t; - enum EBakedTextureIndex { BAKED_HEAD = 0, @@ -86,7 +93,6 @@ enum EBakedTextureIndex BAKED_HAIR, BAKED_NUM_INDICES }; -typedef std::vector<EBakedTextureIndex> bakedtexture_vec_t; // Reference IDs for each mesh. Used as indices for vector of joints enum EMeshIndex @@ -101,19 +107,15 @@ enum EMeshIndex MESH_ID_SKIRT, MESH_ID_NUM_INDICES }; -typedef std::vector<EMeshIndex> mesh_vec_t; +//-------------------------------------------------------------------- +// Vector Types +//-------------------------------------------------------------------- +typedef std::vector<ETextureIndex> texture_vec_t; +typedef std::vector<EBakedTextureIndex> bakedtexture_vec_t; +typedef std::vector<EMeshIndex> mesh_vec_t; typedef std::vector<EWearableType> wearables_vec_t; -//-------------------------------------------------------------------------------- -// Convenience Functions -//-------------------------------------------------------------------------------- - -// Convert from baked texture to associated texture; e.g. BAKED_HEAD -> TEX_HEAD_BAKED -ETextureIndex getTextureIndex(EBakedTextureIndex t); - - - //------------------------------------------------------------------------ // LLVOAvatarDictionary // @@ -124,86 +126,109 @@ ETextureIndex getTextureIndex(EBakedTextureIndex t); //------------------------------------------------------------------------ class LLVOAvatarDictionary : public LLSingleton<LLVOAvatarDictionary> { + //-------------------------------------------------------------------- + // Constructors and Destructors + //-------------------------------------------------------------------- public: LLVOAvatarDictionary(); virtual ~LLVOAvatarDictionary(); +private: + void createAssociations(); - struct TextureDictionaryEntry + //-------------------------------------------------------------------- + // Local and baked textures + //-------------------------------------------------------------------- +public: + struct TextureEntry : public LLDictionaryEntry { - TextureDictionaryEntry(const std::string &name, - bool is_local_texture, - EBakedTextureIndex baked_texture_index = BAKED_NUM_INDICES, - const std::string &default_image_name = "", - EWearableType wearable_type = WT_INVALID); - const std::string mName; - const std::string mDefaultImageName; + TextureEntry(const std::string &name, // this must match the xml name used by LLTexLayerInfo::parseXml + bool is_local_texture, + EBakedTextureIndex baked_texture_index = BAKED_NUM_INDICES, + const std::string& default_image_name = "", + EWearableType wearable_type = WT_INVALID); + const std::string mDefaultImageName; const EWearableType mWearableType; // It's either a local texture xor baked - BOOL mIsLocalTexture; - BOOL mIsBakedTexture; + BOOL mIsLocalTexture; + BOOL mIsBakedTexture; // If it's a local texture, it may be used by a baked texture - BOOL mIsUsedByBakedTexture; - EBakedTextureIndex mBakedTextureIndex; + BOOL mIsUsedByBakedTexture; + EBakedTextureIndex mBakedTextureIndex; }; + + struct Textures : public LLDictionary<ETextureIndex, TextureEntry> + { + Textures(); + } mTextures; + const TextureEntry* getTexture(ETextureIndex index) const { return mTextures.lookup(index); } + const Textures& getTextures() const { return mTextures; } - struct MeshDictionaryEntry + //-------------------------------------------------------------------- + // Meshes + //-------------------------------------------------------------------- +public: + struct MeshEntry : public LLDictionaryEntry { - MeshDictionaryEntry(EBakedTextureIndex baked_index, - const std::string &name, - U8 level, - LLViewerJoint::PickName pick); - const std::string mName; // names of mesh types as they are used in avatar_lad.xml + MeshEntry(EBakedTextureIndex baked_index, + const std::string &name, // names of mesh types as they are used in avatar_lad.xml + U8 level, + LLViewerJoint::PickName pick); // Levels of Detail for each mesh. Must match levels of detail present in avatar_lad.xml // Otherwise meshes will be unable to be found, or levels of detail will be ignored - const U8 mLOD; - const EBakedTextureIndex mBakedID; - const LLViewerJoint::PickName mPickName; + const U8 mLOD; + const EBakedTextureIndex mBakedID; + const LLViewerJoint::PickName mPickName; }; - struct BakedDictionaryEntry + struct Meshes : public LLDictionary<EMeshIndex, MeshEntry> { - BakedDictionaryEntry(ETextureIndex tex_index, - const std::string &name, - U32 num_local_textures, ... ); - const ETextureIndex mTextureIndex; - const std::string mName; - texture_vec_t mLocalTextures; - }; - - struct WearableDictionaryEntry + Meshes(); + } mMeshes; + const MeshEntry* getMesh(EMeshIndex index) const { return mMeshes.lookup(index); } + const Meshes& getMeshes() const { return mMeshes; } + + //-------------------------------------------------------------------- + // Baked Textures + //-------------------------------------------------------------------- +public: + struct BakedEntry : public LLDictionaryEntry { - WearableDictionaryEntry(const std::string &hash_name, - U32 num_wearables, ... ); - const LLUUID mHashID; - wearables_vec_t mWearablesVec; + BakedEntry(ETextureIndex tex_index, + const std::string &name, // unused, but necessary for templating. + const std::string &hash_name, + U32 num_local_textures, ... ); // # local textures, local texture list, # wearables, wearable list + // Local Textures + const ETextureIndex mTextureIndex; + texture_vec_t mLocalTextures; + // Wearables + const LLUUID mWearablesHashID; + wearables_vec_t mWearables; }; - typedef std::map<EBakedTextureIndex, BakedDictionaryEntry*> baked_map_t; - typedef std::map<ETextureIndex, TextureDictionaryEntry*> texture_map_t; - typedef std::map<EMeshIndex, MeshDictionaryEntry*> mesh_map_t; - typedef std::map<EBakedTextureIndex, WearableDictionaryEntry*> wearable_map_t; + struct BakedTextures: public LLDictionary<EBakedTextureIndex, BakedEntry> + { + BakedTextures(); + } mBakedTextures; + const BakedEntry* getBakedTexture(EBakedTextureIndex index) const { return mBakedTextures.lookup(index); } + const BakedTextures& getBakedTextures() const { return mBakedTextures; } + + //-------------------------------------------------------------------- + // Convenience Functions + //-------------------------------------------------------------------- +public: + // Convert from baked texture to associated texture; e.g. BAKED_HEAD -> TEX_HEAD_BAKED + static ETextureIndex bakedToLocalTextureIndex(EBakedTextureIndex t); - const MeshDictionaryEntry *getMesh(EMeshIndex index) const; - const BakedDictionaryEntry *getBakedTexture(EBakedTextureIndex index) const; - const TextureDictionaryEntry *getTexture(ETextureIndex index) const; - const WearableDictionaryEntry *getWearable(EBakedTextureIndex index) const; + // find a baked texture index based on its name + static EBakedTextureIndex findBakedByRegionName(std::string name); - const texture_map_t &getTextures() const { return mTextureMap; } - const baked_map_t &getBakedTextures() const { return mBakedTextureMap; } - const mesh_map_t &getMeshes() const { return mMeshMap; } - const wearable_map_t &getWearables() const { return mWearableMap; } - -private: - void initData(); - void createAssociations(); + static const LLUUID getDefaultTextureImageID(ETextureIndex index); - texture_map_t mTextureMap; - baked_map_t mBakedTextureMap; - mesh_map_t mMeshMap; - wearable_map_t mWearableMap; + // Given a texture entry, determine which wearable type owns it. + static EWearableType getTEWearableType(ETextureIndex index); }; // End LLVOAvatarDictionary } // End namespace LLVOAvatarDefines -#endif +#endif //LL_VO_AVATARDEFINES_H |