Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc')
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc
index 0ba405d97e0..f5a4f09a5a2 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc
@@ -21,6 +21,7 @@
#include "BKE_mesh_wrapper.h"
#include "BKE_modifier.h"
+#include "DNA_ID.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_space_types.h"
@@ -38,6 +39,66 @@ namespace blender::ed::spreadsheet {
using blender::bke::ReadAttribute;
using blender::bke::ReadAttributePtr;
+static void add_columns_for_instances(const InstancesComponent &instances_component,
+ SpreadsheetColumnLayout &column_layout,
+ ResourceCollector &resources)
+{
+ Span<InstancedData> instance_data = instances_component.instanced_data();
+ Span<float4x4> transforms = instances_component.transforms();
+
+ Vector<std::unique_ptr<SpreadsheetColumn>> &columns =
+ resources.construct<Vector<std::unique_ptr<SpreadsheetColumn>>>("columns");
+
+ columns.append(spreadsheet_column_from_function(
+ "Name", [instance_data](int index, CellValue &r_cell_value) {
+ const InstancedData &data = instance_data[index];
+ if (data.type == INSTANCE_DATA_TYPE_OBJECT) {
+ if (data.data.object != nullptr) {
+ r_cell_value.value = ObjectCellValue{data.data.object};
+ }
+ }
+ else if (data.type == INSTANCE_DATA_TYPE_COLLECTION) {
+ if (data.data.collection != nullptr) {
+ r_cell_value.value = CollectionCellValue{data.data.collection};
+ }
+ }
+ }));
+
+ columns.last()->default_width = 8.0f;
+
+ static std::array<char, 3> axis_char = {'X', 'Y', 'Z'};
+ for (const int i : {0, 1, 2}) {
+ std::string name = std::string("Position ") + axis_char[i];
+ columns.append(spreadsheet_column_from_function(
+ name, [transforms, i](int index, CellValue &r_cell_value) {
+ r_cell_value.value = transforms[index].translation()[i];
+ }));
+ }
+
+ for (const int i : {0, 1, 2}) {
+ std::string name = std::string("Rotation ") + axis_char[i];
+ columns.append(spreadsheet_column_from_function(
+ name, [transforms, i](int index, CellValue &r_cell_value) {
+ r_cell_value.value = transforms[index].to_euler()[i];
+ }));
+ }
+
+ for (const int i : {0, 1, 2}) {
+ std::string name = std::string("Scale ") + axis_char[i];
+ columns.append(spreadsheet_column_from_function(
+ name, [transforms, i](int index, CellValue &r_cell_value) {
+ r_cell_value.value = transforms[index].scale()[i];
+ }));
+ }
+
+ for (std::unique_ptr<SpreadsheetColumn> &column : columns) {
+ column_layout.columns.append(column.get());
+ }
+
+ column_layout.row_indices = instance_data.index_range().as_span();
+ column_layout.tot_rows = instances_component.instances_amount();
+}
+
static Vector<std::string> get_sorted_attribute_names_to_display(
const GeometryComponent &component, const AttributeDomain domain)
{
@@ -342,6 +403,12 @@ void spreadsheet_columns_from_geometry(const bContext *C,
if (component == nullptr) {
return;
}
+ if (component_type == GEO_COMPONENT_TYPE_INSTANCES) {
+ add_columns_for_instances(
+ *static_cast<const InstancesComponent *>(component), column_layout, resources);
+ return;
+ }
+
if (!component->attribute_domain_supported(domain)) {
return;
}