summaryrefslogtreecommitdiff
path: root/indra/llprimitive/llmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llprimitive/llmodel.cpp')
-rwxr-xr-xindra/llprimitive/llmodel.cpp186
1 files changed, 93 insertions, 93 deletions
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 595f9aa307..4574100f32 100755
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -1909,99 +1909,99 @@ void LLModel::updateHullCenters()
mCenterOfHullCenters *= 1.f / mHullPoints;
}
-bool LLModel::loadModel(std::istream& is)
-{
- mSculptLevel = -1; // default is an error occured
-
- LLSD header;
- {
- if (!LLSDSerialize::fromBinary(header, is, 1024*1024*1024))
- {
- llwarns << "Mesh header parse error. Not a valid mesh asset!" << llendl;
- return false;
- }
- }
-
- std::string nm[] =
- {
- "lowest_lod",
- "low_lod",
- "medium_lod",
- "high_lod",
- "physics_shape",
- };
-
- const S32 MODEL_LODS = 5;
-
- S32 lod = llclamp((S32) mDetail, 0, MODEL_LODS);
-
- if (header[nm[lod]]["offset"].asInteger() == -1 ||
- header[nm[lod]]["size"].asInteger() == 0 )
- { //cannot load requested LOD
- return false;
- }
-
- bool has_skin = header["skin"]["offset"].asInteger() >=0 &&
- header["skin"]["size"].asInteger() > 0;
-
- if (lod == LLModel::LOD_HIGH)
- { //try to load skin info and decomp info
- std::ios::pos_type cur_pos = is.tellg();
- loadSkinInfo(header, is);
- is.seekg(cur_pos);
- }
-
- if (lod == LLModel::LOD_PHYSICS)
- {
- std::ios::pos_type cur_pos = is.tellg();
- loadDecomposition(header, is);
- is.seekg(cur_pos);
- }
-
- is.seekg(header[nm[lod]]["offset"].asInteger(), std::ios_base::cur);
-
- if (unpackVolumeFaces(is, header[nm[lod]]["size"].asInteger()))
- {
- if (has_skin)
- {
- //build out mSkinWeight from face info
- for (S32 i = 0; i < getNumVolumeFaces(); ++i)
- {
- const LLVolumeFace& face = getVolumeFace(i);
-
- if (face.mWeights)
- {
- for (S32 j = 0; j < face.mNumVertices; ++j)
- {
- LLVector4a& w = face.mWeights[j];
-
- std::vector<JointWeight> wght;
-
- for (S32 k = 0; k < 4; ++k)
- {
- S32 idx = (S32) w[k];
- F32 f = w[k] - idx;
- if (f > 0.f)
- {
- wght.push_back(JointWeight(idx, f));
- }
- }
-
- if (!wght.empty())
- {
- LLVector3 pos(face.mPositions[j].getF32ptr());
- mSkinWeights[pos] = wght;
- }
- }
- }
- }
- }
- return true;
- }
-
- return false;
-
-}
+bool LLModel::loadModel(std::istream& is)
+{
+ mSculptLevel = -1; // default is an error occured
+
+ LLSD header;
+ {
+ if (!LLSDSerialize::fromBinary(header, is, 1024*1024*1024))
+ {
+ llwarns << "Mesh header parse error. Not a valid mesh asset!" << llendl;
+ return false;
+ }
+ }
+
+ std::string nm[] =
+ {
+ "lowest_lod",
+ "low_lod",
+ "medium_lod",
+ "high_lod",
+ "physics_shape",
+ };
+
+ const S32 MODEL_LODS = 5;
+
+ S32 lod = llclamp((S32) mDetail, 0, MODEL_LODS);
+
+ if (header[nm[lod]]["offset"].asInteger() == -1 ||
+ header[nm[lod]]["size"].asInteger() == 0 )
+ { //cannot load requested LOD
+ return false;
+ }
+
+ bool has_skin = header["skin"]["offset"].asInteger() >=0 &&
+ header["skin"]["size"].asInteger() > 0;
+
+ if (lod == LLModel::LOD_HIGH)
+ { //try to load skin info and decomp info
+ std::ios::pos_type cur_pos = is.tellg();
+ loadSkinInfo(header, is);
+ is.seekg(cur_pos);
+ }
+
+ if (lod == LLModel::LOD_PHYSICS)
+ {
+ std::ios::pos_type cur_pos = is.tellg();
+ loadDecomposition(header, is);
+ is.seekg(cur_pos);
+ }
+
+ is.seekg(header[nm[lod]]["offset"].asInteger(), std::ios_base::cur);
+
+ if (unpackVolumeFaces(is, header[nm[lod]]["size"].asInteger()))
+ {
+ if (has_skin)
+ {
+ //build out mSkinWeight from face info
+ for (S32 i = 0; i < getNumVolumeFaces(); ++i)
+ {
+ const LLVolumeFace& face = getVolumeFace(i);
+
+ if (face.mWeights)
+ {
+ for (S32 j = 0; j < face.mNumVertices; ++j)
+ {
+ LLVector4a& w = face.mWeights[j];
+
+ std::vector<JointWeight> wght;
+
+ for (S32 k = 0; k < 4; ++k)
+ {
+ S32 idx = (S32) w[k];
+ F32 f = w[k] - idx;
+ if (f > 0.f)
+ {
+ wght.push_back(JointWeight(idx, f));
+ }
+ }
+
+ if (!wght.empty())
+ {
+ LLVector3 pos(face.mPositions[j].getF32ptr());
+ mSkinWeights[pos] = wght;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ return false;
+
+}
bool LLModel::loadSkinInfo(LLSD& header, std::istream &is)