Repository navigation
cvcGL: setClipChildren follows children coming and going, and the parent's box (stacked on #559) - #561
Merged
Conversation
GraphicsNode::updateClipPlanes built the six face planes with OUTWARD normals
({1,0,0} at max-x, ...), though its own comments said they point inward. VTK
keeps the half-space a clipping plane's normal points into: it builds the plane
equation (n, -n.origin) (vtkAbstractMapper3D::GetClippingPlaneInDataCoords) and
vtkOpenGLPolyDataMapper discards a fragment whose clip distance is negative, so
a point survives where n . (x - origin) >= 0. The GPU volume ray caster clips the
same side (vtkVolumeShaderComposer: clipped where n . (origin - p) > 0). Six
outward planes keep only points outside every face at once -- none -- so
setClipChildren(true) made every child completely invisible.
Negate the six normals and say why in the comment. Document on the declaration
what setClipChildren clips to, and that VTK 9.5's low-memory poly-data mapper
(the GLES3/WebGL2 default) has no clipping-plane support at all, so children
drawn by it are not clipped.
A clipping parent hands every child's mapper its own vtkPlaneCollection (m_clipPlanes), shared. setClipChildren(false) then called RemoveAllClippingPlanes() on each child's mapper, and VTK implements that as ClippingPlanes->RemoveAllItems(): it emptied the parent's collection. From then on updateClipPlanes moved planes that were no longer in it, the next setClipChildren(true) handed every child an empty collection (which applyClipPlanes treats as "remove"), and that parent could never clip again. GeometryNode, GridNode and VolumeNode::applyClipPlanes now detach the collection with SetClippingPlanes(nullptr) instead.
cvcgl_clip_children: a NullGraphicNode box (centred at x = y = 500, away from the origin) with five flat-coloured children -- fully inside, straddling an x/y corner, a tilted quad cut by the z faces, beside the box and above it. - Without GL: the box centre is +half-extent against every plane and a point just past a face is negative against that face's plane only (axis-aligned, and with the parent rotated and moved); every child's mapper holds the planes while clipping is on and none after it goes off; the parent keeps its six planes through an off/on cycle. - Rendered, classic mapper: pixel samples 4 units either side of each face plus the lit area per hue (inside drawn, outside clipped, straddling cut at the face) -- unclipped first so the checks can fail, after clipping goes off, on again, and with the parent rotated and moved while clipping is on. - Rendered, low-memory mapper (forced): VTK's has no clipping planes, so only "not wrongly clipped" is checked; a note prints what it drew. On master it fails 30 of 139 checks (everything invisible under clipping, and the off/on cycle loses the planes). Passes on NVIDIA and llvmpipe. pycvc_gl_clip: the wrapped setClipChildren/getClipChildren, and -- with offscreen GL -- children inside / straddling +x / above +z of a box-outline parent drawn whole / about half / not at all, through an off-and-on cycle, measured by lit area per hue. On master it fails 3 checks.
…ent's box The planes a clipping parent hands its children were set once, on the children present at setClipChildren(true), and re-fitted only when the parent moved: - A child added afterwards was never clipped: addGraphicsChild did not hand it the planes. It does now. - A child removed (reparented, say) kept clipping to its old parent's box. removeGraphicsChild now detaches them. - A parent whose own box changed left the planes on the old box: only updateTransform and setClipChildren re-fitted them. New protected GraphicsNode::ownBoundsChanged() re-fits the bbox outline and the planes, and every node whose box can change reports through it: GeometryNode::setGeometry, NullGraphicNode::setBounds (and its "bounds" state key) and syncBoundsToChildren, VolumeNode / VolSliceNode::setVolume, VolRenNode addVolume / clearVolumes / setVolumeConfig and its state-settings apply (a model_transform written to the tree), LodGraphicsNode when rung 0 comes or goes, and a StreamingGeometryNode's reserved or derived bounds. VolSlice, VolRen, LOD and the derived-bounds path did not refit their bbox outline either; they do now. ownBoundsChanged() runs on the owner thread (VolSlice and VolRen setters come from loader threads), and returns at once when the outline is hidden and the node clips nothing -- a draped link reports a new box from VTK's bounds pass. - A LodGraphicsNode child was never clipped: it draws nothing itself, and its rungs are its children, not the clipping parent's. It now passes the planes it is given to its rungs, including rungs added later (protected static GraphicsNode::applyClipPlanesTo, as applyClipPlanes is protected).
cvcgl_clip_children, without GL: a child added after setClipChildren(true) holds the parent's planes; one clipped from the start is detached when removed (the parent keeping its six) and clipped again when added back; the planes follow NullGraphicNode::setBounds, its "bounds" state key and a group syncing to its children, GeometryNode::setGeometry, VolumeNode and VolSliceNode setVolume, VolRenNode addVolume / setVolumeConfig / a matrix written to its state tree / clearVolumes, and LodGraphicsNode::setBase; a LodGraphicsNode child hands the planes to its rung, to a rung added later, and takes them off and back on with the parent. Rendered on the classic mapper: a child and an LOD child added while clipping is on are cut at the face, a child moved to the root is drawn whole, and growing the box with setBounds moves every cut out with it. checkPlanes takes the expected box. On #559's code it fails 28 of 212 checks; passes on NVIDIA and llvmpipe. pycvc_gl_clip: a child added with sg.add_child_geometry while clipping is on is cut at the -x face (about half drawn).
transfix
added a commit
that referenced
this pull request
Oct 7, 2026
…nates (stacked on #561) (#564) * cvcGL: per-node clip planes in the node's local frame (GraphicsNode::setClipPlanes) * test(cvcGL): cvcgl_clip_planes; per-node planes in pycvc_gl_clip * ariadne(scene): `clip:` on scene nodes — half-spaces in the node's own coordinates * test(ariadne): the `clip:` block — loader, bound-offset sync, realize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#559 made
setClipChildrenclip correctly, but only for the children present when clipping was switched on, and only while the parent's box stayed the same. This PR closes the gaps #559 listed, and two more.What changes
A child added after
setClipChildren(true)is clipped.addGraphicsChildhands it the parent's planes.A removed child is no longer clipped.
removeGraphicsChilddetaches the planes, so a child reparented elsewhere draws whole.The planes follow the parent's box. New protected
GraphicsNode::ownBoundsChanged()re-fits both the bbox outline and the clip planes. Every node whose box can change now reports through it:GeometryNodesetGeometryNullGraphicNodesetBounds(both overloads; also reached from itsboundsstate key),syncBoundsToChildrenVolumeNodesetVolumeVolSliceNodesetVolumeVolRenNodeaddVolume,clearVolumes,setVolumeConfig, and its state-settings apply (avolumes.<i>.matrixwritten to the tree)LodGraphicsNodeStreamingGeometryNodesetDerivedBoundsNow, used byDrapedLinkNode)VolSlice, VolRen, LOD and the derived-bounds path did not refit their bbox outline either; they do now. Light, Axis and Grid nodes have constant boxes.
ownBoundsChanged()runs on the owner thread, because VolSlice and VolRen setters can come from loader threads. It returns at once when the outline is hidden and the node clips nothing. That is the common case, and a draped link reports a new box from VTK's bounds pass. The VolRen apply callback calls it after releasingm_configMutex, sincegetBoundingBox()takes that lock.A
LodGraphicsNodechild is clipped. It draws nothing itself, and its rungs are its own children, so before this they were never clipped. It now passes the planes it is given to its rungs, including rungs added later. This goes through a protected staticGraphicsNode::applyClipPlanesTo, becauseapplyClipPlanesis protected.Tests
cvcgl_clip_childrengoes from 141 to 212 checks.setBounds, every cut moving out with itOn #559's code it fails 28 of 212. With this PR it passes 212/212 on NVIDIA and on llvmpipe.
pycvc_gl_clip: a child added withsg.add_child_geometrywhile clipping is on is cut at the −x face (0.514 of its area drawn).Verification
cvcgl_*suite: 56/56 on NVIDIA and 56/56 on llvmpipe, withCVC_REQUIRE_RENDER=1.pycvc_gl_*,pycvc_ari,pycvc_vtk,pycvc_texture,pycvc_volslice,pycvc_lod): 14/14.git clang-format --diffis clean.ci.ymldoesn't build pycvc, sopycvc_gl_clipwas run locally only.Still not clipped
Children drawn by VTK 9.5's low-memory mapper (the WebGL/GLES default). It has no clipping-plane support at all; the header documents this.