Skip to content

Sketcher: vertex picking broken due to depth buffer (vertical / horizontal lines) #1105

@supersinapsis

Description

@supersinapsis

Is there an existing issue for this?

  • I have searched the existing issues

Version

0.21 (Development)

Full version info

Hi RealThunder,

there is a regression in Sketcher vertex picking.

Problem:
Vertices are not reliably pickable unless the sketch is rotated in perspective.
Typical cases:
- Vertical or oblique lines: only the upper vertex can be selected
- Horizontal lines: neither vertex is pickable
- Rotating the view makes the “missing” vertex selectable

This happens with:
- OpenGL enabled
- OpenGL disabled (software renderer)
So it is not a driver issue.

This strongly indicates a Z-buffer / depth-test interaction.

Location:
src/Mod/Sketcher/Gui/ViewProviderSketch.cpp

Root cause:
Vertex markers (SoMarkerSet) are depth-tested against sketch geometry,
so vertices behind or coplanar with edges fail picking.

Proposed fix:
Disable depth test for vertex markers and force SHAPE picking.

Patch (minimal):


#include <Inventor/nodes/SoDepthBuffer.h>
#include <Inventor/nodes/SoPickStyle.h>

// before PointSet creation
SoDepthBuffer* pcDepth = new SoDepthBuffer;
pcDepth->test.setValue(false);
pointsRoot->addChild(pcDepth);

SoPickStyle* pickStyle = new SoPickStyle;
pickStyle->style = SoPickStyle::SHAPE;
pointsRoot->addChild(pickStyle);

edit->PointSet = new SoMarkerSet;

Subproject(s) affected?

None

Problem description

python3 -c "
path = '/media/alejo/446GB/FreeCad2025/FreeCAD-LinkDaily/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp'
with open(path, 'r') as f: content = f.read()

1. Insertar el Header (encabezado) necesario si no existe

if 'SoDepthBuffer.h' not in content:
content = content.replace('# include <Inventor/nodes/SoMarkerSet.h>', '# include <Inventor/nodes/SoMarkerSet.h>\n# include <Inventor/nodes/SoDepthBuffer.h>')

2. Definir el bloque de reparación (Fix Z-Buffer)

old = ' edit->PointSet = new SoMarkerSet;'
new = ' SoDepthBuffer * pcDepth = new SoDepthBuffer;\n pcDepth->test.setValue(false);\n pointsRoot->addChild(pcDepth);\n\n SoPickStyle* pickStyle = new SoPickStyle;\n pickStyle->style = SoPickStyle::SHAPE;\n pointsRoot->addChild(pickStyle);\n\n edit->PointSet = new SoMarkerSet;'

3. Aplicar el cambio solo si no se aplicó antes (evita duplicados)

if 'pcDepth->test.setValue(false)' not in content:
with open(path, 'w') as f: f.write(content.replace(old, new, 1))
print('✅ Reparación de vértices aplicada a LinkDaily.')
else:
print('⚠️ La reparación ya estaba aplicada anteriormente.')
"

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions