From 8a77048ea0eeb24fbfda092499faba525243b1d2 Mon Sep 17 00:00:00 2001 From: parker Date: Thu, 31 Jul 2025 18:57:25 +0100 Subject: [PATCH] feat: gl exploded mesh representation --- src/Gui/Viewport/GLMesh.cpp | 61 +++++++++++++++++---------- src/Gui/Viewport/ViewportGLWidget.cpp | 3 +- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/Gui/Viewport/GLMesh.cpp b/src/Gui/Viewport/GLMesh.cpp index f2ce9f4..accdbf8 100644 --- a/src/Gui/Viewport/GLMesh.cpp +++ b/src/Gui/Viewport/GLMesh.cpp @@ -3,7 +3,9 @@ #include #include "Engine/Operator/AttributeHandle.h" #include "Engine/Operator/Geometry.h" +#include "Engine/Types.h" #include +#include "icecream.hpp" @@ -71,20 +73,39 @@ void GLMesh::setPosBuffer(enzo::geo::Geometry& geometry) PMP::parameters::vertex_point_map(heMesh.points()) ); + std::shared_ptr PAttr = geometry.getAttribByName(enzo::ga::AttrOwner::POINT, "P"); + enzo::ga::AttributeHandleVector3 PAttrHandle = enzo::ga::AttributeHandleVector3(PAttr); + auto pointPositions = PAttrHandle.getAllValues(); + + std::shared_ptr pointAttr = geometry.getAttribByName(enzo::ga::AttrOwner::VERTEX, "point"); + enzo::ga::AttributeHandleInt pointAttrHandle = enzo::ga::AttributeHandleInt(pointAttr); + auto vertexPointIndices = pointAttrHandle.getAllValues(); - for (enzo::geo::V_index v : heMesh.vertices()) + std::shared_ptr vertexCountAttr = geometry.getAttribByName(enzo::ga::AttrOwner::PRIMITIVE, "vertexCount"); + enzo::ga::AttributeHandleInt vertexCountHandle = enzo::ga::AttributeHandleInt(vertexCountAttr); + std::vector vertexCounts = vertexCountHandle.getAllValues(); + + unsigned int vertexCount = 0; + + for (int primIndx=0; primIndx pointIndices, std::vector prim bind(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); indexData.clear(); - std::cout << "index pointIndices\n-------\n"; - size_t startIndex = 1; + + unsigned int startVert = 0; // create triangle fan from potentially ngon inputs - std::cout << "size: " << primVertexCounts.size() << "\n"; for(size_t primNum=0; primNum