Browse Source

define new_to_old_hpr()

David Rose 21 years ago
parent
commit
962cfa369a
2 changed files with 28 additions and 0 deletions
  1. 26 0
      panda/src/linmath/compose_matrix_src.cxx
  2. 2 0
      panda/src/linmath/compose_matrix_src.h

+ 26 - 0
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);
   decompose_matrix_new_hpr(mat, new_scale, new_shear, new_hpr);
   return 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;
+}

+ 2 - 0
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)
 EXPCL_PANDA FLOATNAME(LVecBase3)
 old_to_new_hpr(const FLOATNAME(LVecBase3) &old_hpr);
 old_to_new_hpr(const FLOATNAME(LVecBase3) &old_hpr);
+EXPCL_PANDA FLOATNAME(LVecBase3)
+new_to_old_hpr(const FLOATNAME(LVecBase3) &new_hpr);
 
 
 END_PUBLISH
 END_PUBLISH