From 7a0c3cd482fc60df065533418b417eb550c5f6ed Mon Sep 17 00:00:00 2001
From: Tazpn <tazpn@users.sourceforge.net>
Date: Mon, 8 Sep 2008 02:26:10 +0000
Subject: [PATCH] niflib: More changes for mass properties

---
 src/NIF_IO.cpp   | 8 ++++----
 src/nif_math.cpp | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/NIF_IO.cpp b/src/NIF_IO.cpp
index 91d24d38..c02e3961 100644
--- a/src/NIF_IO.cpp
+++ b/src/NIF_IO.cpp
@@ -839,16 +839,16 @@ ostream & operator<<( ostream & out, Char8String const & val ) {
 
 //InertiaMatrix
 void NifStream( InertiaMatrix & val, istream& in, const NifInfo & info ) {
-	for (int c = 0; c < 3; ++c) {
-		for (int r = 0; r < 4; ++r) {
+	for (int r = 0; r < 3; ++r) {
+		for (int c = 0; c < 4; ++c) {
 			val[r][c] = ReadFloat( in );
 		}
 	}
 }
 
 void NifStream( InertiaMatrix const & val, ostream& out, const NifInfo & info ) {
-	for (int c = 0; c < 3; ++c) {
-		for (int r = 0; r < 4; ++r) {
+	for (int r = 0; r < 3; ++r) {
+		for (int c = 0; c < 4; ++c) {
 			WriteFloat( val[r][c], out );
 		}
 	}
diff --git a/src/nif_math.cpp b/src/nif_math.cpp
index 48f317b7..b83a5574 100644
--- a/src/nif_math.cpp
+++ b/src/nif_math.cpp
@@ -687,7 +687,7 @@ InertiaMatrix & InertiaMatrix::operator*=( const InertiaMatrix & rh ) {
 	for (int i = 0; i < _countof(rows); i++) {
 		for (int j = 0; j < 4; j++) {
 			t = 0.0f;
-			for (int k = 0; k < 4; k++) {
+			for (int k = 0; k < _countof(rows); k++) {
 				t += lh[i][k] * rh[k][j];
 			}
 			r[i][j] = t;
-- 
GitLab