[Bf-blender-cvs] [922ae55a16a] master: Spreadsheet: Add mesh topology information with a debug value
Hans Goudey
noreply at git.blender.org
Mon Jan 10 23:46:00 CET 2022
Commit: 922ae55a16a96784427080505f0a751c05a74fb6
Author: Hans Goudey
Date: Mon Jan 10 16:45:53 2022 -0600
Branches: master
https://developer.blender.org/rB922ae55a16a96784427080505f0a751c05a74fb6
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
===================================================================
M source/blender/blenkernel/BKE_global.h
M source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
===================================================================
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) {
More information about the Bf-blender-cvs
mailing list