summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2018-08-08 13:34:02 +0100
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2018-08-08 13:34:02 +0100
commit791979c553a09963f03239cecc90083fe3f8c657 (patch)
treebc94be84b8046f19c6a3851ce99d585dd8ca76c6
parent6ce09ad712f98fe5d0097f1de6a5d1793f5f2bdd (diff)
SL-928 - in mesh upload, warn if bind shape is non-identity and skin weights are enabled.
-rw-r--r--indra/llprimitive/llmodelloader.h1
-rw-r--r--indra/newview/llcontrolavatar.cpp22
-rw-r--r--indra/newview/llfloatermodelpreview.cpp18
-rw-r--r--indra/newview/llfloatermodelpreview.h5
-rw-r--r--indra/newview/llskinningutil.cpp27
-rw-r--r--indra/newview/llskinningutil.h1
-rw-r--r--indra/newview/skins/default/xui/en/floater_model_preview.xml1
7 files changed, 54 insertions, 21 deletions
diff --git a/indra/llprimitive/llmodelloader.h b/indra/llprimitive/llmodelloader.h
index d64e0a0773..643c45a6d8 100644
--- a/indra/llprimitive/llmodelloader.h
+++ b/indra/llprimitive/llmodelloader.h
@@ -81,6 +81,7 @@ public:
GENERATING_VERTEX_BUFFERS,
GENERATING_LOD,
DONE,
+ WARNING_BIND_SHAPE_ORIENTATION,
ERROR_PARSING, //basically loading failed
ERROR_MATERIALS,
ERROR_PASSWORD_REQUIRED,
diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp
index 6adb34c263..83d42f6ccf 100644
--- a/indra/newview/llcontrolavatar.cpp
+++ b/indra/newview/llcontrolavatar.cpp
@@ -33,6 +33,7 @@
#include "llviewercontrol.h"
#include "llmeshrepository.h"
#include "llviewerregion.h"
+#include "llskinningutil.h"
LLControlAvatar::LLControlAvatar(const LLUUID& id, const LLPCode pcode, LLViewerRegion* regionp) :
LLVOAvatar(id, pcode, regionp),
@@ -144,26 +145,7 @@ void LLControlAvatar::matchVolumeTransform()
if (skin_info)
{
LL_DEBUGS("BindShape") << getFullname() << " bind shape " << skin_info->mBindShapeMatrix << LL_ENDL;
- LLMatrix3 bind_mat = skin_info->mBindShapeMatrix.getMat3();
- for (auto i = 0; i < 3; i++)
- {
- F32 len = 0.0f;
- for (auto j = 0; j < 3; j++)
- {
- len += bind_mat.mMatrix[i][j] * bind_mat.mMatrix[i][j];
- }
- if (len > 0.0f)
- {
- len = sqrt(len);
- for (auto j = 0; j < 3; j++)
- {
- bind_mat.mMatrix[i][j] /= len;
- }
- }
- }
- bind_mat.invert();
- bind_rot = bind_mat.quaternion();
- bind_rot.normalize();
+ bind_rot = LLSkinningUtil::getUnscaledQuaternion(skin_info->mBindShapeMatrix);
}
#endif
setRotation(bind_rot*obj_rot);
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 0d92cc5acc..268c646719 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -685,6 +685,11 @@ void LLFloaterModelPreview::draw()
childSetTextArg("status", "[STATUS]", getString("status_parse_error"));
toggleCalculateButton(false);
}
+ else
+ if (mModelPreview->getLoadState() == LLModelLoader::WARNING_BIND_SHAPE_ORIENTATION)
+ {
+ childSetTextArg("status", "[STATUS]", getString("status_bind_shape_orientation"));
+ }
else
{
childSetTextArg("status", "[STATUS]", getString("status_idle"));
@@ -1622,6 +1627,19 @@ void LLModelPreview::rebuildUploadData()
mFMP->childDisable( "calculate_btn" );
}
}
+ LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) mFMP;
+ bool upload_skinweights = fmp && fmp->childGetValue("upload_skin").asBoolean();
+ if (upload_skinweights && high_lod_model->mSkinInfo.mJointNames.size() > 0)
+ {
+ LLQuaternion bind_rot = LLSkinningUtil::getUnscaledQuaternion(high_lod_model->mSkinInfo.mBindShapeMatrix);
+ LLQuaternion identity;
+ if (!bind_rot.isEqualEps(identity,0.01))
+ {
+ LL_WARNS() << "non-identity bind shape rot. mat is " << high_lod_model->mSkinInfo.mBindShapeMatrix
+ << " bind_rot " << bind_rot << LL_ENDL;
+ setLoadState( LLModelLoader::WARNING_BIND_SHAPE_ORIENTATION );
+ }
+ }
}
instance.mTransform = mat;
mUploadData.push_back(instance);
diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h
index 53b03c6069..7ec6a58ac7 100644
--- a/indra/newview/llfloatermodelpreview.h
+++ b/indra/newview/llfloatermodelpreview.h
@@ -169,7 +169,10 @@ protected:
void draw();
void initDecompControls();
-
+
+ // FIXME - this function and mStatusMessage have no visible effect, and the
+ // actual status messages are managed by directly manipulation of
+ // the UI element.
void setStatusMessage(const std::string& msg);
LLModelPreview* mModelPreview;
diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp
index 2bd70da01d..3d6b0ed957 100644
--- a/indra/newview/llskinningutil.cpp
+++ b/indra/newview/llskinningutil.cpp
@@ -379,3 +379,30 @@ void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *a
}
}
+
+// This is used for extracting rotation from a bind shape matrix that
+// already has scales baked in
+LLQuaternion LLSkinningUtil::getUnscaledQuaternion(const LLMatrix4& mat4)
+{
+ LLMatrix3 bind_mat = mat4.getMat3();
+ for (auto i = 0; i < 3; i++)
+ {
+ F32 len = 0.0f;
+ for (auto j = 0; j < 3; j++)
+ {
+ len += bind_mat.mMatrix[i][j] * bind_mat.mMatrix[i][j];
+ }
+ if (len > 0.0f)
+ {
+ len = sqrt(len);
+ for (auto j = 0; j < 3; j++)
+ {
+ bind_mat.mMatrix[i][j] /= len;
+ }
+ }
+ }
+ bind_mat.invert();
+ LLQuaternion bind_rot = bind_mat.quaternion();
+ bind_rot.normalize();
+ return bind_rot;
+}
diff --git a/indra/newview/llskinningutil.h b/indra/newview/llskinningutil.h
index e730ef014b..ccc501adc0 100644
--- a/indra/newview/llskinningutil.h
+++ b/indra/newview/llskinningutil.h
@@ -44,6 +44,7 @@ namespace LLSkinningUtil
void getPerVertexSkinMatrix(F32* weights, LLMatrix4a* mat, bool handle_bad_scale, LLMatrix4a& final_mat, U32 max_joints);
void initJointNums(LLMeshSkinInfo* skin, LLVOAvatar *avatar);
void updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *avatar, LLVolumeFace& vol_face);
+ LLQuaternion getUnscaledQuaternion(const LLMatrix4& mat4);
};
#endif
diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml
index 2750316f2e..3db431de1b 100644
--- a/indra/newview/skins/default/xui/en/floater_model_preview.xml
+++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml
@@ -14,6 +14,7 @@
<string name="status_idle"></string>
<string name="status_parse_error">Error: Dae parsing issue - see log for details.</string>
+ <string name="status_bind_shape_orientation">Warning: bind shape matrix is not in standard X-forward orientation.</string>
<string name="status_material_mismatch">Error: Material of model is not a subset of reference model.</string>
<string name="status_reading_file">Loading...</string>
<string name="status_generating_meshes">Generating Meshes...</string>