From ebf3a952d89c38adacfb1ff8d36dbd7732597338 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Thu, 29 Aug 2024 15:37:46 +0800 Subject: [PATCH] abc-not-flip-lines --- projects/Alembic/GetAlembicPrim.cpp | 8 ++++---- zeno/include/zeno/funcs/PrimitiveUtils.h | 2 +- zeno/src/nodes/neo/PrimFlipFaces.cpp | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/Alembic/GetAlembicPrim.cpp b/projects/Alembic/GetAlembicPrim.cpp index a8304e82a8..667c943df6 100644 --- a/projects/Alembic/GetAlembicPrim.cpp +++ b/projects/Alembic/GetAlembicPrim.cpp @@ -159,7 +159,7 @@ struct GetAlembicPrim : INode { prim = get_alembic_prim(abctree, index); } if (get_input2("flipFrontBack")) { - primFlipFaces(prim.get()); + primFlipFaces(prim.get(), true); } if (get_input2("triangulate")) { zeno::primTriangulate(prim.get()); @@ -198,7 +198,7 @@ struct AllAlembicPrim : INode { } auto outprim = zeno::primMerge(prims->getRaw()); if (get_input2("flipFrontBack")) { - primFlipFaces(outprim.get()); + primFlipFaces(outprim.get(), true); } if (get_input2("triangulate") == 1) { zeno::primTriangulate(outprim.get()); @@ -297,7 +297,7 @@ struct AlembicPrimList : INode { for (auto &prim: new_prims->arr) { auto _prim = std::dynamic_pointer_cast(prim); if (get_input2("flipFrontBack")) { - primFlipFaces(_prim.get()); + primFlipFaces(_prim.get(), true); } if (get_input2("splitByFaceset") && get_input2("killDeadVerts")) { primKillDeadVerts(_prim.get()); @@ -457,7 +457,7 @@ struct ImportAlembicPrim : INode { outprim = get_alembic_prim(abctree, index); } } - primFlipFaces(outprim.get()); + primFlipFaces(outprim.get(), true); if (get_input2("triangulate")) { zeno::primTriangulate(outprim.get()); } diff --git a/zeno/include/zeno/funcs/PrimitiveUtils.h b/zeno/include/zeno/funcs/PrimitiveUtils.h index 2fca7e1614..39585e683d 100644 --- a/zeno/include/zeno/funcs/PrimitiveUtils.h +++ b/zeno/include/zeno/funcs/PrimitiveUtils.h @@ -16,7 +16,7 @@ ZENO_API void primPolygonate(PrimitiveObject *prim, bool with_uv = true); ZENO_API void primSepTriangles(PrimitiveObject *prim, bool smoothNormal = true, bool keepTriFaces = true); //ZENO_API void primSmoothNormal(PrimitiveObject *prim, bool isFlipped = false); -ZENO_API void primFlipFaces(PrimitiveObject *prim); +ZENO_API void primFlipFaces(PrimitiveObject *prim, bool only_face = false); ZENO_API void primCalcNormal(PrimitiveObject *prim, float flip = 1.0f, std::string nrmAttr = "nrm"); //ZENO_API void primCalcInsetDir(PrimitiveObject *prim, float flip = 1.0f, std::string nrmAttr = "nrm"); diff --git a/zeno/src/nodes/neo/PrimFlipFaces.cpp b/zeno/src/nodes/neo/PrimFlipFaces.cpp index 44bbd6a711..e37b0bd6fb 100644 --- a/zeno/src/nodes/neo/PrimFlipFaces.cpp +++ b/zeno/src/nodes/neo/PrimFlipFaces.cpp @@ -10,8 +10,8 @@ namespace zeno { -ZENO_API void primFlipFaces(PrimitiveObject *prim) { - if (prim->lines.size()) +ZENO_API void primFlipFaces(PrimitiveObject *prim, bool only_face) { + if (!only_face && prim->lines.size()) parallel_for_each(prim->lines.begin(), prim->lines.end(), [&] (auto &line) { std::swap(line[1], line[0]); }); @@ -47,7 +47,7 @@ ZENO_API void primFlipFaces(PrimitiveObject *prim) { struct PrimFlipFaces : zeno::INode { virtual void apply() override { auto prim = get_input("prim"); - primFlipFaces(prim.get()); + primFlipFaces(prim.get(), false); set_output("prim", std::move(prim)); } };