LMatrix4::xform_point_general_in_place()

This commit is contained in:
David Rose 2012-03-28 00:12:56 +00:00
parent fcbf66df25
commit 29e5d74613
4 changed files with 38 additions and 3 deletions

View File

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

View File

@ -862,6 +862,21 @@ xform_point(const FLOATNAME(LVecBase3) &v) const {
return v_res; 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 // Function: LMatrix4::xform_vec
// Access: Public // Access: Public
@ -943,6 +958,18 @@ xform_point_in_place(FLOATNAME(LVecBase3) &v) const {
#endif // HAVE_EIGEN #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 // Function: LMatrix4::xform_vec_in_place
// Access: Public // Access: Public

View File

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

View File

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