From 2ea8df0593d520b86bcf958263622218f76ac113 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 26 Aug 2015 10:49:02 -0400 Subject: SL-205 WIP - support for 152-joint rigged meshes with both hardware and software skinning. --- indra/llprimitive/llmodel.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index ed903146ef..7290fa5f83 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1762,6 +1762,7 @@ LLSD LLModel::writeModel( S32 count = 0; for (weight_list::iterator iter = weights.begin(); iter != weights.end(); ++iter) { + // BENTO JOINT COUNT LIMIT 255? if (iter->mJointIdx < 255 && iter->mJointIdx >= 0) { U8 idx = (U8) iter->mJointIdx; -- cgit v1.2.3 From 7b410df303d37a800ddd0024932729a574a00860 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 25 Nov 2015 15:07:26 -0500 Subject: SL-124 WIP - cleanup of comments and test code before going to project viewer. --- indra/llprimitive/llmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 72b5ca77dd..adf392fa21 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -867,7 +867,7 @@ LLSD LLModel::writeModel( S32 count = 0; for (weight_list::iterator iter = weights.begin(); iter != weights.end(); ++iter) { - // BENTO JOINT COUNT LIMIT 255? + // Note joint index cannot exceed 255. if (iter->mJointIdx < 255 && iter->mJointIdx >= 0) { U8 idx = (U8) iter->mJointIdx; -- cgit v1.2.3 From b138ca8aeec421f6e5b1412e7c7fbcefd87570d0 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 6 Apr 2016 16:12:39 -0400 Subject: SL-366 - more cases where skinned weights can go awry, and a bunch more asserts to verify. --- indra/llprimitive/llmodel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index adf392fa21..398f0997f3 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1001,7 +1001,7 @@ LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, BOOL nowrite, BO LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos) { - //1. If a vertex has been weighted then we'll find it via pos and return it's weight list + //1. If a vertex has been weighted then we'll find it via pos and return its weight list weight_map::iterator iterPos = mSkinWeights.begin(); weight_map::iterator iterEnd = mSkinWeights.end(); @@ -1224,7 +1224,6 @@ bool LLModel::loadModel(std::istream& is) } return false; - } bool LLModel::isMaterialListSubset( LLModel* ref ) -- cgit v1.2.3 From 34ced1aa2cc286db26e2866cfc7a53ef72d828a4 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 2 Sep 2016 16:44:57 -0400 Subject: SL-395 - partial support for joint scale locking via flag in skin info --- indra/llprimitive/llmodel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 398f0997f3..cd9e5cfa54 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -50,8 +50,12 @@ std::string model_names[] = const int MODEL_NAMES_LENGTH = sizeof(model_names) / sizeof(std::string); LLModel::LLModel(LLVolumeParams& params, F32 detail) - : LLVolume(params, detail), mNormalizedScale(1,1,1), mNormalizedTranslation(0,0,0) - , mPelvisOffset( 0.0f ), mStatus(NO_ERRORS), mSubmodelID(0) + : LLVolume(params, detail), + mNormalizedScale(1,1,1), + mNormalizedTranslation(0,0,0), + mPelvisOffset( 0.0f ), + mStatus(NO_ERRORS), + mSubmodelID(0) { mDecompID = -1; mLocalID = -1; @@ -1446,6 +1450,9 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin) { mPelvisOffset = skin["pelvis_offset"].asReal(); } + + // FIXME BENTO check contents of asset. + mLockScaleIfJointPosition = true; } LLSD LLMeshSkinInfo::asLLSD(bool include_joints) const -- cgit v1.2.3 From 6c46b3caf20af1a2987c0ca4ed0bf8e6ebe80fb4 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Tue, 6 Sep 2016 16:32:41 -0400 Subject: SL-395 - can enable/disable scale lock in mesh upload UI. Feature works. --- indra/llprimitive/llmodel.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index cd9e5cfa54..6637f41966 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -671,6 +671,7 @@ LLSD LLModel::writeModel( const LLModel::Decomposition& decomp, BOOL upload_skin, BOOL upload_joints, + BOOL lock_scale_if_joint_position, BOOL nowrite, BOOL as_slm, int submodel_id) @@ -690,7 +691,7 @@ LLSD LLModel::writeModel( if (skinning) { //write skinning block - mdl["skin"] = high->mSkinInfo.asLLSD(upload_joints); + mdl["skin"] = high->mSkinInfo.asLLSD(upload_joints, lock_scale_if_joint_position); } if (!decomp.mBaseHull.empty() || @@ -1451,11 +1452,17 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin) mPelvisOffset = skin["pelvis_offset"].asReal(); } - // FIXME BENTO check contents of asset. - mLockScaleIfJointPosition = true; + if (skin.has("lock_scale_if_joint_position")) + { + mLockScaleIfJointPosition = skin["lock_scale_if_joint_position"].asBoolean(); + } + else + { + mLockScaleIfJointPosition = false; + } } -LLSD LLMeshSkinInfo::asLLSD(bool include_joints) const +LLSD LLMeshSkinInfo::asLLSD(bool include_joints, bool lock_scale_if_joint_position) const { LLSD ret; @@ -1493,6 +1500,11 @@ LLSD LLMeshSkinInfo::asLLSD(bool include_joints) const } } + if (lock_scale_if_joint_position) + { + ret["lock_scale_if_joint_position"] = mLockScaleIfJointPosition; + } + ret["pelvis_offset"] = mPelvisOffset; } -- cgit v1.2.3 From e6297ab3d6262014d3b501703154437bea523be1 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Tue, 27 Sep 2016 17:29:22 -0400 Subject: SL-451 - support for getJoint() by number, use in initSkinningMatrixPalette() --- indra/llprimitive/llmodel.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 6637f41966..7677dc9e27 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1399,6 +1399,7 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin) for (U32 i = 0; i < skin["joint_names"].size(); ++i) { mJointNames.push_back(skin["joint_names"][i]); + mJointNums.push_back(-1); } } -- cgit v1.2.3 From 45ab1429b2e6feae6ac8cd5ee59feacccd86f7b7 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 19 Oct 2016 11:05:02 -0400 Subject: SL-395 - believed fix for intermittent problem uploading meshes with scale locks --- indra/llprimitive/llmodel.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 7677dc9e27..c98cee218c 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1343,7 +1343,6 @@ bool LLModel::matchMaterialOrder(LLModel* ref, int& refFaceCnt, int& modelFaceCn return true; } - bool LLModel::loadSkinInfo(LLSD& header, std::istream &is) { S32 offset = header["skin"]["offset"].asInteger(); @@ -1386,8 +1385,15 @@ bool LLModel::loadDecomposition(LLSD& header, std::istream& is) return true; } +LLMeshSkinInfo::LLMeshSkinInfo(): + mPelvisOffset(0.0), + mLockScaleIfJointPosition(false) +{ +} -LLMeshSkinInfo::LLMeshSkinInfo(LLSD& skin) +LLMeshSkinInfo::LLMeshSkinInfo(LLSD& skin): + mPelvisOffset(0.0), + mLockScaleIfJointPosition(false) { fromLLSD(skin); } @@ -1503,7 +1509,7 @@ LLSD LLMeshSkinInfo::asLLSD(bool include_joints, bool lock_scale_if_joint_positi if (lock_scale_if_joint_position) { - ret["lock_scale_if_joint_position"] = mLockScaleIfJointPosition; + ret["lock_scale_if_joint_position"] = lock_scale_if_joint_position; } ret["pelvis_offset"] = mPelvisOffset; -- cgit v1.2.3 From 5dcd81c15507ad8f487e5727bc7a94de82f6fb45 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 28 Oct 2016 09:33:57 -0400 Subject: SL-451 - avoid more high-cost string operations in a per-frame function --- indra/llprimitive/llmodel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index c98cee218c..db6d00bc2c 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1387,13 +1387,15 @@ bool LLModel::loadDecomposition(LLSD& header, std::istream& is) LLMeshSkinInfo::LLMeshSkinInfo(): mPelvisOffset(0.0), - mLockScaleIfJointPosition(false) + mLockScaleIfJointPosition(false), + mInvalidJointsScrubbed(false) { } LLMeshSkinInfo::LLMeshSkinInfo(LLSD& skin): mPelvisOffset(0.0), - mLockScaleIfJointPosition(false) + mLockScaleIfJointPosition(false), + mInvalidJointsScrubbed(false) { fromLLSD(skin); } -- cgit v1.2.3 From 4ae6f32ee16b21aed2235e96b99e18eebfdd82c6 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 15 Nov 2016 20:16:01 +0200 Subject: MAINT-6901 Fixes upload assigning different scale to parts of the model --- indra/llprimitive/llmodel.cpp | 159 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index e494c55250..3270722ccb 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -174,6 +174,165 @@ void LLModel::trimVolumeFacesToSize(U32 new_count, LLVolume::face_list_t* remain } } +// Shrink group of models to fit +// on a 1x1x1 cube centered at the origin. +void LLModel::normalizeModels(std::vector> model_list) +{ + std::vector >::iterator iter = model_list.begin(); + + LLVector4a min, max; + while (iter != model_list.end() && (*iter)->mVolumeFaces.empty()) + { + iter++; + } + if (iter == model_list.end()) + { + // no models with faces + return; + } + + min = (*iter)->mVolumeFaces[0].mExtents[0]; + max = (*iter)->mVolumeFaces[0].mExtents[1]; + + // Treat models as a group - each model out of 1x1x1 cube + // needs scaling and will affect whole group scale + while (iter != model_list.end()) + { + LLPointer model = *iter++; + + if (model.get() && model->mVolumeFaces.empty()) + { + // For all of the volume faces + // in the model, loop over + // them and see what the extents + // of the volume along each axis. + + for (U32 i = 0; i < model->mVolumeFaces.size(); ++i) + { + LLVolumeFace& face = model->mVolumeFaces[i]; + + update_min_max(min, max, face.mExtents[0]); + update_min_max(min, max, face.mExtents[1]); + + if (face.mTexCoords) + { + LLVector2& min_tc = face.mTexCoordExtents[0]; + LLVector2& max_tc = face.mTexCoordExtents[1]; + + min_tc = face.mTexCoords[0]; + max_tc = face.mTexCoords[0]; + + for (U32 j = 1; j < face.mNumVertices; ++j) + { + update_min_max(min_tc, max_tc, face.mTexCoords[j]); + } + } + else + { + face.mTexCoordExtents[0].set(0, 0); + face.mTexCoordExtents[1].set(1, 1); + } + } + } + } + + // Now that we have the extents of the model + // we can compute the offset needed to center + // the model at the origin. + + // Compute center of the model + // and make it negative to get translation + // needed to center at origin. + LLVector4a trans; + trans.setAdd(min, max); + trans.mul(-0.5f); + + // Compute the total size along all + // axes of the model. + LLVector4a size; + size.setSub(max, min); + + // Prevent division by zero. + F32 x = size[0]; + F32 y = size[1]; + F32 z = size[2]; + F32 w = size[3]; + if (fabs(x) < F_APPROXIMATELY_ZERO) + { + x = 1.0; + } + if (fabs(y) < F_APPROXIMATELY_ZERO) + { + y = 1.0; + } + if (fabs(z) < F_APPROXIMATELY_ZERO) + { + z = 1.0; + } + size.set(x, y, z, w); + + // Compute scale as reciprocal of size + LLVector4a scale; + scale.splat(1.f); + scale.div(size); + + LLVector4a inv_scale(1.f); + inv_scale.div(scale); + + iter = model_list.begin(); + // apply fixed scale and trans to all models as a single group + while (iter != model_list.end()) + { + LLPointer model = *iter++; + + if (model->mVolumeFaces.empty()) + { + continue; + } + + for (U32 i = 0; i < model->mVolumeFaces.size(); ++i) + { + LLVolumeFace& face = model->mVolumeFaces[i]; + + // We shrink the extents so + // that they fall within + // the unit cube. + face.mExtents[0].add(trans); + face.mExtents[0].mul(scale); + + face.mExtents[1].add(trans); + face.mExtents[1].mul(scale); + + // For all the positions, we scale + // the positions to fit within the unit cube. + LLVector4a* pos = (LLVector4a*)face.mPositions; + LLVector4a* norm = (LLVector4a*)face.mNormals; + + for (U32 j = 0; j < face.mNumVertices; ++j) + { + pos[j].add(trans); + pos[j].mul(scale); + if (norm && !norm[j].equals3(LLVector4a::getZero())) + { + norm[j].mul(inv_scale); + norm[j].normalize3(); + } + } + } + + // mNormalizedScale is the scale at which + // we would need to multiply the model + // by to get the original size of the + // model instead of the normalized size. + LLVector4a normalized_scale; + normalized_scale.splat(1.f); + normalized_scale.div(scale); + model->mNormalizedScale.set(normalized_scale.getF32ptr()); + model->mNormalizedTranslation.set(trans.getF32ptr()); + model->mNormalizedTranslation *= -1.f; + } +} + // Shrink the model to fit // on a 1x1x1 cube centered at the origin. // The positions and extents -- cgit v1.2.3 From 75eb1e6ca6ccb501dba43ccdcaff5c500ca62170 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 18 Nov 2016 16:24:36 +0200 Subject: MAINT-6901 Linux build fix --- indra/llprimitive/llmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 3270722ccb..39ee550844 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -176,7 +176,7 @@ void LLModel::trimVolumeFacesToSize(U32 new_count, LLVolume::face_list_t* remain // Shrink group of models to fit // on a 1x1x1 cube centered at the origin. -void LLModel::normalizeModels(std::vector> model_list) +void LLModel::normalizeModels(std::vector > model_list) { std::vector >::iterator iter = model_list.begin(); -- cgit v1.2.3 From 416a46711df4dfe28a22bef47ef9c97aa96b061a Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 21 Nov 2016 22:58:07 +0200 Subject: MAINT-6901 safety checks fix --- indra/llprimitive/llmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 39ee550844..985ccee91e 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -200,7 +200,7 @@ void LLModel::normalizeModels(std::vector > model_list) { LLPointer model = *iter++; - if (model.get() && model->mVolumeFaces.empty()) + if (model.notNull() && !model->mVolumeFaces.empty()) { // For all of the volume faces // in the model, loop over @@ -285,7 +285,7 @@ void LLModel::normalizeModels(std::vector > model_list) { LLPointer model = *iter++; - if (model->mVolumeFaces.empty()) + if (model.isNull() || model->mVolumeFaces.empty()) { continue; } -- cgit v1.2.3 From 4fc012fbfae8975c2240c70c2c3311263ceee5ac Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 23 Dec 2016 15:16:50 +0200 Subject: Reverted changeset 409b67af8faf (MAINT-6901) --- indra/llprimitive/llmodel.cpp | 159 ------------------------------------------ 1 file changed, 159 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 0c313e460e..db6d00bc2c 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -178,165 +178,6 @@ void LLModel::trimVolumeFacesToSize(U32 new_count, LLVolume::face_list_t* remain } } -// Shrink group of models to fit -// on a 1x1x1 cube centered at the origin. -void LLModel::normalizeModels(std::vector > model_list) -{ - std::vector >::iterator iter = model_list.begin(); - - LLVector4a min, max; - while (iter != model_list.end() && (*iter)->mVolumeFaces.empty()) - { - iter++; - } - if (iter == model_list.end()) - { - // no models with faces - return; - } - - min = (*iter)->mVolumeFaces[0].mExtents[0]; - max = (*iter)->mVolumeFaces[0].mExtents[1]; - - // Treat models as a group - each model out of 1x1x1 cube - // needs scaling and will affect whole group scale - while (iter != model_list.end()) - { - LLPointer model = *iter++; - - if (model.notNull() && !model->mVolumeFaces.empty()) - { - // For all of the volume faces - // in the model, loop over - // them and see what the extents - // of the volume along each axis. - - for (U32 i = 0; i < model->mVolumeFaces.size(); ++i) - { - LLVolumeFace& face = model->mVolumeFaces[i]; - - update_min_max(min, max, face.mExtents[0]); - update_min_max(min, max, face.mExtents[1]); - - if (face.mTexCoords) - { - LLVector2& min_tc = face.mTexCoordExtents[0]; - LLVector2& max_tc = face.mTexCoordExtents[1]; - - min_tc = face.mTexCoords[0]; - max_tc = face.mTexCoords[0]; - - for (U32 j = 1; j < face.mNumVertices; ++j) - { - update_min_max(min_tc, max_tc, face.mTexCoords[j]); - } - } - else - { - face.mTexCoordExtents[0].set(0, 0); - face.mTexCoordExtents[1].set(1, 1); - } - } - } - } - - // Now that we have the extents of the model - // we can compute the offset needed to center - // the model at the origin. - - // Compute center of the model - // and make it negative to get translation - // needed to center at origin. - LLVector4a trans; - trans.setAdd(min, max); - trans.mul(-0.5f); - - // Compute the total size along all - // axes of the model. - LLVector4a size; - size.setSub(max, min); - - // Prevent division by zero. - F32 x = size[0]; - F32 y = size[1]; - F32 z = size[2]; - F32 w = size[3]; - if (fabs(x) < F_APPROXIMATELY_ZERO) - { - x = 1.0; - } - if (fabs(y) < F_APPROXIMATELY_ZERO) - { - y = 1.0; - } - if (fabs(z) < F_APPROXIMATELY_ZERO) - { - z = 1.0; - } - size.set(x, y, z, w); - - // Compute scale as reciprocal of size - LLVector4a scale; - scale.splat(1.f); - scale.div(size); - - LLVector4a inv_scale(1.f); - inv_scale.div(scale); - - iter = model_list.begin(); - // apply fixed scale and trans to all models as a single group - while (iter != model_list.end()) - { - LLPointer model = *iter++; - - if (model.isNull() || model->mVolumeFaces.empty()) - { - continue; - } - - for (U32 i = 0; i < model->mVolumeFaces.size(); ++i) - { - LLVolumeFace& face = model->mVolumeFaces[i]; - - // We shrink the extents so - // that they fall within - // the unit cube. - face.mExtents[0].add(trans); - face.mExtents[0].mul(scale); - - face.mExtents[1].add(trans); - face.mExtents[1].mul(scale); - - // For all the positions, we scale - // the positions to fit within the unit cube. - LLVector4a* pos = (LLVector4a*)face.mPositions; - LLVector4a* norm = (LLVector4a*)face.mNormals; - - for (U32 j = 0; j < face.mNumVertices; ++j) - { - pos[j].add(trans); - pos[j].mul(scale); - if (norm && !norm[j].equals3(LLVector4a::getZero())) - { - norm[j].mul(inv_scale); - norm[j].normalize3(); - } - } - } - - // mNormalizedScale is the scale at which - // we would need to multiply the model - // by to get the original size of the - // model instead of the normalized size. - LLVector4a normalized_scale; - normalized_scale.splat(1.f); - normalized_scale.div(scale); - model->mNormalizedScale.set(normalized_scale.getF32ptr()); - model->mNormalizedTranslation.set(trans.getF32ptr()); - model->mNormalizedTranslation *= -1.f; - } -} - // Shrink the model to fit // on a 1x1x1 cube centered at the origin. // The positions and extents -- cgit v1.2.3