[Bf-blender-cvs] [ba8dd0f24ff] master: Spreadsheet: Support instances component viewer node columns

Hans Goudey noreply at git.blender.org
Fri Nov 19 18:21:59 CET 2021


Commit: ba8dd0f24ff16433cd174f891f0e2f5b2361e240
Author: Hans Goudey
Date:   Fri Nov 19 12:21:54 2021 -0500
Branches: master
https://developer.blender.org/rBba8dd0f24ff16433cd174f891f0e2f5b2361e240

Spreadsheet: Support instances component viewer node columns

After rB97533eede444217b, instances have their own attribute domain,
but the spreadsheet code worked under the assumption that the component
used the point domain. Old files have to re-select the instances data
source to make it properly active

===================================================================

M	source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc

===================================================================

diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc
index 25a9d0f0213..acedcebe05c 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc
@@ -49,7 +49,7 @@ static int is_component_row_selected(struct uiBut *but, const void *arg)
   const bool is_domain_selected = (AttributeDomain)sspreadsheet->attribute_domain == domain;
   bool is_selected = is_component_selected && is_domain_selected;
 
-  if (ELEM(component, GEO_COMPONENT_TYPE_VOLUME, GEO_COMPONENT_TYPE_INSTANCES)) {
+  if (component == GEO_COMPONENT_TYPE_VOLUME) {
     is_selected = is_component_selected;
   }
 
@@ -132,16 +132,6 @@ 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<InstancesComponent>();
-    return instances_component->instances_amount();
-  }
-  return 0;
-}
-
 static int element_count_from_volume(const GeometrySet &geometry_set)
 {
   if (const Volume *volume = geometry_set.get_volume_for_read()) {
@@ -176,6 +166,12 @@ static int element_count_from_component_domain(const GeometrySet &geometry_set,
     return curve_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<InstancesComponent>();
+    return instances_component->attribute_domain_size(domain);
+  }
+
   return 0;
 }
 
@@ -196,11 +192,7 @@ void DatasetRegionDrawer::draw_dataset_row(const int indentation,
                      ymin_offset};
 
   char element_count[7];
-  if (component == GEO_COMPONENT_TYPE_INSTANCES) {
-    BLI_str_format_attribute_domain_size(
-        element_count, element_count_from_instances(draw_context.current_geometry_set));
-  }
-  else if (component == GEO_COMPONENT_TYPE_VOLUME) {
+  if (component == GEO_COMPONENT_TYPE_VOLUME) {
     BLI_str_format_attribute_domain_size(
         element_count, element_count_from_volume(draw_context.current_geometry_set));
   }
@@ -250,7 +242,15 @@ void DatasetRegionDrawer::draw_dataset_row(const int indentation,
 
 void DatasetRegionDrawer::draw_component_row(const DatasetComponentLayoutInfo &component_info)
 {
-  if (ELEM(component_info.type, GEO_COMPONENT_TYPE_VOLUME, GEO_COMPONENT_TYPE_INSTANCES)) {
+  if (component_info.type == GEO_COMPONENT_TYPE_INSTANCES) {
+    draw_dataset_row(0,
+                     component_info.type,
+                     ATTR_DOMAIN_INSTANCE,
+                     component_info.icon,
+                     component_info.label,
+                     true);
+  }
+  else if (component_info.type == GEO_COMPONENT_TYPE_VOLUME) {
     draw_dataset_row(
         0, component_info.type, std::nullopt, component_info.icon, component_info.label, true);
   }



More information about the Bf-blender-cvs mailing list