Feature Request: Z / Depth parameter for ViewObjects

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Feature Request: Z / Depth parameter for ViewObjects

Post by Joel_graff »

So, I've been occasionally annoyed by the lack of rendering order for 2D geometry at the same "depth" (i.e., two overlapping 2D (X/Y) geometries with identical Z-coordinates)

Of course, the easy (and I believe only) solution is to appropriately set the z value of geometry that I want to be above (or below). It's been mentioned somewhat recently here:

https://forum.freecadweb.org/viewtopic.php?t=27128

It would be nice to have a 'z-order' or 'z-depth' attribute on the ViewObject to allow for rendering order / layers at the scenegraph level.

I would think this is manageable easily enough - for example, geometry drawn by Tracker objects can be set to 'ontop'...
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
chrisb
Veteran
Posts: 54150
Joined: Tue Mar 17, 2015 9:14 am

Re: Feature Request: Z / Depth parameter for ViewObjects

Post by chrisb »

"Same level" is for me, well, same level.What do you need this for?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Feature Request: Z / Depth parameter for ViewObjects

Post by sgrogan »

Joel_graff wrote: Fri Apr 19, 2019 5:11 pm I would think this is manageable easily enough - for example, geometry drawn by Tracker objects can be set to 'ontop'...
I don't know the implementation, but sketcher has this. The rendering order for regular, construction, and reference can be set.
"fight the good fight"
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Feature Request: Z / Depth parameter for ViewObjects

Post by Joel_graff »

chrisb wrote: Fri Apr 19, 2019 6:22 pm "Same level" is for me, well, same level.What do you need this for?
If I have 2D geometry which overlaps, they z-fight. It would be nice to be able to specify that one has render priority over the other. In my current use case, I'm creating a tool that manipulates geometry and overlays the 'proposed' geometry on the existing as the user makes changes. I'd like the proposed geometry to always be on top and not have to increment the z-coordinate by 0.01 or something to achieve that.

I've had a few other use cases as well where I've had to fake layers to get things to render properly, though I don't recall them at the moment..

Another other issue is that selection is based on z-depth and will not pick reliably if overlapped geometry is on the same level. In that case, a render depth would also provide the selection mechanism a clue as to which geometry to choose.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Feature Request: Z / Depth parameter for ViewObjects

Post by ickby »

I think this is not so easy to do. You would not want to give the geometry a real z offset, as this could lead to all kind of trouble with accuracy later on. So one would need to manipulate the visuals only. In coin there is a node for that:
https://grey.colorado.edu/coin3d/classS ... ml#details
But according to the documentation it seems to be too limited to be used in freecad, e.g. does not work for lines.
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Feature Request: Z / Depth parameter for ViewObjects

Post by Joel_graff »

ickby wrote: Sat Apr 20, 2019 4:50 am I think this is not so easy to do. You would not want to give the geometry a real z offset, as this could lead to all kind of trouble with accuracy later on. So one would need to manipulate the visuals only. In coin there is a node for that:
https://grey.colorado.edu/coin3d/classS ... ml#details
But according to the documentation it seems to be too limited to be used in freecad, e.g. does not work for lines.
In my use case, offsetting one geometry along the z-axis is not really a bad solution. But that's because I'm working in a 2D context - much like Sketcher. In fact, I'm recreating the Sketcher in a very limited sense. It's certainly a manageable problem, but it's obviously not the ideal way to go about solving it. I can see where it creates problems in a 3D context, though.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
wmayer
Founder
Posts: 20298
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Feature Request: Z / Depth parameter for ViewObjects

Post by wmayer »

The SoPolygonOffset node is already used for the "Flat + lines" rendering mode so that the wireframe is always rendered on top of the faces. This is easy for one object but cannot be done for multiple independent objects.

According to https://en.wikipedia.org/wiki/Z-fighting there are several special use cases where different techniques can be used but there is no general solution that works for every use case.
Post Reply