mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
Remove temp-hpr-fix
This commit is contained in:
parent
f12e2b5f68
commit
62cdb5cac5
@ -381,7 +381,9 @@ write_datagram(BamWriter *manager, Datagram &me) {
|
||||
}
|
||||
|
||||
me.add_bool(compress_channels);
|
||||
me.add_bool(temp_hpr_fix);
|
||||
|
||||
// We now always use the new HPR conventions.
|
||||
me.add_bool(true);
|
||||
|
||||
if (!compress_channels) {
|
||||
// Write out everything uncompressed, as a stream of floats.
|
||||
@ -443,6 +445,8 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
|
||||
bool wrote_compressed = scan.get_bool();
|
||||
|
||||
// If this is false, the file still uses the old HPR conventions,
|
||||
// and we'll have to convert the HPR values to the new convention.
|
||||
bool new_hpr = scan.get_bool();
|
||||
|
||||
if (!wrote_compressed) {
|
||||
@ -457,7 +461,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
_tables[i] = ind_table;
|
||||
}
|
||||
|
||||
if ((!new_hpr && temp_hpr_fix) || (new_hpr && !temp_hpr_fix)) {
|
||||
if (!new_hpr) {
|
||||
// Convert between the old HPR form and the new HPR form.
|
||||
size_t num_hprs = max(max(_tables[6].size(), _tables[7].size()),
|
||||
_tables[8].size());
|
||||
@ -482,12 +486,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
PN_stdfloat p = (hi < _tables[7].size() ? _tables[7][hi] : default_hpr[1]);
|
||||
PN_stdfloat r = (hi < _tables[8].size() ? _tables[8][hi] : default_hpr[2]);
|
||||
|
||||
LVecBase3 hpr;
|
||||
if (temp_hpr_fix) {
|
||||
hpr = old_to_new_hpr(LVecBase3(h, p, r));
|
||||
} else {
|
||||
hpr = new_to_old_hpr(LVecBase3(h, p, r));
|
||||
}
|
||||
LVecBase3 hpr = old_to_new_hpr(LVecBase3(h, p, r));
|
||||
h_table[hi] = hpr[0];
|
||||
p_table[hi] = hpr[1];
|
||||
r_table[hi] = hpr[2];
|
||||
@ -525,20 +524,13 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
PTA_stdfloat r_table = PTA_stdfloat::empty_array(hprs.size(), get_class_type());
|
||||
|
||||
for (i = 0; i < (int)hprs.size(); i++) {
|
||||
if (!new_hpr && temp_hpr_fix) {
|
||||
if (!new_hpr) {
|
||||
// Convert the old HPR form to the new HPR form.
|
||||
LVecBase3 hpr = old_to_new_hpr(hprs[i]);
|
||||
h_table[i] = hpr[0];
|
||||
p_table[i] = hpr[1];
|
||||
r_table[i] = hpr[2];
|
||||
|
||||
} else if (new_hpr && !temp_hpr_fix) {
|
||||
// Convert the new HPR form to the old HPR form.
|
||||
LVecBase3 hpr = new_to_old_hpr(hprs[i]);
|
||||
h_table[i] = hpr[0];
|
||||
p_table[i] = hpr[1];
|
||||
r_table[i] = hpr[2];
|
||||
|
||||
} else {
|
||||
// Store the HPR angle directly.
|
||||
h_table[i] = hprs[i][0];
|
||||
|
@ -154,11 +154,7 @@ get_order() const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const string &EggXfmSAnim::
|
||||
get_standard_order() {
|
||||
if (temp_hpr_fix) {
|
||||
return _standard_order_hpr_fix;
|
||||
} else {
|
||||
return _standard_order_legacy;
|
||||
}
|
||||
return _standard_order;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -26,14 +26,7 @@
|
||||
|
||||
TypeHandle EggXfmSAnim::_type_handle;
|
||||
|
||||
|
||||
// For now, the standard order is sphrt. This matches the old,
|
||||
// incorrect behavior of decompose_matrix(). When we have a new
|
||||
// egg-optchar, we can safely remove the old decompose_matrix() and
|
||||
// restore the correct standard order.
|
||||
const string EggXfmSAnim::_standard_order_legacy = "sphrt";
|
||||
const string EggXfmSAnim::_standard_order_hpr_fix = "srpht";
|
||||
|
||||
const string EggXfmSAnim::_standard_order = "srpht";
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggXfmSAnim::Conversion constructor
|
||||
|
@ -15,10 +15,8 @@
|
||||
#ifndef EGGXFMSANIM_H
|
||||
#define EGGXFMSANIM_H
|
||||
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "eggGroupNode.h"
|
||||
#include "config_linmath.h" // for temp_hpr_fix
|
||||
|
||||
class EggXfmAnimData;
|
||||
|
||||
@ -92,8 +90,7 @@ private:
|
||||
string _order;
|
||||
CoordinateSystem _coordsys;
|
||||
|
||||
static const string _standard_order_legacy;
|
||||
static const string _standard_order_hpr_fix;
|
||||
static const string _standard_order;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -13,24 +13,6 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: compose_matrix
|
||||
// Description: Computes the 3x3 matrix from scale, shear, and
|
||||
// rotation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH void
|
||||
compose_matrix(FLOATNAME(LMatrix3) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs) {
|
||||
if (temp_hpr_fix) {
|
||||
compose_matrix_new_hpr(mat, scale, shear, hpr, cs);
|
||||
} else {
|
||||
compose_matrix_old_hpr(mat, scale, shear, hpr, cs);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: compose_matrix
|
||||
// Description: Computes the 4x4 matrix according to scale, shear,
|
||||
@ -43,11 +25,9 @@ compose_matrix(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
const FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs) {
|
||||
if (temp_hpr_fix) {
|
||||
compose_matrix_new_hpr(mat, scale, shear, hpr, translate, cs);
|
||||
} else {
|
||||
compose_matrix_old_hpr(mat, scale, shear, hpr, translate, cs);
|
||||
}
|
||||
FLOATNAME(LMatrix3) upper3;
|
||||
compose_matrix(upper3, scale, shear, hpr, cs);
|
||||
mat = FLOATNAME(LMatrix4)(upper3, translate);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -59,32 +39,19 @@ INLINE_LINMATH void
|
||||
compose_matrix(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem cs) {
|
||||
if (temp_hpr_fix) {
|
||||
compose_matrix_new_hpr(mat, components, cs);
|
||||
} else {
|
||||
compose_matrix_old_hpr(mat, components, cs);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: decompose_matrix
|
||||
// Description: Extracts out the components of a 3x3 rotation matrix.
|
||||
// Returns true if successful, or false if there was an
|
||||
// error. Since a 3x3 matrix always contains an affine
|
||||
// transform, this should succeed in the normal case;
|
||||
// singular transforms are not treated as an error.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH bool
|
||||
decompose_matrix(const FLOATNAME(LMatrix3) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
FLOATNAME(LVecBase3) &shear,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs) {
|
||||
if (temp_hpr_fix) {
|
||||
return decompose_matrix_new_hpr(mat, scale, shear, hpr, cs);
|
||||
} else {
|
||||
return decompose_matrix_old_hpr(mat, scale, shear, hpr, cs);
|
||||
}
|
||||
FLOATNAME(LVector3) scale(components[0],
|
||||
components[1],
|
||||
components[2]);
|
||||
FLOATNAME(LVector3) shear(components[3],
|
||||
components[4],
|
||||
components[5]);
|
||||
FLOATNAME(LVector3) hpr(components[6],
|
||||
components[7],
|
||||
components[8]);
|
||||
FLOATNAME(LVector3) translate(components[9],
|
||||
components[10],
|
||||
components[11]);
|
||||
compose_matrix(mat, scale, shear, hpr, translate, cs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -101,11 +68,16 @@ decompose_matrix(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs) {
|
||||
if (temp_hpr_fix) {
|
||||
return decompose_matrix_new_hpr(mat, scale, shear, hpr, translate, cs);
|
||||
} else {
|
||||
return decompose_matrix_old_hpr(mat, scale, shear, hpr, translate, cs);
|
||||
// Get the translation first.
|
||||
mat.get_row3(translate, 3);
|
||||
if (!decompose_matrix(mat.get_upper_3(), scale, shear, hpr, cs)) {
|
||||
return false;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
return mat.get_col(3).almost_equal(FLOATNAME(LVecBase4)(0.0, 0.0, 0.0, 1.0));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -119,11 +91,21 @@ INLINE_LINMATH bool
|
||||
decompose_matrix(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem cs) {
|
||||
if (temp_hpr_fix) {
|
||||
return decompose_matrix_new_hpr(mat, components, cs);
|
||||
} else {
|
||||
return decompose_matrix_old_hpr(mat, components, cs);
|
||||
}
|
||||
FLOATNAME(LVector3) scale, shear, hpr, translate;
|
||||
bool result = decompose_matrix(mat, scale, shear, hpr, translate, cs);
|
||||
components[0] = scale[0];
|
||||
components[1] = scale[1];
|
||||
components[2] = scale[2];
|
||||
components[3] = shear[0];
|
||||
components[4] = shear[1];
|
||||
components[5] = shear[2];
|
||||
components[6] = hpr[0];
|
||||
components[7] = hpr[1];
|
||||
components[8] = hpr[2];
|
||||
components[9] = translate[0];
|
||||
components[10] = translate[1];
|
||||
components[11] = translate[2];
|
||||
return result;
|
||||
}
|
||||
|
||||
// The following functions are deprecated; they have been replaced
|
||||
@ -175,159 +157,3 @@ decompose_matrix(const FLOATNAME(LMatrix4) &mat,
|
||||
mat.get_row3(translate,3);
|
||||
return decompose_matrix(mat.get_upper_3(), scale, hpr, cs);
|
||||
}
|
||||
|
||||
|
||||
// The following functions are transitional and serve only to migrate
|
||||
// code from the old, incorrect hpr calculations that Panda used to
|
||||
// use. New code should not call these functions directly; use the
|
||||
// unqualified functions, above, instead.
|
||||
|
||||
// Transitional function.
|
||||
INLINE_LINMATH void
|
||||
compose_matrix_old_hpr(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
const FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs) {
|
||||
FLOATNAME(LMatrix3) upper3;
|
||||
compose_matrix_old_hpr(upper3, scale, shear, hpr, cs);
|
||||
mat = FLOATNAME(LMatrix4)(upper3, translate);
|
||||
}
|
||||
|
||||
// Transitional function.
|
||||
INLINE_LINMATH void
|
||||
compose_matrix_old_hpr(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem cs) {
|
||||
FLOATNAME(LVector3) scale(components[0],
|
||||
components[1],
|
||||
components[2]);
|
||||
FLOATNAME(LVector3) shear(components[3],
|
||||
components[4],
|
||||
components[5]);
|
||||
FLOATNAME(LVector3) hpr(components[6],
|
||||
components[7],
|
||||
components[8]);
|
||||
FLOATNAME(LVector3) translate(components[9],
|
||||
components[10],
|
||||
components[11]);
|
||||
compose_matrix_old_hpr(mat, scale, shear, hpr, translate, cs);
|
||||
}
|
||||
|
||||
// Transitional function.
|
||||
INLINE_LINMATH bool
|
||||
decompose_matrix_old_hpr(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
FLOATNAME(LVecBase3) &shear,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs) {
|
||||
// Get the translation first.
|
||||
mat.get_row3(translate,3);
|
||||
if (!decompose_matrix_old_hpr(mat.get_upper_3(), scale, shear, hpr, cs)) {
|
||||
return false;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
return mat.get_col(3).almost_equal(FLOATNAME(LVecBase4)(0.0, 0.0, 0.0, 1.0));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Transitional function.
|
||||
INLINE_LINMATH bool
|
||||
decompose_matrix_old_hpr(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem cs) {
|
||||
FLOATNAME(LVector3) scale, shear, hpr, translate;
|
||||
bool result = decompose_matrix_old_hpr(mat, scale, shear, hpr, translate, cs);
|
||||
components[0] = scale[0];
|
||||
components[1] = scale[1];
|
||||
components[2] = scale[2];
|
||||
components[3] = shear[0];
|
||||
components[4] = shear[1];
|
||||
components[5] = shear[2];
|
||||
components[6] = hpr[0];
|
||||
components[7] = hpr[1];
|
||||
components[8] = hpr[2];
|
||||
components[9] = translate[0];
|
||||
components[10] = translate[1];
|
||||
components[11] = translate[2];
|
||||
return result;
|
||||
}
|
||||
|
||||
// Transitional function.
|
||||
INLINE_LINMATH void
|
||||
compose_matrix_new_hpr(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
const FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs) {
|
||||
FLOATNAME(LMatrix3) upper3;
|
||||
compose_matrix_new_hpr(upper3, scale, shear, hpr, cs);
|
||||
mat = FLOATNAME(LMatrix4)(upper3, translate);
|
||||
}
|
||||
|
||||
// Transitional function.
|
||||
INLINE_LINMATH void
|
||||
compose_matrix_new_hpr(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem cs) {
|
||||
FLOATNAME(LVector3) scale(components[0],
|
||||
components[1],
|
||||
components[2]);
|
||||
FLOATNAME(LVector3) shear(components[3],
|
||||
components[4],
|
||||
components[5]);
|
||||
FLOATNAME(LVector3) hpr(components[6],
|
||||
components[7],
|
||||
components[8]);
|
||||
FLOATNAME(LVector3) translate(components[9],
|
||||
components[10],
|
||||
components[11]);
|
||||
compose_matrix_new_hpr(mat, scale, shear, hpr, translate, cs);
|
||||
}
|
||||
|
||||
// Transitional function.
|
||||
INLINE_LINMATH bool
|
||||
decompose_matrix_new_hpr(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
FLOATNAME(LVecBase3) &shear,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs) {
|
||||
// Get the translation first.
|
||||
mat.get_row3(translate,3);
|
||||
if (!decompose_matrix_new_hpr(mat.get_upper_3(), scale, shear, hpr, cs)) {
|
||||
return false;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
return mat.get_col(3).almost_equal(FLOATNAME(LVecBase4)(0.0, 0.0, 0.0, 1.0));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Transitional function.
|
||||
INLINE_LINMATH bool
|
||||
decompose_matrix_new_hpr(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem cs) {
|
||||
FLOATNAME(LVector3) scale, shear, hpr, translate;
|
||||
bool result = decompose_matrix_new_hpr(mat, scale, shear, hpr, translate, cs);
|
||||
components[0] = scale[0];
|
||||
components[1] = scale[1];
|
||||
components[2] = scale[2];
|
||||
components[3] = shear[0];
|
||||
components[4] = shear[1];
|
||||
components[5] = shear[2];
|
||||
components[6] = hpr[0];
|
||||
components[7] = hpr[1];
|
||||
components[8] = hpr[2];
|
||||
components[9] = translate[0];
|
||||
components[10] = translate[1];
|
||||
components[11] = translate[2];
|
||||
return result;
|
||||
}
|
||||
|
@ -13,25 +13,6 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: compose_matrix_old_hpr
|
||||
// Description: Computes the 3x3 matrix from scale, shear, and
|
||||
// rotation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
compose_matrix_old_hpr(FLOATNAME(LMatrix3) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs) {
|
||||
TAU_PROFILE("void compose_matrix_old_hpr(LMatrix3 &, const LVecBase3 &, const LVecBase3 &, const LVecBase3 &)", " ", TAU_USER);
|
||||
mat =
|
||||
FLOATNAME(LMatrix3)::scale_shear_mat(scale, shear, cs) *
|
||||
FLOATNAME(LMatrix3)::rotate_mat_normaxis(hpr[1], FLOATNAME(LVector3)::right(cs), cs) *
|
||||
FLOATNAME(LMatrix3)::rotate_mat_normaxis(hpr[0], FLOATNAME(LVector3)::up(cs), cs) *
|
||||
FLOATNAME(LMatrix3)::rotate_mat_normaxis(hpr[2], FLOATNAME(LVector3)::back(cs), cs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: unwind_yup_rotation_old_hpr
|
||||
// Description: Extracts the rotation about the x, y, and z axes from
|
||||
@ -307,19 +288,18 @@ decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: compose_matrix_new_hpr
|
||||
// Function: compose_matrix
|
||||
// Description: Computes the 3x3 matrix from scale, shear, and
|
||||
// rotation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
compose_matrix_new_hpr(FLOATNAME(LMatrix3) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs) {
|
||||
TAU_PROFILE("void compose_matrix_new_hpr(LMatrix3 &, const LVecBase3 &, const LVecBase3 &, const LVecBase3 &)", " ", TAU_USER);
|
||||
compose_matrix(FLOATNAME(LMatrix3) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs) {
|
||||
TAU_PROFILE("void compose_matrix(LMatrix3 &, const LVecBase3 &, const LVecBase3 &, const LVecBase3 &)", " ", TAU_USER);
|
||||
mat.set_scale_shear_mat(scale, shear, cs);
|
||||
if (!IS_NEARLY_ZERO(hpr[2])) {
|
||||
FLOATNAME(LMatrix3) r;
|
||||
@ -339,7 +319,7 @@ compose_matrix_new_hpr(FLOATNAME(LMatrix3) &mat,
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: unwind_yup_rotation_new_hpr
|
||||
// Function: unwind_yup_rotation
|
||||
// Description: Extracts the rotation about the x, y, and z axes from
|
||||
// the given hpr & scale matrix. Adjusts the matrix
|
||||
// to eliminate the rotation.
|
||||
@ -348,8 +328,8 @@ compose_matrix_new_hpr(FLOATNAME(LMatrix3) &mat,
|
||||
// right-handed Y-up coordinate system.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
static void
|
||||
unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
|
||||
TAU_PROFILE("void unwind_yup_rotation_new_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
|
||||
unwind_yup_rotation(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
|
||||
TAU_PROFILE("void unwind_yup_rotation(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
|
||||
|
||||
// Extract the axes from the matrix.
|
||||
FLOATNAME(LVector3) x, y, z;
|
||||
@ -418,7 +398,7 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: unwind_zup_rotation_new_hpr
|
||||
// Function: unwind_zup_rotation
|
||||
// Description: Extracts the rotation about the x, y, and z axes from
|
||||
// the given hpr & scale matrix. Adjusts the matrix
|
||||
// to eliminate the rotation.
|
||||
@ -427,8 +407,8 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
|
||||
// right-handed Z-up coordinate system.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
static void
|
||||
unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
|
||||
TAU_PROFILE("void unwind_zup_rotation_new_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
|
||||
unwind_zup_rotation(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) {
|
||||
TAU_PROFILE("void unwind_zup_rotation(LMatrix3 &, LVecBase3 &)", " ", TAU_USER);
|
||||
// Extract the axes from the matrix.
|
||||
FLOATNAME(LVector3) x, y, z;
|
||||
mat.get_row(x,0);
|
||||
@ -496,7 +476,7 @@ unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: decompose_matrix_new_hpr
|
||||
// Function: decompose_matrix
|
||||
// Description: Extracts out the components of a 3x3 rotation matrix.
|
||||
// Returns true if successful, or false if there was an
|
||||
// error. Since a 3x3 matrix always contains an affine
|
||||
@ -504,12 +484,12 @@ unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr)
|
||||
// singular transforms are not treated as an error.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
FLOATNAME(LVecBase3) &shear,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs) {
|
||||
TAU_PROFILE("bool decompose_matrix_new_hpr(LMatrix3 &, LVecBase3 &, LVecBase3 &, LVecBase3 &)", " ", TAU_USER);
|
||||
decompose_matrix(const FLOATNAME(LMatrix3) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
FLOATNAME(LVecBase3) &shear,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs) {
|
||||
TAU_PROFILE("bool decompose_matrix(LMatrix3 &, LVecBase3 &, LVecBase3 &, LVecBase3 &)", " ", TAU_USER);
|
||||
if (cs == CS_default) {
|
||||
cs = get_default_coordinate_system();
|
||||
}
|
||||
@ -527,13 +507,13 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
switch (cs) {
|
||||
case CS_zup_right:
|
||||
{
|
||||
unwind_zup_rotation_new_hpr(new_mat, hpr);
|
||||
unwind_zup_rotation(new_mat, hpr);
|
||||
}
|
||||
break;
|
||||
|
||||
case CS_yup_right:
|
||||
{
|
||||
unwind_yup_rotation_new_hpr(new_mat, hpr);
|
||||
unwind_yup_rotation(new_mat, hpr);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -548,7 +528,7 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
mat(1, 0), mat(1, 1), -mat(1, 2),
|
||||
-mat(2, 0), -mat(2, 1), mat(2, 2));
|
||||
*/
|
||||
unwind_zup_rotation_new_hpr(new_mat, hpr);
|
||||
unwind_zup_rotation(new_mat, hpr);
|
||||
hpr[0] = -hpr[0];
|
||||
hpr[2] = -hpr[2];
|
||||
}
|
||||
@ -565,7 +545,7 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
mat(1, 0), mat(1, 1), -mat(1, 2),
|
||||
-mat(2, 0), -mat(2, 1), mat(2, 2));
|
||||
*/
|
||||
unwind_yup_rotation_new_hpr(new_mat, hpr);
|
||||
unwind_yup_rotation(new_mat, hpr);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -604,7 +584,6 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: old_to_new_hpr
|
||||
// Description: Converts the HPR as represented in the old, broken
|
||||
@ -618,43 +597,15 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
FLOATNAME(LVecBase3)
|
||||
old_to_new_hpr(const FLOATNAME(LVecBase3) &old_hpr) {
|
||||
TAU_PROFILE("LVecBase3 old_to_new_hpr(const LVecBase3 &)", " ", TAU_USER);
|
||||
FLOATNAME(LMatrix3) mat;
|
||||
compose_matrix_old_hpr(mat,
|
||||
FLOATNAME(LVecBase3)(1.0f, 1.0f, 1.0f),
|
||||
FLOATNAME(LVecBase3)::zero(),
|
||||
old_hpr);
|
||||
FLOATNAME(LMatrix3) mat =
|
||||
FLOATNAME(LMatrix3)::rotate_mat_normaxis(old_hpr[1], FLOATNAME(LVector3)::right()) *
|
||||
FLOATNAME(LMatrix3)::rotate_mat_normaxis(old_hpr[0], FLOATNAME(LVector3)::up()) *
|
||||
FLOATNAME(LMatrix3)::rotate_mat_normaxis(old_hpr[2], FLOATNAME(LVector3)::back());
|
||||
|
||||
FLOATNAME(LVecBase3) new_scale;
|
||||
FLOATNAME(LVecBase3) new_shear;
|
||||
FLOATNAME(LVecBase3) new_hpr;
|
||||
|
||||
decompose_matrix_new_hpr(mat, new_scale, new_shear, new_hpr);
|
||||
|
||||
decompose_matrix(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) {
|
||||
TAU_PROFILE("LVecBase3 new_to_old_hpr(const LVecBase3 &)", " ", TAU_USER);
|
||||
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;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
BEGIN_PUBLISH
|
||||
|
||||
INLINE_LINMATH void
|
||||
EXPCL_PANDA_LINMATH void
|
||||
compose_matrix(FLOATNAME(LMatrix3) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
@ -34,7 +34,7 @@ compose_matrix(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
INLINE_LINMATH bool
|
||||
EXPCL_PANDA_LINMATH bool
|
||||
decompose_matrix(const FLOATNAME(LMatrix3) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
FLOATNAME(LVecBase3) &shear,
|
||||
@ -91,26 +91,6 @@ decompose_matrix(const FLOATNAME(LMatrix4) &mat,
|
||||
// use. New code should not call these functions directly; use the
|
||||
// unqualified functions, above, instead.
|
||||
|
||||
EXPCL_PANDA_LINMATH void
|
||||
compose_matrix_old_hpr(FLOATNAME(LMatrix3) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
INLINE_LINMATH void
|
||||
compose_matrix_old_hpr(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
const FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
INLINE_LINMATH void
|
||||
compose_matrix_old_hpr(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
EXPCL_PANDA_LINMATH bool
|
||||
decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
@ -118,65 +98,8 @@ decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
INLINE_LINMATH bool
|
||||
decompose_matrix_old_hpr(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
FLOATNAME(LVecBase3) &shear,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
INLINE_LINMATH bool
|
||||
decompose_matrix_old_hpr(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem CS = CS_default);
|
||||
|
||||
|
||||
EXPCL_PANDA_LINMATH void
|
||||
compose_matrix_new_hpr(FLOATNAME(LMatrix3) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
INLINE_LINMATH void
|
||||
compose_matrix_new_hpr(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &hpr,
|
||||
const FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
INLINE_LINMATH void
|
||||
compose_matrix_new_hpr(FLOATNAME(LMatrix4) &mat,
|
||||
const FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
EXPCL_PANDA_LINMATH bool
|
||||
decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
FLOATNAME(LVecBase3) &shear,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
INLINE_LINMATH bool
|
||||
decompose_matrix_new_hpr(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATNAME(LVecBase3) &scale,
|
||||
FLOATNAME(LVecBase3) &shear,
|
||||
FLOATNAME(LVecBase3) &hpr,
|
||||
FLOATNAME(LVecBase3) &translate,
|
||||
CoordinateSystem cs = CS_default);
|
||||
|
||||
INLINE_LINMATH bool
|
||||
decompose_matrix_new_hpr(const FLOATNAME(LMatrix4) &mat,
|
||||
FLOATTYPE components[num_matrix_components],
|
||||
CoordinateSystem CS = CS_default);
|
||||
|
||||
|
||||
EXPCL_PANDA_LINMATH FLOATNAME(LVecBase3)
|
||||
old_to_new_hpr(const FLOATNAME(LVecBase3) &old_hpr);
|
||||
EXPCL_PANDA_LINMATH FLOATNAME(LVecBase3)
|
||||
new_to_old_hpr(const FLOATNAME(LVecBase3) &new_hpr);
|
||||
|
||||
END_PUBLISH
|
||||
|
||||
|
@ -31,13 +31,6 @@ ConfigVariableBool paranoid_hpr_quat
|
||||
"decompose operations against the quaternion-matrix and matrix-hpr "
|
||||
"operations. This only has effect if NDEBUG is not defined."));
|
||||
|
||||
ConfigVariableBool temp_hpr_fix
|
||||
("temp-hpr-fix", true,
|
||||
PRC_DESC("Set this true to compute hpr's correctly. Historically, Panda has "
|
||||
"applied these in the wrong order, and roll was backwards relative "
|
||||
"to the other two. Set this false if you need compatibility with "
|
||||
"Panda's old hpr calculations."));
|
||||
|
||||
ConfigVariableBool no_singular_invert
|
||||
("no-singular-invert", false,
|
||||
PRC_DESC("Set this true to make singular-invert warning messages generate an "
|
||||
|
@ -23,7 +23,6 @@
|
||||
NotifyCategoryDecl(linmath, EXPCL_PANDA_LINMATH, EXPTP_PANDA_LINMATH);
|
||||
|
||||
extern EXPCL_PANDA_LINMATH ConfigVariableBool paranoid_hpr_quat;
|
||||
extern EXPCL_PANDA_LINMATH ConfigVariableBool temp_hpr_fix;
|
||||
extern EXPCL_PANDA_LINMATH ConfigVariableBool no_singular_invert;
|
||||
|
||||
extern EXPCL_PANDA_LINMATH void init_liblinmath();
|
||||
|
@ -67,51 +67,27 @@ set_scale_shear_mat(const FLOATNAME(LVecBase3) &scale,
|
||||
|
||||
switch (cs) {
|
||||
case CS_zup_right:
|
||||
if (temp_hpr_fix) {
|
||||
set(scale._v(0), shear._v(0) * scale._v(0), 0.0f,
|
||||
0.0f, scale._v(1), 0.0f,
|
||||
shear._v(1) * scale._v(2), shear._v(2) * scale._v(2), scale._v(2));
|
||||
} else {
|
||||
set(scale._v(0), 0.0f, 0.0f,
|
||||
shear._v(0) * scale._v(1), scale._v(1), 0.0f,
|
||||
shear._v(1) * scale._v(2), shear._v(2) * scale._v(2), scale._v(2));
|
||||
}
|
||||
set(scale._v(0), shear._v(0) * scale._v(0), 0.0f,
|
||||
0.0f, scale._v(1), 0.0f,
|
||||
shear._v(1) * scale._v(2), shear._v(2) * scale._v(2), scale._v(2));
|
||||
break;
|
||||
|
||||
case CS_zup_left:
|
||||
if (temp_hpr_fix) {
|
||||
set(scale._v(0), shear._v(0) * scale._v(0), 0.0f,
|
||||
0.0f, scale._v(1), 0.0f,
|
||||
-shear._v(1) * scale._v(2), -shear._v(2) * scale._v(2), scale._v(2));
|
||||
} else {
|
||||
set(scale._v(0), 0.0f, 0.0f,
|
||||
shear._v(0) * scale._v(1), scale._v(1), 0.0f,
|
||||
-shear._v(1) * scale._v(2), -shear._v(2) * scale._v(2), scale._v(2));
|
||||
}
|
||||
set(scale._v(0), shear._v(0) * scale._v(0), 0.0f,
|
||||
0.0f, scale._v(1), 0.0f,
|
||||
-shear._v(1) * scale._v(2), -shear._v(2) * scale._v(2), scale._v(2));
|
||||
break;
|
||||
|
||||
case CS_yup_right:
|
||||
if (temp_hpr_fix) {
|
||||
set(scale._v(0), 0.0f, shear._v(1) * scale._v(0),
|
||||
shear._v(0) * scale._v(1), scale._v(1), shear._v(2) * scale._v(1),
|
||||
0.0f, 0.0f, scale._v(2));
|
||||
} else {
|
||||
set(scale._v(0), 0.0f, 0.0f,
|
||||
shear._v(0) * scale._v(1), scale._v(1), shear._v(2) * scale._v(1),
|
||||
shear._v(1) * scale._v(2), 0.0f, scale._v(2));
|
||||
}
|
||||
set(scale._v(0), 0.0f, shear._v(1) * scale._v(0),
|
||||
shear._v(0) * scale._v(1), scale._v(1), shear._v(2) * scale._v(1),
|
||||
0.0f, 0.0f, scale._v(2));
|
||||
break;
|
||||
|
||||
case CS_yup_left:
|
||||
if (temp_hpr_fix) {
|
||||
set(scale._v(0), 0.0f, -shear._v(1) * scale._v(0),
|
||||
shear._v(0) * scale._v(1), scale._v(1), -shear._v(2) * scale._v(1),
|
||||
0.0f, 0.0f, scale._v(2));
|
||||
} else {
|
||||
set(scale._v(0), 0.0f, 0.0f,
|
||||
shear._v(0) * scale._v(1), scale._v(1), -shear._v(2) * scale._v(1),
|
||||
-shear._v(1) * scale._v(2), 0.0f, scale._v(2));
|
||||
}
|
||||
set(scale._v(0), 0.0f, -shear._v(1) * scale._v(0),
|
||||
shear._v(0) * scale._v(1), scale._v(1), -shear._v(2) * scale._v(1),
|
||||
0.0f, 0.0f, scale._v(2));
|
||||
break;
|
||||
|
||||
case CS_default:
|
||||
|
@ -108,11 +108,6 @@ set_hpr(const FLOATNAME(LVecBase3) &hpr, CoordinateSystem cs) {
|
||||
(*this) = invert(quat_h * quat_p * quat_r);
|
||||
}
|
||||
|
||||
if (!temp_hpr_fix) {
|
||||
// Compute the old, broken hpr.
|
||||
(*this) = quat_p * quat_h * invert(quat_r);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (paranoid_hpr_quat) {
|
||||
FLOATNAME(LMatrix3) mat;
|
||||
@ -137,19 +132,6 @@ set_hpr(const FLOATNAME(LVecBase3) &hpr, CoordinateSystem cs) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
FLOATNAME(LVecBase3) FLOATNAME(LQuaternion)::
|
||||
get_hpr(CoordinateSystem cs) const {
|
||||
if (!temp_hpr_fix) {
|
||||
// With the old, broken hpr code in place, just go through the
|
||||
// existing matrix decomposition code. Not particularly speedy,
|
||||
// but I don't want to bother with working out how to do it
|
||||
// directly for code that hopefully won't need to last much
|
||||
// longer.
|
||||
FLOATNAME(LMatrix3) mat;
|
||||
extract_to_matrix(mat);
|
||||
FLOATNAME(LVecBase3) scale, hpr;
|
||||
decompose_matrix(mat, scale, hpr, cs);
|
||||
return hpr;
|
||||
}
|
||||
|
||||
if (cs == CS_default) {
|
||||
cs = get_default_coordinate_system();
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ read_reals(DatagramIterator &di, vector_stdfloat &array) {
|
||||
// it is set false, the hprs are decompressed according
|
||||
// to the old, broken hpr calculation; if true, the hprs
|
||||
// are decompressed according to the new, correct hpr
|
||||
// calculation. See temp_hpr_fix.
|
||||
// calculation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool FFTCompressor::
|
||||
read_hprs(DatagramIterator &di, pvector<LVecBase3> &array, bool new_hpr) {
|
||||
@ -732,11 +732,11 @@ read_hprs(DatagramIterator &di, pvector<LVecBase3> &array, bool new_hpr) {
|
||||
if (okflag) {
|
||||
for (int i = 0; i < (int)m00.size(); i++) {
|
||||
LMatrix3 mat(m00[i], m01[i], m02[i],
|
||||
m10[i], m11[i], m12[i],
|
||||
m20[i], m21[i], m22[i]);
|
||||
m10[i], m11[i], m12[i],
|
||||
m20[i], m21[i], m22[i]);
|
||||
LVecBase3 scale, shear, hpr;
|
||||
if (new_hpr) {
|
||||
decompose_matrix_new_hpr(mat, scale, shear, hpr);
|
||||
decompose_matrix(mat, scale, shear, hpr);
|
||||
} else {
|
||||
decompose_matrix_old_hpr(mat, scale, shear, hpr);
|
||||
}
|
||||
@ -799,7 +799,7 @@ read_hprs(DatagramIterator &di, pvector<LVecBase3> &array, bool new_hpr) {
|
||||
}
|
||||
LVecBase3 scale, shear, hpr;
|
||||
if (new_hpr) {
|
||||
decompose_matrix_new_hpr(mat, scale, shear, hpr);
|
||||
decompose_matrix(mat, scale, shear, hpr);
|
||||
} else {
|
||||
decompose_matrix_old_hpr(mat, scale, shear, hpr);
|
||||
}
|
||||
@ -820,7 +820,7 @@ read_hprs(DatagramIterator &di, pvector<LVecBase3> &array, bool new_hpr) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool FFTCompressor::
|
||||
read_hprs(DatagramIterator &di, pvector<LVecBase3> &array) {
|
||||
return read_hprs(di, array, temp_hpr_fix);
|
||||
return read_hprs(di, array, true);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user