diff --git a/zenovis/src/optx/RenderEngineOptx.cpp b/zenovis/src/optx/RenderEngineOptx.cpp index 5effeb93ac..02e5c9c667 100644 --- a/zenovis/src/optx/RenderEngineOptx.cpp +++ b/zenovis/src/optx/RenderEngineOptx.cpp @@ -66,7 +66,7 @@ struct CppTimer { }; static CppTimer timer, localTimer; -void cleanMesh(std::shared_ptr prim, +static void cleanMesh(zeno::PrimitiveObject* prim, std::vector &verts, std::vector &nrm, std::vector &clr, @@ -672,7 +672,40 @@ struct GraphicsManager { vtab[key] = {(float const *)arr.data(), sizeof(arr[0]) / sizeof(float)}; }); auto ts = (int const *)prim->tris.data(); - auto matids = (int const *)prim_in->tris.attr("matid").data(); + auto nvs = prim->verts.size(); + auto nts = prim->tris.size(); +// std::vector verts; +// std::vector nrm; +// std::vector clr; +// std::vector tang; +// std::vector uv; +// std::vector idxBuffer; +// cleanMesh(prim_in, verts, nrm, clr, tang, uv, idxBuffer); +// auto oPrim = std::make_shared(); +// oPrim->verts.resize(verts.size()); +// oPrim->add_attr("nrm"); +// oPrim->add_attr("clr"); +// oPrim->add_attr("uv"); +// oPrim->add_attr("atang"); +// oPrim->tris.resize(idxBuffer.size()); +// +// +// oPrim->verts.attr("pos") = verts; +// oPrim->verts.attr("nrm") = nrm; +// oPrim->verts.attr("clr") = clr; +// oPrim->verts.attr("uv") = uv; +// oPrim->verts.attr("atang") = tang; +// oPrim->tris = idxBuffer; +// +// auto vs = (float const *)oPrim->verts.data(); +// std::map> vtab; +// oPrim->verts.foreach_attr([&] (auto const &key, auto const &arr) { +// vtab[key] = {(float const *)arr.data(), sizeof(arr[0]) / sizeof(float)}; +// }); +// auto ts = (int const *)oPrim->tris.data(); +// auto nvs = oPrim->verts.size(); +// auto nts = oPrim->tris.size(); + std::vector matNameList(0); if(matNum>0) { @@ -683,10 +716,9 @@ struct GraphicsManager { matNameList.emplace_back(matName); } } - auto nvs = prim->verts.size(); - auto nts = prim->tris.size(); auto mtlid = prim_in->userData().get2("mtlid", "Default"); auto instID = prim_in->userData().get2("instID", "Default"); + auto matids = (int const *)prim_in->tris.attr("matid").data(); xinxinoptix::load_object(key, mtlid, instID, vs, nvs, ts, nts, vtab, matids, matNameList); } } diff --git a/zenovis/xinxinoptix/optixPathTracer.cpp b/zenovis/xinxinoptix/optixPathTracer.cpp index 1e83a43d8c..ca3eb01910 100644 --- a/zenovis/xinxinoptix/optixPathTracer.cpp +++ b/zenovis/xinxinoptix/optixPathTracer.cpp @@ -2846,6 +2846,20 @@ struct DrawDat { }; static std::map drawdats; +struct DrawDat2 { + std::vector mtlidList; + std::string mtlid; + std::string instID; + std::vector pos; + std::vector nrm; + std::vector tang; + std::vector clr; + std::vector uv; + std::vector triMats; + std::vector triIdx; +}; +static std::map drawdats2; + std::set uniqueMatsForMesh() { std::set result; @@ -3496,6 +3510,22 @@ static void updateDynamicDrawInstObjects() } } } +void load_object2(std::string const &key, std::string const &mtlid, const std::string &instID, + zeno::PrimitiveObject* prim, std::vector &matids, + std::vector const &matNameList) +{ + DrawDat2 &dat = drawdats2[key]; + dat.triMats = matids; + dat.mtlidList = matNameList; + dat.mtlid = mtlid; + dat.instID = instID; + dat.pos = prim->verts; + dat.nrm = prim->verts.attr("nrm"); + dat.uv = prim->verts.attr("uv"); + dat.clr = prim->verts.attr("clr"); + dat.tang = prim->verts.attr("atang"); + dat.triIdx = prim->tris; +} void load_object(std::string const &key, std::string const &mtlid, const std::string &instID, float const *verts, size_t numverts, int const *tris, size_t numtris,