From 7a4780b4a8d8478181ce9a29c9549f3ffe9cc181 Mon Sep 17 00:00:00 2001
From: Shon Ferguson <shonferg@users.sourceforge.net>
Date: Sat, 24 Jun 2006 19:33:15 +0000
Subject: [PATCH] Fix for NiKeyframeData is no longer in implementation file.

---
 gen/obj_impl.cpp       | 10 ----------
 obj/NiKeyframeData.cpp | 10 ++++++++++
 obj/NiKeyframeData.h   |  1 +
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/gen/obj_impl.cpp b/gen/obj_impl.cpp
index de340f72..20275d92 100644
--- a/gen/obj_impl.cpp
+++ b/gen/obj_impl.cpp
@@ -6261,11 +6261,6 @@ void NiKeyframeData::InternalRead( istream& in, list<uint> & link_stack, unsigne
 
 void NiKeyframeData::InternalWrite( ostream& out, map<NiObjectRef,uint> link_map, unsigned int version, unsigned int user_version ) const {
 	AKeyedData::Write( out, link_map, version, user_version );
-	if ( rotationType == XYZ_ROTATION_KEY ) {
-		numRotationKeys = 1;
-	} else {
-		numRotationKeys = uint(quaternionKeys.size());
-	}
 	NifStream( numRotationKeys, out, version );
 	if ( (numRotationKeys != 0) ) {
 		NifStream( rotationType, out, version );
@@ -6313,11 +6308,6 @@ void NiKeyframeData::InternalWrite( ostream& out, map<NiObjectRef,uint> link_map
 std::string NiKeyframeData::InternalAsString( bool verbose ) const {
 	stringstream out;
 	out << AKeyedData::asString();
-	if ( rotationType == XYZ_ROTATION_KEY ) {
-		numRotationKeys = 1;
-	} else {
-		numRotationKeys = uint(quaternionKeys.size());
-	}
 	out << "  Num Rotation Keys:  " << numRotationKeys << endl;
 	if ( (numRotationKeys != 0) ) {
 		out << "    Rotation Type:  " << rotationType << endl;
diff --git a/obj/NiKeyframeData.cpp b/obj/NiKeyframeData.cpp
index c042799e..c99f8edc 100644
--- a/obj/NiKeyframeData.cpp
+++ b/obj/NiKeyframeData.cpp
@@ -44,14 +44,24 @@ KeyType NiKeyframeData::GetRotateType() const {
 
 void NiKeyframeData::SetRotateType( KeyType t ) {
 	rotationType = t;
+	UpdateRotationKeyCount();
 }
 
 vector< Key<Quaternion> > NiKeyframeData::GetQuatRotateKeys() const {
 	return quaternionKeys;
 }
 
+void NiKeyframeData::UpdateRotationKeyCount() {
+	if ( rotationType == XYZ_ROTATION_KEY ) {
+		numRotationKeys = 1;
+	} else {
+		numRotationKeys = uint(quaternionKeys.size());
+	}
+};
+
 void NiKeyframeData::SetQuatRotateKeys( const vector< Key<Quaternion> > & keys ) {
 	quaternionKeys = keys;
+	UpdateRotationKeyCount();
 }
 
 KeyType NiKeyframeData::GetXRotateType() const {
diff --git a/obj/NiKeyframeData.h b/obj/NiKeyframeData.h
index 403b785b..fb08de34 100644
--- a/obj/NiKeyframeData.h
+++ b/obj/NiKeyframeData.h
@@ -185,6 +185,7 @@ public:
 	void SetScaleKeys( vector< Key<float> > const & keys );
 
 protected:
+	void UpdateRotationKeyCount();
 	NI_KEYFRAME_DATA_MEMBERS
 	STANDARD_INTERNAL_METHODS
 };
-- 
GitLab