-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial support for HalfGrid and ComputeType #1787
Initial support for HalfGrid and ComputeType #1787
Conversation
Initial support for HalfGrid and ComputeType, where the latter enables float computations for HalfGrid which increases accuracy and speed. Signed-off-by: ghurstunither <[email protected]>
Remove HalfGrid from RealGridTypes until a consensus is reached. Signed-off-by: ghurstunither <[email protected]>
Fixes trailingspaces errors Signed-off-by: ghurstunither <[email protected]>
@@ -1746,10 +1747,11 @@ template<typename GridType> | |||
typename GridType::Ptr | |||
createLevelSet(Real voxelSize, Real halfWidth) | |||
{ | |||
using ValueType = typename GridType::ValueType; | |||
using ValueType = typename GridType::ValueType; | |||
using ComputeType = typename GridType::ComputeType; | |||
|
|||
// GridType::ValueType is required to be a floating-point scalar. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should match what the code does. But I think in this case, the comment is right. ValueType
reflects the payload stored in the leaf nodes and in the background value. The requirement for a level-set is for these two things to be floating point.
template<> struct Tolerance<float> { static float value() { return 1e-8f; } }; | ||
template<> struct Tolerance<double> { static double value() { return 1e-15; } }; | ||
template<typename T> struct Tolerance { static T value() { return zeroVal<T>(); } }; | ||
template<> struct Tolerance<math::half> { static math::half value() { return 0.00097656; } }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment on the reference of where this value comes from.
|
||
// isNegative and operator-() are bitwise ops | ||
// all half types in HalfDecl.h _could_ define abs() as half(FromBits, bits() & 0x7fff) | ||
inline math::half Abs(math::half x) { return x.isNegative() ? -x : x; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to see the comment :)
@@ -362,6 +370,10 @@ isApproxZero(const Type& x, const Type& tolerance) | |||
} | |||
|
|||
|
|||
/// Return @c true if @a x is less than zero. | |||
inline bool | |||
isNegative(math::half& x) { return x.isNegative(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to add a const
keyword in the argument.
@ghurstunither. I'm wondering if you have ever compiled this PR with |
|
Should we close this PR and re-open using the feature branch as the source? |
Yes, I’ve gone ahead and closed this one. |
Initial support for
HalfGrid
andComputeType
in OpenVDB, where the latter enables intermediatefloat
computations forHalfGrid
to increase accuracy and speed.ValueToComputeMap
inTypes.h
to setComputeType
at the leaf level and then to propagate all the way up to the grid level.math::half
,ComputeType
isfloat
and for any other typeT
,ComputeType
isT
.HalfGrid
(half vectors not in this PR).math::half
fromTypes.h
to its ownHalfDecl.h
math::half
inMath.h
(to avoid casting in some places) so there were now circular dependancies.ComputeType
instead ofValueType
.Note, I decided not to define
openvdb::is_floating_point
and friends. Instead I opted to usestd::is_floating_point<ComputeType>()::value
instead.Still to come in this PR
*Uunit tests for half and to verify no unit tests have broken.