diff options
| author | Andrey Lihatskiy <118752495+marchcat@users.noreply.github.com> | 2025-12-04 00:30:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-04 00:30:33 +0200 |
| commit | 8c134d5a4a9f08a87104530fe910bc39434cacf2 (patch) | |
| tree | dad5ddf6daf7f5e1bc7b47cd670a99ca73d4c5a1 /indra/llappearanceutility/llprocessskin.cpp | |
| parent | 2c3ce8fb8ce3967d957e13d48627b45dd32f0e00 (diff) | |
| parent | 590f58dbad3dc3db3482dba86bf2619a87a7dad5 (diff) | |
Merge pull request #5020 from secondlife/marchcat/slua-linux
develop-linux → SLua PV merge
Diffstat (limited to 'indra/llappearanceutility/llprocessskin.cpp')
| -rw-r--r-- | indra/llappearanceutility/llprocessskin.cpp | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/indra/llappearanceutility/llprocessskin.cpp b/indra/llappearanceutility/llprocessskin.cpp new file mode 100644 index 0000000000..a3d4d3c6f3 --- /dev/null +++ b/indra/llappearanceutility/llprocessskin.cpp @@ -0,0 +1,118 @@ +/** + * @file llprocessskin.cpp + * @brief Implementation of LLProcesSkin 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$ + */ + +// linden includes +#include "linden_common.h" + +#include "llsd.h" +#include "llsdserialize.h" +#include "llsdutil.h" +#include "llsdutil_math.h" +#include "llstl.h" +#include "llmath.h" +#include "m4math.h" +#include "v4math.h" + +// project includes +#include "llappappearanceutility.h" +#include "llprocessskin.h" + +void LLProcessSkin::process(std::ostream& output) +{ + const LLSD& dataBlock = mInputData; + LLSD skinData = LLSD::emptyMap(); + + LLSD::map_const_iterator skinIter = dataBlock.beginMap(); + LLSD::map_const_iterator skinIterEnd = dataBlock.endMap(); + + for ( ; skinIter!=skinIterEnd; ++skinIter ) + { + const LLSD& skin = skinIter->second; + if ( !skin.has("joint_names") || !skin.has("alt_inverse_bind_matrix") ) + { + throw LLAppException(RV_INVALID_SKIN_BLOCK); + } + + LLSD entry = LLSD::emptyMap(); + + //get all joint names from the skin + { + entry["joint_names"] = LLSD::emptyArray(); + LLSD& joint_names = entry["joint_names"]; + LLSD::array_const_iterator iter(skin["joint_names"].beginArray()); + LLSD::array_const_iterator iter_end(skin["joint_names"].endArray()); + for ( ; iter != iter_end; ++iter ) + { + LL_DEBUGS() << "joint: " << iter->asString() << LL_ENDL; + joint_names.append(*iter); + } + } + //get at the translational component for the joint offsets + { + entry["joint_offset"] = LLSD::emptyArray(); + LLSD& joint_offsets = entry["joint_offset"]; + LLSD::array_const_iterator iter(skin["alt_inverse_bind_matrix"].beginArray()); + LLSD::array_const_iterator iter_end(skin["alt_inverse_bind_matrix"].endArray()); + //just get at the translational component + for ( ; iter != iter_end; ++iter ) + { + LLMatrix4 mat; + for (U32 j = 0; j < 4; j++) + { + for (U32 k = 0; k < 4; k++) + { + mat.mMatrix[j][k] = static_cast<F32>((*iter)[j*4+k].asReal()); + } + } + joint_offsets.append( ll_sd_from_vector3( mat.getTranslation() )); + LL_DEBUGS() << "offset: [" << mat.getTranslation()[0] << " " + << mat.getTranslation()[1] << " " + << mat.getTranslation()[2] << " ]" << LL_ENDL; + } + } + + //get at the *optional* pelvis offset + if (skin.has("pelvis_offset")) + { + entry["pelvis_offset"] = skin["pelvis_offset"]; + } + else + { + entry["pelvis_offset"] = LLSD::Real(0.f); + } + + //add block to outgoing result llsd + skinData[skinIter->first] = entry; + } + + //dump the result llsd into the outgoing output + LLSD result; + result["success"] = true; + result["skindata"] = skinData; + LL_DEBUGS() << "---------------------------\n" << result << LL_ENDL; + output << LLSDOStreamer<LLSDXMLFormatter>(result); +} + |
