diff --git a/include/nif_math.h b/include/nif_math.h index 1378c0013286869fba50bf3b38280c5b6f673371..755c03a7b036a8df1ed3d459b3b8fd6a79d2006c 100644 --- a/include/nif_math.h +++ b/include/nif_math.h @@ -316,8 +316,8 @@ struct NIFLIB_API Float2 { /*! Stores a 2 by 2 matrix used for bump maps. */ struct Matrix22 { - /*! Get the 2x2 identity matrix */ - NIFLIB_API static const Matrix22 & Identity(); + /*! The 2x2 identity matrix constant */ + NIFLIB_API static const Matrix22 IDENTITY; Float2 rows[2]; /*!< The two rows of Float2 structures which hold two floating point numbers each. */ @@ -372,9 +372,6 @@ struct Matrix22 { throw std::out_of_range("Index out of range for MatrixRow3"); return rows[n]; } -private: - /*! The 2x2 identity matrix constant */ - static const Matrix22 IDENTITY; }; /* Stores three floating point numbers. Used as a row of a Matrix33 and to store the data in attr_vector3 and attr_color3 type attributes. */ @@ -435,8 +432,8 @@ struct NIFLIB_API Float3 { /*! Stores a 3 by 3 matrix used for rotation. */ struct Matrix33 { - /*! Returns the 3x3 identity matrix */ - NIFLIB_API static const Matrix33 & Identity(); + /*! The 3x3 identity matrix constant*/ + NIFLIB_API static const Matrix33 IDENTITY; Float3 rows[3]; /*!< The three rows of Float3 structures which hold three floating point numbers each. */ @@ -524,10 +521,6 @@ struct Matrix33 { throw std::out_of_range("Index out of range for MatrixRow3"); return rows[n]; } - -private: - /*! The 3x3 identity matrix constant*/ - static const Matrix33 IDENTITY; }; @@ -593,9 +586,9 @@ struct NIFLIB_API Float4 { /*! Stores a 4 by 4 matrix used for combined transformations. */ struct Matrix44 { - /*! Returns the 4x4 identity matrix */ - NIFLIB_API static const Matrix44 & Identity(); - + /*! The 4x4 identity matrix constant */ + NIFLIB_API static const Matrix44 IDENTITY; + Float4 rows[4]; /*!< The three rows of Float3 structures which hold three floating point numbers each. */ //These operators cause SWIG warnings @@ -815,10 +808,6 @@ struct Matrix44 { throw std::out_of_range("Index out of range for Matrix44"); return rows[n]; } - - private: - /*! The 4x4 identity matrix constant */ - static const Matrix44 IDENTITY; }; /*! Stores a color along with alpha translucency */ diff --git a/src/nif_math.cpp b/src/nif_math.cpp index b1d5cc8dd5ebad764fb85c0b74d2cd577690317a..f004899a5e404e26c1408fdb9a1e59109048f51b 100644 --- a/src/nif_math.cpp +++ b/src/nif_math.cpp @@ -12,25 +12,13 @@ const Matrix44 Matrix44::IDENTITY( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ); -const Matrix44 & Matrix44::Identity() { - return IDENTITY; -}; - const Matrix33 Matrix33::IDENTITY( 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f ); -const Matrix33 & Matrix33::Identity() { - return IDENTITY; -}; - const Matrix22 Matrix22::IDENTITY( 1.0f, 0.0f, 0.0f, 1.0f ); -const Matrix22 & Matrix22::Identity() { - return IDENTITY; -}; - /* TexCoord Methods * */ @@ -162,7 +150,7 @@ Vector3 Vector3::CrossProduct( const Vector3 & rh) const { */ Matrix22::Matrix22() { - *this = Matrix22::Identity(); + *this = Matrix22::IDENTITY; } /* @@ -170,7 +158,7 @@ Matrix22::Matrix22() { */ Matrix33::Matrix33() { - *this = Matrix33::Identity(); + *this = Matrix33::IDENTITY; } Quaternion Matrix33::AsQuaternion() { @@ -241,7 +229,7 @@ Matrix33 Matrix33::operator*( const Matrix33 & m ) const */ Matrix44::Matrix44() { - *this = Matrix44::Identity(); + *this = Matrix44::IDENTITY; } Matrix44::Matrix44( const Matrix33 & r ) { diff --git a/src/obj/NiGeometry.cpp b/src/obj/NiGeometry.cpp index 3b2fac734c60884f8733c0527309d7d9434d820b..160eed526f484321d42836e2dc2bec6b493a3580 100644 --- a/src/obj/NiGeometry.cpp +++ b/src/obj/NiGeometry.cpp @@ -144,7 +144,7 @@ void NiGeometry::ApplySkinOffset() { this->ApplyTransforms(); //Set the skin overall transform to the identity - skinInstance->GetSkinData()->SetOverallTransform( Matrix44::Identity() ); + skinInstance->GetSkinData()->SetOverallTransform( Matrix44::IDENTITY ); //Reset skin offsets skinInstance->GetSkinData()->ResetOffsets( this ); @@ -266,7 +266,7 @@ void NiGeometry::ApplyTransforms() { geom_data->Transform( this->GetLocalTransform() ); //Now that the transforms have been applied, clear them to the identity - this->SetLocalTransform( Matrix44::Identity() ); + this->SetLocalTransform( Matrix44::IDENTITY ); } // Calculate bounding sphere using minimum-volume axis-align bounding box. Its fast but not a very good fit. diff --git a/src/obj/NiNode.cpp b/src/obj/NiNode.cpp index 024adacccba69fc7c83a8d3b17c14413836e5ad6..da13cfae6cb37e8d8715e09a93dfb104a3dd7e7d 100644 --- a/src/obj/NiNode.cpp +++ b/src/obj/NiNode.cpp @@ -239,7 +239,7 @@ void NiNode::PropagateTransform() { } //Nowthat the transforms have been propogated, clear them out - this->SetLocalTransform( Matrix44::Identity() ); + this->SetLocalTransform( Matrix44::IDENTITY ); } bool NiNode::IsSplitMeshProxy() const { @@ -263,7 +263,7 @@ bool NiNode::IsSplitMeshProxy() const { if ( children[i]->IsDerivedType( NiTriBasedGeom::TypeConst() ) == false ) { return false; } - if ( children[i]->GetLocalTransform() != Matrix44::Identity() ) { + if ( children[i]->GetLocalTransform() != Matrix44::IDENTITY ) { return false; } if ( children[i]->GetVisibility() == false ) {