SL-13080 Changes for joint listings in mesh uploader

meow-7.2.2
Andrey Kleshchev 2020-04-23 19:34:14 +03:00
parent c54e0e4f12
commit 9221c8a3f6
4 changed files with 127 additions and 48 deletions

View File

@ -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();

View File

@ -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);
list->addRow(item_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++;
iter++;
map_iter++;
}
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++;
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)
{
U32 count = LLSkinningUtil::getMeshJointCount(skin);
for (U32 j = 0; j < count; ++j)
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)
{
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);

View File

@ -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);

View File

@ -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 (fmp)
{
if (upload_skin)
{
// will populate list of joints
fmp->updateAvatarTab(upload_joints);
}
else
{
fmp->clearAvatarTab();
}
}
if (upload_skin && upload_joints)
{
mFMP->childEnable("lock_scale_if_joint_position");
if (fmp)
{
fmp->updateAvatarTab();
}
}
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;