Skip to content

Gui: prepare 3D rendering and visual test infrastructure for new renderer#31187

Merged
Lgt2x merged 37 commits into
FreeCAD:mainfrom
tritao:prep-render-backend-groundwork
Jul 19, 2026
Merged

Gui: prepare 3D rendering and visual test infrastructure for new renderer#31187
Lgt2x merged 37 commits into
FreeCAD:mainfrom
tritao:prep-render-backend-groundwork

Conversation

@tritao

@tritao tritao commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This PR reworks FreeCAD’s current Coin-based renderer and visual test suite around a cleaner retained-mode foundation. Scene construction, screen-space geometry, mesh render data, framebuffer capture, and teardown are made more explicit, deterministic, and reusable while preserving the existing rendering path.

The result gives the follow-up PR a smaller and clearer integration surface for adding the new renderer, with less duplicated scene preparation and stronger visual-test contracts.

Viewer and framebuffer capture

  • Separates viewer-owned presentation from the GL render-action scene path.
  • Adds renderToImage() for controlled raster capture.
  • Keeps grabFramebuffer() for live viewport capture.
  • Makes viewer lighting optional during controlled captures.
  • Fixes QImage ownership transfer in the Python wrapper.
  • Adds explicit framebuffer behavior contracts.

Retained scene-graph infrastructure

  • Introduces SoFCScreenSpaceGroup for shared screen-space scene preparation.

  • Modernizes retained geometry for:

    • axis cross and NaviCube presentation
    • labels and datum labels
    • spline control points
    • polygon overlays
    • color bars and legends
  • Extracts TranslateManip.

  • Removes the unused SoTextLabel node.

  • Makes background, label, annotation, placement-indicator, and NaviCube rendering more deterministic.

  • Separates bounding-box preparation and screen-space geometry state from rendering state.

Visual test infrastructure

  • Switches Coin snapshots to capture through the live viewer.
  • Centralizes snapshot fixtures, camera policies, framing, and baseline configuration.
  • Makes scene construction deterministic for screen-space and overlay nodes.
  • Refreshes the Coin baselines for the stabilized capture path.
  • Adds coverage for core overlay, transparency, selection, material, label, and mesh-rendering behavior.
  • Ensures visual sources can be built with the required material resources available.

Teardown and lifecycle handling

  • Drains deferred GUI deletions before Python shutdown.
  • Makes viewer and scene teardown more deterministic.
  • Ensures retained mesh geometry is invalidated and refreshed when source data changes.

Scope

This PR establishes the retained scene and visual-testing infrastructure needed by the next renderer integration. It does not add the new renderer or bump Coin.

This work is part of the broader rendering and selection modernization effort tracked in FreeCAD/FPA-grant-proposals#35.

@github-actions github-actions Bot added Status: Needs triage Missing triage Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD Mod: Test Related to the Test Workbench Mod: Measurement Regarding Measurment functionality Language: Python Language: C++ labels Jul 8, 2026
@maxwxyz maxwxyz added Type: Feature FR for improvements or new features Requires: Testing The PR needs testing by users and developers Requires: Code Review The PR requires code to be reviewed and removed Status: Needs triage Missing triage labels Jul 8, 2026
@maxwxyz maxwxyz moved this from Queue to Merge Meeting in Merge Queue Jul 8, 2026
@maxwxyz maxwxyz added this to the 26.3 milestone Jul 8, 2026
@tritao
tritao force-pushed the prep-render-backend-groundwork branch 10 times, most recently from 6c44bbd to 4ae07ce Compare July 11, 2026 09:32
@tritao
tritao marked this pull request as ready for review July 11, 2026 09:33
@tritao
tritao force-pushed the prep-render-backend-groundwork branch 4 times, most recently from 4289cd3 to beb482c Compare July 11, 2026 12:14
@tritao
tritao force-pushed the prep-render-backend-groundwork branch from 90d3f62 to 66907e0 Compare July 18, 2026 19:16
@tritao

tritao commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Did one more audit on this and found some minor issues worth fixing, sent another push with these:

  • Fixed the asymmetric negative ticks in zero-based color scales and added coverage for the complete sequence.
  • Made the snapshot size explicit so the requested 512×512 dimensions are always honored.
  • Separated the So3DAnnotation fixture transforms so the plate, box, and marker no longer affect each other, then refreshed the baseline.

@pierreporte

Copy link
Copy Markdown

What should I test?

@Lgt2x

Lgt2x commented Jul 18, 2026

Copy link
Copy Markdown
Member

@pierreporte see above #31187 (review) :)

@pierreporte

Copy link
Copy Markdown

I haven’t seen any visual problem with things listed in #31187 (review).

Quite a lot of coin messages in the terminale that do not appear in the weekly:

  • Coin warning in SoDB::enableRealTimeSensor(): realtime sensor already on (right at startup)
  • Coin warning in SbRotation::setValue(): Quarternion has zero length => undefined rotation. (a lot of those)
  • Coin error in SoGroup::removeChild(): tried to remove non-existent child 0x6510e893e4c0 (Separator) (there are a ton of these, with different addresses)

@tritao

tritao commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for testing.

Those are fixed by #31112

@maxwxyz maxwxyz 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.

Noticed no issues

@maxwxyz maxwxyz added Approved: Tested The PR was manually tested and approved and removed Requires: Testing The PR needs testing by users and developers labels Jul 19, 2026
@maxwxyz maxwxyz moved this from Merge Meeting to Approved in Merge Queue Jul 19, 2026
@Lgt2x

Lgt2x commented Jul 19, 2026

Copy link
Copy Markdown
Member

Good to go then! Individual commits make sense, will not squash on merge

@Lgt2x
Lgt2x merged commit 76f294b into FreeCAD:main Jul 19, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in Merge Queue Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved: CI Label to start all CI workflows Approved: Code Quality The PR was checked for code quality and approved Approved: Tested The PR was manually tested and approved Language: C++ Language: Python Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD Mod: Measurement Regarding Measurment functionality Mod: Test Related to the Test Workbench Type: Feature FR for improvements or new features

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants