Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/CLIPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2507,18 +2507,29 @@
MeshImporterExporter::importer({meshFi.absoluteFilePath()});
auto& movables = Manager::getSingleton()->getEntities();
Ogre::Entity* entity = nullptr;
Ogre::Entity* firstAnyEntity = nullptr;

Check warning on line 2510 in src/CLIPipeline.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a pointer-to-const. The current type of "firstAnyEntity" is "class Ogre::Entity *".

See more on https://sonarcloud.io/project/issues?id=fernandotonon_QtMeshEditor&issues=AZ46Tr7bEK7wgQC9Bkae&open=AZ46Tr7bEK7wgQC9Bkae&pullRequest=607
// CodeRabbit Major on PR #606: prefer the first SKINNED
// entity. Multi-entity imports often include an unskinned
// helper (collision proxy, prop) first; if we picked it,
// apply would fail with "no skeleton" even though a valid
// rigged mesh loaded later in the scene. Track both so we
// can give a precise error: "no entity at all" vs "found
// entities but none skinned".
for (auto* obj : movables) {
if (obj && obj->getMovableType() == "Entity") {
entity = static_cast<Ogre::Entity*>(obj);
if (!obj || obj->getMovableType() != "Entity") continue;
auto* e = static_cast<Ogre::Entity*>(obj);
if (!firstAnyEntity) firstAnyEntity = e;
if (e->hasSkeleton()) {
entity = e;
break;
}
}
if (!entity) {
if (!firstAnyEntity) {
err() << "Error: Failed to load mesh: " << filePath << Qt::endl;
return 1;
}
if (!entity->hasSkeleton()) {
err() << "Error: Mesh has no skeleton — cannot apply a pose." << Qt::endl;
if (!entity) {
err() << "Error: Loaded mesh has no skinned entity — cannot apply a pose." << Qt::endl;
return 1;
}

Expand All @@ -2545,6 +2556,8 @@
// FBX/glTF it preserves the skeleton, for STL/OBJ it
// bakes the posed mesh down to triangles.
QFileInfo outFi(outputPath);
SentryReporter::addBreadcrumb("file.export",
QString("Exporting posed mesh to %1").arg(outFi.absoluteFilePath()));
const int result = MeshImporterExporter::exportCurrentPose(entity, outFi.absoluteFilePath());
if (result != 0) {
err() << "Error: Export failed: " << outputPath << Qt::endl;
Expand Down
Loading