#4242 Debug dump improvement

for better comparison with collada output
master
Andrey Kleshchev 2025-07-02 23:18:05 +03:00 committed by Andrey Kleshchev
parent 55a79ec56b
commit 5a0bbdc510
12 changed files with 110 additions and 28 deletions

View File

@ -883,6 +883,7 @@ LLDAELoader::LLDAELoader(
std::map<std::string, std::string, std::less<>>& jointAliasMap,
U32 maxJointsPerMesh,
U32 modelLimit,
U32 debugMode,
bool preprocess)
: LLModelLoader(
filename,
@ -895,8 +896,9 @@ LLDAELoader::LLDAELoader(
jointTransformMap,
jointsFromNodes,
jointAliasMap,
maxJointsPerMesh),
mGeneratedModelLimit(modelLimit),
maxJointsPerMesh,
modelLimit,
debugMode),
mPreprocessDAE(preprocess)
{
}

View File

@ -59,6 +59,7 @@ public:
std::map<std::string, std::string, std::less<>>& jointAliasMap,
U32 maxJointsPerMesh,
U32 modelLimit,
U32 debugMode,
bool preprocess);
virtual ~LLDAELoader() ;
@ -103,7 +104,6 @@ protected:
static std::string preprocessDAE(std::string filename);
private:
U32 mGeneratedModelLimit; // Attempt to limit amount of generated submodels
bool mPreprocessDAE;
};

View File

@ -818,7 +818,7 @@ LLSD LLModel::writeModel(
bool upload_skin,
bool upload_joints,
bool lock_scale_if_joint_position,
bool nowrite,
EWriteModelMode write_mode,
bool as_slm,
int submodel_id)
{
@ -1097,10 +1097,10 @@ LLSD LLModel::writeModel(
}
}
return writeModelToStream(ostr, mdl, nowrite, as_slm);
return writeModelToStream(ostr, mdl, write_mode, as_slm);
}
LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, bool nowrite, bool as_slm)
LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, EWriteModelMode write_mode, bool as_slm)
{
std::string::size_type cur_offset = 0;
@ -1162,7 +1162,11 @@ LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, bool nowrite, bo
}
}
if (!nowrite)
if (write_mode == WRITE_HUMAN)
{
ostr << mdl;
}
else if (write_mode == WRITE_BINARY)
{
LLSDSerialize::toBinary(header, ostr);

View File

@ -160,6 +160,12 @@ public:
bool loadSkinInfo(LLSD& header, std::istream& is);
bool loadDecomposition(LLSD& header, std::istream& is);
enum EWriteModelMode
{
WRITE_NO = 0,
WRITE_BINARY,
WRITE_HUMAN,
};
static LLSD writeModel(
std::ostream& ostr,
LLModel* physics,
@ -171,14 +177,14 @@ public:
bool upload_skin,
bool upload_joints,
bool lock_scale_if_joint_position,
bool nowrite = false,
EWriteModelMode write_mode = WRITE_BINARY,
bool as_slm = false,
int submodel_id = 0);
static LLSD writeModelToStream(
std::ostream& ostr,
LLSD& mdl,
bool nowrite = false, bool as_slm = false);
EWriteModelMode write_mode = WRITE_BINARY, bool as_slm = false);
void ClearFacesAndMaterials() { mVolumeFaces.clear(); mMaterialList.clear(); }

View File

@ -113,7 +113,9 @@ LLModelLoader::LLModelLoader(
JointTransformMap& jointTransformMap,
JointNameSet& jointsFromNodes,
JointMap& legalJointNamesMap,
U32 maxJointsPerMesh)
U32 maxJointsPerMesh,
U32 modelLimit,
U32 debugMode)
: mJointList( jointTransformMap )
, mJointsFromNode( jointsFromNodes )
, LLThread("Model Loader")
@ -133,6 +135,8 @@ LLModelLoader::LLModelLoader(
, mNoOptimize(false)
, mCacheOnlyHitIfRigged(false)
, mMaxJointsPerMesh(maxJointsPerMesh)
, mGeneratedModelLimit(modelLimit)
, mDebugMode(debugMode)
, mJointMap(legalJointNamesMap)
{
assert_main_thread();
@ -238,7 +242,9 @@ bool LLModelLoader::doLoadModel()
}
}
return OpenFile(mFilename);
bool res = OpenFile(mFilename);
dumpDebugData(); // conditional on mDebugMode
return res;
}
void LLModelLoader::setLoadState(U32 state)
@ -505,6 +511,11 @@ bool LLModelLoader::isRigSuitableForJointPositionUpload( const std::vector<std::
void LLModelLoader::dumpDebugData()
{
if (mDebugMode == 0)
{
return;
}
std::string log_file = mFilename + "_importer.txt";
LLStringUtil::toLower(log_file);
llofstream file;
@ -543,17 +554,55 @@ void LLModelLoader::dumpDebugData()
}
}
file << "Inv Bind matrices.\n";
file << "\nInv Bind matrices.\n";
for (auto& bind : inv_bind)
{
file << "Joint: " << bind.first << " Matrix: " << bind.second << "\n";
}
file << "Alt Bind matrices.\n";
file << "\nAlt Bind matrices.\n";
for (auto& bind : alt_bind)
{
file << "Joint: " << bind.first << " Matrix: " << bind.second << "\n";
}
if (mDebugMode < 1)
{
return;
}
file << "\nModel LLSDs\n";
S32 model_count = 0;
// some files contain too many models, so stop at 5.
for (LLPointer<LLModel>& mdl : mModelList)
{
const LLMeshSkinInfo& skin_info = mdl->mSkinInfo;
size_t joint_count = skin_info.mJointNames.size();
size_t alt_count = skin_info.mAlternateBindMatrix.size();
LLModel::writeModel(
file,
nullptr,
mdl,
nullptr,
nullptr,
nullptr,
mdl->mPhysics,
joint_count > 0,
alt_count > 0,
false,
LLModel::WRITE_HUMAN,
false,
mdl->mSubmodelID);
file << "\n";
model_count++;
if (model_count == 5)
{
file << "Too many models, stopping at 5.\n";
break;
}
}
}
//called in the main thread

View File

@ -129,6 +129,7 @@ public:
U32 mMaxJointsPerMesh;
U32 mDebugMode; // see dumDebugData() for details
LLModelLoader(
std::string filename,
@ -141,7 +142,9 @@ public:
JointTransformMap& jointTransformMap,
JointNameSet& jointsFromNodes,
JointMap& legalJointNamesMap,
U32 maxJointsPerMesh);
U32 maxJointsPerMesh,
U32 modelLimit,
U32 debugMode);
virtual ~LLModelLoader();
virtual void setNoNormalize() { mNoNormalize = true; }
@ -210,6 +213,7 @@ protected:
bool mRigValidJointUpload;
U32 mLegacyRigFlags;
U32 mGeneratedModelLimit; // Attempt to limit amount of generated submodels
bool mNoNormalize;
bool mNoOptimize;

View File

@ -2,7 +2,7 @@
<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="llsd.xsd">
<map>
<key>ImporterDebug</key>
<key>ImporterDebugVerboseLogging</key>
<map>
<key>Comment</key>
<string>Enable debug output to more precisely identify sources of import errors. Warning: the output can slow down import on many machines.</string>
@ -35,6 +35,17 @@
<key>Value</key>
<integer>768</integer>
</map>
<key>ImporterDebugMode</key>
<map>
<key>Comment</key>
<string>At 0 does nothing, at 1 dumps skinning data near orifinal file, at 2 dumps skining data and first 5 models as llsd</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>ImporterPreprocessDAE</key>
<map>
<key>Comment</key>

View File

@ -98,6 +98,7 @@ LLGLTFLoader::LLGLTFLoader(std::string filename,
std::map<std::string, std::string, std::less<>> & jointAliasMap,
U32 maxJointsPerMesh,
U32 modelLimit,
U32 debugMode,
std::vector<LLJointData> viewer_skeleton) //,
//bool preprocess)
: LLModelLoader( filename,
@ -110,8 +111,9 @@ LLGLTFLoader::LLGLTFLoader(std::string filename,
jointTransformMap,
jointsFromNodes,
jointAliasMap,
maxJointsPerMesh )
, mGeneratedModelLimit(modelLimit)
maxJointsPerMesh,
modelLimit,
debugMode)
, mViewerJointData(viewer_skeleton)
{
}
@ -1037,7 +1039,7 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh&
size_t jointCnt = gltf_skin.mJoints.size();
gltfindex_to_joitindex_map.resize(jointCnt, -1);
if (valid_joints_count > LL_MAX_JOINTS_PER_MESH_OBJECT)
if (valid_joints_count > (S32)mMaxJointsPerMesh)
{
std::map<std::string, S32> goup_use_count;
// Assume that 'Torso' group is always in use since that's what everything else is attached to
@ -1092,7 +1094,7 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh&
// this step needs only joints that have zero uses
continue;
}
if (skin_info.mInvBindMatrix.size() > LL_MAX_JOINTS_PER_MESH_OBJECT)
if (skin_info.mInvBindMatrix.size() > mMaxJointsPerMesh)
{
break;
}
@ -1127,16 +1129,18 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh&
}
}
if (skin_info.mInvBindMatrix.size() > LL_MAX_JOINTS_PER_MESH_OBJECT)
if (skin_info.mInvBindMatrix.size() > mMaxJointsPerMesh)
{
// mMaxJointsPerMesh ususlly is equal to LL_MAX_JOINTS_PER_MESH_OBJECT
// and is 110.
LL_WARNS("GLTF_IMPORT") << "Too many jonts in " << pModel->mLabel
<< " Count: " << (S32)skin_info.mInvBindMatrix.size()
<< " Limit:" << (S32)LL_MAX_JOINTS_PER_MESH_OBJECT << LL_ENDL;
<< " Limit:" << (S32)mMaxJointsPerMesh << LL_ENDL;
LLSD args;
args["Message"] = "ModelTooManyJoints";
args["MODEL_NAME"] = pModel->mLabel;
args["JOINT_COUNT"] = (S32)skin_info.mInvBindMatrix.size();
args["MAX"] = (S32)LL_MAX_JOINTS_PER_MESH_OBJECT;
args["MAX"] = (S32)mMaxJointsPerMesh;
mWarningsArray.append(args);
}

View File

@ -83,6 +83,7 @@ class LLGLTFLoader : public LLModelLoader
std::map<std::string, std::string, std::less<>> & jointAliasMap,
U32 maxJointsPerMesh,
U32 modelLimit,
U32 debugMode,
std::vector<LLJointData> viewer_skeleton); //,
//bool preprocess );
virtual ~LLGLTFLoader();
@ -103,7 +104,6 @@ protected:
tinygltf::Model mGltfModel;
bool mGltfLoaded;
bool mApplyXYRotation = false;
U32 mGeneratedModelLimit;
// GLTF isn't aware of viewer's skeleton and uses it's own,
// so need to take viewer's joints and use them to

View File

@ -2740,7 +2740,7 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
mUploadSkin,
mUploadJoints,
mLockScaleIfJointPosition,
false,
LLModel::WRITE_BINARY,
false,
data.mBaseModel->mSubmodelID);
@ -2898,7 +2898,7 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
mUploadSkin,
mUploadJoints,
mLockScaleIfJointPosition,
false,
LLModel::WRITE_BINARY,
false,
data.mBaseModel->mSubmodelID);

View File

@ -167,7 +167,7 @@ LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp)
, mLastJointUpdate(false)
, mFirstSkinUpdate(true)
, mHasDegenerate(false)
, mImporterDebug(LLCachedControl<bool>(gSavedSettings, "ImporterDebug", false))
, mImporterDebug(LLCachedControl<bool>(gSavedSettings, "ImporterDebugVerboseLogging", false))
{
mNeedsUpdate = true;
mCameraDistance = 0.f;
@ -692,7 +692,7 @@ void LLModelPreview::saveUploadData(const std::string& filename,
save_skinweights,
save_joint_positions,
lock_scale_if_joint_position,
false, true, instance.mModel->mSubmodelID);
LLModel::WRITE_BINARY, true, instance.mModel->mSubmodelID);
data["mesh"][instance.mModel->mLocalID] = str.str();
}
@ -807,6 +807,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable
joint_alias_map,
LLSkinningUtil::getMaxJointCount(),
gSavedSettings.getU32("ImporterModelLimit"),
gSavedSettings.getU32("ImporterDebugMode"),
gSavedSettings.getBOOL("ImporterPreprocessDAE"));
}
else
@ -827,6 +828,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable
joint_alias_map,
LLSkinningUtil::getMaxJointCount(),
gSavedSettings.getU32("ImporterModelLimit"),
gSavedSettings.getU32("ImporterDebugMode"),
viewer_skeleton);
}

View File

@ -1426,7 +1426,7 @@
word_wrap="true">
</text_editor>
<check_box
control_name="ImporterDebug"
control_name="ImporterDebugVerboseLogging"
follows="top|left"
top_pad="9"
left="6"