Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-09-28 18:54:59 +0300
committerJacques Lucke <jacques@blender.org>2022-09-28 18:54:59 +0300
commitc55d38f00b8c0e6ae8bda9cc66614afe28fb3fc9 (patch)
tree0fc280eec3e2d0655197afda823de1062f51ea05 /source/blender/makesdna
parent2312915b9620808d29e9b20529684800638d5a2a (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 'source/blender/makesdna')
-rw-r--r--source/blender/makesdna/DNA_node_types.h2
-rw-r--r--source/blender/makesdna/DNA_space_types.h36
-rw-r--r--source/blender/makesdna/DNA_view3d_defaults.h4
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h10
-rw-r--r--source/blender/makesdna/DNA_viewer_path_types.h40
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h8
6 files changed, 65 insertions, 35 deletions
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index dbda24fb8b7..963567133d9 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1598,6 +1598,8 @@ typedef struct NodeGeometryImageTexture {
typedef struct NodeGeometryViewer {
/* eCustomDataType. */
int8_t data_type;
+ /* eAttrDomain. */
+ int8_t domain;
} NodeGeometryViewer;
typedef struct NodeGeometryUVUnwrap {
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 5a819ead4ec..7f0dd2f9be6 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -22,6 +22,7 @@
#include "DNA_vec_types.h"
/* Hum ... Not really nice... but needed for spacebuts. */
#include "DNA_view2d_types.h"
+#include "DNA_viewer_path_types.h"
#ifdef __cplusplus
extern "C" {
@@ -1888,32 +1889,6 @@ typedef struct SpreadsheetColumn {
char *display_name;
} SpreadsheetColumn;
-/**
- * An item in SpaceSpreadsheet.context_path.
- * This is a bases struct for the structs below.
- */
-typedef struct SpreadsheetContext {
- struct SpreadsheetContext *next, *prev;
- /* eSpaceSpreadsheet_ContextType. */
- int type;
- char _pad[4];
-} SpreadsheetContext;
-
-typedef struct SpreadsheetContextObject {
- SpreadsheetContext base;
- struct Object *object;
-} SpreadsheetContextObject;
-
-typedef struct SpreadsheetContextModifier {
- SpreadsheetContext base;
- char *modifier_name;
-} SpreadsheetContextModifier;
-
-typedef struct SpreadsheetContextNode {
- SpreadsheetContext base;
- char *node_name;
-} SpreadsheetContextNode;
-
typedef struct SpaceSpreadsheet {
SpaceLink *next, *prev;
/** Storage of regions for inactive spaces. */
@@ -1930,12 +1905,11 @@ typedef struct SpaceSpreadsheet {
ListBase row_filters;
/**
- * List of #SpreadsheetContext.
- * This is a path to the data that is displayed in the spreadsheet.
- * It can be set explicitly by an action of the user (e.g. clicking the preview icon in a
- * geometry node) or it can be derived from context automatically based on some heuristic.
+ * Context that is currently displayed in the editor. This is usually a either a single object
+ * (in original/evaluated mode) or path to a viewer node. This is retrieved from the workspace
+ * but can be pinned so that it stays constant even when the active node changes.
*/
- ListBase context_path;
+ ViewerPath viewer_path;
/* eSpaceSpreadsheet_FilterFlag. */
uint8_t filter_flag;
diff --git a/source/blender/makesdna/DNA_view3d_defaults.h b/source/blender/makesdna/DNA_view3d_defaults.h
index b2d17b0ea22..c6c93c33086 100644
--- a/source/blender/makesdna/DNA_view3d_defaults.h
+++ b/source/blender/makesdna/DNA_view3d_defaults.h
@@ -36,8 +36,10 @@
#define _DNA_DEFAULT_View3DOverlay \
{ \
+ .flag = V3D_OVERLAY_VIEWER_ATTRIBUTE, \
.wireframe_threshold = 1.0f, \
.wireframe_opacity = 1.0f, \
+ .viewer_attribute_opacity = 0.8f, \
.xray_alpha_bone = 0.5f, \
.bone_wire_alpha = 1.0f, \
.fade_alpha = 0.40f, \
@@ -81,7 +83,7 @@
.gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR | V3D_SHOW_ORTHO_GRID, \
\
.flag = V3D_SELECT_OUTLINE, \
- .flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_ANNOTATION, \
+ .flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_ANNOTATION | V3D_SHOW_VIEWER, \
\
.lens = 50.0f, \
.clip_start = 0.01f, \
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 2b422f9aebf..f3e56ba7039 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -22,6 +22,7 @@ struct wmTimer;
#include "DNA_movieclip_types.h"
#include "DNA_object_types.h"
#include "DNA_view3d_enums.h"
+#include "DNA_viewer_path_types.h"
#ifdef __cplusplus
extern "C" {
@@ -205,6 +206,7 @@ typedef struct View3DOverlay {
float weight_paint_mode_opacity;
float sculpt_mode_mask_opacity;
float sculpt_mode_face_sets_opacity;
+ float viewer_attribute_opacity;
/** Armature edit/pose mode settings. */
float xray_alpha_bone;
@@ -227,8 +229,6 @@ typedef struct View3DOverlay {
float gpencil_vertex_paint_opacity;
/** Handles display type for curves. */
int handle_display;
-
- char _pad[4];
} View3DOverlay;
/** #View3DOverlay.handle_display */
@@ -348,6 +348,9 @@ typedef struct View3D {
View3DShading shading;
View3DOverlay overlay;
+ /** Path to the viewer node that is currently previewed. This is retrieved from the workspace. */
+ ViewerPath viewer_path;
+
/** Runtime evaluation data (keep last). */
View3D_Runtime runtime;
} View3D;
@@ -443,7 +446,7 @@ enum {
/** #View3D.flag2 (int) */
#define V3D_HIDE_OVERLAYS (1 << 2)
-#define V3D_FLAG2_UNUSED_3 (1 << 3) /* cleared */
+#define V3D_SHOW_VIEWER (1 << 3)
#define V3D_SHOW_ANNOTATION (1 << 4)
#define V3D_LOCK_CAMERA (1 << 5)
#define V3D_FLAG2_UNUSED_6 (1 << 6) /* cleared */
@@ -528,6 +531,7 @@ enum {
V3D_OVERLAY_HIDE_OBJECT_ORIGINS = (1 << 10),
V3D_OVERLAY_STATS = (1 << 11),
V3D_OVERLAY_FADE_INACTIVE = (1 << 12),
+ V3D_OVERLAY_VIEWER_ATTRIBUTE = (1 << 13),
};
/** #View3DOverlay.edit_flag */
diff --git a/source/blender/makesdna/DNA_viewer_path_types.h b/source/blender/makesdna/DNA_viewer_path_types.h
new file mode 100644
index 00000000000..8f470b66ca0
--- /dev/null
+++ b/source/blender/makesdna/DNA_viewer_path_types.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#pragma once
+
+#include "BLI_listbase.h"
+#include "BLI_utildefines.h"
+
+struct ID;
+
+typedef enum ViewerPathElemType {
+ VIEWER_PATH_ELEM_TYPE_ID = 0,
+ VIEWER_PATH_ELEM_TYPE_MODIFIER = 1,
+ VIEWER_PATH_ELEM_TYPE_NODE = 2,
+} ViewerPathElemType;
+
+typedef struct ViewerPathElem {
+ struct ViewerPathElem *next, *prev;
+ int type;
+ char _pad[4];
+} ViewerPathElem;
+
+typedef struct IDViewerPathElem {
+ ViewerPathElem base;
+ struct ID *id;
+} IDViewerPathElem;
+
+typedef struct ModifierViewerPathElem {
+ ViewerPathElem base;
+ char *modifier_name;
+} ModifierViewerPathElem;
+
+typedef struct NodeViewerPathElem {
+ ViewerPathElem base;
+ char *node_name;
+} NodeViewerPathElem;
+
+typedef struct ViewerPath {
+ /** List of #ViewerPathElem. */
+ ListBase path;
+} ViewerPath;
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 1a6e19c31ad..e99f317f057 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -10,6 +10,7 @@
#include "DNA_ID.h"
#include "DNA_asset_types.h"
+#include "DNA_viewer_path_types.h"
#ifdef __cplusplus
extern "C" {
@@ -143,6 +144,13 @@ typedef struct WorkSpace {
/** Workspace-wide active asset library, for asset UIs to use (e.g. asset view UI template). The
* Asset Browser has its own and doesn't use this. */
AssetLibraryReference asset_library_ref;
+
+ /**
+ * Ground truth for the currently active viewer node. When a viewer node is activated its path is
+ * set here. Editors can check here for which node is active (currently the node editor,
+ * spreadsheet and viewport do this).
+ */
+ ViewerPath viewer_path;
} WorkSpace;
/**