Added fast functions to construct all-zero and all-ones matrices

This commit is contained in:
Josh Yelon 2008-01-25 03:37:14 +00:00
parent d0aac98dac
commit ec4e8cdab5
3 changed files with 36 additions and 0 deletions

View File

@ -29,6 +29,26 @@ ident_mat() {
return _ident_mat;
}
////////////////////////////////////////////////////////////////////
// Function: LMatrix4::ones_mat
// Access: Public, Static
// Description: Returns an matrix filled with ones.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4)::
ones_mat() {
return _ones_mat;
}
////////////////////////////////////////////////////////////////////
// Function: LMatrix4::zeros_mat
// Access: Public, Static
// Description: Returns an matrix filled with zeros.
////////////////////////////////////////////////////////////////////
INLINE_LINMATH const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4)::
zeros_mat() {
return _zeros_mat;
}
////////////////////////////////////////////////////////////////////
// Function: LMatrix4::Default Constructor
// Access: Public

View File

@ -24,6 +24,18 @@ const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ident_mat =
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ones_mat =
FLOATNAME(LMatrix4)(1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f);
const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_zeros_mat =
FLOATNAME(LMatrix4)(0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f);
const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_y_to_z_up_mat =
FLOATNAME(LMatrix4)(1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,

View File

@ -134,6 +134,8 @@ PUBLISHED:
INLINE_LINMATH bool invert_in_place();
INLINE_LINMATH static const FLOATNAME(LMatrix4) &ident_mat();
INLINE_LINMATH static const FLOATNAME(LMatrix4) &ones_mat();
INLINE_LINMATH static const FLOATNAME(LMatrix4) &zeros_mat();
INLINE_LINMATH void
set_translate_mat(const FLOATNAME(LVecBase3) &trans);
@ -228,6 +230,8 @@ private:
bool back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const;
static const FLOATNAME(LMatrix4) _ident_mat;
static const FLOATNAME(LMatrix4) _ones_mat;
static const FLOATNAME(LMatrix4) _zeros_mat;
static const FLOATNAME(LMatrix4) _y_to_z_up_mat;
static const FLOATNAME(LMatrix4) _z_to_y_up_mat;
static const FLOATNAME(LMatrix4) _flip_y_mat;