From b63dfb71388f8d710b55882af68c7bcc84353767 Mon Sep 17 00:00:00 2001 From: littlemine Date: Tue, 20 Aug 2024 15:51:27 +0800 Subject: [PATCH] fix fbx typo, upd zpc --- projects/CUDA/SpatialAccel.cuh | 10 ++-- projects/CUDA/Structures.hpp | 14 +++--- projects/CUDA/Utils.hpp | 12 ++--- projects/CUDA/iw_query/Query.cpp | 18 ++++---- projects/CUDA/remesh/simplification.cpp | 6 +-- projects/CUDA/test.cpp | 18 +++++++- projects/CUDA/test1.cu | 2 +- projects/CUDA/utils/Groom.cpp | 2 +- projects/CUDA/utils/Primitives.cpp | 46 +++++++++---------- projects/CUDA/utils/Primitives.cu | 4 +- projects/CUDA/utils/TopoUtils.cu | 4 +- projects/CUDA/zpc | 2 +- projects/CuEulerian/hybrid/P2G.cu | 4 +- projects/CuEulerian/levelset/Extrapolation.cu | 8 ++-- .../levelset/Grid_creator_adaptive.cu | 2 +- .../navierstokes/NS_linearsolver.cu | 6 +-- projects/CuEulerian/navierstokes/NS_topo.cu | 2 +- projects/CuEulerian/swe/Erode.cu | 4 +- projects/CuEulerian/swe/SWE_dense.cu | 4 +- projects/CuEulerian/volume/Transfer.cu | 6 +-- projects/FBX/DualQuaternion.cpp | 2 +- projects/PyZpc/interop/Vector_nodes.cu | 4 +- 22 files changed, 98 insertions(+), 82 deletions(-) diff --git a/projects/CUDA/SpatialAccel.cuh b/projects/CUDA/SpatialAccel.cuh index 71c0a095eb..9785a2e3be 100644 --- a/projects/CUDA/SpatialAccel.cuh +++ b/projects/CUDA/SpatialAccel.cuh @@ -89,7 +89,7 @@ struct ZenoLBvh { Vector box{orderedBvs.get_allocator(), 1}; if (numLeaves <= 2) { using TV = typename Box::TV; - box.setVal(Box{TV::uniform(limits::max()), TV::uniform(limits::lowest())}); + box.setVal(Box{TV::uniform(detail::deduce_numeric_max()), TV::uniform(detail::deduce_numeric_lowest())}); pol(Collapse{numLeaves}, [bvh = proxy(*this), box = proxy(box)] ZS_LAMBDA(int vi) mutable { auto bv = bvh.getNodeBV(vi); for (int d = 0; d != dim; ++d) { @@ -239,13 +239,13 @@ void ZenoLBvh::build(zs::CudaExecution auto lOffsets = proxy(leafOffsets); // total bounding volume - const auto defaultBox = Box{TV::uniform(limits::max()), TV::uniform(limits::lowest())}; + const auto defaultBox = Box{TV::uniform(detail::deduce_numeric_max()), TV::uniform(detail::deduce_numeric_lowest())}; Vector wholeBox{primBvs.get_allocator(), 1}; wholeBox.setVal(defaultBox); policy(primBvs, [box = proxy(wholeBox), execTag] ZS_LAMBDA(const Box &bv) mutable { for (int d = 0; d != dim; ++d) { - atomic_min(execTag, &box(0)._min[d], bv._min[d] - 10 * limits::epsilon()); - atomic_max(execTag, &box(0)._max[d], bv._max[d] + 10 * limits::epsilon()); + atomic_min(execTag, &box(0)._min[d], bv._min[d] - 10 * detail::deduce_numeric_epsilon()); + atomic_max(execTag, &box(0)._max[d], bv._max[d] + 10 * detail::deduce_numeric_epsilon()); } }); @@ -624,7 +624,7 @@ void ZenoLBvh::refit(zs::CudaExecution // refit #if 0 policy(orderedBvs, [] ZS_LAMBDA(auto &bv) { - bv = Box{TV::uniform(limits::max()), TV::uniform(limits::lowest())}; + bv = Box{TV::uniform(detail::deduce_numeric_max()), TV::uniform(detail::deduce_numeric_lowest())}; }); #endif policy(Collapse{numLeaves}, [primBvs = proxy(primBvs), orderedBvs = proxy(orderedBvs), diff --git a/projects/CUDA/Structures.hpp b/projects/CUDA/Structures.hpp index aa85b519bc..d44c06ba17 100644 --- a/projects/CUDA/Structures.hpp +++ b/projects/CUDA/Structures.hpp @@ -339,7 +339,7 @@ struct ZenoParticles : IObjectClone { using namespace zs; constexpr execspace_e space = RM_CVREF_T(pol)::exec_tag::value; constexpr auto defaultBv = - bv_t{vec3f::constant(zs::limits::max()), vec3f::constant(zs::limits::lowest())}; + bv_t{vec3f::constant(zs::detail::deduce_numeric_max()), vec3f::constant(zs::detail::deduce_numeric_lowest())}; if (!particles) return defaultBv; @@ -357,14 +357,14 @@ struct ZenoParticles : IObjectClone { y = xn[1]; z = xn[2]; }); - zs::reduce(pol, std::begin(X), std::end(X), std::begin(res), zs::limits::max(), getmin{}); - zs::reduce(pol, std::begin(X), std::end(X), std::begin(res) + 3, zs::limits::lowest(), + zs::reduce(pol, std::begin(X), std::end(X), std::begin(res), zs::detail::deduce_numeric_max(), getmin{}); + zs::reduce(pol, std::begin(X), std::end(X), std::begin(res) + 3, zs::detail::deduce_numeric_lowest(), getmax{}); - zs::reduce(pol, std::begin(Y), std::end(Y), std::begin(res) + 1, zs::limits::max(), getmin{}); - zs::reduce(pol, std::begin(Y), std::end(Y), std::begin(res) + 4, zs::limits::lowest(), + zs::reduce(pol, std::begin(Y), std::end(Y), std::begin(res) + 1, zs::detail::deduce_numeric_max(), getmin{}); + zs::reduce(pol, std::begin(Y), std::end(Y), std::begin(res) + 4, zs::detail::deduce_numeric_lowest(), getmax{}); - zs::reduce(pol, std::begin(Z), std::end(Z), std::begin(res) + 2, zs::limits::max(), getmin{}); - zs::reduce(pol, std::begin(Z), std::end(Z), std::begin(res) + 5, zs::limits::lowest(), + zs::reduce(pol, std::begin(Z), std::end(Z), std::begin(res) + 2, zs::detail::deduce_numeric_max(), getmin{}); + zs::reduce(pol, std::begin(Z), std::end(Z), std::begin(res) + 5, zs::detail::deduce_numeric_lowest(), getmax{}); res = res.clone({memsrc_e::host, -1}); return bv_t{vec3f{res[0], res[1], res[2]}, vec3f{res[3], res[4], res[5]}}; diff --git a/projects/CUDA/Utils.hpp b/projects/CUDA/Utils.hpp index ed93bd4464..9914c1491b 100644 --- a/projects/CUDA/Utils.hpp +++ b/projects/CUDA/Utils.hpp @@ -282,7 +282,7 @@ constexpr bool pt_accd(VecT p, VecT t0, VecT t1, VecT t2, VecT dp, VecT dt0, dt2 -= mov; dp -= mov; T dispMag2Vec[3] = {dt0.l2NormSqr(), dt1.l2NormSqr(), dt2.l2NormSqr()}; - T tmp = zs::limits::lowest(); + T tmp = zs::detail::deduce_numeric_lowest(); for (int i = 0; i != 3; ++i) if (dispMag2Vec[i] > tmp) tmp = dispMag2Vec[i]; @@ -343,7 +343,7 @@ ee_accd(VecT ea0, VecT ea1, VecT eb0, VecT eb1, VecT dea0, VecT dea1, VecT deb0, T dists[] = {(ea0 - eb0).l2NormSqr(), (ea0 - eb1).l2NormSqr(), (ea1 - eb0).l2NormSqr(), (ea1 - eb1).l2NormSqr()}; { - dist2_cur = zs::limits::max(); + dist2_cur = zs::detail::deduce_numeric_max(); for (const auto &dist : dists) if (dist < dist2_cur) dist2_cur = dist; @@ -378,7 +378,7 @@ ee_accd(VecT ea0, VecT ea1, VecT eb0, VecT eb1, VecT dea0, VecT dea1, VecT deb0, T dists[] = {(ea0 - eb0).l2NormSqr(), (ea0 - eb1).l2NormSqr(), (ea1 - eb0).l2NormSqr(), (ea1 - eb1).l2NormSqr()}; { - dist2_cur = zs::limits::max(); + dist2_cur = zs::detail::deduce_numeric_max(); for (const auto &dist : dists) if (dist < dist2_cur) dist2_cur = dist; @@ -568,7 +568,7 @@ void find_intersection_free_stepsize(Pol &pol, ZenoParticles &zstets, atomic_min(exec_cuda, &finalAlpha[0], alpha); }); // zs::reduce(pol, std::begin(surfAlphas), std::end(surfAlphas), - // std::begin(finalAlpha), limits::max(), getmin{}); + // std::begin(finalAlpha), detail::deduce_numeric_max(), getmin{}); auto surfAlpha = finalAlpha.getVal(); fmt::print(fg(fmt::color::dark_cyan), "surface alpha: {}, default stepsize: {}\n", surfAlpha, stepSize); @@ -708,7 +708,7 @@ void find_boundary_intersection_free_stepsize(Pol &pol, ZenoParticles &zstets, }); }); // zs::reduce(pol, std::begin(surfAlphas), std::end(surfAlphas), - // std::begin(finalAlpha), limits::max(), getmin{}); + // std::begin(finalAlpha), detail::deduce_numeric_max(), getmin{}); auto surfAlpha = finalAlpha.getVal(); stepSize = surfAlpha; fmt::print(fg(fmt::color::dark_cyan), @@ -758,7 +758,7 @@ void find_boundary_intersection_free_stepsize(Pol &pol, ZenoParticles &zstets, }); #if 0 zs::reduce(pol, std::begin(surfEdgeAlphas), std::end(surfEdgeAlphas), - std::begin(finalAlpha), limits::max(), getmin{}); + std::begin(finalAlpha), detail::deduce_numeric_max(), getmin{}); stepSize = std::min(surfAlpha, finalAlpha.getVal()); #else stepSize = finalAlpha.getVal(); diff --git a/projects/CUDA/iw_query/Query.cpp b/projects/CUDA/iw_query/Query.cpp index fa92296dfd..a63f5da2ab 100644 --- a/projects/CUDA/iw_query/Query.cpp +++ b/projects/CUDA/iw_query/Query.cpp @@ -90,9 +90,9 @@ struct QueryNearestPoints : INode { gmin = vertices[i][d]; gmax = vertices[i][d]; }); - reduce(pol, std::begin(gmins), std::end(gmins), std::begin(ret), limits::max(), getmin{}); + reduce(pol, std::begin(gmins), std::end(gmins), std::begin(ret), detail::deduce_numeric_max(), getmin{}); gbv._min[d] = ret.getVal(); - reduce(pol, std::begin(gmaxs), std::end(gmaxs), std::begin(ret), limits::lowest(), getmax{}); + reduce(pol, std::begin(gmaxs), std::end(gmaxs), std::begin(ret), detail::deduce_numeric_lowest(), getmax{}); gbv._max[d] = ret.getVal(); } int axis = 0; // x-axis by default @@ -130,8 +130,8 @@ struct QueryNearestPoints : INode { { int cnt = 0; for (int i = 0; i < vertices.size() - 1; ++i) { - if ((keys[i] >= limits::epsilon() || keys[i] <= -limits::epsilon()) && - (keys[i + 1] >= limits::epsilon() || keys[i + 1] <= -limits::epsilon())) + if ((keys[i] >= detail::deduce_numeric_epsilon() || keys[i] <= -detail::deduce_numeric_epsilon()) && + (keys[i + 1] >= detail::deduce_numeric_epsilon() || keys[i + 1] <= -detail::deduce_numeric_epsilon())) if (keys[i] > keys[i + 1]) { printf("order is wrong at [%d] ... %e, %e...\n", i, keys[i], keys[i + 1]); cnt++; @@ -172,7 +172,7 @@ struct QueryNearestPoints : INode { pol(enumerate(pos, locs, dists, ids, cps), [&xs, &indices, axis](int i, const auto &xi, const int loc, float &dist, int &id, vec3f &cp) { int l = loc + 1; - float d2 = limits::max(); + float d2 = detail::deduce_numeric_max(); int j = -1; int cnt = 0; while (l < xs.size() && cnt++ < 128) { @@ -265,7 +265,7 @@ struct QueryNearestPoints : INode { pol(enumerate(pos, dists, ids, cps), [&pos, &vertices, &locs, &xs, &indices, bvh = proxy(bvh), axis]( int i, const zeno::vec3f &p, float &dist, int &id, zeno::vec3f &cp) { auto target = vertices[id]; - if (auto d = zeno::length(p - target); std::abs(d - dist) > limits::epsilon()) + if (auto d = zeno::length(p - target); std::abs(d - dist) > detail::deduce_numeric_epsilon()) fmt::print("actual dist {}, cp ({}, {}, {}); calced dist {}, cp ({}, {}, {}). \n", d, target[0], target[1], target[2], dist, cp[0], cp[1], cp[2]); const int loc = locs[i]; @@ -275,7 +275,7 @@ struct QueryNearestPoints : INode { auto key = xi[axis]; int l = loc + 1; while (l < xs.size() && zs::sqr(xs[l][axis] - key) < dist2) { - if (auto d2 = zeno::lengthSquared(xs[l] - xi); std::sqrt(d2) + limits::epsilon() < dist) { + if (auto d2 = zeno::lengthSquared(xs[l] - xi); std::sqrt(d2) + detail::deduce_numeric_epsilon() < dist) { fmt::print("[{}] found nearer pair! real id should be {} ({}), not {} ({})\n", i, indices[l], std::sqrt(d2), id, std::sqrt(dist2)); return; @@ -284,7 +284,7 @@ struct QueryNearestPoints : INode { } l = loc; while (l >= 0 && zs::sqr(xs[l][axis] - key) < dist2) { - if (auto d2 = zeno::lengthSquared(xs[l] - xi); std::sqrt(d2) + limits::epsilon() < dist) { + if (auto d2 = zeno::lengthSquared(xs[l] - xi); std::sqrt(d2) + detail::deduce_numeric_epsilon() < dist) { fmt::print("[{}] found nearer pair! real id should be {} ({}), not {} ({})\n", i, indices[l], std::sqrt(d2), id, dist); return; @@ -302,7 +302,7 @@ struct QueryNearestPoints : INode { timer.tick(); pol(zip(range(pos.size()), locs), [&locs, &xs, &vertices, &indices, &pos, &ids, &dists, &cps, axis](int i, const int loc) { - float dist2 = limits::max(); + float dist2 = detail::deduce_numeric_max(); int id = -1; auto xi = pos[i]; auto key = xi[axis]; diff --git a/projects/CUDA/remesh/simplification.cpp b/projects/CUDA/remesh/simplification.cpp index f4773d2db8..087da76c11 100644 --- a/projects/CUDA/remesh/simplification.cpp +++ b/projects/CUDA/remesh/simplification.cpp @@ -69,12 +69,12 @@ struct PolyReduceLite : INode { // zeno::log_warn(fmt::format("begin iter {}\n", i)); /// evaluate vert curvatures pol(range(pos.size()), [&](int i) { - vertEdgeCosts[i] = std::make_pair(limits::max(), std::make_pair(i, -1)); + vertEdgeCosts[i] = std::make_pair(detail::deduce_numeric_max(), std::make_pair(i, -1)); if (vertVerts[i].size() == 0 || vertDiscard[i]) { return; } - auto cost = limits::max(); + auto cost = detail::deduce_numeric_max(); for (auto j : vertVerts[i]) { if (vertDiscard[j]) continue; @@ -105,7 +105,7 @@ struct PolyReduceLite : INode { /// sort edges for collapse auto pair = std::reduce( std::begin(vertEdgeCosts), std::end(vertEdgeCosts), - std::make_pair(limits::max(), std::make_pair(-1, -1)), + std::make_pair(detail::deduce_numeric_max(), std::make_pair(-1, -1)), [](const std::pair> &a, const std::pair> &b) { if (a.first < b.first) return a; diff --git a/projects/CUDA/test.cpp b/projects/CUDA/test.cpp index b414e65329..d8a9845866 100644 --- a/projects/CUDA/test.cpp +++ b/projects/CUDA/test.cpp @@ -21,6 +21,12 @@ #include "zensim/execution/ConcurrencyPrimitive.hpp" #include "zensim/visitors/Print.hpp" +#if 0 +#include "glm/glm.hpp" +#include "glm/gtx/quaternion.hpp" +#include +#endif + namespace zeno { struct spinlock { @@ -442,6 +448,16 @@ struct ZSLinkTest : INode { void apply() override { using namespace zs; constexpr auto space = execspace_e::openmp; + +#if 0 + glm::vec3 v{1, 2, 3}; + glm::mat3 m; + glm::quat q= {1, 0, 0, 0}; + zeno::log_info("glm vec3: {}", v); + zeno::log_info("glm mat3: {}", m); + zeno::log_info("glm quat: {}", q); +#endif + #if 0 using namespace zs; zs::initialize_openvdb(); @@ -839,7 +855,7 @@ struct TestAdaptiveGrid : INode { auto cc = c.cast() / 3; auto vv = zsagv.iSample(0, cc); openvdb::FloatGrid::ValueType vref = sampler.isSample(openvdb::Vec3R(cc[0], cc[1], cc[2])); - if (zs::abs(vref - vv) >= limits::epsilon()) { + if (zs::abs(vref - vv) >= detail::deduce_numeric_epsilon()) { fmt::print(fg(fmt::color::green), "sampled value is {} ({}) at {}, {}, {}\n", v, vv, vref, cc[0], cc[1], cc[2]); } diff --git a/projects/CUDA/test1.cu b/projects/CUDA/test1.cu index 02b89b47f8..f459b540c6 100644 --- a/projects/CUDA/test1.cu +++ b/projects/CUDA/test1.cu @@ -76,7 +76,7 @@ struct ZSCUMathTest : INode { constexpr int n = 100; using TV = zs::vec; //TV m_X[4] = {TV{0, 0, 0}, TV{0, 1, 0}, TV{0, 0, -1}, TV{0, 0, 1}}; - TV m_X[4] = {TV{0, 0, 0}, TV{0, 1, 0}, TV{0, 0, -1}, TV{-limits::epsilon() * 5, 1, -1}}; + TV m_X[4] = {TV{0, 0, 0}, TV{0, 1, 0}, TV{0, 0, -1}, TV{-detail::deduce_numeric_epsilon() * 5, 1, -1}}; auto ra = zs::dihedral_angle(m_X[2], m_X[0], m_X[1], m_X[3], exec_seq); auto grad = zs::dihedral_angle_gradient(m_X[2], m_X[0], m_X[1], m_X[3], exec_seq); auto hess = zs::dihedral_angle_hessian(m_X[2], m_X[0], m_X[1], m_X[3], exec_seq); diff --git a/projects/CUDA/utils/Groom.cpp b/projects/CUDA/utils/Groom.cpp index 16f484e6b9..f57caca64c 100644 --- a/projects/CUDA/utils/Groom.cpp +++ b/projects/CUDA/utils/Groom.cpp @@ -625,7 +625,7 @@ struct GenerateHairs : INode { auto [id, _] = lbvhv.find_nearest( pi, [&](int j, float &dist, int &id) { - float d = zs::limits::max(); + float d = zs::detail::deduce_numeric_max(); d = zs::dist_pp(pi, vec3::from_array(verts[loops[polys[j][0]]])); if (d < dist) { diff --git a/projects/CUDA/utils/Primitives.cpp b/projects/CUDA/utils/Primitives.cpp index 57068512e9..879270a4cf 100644 --- a/projects/CUDA/utils/Primitives.cpp +++ b/projects/CUDA/utils/Primitives.cpp @@ -611,7 +611,7 @@ struct PrimitiveReorder : INode { /// @note bv constexpr auto defaultBv = - bv_t{zsvec3::constant(zs::limits::max()), zsvec3::constant(zs::limits::lowest())}; + bv_t{zsvec3::constant(zs::detail::deduce_numeric_max()), zsvec3::constant(zs::detail::deduce_numeric_lowest())}; bv_t gbv; if (orderVerts || orderTris) { @@ -626,21 +626,21 @@ struct PrimitiveReorder : INode { y = xn[1]; z = xn[2]; }); - zs::reduce(pol, std::begin(X), std::end(X), std::begin(res), zs::limits::max(), getmin{}); - zs::reduce(pol, std::begin(X), std::end(X), std::begin(res) + 3, zs::limits::lowest(), + zs::reduce(pol, std::begin(X), std::end(X), std::begin(res), zs::detail::deduce_numeric_max(), getmin{}); + zs::reduce(pol, std::begin(X), std::end(X), std::begin(res) + 3, zs::detail::deduce_numeric_lowest(), getmax{}); - zs::reduce(pol, std::begin(Y), std::end(Y), std::begin(res) + 1, zs::limits::max(), + zs::reduce(pol, std::begin(Y), std::end(Y), std::begin(res) + 1, zs::detail::deduce_numeric_max(), getmin{}); - zs::reduce(pol, std::begin(Y), std::end(Y), std::begin(res) + 4, zs::limits::lowest(), + zs::reduce(pol, std::begin(Y), std::end(Y), std::begin(res) + 4, zs::detail::deduce_numeric_lowest(), getmax{}); - zs::reduce(pol, std::begin(Z), std::end(Z), std::begin(res) + 2, zs::limits::max(), + zs::reduce(pol, std::begin(Z), std::end(Z), std::begin(res) + 2, zs::detail::deduce_numeric_max(), getmin{}); - zs::reduce(pol, std::begin(Z), std::end(Z), std::begin(res) + 5, zs::limits::lowest(), + zs::reduce(pol, std::begin(Z), std::end(Z), std::begin(res) + 5, zs::detail::deduce_numeric_lowest(), getmax{}); gbv = bv_t{zsvec3{res[0], res[1], res[2]}, zsvec3{res[3], res[4], res[5]}}; } - gbv._min -= limits::epsilon() * 16; - gbv._max += limits::epsilon() * 16; + gbv._min -= detail::deduce_numeric_epsilon() * 16; + gbv._max += detail::deduce_numeric_epsilon() * 16; /// @note reorder struct Mapping { @@ -2820,9 +2820,9 @@ struct ComputeAverageEdgeLength : INode { fmt::print("sum edge lengths: {}, num edges: {}\n", sum[0], els.size()); #endif zs::reduce(pol, std::begin(els), std::end(els), std::begin(sum), 0); - zs::reduce(pol, std::begin(els), std::end(els), std::begin(minEl), zs::limits::max(), + zs::reduce(pol, std::begin(els), std::end(els), std::begin(minEl), zs::detail::deduce_numeric_max(), zs::getmin{}); - zs::reduce(pol, std::begin(els), std::end(els), std::begin(maxEl), zs::limits::min(), + zs::reduce(pol, std::begin(els), std::end(els), std::begin(maxEl), zs::detail::deduce_numeric_min(), zs::getmax{}); set_output("prim", prim); @@ -2988,7 +2988,7 @@ struct ParticleCluster : zeno::INode { }); /// @brief uv - if (pars->has_attr("uv") && uvDist > zs::limits::epsilon() * 10) { + if (pars->has_attr("uv") && uvDist > zs::detail::deduce_numeric_epsilon() * 10) { const auto &uv = pars->attr("uv"); pol(range(pos.size()), [&neighbors, &uv, uvDist2 = uvDist * uvDist](int vi) mutable { int n = neighbors[vi].size(); @@ -3071,7 +3071,7 @@ struct ParticleSegmentation : zeno::INode { float uvDist2 = zs::sqr(get_input2("uv_dist")); const vec2f *uvPtr = nullptr; - if (pars->has_attr("uv") && std::sqrt(uvDist2) > zs::limits::epsilon() * 10) + if (pars->has_attr("uv") && std::sqrt(uvDist2) > zs::detail::deduce_numeric_epsilon() * 10) uvPtr = pars->attr("uv").data(); using namespace zs; @@ -3528,7 +3528,7 @@ struct PrimitiveColoring : INode { pol(range(spmat.outerSize()), [&colors, spmat = proxy(spmat), correct = proxy(correct)](int i) mutable { auto color = colors[i]; - if (color == limits::max()) { + if (color == detail::deduce_numeric_max()) { correct[0] = 0; printf("node [%d]: %f. not colored!\n", i, (float)color); return; @@ -3560,7 +3560,7 @@ struct PrimitiveColoring : INode { pol(range(spmat.outerSize()), [&colors, spmat = proxy(spmat), correct = proxy(correct)](int i) mutable { auto color = colors[i]; - if (color == limits::max()) { + if (color == detail::deduce_numeric_max()) { correct[0] = 0; printf("node [%d]: %f. not colored!\n", i, (float)color); return; @@ -3591,11 +3591,11 @@ struct PrimitiveColoring : INode { bool done = true; pol(zip(weights, minWeights, maskOut, colors), [&](u32 &w, u32 &mw, int &mask, float &color) { //if (w < mw && mask == 0) - if (w < mw && mw != limits::max()) { + if (w < mw && mw != detail::deduce_numeric_max()) { done = false; mask = 1; color = iter; - w = limits::max(); + w = detail::deduce_numeric_max(); } }); return done; @@ -3786,16 +3786,16 @@ struct QueryClosestPrimitive : zeno::INode { std::vector ids(prim->size(), -1); pol(zs::range(prim->size()), [&, lbvh = zs::proxy(lbvh), et = zsbvh->et](int i) { using vec3 = zs::vec; - kvs[i].dist = zs::limits::max(); + kvs[i].dist = zs::detail::deduce_numeric_max(); kvs[i].pid = i; auto pi = vec3::from_array(prim->verts[i]); - float radius = zs::limits::max(); + float radius = zs::detail::deduce_numeric_max(); if (prim->has_attr(radiusTag)) radius = prim->attr(radiusTag)[i]; lbvh.find_nearest( pi, [&ids, &kvs, &pi, &targetPrim, i, et](int j, float &dist, int &idx) { - float d = zs::limits::max(); + float d = zs::detail::deduce_numeric_max(); if (et == ZenoLinearBvh::point) { d = zs::dist_pp(pi, vec3::from_array(targetPrim->verts[j])); } else if (et == ZenoLinearBvh::curve) { @@ -3865,7 +3865,7 @@ struct QueryClosestPrimitive : zeno::INode { auto lbvhv = zs::proxy(lbvh); lbvhv.find_nearest(pi, [&, et = zsbvh->et](int j, float &dist_, int &idx) { using vec3 = zs::vec; - float d = zs::limits::max(); + float d = zs::detail::deduce_numeric_max(); if (et == ZenoLinearBvh::point) { d = zs::dist_pp(pi, vec3::from_array(targetPrim->verts[j])); } else if (et == ZenoLinearBvh::curve) { @@ -4099,9 +4099,9 @@ static zeno::vec3f compute_dimensions(const PrimitiveObject &primA, const Primit pol(zs::enumerate(posB), [&, offset = posA.size()](int col, const auto &p) { locs[col + offset] = p[d]; }); std::vector ret(2); - zs::reduce(pol, std::begin(locs), std::end(locs), std::begin(ret), zs::limits::max(), + zs::reduce(pol, std::begin(locs), std::end(locs), std::begin(ret), zs::detail::deduce_numeric_max(), zs::getmin()); - zs::reduce(pol, std::begin(locs), std::end(locs), std::begin(ret) + 1, zs::limits::lowest(), + zs::reduce(pol, std::begin(locs), std::end(locs), std::begin(ret) + 1, zs::detail::deduce_numeric_lowest(), zs::getmax()); dims[d] = ret[1] - ret[0]; }; diff --git a/projects/CUDA/utils/Primitives.cu b/projects/CUDA/utils/Primitives.cu index 30a5d0d8d7..8dd15b78c7 100644 --- a/projects/CUDA/utils/Primitives.cu +++ b/projects/CUDA/utils/Primitives.cu @@ -199,9 +199,9 @@ struct ZSPrimitiveReduction : zeno::INode { if (opStr == "avg") { result = prim_reduce(verts, 0, pass_on{}, std::plus{}, attrToReduce) / verts.size(); } else if (opStr == "max") { - result = prim_reduce(verts, limits::lowest(), pass_on{}, getmax{}, attrToReduce); + result = prim_reduce(verts, detail::deduce_numeric_lowest(), pass_on{}, getmax{}, attrToReduce); } else if (opStr == "min") { - result = prim_reduce(verts, limits::max(), pass_on{}, getmin{}, attrToReduce); + result = prim_reduce(verts, detail::deduce_numeric_max(), pass_on{}, getmin{}, attrToReduce); } else if (opStr == "absmax") { result = prim_reduce(verts, 0, getabs{}, getmax{}, attrToReduce); } diff --git a/projects/CUDA/utils/TopoUtils.cu b/projects/CUDA/utils/TopoUtils.cu index c70ce06c5c..d2a66d3eb6 100644 --- a/projects/CUDA/utils/TopoUtils.cu +++ b/projects/CUDA/utils/TopoUtils.cu @@ -152,7 +152,7 @@ void update_surface_cell_normals(zs::CudaExecutionPolicy &pol, ZenoParticles::pa using vec3 = RM_CVREF_T(t0); using T = typename vec3::value_type; auto nrm = (t1 - t0).cross(t2 - t0); - if (auto len = nrm.l2NormSqr(); len > limits::epsilon() * 10) + if (auto len = nrm.l2NormSqr(); len > detail::deduce_numeric_epsilon() * 10) nrm /= zs::sqrt(len); else nrm = vec3::zeros(); @@ -179,7 +179,7 @@ void update_surface_cell_normals(zs::CudaExecutionPolicy &pol, ZenoParticles::pa using vec3 = RM_CVREF_T(e0); using T = typename vec3::value_type; auto nrm = ne.cross(e10); - if (auto len = nrm.l2NormSqr(); len > limits::epsilon() * 10) + if (auto len = nrm.l2NormSqr(); len > detail::deduce_numeric_epsilon() * 10) nrm /= zs::sqrt(len); else nrm = vec3::zeros(); diff --git a/projects/CUDA/zpc b/projects/CUDA/zpc index 764099cd57..b7ac10424c 160000 --- a/projects/CUDA/zpc +++ b/projects/CUDA/zpc @@ -1 +1 @@ -Subproject commit 764099cd5778d08e0d6bd375c79ec4702e7dcd68 +Subproject commit b7ac10424c58720992ea9795db328bfe68429c07 diff --git a/projects/CuEulerian/hybrid/P2G.cu b/projects/CuEulerian/hybrid/P2G.cu index d706071b0a..8e69a94d73 100644 --- a/projects/CuEulerian/hybrid/P2G.cu +++ b/projects/CuEulerian/hybrid/P2G.cu @@ -342,7 +342,7 @@ struct ZSPrimitiveToSparseGrid : INode { nchns] __device__(std::size_t cellno) mutable { for (int d = 0; d < nchns; ++d) { auto wd = spg(wOffset + d, cellno); - if (wd > limits::epsilon() * 10) { + if (wd > detail::deduce_numeric_epsilon() * 10) { spg(tagDstOffset + d, cellno) /= wd; } } @@ -353,7 +353,7 @@ struct ZSPrimitiveToSparseGrid : INode { wOffset = spg._grid.getPropertyOffset("weight"), nchns] __device__(std::size_t cellno) mutable { auto w = spg(wOffset, cellno); - if (w > limits::epsilon() * 10) { + if (w > detail::deduce_numeric_epsilon() * 10) { for (int d = 0; d < nchns; ++d) spg(tagDstOffset + d, cellno) /= w; } diff --git a/projects/CuEulerian/levelset/Extrapolation.cu b/projects/CuEulerian/levelset/Extrapolation.cu index 10529bf4d2..b2022fcd86 100644 --- a/projects/CuEulerian/levelset/Extrapolation.cu +++ b/projects/CuEulerian/levelset/Extrapolation.cu @@ -215,7 +215,7 @@ struct ZSGridExtrapolateAttr : INode { normal[1] = (sdf_y[1] - sdf_y[0]) / (2.f * dx); normal[2] = (sdf_z[1] - sdf_z[0]) / (2.f * dx); - normal /= zs::max(normal.length(), zs::limits::epsilon() * 10); + normal /= zs::max(normal.length(), zs::detail::deduce_numeric_epsilon() * 10); spgv._grid.tuple(zs::dim_c<3>, "adv", blockno * spgv.block_size + cellno) = normal; } @@ -404,8 +404,8 @@ struct ZSGridExtrapolateAttr : INode { } } - if ((extDir == "negative" && sdf < -zs::limits::epsilon() * 10) || - (extDir == "positive" && sdf > zs::limits::epsilon() * 10) || extDir == "both") { + if ((extDir == "negative" && sdf < -zs::detail::deduce_numeric_epsilon() * 10) || + (extDir == "positive" && sdf > zs::detail::deduce_numeric_epsilon() * 10) || extDir == "both") { zs::vec normal = spgv._grid.pack(zs::dim_c<3>, "adv", blockno * spgv.block_size + cellno); @@ -422,7 +422,7 @@ struct ZSGridExtrapolateAttr : INode { spgv._grid.pack(zs::dim_c<3>, "adv", blockno * spgv.block_size + n_cellno); } - normal /= zs::max(normal.length(), zs::limits::epsilon() * 10); + normal /= zs::max(normal.length(), zs::detail::deduce_numeric_epsilon() * 10); } auto sign = [](float val) { return val > 0 ? 1 : -1; }; diff --git a/projects/CuEulerian/levelset/Grid_creator_adaptive.cu b/projects/CuEulerian/levelset/Grid_creator_adaptive.cu index 03020ac855..064ffe545c 100644 --- a/projects/CuEulerian/levelset/Grid_creator_adaptive.cu +++ b/projects/CuEulerian/levelset/Grid_creator_adaptive.cu @@ -297,7 +297,7 @@ struct ValidateAdaptiveGrid : INode { // zs::vec zsp{p[0], p[1], p[2]}; auto v = zsagv.wSample(zsacc, 0, zsp); - if (zs::abs(vref - v) >= limits::epsilon() && + if (zs::abs(vref - v) >= detail::deduce_numeric_epsilon() && vref != sdf->background()) fmt::print("\tref: {}, actual: {}\n", vref, v); else diff --git a/projects/CuEulerian/navierstokes/NS_linearsolver.cu b/projects/CuEulerian/navierstokes/NS_linearsolver.cu index f842bf2c57..8f42fc474c 100644 --- a/projects/CuEulerian/navierstokes/NS_linearsolver.cu +++ b/projects/CuEulerian/navierstokes/NS_linearsolver.cu @@ -198,7 +198,7 @@ struct ZSNSPressureProject : INode { auto stclSum = tile.shfl(stclVal, 1); auto cutSum = tile.shfl(cutVal, 1); - cutSum = zs::max(cutSum, zs::limits::epsilon() * 10); + cutSum = zs::max(cutSum, zs::detail::deduce_numeric_epsilon() * 10); if (lane_id == 0) { spgv(pOffset, blockno, 0) = stclVal + sor * (stclSum * dx - div * rho) / (cutSum * dx); } @@ -528,7 +528,7 @@ struct ZSNSPressureProject : INode { cut_z[1] = cut2shmem[idx + 1]; float cut_sum = cut_x[0] + cut_x[1] + cut_y[0] + cut_y[1] + cut_z[0] + cut_z[1]; - cut_sum = zs::max(cut_sum, zs::limits::epsilon() * 10); + cut_sum = zs::max(cut_sum, zs::detail::deduce_numeric_epsilon() * 10); p_self = (1.f - sor) * p_self + sor * @@ -1582,7 +1582,7 @@ void ZSNSPressureProject::coloredSOR<0>(zs::CudaExecutionPolicy &pol, ZenoSparse cut_z[1] = spgv.value(cutOffset + 2, icoord + vec3i(0, 0, 1), 1.f); float cut_sum = cut_x[0] + cut_x[1] + cut_y[0] + cut_y[1] + cut_z[0] + cut_z[1]; - cut_sum = zs::max(cut_sum, zs::limits::epsilon() * 10); + cut_sum = zs::max(cut_sum, zs::detail::deduce_numeric_epsilon() * 10); p_self = (1.f - sor) * p_self + sor * diff --git a/projects/CuEulerian/navierstokes/NS_topo.cu b/projects/CuEulerian/navierstokes/NS_topo.cu index 524f6dd9ca..03144ba48d 100644 --- a/projects/CuEulerian/navierstokes/NS_topo.cu +++ b/projects/CuEulerian/navierstokes/NS_topo.cu @@ -353,7 +353,7 @@ struct ZSMaintainSparseGrid : INode { else if (opt == 1) maintain( zsSPG.get(), src_tag(zsSPG, tag), - [] __device__(float v) -> bool { return v > zs::limits::epsilon() * 10; }, nlayers); + [] __device__(float v) -> bool { return v > zs::detail::deduce_numeric_epsilon() * 10; }, nlayers); else if (opt == 2) maintain( zsSPG.get(), src_tag(zsSPG, tag), diff --git a/projects/CuEulerian/swe/Erode.cu b/projects/CuEulerian/swe/Erode.cu index 55dd537ede..4fe6a2335b 100644 --- a/projects/CuEulerian/swe/Erode.cu +++ b/projects/CuEulerian/swe/Erode.cu @@ -29,7 +29,7 @@ namespace zs { } __forceinline__ __device__ zs::vec normalizeSafe(const zs::vec &a, - float b = zs::limits::epsilon()) { + float b = zs::detail::deduce_numeric_epsilon()) { return a * (1 / zs::max(b, a.length())); } @@ -1694,7 +1694,7 @@ namespace zeno { __forceinline__ __device__ float fit(const float data, const float ss, const float se, const float ds, const float de) { - float b = zs::limits::epsilon(); + float b = zs::detail::deduce_numeric_epsilon(); b = zs::max(zs::abs(se - ss), b); b = se - ss >= 0 ? b : -b; float alpha = (data - ss) / b; diff --git a/projects/CuEulerian/swe/SWE_dense.cu b/projects/CuEulerian/swe/SWE_dense.cu index 5e0f439cec..9bef4fe761 100644 --- a/projects/CuEulerian/swe/SWE_dense.cu +++ b/projects/CuEulerian/swe/SWE_dense.cu @@ -421,7 +421,7 @@ struct ZSSolveShallowWaterMomentum : INode { adv_term += w_adv * scheme::HJ_WENO3(u_old[idx(i, j - upwind)], u_old[idx(i, j)], u_old[idx(i, j + upwind)], u_old[idx(i, j + 2 * upwind)], w_adv, dx); h_f = 0.5f * (h[idx(i, j)] + h[idx(i - 1, j)]); - if (zs::abs(h_f) > zs::limits::epsilon() * 10) + if (zs::abs(h_f) > zs::detail::deduce_numeric_epsilon() * 10) grad_term = gravity * ((h[idx(i, j)] - h[idx(i - 1, j)]) / dx + (B[idx(i, j)] - B[idx(i - 1, j)]) / dx); else grad_term = 0; @@ -440,7 +440,7 @@ struct ZSSolveShallowWaterMomentum : INode { adv_term += w_adv * scheme::HJ_WENO3(w_old[idx(i, j - upwind)], w_old[idx(i, j)], w_old[idx(i, j + upwind)], w_old[idx(i, j + 2 * upwind)], w_adv, dx); h_f = 0.5f * (h[idx(i, j)] + h[idx(i, j - 1)]); - if (zs::abs(h_f) > zs::limits::epsilon() * 10) + if (zs::abs(h_f) > zs::detail::deduce_numeric_epsilon() * 10) grad_term = gravity * ((h[idx(i, j)] - h[idx(i, j - 1)]) / dx + (B[idx(i, j)] - B[idx(i, j - 1)]) / dx); else grad_term = 0; diff --git a/projects/CuEulerian/volume/Transfer.cu b/projects/CuEulerian/volume/Transfer.cu index fb60e15696..e2d641758f 100644 --- a/projects/CuEulerian/volume/Transfer.cu +++ b/projects/CuEulerian/volume/Transfer.cu @@ -131,7 +131,7 @@ struct PrimitiveToZSLevelSet : INode { auto block = ls._grid.block(ls._table.query(c - cellcoord)); auto cellno = lsv_t::grid_view_t::coord_to_cellid(cellcoord); auto nodePos = ls.indexToWorld(c); - constexpr float eps = limits::epsilon(); + constexpr float eps = detail::deduce_numeric_epsilon(); auto dis = zs::sqrt((x - nodePos).l2NormSqr() + eps); atomic_min(exec_cuda, &block("sdf", cellno), dis); @@ -205,8 +205,8 @@ struct PrimitiveToZSLevelSet : INode { ls._table.reset(true); Vector mi{1, memsrc_e::device}, ma{1, memsrc_e::device}; - mi.setVal(IV::uniform(limits::max())); - ma.setVal(IV::uniform(limits::lowest())); + mi.setVal(IV::uniform(detail::deduce_numeric_max())); + ma.setVal(IV::uniform(detail::deduce_numeric_lowest())); iterate(cudaPol, nvoxels, xs, ls, mi, ma); if (numEles) iterate(cudaPol, nvoxels, elePos, ls, mi, ma); diff --git a/projects/FBX/DualQuaternion.cpp b/projects/FBX/DualQuaternion.cpp index 8f7c731f75..68568bc7f3 100644 --- a/projects/FBX/DualQuaternion.cpp +++ b/projects/FBX/DualQuaternion.cpp @@ -80,7 +80,7 @@ constexpr glm::quat dual_quat(const glm::quat& q,const glm::vec3& t) { auto ty = t[1]; auto tz = t[2]; - glm::quat qd; + glm::quat qd{}; qd.w = -0.5*( tx*qx + ty*qy + tz*qz); // qd.w qd.x = 0.5*( tx*qw + ty*qz - tz*qy); // qd.x qd.y = 0.5*(-tx*qz + ty*qw + tz*qx); // qd.y diff --git a/projects/PyZpc/interop/Vector_nodes.cu b/projects/PyZpc/interop/Vector_nodes.cu index 194924a039..e34b84a93f 100644 --- a/projects/PyZpc/interop/Vector_nodes.cu +++ b/projects/PyZpc/interop/Vector_nodes.cu @@ -75,11 +75,11 @@ struct ReduceZsVector : INode { zs::plus{}); else if (opStr == "max") zs::reduce(pol, std::begin(vector), std::end(vector), - std::begin(res), zs::limits::min(), + std::begin(res), zs::detail::deduce_numeric_min(), zs::getmax{}); else zs::reduce(pol, std::begin(vector), std::end(vector), - std::begin(res), zs::limits::max(), + std::begin(res), zs::detail::deduce_numeric_max(), zs::getmin{}); result = static_cast(res.getVal()); },