Skip to content

Commit

Permalink
[release] cihou roy pyramid
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Aug 11, 2022
1 parent 76787a2 commit 7ed08a1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ui/zenoedit/dock/zenodockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
52 changes: 52 additions & 0 deletions zeno/src/nodes/neo/PrimVertFaceOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,57 @@ ZENDEFNODE(PrimFacesAttrToVerts, {
{"primitive"},
});

struct PrimFacesCenterAsVerts : INode {
virtual void apply() override {
auto prim = get_input<PrimitiveObject>("prim");
auto faceType = get_input2<std::string>("faceType");
auto copyFaceAttrs = get_input2<bool>("copyFaceAttrs");

auto outprim = std::make_shared<PrimitiveObject>();
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<vec3f> 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<AttrAcceptAll>([&] (auto const &key, auto const &facesArr) {
using T = std::decay_t<decltype(facesArr[0])>;
auto &vertsArr = outprim->verts.add_attr<T>(key);
vertsArr = facesArr;
});
}

}, enum_variant<std::variant<
face_lines, face_tris, face_quads, face_polys
>>(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"},
});

}
}

0 comments on commit 7ed08a1

Please sign in to comment.