Skip to content

Mat44_ and Mat4_InverseRotationTranslation have opposite meanings #7

Description

@jcant0n

math.h says the Mat4_* block holds "shortened names forwarding to Mat44". For this pair that is false, and the two do opposite things:

Mat44_InverseRotationTranslation(result, quat, translation)
  -> Mat44::sInverseRotationTranslation(...)          BUILDS a matrix from a rotation and a translation

Mat4_InverseRotationTranslation(mat)
  -> toJphMat44(mat).InversedRotationTranslation()    INVERTS the matrix it is given

There is a third, one letter away: RMat44_InversedRotationTranslation(m, result)Inversed, not Inverse — which means the inverting one.

This is the likeliest thing in the wrapper to be silently mis-wired during a hand repair: three near-identical names, two semantics, and a header comment asserting they are aliases.

Worth either renaming so the difference is visible, or correcting the comment to say which is which. JoltC/tests/test_math_roundtrip.c exercises all three and asserts they agree where they should, so a rename has a safety net.

Two smaller items in the same file:

  • Vec3_Normalize and Vec3_Normalized are byte-identical implementations (math.cpp:72-75 and 102-105), neither in place. The name difference implies a semantic one that does not exist, so a repair could "fix" one and diverge them.
  • MassProperties_DecomposePrincipalMomentsOfInertia discards Jolt's convergence bool and, on the exception path, never writes its out-parameters — a caller who did not pre-zero them reads uninitialised memory with no way to tell.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions