summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-04-23 19:34:14 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-04-23 20:51:06 +0300
commit9221c8a3f65aa14cad4fec03b7033ad800f6ba35 (patch)
treec311b839138c1e1ef2d5258bffc189072a58e417
parentc54e0e4f12dedff2d64354215fd7bcb68b09c7fd (diff)
SL-13080 Changes for joint listings in mesh uploader
-rw-r--r--indra/llprimitive/lldaeloader.cpp6
-rw-r--r--indra/newview/llfloatermodelpreview.cpp126
-rw-r--r--indra/newview/llfloatermodelpreview.h5
-rw-r--r--indra/newview/llmodelpreview.cpp36
4 files changed, 126 insertions, 47 deletions
diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp
index 139f48fef8..431443788c 100644
--- a/indra/llprimitive/lldaeloader.cpp
+++ b/indra/llprimitive/lldaeloader.cpp
@@ -1470,6 +1470,12 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
}
}
+ U32 bind_count = model->mSkinInfo.mAlternateBindMatrix.size();
+ if (bind_count > 0 && bind_count != jointCnt)
+ {
+ LL_WARNS("Mesh") << "Model " << model->mLabel << " has invalid joint bind matrix list." << LL_ENDL;
+ }
+
//grab raw position array
domVertices* verts = mesh->getVertices();
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 5df3139d0d..666406d039 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -433,46 +433,82 @@ void LLFloaterModelPreview::onClickCalculateBtn()
mUploadBtn->setEnabled(false);
}
-void populate_list_with_map(LLScrollListCtrl *list, const std::map<std::string, LLVector3> &vector_map)
+// Modified cell_params, make sure to clear values if you have to reuse cell_params outside of this function
+void add_row_to_list(LLScrollListCtrl *listp,
+ LLScrollListCell::Params &cell_params,
+ const LLSD &item_value,
+ const std::string &name,
+ const LLSD &vx,
+ const LLSD &vy,
+ const LLSD &vz)
{
- if (vector_map.empty())
+ LLScrollListItem::Params item_params;
+ item_params.value = item_value;
+
+ cell_params.column = "model_name";
+ cell_params.value = name;
+
+ item_params.columns.add(cell_params);
+
+ cell_params.column = "axis_x";
+ cell_params.value = vx;
+ item_params.columns.add(cell_params);
+
+ cell_params.column = "axis_y";
+ cell_params.value = vy;
+ item_params.columns.add(cell_params);
+
+ cell_params.column = "axis_z";
+ cell_params.value = vz;
+
+ item_params.columns.add(cell_params);
+
+ listp->addRow(item_params);
+}
+
+void populate_list_with_overrides(LLScrollListCtrl *listp, const LLJointOverrideData &data, bool include_overrides)
+{
+ if (data.mModelsNoOverrides.empty() && data.mPosOverrides.empty())
{
return;
}
+
+ static const LLSD no_override_placeholder("-"); // LLSD to not conflict in '?'
+
S32 count = 0;
LLScrollListCell::Params cell_params;
cell_params.font = LLFontGL::getFontSansSerif();
// Start out right justifying numeric displays
cell_params.font_halign = LLFontGL::HCENTER;
- std::map<std::string, LLVector3>::const_iterator iter = vector_map.begin();
- std::map<std::string, LLVector3>::const_iterator end = vector_map.end();
- while (iter != end)
+ std::map<std::string, LLVector3>::const_iterator map_iter = data.mPosOverrides.begin();
+ std::map<std::string, LLVector3>::const_iterator map_end = data.mPosOverrides.end();
+ while (map_iter != map_end)
{
- LLScrollListItem::Params item_params;
- item_params.value = LLSD::Integer(count);
-
- cell_params.column = "model_name";
- cell_params.value = iter->first;
-
- item_params.columns.add(cell_params);
-
- cell_params.column = "axis_x";
- cell_params.value = iter->second.mV[VX];
- item_params.columns.add(cell_params);
-
- cell_params.column = "axis_y";
- cell_params.value = iter->second.mV[VY];
- item_params.columns.add(cell_params);
-
- cell_params.column = "axis_z";
- cell_params.value = iter->second.mV[VZ];
-
- item_params.columns.add(cell_params);
+ add_row_to_list(listp,
+ cell_params,
+ LLSD::Integer(count),
+ map_iter->first,
+ include_overrides ? map_iter->second.mV[VX] : no_override_placeholder,
+ include_overrides ? map_iter->second.mV[VY] : no_override_placeholder,
+ include_overrides ? map_iter->second.mV[VZ] : no_override_placeholder);
+ count++;
+ map_iter++;
+ }
- list->addRow(item_params);
+ std::set<std::string>::const_iterator set_iter = data.mModelsNoOverrides.begin();
+ std::set<std::string>::const_iterator set_end = data.mModelsNoOverrides.end();
+ while (set_iter != set_end)
+ {
+ add_row_to_list(listp,
+ cell_params,
+ LLSD::Integer(count),
+ *set_iter,
+ no_override_placeholder,
+ no_override_placeholder,
+ no_override_placeholder);
count++;
- iter++;
+ set_iter++;
}
}
@@ -493,7 +529,8 @@ void LLFloaterModelPreview::onJointListSelection()
{
std::string label = selected->getValue().asString();
LLJointOverrideData &data = mJointOverrides[display_lod][label];
- populate_list_with_map(joints_pos, data.mPosOverrides);
+ bool upload_joint_positions = childGetValue("upload_joints").asBoolean();
+ populate_list_with_overrides(joints_pos, data, upload_joint_positions);
joint_pos_descr->setTextArg("[JOINT]", label);
mSelectedJointName = label;
@@ -1285,7 +1322,7 @@ void LLFloaterModelPreview::clearAvatarTab()
joint_pos_descr->setTextArg("[JOINT]", std::string("mPelvis")); // Might be better to hide it
}
-void LLFloaterModelPreview::updateAvatarTab()
+void LLFloaterModelPreview::updateAvatarTab(bool highlight_overrides)
{
S32 display_lod = mModelPreview->mPreviewLOD;
if (mModelPreview->mModel[display_lod].empty())
@@ -1307,10 +1344,22 @@ void LLFloaterModelPreview::updateAvatarTab()
LLModelInstance& instance = *model_iter;
LLModel* model = instance.mModel;
const LLMeshSkinInfo *skin = &model->mSkinInfo;
- if (skin->mAlternateBindMatrix.size() > 0)
+ U32 joint_count = LLSkinningUtil::getMeshJointCount(skin);
+ U32 bind_count = highlight_overrides ? skin->mAlternateBindMatrix.size() : 0; // simply do not include overrides if data is not needed
+ if (bind_count > 0 && bind_count != joint_count)
+ {
+ std::ostringstream out;
+ out << "Invalid joint overrides for model " << model->getName();
+ out << ". Amount of joints " << joint_count;
+ out << ", is different from amount of overrides " << bind_count;
+ LL_INFOS() << out.str() << LL_ENDL;
+ addStringToLog(out.str(), true);
+ // Disable overrides for this model
+ bind_count = 0;
+ }
+ if (bind_count > 0)
{
- U32 count = LLSkinningUtil::getMeshJointCount(skin);
- for (U32 j = 0; j < count; ++j)
+ for (U32 j = 0; j < joint_count; ++j)
{
const LLVector3& jointPos = skin->mAlternateBindMatrix[j].getTranslation();
LLJointOverrideData &data = mJointOverrides[display_lod][skin->mJointNames[j]];
@@ -1323,7 +1372,14 @@ void LLFloaterModelPreview::updateAvatarTab()
data.mHasConflicts = true;
}
data.mPosOverrides[model->getName()] = jointPos;
-
+ }
+ }
+ else
+ {
+ for (U32 j = 0; j < joint_count; ++j)
+ {
+ LLJointOverrideData &data = mJointOverrides[display_lod][skin->mJointNames[j]];
+ data.mModelsNoOverrides.insert(model->getName());
}
}
}
@@ -1364,6 +1420,10 @@ void LLFloaterModelPreview::updateAvatarTab()
cell_params.color = LLColor4::orange;
conflicts++;
}
+ if (highlight_overrides && joint_iter->second.mPosOverrides.size() > 0)
+ {
+ cell_params.font.style = "BOLD";
+ }
item_params.columns.add(cell_params);
diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h
index ca52312756..48b90e9d44 100644
--- a/indra/newview/llfloatermodelpreview.h
+++ b/indra/newview/llfloatermodelpreview.h
@@ -43,7 +43,8 @@ class LLJointOverrideData
{
public:
LLJointOverrideData() : mHasConflicts(false) {};
- std::map<std::string, LLVector3> mPosOverrides;
+ std::map<std::string, LLVector3> mPosOverrides; // models with overrides
+ std::set<std::string> mModelsNoOverrides; // models without defined overrides
bool mHasConflicts;
};
typedef std::map<std::string, LLJointOverrideData> joint_override_data_map_t;
@@ -86,7 +87,7 @@ public:
static void addStringToLog(const std::string& str, bool flash);
static void addStringToLog(const std::ostringstream& strm, bool flash);
void clearAvatarTab(); // clears table
- void updateAvatarTab(); // populates table and data as nessesary
+ void updateAvatarTab(bool highlight_overrides); // populates table and data as nessesary
void setDetails(F32 x, F32 y, F32 z, F32 streaming_cost, F32 physics_cost);
void setPreviewLOD(S32 lod);
diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp
index 9e39d0cf51..21c6895a6c 100644
--- a/indra/newview/llmodelpreview.cpp
+++ b/indra/newview/llmodelpreview.cpp
@@ -2734,6 +2734,10 @@ BOOL LLModelPreview::render()
if (upload_joints != mLastJointUpdate)
{
mLastJointUpdate = upload_joints;
+ if (fmp)
+ {
+ fmp->clearAvatarTab();
+ }
}
for (LLModelLoader::scene::iterator iter = mScene[mPreviewLOD].begin(); iter != mScene[mPreviewLOD].end(); ++iter)
@@ -2801,22 +2805,27 @@ BOOL LLModelPreview::render()
upload_joints = false;
}
- if (upload_skin && upload_joints)
+ if (fmp)
{
- mFMP->childEnable("lock_scale_if_joint_position");
- if (fmp)
+ if (upload_skin)
{
- fmp->updateAvatarTab();
+ // will populate list of joints
+ fmp->updateAvatarTab(upload_joints);
}
+ else
+ {
+ fmp->clearAvatarTab();
+ }
+ }
+
+ if (upload_skin && upload_joints)
+ {
+ mFMP->childEnable("lock_scale_if_joint_position");
}
else
{
mFMP->childDisable("lock_scale_if_joint_position");
mFMP->childSetValue("lock_scale_if_joint_position", false);
- if (fmp)
- {
- fmp->clearAvatarTab();
- }
}
//Only enable joint offsets if it passed the earlier critiquing
@@ -3218,9 +3227,12 @@ BOOL LLModelPreview::render()
{
const LLMeshSkinInfo *skin = &model->mSkinInfo;
LLSkinningUtil::initJointNums(&model->mSkinInfo, getPreviewAvatar());// inits skin->mJointNums if nessesary
- U32 count = LLSkinningUtil::getMeshJointCount(skin);
+ U32 joint_count = LLSkinningUtil::getMeshJointCount(skin);
+ U32 bind_count = skin->mAlternateBindMatrix.size();
- if (joint_overrides && skin->mAlternateBindMatrix.size() > 0)
+ if (joint_overrides
+ && bind_count > 0
+ && joint_count == bind_count)
{
// mesh_id is used to determine which mesh gets to
// set the joint offset, in the event of a conflict. Since
@@ -3231,7 +3243,7 @@ BOOL LLModelPreview::render()
// incorrect.
LLUUID fake_mesh_id;
fake_mesh_id.generate();
- for (U32 j = 0; j < count; ++j)
+ for (U32 j = 0; j < joint_count; ++j)
{
LLJoint *joint = getPreviewAvatar()->getJoint(skin->mJointNums[j]);
if (joint)
@@ -3278,7 +3290,7 @@ BOOL LLModelPreview::render()
//build matrix palette
LLMatrix4a mat[LL_MAX_JOINTS_PER_MESH_OBJECT];
- LLSkinningUtil::initSkinningMatrixPalette((LLMatrix4*)mat, count,
+ LLSkinningUtil::initSkinningMatrixPalette((LLMatrix4*)mat, joint_count,
skin, getPreviewAvatar());
LLMatrix4a bind_shape_matrix;