Skip to content

Fix incorrect FBX connection order - #6421

Merged
kimkulling merged 2 commits into
assimp:masterfrom
mwpenny:fbx-connection-fix
Dec 11, 2025
Merged

kimkulling merged 2 commits into
assimp:masterfrom
mwpenny:fbx-connection-fix

Conversation

@mwpenny

@mwpenny mwpenny commented Dec 10, 2025 •

Copy link
Copy Markdown
Contributor

PR #6120 fixed a macro which previously prevented std::unordered_multimap from being used during FBX import when compiled with GCC (50e661a).

This caused FBX::Element properties to be stored in arbitrary order, but the order of connections ("C" properties) in FBX files matters.

  • Insertion order is computed while iterating the map
  • Stored insertion order is how Connections are compared
  • The comparison function is used to sort the Connections during retrieval

The main issue I saw was incorrect materials.

This PR changes the type of FBX::ElementMap to always use std::multimap (i.e., ordered). This was the behavior for years under GCC while the broken macro was in use. Unordered containers are still used elsewhere in the FBX importer to benefit from their performance.

Another way to fix this, for example, is to store the ordering in the Element. Let me know if you prefer that. I erred on the side of simplicity and history.

Summary by CodeRabbit

  • Refactor
    • Updated internal data structure implementation for FBX asset parsing to improve consistency and performance characteristics.

✏️ Tip: You can customize this high-level summary in your review settings.

PR assimp#6120 fixed a macro which previously prevented std::unordered_multimap
from being used during FBX import when compiled with GCC.

This caused FBX::Element properties to be stored in arbitrary order,
but the order of connections ("C" properties) in FBX files matters.
The main issue I saw was incorrect materials.

This changes the type of FBX::ElementMap to always use std::multimap
(i.e., ordered). This was the behavior for years under GCC while the
broken macro was in use. Unordered containers are still used elsewhere
in the FBX importer to benefit from their performance.
@coderabbitai

coderabbitai Bot commented Dec 10, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The change replaces a custom unordered multimap type with the standard ordered multimap in the FBX parser's public type alias. This modifies iteration order guarantees and lookup performance characteristics for Element storage within Scope, while preserving the public API surface.

Changes

Cohort / File(s) Summary
FBX Parser Type Alias Update
code/AssetLib/FBX/FBXParser.h
Changed ElementMap public type alias from std::fbx_unordered_multimap<std::string, Element*> to std::multimap<std::string, Element*>, replacing unordered with ordered multimap container

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that code depending on this type alias handles ordered iteration correctly (e.g., any code relying on unordered traversal order)
  • Confirm that the performance trade-off from unordered to ordered lookup is acceptable in the FBX parsing context
  • Check that equal_range behavior expectations align with the multimap ordering semantics

Poem

🐰 Order emerges from chaos old,
Unordered maps now sorted, bold,
FBX elements in line they stand,
A tidy multimap across the land! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix incorrect FBX connection order' accurately describes the main change: addressing incorrect ordering of FBX connections by switching ElementMap from unordered_multimap back to ordered multimap.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
code/AssetLib/FBX/FBXParser.h (1)

67-69: Switch to std::multimap correctly restores deterministic element ordering

Using std::multimap<std::string, Element*> for ElementMap looks consistent with the intent to have stable, deterministic iteration order for Scope::elements. Existing usages (find, equal_range, iteration in FindElementCaseInsensitive) remain valid; the only change is the expected O(log n) lookup complexity, which seems like a reasonable tradeoff given the ordering bug you’re fixing.

SonarCloud’s suggestion about a transparent comparator could be addressed like:

using ElementMap = std::multimap<std::string, Element*, std::less<>>;

This would allow heterogeneous lookup (e.g., const char*, std::string_view) without constructing a std::string. However, since all current lookups here use const std::string&, the practical benefit is minimal, and adopting std::less<> assumes a C++14-or-newer standard library. I’d treat this as an optional follow‑up only if the project’s baseline and other FBX containers already rely on transparent comparators.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7538628 and 0c08cef.

📒 Files selected for processing (1)
  • code/AssetLib/FBX/FBXParser.h (1 hunks)
🧰 Additional context used
🪛 GitHub Check: SonarCloud Code Analysis
code/AssetLib/FBX/FBXParser.h

[warning] 67-67: Use the transparent comparator "std::less<>" with this associative string container.

See more on https://sonarcloud.io/project/issues?id=assimp_assimp&issues=AZsGSjABcR2-lG0kNVqj&open=AZsGSjABcR2-lG0kNVqj&pullRequest=6421

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: ubuntu-latest-clang++-build-and-test
  • GitHub Check: ubuntu-latest-g++-build-and-test
  • GitHub Check: macos-latest-clang++-build-and-test
  • GitHub Check: windows-hunter-latest-cl.exe-build-and-test
  • GitHub Check: windows-latest-clang.exe-build-and-test
  • GitHub Check: windows-latest-cl.exe-build-and-test
  • GitHub Check: adress-sanitizer
  • GitHub Check: undefined-behavior-sanitizer
  • GitHub Check: Fuzzing

@sonarqubecloud

sonarqubecloud Bot commented Dec 11, 2025 •

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
1 Accepted issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@kimkulling
kimkulling merged commit e3b13a4 into assimp:master Dec 11, 2025
@kimkulling

Copy link
Copy Markdown
Member

Merged, thanks a lot for your contribution.

@kimkulling kimkulling added Bug Global flag to mark a deviation from expected behaviour FBX Bugs related to the FBX format labels Dec 11, 2025
@mwpenny

mwpenny commented Dec 11, 2025

Copy link
Copy Markdown
Contributor Author

Happy to help. Thanks for the fast response, and for this project.

Question: is there a rough release schedule/cadence documented somewhere? Or a list of remaining work before the next release? I took a look at the DevOps backlog board but couldn't find it.

There has been a lot of great work since the previous release. It would be nice to be able to get the latest improvements and fixes via a package manager. That would also help with downstream build automation for library consumers.

Thanks again.

kimkulling added a commit that referenced this pull request Jul 1, 2026
PR #6120 fixed a macro which previously prevented std::unordered_multimap
from being used during FBX import when compiled with GCC.

This caused FBX::Element properties to be stored in arbitrary order,
but the order of connections ("C" properties) in FBX files matters.
The main issue I saw was incorrect materials.

This changes the type of FBX::ElementMap to always use std::multimap
(i.e., ordered). This was the behavior for years under GCC while the
broken macro was in use. Unordered containers are still used elsewhere
in the FBX importer to benefit from their performance.

Co-authored-by: Kim Kulling <[email protected]>
tkluge-fender pushed a commit to cclsoftware/assimp that referenced this pull request Jul 28, 2026
PR assimp#6120 fixed a macro which previously prevented std::unordered_multimap
from being used during FBX import when compiled with GCC.

This caused FBX::Element properties to be stored in arbitrary order,
but the order of connections ("C" properties) in FBX files matters.
The main issue I saw was incorrect materials.

This changes the type of FBX::ElementMap to always use std::multimap
(i.e., ordered). This was the behavior for years under GCC while the
broken macro was in use. Unordered containers are still used elsewhere
in the FBX importer to benefit from their performance.

Co-authored-by: Kim Kulling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Global flag to mark a deviation from expected behaviour FBX Bugs related to the FBX format

Projects

Development

Successfully merging this pull request may close these issues.

2 participants