From 7ed08a1bee8827a68280b1f7fa51192d7040127c Mon Sep 17 00:00:00 2001 From: archibate <1931127624@qq.com> Date: Thu, 11 Aug 2022 16:11:01 +0800 Subject: [PATCH] [release] cihou roy pyramid --- ui/zenoedit/dock/zenodockwidget.cpp | 2 +- zeno/src/nodes/neo/PrimVertFaceOps.cpp | 52 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/ui/zenoedit/dock/zenodockwidget.cpp b/ui/zenoedit/dock/zenodockwidget.cpp index 6c713b9c58..6abbadb9a4 100644 --- a/ui/zenoedit/dock/zenodockwidget.cpp +++ b/ui/zenoedit/dock/zenodockwidget.cpp @@ -111,7 +111,7 @@ void ZenoDockWidget::onNodesSelected(const QModelIndex& subgIdx, const QModelInd if (select) { const QModelIndex& idx = nodes[0]; QString nodeId = pModel->data2(subgIdx, idx, ROLE_OBJID).toString(); - auto scene = Zenovis::GetInstance().getSession()->get_scene(); + auto *scene = Zenovis::GetInstance().getSession()->get_scene(); scene->selected.clear(); std::string nodeid = nodeId.toStdString(); for (auto const &[key, ptr]: scene->objectsMan->pairs()) { diff --git a/zeno/src/nodes/neo/PrimVertFaceOps.cpp b/zeno/src/nodes/neo/PrimVertFaceOps.cpp index 6fbc7cf2b9..546102d385 100644 --- a/zeno/src/nodes/neo/PrimVertFaceOps.cpp +++ b/zeno/src/nodes/neo/PrimVertFaceOps.cpp @@ -241,5 +241,57 @@ ZENDEFNODE(PrimFacesAttrToVerts, { {"primitive"}, }); +struct PrimFacesCenterAsVerts : INode { + virtual void apply() override { + auto prim = get_input("prim"); + auto faceType = get_input2("faceType"); + auto copyFaceAttrs = get_input2("copyFaceAttrs"); + + auto outprim = std::make_shared(); + std::visit([&] (auto faceTy) { + + auto &prim_faces = faceTy.from_prim(prim.get()); + outprim->verts.resize(prim_faces.size()); + + for (int i = 0; i < prim_faces.size(); i++) { + meth_average reducer; + faceTy.foreach_ind(prim.get(), prim_faces[i], [&] (int ind) { + reducer.add(prim->verts[ind]); + }); + outprim->verts[i] = reducer.get(); + } + + if (copyFaceAttrs) { + prim_faces.template foreach_attr([&] (auto const &key, auto const &facesArr) { + using T = std::decay_t; + auto &vertsArr = outprim->verts.add_attr(key); + vertsArr = facesArr; + }); + } + + }, enum_variant>(array_index({ + "lines", "tris", "quads", "polys" + }, faceType))); + + set_output("prim", std::move(outprim)); + } +}; + +ZENDEFNODE(PrimFacesCenterAsVerts, { + { + {"PrimitiveObject", "prim"}, + {"enum lines tris quads polys", "faceType", "tris"}, + {"bool", "copyFaceAttrs", "1"}, + }, + { + {"PrimitiveObject", "prim"}, + }, + { + }, + {"primitive"}, +}); + } }