[codex] Improve mesh segmentation post-processing#780
Conversation
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. 📝 WalkthroughWalkthrough
ChangesRig-prior labels wired into segmentation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3b13a5474
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (bp >= 0 && bp < count) | ||
| labels[v] = bp; |
There was a problem hiding this comment.
Do not treat unresolved rig labels as hints
In meshes with a skeleton but sparse or missing bone assignments, AutoRig::rigPriorPartLabels returns a non-empty vector and leaves unassigned vertices as Unknown (0). Since the CLI/MCP/Edit paths now pass that vector into predict, this condition accepts 0 as an authoritative bone hint and overwrites the model/geometric prediction with Unknown; with --no-model or a missing model, a sparsely weighted skinned mesh can therefore come back mostly/all Unknown instead of retaining spatial labels. Ignore the Unknown sentinel here (or only pass sufficiently resolved labels) so unresolved vertices keep the predictor result.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/MeshSegmenter.cpp (1)
123-133: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winDeduplicate topology neighbours before voting.
neighbours[v]can contain the same adjacent vertex multiple times across shared triangles, so smoothing becomes tessellation-weighted instead of a majority over adjacent vertices.Proposed fix
for (int i = 0; i + 2 < indexCount; i += 3) { const int a = static_cast<int>(indices[i]); const int b = static_cast<int>(indices[i + 1]); const int c = static_cast<int>(indices[i + 2]); if (a < 0 || b < 0 || c < 0 || a >= vertexCount || b >= vertexCount || c >= vertexCount) continue; neighbours[a].push_back(b); neighbours[a].push_back(c); neighbours[b].push_back(a); neighbours[b].push_back(c); neighbours[c].push_back(a); neighbours[c].push_back(b); } + for (auto& ns : neighbours) { + std::sort(ns.begin(), ns.end()); + ns.erase(std::unique(ns.begin(), ns.end()), ns.end()); + }🤖 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/MeshSegmenter.cpp` around lines 123 - 133, The neighbour accumulation in MeshSegmenter::segmentMesh currently adds duplicate adjacent vertices into neighbours[v], which makes the smoothing vote depend on tessellation density instead of unique adjacency. Deduplicate each vertex’s neighbour list before the voting step in the same MeshSegmenter logic, using a per-vertex set or by uniquing the accumulated neighbours after triangle traversal, while keeping the rest of the segmentation flow unchanged.
🤖 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.
Nitpick comments:
In `@src/MeshSegmenter.cpp`:
- Around line 123-133: The neighbour accumulation in MeshSegmenter::segmentMesh
currently adds duplicate adjacent vertices into neighbours[v], which makes the
smoothing vote depend on tessellation density instead of unique adjacency.
Deduplicate each vertex’s neighbour list before the voting step in the same
MeshSegmenter logic, using a per-vertex set or by uniquing the accumulated
neighbours after triangle traversal, while keeping the rest of the segmentation
flow unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 614afa73-6acc-486f-ac8e-9f5d969346c4
📒 Files selected for processing (4)
src/CLIPipeline.cppsrc/EditModeController.cppsrc/MCPServer.cppsrc/MeshSegmenter.cpp
|



Summary
This PR improves mesh part segmentation quality without changing or retraining the model weights.
It updates the inference/post-processing harness to:
NverticesWhy
The previous segmentation path often produced fragmented or incomplete regions. On unrigged meshes, a sampling/scatter issue could leave large parts of the mesh with weak/default labels. The topology smoothing pass makes selections more coherent, which improves whole-part selection even when no skeleton is available.
This does not solve every semantic mistake. For example, adjacent regions such as head/arm or belly/leg can still merge when model confidence is weak. That should be addressed in a follow-up with stronger boundary/geodesic constraints or retrained weights.
Validation
QtMeshEditorlocally in the x86_64 macOS build tree.Summary by CodeRabbit
New Features
Bug Fixes
Chores