Closed Bug 1720176 Opened 5 years ago Closed 5 years ago

Matrix4x4Typed::Decompose() is not properly typed

Categories

(Core :: Graphics, defect)

defect

Tracking

()

RESOLVED FIXED
92 Branch
Tracking Status
firefox92 --- fixed

People

(Reporter: botond, Assigned: botond)

Details

Attachments

(2 files)

The signature of Matrix4x4Typed::Decompose() is as follows:

template <class SourceUnits, class TargetUnits, class T>
class Matrix4x4Typed {
  ...
  bool Decompose(Point3DTyped<UnknownUnits, T>& translation,
                 BaseQuaternion<T>& rotation,
                 Point3DTyped<UnknownUnits, T>& scale) const {
};

Note the use of UnknownUnits in the signature.

Moreover, even if you pass in inputs of the specified (unknown) types, a call to this function does not compile if the matrix itself is not unknown-typed, because of this call:

rotation.SetFromRotationMatrix(*this);

Here, BaseQuaternion::SetFromRotationMatrix() is not templated on any unit types and expects an unknown matrix as input.

So, the only way to call this function is to convert to an unknown matrix first:

matrix.ToUnknownMatrix().Decompose(...)

which is probably not what's intended.

It's not immediately obvious how to convert the signature into a fully typed one:

  • The translation applies after the other transforms, so that could be changed to Point3DTyped<TargetUnits>
  • BaseQuaternion is not parameterized on types (which is fine, it can be left alone)
  • For the scale, it's not clear how it could be typed. We usually use ScaleFactors2D<Source, Target> for typed scales, but we don't have a "3D" scale representation.

So, I think for now I'll just leave the signature alone, and tweak the implementation so that it compiles for non-Unknown matrix objects as well.

Assignee: nobody → botond

Prior to this patch, ToUnknownMatrix() on a Matrix4x4Typed<A, B, double>
would return a Matrix4x4Typed<Unknown, Unknown, float>.

After this patch, it returns a Matrix4x4Typed<Unknown, Unknown, double>.

Pushed by bballo@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f95bf7ce00ee Get To/FromUnknownMatrix() to respect the matrix's representation type. r=jrmuizel https://hg.mozilla.org/integration/autoland/rev/9079b87aeba1 Get Matrix4x4Typed::Decompose() to compile for non-Unknown matrix types. r=jrmuizel
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: