Skip to content

ofNode transform version + ofCamera cached frustum planes - #8690

Closed
danoli3 wants to merge 1 commit into
openframeworks:masterfrom
danoli3:core-camera-frustum-cache
Closed

danoli3 wants to merge 1 commit into
openframeworks:masterfrom
danoli3:core-camera-frustum-cache

Conversation

@danoli3

@danoli3 danoli3 commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Adds a monotonic transform version to ofNode and cached frustum planes to ofCamera so external consumers (culling, LOD, octree, shadows) can skip work when nothing moved.

// ofNode
uint64_t getTransformVersion() const;
uint64_t getGlobalTransformVersion() const;

// ofCamera
const std::array<glm::vec4, 6> & getFrustumPlanes(const ofRectangle & viewport) const;
const std::array<glm::vec4, 6> & getFrustumPlanes() const;
uint64_t getFrustumVersion() const;

Six inward-facing unit-normal planes (L, R, B, T, N, F), extracted from the view-projection matrix and cached keyed on (paramsVersion, globalTransformVersion, viewport). Pure additions.

ofNode gains a monotonic transform version so external caches (frustum
culling, LOD, octree rebuilds, shadow passes) can tell when a node's
matrices have been invalidated without recomputing them:

- getTransformVersion()        -- bumps on any local change
- getGlobalTransformVersion()  -- walks the parent chain and combines

The counter is bumped in createMatrix() (the single chokepoint for local
transform updates), in setParent / clearParent, in the existing
onParent*Changed listeners (so a direct parent change is observable), and
in copy / move / assignment.

ofCamera gains cached frustum planes extracted from its view-projection
matrix (Gribb-Hartmann), lazily rebuilt only when inputs change:

- getFrustumPlanes(viewport)   -- six normalised inward-facing planes:
                                   left, right, bottom, top, near, far
- getFrustumPlanes()           -- uses getViewport()
- getFrustumVersion()          -- cheap probe for change detection
                                   (params + global transform version)

Projection setters (setFov, setNearClip, setFarClip, setLensOffset,
setForceAspectRatio, setVFlip, enableOrtho, disableOrtho, setupPerspective,
and the lazy near/far fill in calcClipPlanes) bump an internal params
version; any node-transform change is picked up via getGlobalTransformVersion().
The cache keyed on (paramsVersion, globalTransformVersion, viewport)
rebuilds when any of those three change.

Addresses the common culling-system pattern of recomputing frustum planes
and per-node world AABBs every frame regardless of whether anything moved;
see the ofxEnTT CullingSystem addon.
@danoli3 danoli3 closed this Nov 26, 2026
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