From 3ed0dc89d1db3f5108c1bdf29eba2156adbc842a Mon Sep 17 00:00:00 2001 From: apradhana Date: Tue, 10 Sep 2024 12:17:13 -0700 Subject: [PATCH] Template specialization of cwiseAdd for Vec3 half should be in Types.h and not in Vec3.h. Signed-off-by: apradhana --- openvdb/openvdb/Types.h | 17 +++++++++++++++++ openvdb/openvdb/math/Vec3.h | 14 -------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/openvdb/openvdb/Types.h b/openvdb/openvdb/Types.h index ad811e1520..d654750b7e 100644 --- a/openvdb/openvdb/Types.h +++ b/openvdb/openvdb/Types.h @@ -688,6 +688,23 @@ class Steal {}; /// @brief Tag dispatch class that distinguishes constructors during file input class PartialCreate {}; +// For half compilation +namespace math { +template<> +inline auto cwiseAdd(const math::Vec3& v, const float s) +{ + math::Vec3 out; + const math::half* ip = v.asPointer(); + math::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; +} +} // namespace math + } // namespace OPENVDB_VERSION_NAME } // namespace openvdb diff --git a/openvdb/openvdb/math/Vec3.h b/openvdb/openvdb/math/Vec3.h index 0b8c5acceb..2ea5d32838 100644 --- a/openvdb/openvdb/math/Vec3.h +++ b/openvdb/openvdb/math/Vec3.h @@ -594,20 +594,6 @@ 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