diff options
| author | Rye <rye@alchemyviewer.org> | 2025-10-24 01:38:56 -0400 |
|---|---|---|
| committer | Rye <rye@alchemyviewer.org> | 2025-10-27 04:59:14 -0400 |
| commit | 1727c4d26429dd256fb2cd90fa83085e976794cc (patch) | |
| tree | 532a24aa7e9bf659404f79c9d372c409b54a094e /indra/llappearanceutility/llbakingwearablesdata.cpp | |
| parent | f7da57ddda41a4671949566ba4d13fe12fa68922 (diff) | |
Reintroduce llappearanceutility to viewer tree from archive/develop
Signed-off-by: Rye <rye@alchemyviewer.org>
Diffstat (limited to 'indra/llappearanceutility/llbakingwearablesdata.cpp')
| -rw-r--r-- | indra/llappearanceutility/llbakingwearablesdata.cpp | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/indra/llappearanceutility/llbakingwearablesdata.cpp b/indra/llappearanceutility/llbakingwearablesdata.cpp new file mode 100644 index 0000000000..18edb86348 --- /dev/null +++ b/indra/llappearanceutility/llbakingwearablesdata.cpp @@ -0,0 +1,131 @@ +/** + * @file llbakingwearablesdata.cpp + * @brief Implementation of LLBakingWearablesData class + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + + +#include "linden_common.h" + +#include "llbakingwearablesdata.h" +#include "llbakingwearable.h" + +using namespace LLAvatarAppearanceDefines; + +LLBakingWearablesData::LLBakingWearablesData() +{ +} + +// virtual +LLBakingWearablesData::~LLBakingWearablesData() +{ + std::for_each(mWearables.begin(), mWearables.end(), DeletePointer()); + mWearables.clear(); +} + +void LLBakingWearablesData::setWearableOutfit(LLSD& sd) +{ + LLSD::array_const_iterator type_iter = sd.beginArray(); + LLSD::array_const_iterator type_end = sd.endArray(); + S32 wearable_index = 0; + for (; type_iter != type_end && wearable_index < (S32) LLWearableType::WT_COUNT; ++type_iter, ++wearable_index) + { + LLSD::array_const_iterator wearable_iter = type_iter->beginArray(); + LLSD::array_const_iterator wearable_end = type_iter->endArray(); + for (; wearable_iter != wearable_end; ++wearable_iter) + { + if ( wearable_iter->isDefined() ) + { + LLBakingWearable* wearable = new LLBakingWearable(); + std::istringstream istr( (*wearable_iter)["contents"].asString() ); + wearable->importStream(istr, mAvatarAppearance); + + // Sanity check the wearable type. + if (wearable->getType() != wearable_index) + { + LL_WARNS() << "Unexpected wearable type! Expected " << wearable_index + << ", processed " << (S32) wearable->getType() << LL_ENDL; + // *TODO: Throw exception? + delete wearable; + continue; + } + mWearables.push_back(wearable); + + const LLWearableType::EType type = wearable->getType(); + if (wearable->getAssetType() == LLAssetType::AT_BODYPART) + { + // exactly one wearable per body part + setWearable(type,0,wearable); + } + else + { + pushWearable(type,wearable); + } + } + } + } + + wearable_list_t::const_iterator wearable_iter = mWearables.begin(); + wearable_list_t::const_iterator wearable_end = mWearables.end(); + for (; wearable_iter != wearable_end; ++wearable_iter) + { + LLBakingWearable* wearable = (*wearable_iter); + const bool removed = false; + wearableUpdated(wearable, removed); + } + + for(wearable_index = 0; wearable_index < (S32) LLWearableType::WT_COUNT; wearable_index++) + { + LLWearable* top_wearable = getTopWearable((LLWearableType::EType)wearable_index); + if (top_wearable) + { + top_wearable->writeToAvatar(mAvatarAppearance); + } + } +} + + +void LLBakingWearablesData::asLLSD(LLSD& sd) const +{ + sd = LLSD::emptyMap(); + wearableentry_map_t::const_iterator type_iter = mWearableDatas.begin(); + wearableentry_map_t::const_iterator type_end = mWearableDatas.end(); + for (; type_iter != type_end; ++type_iter) + { + LLSD wearable_type_sd = LLSD::emptyArray(); + LLWearableType::EType wearable_type = type_iter->first; + wearableentry_vec_t::const_iterator wearable_iter = type_iter->second.begin(); + wearableentry_vec_t::const_iterator wearable_end = type_iter->second.end(); + for (; wearable_iter != wearable_end; ++wearable_iter) + { + const LLBakingWearable* wearable = dynamic_cast<LLBakingWearable*>(*wearable_iter); + LLSD wearable_sd; + wearable->asLLSD(wearable_sd); + wearable_type_sd.append(wearable_sd); + } + sd[LLWearableType::getInstance()->getTypeName(wearable_type)] = wearable_type_sd; + } +} + + + |
