From 406136a515365487bd1837932c3952bfdcd62a64 Mon Sep 17 00:00:00 2001
From: Shon Ferguson <shonferg@users.sourceforge.net>
Date: Sat, 5 May 2007 18:50:17 +0000
Subject: [PATCH] Re-exposed IDENTITY constants and marked then NIFLIB_API. 
 Now you must use MatrixXX::IDENTITY instead of MatrixXX::Identity() again.

---
 include/nif_math.h     | 25 +++++++------------------
 src/nif_math.cpp       | 18 +++---------------
 src/obj/NiGeometry.cpp |  4 ++--
 src/obj/NiNode.cpp     |  4 ++--
 4 files changed, 14 insertions(+), 37 deletions(-)

diff --git a/include/nif_math.h b/include/nif_math.h
index 1378c001..755c03a7 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 b1d5cc8d..f004899a 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 3b2fac73..160eed52 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 024adacc..da13cfae 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 ) {
-- 
GitLab