Skip to content

feat(import): auto-scale sub-unit meshes to ~3 units#539

Merged
fernandotonon merged 1 commit into
masterfrom
feat/import-autoscale-3x
May 16, 2026
Merged

feat(import): auto-scale sub-unit meshes to ~3 units#539
fernandotonon merged 1 commit into
masterfrom
feat/import-autoscale-3x

Conversation

@fernandotonon
Copy link
Copy Markdown
Owner

@fernandotonon fernandotonon commented May 16, 2026

Summary

  • Bump the sub-unit auto-scale target from ~1 unit to ~3 units so mm-scale FBX / photogrammetry imports come in at a more comfortable working size (users were manually scaling up after every such import).
  • Threshold (maxExtent < 0.01) and behavior for sensible-scale assets unchanged.
  • Test comments + expected factor description updated; the existing EXPECT_GE(scale, 50.0f) assertion still holds (factor for 0.005 extent: ~200 → ~600).

Test plan

  • CI: Importer_SubUnitMesh_AutoScalesParentNode still passes.
  • CI: Importer_NormalSizedMesh_KeepsScale1 still passes (corollary — above-threshold meshes are not touched).
  • Manual: load a known sub-unit FBX (e.g. mm-scale photogrammetry asset) and confirm it lands ~3× larger than before.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of very small mesh imports to prevent camera clipping issues. Small meshes are now auto-scaled to a more appropriate target size during import.

Review Change Stack

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) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

The importer's sub-unit mesh auto-scaling logic is adjusted to apply a larger scale factor (3.0f / maxExtent instead of 1.0f / maxExtent) when bounding-box extents are below 0.01, targeting a ~3-unit largest dimension. Test documentation is updated to reflect the new target and scaling rationale.

Changes

Sub-unit mesh auto-scaling adjustment

Layer / File(s) Summary
Auto-scaling scale factor update
src/MeshImporterExporter.cpp
MeshImporterExporter::importer() changes the scale factor from 1.0f / maxExtent to 3.0f / maxExtent for entities with bounding-box extent < 0.01, with the comment updated to target ~3 units instead of ~1.
Test documentation updates
src/MeshImporterExporter_test.cpp
Slice-F3 documentation comment and in-test comments are revised to state the ~3-unit auto-scaling target, estimated scaling-factor (~600), and assertion looseness rationale.

Possibly Related PRs

  • fernandotonon/QtMeshEditor#456: Directly related at the implementation level; both PRs adjust the sub-unit auto-scaling scale factor and target size in MeshImporterExporter::importer().

Poem

🐰 A little mesh once crept so small,
Now scaled by three to stand up tall—
No camera clipping, crisp and clean,
From 0.01 to three, the best we've seen!

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adjusting auto-scaling of sub-unit meshes from ~1 to ~3 units, which matches the primary modification in the code and test files.
Description check ✅ Passed The PR description includes all required template sections (Summary and Technical Details with Features/Bugfixes subsections), providing clear context for the scale factor change, test updates, and validation plan.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/import-autoscale-3x

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/MeshImporterExporter.cpp (1)

2113-2119: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add Sentry breadcrumb for auto-scale import action.

Line 2113 changes import behavior materially, but this significant import-side operation is only logged to Ogre logs; it should also emit a file.import breadcrumb for traceability.

Suggested patch
                 if (maxExtent > 0.0f && maxExtent < 0.01f) {
                     const Ogre::Real factor = 3.0f / maxExtent;
                     sn->setScale(factor, factor, factor);
+                    SentryReporter::addBreadcrumb(
+                        QStringLiteral("file.import"),
+                        QStringLiteral("Auto-scaled sub-unit mesh '%1' by %2 (maxExtent=%3)")
+                            .arg(QString::fromStdString(en->getName()))
+                            .arg(factor)
+                            .arg(maxExtent));
                     Ogre::LogManager::getSingleton().logMessage(
                         "MeshImporterExporter: auto-scaled '" + en->getName() +
                         "' by " + std::to_string(factor) +
                         " (source max-extent " + std::to_string(maxExtent) +
                         " was inside the near-clip plane)");
                 }

As per coding guidelines: "All user-facing actions and significant operations must be tracked with SentryReporter::addBreadcrumb(category, message). Use 'file.import' / 'file.export' for I/O operations."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/MeshImporterExporter.cpp` around lines 2113 - 2119, Auto-scaling during
import is only logged to Ogre but needs a Sentry breadcrumb for traceability;
after computing factor and calling sn->setScale(...) (in the
MeshImporterExporter import path where factor, maxExtent and en->getName() are
available), add a call to SentryReporter::addBreadcrumb("file.import",
<message>) with a concise message similar to the Ogre log (include
en->getName(), factor and maxExtent). Ensure SentryReporter is
included/available in this translation unit and the breadcrumb call mirrors the
existing Ogre log text for consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/MeshImporterExporter.cpp`:
- Around line 2113-2119: Auto-scaling during import is only logged to Ogre but
needs a Sentry breadcrumb for traceability; after computing factor and calling
sn->setScale(...) (in the MeshImporterExporter import path where factor,
maxExtent and en->getName() are available), add a call to
SentryReporter::addBreadcrumb("file.import", <message>) with a concise message
similar to the Ogre log (include en->getName(), factor and maxExtent). Ensure
SentryReporter is included/available in this translation unit and the breadcrumb
call mirrors the existing Ogre log text for consistency.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4b84b122-1d8e-4864-99fa-91bd2221507c

📥 Commits

Reviewing files that changed from the base of the PR and between faae230 and 67aede0.

📒 Files selected for processing (2)
  • src/MeshImporterExporter.cpp
  • src/MeshImporterExporter_test.cpp

@sonarqubecloud
Copy link
Copy Markdown

@fernandotonon fernandotonon merged commit 645c461 into master May 16, 2026
20 checks passed
@fernandotonon fernandotonon deleted the feat/import-autoscale-3x branch May 16, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant