Fix crash importing skinned meshes without animations (e.g. bandit.fbx) - #237
Conversation
The skeleton was only created when scene->HasAnimations(), but a mesh can be fully skinned (bones + weights) without any animation tracks. When MeshProcessor tried to call skeleton->getBone() for a null skeleton, the result was a SIGSEGV. Fix: create the skeleton whenever any mesh in the scene has bones, not just when animations are present. Also add a hasBone() guard in MeshProcessor so a missing bone entry never hard-crashes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughSkeleton and binding-pose creation was decoupled from animation presence: skeletons are now created when a scene has animations or skinned meshes with bones. Animation track processing remains executed only when Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Assimp/Importer.cpp`:
- Around line 78-85: The skeleton member/variable must be cleared before the
conditional creation to avoid carrying a previous skeleton into MeshProcessor;
update Importer.cpp to reset skeleton (e.g., set to nullptr/clear) immediately
before the if(hasBones || scene->HasAnimations()) block so that when the block
is skipped MeshProcessor meshProcessor(skeleton) sees an empty/null skeleton and
no stale skeleton is bound; ensure references to
Ogre::SkeletonManager::getSingleton().create(modelName+".skeleton", ...) remain
unchanged and only the pre-check reset of skeleton is added.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 56c21850-e1e8-42cc-a801-3e47b650fbef
📒 Files selected for processing (2)
src/Assimp/Importer.cppsrc/Assimp/MeshProcessor.cpp
| // Process the skeleton whenever the scene has bones (skinned mesh) or animations. | ||
| // A mesh can be skinned without having any animations (e.g. a rigged bind-pose). | ||
| bool hasBones = false; | ||
| for(unsigned i = 0; i < scene->mNumMeshes && !hasBones; ++i) | ||
| hasBones = scene->mMeshes[i]->mNumBones > 0; | ||
|
|
||
| if(hasBones || scene->HasAnimations()) { | ||
| skeleton = Ogre::SkeletonManager::getSingleton().create(modelName+".skeleton", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true); |
There was a problem hiding this comment.
Reset skeleton before conditional creation to avoid stale state across imports.
When this block is skipped (no bones and no animations), skeleton can keep a previous value and still flow into Line 103 (MeshProcessor meshProcessor(skeleton)), then be rebound at mesh creation time. That can incorrectly link a static mesh to an old skeleton.
Proposed fix
Ogre::MeshPtr AssimpToOgreImporter::loadModel(const std::string& path, bool convertToLeftHanded, unsigned int additionalFlags) {
+ // Clear importer state from previous loads.
+ skeleton = Ogre::SkeletonPtr();
+
importer.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);
@@
- if(hasBones || scene->HasAnimations()) {
+ if(hasBones || scene->HasAnimations()) {
skeleton = Ogre::SkeletonManager::getSingleton().create(modelName+".skeleton", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/Assimp/Importer.cpp` around lines 78 - 85, The skeleton member/variable
must be cleared before the conditional creation to avoid carrying a previous
skeleton into MeshProcessor; update Importer.cpp to reset skeleton (e.g., set to
nullptr/clear) immediately before the if(hasBones || scene->HasAnimations())
block so that when the block is skipped MeshProcessor meshProcessor(skeleton)
sees an empty/null skeleton and no stale skeleton is bound; ensure references to
Ogre::SkeletonManager::getSingleton().create(modelName+".skeleton", ...) remain
unchanged and only the pre-check reset of skeleton is added.
|



Summary
Importer.cpponly created the Ogre skeleton whenscene->HasAnimations(), so a bind-pose-only rigged model leftskeleton = nullptr.MeshProcessor::processMeshthen calledskeleton->getBone()on that null pointer.mNumBones > 0), not just when animations are present. Also added ahasBone()guard inMeshProcessoras a safety net.Test plan
bandit.fbx(116-bone skinned character, no animations) — should succeed🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Chores