diff options
author | Jacques Lucke <jacques@blender.org> | 2021-03-15 12:16:11 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-03-15 12:16:11 +0300 |
commit | 4ed208bcd82e912fa9a0da6137af6e87004e9365 (patch) | |
tree | 515ace29470dd5e2a785e3c18e482f54f30ff36e /source/blender/makesrna/intern/rna_space.c | |
parent | b617b44419613ae87d64b5d4692515750c83b417 (diff) |
Spreadsheet: support showing data from original/unevaluated object
There are two caveats of the current implementation which still need
to be resolved in a separate step:
* In theory the data on the original object can be editable in the spreadsheet.
* If a complex object is in edit mode, and its original data is displayed,
the drawing code can be slow, because the bmesh is converted to a mesh
every time. The proper solution is to draw the data from the bmesh directly.
This should become easier after an upcoming refactor.
Ref T86141.
Differential Revision: https://developer.blender.org/D10701
Diffstat (limited to 'source/blender/makesrna/intern/rna_space.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index db36909d2f9..63600571c0d 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -26,6 +26,7 @@ #include "BLT_translation.h" #include "BKE_attribute.h" +#include "BKE_context.h" #include "BKE_geometry_set.h" #include "BKE_image.h" #include "BKE_key.h" @@ -3003,17 +3004,33 @@ static void rna_SpaceSpreadsheet_geometry_component_type_update(Main *UNUSED(bma } } -const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *UNUSED(C), +const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)ptr->data; + GeometryComponentType component_type = sspreadsheet->geometry_component_type; + if (sspreadsheet->object_eval_state == SPREADSHEET_OBJECT_EVAL_STATE_ORIGINAL) { + Object *active_object = CTX_data_active_object(C); + Object *used_object = (sspreadsheet->pinned_id && GS(sspreadsheet->pinned_id->name) == ID_OB) ? + (Object *)sspreadsheet->pinned_id : + active_object; + if (used_object != NULL) { + if (used_object->type == OB_POINTCLOUD) { + component_type = GEO_COMPONENT_TYPE_POINT_CLOUD; + } + else { + component_type = GEO_COMPONENT_TYPE_MESH; + } + } + } + EnumPropertyItem *item_array = NULL; int items_len = 0; for (const EnumPropertyItem *item = rna_enum_attribute_domain_items; item->identifier != NULL; item++) { - if (sspreadsheet->geometry_component_type == GEO_COMPONENT_TYPE_MESH) { + if (component_type == GEO_COMPONENT_TYPE_MESH) { if (!ELEM(item->value, ATTR_DOMAIN_CORNER, ATTR_DOMAIN_EDGE, @@ -3022,7 +3039,7 @@ const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *UN continue; } } - if (sspreadsheet->geometry_component_type == GEO_COMPONENT_TYPE_POINT_CLOUD) { + if (component_type == GEO_COMPONENT_TYPE_POINT_CLOUD) { if (item->value != ATTR_DOMAIN_POINT) { continue; } @@ -7254,6 +7271,20 @@ static void rna_def_space_spreadsheet(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem object_eval_state_items[] = { + {SPREADSHEET_OBJECT_EVAL_STATE_FINAL, + "FINAL", + ICON_NONE, + "Final", + "Use data from object with all modifiers applied"}, + {SPREADSHEET_OBJECT_EVAL_STATE_ORIGINAL, + "ORIGINAL", + ICON_NONE, + "Original", + "Use data from original object without any modifiers applied"}, + {0, NULL, 0, NULL, NULL}, + }; + srna = RNA_def_struct(brna, "SpaceSpreadsheet", "Space"); RNA_def_struct_ui_text(srna, "Space Spreadsheet", "Spreadsheet space data"); @@ -7284,6 +7315,11 @@ static void rna_def_space_spreadsheet(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceSpreadsheet_attribute_domain_itemf"); RNA_def_property_ui_text(prop, "Attribute Domain", "Attribute domain to display"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); + + prop = RNA_def_property(srna, "object_eval_state", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, object_eval_state_items); + RNA_def_property_ui_text(prop, "Object Evaluation State", ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); } void RNA_def_space(BlenderRNA *brna) |