Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/MeshImporterExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() +
Expand Down
6 changes: 3 additions & 3 deletions src/MeshImporterExporter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)";

Expand Down Expand Up @@ -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)";
Expand Down
Loading