From 5759bbe9f9e8706356c9d39939f472e3bb717860 Mon Sep 17 00:00:00 2001 From: Fabian Schempp Date: Fri, 25 Jun 2021 22:57:47 +0200 Subject: Fixes a bug where the instances count in the spreadsheet editor dataset region always showed 0. This was caused by a conditional statement that needed a domain to be set, which is not the case for Instances component type. Reviewer: Hans Goudey (Hoogly Boogly) Differential Revision: https://developer.blender.org/D11710 --- .../space_spreadsheet/spreadsheet_dataset_draw.cc | 32 ++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'source/blender/editors/space_spreadsheet') diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc index 1fa6e47fcdf..4f870092caa 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc @@ -130,6 +130,16 @@ void DatasetRegionDrawer::draw_hierarchy(const DatasetLayoutHierarchy &layout) } } +static int element_count_from_instances(const GeometrySet &geometry_set) +{ + if (geometry_set.has_instances()) { + const InstancesComponent *instances_component = + geometry_set.get_component_for_read(); + return instances_component->instances_amount(); + } + return 0; +} + static int element_count_from_component_domain(const GeometrySet &geometry_set, GeometryComponentType component, AttributeDomain domain) @@ -145,12 +155,6 @@ static int element_count_from_component_domain(const GeometrySet &geometry_set, return point_cloud_component->attribute_domain_size(domain); } - if (geometry_set.has_instances() && component == GEO_COMPONENT_TYPE_INSTANCES) { - const InstancesComponent *instances_component = - geometry_set.get_component_for_read(); - return instances_component->instances_amount(); - } - if (geometry_set.has_volume() && component == GEO_COMPONENT_TYPE_VOLUME) { const VolumeComponent *volume_component = geometry_set.get_component_for_read(); @@ -182,11 +186,17 @@ void DatasetRegionDrawer::draw_dataset_row(const int indentation, ymin_offset}; char element_count[7]; - BLI_str_format_attribute_domain_size( - element_count, - domain ? element_count_from_component_domain( - draw_context.current_geometry_set, component, *domain) : - 0); + if (component == GEO_COMPONENT_TYPE_INSTANCES) { + BLI_str_format_attribute_domain_size( + element_count, element_count_from_instances(draw_context.current_geometry_set)); + } + else { + BLI_str_format_attribute_domain_size( + element_count, + domain ? element_count_from_component_domain( + draw_context.current_geometry_set, component, *domain) : + 0); + } std::string label_and_element_count = label; label_and_element_count += UI_SEP_CHAR; -- cgit v1.2.3