From 59c23b4d719e5e5dc672683b2c12c5ecdd085e73 Mon Sep 17 00:00:00 2001 From: apradhana Date: Tue, 10 Sep 2024 10:53:22 -0700 Subject: [PATCH] Add cwiseAdd to Vec3.h because half type doesn't satisfy std::is_arithmetic so the operator doesn't get instantiated. Signed-off-by: apradhana --- openvdb/openvdb/math/Vec3.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/openvdb/openvdb/math/Vec3.h b/openvdb/openvdb/math/Vec3.h index 2ea5d32838..0b8c5acceb 100644 --- a/openvdb/openvdb/math/Vec3.h +++ b/openvdb/openvdb/math/Vec3.h @@ -594,6 +594,20 @@ Abs(const Vec3& v) return Vec3(Abs(v[0]), Abs(v[1]), Abs(v[2])); } +template<> +inline auto cwiseAdd(const Vec3& v, const float s) +{ + Vec3 out; + const math::internal::half* ip = v.asPointer(); + math::internal::half* op = out.asPointer(); + for (unsigned i = 0; i < 3; ++i, ++op, ++ip) { + OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN + *op = *ip + s; + OPENVDB_NO_TYPE_CONVERSION_WARNING_END + } + return out; +} + /// Orthonormalize vectors v1, v2 and v3 and store back the resulting /// basis e.g. Vec3d::orthonormalize(v1,v2,v3); template