tl;dr: We plan to deprecate functions that are known potential sources of precision loss in the 24.08 release and then remove these methods in 24.11. We welcome your feedback in this thread!
–
The type GfMatrix4d
is commonly used in the Pixar pipeline to represent local-to-world transformations. When local space points are represented using the type GfVec3f
, calls to functions such as GfMatrix4d::Transform
can lose precision due to overloads that take and return values of type GfVec3f
. Production experience has shown us this precision loss can be critical, e.g., due to large translations in local-to-world matrices that require points in world space to be represented with higher precision than is necessary in local space (which is presumably chosen so that the points are sufficiently close to the local origin).
In order to avoid this loss of precision, it is currently necessary to explicitly cast a GfVec3f
argument to GfVec3d
in order to select the overload that computes and returns a double-precision result; it is easy to call a lossy overload by accident. And when lost precision causes observable problems downstream, it can be very difficult and time-consuming to track down the source of the problem.
Therefore, we plan to deprecate functions that are known potential sources of precision loss (marking them as deprecated in the documentation and annotating the functions using the [[deprecated]]
attribute) in the 24.08 release, and then to remove these methods in 24.11. Note that the above geometric interpretation doesn’t apply to all of the operations we are planning to deprecate, but for consistency, we plan to remove all methods and free functions that produce a float-valued vector from an operation on a float-valued vector and a double-valued matrix.
After the functions are removed (in 24.11), each client code site that was calling the old API will end up invoking a function that takes and returns a GfVec3d
(or GfVec2d
or GfVec4d
), which in many cases will many that the client code will have to explicitly cast the result to the corresponding single-precision type. One benefit is that the loss of precision (which may or may not be significant to the client) will be explicit in the calling code.
The full list of functions to be deprecated is:
GfVec3f GfMatrix4d::Transform(const GfVec3f &)
GfVec3f GfMatrix4d::TransformAffine(const GfVec3f &)
GfVec3f GfMatrix4d::TransformDir(const GfVec3f &)
GfVec3f GfRotation::TransformDir(const GfVec3f &)
GfVec2f operator*(const GfMatrix2d &, const GfVec2f &)
GfVec2f operator*(const GfVec2f &, const GfMatrix2d &)
GfVec3f operator*(const GfMatrix3d &, const GfVec3f &)
GfVec3f operator*(const GfVec3f &, const GfMatrix3d &)
GfVec4f operator*(const GfMatrix4d &, const GfVec4f &)
GfVec4f operator*(const GfVec4f &, const GfMatrix4d &)
Let’s continue the discussion here with any questions or concerns you have!