From 271f34f77e056611e5e227b60823dd94f76340df Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 14 Jul 2021 11:16:43 +0200 Subject: Geometry Nodes: initial socket inspection Socket inspection helps with debugging a geometry node group. Now, when hovering over a socket, a tooltip will appear that provides information about the data in the socket. Note, socket inspection only works for sockets that have been computed already. Nodes that are not connected to an output are not computed. Future improvements can include ui changes to make the tooltip look more like in the original design (T85251). Furthermore, additional information could be shown if necessary. Differential Revision: https://developer.blender.org/D11842 --- .../blender/nodes/NOD_geometry_nodes_eval_log.hh | 18 +++++++++++++ .../nodes/intern/geometry_nodes_eval_log.cc | 31 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/NOD_geometry_nodes_eval_log.hh b/source/blender/nodes/NOD_geometry_nodes_eval_log.hh index 1c4590f96ac..b85862a0176 100644 --- a/source/blender/nodes/NOD_geometry_nodes_eval_log.hh +++ b/source/blender/nodes/NOD_geometry_nodes_eval_log.hh @@ -90,6 +90,24 @@ class GeometryValueLog : public ValueLog { std::unique_ptr full_geometry_; public: + struct MeshInfo { + int tot_verts, tot_edges, tot_faces; + }; + struct CurveInfo { + int tot_splines; + }; + struct PointCloudInfo { + int tot_points; + }; + struct InstancesInfo { + int tot_instances; + }; + + std::optional mesh_info; + std::optional curve_info; + std::optional pointcloud_info; + std::optional instances_info; + GeometryValueLog(const GeometrySet &geometry_set, bool log_full_geometry); Span attributes() const diff --git a/source/blender/nodes/intern/geometry_nodes_eval_log.cc b/source/blender/nodes/intern/geometry_nodes_eval_log.cc index 85182b67c8a..3024cc51cad 100644 --- a/source/blender/nodes/intern/geometry_nodes_eval_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_eval_log.cc @@ -150,6 +150,37 @@ GeometryValueLog::GeometryValueLog(const GeometrySet &geometry_set, bool log_ful 8); for (const GeometryComponent *component : geometry_set.get_components_for_read()) { component_types_.append(component->type()); + switch (component->type()) { + case GEO_COMPONENT_TYPE_MESH: { + const MeshComponent &mesh_component = *(const MeshComponent *)component; + MeshInfo &info = this->mesh_info.emplace(); + info.tot_verts = mesh_component.attribute_domain_size(ATTR_DOMAIN_POINT); + info.tot_edges = mesh_component.attribute_domain_size(ATTR_DOMAIN_EDGE); + info.tot_faces = mesh_component.attribute_domain_size(ATTR_DOMAIN_FACE); + break; + } + case GEO_COMPONENT_TYPE_CURVE: { + const CurveComponent &curve_component = *(const CurveComponent *)component; + CurveInfo &info = this->curve_info.emplace(); + info.tot_splines = curve_component.attribute_domain_size(ATTR_DOMAIN_CURVE); + break; + } + case GEO_COMPONENT_TYPE_POINT_CLOUD: { + const PointCloudComponent &pointcloud_component = *(const PointCloudComponent *)component; + PointCloudInfo &info = this->pointcloud_info.emplace(); + info.tot_points = pointcloud_component.attribute_domain_size(ATTR_DOMAIN_POINT); + break; + } + case GEO_COMPONENT_TYPE_INSTANCES: { + const InstancesComponent &instances_component = *(const InstancesComponent *)component; + InstancesInfo &info = this->instances_info.emplace(); + info.tot_instances = instances_component.instances_amount(); + break; + } + case GEO_COMPONENT_TYPE_VOLUME: { + break; + } + } } if (log_full_geometry) { full_geometry_ = std::make_unique(geometry_set); -- cgit v1.2.3