From fb973c9cfd76ed0f9146cdf1aa850c09a4733414 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 23 Aug 2007 16:24:49 +0000 Subject: [PATCH] Add LMatrix*::xform_vec_general(), fix clip plane issues --- panda/src/char/config_char.cxx | 7 -- panda/src/linmath/Sources.pp | 12 +-- panda/src/linmath/linmath_composite2.cxx | 2 - panda/src/linmath/lmat_ops.h | 3 +- panda/src/linmath/lmatrix.cxx | 13 +-- panda/src/linmath/lmatrix.h | 29 +++--- panda/src/linmath/lmatrix3.cxx | 28 ------ panda/src/linmath/lmatrix3.h | 41 -------- panda/src/linmath/lmatrix3_src.I | 114 ++++++++++++++++++++++- panda/src/linmath/lmatrix3_src.h | 15 +++ panda/src/linmath/lmatrix4.cxx | 28 ------ panda/src/linmath/lmatrix4.h | 43 --------- panda/src/linmath/lmatrix4_src.I | 18 +++- panda/src/linmath/lmatrix4_src.h | 3 + panda/src/mathutil/plane_src.I | 7 +- panda/src/pgraph/cullPlanes.cxx | 3 + 16 files changed, 184 insertions(+), 182 deletions(-) delete mode 100644 panda/src/linmath/lmatrix3.cxx delete mode 100644 panda/src/linmath/lmatrix3.h delete mode 100644 panda/src/linmath/lmatrix4.cxx delete mode 100644 panda/src/linmath/lmatrix4.h diff --git a/panda/src/char/config_char.cxx b/panda/src/char/config_char.cxx index 8a9282a4f4..87220439ae 100644 --- a/panda/src/char/config_char.cxx +++ b/panda/src/char/config_char.cxx @@ -26,7 +26,6 @@ #include "characterVertexSlider.h" #include "jointVertexTransform.h" #include "dconfig.h" -#include "lmatrix4.h" Configure(config_char); NotifyCategoryDef(char, ""); @@ -68,12 +67,6 @@ init_libchar() { CharacterVertexSlider::init_type(); JointVertexTransform::init_type(); - // This isn't defined in this package, but it *is* essential that it - // be initialized. We have to do it explicitly here since template - // statics don't necessarily resolve very well across dynamic - // libraries. - LMatrix4f::init_type(); - //Registration of writeable object's creation //functions with BamReader's factory Character::register_with_read_factory(); diff --git a/panda/src/linmath/Sources.pp b/panda/src/linmath/Sources.pp index 17ba31236a..a58684785b 100644 --- a/panda/src/linmath/Sources.pp +++ b/panda/src/linmath/Sources.pp @@ -14,8 +14,8 @@ compose_matrix_src.cxx compose_matrix_src.h config_linmath.h \ coordinateSystem.h dbl2fltnames.h dblnames.h deg_2_rad.h \ flt2dblnames.h fltnames.h lcast_to.h lcast_to_src.h \ - lcast_to_src.I lmatrix.h lmatrix3.h lmatrix3_src.I \ - lmatrix3_src.cxx lmatrix3_src.h lmatrix4.h lmatrix4_src.I \ + lcast_to_src.I lmatrix.h lmatrix3_src.I \ + lmatrix3_src.cxx lmatrix3_src.h lmatrix4_src.I \ lmatrix4_src.cxx lmatrix4_src.h lorientation.h \ lorientation_src.I lorientation_src.cxx lorientation_src.h \ lpoint2.h lpoint2_src.I lpoint2_src.cxx lpoint2_src.h \ @@ -39,8 +39,8 @@ #define INCLUDED_SOURCES \ compose_matrix.cxx config_linmath.cxx coordinateSystem.cxx \ - lmatrix.cxx lmatrix3.cxx \ - lmatrix4.cxx lorientation.cxx lpoint2.cxx \ + lmatrix.cxx \ + lorientation.cxx lpoint2.cxx \ lpoint3.cxx lpoint4.cxx lquaternion.cxx lrotation.cxx \ luse.cxx lvecBase2.cxx lvecBase3.cxx lvecBase4.cxx \ lvector2.cxx lvector3.cxx lvector4.cxx mathNumbers.cxx \ @@ -53,8 +53,8 @@ compose_matrix_src.h config_linmath.h coordinateSystem.h \ dbl2fltnames.h dblnames.h deg_2_rad.h \ flt2dblnames.h fltnames.h lcast_to.h lcast_to_src.I lcast_to_src.h \ - lmat_ops.h lmat_ops_src.I lmat_ops_src.h lmatrix.h lmatrix3.h \ - lmatrix3_src.I lmatrix3_src.h lmatrix4.h lmatrix4_src.I \ + lmat_ops.h lmat_ops_src.I lmat_ops_src.h lmatrix.h \ + lmatrix3_src.I lmatrix3_src.h lmatrix4_src.I \ lmatrix4_src.h lorientation.h lorientation_src.I \ lorientation_src.h lpoint2.h lpoint2_src.I lpoint2_src.h lpoint3.h \ lpoint3_src.I lpoint3_src.h lpoint4.h lpoint4_src.I lpoint4_src.h \ diff --git a/panda/src/linmath/linmath_composite2.cxx b/panda/src/linmath/linmath_composite2.cxx index 988e72363f..b742520c05 100644 --- a/panda/src/linmath/linmath_composite2.cxx +++ b/panda/src/linmath/linmath_composite2.cxx @@ -2,8 +2,6 @@ #include "compose_matrix.cxx" #include "config_linmath.cxx" #include "coordinateSystem.cxx" -#include "lmatrix3.cxx" -#include "lmatrix4.cxx" #include "lmatrix.cxx" #include "lorientation.cxx" #include "lpoint2.cxx" diff --git a/panda/src/linmath/lmat_ops.h b/panda/src/linmath/lmat_ops.h index ff652b07c2..01baa2d8f1 100644 --- a/panda/src/linmath/lmat_ops.h +++ b/panda/src/linmath/lmat_ops.h @@ -25,8 +25,7 @@ #include "lvecBase4.h" #include "lpoint4.h" #include "lvector4.h" -#include "lmatrix3.h" -#include "lmatrix4.h" +#include "lmatrix.h" #include "fltnames.h" #include "lmat_ops_src.h" diff --git a/panda/src/linmath/lmatrix.cxx b/panda/src/linmath/lmatrix.cxx index b11f68de10..87c7cf7f78 100644 --- a/panda/src/linmath/lmatrix.cxx +++ b/panda/src/linmath/lmatrix.cxx @@ -16,11 +16,12 @@ // //////////////////////////////////////////////////////////////////// -#include "pandabase.h" #include "lmatrix.h" -// This tells GCC to explicitly instantiate the templates defined in -// lmatrix.h and leave them here. -#ifdef __GNUC__ -#pragma implementation -#endif +#include "fltnames.h" +#include "lmatrix3_src.cxx" +#include "lmatrix4_src.cxx" + +#include "dblnames.h" +#include "lmatrix3_src.cxx" +#include "lmatrix4_src.cxx" diff --git a/panda/src/linmath/lmatrix.h b/panda/src/linmath/lmatrix.h index 7fd1468e35..9390a0a12b 100644 --- a/panda/src/linmath/lmatrix.h +++ b/panda/src/linmath/lmatrix.h @@ -21,21 +21,26 @@ #include "pandabase.h" #include "config_linmath.h" +#include +#include "typedObject.h" +#include "datagram.h" +#include "datagramIterator.h" +#include "pnotify.h" +#include "indent.h" -#include "lmatrix3.h" -#include "lmatrix4.h" +#include "deg_2_rad.h" +#include "nearly_zero.h" -/* -typedef LMatrix3 LMatrix3f; -typedef LMatrix4 LMatrix4f; +#include "coordinateSystem.h" +#include "lvecBase4.h" +#include "lvecBase3.h" +#include "lvecBase2.h" -typedef LMatrix3 LMatrix3d; -typedef LMatrix4 LMatrix4d; -*/ +#include "fltnames.h" +// lmatrix3_src.h includes lmatrix4_src.h. +#include "lmatrix3_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif +#include "dblnames.h" +#include "lmatrix3_src.h" #endif diff --git a/panda/src/linmath/lmatrix3.cxx b/panda/src/linmath/lmatrix3.cxx deleted file mode 100644 index 300f10bf61..0000000000 --- a/panda/src/linmath/lmatrix3.cxx +++ /dev/null @@ -1,28 +0,0 @@ -// Filename: lmatrix3.cxx -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#include "config_linmath.h" -#include "lmatrix3.h" - -#include "fltnames.h" -#include "lmatrix3_src.cxx" - -#include "dblnames.h" -#include "lmatrix3_src.cxx" - - diff --git a/panda/src/linmath/lmatrix3.h b/panda/src/linmath/lmatrix3.h deleted file mode 100644 index 8cf76d3597..0000000000 --- a/panda/src/linmath/lmatrix3.h +++ /dev/null @@ -1,41 +0,0 @@ -// Filename: lmatrix3.h -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#ifndef LMATRIX3_H -#define LMATRIX3_H - -#include "pandabase.h" -#include -#include "typedObject.h" -#include "datagram.h" -#include "datagramIterator.h" -#include "pnotify.h" -#include "indent.h" -#include "deg_2_rad.h" -#include "nearly_zero.h" -#include "coordinateSystem.h" -#include "lvecBase3.h" -#include "lvecBase2.h" - -#include "fltnames.h" -#include "lmatrix3_src.h" - -#include "dblnames.h" -#include "lmatrix3_src.h" - -#endif diff --git a/panda/src/linmath/lmatrix3_src.I b/panda/src/linmath/lmatrix3_src.I index 41ac32af6e..5be705dc72 100644 --- a/panda/src/linmath/lmatrix3_src.I +++ b/panda/src/linmath/lmatrix3_src.I @@ -450,8 +450,7 @@ v_res._v.v._2 = v._v.v._0*mat._m.m._02 + v._v.v._1*mat._m.m._12 + v._v.v._2*mat. //////////////////////////////////////////////////////////////////// // Function: LMatrix3::xform // Access: Public -// Description: 3-component vector or point times matrix. This is a -// fully general operation. +// Description: 3-component vector or point times matrix. //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3):: xform(const FLOATNAME(LVecBase3) &v) const { @@ -506,6 +505,45 @@ xform_vec(const FLOATNAME(LVecBase2) &v) const { // v.dot(get_col2(1))); } +//////////////////////////////////////////////////////////////////// +// Function: LMatrix3::xform_vec +// Access: Public +// Description: The matrix transforms a 3-component vector and +// returns the result. This assumes the matrix is an +// orthonormal transform. +// +// In practice, this is the same computation as xform(). +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3):: +xform_vec(const FLOATNAME(LVecBase3) &v) const { + TAU_PROFILE("LVecBase3 LMatrix3::xform_vec(const LVecBase3 &)", " ", TAU_USER); + FLOATNAME(LVecBase3) v_res; + + // v._v.v._3 == 0.0f for this case + + v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10 + v._v.v._2*_m.m._20; + v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11 + v._v.v._2*_m.m._21; + v_res._v.v._2 = v._v.v._0*_m.m._02 + v._v.v._1*_m.m._12 + v._v.v._2*_m.m._22; + + return v_res; +} + +//////////////////////////////////////////////////////////////////// +// Function: LMatrix3::xform_vec_general +// Access: Public +// Description: The matrix transforms a 3-component vector (without +// translation component) and returns the result, as a +// fully general operation. +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3):: +xform_vec_general(const FLOATNAME(LVecBase3) &v) const { + TAU_PROFILE("LVecBase3 LMatrix3::xform_vec_general(const LVecBase3 &)", " ", TAU_USER); + FLOATNAME(LMatrix3) i; + i.invert_transpose_from(*this); + + return i.xform(v); +} + //////////////////////////////////////////////////////////////////// // Function: LMatrix3::mult_cel // Access: Private @@ -833,6 +871,78 @@ invert_in_place() { return invert_from(temp); } +//////////////////////////////////////////////////////////////////// +// Function: LMatrix3::invert_transpose_from +// Access: Public +// Description: Simultaneously computes the inverse of the indicated +// matrix, and then the transpose of that inverse. +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH bool FLOATNAME(LMatrix3):: +invert_transpose_from(const FLOATNAME(LMatrix3) &other) { + TAU_PROFILE("bool LMatrix3::invert_transpose_from(const LMatrix3 &)", " ", TAU_USER); + + FLOATTYPE other_det = MATRIX3_DETERMINANT(other._m.m); + + if (IS_THRESHOLD_ZERO(other_det, (NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE)))) { +#ifdef NOTIFY_DEBUG + linmath_cat.warning() << "Tried to invert singular LMatrix3.\n"; +#endif + (*this) = ident_mat(); + return false; + } + + other_det = 1.0f / other_det; + _m.m._00 = other_det * DET2(other._m.m._11, other._m.m._12, other._m.m._21, other._m.m._22); + _m.m._01 = -other_det * DET2(other._m.m._10, other._m.m._12, other._m.m._20, other._m.m._22); + _m.m._02 = other_det * DET2(other._m.m._10, other._m.m._11, other._m.m._20, other._m.m._21); + + _m.m._10 = -other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._21, other._m.m._22); + _m.m._11 = other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._20, other._m.m._22); + _m.m._12 = -other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._20, other._m.m._21); + + _m.m._20 = other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._11, other._m.m._12); + _m.m._21 = -other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._10, other._m.m._12); + _m.m._22 = other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._10, other._m.m._11); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LMatrix3::invert_transpose_from +// Access: Public +// Description: Simultaneously computes the inverse of the indicated +// matrix, and then the transpose of that inverse. +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH bool FLOATNAME(LMatrix3):: +invert_transpose_from(const FLOATNAME(LMatrix4) &other) { + TAU_PROFILE("bool LMatrix3::invert_transpose_from(const LMatrix4 &)", " ", TAU_USER); + + FLOATTYPE other_det = MATRIX3_DETERMINANT(other._m.m); + + if (IS_THRESHOLD_ZERO(other_det, (NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE)))) { +#ifdef NOTIFY_DEBUG + linmath_cat.warning() << "Tried to invert singular LMatrix4.\n"; +#endif + (*this) = ident_mat(); + return false; + } + + other_det = 1.0f / other_det; + _m.m._00 = other_det * DET2(other._m.m._11, other._m.m._12, other._m.m._21, other._m.m._22); + _m.m._01 = -other_det * DET2(other._m.m._10, other._m.m._12, other._m.m._20, other._m.m._22); + _m.m._02 = other_det * DET2(other._m.m._10, other._m.m._11, other._m.m._20, other._m.m._21); + + _m.m._10 = -other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._21, other._m.m._22); + _m.m._11 = other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._20, other._m.m._22); + _m.m._12 = -other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._20, other._m.m._21); + + _m.m._20 = other_det * DET2(other._m.m._01, other._m.m._02, other._m.m._11, other._m.m._12); + _m.m._21 = -other_det * DET2(other._m.m._00, other._m.m._02, other._m.m._10, other._m.m._12); + _m.m._22 = other_det * DET2(other._m.m._00, other._m.m._01, other._m.m._10, other._m.m._11); + + return true; +} + //////////////////////////////////////////////////////////////////// // Function: LMatrix::set_translate_mat // Access: Public diff --git a/panda/src/linmath/lmatrix3_src.h b/panda/src/linmath/lmatrix3_src.h index 65f78c6782..fa4546127f 100644 --- a/panda/src/linmath/lmatrix3_src.h +++ b/panda/src/linmath/lmatrix3_src.h @@ -16,6 +16,8 @@ // //////////////////////////////////////////////////////////////////// +class FLOATNAME(LMatrix4); + //////////////////////////////////////////////////////////////////// // Class : LMatrix3 // Description : This is a 3-by-3 transform matrix. It typically will @@ -103,6 +105,12 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVecBase2) xform_vec(const FLOATNAME(LVecBase2) &v) const; + INLINE_LINMATH FLOATNAME(LVecBase3) + xform_vec(const FLOATNAME(LVecBase3) &v) const; + + INLINE_LINMATH FLOATNAME(LVecBase3) + xform_vec_general(const FLOATNAME(LVecBase3) &v) const; + // this = other1 * other2 INLINE_LINMATH void multiply( const FLOATNAME(LMatrix3) &other1, const FLOATNAME(LMatrix3) &other2); @@ -131,6 +139,9 @@ PUBLISHED: INLINE_LINMATH bool invert_from(const FLOATNAME(LMatrix3) &other); INLINE_LINMATH bool invert_in_place(); + INLINE_LINMATH bool invert_transpose_from(const FLOATNAME(LMatrix3) &other); + INLINE_LINMATH bool invert_transpose_from(const FLOATNAME(LMatrix4) &other); + static INLINE_LINMATH const FLOATNAME(LMatrix3) &ident_mat(); // A 3x3 matrix is likely to be used for one of two purposes. In @@ -289,4 +300,8 @@ INLINE_LINMATH FLOATNAME(LMatrix3) transpose(const FLOATNAME(LMatrix3) &a); INLINE_LINMATH FLOATNAME(LMatrix3) invert(const FLOATNAME(LMatrix3) &a); END_PUBLISH +// We can safely include lmatrix4_src.h down here and avoid circular +// dependencies. +#include "lmatrix4_src.h" + #include "lmatrix3_src.I" diff --git a/panda/src/linmath/lmatrix4.cxx b/panda/src/linmath/lmatrix4.cxx deleted file mode 100644 index 2437c157ee..0000000000 --- a/panda/src/linmath/lmatrix4.cxx +++ /dev/null @@ -1,28 +0,0 @@ -// Filename: lmatrix4.cxx -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#include "config_linmath.h" -#include "lmatrix4.h" - -#include "fltnames.h" -#include "lmatrix4_src.cxx" - -#include "dblnames.h" -#include "lmatrix4_src.cxx" - - diff --git a/panda/src/linmath/lmatrix4.h b/panda/src/linmath/lmatrix4.h deleted file mode 100644 index 7504a566e8..0000000000 --- a/panda/src/linmath/lmatrix4.h +++ /dev/null @@ -1,43 +0,0 @@ -// Filename: lmatrix4.h -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#ifndef LMATRIX4_H -#define LMATRIX4_H - -#include "pandabase.h" -#include -#include "typedObject.h" -#include "datagram.h" -#include "datagramIterator.h" -#include "indent.h" - -#include "deg_2_rad.h" -#include "nearly_zero.h" - -#include "coordinateSystem.h" -#include "lvecBase4.h" -#include "lvecBase3.h" -#include "lmatrix3.h" - -#include "fltnames.h" -#include "lmatrix4_src.h" - -#include "dblnames.h" -#include "lmatrix4_src.h" - -#endif diff --git a/panda/src/linmath/lmatrix4_src.I b/panda/src/linmath/lmatrix4_src.I index 857fd6ee43..30561ad619 100644 --- a/panda/src/linmath/lmatrix4_src.I +++ b/panda/src/linmath/lmatrix4_src.I @@ -656,7 +656,7 @@ xform_point(const FLOATNAME(LVecBase3) &v) const { // Access: Public // Description: The matrix transforms a 3-component vector (without // translation component) and returns the result. This -// assumes the matrix is an affine transform. +// assumes the matrix is an orthonormal transform. //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: xform_vec(const FLOATNAME(LVecBase3) &v) const { @@ -672,6 +672,22 @@ xform_vec(const FLOATNAME(LVecBase3) &v) const { return v_res; } +//////////////////////////////////////////////////////////////////// +// Function: LMatrix4::xform_vec_general +// Access: Public +// Description: The matrix transforms a 3-component vector (without +// translation component) and returns the result, as a +// fully general operation. +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: +xform_vec_general(const FLOATNAME(LVecBase3) &v) const { + TAU_PROFILE("LVecBase3 LMatrix4::xform_vec_general(const LVecBase3 &)", " ", TAU_USER); + FLOATNAME(LMatrix3) i; + i.invert_transpose_from(*this); + + return i.xform(v); +} + //////////////////////////////////////////////////////////////////// // Function: LMatrix4::mult_cel // Access: Private diff --git a/panda/src/linmath/lmatrix4_src.h b/panda/src/linmath/lmatrix4_src.h index 5d5c8615f1..64b2c43d92 100644 --- a/panda/src/linmath/lmatrix4_src.h +++ b/panda/src/linmath/lmatrix4_src.h @@ -107,6 +107,9 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVecBase3) xform_vec(const FLOATNAME(LVecBase3) &v) const; + INLINE_LINMATH FLOATNAME(LVecBase3) + xform_vec_general(const FLOATNAME(LVecBase3) &v) const; + // this = other1 * other2 INLINE_LINMATH void multiply(const FLOATNAME(LMatrix4) &other1, const FLOATNAME(LMatrix4) &other2); diff --git a/panda/src/mathutil/plane_src.I b/panda/src/mathutil/plane_src.I index cd74ad131f..6081b9d745 100644 --- a/panda/src/mathutil/plane_src.I +++ b/panda/src/mathutil/plane_src.I @@ -99,9 +99,8 @@ FLOATNAME(Plane)(FLOATTYPE a, FLOATTYPE b, FLOATTYPE c, FLOATTYPE d) : //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL FLOATNAME(Plane) FLOATNAME(Plane):: operator * (const FLOATNAME(LMatrix3) &mat) const { - FLOATNAME(LVector3) new_normal = get_normal() * mat; - FLOATNAME(LPoint3) new_point = get_point() * mat; - return FLOATNAME(Plane)(new_normal, new_point); + FLOATNAME(LVector3) new_normal = mat.xform(get_normal()); + return FLOATNAME(Plane)(new_normal, get_point()); } //////////////////////////////////////////////////////////////////// @@ -111,7 +110,7 @@ operator * (const FLOATNAME(LMatrix3) &mat) const { //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL FLOATNAME(Plane) FLOATNAME(Plane):: operator * (const FLOATNAME(LMatrix4) &mat) const { - FLOATNAME(LVector3) new_normal = get_normal() * mat; + FLOATNAME(LVector3) new_normal = mat.xform_vec_general(get_normal()); FLOATNAME(LPoint3) new_point = get_point() * mat; return FLOATNAME(Plane)(new_normal, new_point); } diff --git a/panda/src/pgraph/cullPlanes.cxx b/panda/src/pgraph/cullPlanes.cxx index 6689245eca..5ebc452404 100644 --- a/panda/src/pgraph/cullPlanes.cxx +++ b/panda/src/pgraph/cullPlanes.cxx @@ -155,6 +155,9 @@ do_cull(int &result, CPT(RenderState) &state, Planes::const_iterator pi; for (pi = _planes.begin(); pi != _planes.end(); ++pi) { int plane_result = (*pi).second->contains(node_gbv); + pgraph_cat.debug() + << "comparing " << *(*pi).second << " to " << *node_gbv + << ": " << hex << plane_result << dec << "\n"; if (plane_result == BoundingVolume::IF_no_intersection) { // The node is completely behind this clip plane. Short-circuit // the rest of the logic; none of the other planes matter.