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
This commit is contained in:
parent
37b336a8af
commit
922ae55a16
Notes:
blender-bot
2024-05-19 18:31:11 +02:00
Referenced by issue #95837, Regression: GPU memory accumulation in Cycles render Referenced by issue #94797, Crash when playing animation in eevee rendered view
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue