diff options
author | Jonathan Wolk <none@none> | 2010-10-19 11:29:42 -0700 |
---|---|---|
committer | Jonathan Wolk <none@none> | 2010-10-19 11:29:42 -0700 |
commit | 256c6e6a252feaa7ae50f81778aab1e0246a526a (patch) | |
tree | ef1982449f3942fe6a5504b5e18536e21644e7e5 /indra/llprimitive | |
parent | a045261002963fce7a719c9bcffee396aef821ca (diff) |
Moved retry logic for certain mesh header fetches to help with SH-323 'Some mesh objects fail to load data for valid meshes'. Renamed some variables to be more clear.
Diffstat (limited to 'indra/llprimitive')
-rw-r--r-- | indra/llprimitive/llmodel.cpp | 113 | ||||
-rw-r--r-- | indra/llprimitive/llmodel.h | 76 |
2 files changed, 143 insertions, 46 deletions
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 7ae472ce82..7fa72d82e1 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -950,13 +950,14 @@ void LLModel::setNumVolumeFaces(S32 count) mVolumeFaces.resize(count); } -void LLModel::setVolumeFaceData(S32 f, - LLStrider<LLVector3> pos, - LLStrider<LLVector3> norm, - LLStrider<LLVector2> tc, - LLStrider<U16> ind, - U32 num_verts, - U32 num_indices) +void LLModel::setVolumeFaceData( + S32 f, + LLStrider<LLVector3> pos, + LLStrider<LLVector3> norm, + LLStrider<LLVector2> tc, + LLStrider<U16> ind, + U32 num_verts, + U32 num_indices) { LLVolumeFace& face = mVolumeFaces[f]; @@ -1283,18 +1284,63 @@ LLModel* LLModel::loadModelFromDomMesh(domMesh *mesh) } //static -LLSD LLModel::writeModel(std::string filename, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* impostor, LLModel::physics_shape& decomp, bool upload_skin, bool upload_joints, bool nowrite) +LLSD LLModel::writeModel( + std::string filename, + LLModel* physics, + LLModel* high, + LLModel* medium, + LLModel* low, + LLModel* impostor, + const convex_hull_decomposition& decomp, + BOOL upload_skin, + BOOL upload_joints, + BOOL nowrite) { LLModel::hull dummy_hull; - return writeModel(filename, physics, high, medium, low, impostor, decomp, dummy_hull, upload_skin, upload_joints, nowrite); + return writeModel( + filename, + physics, + high, + medium, + low, + impostor, + decomp, + dummy_hull, + upload_skin, + upload_joints, + nowrite); } //static -LLSD LLModel::writeModel(std::string filename, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* impostor, LLModel::physics_shape& decomp, LLModel::hull& base_hull, bool upload_skin, bool upload_joints, bool nowrite) +LLSD LLModel::writeModel( + std::string filename, + LLModel* physics, + LLModel* high, + LLModel* medium, + LLModel* low, + LLModel* impostor, + const convex_hull_decomposition& decomp, + const hull& base_hull, + BOOL upload_skin, + BOOL upload_joints, + BOOL nowrite) { - std::ofstream os(filename.c_str(), std::ofstream::out | std::ofstream::binary); + std::ofstream os( + filename.c_str(), + std::ofstream::out | std::ofstream::binary); - LLSD header = writeModel(os, physics, high, medium, low, impostor, decomp, base_hull, upload_skin, upload_joints, nowrite); + LLSD header = writeModel( + os, + physics, + high, + medium, + low, + impostor, + decomp, + base_hull, + upload_skin, + upload_joints, + nowrite); os.close(); @@ -1302,7 +1348,18 @@ LLSD LLModel::writeModel(std::string filename, LLModel* physics, LLModel* high, } //static -LLSD LLModel::writeModel(std::ostream& ostr, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* impostor, LLModel::physics_shape& decomp, LLModel::hull& base_hull, bool upload_skin, bool upload_joints, bool nowrite) +LLSD LLModel::writeModel( + std::ostream& ostr, + LLModel* physics, + LLModel* high, + LLModel* medium, + LLModel* low, + LLModel* impostor, + const convex_hull_decomposition& decomp, + const hull& base_hull, + BOOL upload_skin, + BOOL upload_joints, + BOOL nowrite) { LLSD mdl; @@ -1392,12 +1449,15 @@ LLSD LLModel::writeModel(std::ostream& ostr, LLModel* physics, LLModel* high, LL { U32 size = decomp[i].size(); total += size; - hulls[i] = (U8) size; + // The valid range of sizes is actually 3-256 verts. We need this to fit into a U8, + // So we just subtract 1 + hulls[i] = (U8) (size - 1); for (U32 j = 0; j < decomp[i].size(); ++j) { update_min_max(min, max, decomp[i][j]); } + } for (U32 i = 0; i < base_hull.size(); ++i) @@ -1779,29 +1839,30 @@ LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos) } } -void LLModel::setPhysicsShape(const LLModel::physics_shape& shape) +void LLModel::setConvexHullDecomposition( + const LLModel::convex_hull_decomposition& decomp) { - mPhysicsShape = shape; + mConvexHullDecomp = decomp; - mHullCenter.resize(mPhysicsShape.size()); - mPhysicsPoints = 0; - mPhysicsCenter.clear(); + mHullCenter.resize(mConvexHullDecomp.size()); + mHullPoints = 0; + mCenterOfHullCenters.clear(); - for (U32 i = 0; i < shape.size(); ++i) + for (U32 i = 0; i < decomp.size(); ++i) { LLVector3 cur_center; - for (U32 j = 0; j < shape[i].size(); ++j) + for (U32 j = 0; j < decomp[i].size(); ++j) { - cur_center += shape[i][j]; + cur_center += decomp[i][j]; } - mPhysicsCenter += cur_center; - cur_center *= 1.f/shape[i].size(); + mCenterOfHullCenters += cur_center; + cur_center *= 1.f/decomp[i].size(); mHullCenter[i] = cur_center; - mPhysicsPoints += shape[i].size(); + mHullPoints += decomp[i].size(); } - mPhysicsCenter *= 1.f/mPhysicsPoints; + mCenterOfHullCenters *= 1.f / mHullPoints; } diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index c95ffd882d..b45bca626a 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -50,16 +50,52 @@ public: NUM_LODS }; - //physics shape is a vector of convex hulls + //convex_hull_decomposition is a vector of convex hulls //each convex hull is a set of points + typedef std::vector<std::vector<LLVector3> > convex_hull_decomposition; typedef std::vector<LLVector3> hull; - typedef std::vector<hull> physics_shape; LLModel(LLVolumeParams& params, F32 detail); - static LLSD writeModel(std::string filename, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* imposotr, LLModel::physics_shape& physics_shape, bool upload_skin, bool upload_joints, bool nowrite = FALSE); - static LLSD writeModel(std::string filename, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* imposotr, LLModel::physics_shape& physics_shape, LLModel::hull& base_hull, bool upload_skin, bool upload_joints, bool nowrite = FALSE); - static LLSD writeModel(std::ostream& ostr, LLModel* physics, LLModel* high, LLModel* medium, LLModel* low, LLModel* imposotr, LLModel::physics_shape& physics_shape, LLModel::hull& base_hull, bool upload_skin, bool upload_joints, bool nowrite = FALSE); - static LLSD writeModelToStream(std::ostream& ostr, LLSD& mdl, BOOL nowrite = FALSE); + static LLSD writeModel( + std::string filename, + LLModel* physics, + LLModel* high, + LLModel* medium, + LLModel* low, + LLModel* imposotr, + const LLModel::convex_hull_decomposition& convex_hull_decomposition, + const LLModel::hull& base_hull, + BOOL upload_skin, + BOOL upload_joints, + BOOL nowrite = FALSE); + static LLSD writeModel( + std::string filename, + LLModel* physics, + LLModel* high, + LLModel* medium, + LLModel* low, + LLModel* imposotr, + const LLModel::convex_hull_decomposition& convex_hull_decomposition, + BOOL upload_skin, + BOOL upload_joints, + BOOL nowrite = FALSE); + static LLSD writeModel( + std::ostream& ostr, + LLModel* physics, + LLModel* high, + LLModel* medium, + LLModel* low, + LLModel* imposotr, + const LLModel::convex_hull_decomposition& convex_hull_decomposition, + const LLModel::hull& base_hull, + BOOL upload_skin, + BOOL upload_joints, + BOOL nowrite = FALSE); + static LLSD writeModelToStream( + std::ostream& ostr, + LLSD& mdl, + BOOL nowrite = FALSE); + static LLModel* loadModelFromAsset(std::string filename, S32 lod); static LLModel* loadModelFromDae(std::string filename); static LLModel* loadModelFromDomMesh(domMesh* mesh); @@ -69,13 +105,14 @@ public: void appendFace(const LLVolumeFace& src_face, std::string src_material, LLMatrix4& mat, LLMatrix4& norm_mat); void setNumVolumeFaces(S32 count); - void setVolumeFaceData(S32 f, - LLStrider<LLVector3> pos, - LLStrider<LLVector3> norm, - LLStrider<LLVector2> tc, - LLStrider<U16> ind, - U32 num_verts, - U32 num_indices); + void setVolumeFaceData( + S32 f, + LLStrider<LLVector3> pos, + LLStrider<LLVector3> norm, + LLStrider<LLVector2> tc, + LLStrider<U16> ind, + U32 num_verts, + U32 num_indices); void smoothNormals(F32 angle_cutoff); @@ -84,8 +121,6 @@ public: void normalizeVolumeFaces(); void optimizeVolumeFaces(); - - U32 getResourceCost(); void getNormalizedScaleTranslation(LLVector3& scale_out, LLVector3& translation_out); std::vector<std::string> mMaterialList; @@ -155,13 +190,14 @@ public: LLVector3 mNormalizedScale; LLVector3 mNormalizedTranslation; - //physics shape - physics_shape mPhysicsShape; - void setPhysicsShape(const physics_shape& shape); + // convex hull decomposition + convex_hull_decomposition mConvexHullDecomp; + void setConvexHullDecomposition( + const convex_hull_decomposition& decomp); - LLVector3 mPhysicsCenter; + LLVector3 mCenterOfHullCenters; std::vector<LLVector3> mHullCenter; - U32 mPhysicsPoints; + U32 mHullPoints; protected: void addVolumeFacesFromDomMesh(domMesh* mesh); |