From 67aede086fbcd71b473dc755af87cd8aaf68f6a3 Mon Sep 17 00:00:00 2001 From: Fernando Date: Sat, 16 May 2026 16:59:06 -0400 Subject: [PATCH] feat(import): auto-scale sub-unit meshes to ~3 units instead of ~1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The auto-scale heuristic for mm-scale FBX / photogrammetry assets previously brought the largest bounding-box dimension to ~1 unit. At that target the imported model lands well inside the default camera framing and feels visually small — users had to manually scale up after every sub-unit import. Bump the target to 3 units so models come in at a more comfortable working size. Threshold (0.01) and behavior for sensible-scale assets unchanged. Test comments + expected factor description updated; the existing `>= 50` assertion still holds (factor for 0.005 extent: ~200 → ~600). Co-Authored-By: Claude Opus 4.7 (1M context) --- src/MeshImporterExporter.cpp | 4 ++-- src/MeshImporterExporter_test.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/MeshImporterExporter.cpp b/src/MeshImporterExporter.cpp index a69841cd..fab37165 100755 --- a/src/MeshImporterExporter.cpp +++ b/src/MeshImporterExporter.cpp @@ -2104,13 +2104,13 @@ void MeshImporterExporter::importer(const QStringList &_uriList, unsigned int ad // bounding-box extents <0.01 — the entity loads but sits // entirely inside the default near-clip distance and never // renders. Scale the parent SceneNode so the largest - // dimension lands at ~1 unit. Threshold of 0.01 avoids + // dimension lands at ~3 units. Threshold of 0.01 avoids // touching sensible-scale assets (anything from a few cm up). if (en && en->getMesh()) { const auto& bbSize = en->getBoundingBox().getSize(); const Ogre::Real maxExtent = std::max({bbSize.x, bbSize.y, bbSize.z}); if (maxExtent > 0.0f && maxExtent < 0.01f) { - const Ogre::Real factor = 1.0f / maxExtent; + const Ogre::Real factor = 3.0f / maxExtent; sn->setScale(factor, factor, factor); Ogre::LogManager::getSingleton().logMessage( "MeshImporterExporter: auto-scaled '" + en->getName() + diff --git a/src/MeshImporterExporter_test.cpp b/src/MeshImporterExporter_test.cpp index dd9fa1fb..694594d6 100644 --- a/src/MeshImporterExporter_test.cpp +++ b/src/MeshImporterExporter_test.cpp @@ -1695,7 +1695,7 @@ TEST(MeshImporterExporterStandaloneTest, FormatFileURI_ShortAliasUppercaseIsAppe // can come in with bounding-box extents below the camera near-clip // distance — they load but render invisible. The importer should detect // this and scale the parent SceneNode so the largest dimension lands -// at ~1 unit. +// at ~3 units. TEST_F(MeshImporterExporterTest, Importer_SubUnitMesh_AutoScalesParentNode) { ASSERT_TRUE(canLoadMeshFiles()) << "GL/hardware buffers required (Xvfb in CI)"; @@ -1730,8 +1730,8 @@ TEST_F(MeshImporterExporterTest, Importer_SubUnitMesh_AutoScalesParentNode) { auto* importedNode = manager->getSceneNodes().last(); const Ogre::Vector3 scale = importedNode->getScale(); - // Auto-scale should bring the largest dim to ~1. With a 0.005-unit - // extent the factor is ~200, but we test loosely (>= 50) to stay + // Auto-scale should bring the largest dim to ~3. With a 0.005-unit + // extent the factor is ~600, but we test loosely (>= 50) to stay // robust against future tweaks to the threshold. EXPECT_GE(scale.x, 50.0f) << "Sub-unit mesh did not get auto-scaled (x)"; EXPECT_GE(scale.y, 50.0f) << "Sub-unit mesh did not get auto-scaled (y)";