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
path: root/source
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-01-11 01:45:53 +0300
committerHans Goudey <h.goudey@me.com>2022-01-11 01:45:53 +0300
commit922ae55a16a96784427080505f0a751c05a74fb6 (patch)
treef167b468c522c535169c2b53c3e25be854f1ecde /source
parent37b336a8af31e4280ccc752769336fcff87ed124 (diff)
Spreadsheet: Add mesh topology information with a debug value
This commit adds topology information from mesh data structs to the spreadsheet when the debug value `4001` is set. Eventually we could expose these. For now it can be a useful tool for developers when working on mesh algorithms. Differential Revision: https://developer.blender.org/D13735
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_global.h1
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc62
2 files changed, 63 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index ecf2e1f32a0..0c17636be03 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -104,6 +104,7 @@ typedef struct Global {
* * 1234: Disable new dyntopo code fixing skinny faces generation (04/2015).
* * 3001: Enable additional Fluid modifier (Mantaflow) options (02/2020).
* * 4000: Line Art state output and debugging logs (03/2021).
+ * * 4001: Mesh topology information in the spreadsheet (01/2022).
* * 16384 and above: Reserved for python (add-ons) usage.
*/
short debug_value;
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 337a6037c42..b9b03732a40 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -18,6 +18,7 @@
#include "BKE_context.h"
#include "BKE_editmesh.h"
+#include "BKE_global.h"
#include "BKE_lib_id.h"
#include "BKE_mesh.h"
#include "BKE_mesh_wrapper.h"
@@ -103,6 +104,20 @@ void GeometryDataSource::foreach_default_column_ids(
fn({(char *)"Rotation"}, false);
fn({(char *)"Scale"}, false);
}
+ else if (G.debug_value == 4001 && component_->type() == GEO_COMPONENT_TYPE_MESH) {
+ if (domain_ == ATTR_DOMAIN_EDGE) {
+ fn({(char *)"Vertex 1"}, false);
+ fn({(char *)"Vertex 2"}, false);
+ }
+ else if (domain_ == ATTR_DOMAIN_FACE) {
+ fn({(char *)"Corner Start"}, false);
+ fn({(char *)"Corner Size"}, false);
+ }
+ else if (domain_ == ATTR_DOMAIN_CORNER) {
+ fn({(char *)"Vertex"}, false);
+ fn({(char *)"Edge"}, false);
+ }
+ }
}
std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values(
@@ -146,6 +161,53 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values(
}));
}
}
+ else if (G.debug_value == 4001 && component_->type() == GEO_COMPONENT_TYPE_MESH) {
+ const MeshComponent &component = static_cast<const MeshComponent &>(*component_);
+ if (const Mesh *mesh = component.get_for_read()) {
+ if (domain_ == ATTR_DOMAIN_EDGE) {
+ if (STREQ(column_id.name, "Vertex 1")) {
+ return std::make_unique<ColumnValues>(
+ column_id.name, VArray<int>::ForFunc(mesh->totedge, [mesh](int64_t index) {
+ return mesh->medge[index].v1;
+ }));
+ }
+ if (STREQ(column_id.name, "Vertex 2")) {
+ return std::make_unique<ColumnValues>(
+ column_id.name, VArray<int>::ForFunc(mesh->totedge, [mesh](int64_t index) {
+ return mesh->medge[index].v2;
+ }));
+ }
+ }
+ else if (domain_ == ATTR_DOMAIN_FACE) {
+ if (STREQ(column_id.name, "Corner Start")) {
+ return std::make_unique<ColumnValues>(
+ column_id.name, VArray<int>::ForFunc(mesh->totpoly, [mesh](int64_t index) {
+ return mesh->mpoly[index].loopstart;
+ }));
+ }
+ if (STREQ(column_id.name, "Corner Size")) {
+ return std::make_unique<ColumnValues>(
+ column_id.name, VArray<int>::ForFunc(mesh->totpoly, [mesh](int64_t index) {
+ return mesh->mpoly[index].totloop;
+ }));
+ }
+ }
+ else if (domain_ == ATTR_DOMAIN_CORNER) {
+ if (STREQ(column_id.name, "Vertex")) {
+ return std::make_unique<ColumnValues>(
+ column_id.name, VArray<int>::ForFunc(mesh->totloop, [mesh](int64_t index) {
+ return mesh->mloop[index].v;
+ }));
+ }
+ if (STREQ(column_id.name, "Edge")) {
+ return std::make_unique<ColumnValues>(
+ column_id.name, VArray<int>::ForFunc(mesh->totloop, [mesh](int64_t index) {
+ return mesh->mloop[index].e;
+ }));
+ }
+ }
+ }
+ }
bke::ReadAttributeLookup attribute = component_->attribute_try_get_for_read(column_id.name);
if (!attribute) {