Repository navigation
cvcGL: setClipChildren clipped everything (outward planes) and could not be re-enabled - #559
Merged
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.
transfix
pushed a commit
that referenced
this pull request
Oct 7, 2026
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.
GraphicsNode::setClipChildren(true)made every child completely invisible. Found while reviewing #512, and reproduced there with a plain triangle child and with aDrapedLinkNode. Nothing in the repo callssetClipChildrenyet, and nothing tested it. pycvc_gl wraps it (setClipChildren/getClipChildren; onlygetClipPlanesis%ignored).1. The planes faced out of the box
updateClipPlanesbuilt the six face planes with outward normals ({1,0,0}at max-x, and so on), although its comments said they point inward. VTK 9.5 keeps the side a clipping plane's normal points into:vtkAbstractMapper3D::GetClippingPlaneInDataCoordsbuilds the plane equation(n, -n·origin).vtkOpenGLPolyDataMapper::ReplaceShaderClipcomputesdot(clipPlanes[i], vertexMC)and discards the fragment when it is< 0.0. So a point is kept wheren·(x − origin) ≥ 0.vtkVolumeShaderComposertreats a sample as clipped wheredot(n, origin − p) > 0.Six outward planes keep only points outside all six faces at once, which is nothing. Fix: negate the six normals and correct the comments.
2. Turning clipping off emptied the parent's planes
This turned up while writing the test. A clipping parent gives every child's mapper the same
vtkPlaneCollection: its ownm_clipPlanes.setClipChildren(false)then calledRemoveAllClippingPlanes()on each child's mapper, and VTK implements that asClippingPlanes->RemoveAllItems(). That emptied the parent's collection. After that,updateClipPlanesmoved planes that were no longer in it, and the nextsetClipChildren(true)handed every child an empty collection, whichapplyClipPlanestreats as "remove". So after one off/on cycle, that parent could never clip again.Fix:
GeometryNode,GridNodeandVolumeNode::applyClipPlanesnow detach withSetClippingPlanes(nullptr)instead of emptying.Tests
cvcgl_clip_children(src/cvcGL/test, offscreen, llvmpipe-friendly, sharesstreaming_test_util.h). ANullGraphicNodebox 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.vtkOpenGLLowMemoryPolyDataMapperhas no clipping-plane code at all, so only "not wrongly clipped" is checked; a note prints what it drew. The header now says so.pycvc_gl_clip(bindings/pycvc). The wrapped getter and setter. With offscreen GL, a box-outline parent with children inside, straddling +x and above +z, measured by lit area per hue through an off/on cycle: inside 1.000, straddling 0.514, above 0.000.Verification
cvcgl_clip_children: 141/141 pass on NVIDIA (GTX 1650, 595.91) and on Mesa llvmpipe (25.2.8). With master's cvcGL sources it fails 30 of 139: everything is invisible under clipping, and the off/on cycle loses the planes.pycvc_gl_clippasses. Against master'slibcvcGLit fails 3.cvcgl_*suite passes 56/56 on NVIDIA and 56/56 on llvmpipe withCVC_REQUIRE_RENDER=1, includingcvcgl_streaming_overlays.git clang-format --diff origin/masteris clean.ci.ymldoesn't build pycvc, so in CI onlycvcgl_clip_childrenruns.pycvc_gl_clipwas run locally against the deps-vr3 prefix.Notes
DrapedLinkNodeclip test (testLinkClipincvcgl_streaming_overlays.cpp) sets correctly oriented planes directly on the mapper (inwardBox()) because of this bug. Once this lands it could switch to a clipping parent withsetClipChildren(true).setClipChildren(true)is not clipped.addGraphicsChildnever applies the planes.NullGraphicNode::setBounds,GeometryNode::setGeometry) does not refresh the planes. OnlyupdateTransformandsetClipChildrencallupdateClipPlanes.