diff options
author | Jacques Lucke <jacques@blender.org> | 2021-04-26 10:16:53 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-04-26 10:16:53 +0300 |
commit | 9b64927a8aabe3f71784be1022a1daf3fb4e0b28 (patch) | |
tree | 0f4929197a1adf8c23dd26d2615373f7f49a63a5 /source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc | |
parent | c63142ca8fc22ecd5510251d755d73cfc57a7c7b (diff) | |
parent | a17ea1a6691920cc307f3e44dd285b2d8e8bdd35 (diff) |
Merge branch 'blender-v2.93-release'
Diffstat (limited to 'source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc')
-rw-r--r-- | source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc | 116 |
1 files changed, 39 insertions, 77 deletions
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc index 405f0cd9455..1ae3f462cfa 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc @@ -47,28 +47,7 @@ void GeometryDataSource::foreach_default_column_ids( } SpreadsheetColumnID column_id; column_id.name = (char *)name.c_str(); - if (meta_data.data_type == CD_PROP_FLOAT3) { - for (const int i : {0, 1, 2}) { - column_id.index = i; - fn(column_id); - } - } - else if (meta_data.data_type == CD_PROP_FLOAT2) { - for (const int i : {0, 1}) { - column_id.index = i; - fn(column_id); - } - } - else if (meta_data.data_type == CD_PROP_COLOR) { - for (const int i : {0, 1, 2, 3}) { - column_id.index = i; - fn(column_id); - } - } - else { - column_id.index = -1; - fn(column_id); - } + fn(column_id); return true; }); } @@ -90,9 +69,6 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values( const CustomDataType type = bke::cpp_type_to_custom_data_type(varray->type()); switch (type) { case CD_PROP_FLOAT: - if (column_id.index != -1) { - return {}; - } return column_values_from_function( column_id.name, domain_size, [varray](int index, CellValue &r_cell_value) { float value; @@ -100,9 +76,6 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values( r_cell_value.value_float = value; }); case CD_PROP_INT32: - if (column_id.index != -1) { - return {}; - } return column_values_from_function( column_id.name, domain_size, [varray](int index, CellValue &r_cell_value) { int value; @@ -110,9 +83,6 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values( r_cell_value.value_int = value; }); case CD_PROP_BOOL: - if (column_id.index != -1) { - return {}; - } return column_values_from_function( column_id.name, domain_size, [varray](int index, CellValue &r_cell_value) { bool value; @@ -120,43 +90,37 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values( r_cell_value.value_bool = value; }); case CD_PROP_FLOAT2: { - if (column_id.index < 0 || column_id.index > 1) { - return {}; - } - const std::array<const char *, 2> suffixes = {" X", " Y"}; - const std::string name = StringRef(column_id.name) + suffixes[column_id.index]; return column_values_from_function( - name, domain_size, [varray, axis = column_id.index](int index, CellValue &r_cell_value) { + column_id.name, + domain_size, + [varray](int index, CellValue &r_cell_value) { float2 value; varray->get(index, &value); - r_cell_value.value_float = value[axis]; - }); + r_cell_value.value_float2 = value; + }, + default_float2_column_width); } case CD_PROP_FLOAT3: { - if (column_id.index < 0 || column_id.index > 2) { - return {}; - } - const std::array<const char *, 3> suffixes = {" X", " Y", " Z"}; - const std::string name = StringRef(column_id.name) + suffixes[column_id.index]; return column_values_from_function( - name, domain_size, [varray, axis = column_id.index](int index, CellValue &r_cell_value) { + column_id.name, + domain_size, + [varray](int index, CellValue &r_cell_value) { float3 value; varray->get(index, &value); - r_cell_value.value_float = value[axis]; - }); + r_cell_value.value_float3 = value; + }, + default_float3_column_width); } case CD_PROP_COLOR: { - if (column_id.index < 0 || column_id.index > 3) { - return {}; - } - const std::array<const char *, 4> suffixes = {" R", " G", " B", " A"}; - const std::string name = StringRef(column_id.name) + suffixes[column_id.index]; return column_values_from_function( - name, domain_size, [varray, axis = column_id.index](int index, CellValue &r_cell_value) { + column_id.name, + domain_size, + [varray](int index, CellValue &r_cell_value) { Color4f value; varray->get(index, &value); - r_cell_value.value_float = value[axis]; - }); + r_cell_value.value_color = value; + }, + default_color_column_width); } default: break; @@ -295,15 +259,11 @@ void InstancesDataSource::foreach_default_column_ids( } SpreadsheetColumnID column_id; - column_id.index = -1; column_id.name = (char *)"Name"; fn(column_id); for (const char *name : {"Position", "Rotation", "Scale"}) { - for (const int i : {0, 1, 2}) { - column_id.name = (char *)name; - column_id.index = i; - fn(column_id); - } + column_id.name = (char *)name; + fn(column_id); } } @@ -314,7 +274,6 @@ std::unique_ptr<ColumnValues> InstancesDataSource::get_column_values( return {}; } - const std::array<const char *, 3> suffixes = {" X", " Y", " Z"}; const int size = this->tot_rows(); if (STREQ(column_id.name, "Name")) { Span<InstancedData> instance_data = component_->instanced_data(); @@ -335,30 +294,33 @@ std::unique_ptr<ColumnValues> InstancesDataSource::get_column_values( values->default_width = 8.0f; return values; } - if (column_id.index < 0 || column_id.index > 2) { - return {}; - } Span<float4x4> transforms = component_->transforms(); if (STREQ(column_id.name, "Position")) { - std::string name = StringRef("Position") + suffixes[column_id.index]; return column_values_from_function( - name, size, [transforms, axis = column_id.index](int index, CellValue &r_cell_value) { - r_cell_value.value_float = transforms[index].translation()[axis]; - }); + column_id.name, + size, + [transforms](int index, CellValue &r_cell_value) { + r_cell_value.value_float3 = transforms[index].translation(); + }, + default_float3_column_width); } if (STREQ(column_id.name, "Rotation")) { - std::string name = StringRef("Rotation") + suffixes[column_id.index]; return column_values_from_function( - name, size, [transforms, axis = column_id.index](int index, CellValue &r_cell_value) { - r_cell_value.value_float = transforms[index].to_euler()[axis]; - }); + column_id.name, + size, + [transforms](int index, CellValue &r_cell_value) { + r_cell_value.value_float3 = transforms[index].to_euler(); + }, + default_float3_column_width); } if (STREQ(column_id.name, "Scale")) { - std::string name = StringRef("Scale") + suffixes[column_id.index]; return column_values_from_function( - name, size, [transforms, axis = column_id.index](int index, CellValue &r_cell_value) { - r_cell_value.value_float = transforms[index].scale()[axis]; - }); + column_id.name, + size, + [transforms](int index, CellValue &r_cell_value) { + r_cell_value.value_float3 = transforms[index].scale(); + }, + default_float3_column_width); } return {}; } |