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
281 lines
10 KiB
C++
281 lines
10 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2016 Blender Foundation. */
|
|
|
|
/** \file
|
|
* \ingroup draw
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct GPUBatch;
|
|
struct GPUMaterial;
|
|
struct ModifierData;
|
|
struct Object;
|
|
struct PTCacheEdit;
|
|
struct ParticleSystem;
|
|
struct Volume;
|
|
struct VolumeGrid;
|
|
struct bGPDstroke;
|
|
struct bGPdata;
|
|
|
|
/**
|
|
* Shape resolution level of detail.
|
|
*/
|
|
typedef enum eDRWLevelOfDetail {
|
|
DRW_LOD_LOW = 0,
|
|
DRW_LOD_MEDIUM = 1,
|
|
DRW_LOD_HIGH = 2,
|
|
|
|
DRW_LOD_MAX, /* Max number of level of detail */
|
|
} eDRWLevelOfDetail;
|
|
|
|
void DRW_shape_cache_free(void);
|
|
|
|
/* 3D cursor */
|
|
struct GPUBatch *DRW_cache_cursor_get(bool crosshair_lines);
|
|
|
|
/* Common Shapes */
|
|
struct GPUBatch *DRW_cache_groundline_get(void);
|
|
/* Grid */
|
|
struct GPUBatch *DRW_cache_grid_get(void);
|
|
/**
|
|
* Use this one for rendering full-screen passes. For 3D objects use #DRW_cache_quad_get().
|
|
*/
|
|
struct GPUBatch *DRW_cache_fullscreen_quad_get(void);
|
|
/* Just a regular quad with 4 vertices. */
|
|
struct GPUBatch *DRW_cache_quad_get(void);
|
|
/* Just a regular quad with 4 vertices - wires. */
|
|
struct GPUBatch *DRW_cache_quad_wires_get(void);
|
|
struct GPUBatch *DRW_cache_cube_get(void);
|
|
struct GPUBatch *DRW_cache_normal_arrow_get(void);
|
|
|
|
struct GPUBatch *DRW_cache_sphere_get(eDRWLevelOfDetail level_of_detail);
|
|
|
|
/* Dummy VBOs */
|
|
|
|
struct GPUBatch *DRW_gpencil_dummy_buffer_get(void);
|
|
|
|
/* Common Object */
|
|
|
|
struct GPUBatch *DRW_cache_object_all_edges_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold);
|
|
struct GPUBatch *DRW_cache_object_surface_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob);
|
|
struct GPUBatch **DRW_cache_object_surface_material_get(struct Object *ob,
|
|
struct GPUMaterial **gpumat_array,
|
|
uint gpumat_array_len);
|
|
struct GPUBatch *DRW_cache_object_face_wireframe_get(struct Object *ob);
|
|
int DRW_cache_object_material_count_get(struct Object *ob);
|
|
|
|
/**
|
|
* Returns the vertbuf used by shaded surface batch.
|
|
*/
|
|
struct GPUVertBuf *DRW_cache_object_pos_vertbuf_get(struct Object *ob);
|
|
|
|
/* Empties */
|
|
struct GPUBatch *DRW_cache_plain_axes_get(void);
|
|
struct GPUBatch *DRW_cache_single_arrow_get(void);
|
|
struct GPUBatch *DRW_cache_empty_cube_get(void);
|
|
struct GPUBatch *DRW_cache_circle_get(void);
|
|
struct GPUBatch *DRW_cache_empty_sphere_get(void);
|
|
struct GPUBatch *DRW_cache_empty_cylinder_get(void);
|
|
struct GPUBatch *DRW_cache_empty_cone_get(void);
|
|
struct GPUBatch *DRW_cache_empty_capsule_cap_get(void);
|
|
struct GPUBatch *DRW_cache_empty_capsule_body_get(void);
|
|
|
|
/* Force Field */
|
|
|
|
struct GPUBatch *DRW_cache_field_wind_get(void);
|
|
struct GPUBatch *DRW_cache_field_force_get(void);
|
|
struct GPUBatch *DRW_cache_field_vortex_get(void);
|
|
|
|
/* Screen-aligned circle. */
|
|
|
|
struct GPUBatch *DRW_cache_field_curve_get(void);
|
|
struct GPUBatch *DRW_cache_field_tube_limit_get(void);
|
|
struct GPUBatch *DRW_cache_field_cone_limit_get(void);
|
|
|
|
/* Screen-aligned dashed circle */
|
|
|
|
struct GPUBatch *DRW_cache_field_sphere_limit_get(void);
|
|
|
|
/* Lights */
|
|
|
|
struct GPUBatch *DRW_cache_light_point_lines_get(void);
|
|
struct GPUBatch *DRW_cache_light_sun_lines_get(void);
|
|
struct GPUBatch *DRW_cache_light_spot_lines_get(void);
|
|
struct GPUBatch *DRW_cache_light_area_disk_lines_get(void);
|
|
struct GPUBatch *DRW_cache_light_area_square_lines_get(void);
|
|
struct GPUBatch *DRW_cache_light_spot_volume_get(void);
|
|
|
|
/* Camera */
|
|
|
|
struct GPUBatch *DRW_cache_camera_frame_get(void);
|
|
struct GPUBatch *DRW_cache_camera_volume_get(void);
|
|
struct GPUBatch *DRW_cache_camera_volume_wire_get(void);
|
|
struct GPUBatch *DRW_cache_camera_tria_wire_get(void);
|
|
struct GPUBatch *DRW_cache_camera_tria_get(void);
|
|
struct GPUBatch *DRW_cache_camera_distances_get(void);
|
|
|
|
/* Speaker */
|
|
|
|
struct GPUBatch *DRW_cache_speaker_get(void);
|
|
|
|
/* Probe */
|
|
|
|
struct GPUBatch *DRW_cache_lightprobe_cube_get(void);
|
|
struct GPUBatch *DRW_cache_lightprobe_grid_get(void);
|
|
struct GPUBatch *DRW_cache_lightprobe_planar_get(void);
|
|
|
|
/* Bones */
|
|
|
|
struct GPUBatch *DRW_cache_bone_octahedral_get(void);
|
|
struct GPUBatch *DRW_cache_bone_octahedral_wire_get(void);
|
|
struct GPUBatch *DRW_cache_bone_box_get(void);
|
|
struct GPUBatch *DRW_cache_bone_box_wire_get(void);
|
|
struct GPUBatch *DRW_cache_bone_envelope_solid_get(void);
|
|
struct GPUBatch *DRW_cache_bone_envelope_outline_get(void);
|
|
struct GPUBatch *DRW_cache_bone_point_get(void);
|
|
struct GPUBatch *DRW_cache_bone_point_wire_outline_get(void);
|
|
struct GPUBatch *DRW_cache_bone_stick_get(void);
|
|
struct GPUBatch *DRW_cache_bone_arrows_get(void);
|
|
struct GPUBatch *DRW_cache_bone_dof_sphere_get(void);
|
|
struct GPUBatch *DRW_cache_bone_dof_lines_get(void);
|
|
|
|
/* Meshes */
|
|
|
|
struct GPUBatch *DRW_cache_mesh_all_verts_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_all_edges_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_loose_edges_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold);
|
|
struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_surface_edges_get(struct Object *ob);
|
|
/**
|
|
* Return list of batches with length equal to `max(1, totcol)`.
|
|
*/
|
|
struct GPUBatch **DRW_cache_mesh_surface_shaded_get(struct Object *ob,
|
|
struct GPUMaterial **gpumat_array,
|
|
uint gpumat_array_len);
|
|
/**
|
|
* Return list of batches with length equal to `max(1, totcol)`.
|
|
*/
|
|
struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_surface_vertpaint_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_surface_sculptcolors_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_surface_mesh_analysis_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_face_wireframe_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_mesh_surface_viewer_attribute_get(struct Object *ob);
|
|
|
|
/* Curve */
|
|
|
|
struct GPUBatch *DRW_cache_curve_edge_wire_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_curve_edge_wire_viewer_attribute_get(struct Object *ob);
|
|
|
|
/* edit-mode */
|
|
|
|
struct GPUBatch *DRW_cache_curve_edge_normal_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_curve_edge_overlay_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_curve_vert_overlay_get(struct Object *ob);
|
|
|
|
/* Font */
|
|
|
|
struct GPUBatch *DRW_cache_text_edge_wire_get(struct Object *ob);
|
|
|
|
/* Surface */
|
|
|
|
struct GPUBatch *DRW_cache_surf_edge_wire_get(struct Object *ob);
|
|
|
|
/* Lattice */
|
|
|
|
struct GPUBatch *DRW_cache_lattice_verts_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_lattice_wire_get(struct Object *ob, bool use_weight);
|
|
struct GPUBatch *DRW_cache_lattice_vert_overlay_get(struct Object *ob);
|
|
|
|
/* Particles */
|
|
|
|
struct GPUBatch *DRW_cache_particles_get_hair(struct Object *object,
|
|
struct ParticleSystem *psys,
|
|
struct ModifierData *md);
|
|
struct GPUBatch *DRW_cache_particles_get_dots(struct Object *object, struct ParticleSystem *psys);
|
|
struct GPUBatch *DRW_cache_particles_get_edit_strands(struct Object *object,
|
|
struct ParticleSystem *psys,
|
|
struct PTCacheEdit *edit,
|
|
bool use_weight);
|
|
struct GPUBatch *DRW_cache_particles_get_edit_inner_points(struct Object *object,
|
|
struct ParticleSystem *psys,
|
|
struct PTCacheEdit *edit);
|
|
struct GPUBatch *DRW_cache_particles_get_edit_tip_points(struct Object *object,
|
|
struct ParticleSystem *psys,
|
|
struct PTCacheEdit *edit);
|
|
struct GPUBatch *DRW_cache_particles_get_prim(int type);
|
|
|
|
/* Curves */
|
|
|
|
struct GPUBatch *DRW_cache_curves_surface_get(struct Object *ob);
|
|
struct GPUBatch **DRW_cache_curves_surface_shaded_get(struct Object *ob,
|
|
struct GPUMaterial **gpumat_array,
|
|
uint gpumat_array_len);
|
|
struct GPUBatch *DRW_cache_curves_face_wireframe_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_curves_edge_detection_get(struct Object *ob, bool *r_is_manifold);
|
|
|
|
/* PointCloud */
|
|
|
|
struct GPUBatch *DRW_cache_pointcloud_get_dots(struct Object *obj);
|
|
struct GPUBatch *DRW_cache_pointcloud_surface_get(struct Object *obj);
|
|
struct GPUBatch *DRW_cache_pointcloud_surface_viewer_attribute_get(struct Object *obj);
|
|
|
|
/* Volume */
|
|
|
|
typedef struct DRWVolumeGrid {
|
|
struct DRWVolumeGrid *next, *prev;
|
|
|
|
/* Grid name. */
|
|
char *name;
|
|
|
|
/* 3D texture. */
|
|
struct GPUTexture *texture;
|
|
|
|
/* Transform between 0..1 texture space and object space. */
|
|
float texture_to_object[4][4];
|
|
float object_to_texture[4][4];
|
|
|
|
/* Transform from bounds to texture space. */
|
|
float object_to_bounds[4][4];
|
|
float bounds_to_texture[4][4];
|
|
} DRWVolumeGrid;
|
|
|
|
DRWVolumeGrid *DRW_volume_batch_cache_get_grid(struct Volume *volume,
|
|
const struct VolumeGrid *grid);
|
|
struct GPUBatch *DRW_cache_volume_face_wireframe_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_volume_selection_surface_get(struct Object *ob);
|
|
|
|
/* GPencil */
|
|
|
|
struct GPUBatch *DRW_cache_gpencil_strokes_get(struct Object *ob, int cfra);
|
|
struct GPUBatch *DRW_cache_gpencil_fills_get(struct Object *ob, int cfra);
|
|
struct GPUBatch *DRW_cache_gpencil_edit_lines_get(struct Object *ob, int cfra);
|
|
struct GPUBatch *DRW_cache_gpencil_edit_points_get(struct Object *ob, int cfra);
|
|
struct GPUBatch *DRW_cache_gpencil_edit_curve_handles_get(struct Object *ob, int cfra);
|
|
struct GPUBatch *DRW_cache_gpencil_edit_curve_points_get(struct Object *ob, int cfra);
|
|
struct GPUBatch *DRW_cache_gpencil_sbuffer_stroke_get(struct Object *ob);
|
|
struct GPUBatch *DRW_cache_gpencil_sbuffer_fill_get(struct Object *ob);
|
|
int DRW_gpencil_material_count_get(struct bGPdata *gpd);
|
|
|
|
struct GPUBatch *DRW_cache_gpencil_face_wireframe_get(struct Object *ob);
|
|
|
|
struct bGPDstroke *DRW_cache_gpencil_sbuffer_stroke_data_get(struct Object *ob);
|
|
/**
|
|
* Sbuffer batches are temporary. We need to clear it after drawing.
|
|
*/
|
|
void DRW_cache_gpencil_sbuffer_clear(struct Object *ob);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|