Skip to content

Commit 7ed08a1

Browse files
author
archibate
committed
[release] cihou roy pyramid
1 parent 76787a2 commit 7ed08a1

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

ui/zenoedit/dock/zenodockwidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void ZenoDockWidget::onNodesSelected(const QModelIndex& subgIdx, const QModelInd
111111
if (select) {
112112
const QModelIndex& idx = nodes[0];
113113
QString nodeId = pModel->data2(subgIdx, idx, ROLE_OBJID).toString();
114-
auto scene = Zenovis::GetInstance().getSession()->get_scene();
114+
auto *scene = Zenovis::GetInstance().getSession()->get_scene();
115115
scene->selected.clear();
116116
std::string nodeid = nodeId.toStdString();
117117
for (auto const &[key, ptr]: scene->objectsMan->pairs()) {

zeno/src/nodes/neo/PrimVertFaceOps.cpp

+52
Original file line numberDiff line numberDiff line change
@@ -241,5 +241,57 @@ ZENDEFNODE(PrimFacesAttrToVerts, {
241241
{"primitive"},
242242
});
243243

244+
struct PrimFacesCenterAsVerts : INode {
245+
virtual void apply() override {
246+
auto prim = get_input<PrimitiveObject>("prim");
247+
auto faceType = get_input2<std::string>("faceType");
248+
auto copyFaceAttrs = get_input2<bool>("copyFaceAttrs");
249+
250+
auto outprim = std::make_shared<PrimitiveObject>();
251+
std::visit([&] (auto faceTy) {
252+
253+
auto &prim_faces = faceTy.from_prim(prim.get());
254+
outprim->verts.resize(prim_faces.size());
255+
256+
for (int i = 0; i < prim_faces.size(); i++) {
257+
meth_average<vec3f> reducer;
258+
faceTy.foreach_ind(prim.get(), prim_faces[i], [&] (int ind) {
259+
reducer.add(prim->verts[ind]);
260+
});
261+
outprim->verts[i] = reducer.get();
262+
}
263+
264+
if (copyFaceAttrs) {
265+
prim_faces.template foreach_attr<AttrAcceptAll>([&] (auto const &key, auto const &facesArr) {
266+
using T = std::decay_t<decltype(facesArr[0])>;
267+
auto &vertsArr = outprim->verts.add_attr<T>(key);
268+
vertsArr = facesArr;
269+
});
270+
}
271+
272+
}, enum_variant<std::variant<
273+
face_lines, face_tris, face_quads, face_polys
274+
>>(array_index({
275+
"lines", "tris", "quads", "polys"
276+
}, faceType)));
277+
278+
set_output("prim", std::move(outprim));
279+
}
280+
};
281+
282+
ZENDEFNODE(PrimFacesCenterAsVerts, {
283+
{
284+
{"PrimitiveObject", "prim"},
285+
{"enum lines tris quads polys", "faceType", "tris"},
286+
{"bool", "copyFaceAttrs", "1"},
287+
},
288+
{
289+
{"PrimitiveObject", "prim"},
290+
},
291+
{
292+
},
293+
{"primitive"},
294+
});
295+
244296
}
245297
}

0 commit comments

Comments
 (0)