Skip to content

quads chunk 2: GPU upload n-gon triangulation (re-targeted) - #330

Merged
fernandotonon merged 2 commits into
feat/quadsfrom
feat/quads-2-gpu-upload
Apr 28, 2026
Merged

quads chunk 2: GPU upload n-gon triangulation (re-targeted)#330
fernandotonon merged 2 commits into
feat/quadsfrom
feat/quads-2-gpu-upload

Conversation

@fernandotonon

Copy link
Copy Markdown
Owner

Summary

Chunk 2 of the quad migration (#326). Re-opening from #328 because that PR auto-closed when its base branch (feat/quads-1-foundation) was deleted on chunk 1's merge.

Same content as the (now-closed) #328 — fully green CI on the previous run. No code changes since.

Wires EditableSubMesh::faces through the GPU upload path so quad-bearing meshes render correctly via fan-triangulation. No behavior change for triangle-only meshes.

Changes

  • buildSubMeshBuffers re-triangulates faces into triangles defensively when faces is non-empty.
  • recalculateNormals / recalculateNormalsFlat re-sync triangles from faces before accumulating.
  • New syncTriangulation() and totalFaceCount() free functions (kept off EditableMesh to stay under Sonar's 35-method ceiling).

Tests

+5 standalone tests; full suite stays green (was 173 + 18 → now 191 with chunk 1).

Closes

Re-opens #328 (auto-closed due to base-branch deletion). Towards #326.

🤖 Generated with Claude Code

fernandotonon and others added 2 commits April 28, 2026 02:48
Wires the EditableSubMesh::faces (n-gon canonical) field through the
GPU upload path so quad-bearing meshes render correctly via fan-
triangulation. Triangle-only meshes are byte-identical before/after.

Changes:
  - buildSubMeshBuffers (the GPU upload entry point used by
    resizeEntityBuffers and createNewMesh) re-triangulates faces into
    triangles defensively when faces is non-empty, so the index buffer
    always matches the live face data even if the caller forgot to
    sync. Triangle-only submeshes pay zero overhead — no copy, no
    extra work.
  - recalculateNormals / recalculateNormalsFlat call triangulateFaces
    first when faces is canonical, so vertex normals always reflect
    the current polygon geometry.
  - New EditableMesh::syncTriangulation() helper for callers that
    mutate faces directly and want to publish the change to triangles.
  - New EditableMesh::totalFaceCount() for the n-gon-aware caller —
    reports faces.size() when n-gons are present, falls back to
    triangles.size() for legacy submeshes.

Tests (+5):
  - syncTriangulation fan-triangulates a quad face into 2 triangles.
  - syncTriangulation is a no-op on triangle-only submeshes.
  - totalFaceCount falls back to triangle count for legacy submeshes
    and reports n-gon count when faces is canonical.
  - recalculateNormals re-syncs triangles from faces and produces
    correct vertex normals on a quad-only mesh.

No behavior change for triangle-only meshes — chunk 1 + chunk 2 keep
the existing path byte-identical. Quad meshes can now render correctly
end-to-end (limited by importers, which still triangulate at load —
that's chunk 3).

Towards #326.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- src/EditableMesh.cpp:355,433: explicit `static_cast<uint32_t>` for
  `size_t` → Ogre's `vertexCount` / `indexCount` (uint32). The
  conversion was implicit pre-existing, but Sonar treats my edits to
  those lines as new and flags the precision-loss warning.
- src/EditableMesh.h: convert the new `totalFaceCount()` and
  `syncTriangulation()` from member methods to free functions taking
  `std::vector<EditableSubMesh>&`. The class hit Sonar's 35-method
  ceiling; free functions are the natural pattern here anyway since
  they mirror the existing `triangulateFaces(EditableSubMesh&)` and
  `promoteTrianglesToFaces(EditableSubMesh&)` helpers.
- Tests updated to call the free-function versions.

No behavior change; same 191 tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f7810686-b917-47e3-bd98-11693823ba4a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/quads-2-gpu-upload

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.

@sonarqubecloud

Copy link
Copy Markdown

@fernandotonon
fernandotonon merged commit 86d073e into feat/quads Apr 28, 2026
51 checks passed
@fernandotonon
fernandotonon deleted the feat/quads-2-gpu-upload branch April 28, 2026 15:03
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