From 88ecf945503ae14fffcce2c28aa573b19807fa3e Mon Sep 17 00:00:00 2001
From: Shon Ferguson <shonferg@users.sourceforge.net>
Date: Sat, 23 Sep 2006 04:50:35 +0000
Subject: [PATCH] Fixed ComplexShape::Merge and ComplexShape::Split to properly
 take new uvSet member of TexDesc into account. Updated Niflib for Python
 readme to reflect the continuing "new_niflib" name. Reverted
 NiTriBasedGeom::GetSkinInfluencedVertices function to old functionality which
 works as long as the NIF is valid.  Some valid NIF files were not loading
 with the new changes. Updated version in Doxyfile to 0.5.8

---
 Doxyfile                     |   2 +-
 Niflib for Python ReadMe.txt |   8 +-
 include/gen/TexDesc.h        |   5 +-
 src/ComplexShape.cpp         | 140 ++++++++++++++++++-----------------
 src/gen/TexDesc.cpp          |   2 +-
 src/gen/obj_impl.cpp         |  54 +++++++-------
 src/obj/NiTriBasedGeom.cpp   |   8 +-
 7 files changed, 111 insertions(+), 108 deletions(-)

diff --git a/Doxyfile b/Doxyfile
index de7558c0..d70e69e3 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -4,7 +4,7 @@
 # Project related configuration options
 #---------------------------------------------------------------------------
 PROJECT_NAME           = Niflib
-PROJECT_NUMBER         = 0.5.6
+PROJECT_NUMBER         = 0.5.8
 OUTPUT_DIRECTORY       = doc
 CREATE_SUBDIRS         = NO
 OUTPUT_LANGUAGE        = English
diff --git a/Niflib for Python ReadMe.txt b/Niflib for Python ReadMe.txt
index 70b41861..a4be7fb0 100644
--- a/Niflib for Python ReadMe.txt	
+++ b/Niflib for Python ReadMe.txt	
@@ -2,9 +2,11 @@ Python SWIG wrapper for Niflib
 
 To use:  Unzip the files to your Python folder (Probably C:\Python24).
 
-Due to the many API changes in this version of Niflib, the module is called "new_niflib" to
-give people using the existing Niflib for Python the ability to use both versions at the same time.
-The next major release will return to the name "niflib."
+Due to many API changes in Niflib 0.5, the module is called "new_niflib" to give
+people using the older versions of Niflib for Python the ability to use both
+versions at the same time.
+
+A future release will return to using 'niflib.'
 
 From within Python:
 
diff --git a/include/gen/TexDesc.h b/include/gen/TexDesc.h
index d45eb527..61ae6340 100644
--- a/include/gen/TexDesc.h
+++ b/include/gen/TexDesc.h
@@ -34,9 +34,10 @@ struct NIFLIB_API TexDesc {
 	 */
 	TexFilterMode filterMode;
 	/*!
-	 * Texture set? Usually 0.
+	 * The texture coordinate set in NiTriBasedGeomData that this texture
+	 * slot will use.
 	 */
-	uint textureSet;
+	uint uvSet;
 	/*!
 	 * 0?
 	 */
diff --git a/src/ComplexShape.cpp b/src/ComplexShape.cpp
index 439bbbbb..67669939 100644
--- a/src/ComplexShape.cpp
+++ b/src/ComplexShape.cpp
@@ -331,87 +331,88 @@ void ComplexShape::Merge( const Ref<NiAVObject> & root ) {
 		//Texture Coordinates
 
 		//Create UV set list
-		vector<TexType> uvSetList;
+		vector<TexType> uvSetList( shapeUVs.size() );
+		//Initialize to base
+		for ( unsigned tex = 0; tex < uvSetList.size(); ++tex ) {
+			uvSetList[tex] = BASE_MAP;
+		}
 		NiPropertyRef niProp = (*geom)->GetPropertyByType( NiTexturingProperty::TypeConst() );
 		NiTexturingPropertyRef niTexProp;
 		if ( niProp != NULL ) {
 			niTexProp = DynamicCast<NiTexturingProperty>(niProp);
 		}
+
 		if ( niTexProp != NULL ) {
+			//Add the UV set to the list for every type of texture slot that uses it
 			for ( int tex = 0; tex < 8; ++tex ) {
 				if ( niTexProp->HasTexture(tex) == true ) {
-					////cout << "Adding texture type to list:  " << TexType(tex) << endl;
-					uvSetList.push_back( TexType(tex) );
-				}
-			}
-		}
-
-		for ( unsigned set = 0; set < shapeUVs.size(); ++set ) {
-			TexType newType = BASE_MAP;
-			if ( uvSetList.size() > set ) {
-				 newType = uvSetList[set];
-			}
+					TexDesc td = niTexProp->GetTexture(tex);
+					
+					unsigned set = td.uvSet;
+					TexType newType = TexType(tex);
+
+					//Search for matching UV set
+					bool match_found = false;
+					unsigned uvSetIndex;
+					for ( unsigned set_index = 0; set_index < texCoordSets.size(); ++set_index ) {
+						if ( texCoordSets[set_index].texType  == newType ) {
+							////cout << "Match found, use existing texture set index" << endl;
+							//Match found, use existing index
+							uvSetIndex = set_index;
+							match_found = true;
+							//Stop searching
+							break;
+						}
+					}
 
-			//Search for matching UV set
-			bool match_found = false;
-			unsigned uvSetIndex;
-			for ( unsigned set_index = 0; set_index < texCoordSets.size(); ++set_index ) {
-				if ( texCoordSets[set_index].texType  == newType ) {
-					////cout << "Match found, use existing texture set index" << endl;
-					//Match found, use existing index
-					uvSetIndex = set_index;
-					match_found = true;
-					//Stop searching
-					break;
-				}
-			}
+					if ( match_found == false ) {
+						////cout << "No match found, add this texture set to the list" << endl;
+						//No match found, add this UV set to the list
+						TexCoordSet newTCS;
+						newTCS.texType = newType;
+						texCoordSets.push_back( newTCS );
+						//Record new index
+						uvSetIndex = unsigned(texCoordSets.size()) - 1;
+					}
 
-			if ( match_found == false ) {
-				////cout << "No match found, add this texture set to the list" << endl;
-				//No match found, add this UV set to the list
-				TexCoordSet newTCS;
-				newTCS.texType = newType;
-				texCoordSets.push_back( newTCS );
-				//Record new index
-				uvSetIndex = unsigned(texCoordSets.size()) - 1;
-			}
+					////cout << "Loop through texture cooridnates in this set" << endl;
+					for ( unsigned v = 0; v < shapeUVs[set].size(); ++v ) {
+						TexCoord newCoord;
+
+						newCoord = shapeUVs[set][v];
+
+						//cout << "Search for matching texture coordinate" << endl;
+						//cout << "uvSetIndex:  " << uvSetIndex << endl;
+						//cout << "set:  " << set << endl;
+						//cout << "texCoordSets.size():  " << unsigned(texCoordSets.size()) << endl;
+						//cout << "v:  " << v << endl;
+						//cout << "lookUp.size():  " << unsigned(lookUp.size()) << endl;
+						//cout << "texCoordSets[uvSetIndex].texCoords.size():  " << unsigned(texCoordSets[uvSetIndex].texCoords.size()) << endl;
+						//Search for matching texture cooridnate
+						bool match_found = false;
+						for ( unsigned tc_index = 0; tc_index < texCoordSets[uvSetIndex].texCoords.size(); ++tc_index ) {
+							if ( texCoordSets[uvSetIndex].texCoords[tc_index]  == newCoord ) {
+								////cout << " Match found, using existing index" << endl;;
+								//Match found, use existing index
+								lookUp[v].uvIndices[uvSetIndex] = tc_index;
+								match_found = true;
+								////cout << "Stop searching" << endl;
+								//Stop searching
+								break;
+							}
+						}
 
-			////cout << "Loop through texture cooridnates in this set" << endl;
-			for ( unsigned v = 0; v < shapeUVs[set].size(); ++v ) {
-				TexCoord newCoord;
-
-				newCoord = shapeUVs[set][v];
-
-				//cout << "Search for matching texture coordinate" << endl;
-				//cout << "uvSetIndex:  " << uvSetIndex << endl;
-				//cout << "set:  " << set << endl;
-				//cout << "texCoordSets.size():  " << unsigned(texCoordSets.size()) << endl;
-				//cout << "v:  " << v << endl;
-				//cout << "lookUp.size():  " << unsigned(lookUp.size()) << endl;
-				//cout << "texCoordSets[uvSetIndex].texCoords.size():  " << unsigned(texCoordSets[uvSetIndex].texCoords.size()) << endl;
-				//Search for matching texture cooridnate
-				bool match_found = false;
-				for ( unsigned tc_index = 0; tc_index < texCoordSets[uvSetIndex].texCoords.size(); ++tc_index ) {
-					if ( texCoordSets[uvSetIndex].texCoords[tc_index]  == newCoord ) {
-						////cout << " Match found, using existing index" << endl;;
-						//Match found, use existing index
-						lookUp[v].uvIndices[uvSetIndex] = tc_index;
-						match_found = true;
-						////cout << "Stop searching" << endl;
-						//Stop searching
-						break;
+						////cout << "Done with loop, check if match was found" << endl;
+						if ( match_found == false ) {
+							////cout << "No match found" << endl;
+							//No match found, add this texture coordinate to the list
+							texCoordSets[uvSetIndex].texCoords.push_back( newCoord );
+							////cout << "Record new index" << endl;
+							//Record new index
+							lookUp[v].uvIndices[uvSetIndex] = unsigned(texCoordSets[uvSetIndex].texCoords.size()) - 1;
+						}
 					}
 				}
-
-				////cout << "Done with loop, check if match was found" << endl;
-				if ( match_found == false ) {
-					////cout << "No match found" << endl;
-					//No match found, add this texture coordinate to the list
-					texCoordSets[uvSetIndex].texCoords.push_back( newCoord );
-					////cout << "Record new index" << endl;
-					//Record new index
-					lookUp[v].uvIndices[uvSetIndex] = unsigned(texCoordSets[uvSetIndex].texCoords.size()) - 1;
-				}
 			}
 		}
 
@@ -791,6 +792,9 @@ Ref<NiAVObject> ComplexShape::Split( Ref<NiNode> & parent, Matrix44 & transform,
 			for ( int tex_num = 0; tex_num < 8; ++tex_num ) {
 				if (niTexProp->HasTexture(tex_num)) {
 					shapeTexCoordSets.push_back(tex_num);
+					TexDesc td = niTexProp->GetTexture(tex_num);
+					td.uvSet = shapeTexCoordSets.size() - 1;
+					niTexProp->SetTexture(tex_num, td);
 				}
 			}
 		} else {
diff --git a/src/gen/TexDesc.cpp b/src/gen/TexDesc.cpp
index ae265b3b..4aac8d5b 100644
--- a/src/gen/TexDesc.cpp
+++ b/src/gen/TexDesc.cpp
@@ -6,7 +6,7 @@ All rights reserved.  Please see niflib.h for licence. */
 using namespace Niflib;
 
 //Constructor
-TexDesc::TexDesc() : source(NULL), clampMode((TexClampMode)WRAP_S_WRAP_T), filterMode((TexFilterMode)FILTER_TRILERP), textureSet((uint)0), ps2L((ushort)0), ps2K((ushort)0xFFB5), unknown1((ushort)0), hasTextureTransform(false), wRotation(0.0f), transformType_((uint)0) {};
+TexDesc::TexDesc() : source(NULL), clampMode((TexClampMode)WRAP_S_WRAP_T), filterMode((TexFilterMode)FILTER_TRILERP), uvSet((uint)0), ps2L((ushort)0), ps2K((ushort)0xFFB5), unknown1((ushort)0), hasTextureTransform(false), wRotation(0.0f), transformType_((uint)0) {};
 
 //Destructor
 TexDesc::~TexDesc() {};
diff --git a/src/gen/obj_impl.cpp b/src/gen/obj_impl.cpp
index c1cead69..17bdca5e 100644
--- a/src/gen/obj_impl.cpp
+++ b/src/gen/obj_impl.cpp
@@ -10681,7 +10681,7 @@ void NiTexturingProperty::InternalRead( istream& in, list<uint> & link_stack, un
 		link_stack.push_back( block_num );
 		NifStream( baseTexture.clampMode, in, version );
 		NifStream( baseTexture.filterMode, in, version );
-		NifStream( baseTexture.textureSet, in, version );
+		NifStream( baseTexture.uvSet, in, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( baseTexture.ps2L, in, version );
 			NifStream( baseTexture.ps2K, in, version );
@@ -10706,7 +10706,7 @@ void NiTexturingProperty::InternalRead( istream& in, list<uint> & link_stack, un
 		link_stack.push_back( block_num );
 		NifStream( darkTexture.clampMode, in, version );
 		NifStream( darkTexture.filterMode, in, version );
-		NifStream( darkTexture.textureSet, in, version );
+		NifStream( darkTexture.uvSet, in, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( darkTexture.ps2L, in, version );
 			NifStream( darkTexture.ps2K, in, version );
@@ -10731,7 +10731,7 @@ void NiTexturingProperty::InternalRead( istream& in, list<uint> & link_stack, un
 		link_stack.push_back( block_num );
 		NifStream( detailTexture.clampMode, in, version );
 		NifStream( detailTexture.filterMode, in, version );
-		NifStream( detailTexture.textureSet, in, version );
+		NifStream( detailTexture.uvSet, in, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( detailTexture.ps2L, in, version );
 			NifStream( detailTexture.ps2K, in, version );
@@ -10756,7 +10756,7 @@ void NiTexturingProperty::InternalRead( istream& in, list<uint> & link_stack, un
 		link_stack.push_back( block_num );
 		NifStream( glossTexture.clampMode, in, version );
 		NifStream( glossTexture.filterMode, in, version );
-		NifStream( glossTexture.textureSet, in, version );
+		NifStream( glossTexture.uvSet, in, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( glossTexture.ps2L, in, version );
 			NifStream( glossTexture.ps2K, in, version );
@@ -10781,7 +10781,7 @@ void NiTexturingProperty::InternalRead( istream& in, list<uint> & link_stack, un
 		link_stack.push_back( block_num );
 		NifStream( glowTexture.clampMode, in, version );
 		NifStream( glowTexture.filterMode, in, version );
-		NifStream( glowTexture.textureSet, in, version );
+		NifStream( glowTexture.uvSet, in, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( glowTexture.ps2L, in, version );
 			NifStream( glowTexture.ps2K, in, version );
@@ -10806,7 +10806,7 @@ void NiTexturingProperty::InternalRead( istream& in, list<uint> & link_stack, un
 		link_stack.push_back( block_num );
 		NifStream( bumpMapTexture.clampMode, in, version );
 		NifStream( bumpMapTexture.filterMode, in, version );
-		NifStream( bumpMapTexture.textureSet, in, version );
+		NifStream( bumpMapTexture.uvSet, in, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( bumpMapTexture.ps2L, in, version );
 			NifStream( bumpMapTexture.ps2K, in, version );
@@ -10834,7 +10834,7 @@ void NiTexturingProperty::InternalRead( istream& in, list<uint> & link_stack, un
 		link_stack.push_back( block_num );
 		NifStream( decal0Texture.clampMode, in, version );
 		NifStream( decal0Texture.filterMode, in, version );
-		NifStream( decal0Texture.textureSet, in, version );
+		NifStream( decal0Texture.uvSet, in, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( decal0Texture.ps2L, in, version );
 			NifStream( decal0Texture.ps2K, in, version );
@@ -10861,7 +10861,7 @@ void NiTexturingProperty::InternalRead( istream& in, list<uint> & link_stack, un
 		link_stack.push_back( block_num );
 		NifStream( decal1Texture.clampMode, in, version );
 		NifStream( decal1Texture.filterMode, in, version );
-		NifStream( decal1Texture.textureSet, in, version );
+		NifStream( decal1Texture.uvSet, in, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( decal1Texture.ps2L, in, version );
 			NifStream( decal1Texture.ps2K, in, version );
@@ -10890,7 +10890,7 @@ void NiTexturingProperty::InternalRead( istream& in, list<uint> & link_stack, un
 				link_stack.push_back( block_num );
 				NifStream( shaderTextures[i2].textureData.clampMode, in, version );
 				NifStream( shaderTextures[i2].textureData.filterMode, in, version );
-				NifStream( shaderTextures[i2].textureData.textureSet, in, version );
+				NifStream( shaderTextures[i2].textureData.uvSet, in, version );
 				if ( version <= 0x0A020000 ) {
 					NifStream( shaderTextures[i2].textureData.ps2L, in, version );
 					NifStream( shaderTextures[i2].textureData.ps2K, in, version );
@@ -10930,7 +10930,7 @@ void NiTexturingProperty::InternalWrite( ostream& out, map<NiObjectRef,uint> lin
 			NifStream( 0xffffffff, out, version );
 		NifStream( baseTexture.clampMode, out, version );
 		NifStream( baseTexture.filterMode, out, version );
-		NifStream( baseTexture.textureSet, out, version );
+		NifStream( baseTexture.uvSet, out, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( baseTexture.ps2L, out, version );
 			NifStream( baseTexture.ps2K, out, version );
@@ -10957,7 +10957,7 @@ void NiTexturingProperty::InternalWrite( ostream& out, map<NiObjectRef,uint> lin
 			NifStream( 0xffffffff, out, version );
 		NifStream( darkTexture.clampMode, out, version );
 		NifStream( darkTexture.filterMode, out, version );
-		NifStream( darkTexture.textureSet, out, version );
+		NifStream( darkTexture.uvSet, out, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( darkTexture.ps2L, out, version );
 			NifStream( darkTexture.ps2K, out, version );
@@ -10984,7 +10984,7 @@ void NiTexturingProperty::InternalWrite( ostream& out, map<NiObjectRef,uint> lin
 			NifStream( 0xffffffff, out, version );
 		NifStream( detailTexture.clampMode, out, version );
 		NifStream( detailTexture.filterMode, out, version );
-		NifStream( detailTexture.textureSet, out, version );
+		NifStream( detailTexture.uvSet, out, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( detailTexture.ps2L, out, version );
 			NifStream( detailTexture.ps2K, out, version );
@@ -11011,7 +11011,7 @@ void NiTexturingProperty::InternalWrite( ostream& out, map<NiObjectRef,uint> lin
 			NifStream( 0xffffffff, out, version );
 		NifStream( glossTexture.clampMode, out, version );
 		NifStream( glossTexture.filterMode, out, version );
-		NifStream( glossTexture.textureSet, out, version );
+		NifStream( glossTexture.uvSet, out, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( glossTexture.ps2L, out, version );
 			NifStream( glossTexture.ps2K, out, version );
@@ -11038,7 +11038,7 @@ void NiTexturingProperty::InternalWrite( ostream& out, map<NiObjectRef,uint> lin
 			NifStream( 0xffffffff, out, version );
 		NifStream( glowTexture.clampMode, out, version );
 		NifStream( glowTexture.filterMode, out, version );
-		NifStream( glowTexture.textureSet, out, version );
+		NifStream( glowTexture.uvSet, out, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( glowTexture.ps2L, out, version );
 			NifStream( glowTexture.ps2K, out, version );
@@ -11065,7 +11065,7 @@ void NiTexturingProperty::InternalWrite( ostream& out, map<NiObjectRef,uint> lin
 			NifStream( 0xffffffff, out, version );
 		NifStream( bumpMapTexture.clampMode, out, version );
 		NifStream( bumpMapTexture.filterMode, out, version );
-		NifStream( bumpMapTexture.textureSet, out, version );
+		NifStream( bumpMapTexture.uvSet, out, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( bumpMapTexture.ps2L, out, version );
 			NifStream( bumpMapTexture.ps2K, out, version );
@@ -11095,7 +11095,7 @@ void NiTexturingProperty::InternalWrite( ostream& out, map<NiObjectRef,uint> lin
 			NifStream( 0xffffffff, out, version );
 		NifStream( decal0Texture.clampMode, out, version );
 		NifStream( decal0Texture.filterMode, out, version );
-		NifStream( decal0Texture.textureSet, out, version );
+		NifStream( decal0Texture.uvSet, out, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( decal0Texture.ps2L, out, version );
 			NifStream( decal0Texture.ps2K, out, version );
@@ -11124,7 +11124,7 @@ void NiTexturingProperty::InternalWrite( ostream& out, map<NiObjectRef,uint> lin
 			NifStream( 0xffffffff, out, version );
 		NifStream( decal1Texture.clampMode, out, version );
 		NifStream( decal1Texture.filterMode, out, version );
-		NifStream( decal1Texture.textureSet, out, version );
+		NifStream( decal1Texture.uvSet, out, version );
 		if ( version <= 0x0A020000 ) {
 			NifStream( decal1Texture.ps2L, out, version );
 			NifStream( decal1Texture.ps2K, out, version );
@@ -11154,7 +11154,7 @@ void NiTexturingProperty::InternalWrite( ostream& out, map<NiObjectRef,uint> lin
 					NifStream( 0xffffffff, out, version );
 				NifStream( shaderTextures[i2].textureData.clampMode, out, version );
 				NifStream( shaderTextures[i2].textureData.filterMode, out, version );
-				NifStream( shaderTextures[i2].textureData.textureSet, out, version );
+				NifStream( shaderTextures[i2].textureData.uvSet, out, version );
 				if ( version <= 0x0A020000 ) {
 					NifStream( shaderTextures[i2].textureData.ps2L, out, version );
 					NifStream( shaderTextures[i2].textureData.ps2K, out, version );
@@ -11190,7 +11190,7 @@ std::string NiTexturingProperty::InternalAsString( bool verbose ) const {
 		out << "    Source:  " << baseTexture.source << endl;
 		out << "    Clamp Mode:  " << baseTexture.clampMode << endl;
 		out << "    Filter Mode:  " << baseTexture.filterMode << endl;
-		out << "    Texture Set:  " << baseTexture.textureSet << endl;
+		out << "    UV Set:  " << baseTexture.uvSet << endl;
 		out << "    PS2 L:  " << baseTexture.ps2L << endl;
 		out << "    PS2 K:  " << baseTexture.ps2K << endl;
 		out << "    Unknown1:  " << baseTexture.unknown1 << endl;
@@ -11208,7 +11208,7 @@ std::string NiTexturingProperty::InternalAsString( bool verbose ) const {
 		out << "    Source:  " << darkTexture.source << endl;
 		out << "    Clamp Mode:  " << darkTexture.clampMode << endl;
 		out << "    Filter Mode:  " << darkTexture.filterMode << endl;
-		out << "    Texture Set:  " << darkTexture.textureSet << endl;
+		out << "    UV Set:  " << darkTexture.uvSet << endl;
 		out << "    PS2 L:  " << darkTexture.ps2L << endl;
 		out << "    PS2 K:  " << darkTexture.ps2K << endl;
 		out << "    Unknown1:  " << darkTexture.unknown1 << endl;
@@ -11226,7 +11226,7 @@ std::string NiTexturingProperty::InternalAsString( bool verbose ) const {
 		out << "    Source:  " << detailTexture.source << endl;
 		out << "    Clamp Mode:  " << detailTexture.clampMode << endl;
 		out << "    Filter Mode:  " << detailTexture.filterMode << endl;
-		out << "    Texture Set:  " << detailTexture.textureSet << endl;
+		out << "    UV Set:  " << detailTexture.uvSet << endl;
 		out << "    PS2 L:  " << detailTexture.ps2L << endl;
 		out << "    PS2 K:  " << detailTexture.ps2K << endl;
 		out << "    Unknown1:  " << detailTexture.unknown1 << endl;
@@ -11244,7 +11244,7 @@ std::string NiTexturingProperty::InternalAsString( bool verbose ) const {
 		out << "    Source:  " << glossTexture.source << endl;
 		out << "    Clamp Mode:  " << glossTexture.clampMode << endl;
 		out << "    Filter Mode:  " << glossTexture.filterMode << endl;
-		out << "    Texture Set:  " << glossTexture.textureSet << endl;
+		out << "    UV Set:  " << glossTexture.uvSet << endl;
 		out << "    PS2 L:  " << glossTexture.ps2L << endl;
 		out << "    PS2 K:  " << glossTexture.ps2K << endl;
 		out << "    Unknown1:  " << glossTexture.unknown1 << endl;
@@ -11262,7 +11262,7 @@ std::string NiTexturingProperty::InternalAsString( bool verbose ) const {
 		out << "    Source:  " << glowTexture.source << endl;
 		out << "    Clamp Mode:  " << glowTexture.clampMode << endl;
 		out << "    Filter Mode:  " << glowTexture.filterMode << endl;
-		out << "    Texture Set:  " << glowTexture.textureSet << endl;
+		out << "    UV Set:  " << glowTexture.uvSet << endl;
 		out << "    PS2 L:  " << glowTexture.ps2L << endl;
 		out << "    PS2 K:  " << glowTexture.ps2K << endl;
 		out << "    Unknown1:  " << glowTexture.unknown1 << endl;
@@ -11280,7 +11280,7 @@ std::string NiTexturingProperty::InternalAsString( bool verbose ) const {
 		out << "    Source:  " << bumpMapTexture.source << endl;
 		out << "    Clamp Mode:  " << bumpMapTexture.clampMode << endl;
 		out << "    Filter Mode:  " << bumpMapTexture.filterMode << endl;
-		out << "    Texture Set:  " << bumpMapTexture.textureSet << endl;
+		out << "    UV Set:  " << bumpMapTexture.uvSet << endl;
 		out << "    PS2 L:  " << bumpMapTexture.ps2L << endl;
 		out << "    PS2 K:  " << bumpMapTexture.ps2K << endl;
 		out << "    Unknown1:  " << bumpMapTexture.unknown1 << endl;
@@ -11301,7 +11301,7 @@ std::string NiTexturingProperty::InternalAsString( bool verbose ) const {
 		out << "    Source:  " << decal0Texture.source << endl;
 		out << "    Clamp Mode:  " << decal0Texture.clampMode << endl;
 		out << "    Filter Mode:  " << decal0Texture.filterMode << endl;
-		out << "    Texture Set:  " << decal0Texture.textureSet << endl;
+		out << "    UV Set:  " << decal0Texture.uvSet << endl;
 		out << "    PS2 L:  " << decal0Texture.ps2L << endl;
 		out << "    PS2 K:  " << decal0Texture.ps2K << endl;
 		out << "    Unknown1:  " << decal0Texture.unknown1 << endl;
@@ -11321,7 +11321,7 @@ std::string NiTexturingProperty::InternalAsString( bool verbose ) const {
 		out << "    Source:  " << decal1Texture.source << endl;
 		out << "    Clamp Mode:  " << decal1Texture.clampMode << endl;
 		out << "    Filter Mode:  " << decal1Texture.filterMode << endl;
-		out << "    Texture Set:  " << decal1Texture.textureSet << endl;
+		out << "    UV Set:  " << decal1Texture.uvSet << endl;
 		out << "    PS2 L:  " << decal1Texture.ps2L << endl;
 		out << "    PS2 K:  " << decal1Texture.ps2K << endl;
 		out << "    Unknown1:  " << decal1Texture.unknown1 << endl;
@@ -11341,7 +11341,7 @@ std::string NiTexturingProperty::InternalAsString( bool verbose ) const {
 			out << "      Source:  " << shaderTextures[i1].textureData.source << endl;
 			out << "      Clamp Mode:  " << shaderTextures[i1].textureData.clampMode << endl;
 			out << "      Filter Mode:  " << shaderTextures[i1].textureData.filterMode << endl;
-			out << "      Texture Set:  " << shaderTextures[i1].textureData.textureSet << endl;
+			out << "      UV Set:  " << shaderTextures[i1].textureData.uvSet << endl;
 			out << "      PS2 L:  " << shaderTextures[i1].textureData.ps2L << endl;
 			out << "      PS2 K:  " << shaderTextures[i1].textureData.ps2K << endl;
 			out << "      Unknown1:  " << shaderTextures[i1].textureData.unknown1 << endl;
diff --git a/src/obj/NiTriBasedGeom.cpp b/src/obj/NiTriBasedGeom.cpp
index 00395695..26794a9d 100644
--- a/src/obj/NiTriBasedGeom.cpp
+++ b/src/obj/NiTriBasedGeom.cpp
@@ -254,17 +254,13 @@ vector<Vector3> NiTriBasedGeom::GetSkinInfluencedVertices() const {
 	vector<Vector3> skin_verts( vertices.size());
 
 	//Transform vertices into position based on skin data
-	Matrix44 skel_root_inv = skel_root->GetWorldTransform().Inverse();
+	Matrix44 root_world = skel_root->GetWorldTransform();
 	Matrix44 geom_world = GetWorldTransform();
-	Matrix44 overall_offset = skin_data->GetOverallTransform();
-
 	for ( uint i = 0; i < skin_data->GetBoneCount(); ++i ) {
 		Matrix44 bone_world = bone_nodes[i]->GetWorldTransform();
 		Matrix44 bone_offset = skin_data->GetBoneTransform(i);
 		vector<SkinWeight> weights = skin_data->GetBoneWeights(i);
-		//Matrix44 vert_trans =  bone_offset * skel_root_inv * bone_world * overall_offset * geom_world;
-		Matrix44 vert_trans = geom_world * bone_world * skel_root_inv * overall_offset * bone_offset;
-
+		Matrix44 vert_trans =  bone_offset * bone_world;
 		for ( uint j = 0; j < weights.size(); ++j ) {
 			uint index = weights[j].index;
 			float weight = weights[j].weight;
-- 
GitLab