PageRenderTime 69ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llfloateravatartextures.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 201 lines | 156 code | 17 blank | 28 comment | 26 complexity | 7f37b7f48b795beb69285ac64cdc632d MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llfloateravatartextures.cpp
  3. * @brief Debugging view showing underlying avatar textures and baked textures.
  4. *
  5. * $LicenseInfo:firstyear=2006&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llfloateravatartextures.h"
  28. // library headers
  29. #include "llavatarnamecache.h"
  30. #include "llagent.h"
  31. #include "llagentwearables.h"
  32. #include "lltexturectrl.h"
  33. #include "lluictrlfactory.h"
  34. #include "llviewerobjectlist.h"
  35. #include "llvoavatarself.h"
  36. using namespace LLVOAvatarDefines;
  37. LLFloaterAvatarTextures::LLFloaterAvatarTextures(const LLSD& id)
  38. : LLFloater(id),
  39. mID(id.asUUID())
  40. {
  41. }
  42. LLFloaterAvatarTextures::~LLFloaterAvatarTextures()
  43. {
  44. }
  45. BOOL LLFloaterAvatarTextures::postBuild()
  46. {
  47. for (U32 i=0; i < TEX_NUM_INDICES; i++)
  48. {
  49. const std::string tex_name = LLVOAvatarDictionary::getInstance()->getTexture(ETextureIndex(i))->mName;
  50. mTextures[i] = getChild<LLTextureCtrl>(tex_name);
  51. }
  52. mTitle = getTitle();
  53. childSetAction("Dump", onClickDump, this);
  54. refresh();
  55. return TRUE;
  56. }
  57. void LLFloaterAvatarTextures::draw()
  58. {
  59. refresh();
  60. LLFloater::draw();
  61. }
  62. static void update_texture_ctrl(LLVOAvatar* avatarp,
  63. LLTextureCtrl* ctrl,
  64. ETextureIndex te)
  65. {
  66. LLUUID id = IMG_DEFAULT_AVATAR;
  67. const LLVOAvatarDictionary::TextureEntry* tex_entry = LLVOAvatarDictionary::getInstance()->getTexture(te);
  68. if (tex_entry->mIsLocalTexture)
  69. {
  70. if (avatarp->isSelf())
  71. {
  72. const LLWearableType::EType wearable_type = tex_entry->mWearableType;
  73. LLWearable *wearable = gAgentWearables.getWearable(wearable_type, 0);
  74. if (wearable)
  75. {
  76. LLLocalTextureObject *lto = wearable->getLocalTextureObject(te);
  77. if (lto)
  78. {
  79. id = lto->getID();
  80. }
  81. }
  82. }
  83. }
  84. else
  85. {
  86. id = avatarp->getTE(te)->getID();
  87. }
  88. //id = avatarp->getTE(te)->getID();
  89. if (id == IMG_DEFAULT_AVATAR)
  90. {
  91. ctrl->setImageAssetID(LLUUID::null);
  92. ctrl->setToolTip(tex_entry->mName + " : " + std::string("IMG_DEFAULT_AVATAR"));
  93. }
  94. else
  95. {
  96. ctrl->setImageAssetID(id);
  97. ctrl->setToolTip(tex_entry->mName + " : " + id.asString());
  98. }
  99. }
  100. static LLVOAvatar* find_avatar(const LLUUID& id)
  101. {
  102. LLViewerObject *obj = gObjectList.findObject(id);
  103. while (obj && obj->isAttachment())
  104. {
  105. obj = (LLViewerObject *)obj->getParent();
  106. }
  107. if (obj && obj->isAvatar())
  108. {
  109. return (LLVOAvatar*)obj;
  110. }
  111. else
  112. {
  113. return NULL;
  114. }
  115. }
  116. void LLFloaterAvatarTextures::refresh()
  117. {
  118. if (gAgent.isGodlike())
  119. {
  120. LLVOAvatar *avatarp = find_avatar(mID);
  121. if (avatarp)
  122. {
  123. LLAvatarName av_name;
  124. if (LLAvatarNameCache::get(avatarp->getID(), &av_name))
  125. {
  126. setTitle(mTitle + ": " + av_name.getCompleteName());
  127. }
  128. for (U32 i=0; i < TEX_NUM_INDICES; i++)
  129. {
  130. update_texture_ctrl(avatarp, mTextures[i], ETextureIndex(i));
  131. }
  132. }
  133. else
  134. {
  135. setTitle(mTitle + ": " + getString("InvalidAvatar") + " (" + mID.asString() + ")");
  136. }
  137. }
  138. }
  139. // static
  140. void LLFloaterAvatarTextures::onClickDump(void* data)
  141. {
  142. if (gAgent.isGodlike())
  143. {
  144. const LLVOAvatarSelf* avatarp = gAgentAvatarp;
  145. if (!avatarp) return;
  146. for (S32 i = 0; i < avatarp->getNumTEs(); i++)
  147. {
  148. const LLTextureEntry* te = avatarp->getTE(i);
  149. if (!te) continue;
  150. const LLVOAvatarDictionary::TextureEntry* tex_entry = LLVOAvatarDictionary::getInstance()->getTexture((ETextureIndex)(i));
  151. if (!tex_entry)
  152. continue;
  153. if (LLVOAvatar::isIndexLocalTexture((ETextureIndex)i))
  154. {
  155. LLUUID id = IMG_DEFAULT_AVATAR;
  156. LLWearableType::EType wearable_type = LLVOAvatarDictionary::getInstance()->getTEWearableType((ETextureIndex)i);
  157. if (avatarp->isSelf())
  158. {
  159. LLWearable *wearable = gAgentWearables.getWearable(wearable_type, 0);
  160. if (wearable)
  161. {
  162. LLLocalTextureObject *lto = wearable->getLocalTextureObject(i);
  163. if (lto)
  164. {
  165. id = lto->getID();
  166. }
  167. }
  168. }
  169. if (id != IMG_DEFAULT_AVATAR)
  170. {
  171. llinfos << "TE " << i << " name:" << tex_entry->mName << " id:" << id << llendl;
  172. }
  173. else
  174. {
  175. llinfos << "TE " << i << " name:" << tex_entry->mName << " id:" << "<DEFAULT>" << llendl;
  176. }
  177. }
  178. else
  179. {
  180. llinfos << "TE " << i << " name:" << tex_entry->mName << " id:" << te->getID() << llendl;
  181. }
  182. }
  183. }
  184. }