Skip to content

Commit

Permalink
Template specialization of cwiseAdd for Vec3 half should be in Types.…
Browse files Browse the repository at this point in the history
…h and not in Vec3.h.

Signed-off-by: apradhana <[email protected]>
  • Loading branch information
apradhana committed Sep 10, 2024
1 parent 5a547f1 commit 3ed0dc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
17 changes: 17 additions & 0 deletions openvdb/openvdb/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<math::half>& v, const float s)
{
math::Vec3<math::half> 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

Expand Down
14 changes: 0 additions & 14 deletions openvdb/openvdb/math/Vec3.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,20 +594,6 @@ Abs(const Vec3<T>& v)
return Vec3<T>(Abs(v[0]), Abs(v[1]), Abs(v[2]));
}

template<>
inline auto cwiseAdd(const Vec3<math::internal::half>& v, const float s)
{
Vec3<math::internal::half> 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 <typename T>
Expand Down

0 comments on commit 3ed0dc8

Please sign in to comment.