diff --git a/panda/src/linmath/compose_matrix_src.cxx b/panda/src/linmath/compose_matrix_src.cxx index 4bbd44736f..9f1a9dd3fb 100644 --- a/panda/src/linmath/compose_matrix_src.cxx +++ b/panda/src/linmath/compose_matrix_src.cxx @@ -633,3 +633,29 @@ old_to_new_hpr(const FLOATNAME(LVecBase3) &old_hpr) { decompose_matrix_new_hpr(mat, new_scale, new_shear, new_hpr); return new_hpr; } + +//////////////////////////////////////////////////////////////////// +// Function: new_to_old_hpr +// Description: Converts the HPR as represented in the new, correct +// representation to the old, broken way. Returns the +// old HPR. Useful only for backporting. +// +// This function is provided to ease transition from new +// systems that relied on Panda's original broken HPR +// calculation. +//////////////////////////////////////////////////////////////////// +FLOATNAME(LVecBase3) +new_to_old_hpr(const FLOATNAME(LVecBase3) &new_hpr) { + FLOATNAME(LMatrix3) mat; + compose_matrix_new_hpr(mat, + FLOATNAME(LVecBase3)(1.0f, 1.0f, 1.0f), + FLOATNAME(LVecBase3)::zero(), + new_hpr); + + FLOATNAME(LVecBase3) old_scale; + FLOATNAME(LVecBase3) old_shear; + FLOATNAME(LVecBase3) old_hpr; + + decompose_matrix_old_hpr(mat, old_scale, old_shear, old_hpr); + return old_hpr; +} diff --git a/panda/src/linmath/compose_matrix_src.h b/panda/src/linmath/compose_matrix_src.h index fb204e4daf..b1288b8e52 100644 --- a/panda/src/linmath/compose_matrix_src.h +++ b/panda/src/linmath/compose_matrix_src.h @@ -174,6 +174,8 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix4) &mat, FLOATTYPE components[nu EXPCL_PANDA FLOATNAME(LVecBase3) old_to_new_hpr(const FLOATNAME(LVecBase3) &old_hpr); +EXPCL_PANDA FLOATNAME(LVecBase3) +new_to_old_hpr(const FLOATNAME(LVecBase3) &new_hpr); END_PUBLISH