소스 검색

LMatrix4::xform_point_general_in_place()

David Rose 13 년 전
부모
커밋
29e5d74613
4개의 변경된 파일38개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 2
      panda/src/grutil/pfmFile.cxx
  2. 27 0
      panda/src/linmath/lmatrix4_src.I
  3. 6 0
      panda/src/linmath/lmatrix4_src.h
  4. 4 1
      panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx

+ 1 - 2
panda/src/grutil/pfmFile.cxx

@@ -534,8 +534,7 @@ xform(const LMatrix4 &transform) {
     if (_has_no_data_value && (*ti) == _no_data_value) {
       continue;
     }
-
-    (*ti) = (*ti) * transform;
+    transform.xform_point_general_in_place(*ti);
   }
 }
 

+ 27 - 0
panda/src/linmath/lmatrix4_src.I

@@ -862,6 +862,21 @@ xform_point(const FLOATNAME(LVecBase3) &v) const {
   return v_res;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::xform_point_general
+//       Access: Public
+//  Description: The matrix transforms a 3-component point (including
+//               translation component) and returns the result, as a
+//               fully general operation.
+////////////////////////////////////////////////////////////////////
+INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4)::
+xform_point_general(const FLOATNAME(LVecBase3) &v) const {
+  TAU_PROFILE("LVecBase3 LMatrix4::xform_point_general(const LVecBase3 &)", " ", TAU_USER);
+  FLOATNAME(LVecBase4) v4(v[0], v[1], v[2], 1.0);
+  v4 = xform(v4);
+  return FLOATNAME(LVecBase3)(v4[0] / v4[3], v4[1] / v4[3], v4[2] / v4[3]);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix4::xform_vec
 //       Access: Public
@@ -943,6 +958,18 @@ xform_point_in_place(FLOATNAME(LVecBase3) &v) const {
 #endif  // HAVE_EIGEN
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::xform_point_general_in_place
+//       Access: Public
+//  Description: The matrix transforms a 3-component point (including
+//               translation component), as a fully general operation.
+////////////////////////////////////////////////////////////////////
+INLINE_LINMATH void FLOATNAME(LMatrix4)::
+xform_point_general_in_place(FLOATNAME(LVecBase3) &v) const {
+  TAU_PROFILE("void LMatrix4::xform_point_general_in_place(LVecBase3 &)", " ", TAU_USER);
+  v = xform_point_general(v);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix4::xform_vec_in_place
 //       Access: Public

+ 6 - 0
panda/src/linmath/lmatrix4_src.h

@@ -137,6 +137,9 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LVecBase3)
   xform_point(const FLOATNAME(LVecBase3) &v) const;
 
+  INLINE_LINMATH FLOATNAME(LVecBase3)
+  xform_point_general(const FLOATNAME(LVecBase3) &v) const;
+
   INLINE_LINMATH FLOATNAME(LVecBase3)
   xform_vec(const FLOATNAME(LVecBase3) &v) const;
 
@@ -149,6 +152,9 @@ PUBLISHED:
   INLINE_LINMATH void
   xform_point_in_place(FLOATNAME(LVecBase3) &v) const;
 
+  INLINE_LINMATH void
+  xform_point_general_in_place(FLOATNAME(LVecBase3) &v) const;
+
   INLINE_LINMATH void
   xform_vec_in_place(FLOATNAME(LVecBase3) &v) const;
 

+ 4 - 1
panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx

@@ -899,6 +899,7 @@ write_data(xel *array, xelval *alpha) {
 
   switch ( get_color_type() ) {
   case CT_color:
+  case CT_grayscale:
     // This call is a bit of fakery to convert our proper 2-d array of
     // xels to an indirect 2-d array of pixels.  We make it look like a
     // single row of _x_size * _y_size pixels.
@@ -907,7 +908,7 @@ write_data(xel *array, xelval *alpha) {
     // regardless of the number of colors we can read.
     chv = ppm_computecolorhist( (pixel **)&array, _x_size * _y_size, 1,
                                 256, &colors );
-    if ( chv == (colorhist_vector) 0 ) {
+    if ( chv == (colorhist_vector) 0 || true) {
       pnmimage_tiff_cat.debug()
         << colors << " colors found; too many for a palette.\n"
         << "Writing a 24-bit RGB file.\n";
@@ -936,10 +937,12 @@ write_data(xel *array, xelval *alpha) {
     grayscale = false;
     break;
 
+    /*
   case CT_grayscale:
     chv = (colorhist_vector) 0;
     grayscale = true;
     break;
+    */
 
   default:
     break;