diff options
author | Jacques Lucke <jacques@blender.org> | 2022-09-28 18:54:59 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-09-28 18:54:59 +0300 |
commit | c55d38f00b8c0e6ae8bda9cc66614afe28fb3fc9 (patch) | |
tree | 0fc280eec3e2d0655197afda823de1062f51ea05 /release | |
parent | 2312915b9620808d29e9b20529684800638d5a2a (diff) |
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_operators/spreadsheet.py | 1 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_spreadsheet.py | 75 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 8 |
3 files changed, 48 insertions, 36 deletions
diff --git a/release/scripts/startup/bl_operators/spreadsheet.py b/release/scripts/startup/bl_operators/spreadsheet.py index 1ba7d2db2fd..aef4231d573 100644 --- a/release/scripts/startup/bl_operators/spreadsheet.py +++ b/release/scripts/startup/bl_operators/spreadsheet.py @@ -32,7 +32,6 @@ class SPREADSHEET_OT_toggle_pin(Operator): def unpin(self, context): space = context.space_data space.is_pinned = False - space.context_path.guess() classes = ( diff --git a/release/scripts/startup/bl_ui/space_spreadsheet.py b/release/scripts/startup/bl_ui/space_spreadsheet.py index 741ad544d67..846582b0142 100644 --- a/release/scripts/startup/bl_ui/space_spreadsheet.py +++ b/release/scripts/startup/bl_ui/space_spreadsheet.py @@ -11,34 +11,37 @@ class SPREADSHEET_HT_header(bpy.types.Header): space = context.space_data layout.template_header() + viewer_path = space.viewer_path.path - if len(space.context_path) == 0: - self.draw_without_context_path(layout) + if len(viewer_path) == 0: + self.draw_without_viewer_path(layout) return - root_context = space.context_path[0] - if root_context.type != 'OBJECT': - self.draw_without_context_path(layout) + root_context = viewer_path[0] + if root_context.type != 'ID': + self.draw_without_viewer_path(layout) return - obj = root_context.object + if not isinstance(root_context.id, bpy.types.Object): + self.draw_without_viewer_path(layout) + return + obj = root_context.id if obj is None: - self.draw_without_context_path(layout) + self.draw_without_viewer_path(layout) return layout.prop(space, "object_eval_state", text="") - context_path = space.context_path if space.object_eval_state == 'ORIGINAL': # Only show first context. - context_path = context_path[:1] - if space.display_context_path_collapsed: - self.draw_collapsed_context_path(context, layout, context_path) + viewer_path = viewer_path[:1] + if space.display_viewer_path_collapsed: + self.draw_collapsed_viewer_path(context, layout, viewer_path) else: - self.draw_full_context_path(context, layout, context_path) + self.draw_full_viewer_path(context, layout, viewer_path) pin_icon = 'PINNED' if space.is_pinned else 'UNPINNED' layout.operator("spreadsheet.toggle_pin", text="", icon=pin_icon, emboss=False) - if space.object_eval_state == 'VIEWER_NODE' and len(context_path) < 3: + if space.object_eval_state == 'VIEWER_NODE' and len(viewer_path) < 3: layout.label(text="No active viewer node", icon='INFO') layout.separator_spacer() @@ -49,50 +52,52 @@ class SPREADSHEET_HT_header(bpy.types.Header): sub.prop(space, "show_only_selected", text="") row.prop(space, "use_filter", toggle=True, icon='FILTER', icon_only=True) - def draw_without_context_path(self, layout): + def draw_without_viewer_path(self, layout): layout.label(text="No active context") - def draw_full_context_path(self, context, layout, context_path): + def draw_full_viewer_path(self, context, layout, viewer_path): space = context.space_data row = layout.row() - for ctx in context_path[:-1]: + for ctx in viewer_path[:-1]: subrow = row.row(align=True) self.draw_spreadsheet_context(subrow, ctx) - self.draw_spreadsheet_context_path_icon(subrow, space) + self.draw_spreadsheet_viewer_path_icon(subrow, space) - self.draw_spreadsheet_context(row, context_path[-1]) + self.draw_spreadsheet_context(row, viewer_path[-1]) - def draw_collapsed_context_path(self, context, layout, context_path): + def draw_collapsed_viewer_path(self, context, layout, viewer_path): space = context.space_data row = layout.row(align=True) - self.draw_spreadsheet_context(row, context_path[0]) - if len(context_path) == 1: + self.draw_spreadsheet_context(row, viewer_path[0]) + if len(viewer_path) == 1: return - self.draw_spreadsheet_context_path_icon(row, space) - if len(context_path) > 2: - self.draw_spreadsheet_context_path_icon(row, space, icon='DOT') - self.draw_spreadsheet_context_path_icon(row, space) - self.draw_spreadsheet_context(row, context_path[-1]) + self.draw_spreadsheet_viewer_path_icon(row, space) + if len(viewer_path) > 2: + self.draw_spreadsheet_viewer_path_icon(row, space, icon='DOT') + self.draw_spreadsheet_viewer_path_icon(row, space) + self.draw_spreadsheet_context(row, viewer_path[-1]) def draw_spreadsheet_context(self, layout, ctx): - if ctx.type == 'OBJECT': - if ctx.object is None: - layout.label(text="<no object>", icon='OBJECT_DATA') + if ctx.type == 'ID': + if ctx.id is not None and isinstance(ctx.id, bpy.types.Object): + layout.label(text=ctx.id.name, icon='OBJECT_DATA') else: - layout.label(text=ctx.object.name, icon='OBJECT_DATA') + layout.label(text="Invalid id") elif ctx.type == 'MODIFIER': layout.label(text=ctx.modifier_name, icon='MODIFIER') elif ctx.type == 'NODE': layout.label(text=ctx.node_name, icon='NODE') - def draw_spreadsheet_context_path_icon(self, layout, space, icon='RIGHTARROW_THIN'): - layout.prop(space, "display_context_path_collapsed", icon_only=True, emboss=False, icon=icon) + def draw_spreadsheet_viewer_path_icon(self, layout, space, icon='RIGHTARROW_THIN'): + layout.prop(space, "display_viewer_path_collapsed", icon_only=True, emboss=False, icon=icon) def selection_filter_available(self, space): - root_context = space.context_path[0] - if root_context.type != 'OBJECT': + root_context = space.viewer_path.path[0] + if root_context.type != 'ID': + return False + if not isinstance(root_context.id, bpy.types.Object): return False - obj = root_context.object + obj = root_context.id if obj is None: return False if obj.type == 'MESH': diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index a687f3c937f..092fae671e0 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1216,6 +1216,7 @@ class VIEW3D_MT_view(Menu): layout.operator("view3d.view_all").center = False layout.operator("view3d.view_persportho", text="Perspective/Orthographic") layout.menu("VIEW3D_MT_view_local") + layout.prop(view, "show_viewer", text="Viewer Node") layout.separator() @@ -6347,6 +6348,13 @@ class VIEW3D_PT_overlay_geometry(Panel): sub.prop(overlay, "wireframe_opacity", text="Opacity") row = col.row(align=True) + row.active = view.show_viewer + row.prop(overlay, "show_viewer_attribute", text="") + subrow = row.row(align=True) + subrow.active = overlay.show_viewer_attribute + subrow.prop(overlay, "viewer_attribute_opacity", text="Viewer Node") + + row = col.row(align=True) # These properties should be always available in the UI for all modes # other than Object. |