From 4a6a4d4cb21375c10cb29289c3b36c7f463f2ba4 Mon Sep 17 00:00:00 2001
From: Shon Ferguson <shonferg@users.sourceforge.net>
Date: Wed, 1 Nov 2006 21:17:27 +0000
Subject: [PATCH] Fixed some GCC compile problems. Changed some functions to
 use pointers instead of Ref templates. Updated to latest XML description.

---
 include/gen/Header.h                    |   2 +-
 include/gen/OblivionColFilter.h         |  38 +++++++
 include/gen/OblivionSubShape.h          |  46 ++++++++
 include/gen/enums_intl.h                |   2 +-
 include/gen/hkTriangle.h                |   3 +-
 include/gen/obj_defines.h               | 112 ++++++++++----------
 include/nif_versions.h                  |   2 +-
 include/obj/NiObjectNET.h               |   8 +-
 include/obj/NiSequenceStreamHelper.h    |   2 +-
 include/obj/bhkNiTriStripsShape.h       |   1 +
 include/obj/bhkPackedNiTriStripsShape.h |   1 +
 niflib.vcproj                           |  16 +++
 src/gen/OblivionColFilter.cpp           |  11 ++
 src/gen/OblivionSubShape.cpp            |  11 ++
 src/gen/obj_impl.cpp                    | 134 ++++++++++++------------
 src/obj/NiObjectNET.cpp                 |  22 ++--
 src/obj/bhkNiTriStripsShape.cpp         |   6 +-
 17 files changed, 274 insertions(+), 143 deletions(-)
 create mode 100644 include/gen/OblivionColFilter.h
 create mode 100644 include/gen/OblivionSubShape.h
 create mode 100644 src/gen/OblivionColFilter.cpp
 create mode 100644 src/gen/OblivionSubShape.cpp

diff --git a/include/gen/Header.h b/include/gen/Header.h
index b15e6630..dc5313c1 100644
--- a/include/gen/Header.h
+++ b/include/gen/Header.h
@@ -27,7 +27,7 @@ struct NIFLIB_API Header {
 	/*!
 	 * Unknown.
 	 */
-	array<3,LineString> copyright;
+	array<3,LineString > copyright;
 	/*!
 	 * The NIF version, in hexadecimal notation: 0x04000002, 0x0401000C,
 	 * 0x04020002, 0x04020100, 0x04020200, 0x0A000100, 0x0A010000,
diff --git a/include/gen/OblivionColFilter.h b/include/gen/OblivionColFilter.h
new file mode 100644
index 00000000..79721a8d
--- /dev/null
+++ b/include/gen/OblivionColFilter.h
@@ -0,0 +1,38 @@
+/* Copyright (c) 2006, NIF File Format Library and Tools
+All rights reserved.  Please see niflib.h for licence. */
+
+#ifndef _OBLIVIONCOLFILTER_H_
+#define _OBLIVIONCOLFILTER_H_
+
+#include "../NIF_IO.h"
+
+namespace Niflib {
+
+
+/*!
+ * Oblivion's ColFilter property for Havok.
+ */
+struct NIFLIB_API OblivionColFilter {
+	/*! Default Constructor */
+	OblivionColFilter();
+	/*! Default Destructor */
+	~OblivionColFilter();
+	/*!
+	 * Sets mesh color in Oblivion Construction Set.
+	 */
+	OblivionLayer layer;
+	/*!
+	 * The first bit sets the LINK property and controls whether this body is
+	 * physically linked to others. The next bit turns collision off. Then,
+	 * the next bit sets the SCALED property in Oblivion. The next five bits
+	 * make up the number of this part in a linked body list.
+	 */
+	byte colFilter;
+	/*!
+	 * Unknown.
+	 */
+	ushort unknownShort;
+};
+
+}
+#endif
diff --git a/include/gen/OblivionSubShape.h b/include/gen/OblivionSubShape.h
new file mode 100644
index 00000000..c9a1653d
--- /dev/null
+++ b/include/gen/OblivionSubShape.h
@@ -0,0 +1,46 @@
+/* Copyright (c) 2006, NIF File Format Library and Tools
+All rights reserved.  Please see niflib.h for licence. */
+
+#ifndef _OBLIVIONSUBSHAPE_H_
+#define _OBLIVIONSUBSHAPE_H_
+
+#include "../NIF_IO.h"
+
+namespace Niflib {
+
+
+/*!
+ * Havok Information for packed TriStrip shapes.
+ */
+struct NIFLIB_API OblivionSubShape {
+	/*! Default Constructor */
+	OblivionSubShape();
+	/*! Default Destructor */
+	~OblivionSubShape();
+	/*!
+	 * Sets mesh color in Oblivion Construction Set.
+	 */
+	OblivionLayer layer;
+	/*!
+	 * The first bit sets the LINK property and controls whether this body is
+	 * physically linked to others. The next bit turns collision off. Then,
+	 * the next bit sets the SCALED property in Oblivion. The next five bits
+	 * make up the number of this part in a linked body list.
+	 */
+	byte colFilter;
+	/*!
+	 * Unknown.
+	 */
+	ushort unknownShort;
+	/*!
+	 * Seems to be the number of vertices that form this sub shape.
+	 */
+	uint vertexCount___;
+	/*!
+	 * The material of the subshape.
+	 */
+	HavokMaterial material;
+};
+
+}
+#endif
diff --git a/include/gen/enums_intl.h b/include/gen/enums_intl.h
index 8911b05c..50ac344d 100644
--- a/include/gen/enums_intl.h
+++ b/include/gen/enums_intl.h
@@ -6,7 +6,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include <iostream>
 using namespace std;
 
-#include "nif_basic_types.h"
+#include "../nif_basic_types.h"
 
 namespace Niflib {
 
diff --git a/include/gen/hkTriangle.h b/include/gen/hkTriangle.h
index 0946ce75..3e3e60a8 100644
--- a/include/gen/hkTriangle.h
+++ b/include/gen/hkTriangle.h
@@ -26,8 +26,7 @@ struct NIFLIB_API hkTriangle {
 	 */
 	ushort unknownShort;
 	/*!
-	 * This appears to be a normalized vector, so probably it is a normal or
-	 * a tangent vector or something like that.
+	 * This is the triangle's normal.
 	 */
 	Vector3 normal;
 };
diff --git a/include/gen/obj_defines.h b/include/gen/obj_defines.h
index 25efbaf6..552098f6 100644
--- a/include/gen/obj_defines.h
+++ b/include/gen/obj_defines.h
@@ -194,7 +194,7 @@ ushort unknownShort3; \
 bool hasUnknownFloats2; \
 vector<float > unknownFloats2; \
 byte hasUnknownFloats3; \
-vector< array<4,float> > unknownFloats3; \
+vector< array<4,float > > unknownFloats3; \
 
 #define BHK_BLEND_COLLISION_OBJECT_MEMBERS \
 float unknownFloat1; \
@@ -210,7 +210,7 @@ ushort unknownShort2; \
 ushort unknownShort3; \
 ushort unknownShort4; \
 Vector3 dimensions; \
-float unknownFloat2; \
+float min_Size; \
 
 #define BHK_CAPSULE_SHAPE_MEMBERS \
 float radius; \
@@ -226,14 +226,14 @@ float radius2; \
 #define BHK_COLLISION_OBJECT_MEMBERS \
 
 #define BHK_CONVEX_VERTICES_SHAPE_MEMBERS \
-array<7,float> unknownFloats1; \
-mutable uint num1; \
-vector<Float4 > unknownVectors1; \
-mutable uint num2; \
-vector<Float4 > unknownVectors2; \
+array<7,float > unknownFloats1; \
+mutable uint numVertices; \
+vector<Float4 > vertices; \
+mutable uint numNormals; \
+vector<Float4 > normals; \
 
 #define BHK_HINGE_CONSTRAINT_MEMBERS \
-array< 5, array<4,float> > unknownFloats; \
+array< 5, array<4,float > > unknownFloats; \
 
 #define BHK_LIMITED_HINGE_CONSTRAINT_MEMBERS \
 LimitedHingeDescriptor limitedHinge; \
@@ -242,7 +242,7 @@ LimitedHingeDescriptor limitedHinge; \
 mutable uint numSubShapes; \
 vector<Ref<bhkShape > > subShapes; \
 HavokMaterial material; \
-array<6,float> unknownFloats; \
+array<6,float > unknownFloats; \
 mutable uint numUnknownInts; \
 vector<uint > unknownInts; \
 
@@ -260,7 +260,7 @@ float damping; \
 #define BHK_MOPP_BV_TREE_SHAPE_MEMBERS \
 Ref<bhkShape > shape; \
 HavokMaterial material; \
-array<8,byte> unknownBytes1; \
+array<8,byte > unknownBytes1; \
 float unknownFloat; \
 mutable uint numUnknownBytes2; \
 vector<byte > unknownBytes2; \
@@ -277,35 +277,35 @@ vector<Sphere > spheres; \
 #define BHK_NI_TRI_STRIPS_SHAPE_MEMBERS \
 float unknownFloat1; \
 uint unknownInt1; \
-array<4,uint> unknownInts1; \
+array<4,uint > unknownInts1; \
 uint unknownInt2; \
 Vector3 scale; \
 uint unknownInt3; \
 mutable uint numStripsData; \
 vector<Ref<NiTriStripsData > > stripsData; \
-mutable uint numUnknownInts2; \
-vector<uint > unknownInts2; \
+mutable uint numDataLayers; \
+vector<OblivionColFilter > dataLayers; \
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_MEMBERS \
-mutable ushort numSubparts; \
-vector< array<3,uint> > subparts; \
-array<9,float> unknownFloats; \
+mutable ushort numSubShapes; \
+vector<OblivionSubShape > subShapes; \
+array<9,float > unknownFloats; \
 float scale; \
-array<3,float> unknownFloats2; \
+array<3,float > unknownFloats2; \
 Ref<hkPackedNiTriStripsData > data; \
 
 #define BHK_PRISMATIC_CONSTRAINT_MEMBERS \
-array<8,Float4> unknownVectors; \
-array<3,float> unknownFloats2; \
+array<8,Float4 > unknownVectors; \
+array<3,float > unknownFloats2; \
 
 #define BHK_RAGDOLL_CONSTRAINT_MEMBERS \
 
 #define BHK_RIGID_BODY_MEMBERS \
-array<5,float> unknown5Floats; \
-array<4,ushort> unknown4Shorts; \
+array<5,float > unknown5Floats; \
+array<4,ushort > unknown4Shorts; \
 OblivionLayer layerCopy; \
 byte colFilterCopy; \
-array<7,ushort> unknown7Shorts; \
+array<7,ushort > unknown7Shorts; \
 Vector3 translation; \
 float unknownFloat00; \
 QuaternionXYZW rotation; \
@@ -313,7 +313,7 @@ Vector3 linearVelocity; \
 float unknownFloat01; \
 Vector3 angularVelocity; \
 float unknownFloat02; \
-array<12,float> transform; \
+array<12,float > transform; \
 Vector3 center; \
 float unknownFloat03; \
 float mass; \
@@ -337,8 +337,8 @@ vector<Ref<AbhkConstraint > > constraints; \
 #define BHK_RIGID_BODY_T_MEMBERS \
 
 #define BHK_SIMPLE_SHAPE_PHANTOM_MEMBERS \
-array<7,float> unkownFloats; \
-array< 3, array<5,float> > unknownFloats2; \
+array<7,float > unkownFloats; \
+array< 3, array<5,float > > unknownFloats2; \
 float unknownFloat; \
 
 #define BHK_S_P_COLLISION_OBJECT_MEMBERS \
@@ -347,7 +347,7 @@ float unknownFloat; \
 float radius; \
 
 #define BHK_STIFF_SPRING_CONSTRAINT_MEMBERS \
-array< 2, array<4,float> > unknownFloats; \
+array< 2, array<4,float > > unknownFloats; \
 float unknownFloat; \
 
 #define BHK_TRANSFORM_SHAPE_MEMBERS \
@@ -437,10 +437,10 @@ Ref<NiBoolData > data; \
 uint numControlPt; \
 
 #define NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_MEMBERS \
-array<4,float> unknownFloats; \
+array<4,float > unknownFloats; \
 
 #define NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_MEMBERS \
-array<6,float> unknownFloats; \
+array<6,float > unknownFloats; \
 
 #define NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_MEMBERS \
 Vector3 translation; \
@@ -486,8 +486,8 @@ uint unknownInt2; \
 byte unknownByte; \
 uint collisionType; \
 Vector3 unknownVector; \
-array<8,float> unknownFloat1; \
-array<15,float> unknownFloat2; \
+array<8,float > unknownFloat1; \
+array<15,float > unknownFloat2; \
 
 #define NI_COLOR_DATA_MEMBERS \
 KeyGroup<Color4 > data; \
@@ -595,7 +595,7 @@ mutable uint numRotationKeys; \
 KeyType rotationType; \
 vector<Key<Quaternion > > quaternionKeys; \
 float unknownFloat; \
-array<3,KeyGroup<float >> xyzRotations; \
+array<3,KeyGroup<float > > xyzRotations; \
 KeyGroup<Vector3 > translations; \
 KeyGroup<float > scales; \
 
@@ -637,8 +637,8 @@ float alpha; \
 
 #define NI_MESH_P_SYS_DATA_MEMBERS \
 byte unknownByte11; \
-vector< array<10,float> > unknownFloats4; \
-vector< array<12,float> > unknownFloats5; \
+vector< array<10,float > > unknownFloats4; \
+vector< array<12,float > > unknownFloats5; \
 uint unknownInt1; \
 Ref<NiObject > modifier; \
 byte unknownByte2; \
@@ -671,7 +671,7 @@ vector<Ref<NiDynamicEffect > > effects; \
 
 #define FX_WIDGET_MEMBERS \
 byte unknown1; \
-array<292,byte> unknown292Bytes; \
+array<292,byte > unknown292Bytes; \
 
 #define FX_BUTTON_MEMBERS \
 
@@ -690,7 +690,7 @@ BillboardMode billboardMode; \
 #define NI_B_S_PARTICLE_NODE_MEMBERS \
 
 #define NI_L_O_D_NODE_MEMBERS \
-array<4,byte> unknown4Bytes; \
+array<4,byte > unknown4Bytes; \
 Vector3 lodCenter; \
 mutable uint numLodLevels; \
 vector<LODRange > lodLevels; \
@@ -700,7 +700,7 @@ Ref<NiLODData > lodLevelData; \
 #define NI_PALETTE_MEMBERS \
 byte unknownByte; \
 uint numEntries_; \
-array< 256, array<4,byte> > palette; \
+array< 256, array<4,byte > > palette; \
 
 #define NI_PARTICLE_BOMB_MEMBERS \
 float unknownFloat1; \
@@ -819,9 +819,9 @@ uint greenMask; \
 uint blueMask; \
 uint alphaMask; \
 uint bitsPerPixel; \
-array<8,byte> unknown8Bytes; \
+array<8,byte > unknown8Bytes; \
 uint unknownInt; \
-array<54,byte> unknown54Bytes; \
+array<54,byte > unknown54Bytes; \
 Ref<NiPalette > palette; \
 mutable uint numMipmaps; \
 uint bytesPerPixel; \
@@ -867,9 +867,9 @@ Ref<NiPSysSpawnModifier > spawnModifier; \
 
 #define NI_P_SYS_BOMB_MODIFIER_MEMBERS \
 NiNode * unknownLink; \
-array<2,uint> unknownInts1; \
-array<3,float> unknownFloats; \
-array<2,uint> unknownInts2; \
+array<2,uint > unknownInts1; \
+array<3,float > unknownFloats; \
+array<2,uint > unknownInts2; \
 
 #define NI_P_SYS_BOUND_UPDATE_MODIFIER_MEMBERS \
 ushort updateSkip; \
@@ -890,13 +890,13 @@ float radius; \
 float height; \
 
 #define NI_P_SYS_DATA_MEMBERS \
-vector< array<10,float> > unknownFloats4; \
+vector< array<10,float > > unknownFloats4; \
 bool unknownBool1; \
-vector< array<32,byte> > unknownBytes; \
-vector< array<28,byte> > unknownBytesAlt; \
+vector< array<32,byte > > unknownBytes; \
+vector< array<28,byte > > unknownBytesAlt; \
 byte unknownByte3; \
 bool unknownBool2; \
-vector< array<4,byte> > unknownBytes2; \
+vector< array<4,byte > > unknownBytes2; \
 uint unknownInt1; \
 
 #define NI_P_SYS_DRAG_MODIFIER_MEMBERS \
@@ -1123,12 +1123,12 @@ uint operation; \
 Ref<NiFloatData > data; \
 
 #define NI_TEXTURE_MODE_PROPERTY_MEMBERS \
-array<3,short> unknown3Shorts; \
+array<3,short > unknown3Shorts; \
 
 #define NI_IMAGE_MEMBERS \
 byte external_; \
 string file; \
-array<4,short> unknown4Shorts; \
+array<4,short > unknown4Shorts; \
 
 #define NI_TEXTURE_PROPERTY_MEMBERS \
 ushort flags; \
@@ -1172,7 +1172,7 @@ vector<ShaderTexDesc > shaderTextures; \
 Vector3 translation; \
 Quaternion rotation; \
 float scale; \
-array<3,byte> unknownBytes; \
+array<3,byte > unknownBytes; \
 Ref<NiTransformData > data; \
 
 #define NI_TRI_SHAPE_MEMBERS \
@@ -1201,16 +1201,16 @@ mutable ushort unknownCount2; \
 mutable ushort unknownCount3; \
 float unknownFloat; \
 ushort unknownShort; \
-vector< array<6,ushort> > unknownClodShorts1; \
+vector< array<6,ushort > > unknownClodShorts1; \
 vector<ushort > unknownClodShorts2; \
-vector< array<6,ushort> > unknownClodShorts3; \
+vector< array<6,ushort > > unknownClodShorts3; \
 
 #define NI_U_V_CONTROLLER_MEMBERS \
 ushort unknownShort; \
 Ref<NiUVData > data; \
 
 #define NI_U_V_DATA_MEMBERS \
-array<4,KeyGroup<float >> uvGroups; \
+array<4,KeyGroup<float > > uvGroups; \
 
 #define NI_VECTOR_EXTRA_DATA_MEMBERS \
 Vector3 vectorData; \
@@ -1679,7 +1679,7 @@ CompareMode function; \
 
 #define BHK_BOX_SHAPE_PARENT bhkConvexShape
 
-#define BHK_BOX_SHAPE_CONSTRUCT  : unknownFloat1(0.0f), unknownShort1((ushort)0), unknownShort2((ushort)0), unknownShort3((ushort)0), unknownShort4((ushort)0), unknownFloat2(0.0f)
+#define BHK_BOX_SHAPE_CONSTRUCT  : unknownFloat1(0.0f), unknownShort1((ushort)0), unknownShort2((ushort)0), unknownShort3((ushort)0), unknownShort4((ushort)0), min_Size(0.0f)
 
 #define BHK_CAPSULE_SHAPE_INCLUDE "bhkConvexShape.h"
 
@@ -1696,7 +1696,7 @@ CompareMode function; \
 
 #define BHK_CONVEX_VERTICES_SHAPE_PARENT bhkSphereRepShape
 
-#define BHK_CONVEX_VERTICES_SHAPE_CONSTRUCT  : num1((uint)0), num2((uint)0)
+#define BHK_CONVEX_VERTICES_SHAPE_CONSTRUCT  : numVertices((uint)0), numNormals((uint)0)
 
 #define BHK_HINGE_CONSTRAINT_INCLUDE "AbhkConstraint.h"
 
@@ -1736,13 +1736,13 @@ CompareMode function; \
 
 #define BHK_NI_TRI_STRIPS_SHAPE_PARENT bhkSphereRepShape
 
-#define BHK_NI_TRI_STRIPS_SHAPE_CONSTRUCT  : unknownFloat1(0.1f), unknownInt1((uint)0x004ABE60), unknownInt2((uint)1), scale(1.0f, 1.0f, 1.0f), unknownInt3((uint)0), numStripsData((uint)0), numUnknownInts2((uint)0)
+#define BHK_NI_TRI_STRIPS_SHAPE_CONSTRUCT  : unknownFloat1(0.1f), unknownInt1((uint)0x004ABE60), unknownInt2((uint)1), scale(1.0f, 1.0f, 1.0f), unknownInt3((uint)0), numStripsData((uint)0), numDataLayers((uint)0)
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_INCLUDE "AbhkShapeCollection.h"
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_PARENT AbhkShapeCollection
 
-#define BHK_PACKED_NI_TRI_STRIPS_SHAPE_CONSTRUCT  : numSubparts((ushort)0), scale(1.0f), data(NULL)
+#define BHK_PACKED_NI_TRI_STRIPS_SHAPE_CONSTRUCT  : numSubShapes((ushort)0), scale(1.0f), data(NULL)
 
 #define BHK_PRISMATIC_CONSTRAINT_INCLUDE "AbhkConstraint.h"
 
@@ -2541,7 +2541,7 @@ CompareMode function; \
 
 #define NI_SOURCE_TEXTURE_PARENT NiObjectNET
 
-#define NI_SOURCE_TEXTURE_CONSTRUCT  : useExternal((byte)1), unknownLink(NULL), unknownByte((byte)1), pixelData(NULL), pixelLayout((PixelLayout)5), useMipmaps((MipMapFormat)2), alphaFormat((AlphaFormat)3), unknownByte2((byte)1)
+#define NI_SOURCE_TEXTURE_CONSTRUCT  : useExternal((byte)1), unknownLink(NULL), unknownByte((byte)0), pixelData(NULL), pixelLayout((PixelLayout)5), useMipmaps((MipMapFormat)2), alphaFormat((AlphaFormat)3), unknownByte2((byte)1)
 
 #define NI_SPECULAR_PROPERTY_INCLUDE "NiProperty.h"
 
diff --git a/include/nif_versions.h b/include/nif_versions.h
index 4abb0ff4..a37724b2 100644
--- a/include/nif_versions.h
+++ b/include/nif_versions.h
@@ -23,4 +23,4 @@ const unsigned VER_20_0_0_5    = 0x14000005; /*!< NIF Version 20.0.0.4 */
 const unsigned VER_UNSUPPORTED = 0xFFFFFFFF; /*!< Unsupported NIF Version */
 const unsigned VER_INVALID     = 0xFFFFFFFE; /*!< Not a NIF file */
 
-#endif
\ No newline at end of file
+#endif
diff --git a/include/obj/NiObjectNET.h b/include/obj/NiObjectNET.h
index f3f4d45f..75d1d1e9 100644
--- a/include/obj/NiObjectNET.h
+++ b/include/obj/NiObjectNET.h
@@ -48,14 +48,14 @@ public:
 	 */
 	virtual string GetIDString();
 
-	void AddExtraData( Ref<NiExtraData> & obj, uint version = VER_10_0_1_0 );
-	void RemoveExtraData( Ref<NiExtraData> obj );
+	void AddExtraData( NiExtraData * obj, unsigned version = VER_10_0_1_0 );
+	void RemoveExtraData( NiExtraData * obj );
 	void ShiftExtraData( uint version = VER_10_0_1_0 );
 	void ClearExtraData();
 	list< Ref<NiExtraData> > GetExtraData() const;
 
-	void AddController( Ref<NiTimeController> & obj );
-	void RemoveController( Ref<NiTimeController> obj );
+	void AddController( NiTimeController * obj );
+	void RemoveController( NiTimeController * obj );
 	void ClearControllers();
 	list< Ref<NiTimeController> > GetControllers() const;
 
diff --git a/include/obj/NiSequenceStreamHelper.h b/include/obj/NiSequenceStreamHelper.h
index a1ed0391..172a5650 100644
--- a/include/obj/NiSequenceStreamHelper.h
+++ b/include/obj/NiSequenceStreamHelper.h
@@ -16,7 +16,7 @@ typedef Ref<NiSequenceStreamHelper> NiSequenceStreamHelperRef;
  * NiSequenceStreamHelper - Keyframe animation root node, in .kf files.
  */
 
-class NIFLIB_API NiSequenceStreamHelper : public NI_SEQUENCE_STREAM_HELPER_PARENT {
+class NiSequenceStreamHelper : public NI_SEQUENCE_STREAM_HELPER_PARENT {
 public:
 	NiSequenceStreamHelper();
 	~NiSequenceStreamHelper();
diff --git a/include/obj/bhkNiTriStripsShape.h b/include/obj/bhkNiTriStripsShape.h
index 4d61396b..e6715fb4 100644
--- a/include/obj/bhkNiTriStripsShape.h
+++ b/include/obj/bhkNiTriStripsShape.h
@@ -8,6 +8,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "../Ref.h"
+#include "../gen/OblivionColFilter.h"
 namespace Niflib {
 
 // Forward define of referenced blocks
diff --git a/include/obj/bhkPackedNiTriStripsShape.h b/include/obj/bhkPackedNiTriStripsShape.h
index 2f660c4e..4f2d258f 100644
--- a/include/obj/bhkPackedNiTriStripsShape.h
+++ b/include/obj/bhkPackedNiTriStripsShape.h
@@ -8,6 +8,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "../Ref.h"
+#include "../gen/OblivionSubShape.h"
 namespace Niflib {
 
 // Forward define of referenced blocks
diff --git a/niflib.vcproj b/niflib.vcproj
index 5da87071..0428d854 100644
--- a/niflib.vcproj
+++ b/niflib.vcproj
@@ -1474,6 +1474,14 @@
 					RelativePath=".\src\gen\obj_impl.cpp"
 					>
 				</File>
+				<File
+					RelativePath=".\src\gen\OblivionColFilter.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\src\gen\OblivionSubShape.cpp"
+					>
+				</File>
 				<File
 					RelativePath=".\src\gen\Particle.cpp"
 					>
@@ -2584,6 +2592,14 @@
 					RelativePath=".\include\gen\obj_defines.h"
 					>
 				</File>
+				<File
+					RelativePath=".\include\gen\OblivionColFilter.h"
+					>
+				</File>
+				<File
+					RelativePath=".\include\gen\OblivionSubShape.h"
+					>
+				</File>
 				<File
 					RelativePath=".\include\gen\Particle.h"
 					>
diff --git a/src/gen/OblivionColFilter.cpp b/src/gen/OblivionColFilter.cpp
new file mode 100644
index 00000000..54086730
--- /dev/null
+++ b/src/gen/OblivionColFilter.cpp
@@ -0,0 +1,11 @@
+/* Copyright (c) 2006, NIF File Format Library and Tools
+All rights reserved.  Please see niflib.h for licence. */
+
+#include "../../include/gen/OblivionColFilter.h"
+using namespace Niflib;
+
+//Constructor
+OblivionColFilter::OblivionColFilter() : colFilter((byte)0), unknownShort((ushort)0) {};
+
+//Destructor
+OblivionColFilter::~OblivionColFilter() {};
diff --git a/src/gen/OblivionSubShape.cpp b/src/gen/OblivionSubShape.cpp
new file mode 100644
index 00000000..ee78161f
--- /dev/null
+++ b/src/gen/OblivionSubShape.cpp
@@ -0,0 +1,11 @@
+/* Copyright (c) 2006, NIF File Format Library and Tools
+All rights reserved.  Please see niflib.h for licence. */
+
+#include "../../include/gen/OblivionSubShape.h"
+using namespace Niflib;
+
+//Constructor
+OblivionSubShape::OblivionSubShape() : colFilter((byte)0), unknownShort((ushort)0), vertexCount___((uint)0) {};
+
+//Destructor
+OblivionSubShape::~OblivionSubShape() {};
diff --git a/src/gen/obj_impl.cpp b/src/gen/obj_impl.cpp
index 20e09110..355fd2ba 100644
--- a/src/gen/obj_impl.cpp
+++ b/src/gen/obj_impl.cpp
@@ -2211,7 +2211,7 @@ void bhkBoxShape::InternalRead( istream& in, list<uint> & link_stack, unsigned i
 	NifStream( unknownShort3, in, version );
 	NifStream( unknownShort4, in, version );
 	NifStream( dimensions, in, version );
-	NifStream( unknownFloat2, in, version );
+	NifStream( min_Size, in, version );
 }
 
 void bhkBoxShape::InternalWrite( ostream& out, const map<NiObjectRef,uint> & link_map, unsigned int version, unsigned int user_version ) const {
@@ -2222,7 +2222,7 @@ void bhkBoxShape::InternalWrite( ostream& out, const map<NiObjectRef,uint> & lin
 	NifStream( unknownShort3, out, version );
 	NifStream( unknownShort4, out, version );
 	NifStream( dimensions, out, version );
-	NifStream( unknownFloat2, out, version );
+	NifStream( min_Size, out, version );
 }
 
 std::string bhkBoxShape::InternalAsString( bool verbose ) const {
@@ -2235,7 +2235,7 @@ std::string bhkBoxShape::InternalAsString( bool verbose ) const {
 	out << "  Unknown Short 3:  " << unknownShort3 << endl;
 	out << "  Unknown Short 4:  " << unknownShort4 << endl;
 	out << "  Dimensions:  " << dimensions << endl;
-	out << "  Unknown Float 2:  " << unknownFloat2 << endl;
+	out << "  Min. size:  " << min_Size << endl;
 	return out.str();
 }
 
@@ -2331,32 +2331,32 @@ void bhkConvexVerticesShape::InternalRead( istream& in, list<uint> & link_stack,
 	for (uint i1 = 0; i1 < 7; i1++) {
 		NifStream( unknownFloats1[i1], in, version );
 	};
-	NifStream( num1, in, version );
-	unknownVectors1.resize(num1);
-	for (uint i1 = 0; i1 < unknownVectors1.size(); i1++) {
-		NifStream( unknownVectors1[i1], in, version );
+	NifStream( numVertices, in, version );
+	vertices.resize(numVertices);
+	for (uint i1 = 0; i1 < vertices.size(); i1++) {
+		NifStream( vertices[i1], in, version );
 	};
-	NifStream( num2, in, version );
-	unknownVectors2.resize(num2);
-	for (uint i1 = 0; i1 < unknownVectors2.size(); i1++) {
-		NifStream( unknownVectors2[i1], in, version );
+	NifStream( numNormals, in, version );
+	normals.resize(numNormals);
+	for (uint i1 = 0; i1 < normals.size(); i1++) {
+		NifStream( normals[i1], in, version );
 	};
 }
 
 void bhkConvexVerticesShape::InternalWrite( ostream& out, const map<NiObjectRef,uint> & link_map, unsigned int version, unsigned int user_version ) const {
 	bhkSphereRepShape::Write( out, link_map, version, user_version );
-	num2 = uint(unknownVectors2.size());
-	num1 = uint(unknownVectors1.size());
+	numNormals = uint(normals.size());
+	numVertices = uint(vertices.size());
 	for (uint i1 = 0; i1 < 7; i1++) {
 		NifStream( unknownFloats1[i1], out, version );
 	};
-	NifStream( num1, out, version );
-	for (uint i1 = 0; i1 < unknownVectors1.size(); i1++) {
-		NifStream( unknownVectors1[i1], out, version );
+	NifStream( numVertices, out, version );
+	for (uint i1 = 0; i1 < vertices.size(); i1++) {
+		NifStream( vertices[i1], out, version );
 	};
-	NifStream( num2, out, version );
-	for (uint i1 = 0; i1 < unknownVectors2.size(); i1++) {
-		NifStream( unknownVectors2[i1], out, version );
+	NifStream( numNormals, out, version );
+	for (uint i1 = 0; i1 < normals.size(); i1++) {
+		NifStream( normals[i1], out, version );
 	};
 }
 
@@ -2364,8 +2364,8 @@ std::string bhkConvexVerticesShape::InternalAsString( bool verbose ) const {
 	stringstream out;
 	uint array_output_count = 0;
 	out << bhkSphereRepShape::asString();
-	num2 = uint(unknownVectors2.size());
-	num1 = uint(unknownVectors1.size());
+	numNormals = uint(normals.size());
+	numVertices = uint(vertices.size());
 	array_output_count = 0;
 	for (uint i1 = 0; i1 < 7; i1++) {
 		if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
@@ -2378,9 +2378,9 @@ std::string bhkConvexVerticesShape::InternalAsString( bool verbose ) const {
 		out << "    Unknown Floats 1[" << i1 << "]:  " << unknownFloats1[i1] << endl;
 		array_output_count++;
 	};
-	out << "  Num 1:  " << num1 << endl;
+	out << "  Num Vertices:  " << numVertices << endl;
 	array_output_count = 0;
-	for (uint i1 = 0; i1 < unknownVectors1.size(); i1++) {
+	for (uint i1 = 0; i1 < vertices.size(); i1++) {
 		if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
 			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl;
 			break;
@@ -2388,12 +2388,12 @@ std::string bhkConvexVerticesShape::InternalAsString( bool verbose ) const {
 		if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
 			break;
 		};
-		out << "    Unknown Vectors 1[" << i1 << "]:  " << unknownVectors1[i1] << endl;
+		out << "    Vertices[" << i1 << "]:  " << vertices[i1] << endl;
 		array_output_count++;
 	};
-	out << "  Num 2:  " << num2 << endl;
+	out << "  Num Normals:  " << numNormals << endl;
 	array_output_count = 0;
-	for (uint i1 = 0; i1 < unknownVectors2.size(); i1++) {
+	for (uint i1 = 0; i1 < normals.size(); i1++) {
 		if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
 			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl;
 			break;
@@ -2401,7 +2401,7 @@ std::string bhkConvexVerticesShape::InternalAsString( bool verbose ) const {
 		if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
 			break;
 		};
-		out << "    Unknown Vectors 2[" << i1 << "]:  " << unknownVectors2[i1] << endl;
+		out << "    Normals[" << i1 << "]:  " << normals[i1] << endl;
 		array_output_count++;
 	};
 	return out.str();
@@ -2930,16 +2930,18 @@ void bhkNiTriStripsShape::InternalRead( istream& in, list<uint> & link_stack, un
 		NifStream( block_num, in, version );
 		link_stack.push_back( block_num );
 	};
-	NifStream( numUnknownInts2, in, version );
-	unknownInts2.resize(numUnknownInts2);
-	for (uint i1 = 0; i1 < unknownInts2.size(); i1++) {
-		NifStream( unknownInts2[i1], in, version );
+	NifStream( numDataLayers, in, version );
+	dataLayers.resize(numDataLayers);
+	for (uint i1 = 0; i1 < dataLayers.size(); i1++) {
+		NifStream( dataLayers[i1].layer, in, version );
+		NifStream( dataLayers[i1].colFilter, in, version );
+		NifStream( dataLayers[i1].unknownShort, in, version );
 	};
 }
 
 void bhkNiTriStripsShape::InternalWrite( ostream& out, const map<NiObjectRef,uint> & link_map, unsigned int version, unsigned int user_version ) const {
 	bhkSphereRepShape::Write( out, link_map, version, user_version );
-	numUnknownInts2 = uint(unknownInts2.size());
+	numDataLayers = uint(dataLayers.size());
 	numStripsData = uint(stripsData.size());
 	NifStream( unknownFloat1, out, version );
 	NifStream( unknownInt1, out, version );
@@ -2956,9 +2958,11 @@ void bhkNiTriStripsShape::InternalWrite( ostream& out, const map<NiObjectRef,uin
 		else
 			NifStream( 0xffffffff, out, version );
 	};
-	NifStream( numUnknownInts2, out, version );
-	for (uint i1 = 0; i1 < unknownInts2.size(); i1++) {
-		NifStream( unknownInts2[i1], out, version );
+	NifStream( numDataLayers, out, version );
+	for (uint i1 = 0; i1 < dataLayers.size(); i1++) {
+		NifStream( dataLayers[i1].layer, out, version );
+		NifStream( dataLayers[i1].colFilter, out, version );
+		NifStream( dataLayers[i1].unknownShort, out, version );
 	};
 }
 
@@ -2966,7 +2970,7 @@ std::string bhkNiTriStripsShape::InternalAsString( bool verbose ) const {
 	stringstream out;
 	uint array_output_count = 0;
 	out << bhkSphereRepShape::asString();
-	numUnknownInts2 = uint(unknownInts2.size());
+	numDataLayers = uint(dataLayers.size());
 	numStripsData = uint(stripsData.size());
 	out << "  Unknown Float 1:  " << unknownFloat1 << endl;
 	out << "  Unknown Int 1:  " << unknownInt1 << endl;
@@ -2998,18 +3002,16 @@ std::string bhkNiTriStripsShape::InternalAsString( bool verbose ) const {
 		out << "    Strips Data[" << i1 << "]:  " << stripsData[i1] << endl;
 		array_output_count++;
 	};
-	out << "  Num Unknown Ints 2:  " << numUnknownInts2 << endl;
+	out << "  Num Data Layers:  " << numDataLayers << endl;
 	array_output_count = 0;
-	for (uint i1 = 0; i1 < unknownInts2.size(); i1++) {
+	for (uint i1 = 0; i1 < dataLayers.size(); i1++) {
 		if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
 			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl;
 			break;
 		};
-		if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
-			break;
-		};
-		out << "    Unknown Ints 2[" << i1 << "]:  " << unknownInts2[i1] << endl;
-		array_output_count++;
+		out << "    Layer:  " << dataLayers[i1].layer << endl;
+		out << "    Col Filter:  " << dataLayers[i1].colFilter << endl;
+		out << "    Unknown Short:  " << dataLayers[i1].unknownShort << endl;
 	};
 	return out.str();
 }
@@ -3034,12 +3036,14 @@ std::list<NiObjectRef> bhkNiTriStripsShape::InternalGetRefs() const {
 void bhkPackedNiTriStripsShape::InternalRead( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version ) {
 	uint block_num;
 	AbhkShapeCollection::Read( in, link_stack, version, user_version );
-	NifStream( numSubparts, in, version );
-	subparts.resize(numSubparts);
-	for (uint i1 = 0; i1 < subparts.size(); i1++) {
-		for (uint i2 = 0; i2 < 3; i2++) {
-			NifStream( subparts[i1][i2], in, version );
-		};
+	NifStream( numSubShapes, in, version );
+	subShapes.resize(numSubShapes);
+	for (uint i1 = 0; i1 < subShapes.size(); i1++) {
+		NifStream( subShapes[i1].layer, in, version );
+		NifStream( subShapes[i1].colFilter, in, version );
+		NifStream( subShapes[i1].unknownShort, in, version );
+		NifStream( subShapes[i1].vertexCount___, in, version );
+		NifStream( subShapes[i1].material, in, version );
 	};
 	for (uint i1 = 0; i1 < 9; i1++) {
 		NifStream( unknownFloats[i1], in, version );
@@ -3054,12 +3058,14 @@ void bhkPackedNiTriStripsShape::InternalRead( istream& in, list<uint> & link_sta
 
 void bhkPackedNiTriStripsShape::InternalWrite( ostream& out, const map<NiObjectRef,uint> & link_map, unsigned int version, unsigned int user_version ) const {
 	AbhkShapeCollection::Write( out, link_map, version, user_version );
-	numSubparts = ushort(subparts.size());
-	NifStream( numSubparts, out, version );
-	for (uint i1 = 0; i1 < subparts.size(); i1++) {
-		for (uint i2 = 0; i2 < 3; i2++) {
-			NifStream( subparts[i1][i2], out, version );
-		};
+	numSubShapes = ushort(subShapes.size());
+	NifStream( numSubShapes, out, version );
+	for (uint i1 = 0; i1 < subShapes.size(); i1++) {
+		NifStream( subShapes[i1].layer, out, version );
+		NifStream( subShapes[i1].colFilter, out, version );
+		NifStream( subShapes[i1].unknownShort, out, version );
+		NifStream( subShapes[i1].vertexCount___, out, version );
+		NifStream( subShapes[i1].material, out, version );
 	};
 	for (uint i1 = 0; i1 < 9; i1++) {
 		NifStream( unknownFloats[i1], out, version );
@@ -3078,21 +3084,19 @@ std::string bhkPackedNiTriStripsShape::InternalAsString( bool verbose ) const {
 	stringstream out;
 	uint array_output_count = 0;
 	out << AbhkShapeCollection::asString();
-	numSubparts = ushort(subparts.size());
-	out << "  Num Subparts:  " << numSubparts << endl;
+	numSubShapes = ushort(subShapes.size());
+	out << "  Num Sub Shapes:  " << numSubShapes << endl;
 	array_output_count = 0;
-	for (uint i1 = 0; i1 < subparts.size(); i1++) {
+	for (uint i1 = 0; i1 < subShapes.size(); i1++) {
 		if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
 			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl;
 			break;
 		};
-		for (uint i2 = 0; i2 < 3; i2++) {
-			if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
-				break;
-			};
-			out << "      Subparts[" << i2 << "]:  " << subparts[i1][i2] << endl;
-			array_output_count++;
-		};
+		out << "    Layer:  " << subShapes[i1].layer << endl;
+		out << "    Col Filter:  " << subShapes[i1].colFilter << endl;
+		out << "    Unknown Short:  " << subShapes[i1].unknownShort << endl;
+		out << "    Vertex Count (?):  " << subShapes[i1].vertexCount___ << endl;
+		out << "    Material:  " << subShapes[i1].material << endl;
 	};
 	array_output_count = 0;
 	for (uint i1 = 0; i1 < 9; i1++) {
diff --git a/src/obj/NiObjectNET.cpp b/src/obj/NiObjectNET.cpp
index 3f28ca7d..8b92c5a5 100644
--- a/src/obj/NiObjectNET.cpp
+++ b/src/obj/NiObjectNET.cpp
@@ -52,22 +52,23 @@ string NiObjectNET::GetIDString() {
 	return out.str();
 }
 
-void NiObjectNET::AddExtraData( Ref<NiExtraData> & obj, uint version ) {
+void NiObjectNET::AddExtraData( NiExtraData * obj, uint version ) {
 	if ( version >= VER_10_0_1_0 ) {
 		//In later versions, extra data is just stored in a vector
-		extraDataList.push_back( obj );
+		extraDataList.push_back( NiExtraDataRef(obj) );
 	} else {
 		//In earlier versions, extra data is a singly linked list
 		//Insert at begining of list
 		obj->SetNextExtraData( extraData);
-		extraData = obj;
+		extraData = NiExtraDataRef(obj);
 	}
 }
 
-void NiObjectNET::RemoveExtraData( Ref<NiExtraData> obj ) {
+void NiObjectNET::RemoveExtraData( NiExtraData * obj ) {
 	//Search both types of extra data list for the one to remove
+	NiExtraDataRef ref(obj);
 	for ( vector< NiExtraDataRef >::iterator it = extraDataList.begin(); it != extraDataList.end(); ) {
-		if ( *it == obj ) {
+		if ( *it == ref ) {
 			it = extraDataList.erase( it );
 		} else {
 			++it;
@@ -76,7 +77,7 @@ void NiObjectNET::RemoveExtraData( Ref<NiExtraData> obj ) {
 	
 	NiExtraDataRef * extra = &extraData;
 	while ( (*extra) != NULL ) {
-		if ( (*extra) == obj ) {
+		if ( (*extra) == ref ) {
 			//Cut this reference out of the list
 			(*extra) = (*extra)->GetNextExtraData();
 		} else {
@@ -86,7 +87,7 @@ void NiObjectNET::RemoveExtraData( Ref<NiExtraData> obj ) {
 	}
 }
 
-void NiObjectNET::ShiftExtraData( uint version ) {
+void NiObjectNET::ShiftExtraData( unsigned version ) {
 	//Shift any extra data references that are stored in a way that doesn't match
 	//the requested version to the way that does
 	if ( version >= VER_10_0_1_0 ) {
@@ -132,17 +133,18 @@ list< Ref<NiExtraData> > NiObjectNET::GetExtraData() const {
 	return extras;
 }
 
-void NiObjectNET::AddController( Ref<NiTimeController> & obj ) {
+	void NiObjectNET::AddController( NiTimeController * obj ) {
 	//Insert at begining of list
 	obj->SetTarget( this );
 	obj->SetNextController( controller );
 	controller = obj;
 }
 
-void NiObjectNET::RemoveController( Ref<NiTimeController> obj ) {
+void NiObjectNET::RemoveController( NiTimeController * obj ) {
+	NiTimeControllerRef ref(obj);
 	for(NiTimeControllerRef last = controller, cont = last, next; cont != NULL; cont = next ) {
       next = cont->GetNextController();
-		if ( cont == obj ) {
+		if ( cont == ref ) {
 			//Cut this reference out of the list
 			cont->SetTarget( NULL );
          cont->SetNextController( NiTimeControllerRef() );
diff --git a/src/obj/bhkNiTriStripsShape.cpp b/src/obj/bhkNiTriStripsShape.cpp
index 6c68892a..0dc3fbe1 100644
--- a/src/obj/bhkNiTriStripsShape.cpp
+++ b/src/obj/bhkNiTriStripsShape.cpp
@@ -43,8 +43,10 @@ void bhkNiTriStripsShape::SetNumStripsData(int n)
 
    // This is currently a kludge for compatibility with the max NifExporter as we dont know what this 
    //   does but its always same number of strips and usually 1 or 4
-   numUnknownInts2 = n;
-   unknownInts2.assign(n, 1);
+   //numUnknownInts2 = n;
+   //unknownInts2.assign(n, 1);
+
+	//TODO:  Understand why these are gone and what to do about it
 }
 
 void bhkNiTriStripsShape::SetStripsData(int i, Ref<NiTriStripsData> &strips)
-- 
GitLab