From 2155d689efccd702639dde8402ac4717becf3128 Mon Sep 17 00:00:00 2001
From: skyfox69 <fdueber@cat-gmbh.de>
Date: Tue, 1 May 2012 08:03:50 +0200
Subject: [PATCH] added some copy constructors

---
 include/RefObject.h                    |  3 ++
 include/Type.h                         |  1 +
 include/nif_math.h                     | 16 ++++++++
 include/obj/BSLightingShaderProperty.h |  3 ++
 include/obj/NiAVObject.h               |  3 ++
 include/obj/NiNode.h                   |  3 ++
 include/obj/NiObject.h                 |  3 ++
 include/obj/NiObjectNET.h              |  3 ++
 include/obj/bhkCompressedMeshShape.h   |  3 ++
 include/obj/bhkMoppBvTreeShape.h       |  3 ++
 include/obj/bhkRigidBody.h             |  3 ++
 src/RefObject.cpp                      |  5 +++
 src/Type.cpp                           |  2 +
 src/nif_math.cpp                       |  4 ++
 src/obj/BSLightingShaderProperty.cpp   | 30 ++++++++++++++
 src/obj/NiAVObject.cpp                 | 21 ++++++++++
 src/obj/NiNode.cpp                     |  7 ++++
 src/obj/NiObject.cpp                   |  8 ++++
 src/obj/NiObjectNET.cpp                | 17 ++++++++
 src/obj/bhkCompressedMeshShape.cpp     | 13 +++++++
 src/obj/bhkMoppBvTreeShape.cpp         | 18 +++++++++
 src/obj/bhkRigidBody.cpp               | 54 ++++++++++++++++++++++++++
 22 files changed, 223 insertions(+)

diff --git a/include/RefObject.h b/include/RefObject.h
index 4dfa2dbb..43dbd57f 100644
--- a/include/RefObject.h
+++ b/include/RefObject.h
@@ -29,6 +29,9 @@ public:
 	/*! Constructor */
 	NIFLIB_API RefObject();
 
+	/*! Copy Constructor */
+	NIFLIB_API RefObject(const RefObject& src);
+
 	/*! Destructor */
 	NIFLIB_API virtual ~RefObject();
 
diff --git a/include/Type.h b/include/Type.h
index 8c41a6f2..6d14735e 100644
--- a/include/Type.h
+++ b/include/Type.h
@@ -19,6 +19,7 @@ class NiObject;
 class Type {
 public:
 	NIFLIB_API Type (const string & type_name, const Type * par_type );
+	NIFLIB_API Type (const Type& src);
 	NIFLIB_API ~Type();
 
 	NIFLIB_API string GetTypeName() const;
diff --git a/include/nif_math.h b/include/nif_math.h
index eec07e49..33dea805 100644
--- a/include/nif_math.h
+++ b/include/nif_math.h
@@ -45,6 +45,9 @@ struct TexCoord {
 	/*! Default constructor	*/
 	NIFLIB_API TexCoord() : u(0.0f), v(0.0f) {}
 
+	/*! Copy constructor	*/
+	NIFLIB_API TexCoord(const TexCoord& src) : u(src.u), v(src.v) {}
+
 	NIFLIB_API TexCoord operator+(const TexCoord& rhs) const
 	{
 		TexCoord ret;
@@ -603,6 +606,9 @@ struct Matrix33 {
 	/*! Default constructor.   Initializes matrix to identity.  */
 	NIFLIB_API Matrix33();
 
+	/*! Copy constructor.   */
+	NIFLIB_API Matrix33(const Matrix33& src);
+
 	/*! This constructor can be used to set all values in this matrix during initialization
 	 * \param[in] m11 The value to set at row 1, column 1.
 	 * \param[in] m12 The value to set at row 1, column 2.
@@ -955,6 +961,13 @@ struct Color3 {
 	/*! Default constructor */
 	NIFLIB_API Color3() {}
 
+	/*! Copy constructor */
+	NIFLIB_API Color3(const Color3& src) {
+		this->r = src.r;
+		this->g = src.g;
+		this->b = src.b;
+	}
+
 	/*! This constructor can be used to set all values in this structure during initialization
 	 * \param[in] r The value to set the red component of this color to.  Should be between 0.0f and 1.0f.
 	 * \param[in] g The value to set the green component of this color to. Should be between 0.0f and 1.0f.
@@ -1010,6 +1023,9 @@ struct Color4 {
 	/*! Default constructor */
 	NIFLIB_API Color4() : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {}
 
+	/*! Copy constructor */
+	NIFLIB_API Color4(const Color4& src) : r(src.r), g(src.g), b(src.b), a(src.a) {}
+
 	/*! This constructor can be used to set all values in this structure during initialization
 	 * \param[in] r The value to set the red component of this color to.  Should be between 0.0f and 1.0f.
 	 * \param[in] g The value to set the green component of this color to. Should be between 0.0f and 1.0f.
diff --git a/include/obj/BSLightingShaderProperty.h b/include/obj/BSLightingShaderProperty.h
index 5abf7c47..2fe84d8b 100644
--- a/include/obj/BSLightingShaderProperty.h
+++ b/include/obj/BSLightingShaderProperty.h
@@ -34,6 +34,9 @@ public:
 	/*! Constructor */
 	NIFLIB_API BSLightingShaderProperty();
 
+	/*! Copy constructor */
+	NIFLIB_API BSLightingShaderProperty(const BSLightingShaderProperty& src);
+
 	/*! Destructor */
 	NIFLIB_API virtual ~BSLightingShaderProperty();
 
diff --git a/include/obj/NiAVObject.h b/include/obj/NiAVObject.h
index 77f56e60..8a842cfa 100644
--- a/include/obj/NiAVObject.h
+++ b/include/obj/NiAVObject.h
@@ -35,6 +35,9 @@ public:
 	/*! Constructor */
 	NIFLIB_API NiAVObject();
 
+	/*! Copy constructor */
+	NIFLIB_API NiAVObject(const NiAVObject& src);
+
 	/*! Destructor */
 	NIFLIB_API virtual ~NiAVObject();
 
diff --git a/include/obj/NiNode.h b/include/obj/NiNode.h
index 0c7414b2..d2cf7790 100644
--- a/include/obj/NiNode.h
+++ b/include/obj/NiNode.h
@@ -34,6 +34,9 @@ public:
 	/*! Constructor */
 	NIFLIB_API NiNode();
 
+	/*! Copy constructor */
+	NIFLIB_API NiNode(const NiNode& src);
+
 	/*! Destructor */
 	NIFLIB_API virtual ~NiNode();
 
diff --git a/include/obj/NiObject.h b/include/obj/NiObject.h
index 7553cad1..9a9ef193 100644
--- a/include/obj/NiObject.h
+++ b/include/obj/NiObject.h
@@ -38,6 +38,9 @@ public:
 	/*! Constructor */
 	NIFLIB_API NiObject();
 
+	/*! Copy constructor */
+	NIFLIB_API NiObject(const NiObject& src);
+
 	/*! Destructor */
 	NIFLIB_API virtual ~NiObject();
 
diff --git a/include/obj/NiObjectNET.h b/include/obj/NiObjectNET.h
index 67c6cb14..07c19ea4 100644
--- a/include/obj/NiObjectNET.h
+++ b/include/obj/NiObjectNET.h
@@ -31,6 +31,9 @@ public:
 	/*! Constructor */
 	NIFLIB_API NiObjectNET();
 
+	/*! Copy constructor */
+	NIFLIB_API NiObjectNET(const NiObjectNET& src);
+
 	/*! Destructor */
 	NIFLIB_API virtual ~NiObjectNET();
 
diff --git a/include/obj/bhkCompressedMeshShape.h b/include/obj/bhkCompressedMeshShape.h
index 8e9c3593..3ac0c392 100644
--- a/include/obj/bhkCompressedMeshShape.h
+++ b/include/obj/bhkCompressedMeshShape.h
@@ -32,6 +32,9 @@ public:
 	/*! Constructor */
 	NIFLIB_API bhkCompressedMeshShape();
 
+	/*! Copy constructor */
+	NIFLIB_API bhkCompressedMeshShape(const bhkCompressedMeshShape& src);
+
 	/*! Destructor */
 	NIFLIB_API virtual ~bhkCompressedMeshShape();
 
diff --git a/include/obj/bhkMoppBvTreeShape.h b/include/obj/bhkMoppBvTreeShape.h
index 10bd9af1..30db0dfe 100644
--- a/include/obj/bhkMoppBvTreeShape.h
+++ b/include/obj/bhkMoppBvTreeShape.h
@@ -30,6 +30,9 @@ public:
 	/*! Constructor */
 	NIFLIB_API bhkMoppBvTreeShape();
 
+	/*! Copy constructor */
+	NIFLIB_API bhkMoppBvTreeShape(const bhkMoppBvTreeShape& src);
+
 	/*! Destructor */
 	NIFLIB_API virtual ~bhkMoppBvTreeShape();
 
diff --git a/include/obj/bhkRigidBody.h b/include/obj/bhkRigidBody.h
index f923c218..4724bbba 100644
--- a/include/obj/bhkRigidBody.h
+++ b/include/obj/bhkRigidBody.h
@@ -39,6 +39,9 @@ public:
 	/*! Constructor */
 	NIFLIB_API bhkRigidBody();
 
+	/*! Copy constructor */
+	NIFLIB_API bhkRigidBody(const bhkRigidBody& src);
+
 	/*! Destructor */
 	NIFLIB_API virtual ~bhkRigidBody();
 
diff --git a/src/RefObject.cpp b/src/RefObject.cpp
index 6db8980d..9d92a736 100644
--- a/src/RefObject.cpp
+++ b/src/RefObject.cpp
@@ -12,6 +12,11 @@ RefObject::RefObject() {
 	objectsInMemory++;
 }
 
+RefObject::RefObject(const RefObject& src) {
+	_ref_count = 0;
+	objectsInMemory++;
+}
+
 RefObject::~RefObject() {
 	objectsInMemory--;
 }
diff --git a/src/Type.cpp b/src/Type.cpp
index 09639ef7..3fa1c327 100644
--- a/src/Type.cpp
+++ b/src/Type.cpp
@@ -9,6 +9,8 @@ int Type::num_types = 0;
 
 Type::Type (const string & type_name, const Type * par_type ) : name(type_name), base_type(par_type), internal_type_number(num_types++) {} 
 
+Type::Type(const Type& src) : name(src.name), base_type(src.base_type), internal_type_number(src.internal_type_number) {}
+
 Type::~Type() {}
 
 bool Type::operator<( const Type & compare_to ) const {
diff --git a/src/nif_math.cpp b/src/nif_math.cpp
index a7ffb8d4..561d7ad3 100644
--- a/src/nif_math.cpp
+++ b/src/nif_math.cpp
@@ -298,6 +298,10 @@ Matrix33::Matrix33() {
 	*this = Matrix33::IDENTITY;
 }
 
+Matrix33::Matrix33(const Matrix33& src) {
+	*this = src;
+}
+
 Quaternion Matrix33::AsQuaternion() const {
 	Quaternion quat;
 	float tr, s, q[4];
diff --git a/src/obj/BSLightingShaderProperty.cpp b/src/obj/BSLightingShaderProperty.cpp
index 0ff33749..f3ce7690 100644
--- a/src/obj/BSLightingShaderProperty.cpp
+++ b/src/obj/BSLightingShaderProperty.cpp
@@ -27,6 +27,36 @@ BSLightingShaderProperty::BSLightingShaderProperty() : shaderFlags1((unsigned in
 	//--END CUSTOM CODE--//
 }
 
+BSLightingShaderProperty::BSLightingShaderProperty(const BSLightingShaderProperty& src)
+	:	shaderFlags1(src.shaderFlags1),
+		shaderFlags2(src.shaderFlags2),
+		textureSet(NULL),
+		emissiveSaturation(src.emissiveSaturation),
+		unknownInt7(src.unknownInt7),
+		alpha(src.alpha),
+		unknownFloat2(src.unknownFloat2),
+		glossiness(src.glossiness),
+		specularStrength(src.specularStrength),
+		lightingEffect1(src.lightingEffect1),
+		lightingEffect2(src.lightingEffect2),
+		environmentMapStrength(src.environmentMapStrength),
+		unknownFloat9(src.unknownFloat9),
+		eyeCubemapScale(src.eyeCubemapScale),
+		emissiveColor(src.emissiveColor),
+		specularColor(src.specularColor),
+		unknownColor1(src.unknownColor1),
+		unknownColor2(src.unknownColor2),
+		unknownFloatSet1(src.unknownFloatSet1),
+		unknownFloatSet5(src.unknownFloatSet5),
+		leftEyeReflectionCenter(src.leftEyeReflectionCenter),
+		rightEyeReflectionCenter(src.rightEyeReflectionCenter),
+		textureTranslation1(src.textureTranslation1),
+		textureRepeat(src.textureRepeat)
+{
+	//--BEGIN CONSTRUCTOR CUSTOM CODE--//
+	//--END CUSTOM CODE--//
+}
+
 BSLightingShaderProperty::~BSLightingShaderProperty() {
 	//--BEGIN DESTRUCTOR CUSTOM CODE--//
 
diff --git a/src/obj/NiAVObject.cpp b/src/obj/NiAVObject.cpp
index 7329dd7e..a888c1c9 100644
--- a/src/obj/NiAVObject.cpp
+++ b/src/obj/NiAVObject.cpp
@@ -31,6 +31,27 @@ NiAVObject::NiAVObject() : flags((unsigned short)0), unknownShort1((unsigned sho
 	//--END CUSTOM CODE--//
 }
 
+NiAVObject::NiAVObject(const NiAVObject& src)
+	:	NiObjectNET(src),
+		flags(src.flags),
+		unknownShort1(src.unknownShort1),
+		scale(src.scale),
+		numProperties((unsigned int)0),
+		unknown2(src.unknown2),
+		hasBoundingBox(src.hasBoundingBox),
+		collisionObject(NULL),
+		translation(src.translation),
+		velocity(src.velocity),
+		rotation(src.rotation),
+		boundingBox(src.boundingBox)
+{
+	//--BEGIN CONSTRUCTOR CUSTOM CODE--//
+
+	parent = NULL;
+
+	//--END CUSTOM CODE--//
+}
+
 NiAVObject::~NiAVObject() {
 	//--BEGIN DESTRUCTOR CUSTOM CODE--//
 
diff --git a/src/obj/NiNode.cpp b/src/obj/NiNode.cpp
index 1325acc7..1908062e 100644
--- a/src/obj/NiNode.cpp
+++ b/src/obj/NiNode.cpp
@@ -33,6 +33,13 @@ NiNode::NiNode() : numChildren((unsigned int)0), numEffects((unsigned int)0) {
 	//--END CUSTOM CODE--//
 }
 
+NiNode::NiNode(const NiNode& src)
+	:	NiAVObject(src),
+		numChildren((unsigned int)0),
+		numEffects((unsigned int)0)
+{
+}
+
 NiNode::~NiNode() {
 	//--BEGIN DESTRUCTOR CUSTOM CODE--//
 
diff --git a/src/obj/NiObject.cpp b/src/obj/NiObject.cpp
index deb2fb2f..f9e2ccf2 100644
--- a/src/obj/NiObject.cpp
+++ b/src/obj/NiObject.cpp
@@ -25,6 +25,14 @@ NiObject::NiObject() {
 	//--END CUSTOM CODE--//
 }
 
+NiObject::NiObject(const NiObject& src)
+	:	RefObject(src),
+		internal_block_number(src.internal_block_number)
+{
+	//--BEGIN CONSTRUCTOR CUSTOM CODE--//
+	//--END CUSTOM CODE--//
+}
+
 NiObject::~NiObject() {
 	//--BEGIN DESTRUCTOR CUSTOM CODE--//
 	//--END CUSTOM CODE--//
diff --git a/src/obj/NiObjectNET.cpp b/src/obj/NiObjectNET.cpp
index dfc1177f..d29c35bf 100644
--- a/src/obj/NiObjectNET.cpp
+++ b/src/obj/NiObjectNET.cpp
@@ -27,6 +27,23 @@ NiObjectNET::NiObjectNET() : skyrimShaderType((unsigned int)0), hasOldExtraData(
 	//--END CUSTOM CODE--//
 }
 
+NiObjectNET::NiObjectNET(const NiObjectNET& src)
+	:	NiObject(src),
+		skyrimShaderType(src.skyrimShaderType),
+		name(src.name),
+		hasOldExtraData (src.hasOldExtraData),
+		oldExtraPropName(src.oldExtraPropName),
+		oldExtraInternalId(src.oldExtraInternalId),
+		oldExtraString(src.oldExtraString),
+		unknownByte(src.unknownByte),
+		extraData(NULL),
+		numExtraDataList((unsigned int)0),
+		controller(NULL)
+{
+	//--BEGIN CONSTRUCTOR CUSTOM CODE--//
+	//--END CUSTOM CODE--//
+}
+
 NiObjectNET::~NiObjectNET() {
 	//--BEGIN DESTRUCTOR CUSTOM CODE--//
 
diff --git a/src/obj/bhkCompressedMeshShape.cpp b/src/obj/bhkCompressedMeshShape.cpp
index 823bbda6..43dfaea8 100644
--- a/src/obj/bhkCompressedMeshShape.cpp
+++ b/src/obj/bhkCompressedMeshShape.cpp
@@ -28,6 +28,19 @@ bhkCompressedMeshShape::bhkCompressedMeshShape() : target(NULL), material((Havok
 	//--END CUSTOM CODE--//
 }
 
+bhkCompressedMeshShape::bhkCompressedMeshShape(const bhkCompressedMeshShape& src)
+	:	target(NULL),
+		material(src.material),
+		unknownFloat1(src.unknownFloat1),
+		data(NULL)
+{
+	for (short i(0); i < 8; ++i)
+	{
+		unknown8Bytes[i] = src.unknown8Bytes[i];
+		unknownFloats[i] = src.unknownFloats[i];
+	}
+}
+
 bhkCompressedMeshShape::~bhkCompressedMeshShape() {
 	//--BEGIN DESTRUCTOR CUSTOM CODE--//
 
diff --git a/src/obj/bhkMoppBvTreeShape.cpp b/src/obj/bhkMoppBvTreeShape.cpp
index 930b0078..ff98faaa 100644
--- a/src/obj/bhkMoppBvTreeShape.cpp
+++ b/src/obj/bhkMoppBvTreeShape.cpp
@@ -25,6 +25,24 @@ bhkMoppBvTreeShape::bhkMoppBvTreeShape() : shape(NULL), material((HavokMaterial)
 	//--END CUSTOM CODE--//
 }
 
+bhkMoppBvTreeShape::bhkMoppBvTreeShape(const bhkMoppBvTreeShape& src)
+	:	shape(NULL),
+		material(src.material),
+		unknownInt1(src.unknownInt1),
+		unknownInt2(src.unknownInt2),
+		unknownFloat(src.unknownFloat),
+		moppDataSize(src.moppDataSize),
+		scale(src.scale),
+		unknownByte1(src.unknownByte1),
+		origin(src.origin)
+{
+	moppData.resize(src.moppData.size());
+	for (unsigned int i(0); i < src.moppData.size(); ++i)
+	{
+		moppData[i] = src.moppData[i];
+	}
+}
+
 bhkMoppBvTreeShape::~bhkMoppBvTreeShape() {
 	//--BEGIN DESTRUCTOR CUSTOM CODE--//
 	//--END CUSTOM CODE--//
diff --git a/src/obj/bhkRigidBody.cpp b/src/obj/bhkRigidBody.cpp
index 86004175..6d238812 100644
--- a/src/obj/bhkRigidBody.cpp
+++ b/src/obj/bhkRigidBody.cpp
@@ -27,6 +27,60 @@ bhkRigidBody::bhkRigidBody() : unknownInt1((int)0), unknownInt2((int)0x00000001)
 	//--END CUSTOM CODE--//
 }
 
+bhkRigidBody::bhkRigidBody(const bhkRigidBody& src)
+	:	unknownInt1(src.unknownInt1),
+		unknownInt2(src.unknownInt2),
+		collisionResponse_(src.collisionResponse_),
+		unknownByte(src.unknownByte),
+		processContactCallbackDelay_(src.processContactCallbackDelay_),
+		layerCopy(src.layerCopy),
+		colFilterCopy(src.colFilterCopy),
+		translation(src.translation),
+		rotation(src.rotation),
+		linearVelocity(src.linearVelocity),
+		angularVelocity(src.angularVelocity),
+		inertia(src.inertia),
+		center(src.center),
+		mass(src.mass),
+		linearDamping(src.linearDamping),
+		angularDamping(src.angularDamping),
+		friction(src.friction),
+		restitution(src.restitution),
+		unknownFloat51(src.unknownFloat51),
+		unknownFloat52(src.unknownFloat52),
+		unknownFloat53(src.unknownFloat53),
+		maxLinearVelocity(src.maxLinearVelocity),
+		maxAngularVelocity(src.maxAngularVelocity),
+		penetrationDepth(src.penetrationDepth),
+		motionSystem(src.motionSystem),
+		deactivatorType(src.deactivatorType),
+		solverDeactivation(src.solverDeactivation),
+		qualityType(src.qualityType),
+		unknownInt6(src.unknownInt6),
+		unknownInt7(src.unknownInt7),
+		unknownInt8(src.unknownInt8),
+		unknownInt81(src.unknownInt81),
+		numConstraints(src.numConstraints),
+		unknownInt9(src.unknownInt9),
+		unknownInt91(src.unknownInt91)
+{
+	//--BEGIN CONSTRUCTOR CUSTOM CODE--//
+	for (short i(0); i < 3; ++i)
+	{
+		unknown3Ints[i] = src.unknown3Ints[i];
+	}
+	for (short i(0); i < 2; ++i)
+	{
+		unknown2Shorts[i] = src.unknown2Shorts[i];
+	}
+	for (short i(0); i < 7; ++i)
+	{
+		unknown7Shorts[i] = src.unknown7Shorts[i];
+	}
+	//vector<Ref<bhkSerializable > > constraints;	vector<Ref<bhkSerializable > > constraints;
+	//--END CUSTOM CODE--//
+}
+
 bhkRigidBody::~bhkRigidBody() {
 	//--BEGIN DESTRUCTOR CUSTOM CODE--//
 	//--END CUSTOM CODE--//
-- 
GitLab