@@ -868,9 +868,13 @@ struct Blend1
868868 aMult(a), bMult(b), ONE(openvdb::zeroVal<ValueT>() + 1) {}
869869 void operator ()(const ValueT& a, const ValueT& b, ValueT& out) const
870870 {
871- OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
872- out = ValueT ((ONE - aMult * a) * bMult * b);
873- OPENVDB_NO_TYPE_CONVERSION_WARNING_END
871+ if constexpr (std::is_same<ValueT, bool >::value) {
872+ out = a && !b;
873+ } else {
874+ OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
875+ out = ValueT ((ONE - aMult * a) * bMult * b);
876+ OPENVDB_NO_TYPE_CONVERSION_WARNING_END
877+ }
874878 }
875879};
876880
@@ -888,9 +892,14 @@ struct Blend2
888892 aMult(a), bMult(b), ONE(openvdb::zeroVal<ValueT>() + 1) {}
889893 void operator ()(const ValueT& a, const ValueT& b, ValueT& out) const
890894 {
891- OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
892- out = ValueT (a*aMult); out = out + ValueT ((ONE - out) * bMult*b);
893- OPENVDB_NO_TYPE_CONVERSION_WARNING_END
895+ if constexpr (std::is_same<ValueT, bool >::value) {
896+ out = !a && !b;
897+ } else {
898+ OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
899+ out = ValueT (a*aMult);
900+ out = out + ValueT ((ONE - out) * bMult*b);
901+ OPENVDB_NO_TYPE_CONVERSION_WARNING_END
902+ }
894903 }
895904};
896905
@@ -996,36 +1005,39 @@ struct SOP_OpenVDB_Combine::CombineOp
9961005 typename GridT::Ptr resampleToMatch (const GridT& src, const hvdb::Grid& ref, int order)
9971006 {
9981007 using ValueT = typename GridT::ValueType;
999- const ValueT ZERO = openvdb::zeroVal<ValueT>();
10001008
10011009 const openvdb::math::Transform& refXform = ref.constTransform ();
10021010
10031011 typename GridT::Ptr dest;
10041012 if (src.getGridClass () == openvdb::GRID_LEVEL_SET) {
1005- // For level set grids, use the level set rebuild tool to both resample the
1006- // source grid to match the reference grid and to rebuild the resulting level set.
1007- const bool refIsLevelSet = ref.getGridClass () == openvdb::GRID_LEVEL_SET;
1008- OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
1009- const ValueT halfWidth = refIsLevelSet
1010- ? ValueT (ZERO + this ->getScalarBackgroundValue (ref) * (1.0 / ref.voxelSize ()[0 ]))
1011- : ValueT (src.background () * (1.0 / src.voxelSize ()[0 ]));
1012- OPENVDB_NO_TYPE_CONVERSION_WARNING_END
1013-
1014- if (!openvdb::math::isFinite (halfWidth)) {
1015- std::stringstream msg;
1016- msg << " Resample to match: Illegal narrow band width = " << halfWidth
1017- << " , caused by grid '" << src.getName () << " ' with background "
1018- << this ->getScalarBackgroundValue (ref);
1019- throw std::invalid_argument (msg.str ());
1020- }
1013+ if constexpr (std::is_floating_point<ValueT>::value) {
1014+ const ValueT ZERO = openvdb::zeroVal<ValueT>();
1015+
1016+ // For level set grids, use the level set rebuild tool to both resample the
1017+ // source grid to match the reference grid and to rebuild the resulting level set.
1018+ const bool refIsLevelSet = ref.getGridClass () == openvdb::GRID_LEVEL_SET;
1019+ OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
1020+ const ValueT halfWidth = refIsLevelSet
1021+ ? ValueT (ZERO + this ->getScalarBackgroundValue (ref) * (1.0 / ref.voxelSize ()[0 ]))
1022+ : ValueT (src.background () * (1.0 / src.voxelSize ()[0 ]));
1023+ OPENVDB_NO_TYPE_CONVERSION_WARNING_END
1024+
1025+ if (!openvdb::math::isFinite (halfWidth)) {
1026+ std::stringstream msg;
1027+ msg << " Resample to match: Illegal narrow band width = " << halfWidth
1028+ << " , caused by grid '" << src.getName () << " ' with background "
1029+ << this ->getScalarBackgroundValue (ref);
1030+ throw std::invalid_argument (msg.str ());
1031+ }
10211032
1022- try {
1023- dest = openvdb::tools::doLevelSetRebuild (src, /* iso=*/ ZERO,
1024- /* exWidth=*/ halfWidth, /* inWidth=*/ halfWidth, &refXform, &interrupt.interrupter ());
1025- } catch (openvdb::TypeError&) {
1026- self->addWarning (SOP_MESSAGE, (" skipped rebuild of level set grid "
1027- + src.getName () + " of type " + src.type ()).c_str ());
1028- dest.reset ();
1033+ try {
1034+ dest = openvdb::tools::doLevelSetRebuild (src, /* iso=*/ ZERO,
1035+ /* exWidth=*/ halfWidth, /* inWidth=*/ halfWidth, &refXform, &interrupt.interrupter ());
1036+ } catch (openvdb::TypeError&) {
1037+ self->addWarning (SOP_MESSAGE, (" skipped rebuild of level set grid "
1038+ + src.getName () + " of type " + src.type ()).c_str ());
1039+ dest.reset ();
1040+ }
10291041 }
10301042 }
10311043 if (!dest && src.constTransform () != refXform) {
0 commit comments