Bläddra i källkod

Refactored Vector and Quaternion types so they don't perform zero initialization by default

BearishSun 9 år sedan
förälder
incheckning
38e6e99f41
47 ändrade filer med 217 tillägg och 149 borttagningar
  1. 2 2
      Source/BansheeCore/Include/BsCAudioListener.h
  2. 2 2
      Source/BansheeCore/Include/BsCAudioSource.h
  3. 1 1
      Source/BansheeCore/Include/BsCBoxCollider.h
  4. 2 2
      Source/BansheeCore/Include/BsCCollider.h
  5. 3 3
      Source/BansheeCore/Include/BsCRigidbody.h
  6. 1 1
      Source/BansheeCore/Include/BsCharacterController.h
  7. 6 4
      Source/BansheeCore/Include/BsD6Joint.h
  8. 2 2
      Source/BansheeCore/Include/BsJoint.h
  9. 6 6
      Source/BansheeCore/Include/BsPrefabDiff.h
  10. 26 14
      Source/BansheeCore/Source/BsAnimationCurve.cpp
  11. 1 1
      Source/BansheeCore/Source/BsAnimationUtility.cpp
  12. 1 1
      Source/BansheeCore/Source/BsAudioListener.cpp
  13. 2 1
      Source/BansheeCore/Source/BsAudioSource.cpp
  14. 13 2
      Source/BansheeCore/Source/BsCJoint.cpp
  15. 6 10
      Source/BansheeCore/Source/BsCamera.cpp
  16. 3 7
      Source/BansheeCore/Source/BsMeshData.cpp
  17. 4 4
      Source/BansheeCore/Source/BsMeshUtility.cpp
  18. 1 1
      Source/BansheeEditor/Include/BsSceneGrid.h
  19. 8 0
      Source/BansheeEditor/Source/BsDockManager.cpp
  20. 20 18
      Source/BansheeEditor/Source/BsGizmoManager.cpp
  21. 2 2
      Source/BansheeEditor/Source/BsHandleSlider.cpp
  22. 3 1
      Source/BansheeEditor/Source/BsHandleSliderDisc.cpp
  23. 2 3
      Source/BansheeEditor/Source/BsHandleSliderLine.cpp
  24. 2 4
      Source/BansheeEditor/Source/BsHandleSliderPlane.cpp
  25. 0 2
      Source/BansheeEngine/Include/BsGUIWidget.h
  26. 2 2
      Source/BansheeEngine/Source/BsDrawHelper.cpp
  27. 3 2
      Source/BansheeEngine/Source/BsGUICanvas.cpp
  28. 4 4
      Source/BansheeEngine/Source/BsGUIWidget.cpp
  29. 8 4
      Source/BansheeEngine/Source/BsLight.cpp
  30. 1 1
      Source/BansheeEngine/Source/BsRenderable.cpp
  31. 1 1
      Source/BansheeFBXImporter/Source/BsFBXUtility.cpp
  32. 1 0
      Source/BansheePhysX/Source/BsPhysX.cpp
  33. 6 0
      Source/BansheeUtility/Include/BsFwdDeclUtil.h
  34. 8 0
      Source/BansheeUtility/Include/BsMatrix3.h
  35. 9 1
      Source/BansheeUtility/Include/BsMatrix4.h
  36. 12 1
      Source/BansheeUtility/Include/BsQuaternion.h
  37. 5 2
      Source/BansheeUtility/Include/BsVector2.h
  38. 4 1
      Source/BansheeUtility/Include/BsVector3.h
  39. 4 1
      Source/BansheeUtility/Include/BsVector4.h
  40. 5 6
      Source/BansheeUtility/Source/BsAABox.cpp
  41. 1 0
      Source/BansheeUtility/Source/BsLineSegment3.cpp
  42. 9 17
      Source/BansheeUtility/Source/BsPlane.cpp
  43. 0 1
      Source/BansheeUtility/Source/BsQuaternion.cpp
  44. 2 1
      Source/BansheeUtility/Source/BsRect3.cpp
  45. 1 1
      Source/BansheeUtility/Source/BsTorus.cpp
  46. 3 0
      Source/RenderBeast/Source/BsPostProcessing.cpp
  47. 9 9
      Source/SBansheeEngine/Source/BsScriptSceneObject.cpp

+ 2 - 2
Source/BansheeCore/Include/BsCAudioListener.h

@@ -71,8 +71,8 @@ namespace BansheeEngine
 		void updateTransform();
 		void updateTransform();
 
 
 		SPtr<AudioListener> mInternal;
 		SPtr<AudioListener> mInternal;
-		Vector3 mLastPosition;
-		Vector3 mVelocity;
+		Vector3 mLastPosition = Vector3::ZERO;
+		Vector3 mVelocity = Vector3::ZERO;
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								RTTI		                     		*/
 		/* 								RTTI		                     		*/

+ 2 - 2
Source/BansheeCore/Include/BsCAudioSource.h

@@ -137,8 +137,8 @@ namespace BansheeEngine
 		void updateTransform();
 		void updateTransform();
 
 
 		SPtr<AudioSource> mInternal;
 		SPtr<AudioSource> mInternal;
-		Vector3 mLastPosition;
-		Vector3 mVelocity;
+		Vector3 mLastPosition = Vector3::ZERO;
+		Vector3 mVelocity = Vector3::ZERO;
 
 
 		HAudioClip mAudioClip;
 		HAudioClip mAudioClip;
 		float mVolume;
 		float mVolume;

+ 1 - 1
Source/BansheeCore/Include/BsCBoxCollider.h

@@ -53,7 +53,7 @@ namespace BansheeEngine
 		SPtr<Collider> createInternal() override;
 		SPtr<Collider> createInternal() override;
 
 
     protected:
     protected:
-		Vector3 mExtents;
+		Vector3 mExtents = Vector3::ZERO;
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								RTTI		                     		*/
 		/* 								RTTI		                     		*/

+ 2 - 2
Source/BansheeCore/Include/BsCCollider.h

@@ -171,8 +171,8 @@ namespace BansheeEngine
 		HPhysicsMaterial mMaterial;
 		HPhysicsMaterial mMaterial;
 		float mMass = 1.0f;
 		float mMass = 1.0f;
 		bool mIsTrigger = false;
 		bool mIsTrigger = false;
-		Vector3 mLocalPosition;
-		Quaternion mLocalRotation;
+		Vector3 mLocalPosition = Vector3::ZERO;
+		Quaternion mLocalRotation = Quaternion::IDENTITY;
 
 
 		HRigidbody mParent;
 		HRigidbody mParent;
 
 

+ 3 - 3
Source/BansheeCore/Include/BsCRigidbody.h

@@ -239,9 +239,9 @@ namespace BansheeEngine
 		UINT32 mVelocitySolverCount = 1;
 		UINT32 mVelocitySolverCount = 1;
 		Rigidbody::Flag mFlags = (Rigidbody::Flag)((UINT32)Rigidbody::Flag::AutoTensors | (UINT32)Rigidbody::Flag::AutoMass);
 		Rigidbody::Flag mFlags = (Rigidbody::Flag)((UINT32)Rigidbody::Flag::AutoTensors | (UINT32)Rigidbody::Flag::AutoMass);
 		CollisionReportMode mCollisionReportMode = CollisionReportMode::None;
 		CollisionReportMode mCollisionReportMode = CollisionReportMode::None;
-		Vector3 mCMassPosition;
-		Quaternion mCMassRotation;
-		Vector3 mInertiaTensor;
+		Vector3 mCMassPosition = Vector3::ZERO;
+		Quaternion mCMassRotation = Quaternion::IDENTITY;
+		Vector3 mInertiaTensor = Vector3::ZERO;
 		float mMass = 0.0f;
 		float mMass = 0.0f;
 		float mMaxAngularVelocity = 1.0f;
 		float mMaxAngularVelocity = 1.0f;
 		float mLinearDrag = 0.0f;
 		float mLinearDrag = 0.0f;

+ 1 - 1
Source/BansheeCore/Include/BsCharacterController.h

@@ -226,7 +226,7 @@ namespace BansheeEngine
 	struct CHAR_CONTROLLER_DESC
 	struct CHAR_CONTROLLER_DESC
 	{
 	{
 		/** Center of the controller capsule */
 		/** Center of the controller capsule */
-		Vector3 position;
+		Vector3 position = Vector3::ZERO;
 
 
 		/**
 		/**
 		 * Contact offset specifies a skin around the object within which contacts will be generated. It should be a small
 		 * Contact offset specifies a skin around the object within which contacts will be generated. It should be a small

+ 6 - 4
Source/BansheeCore/Include/BsD6Joint.h

@@ -188,15 +188,17 @@ namespace BansheeEngine
 	/** Structure used for initializing a new D6Joint. */
 	/** Structure used for initializing a new D6Joint. */
 	struct D6_JOINT_DESC : JOINT_DESC
 	struct D6_JOINT_DESC : JOINT_DESC
 	{
 	{
+		D6_JOINT_DESC() { }
+
 		D6Joint::Motion motion[(UINT32)D6Joint::Axis::Count];
 		D6Joint::Motion motion[(UINT32)D6Joint::Axis::Count];
 		D6Joint::Drive drive[(UINT32)D6Joint::DriveType::Count];
 		D6Joint::Drive drive[(UINT32)D6Joint::DriveType::Count];
 		LimitLinear limitLinear;
 		LimitLinear limitLinear;
 		LimitAngularRange limitTwist;
 		LimitAngularRange limitTwist;
 		LimitConeRange limitSwing;
 		LimitConeRange limitSwing;
-		Vector3 drivePosition;
-		Quaternion driveRotation;
-		Vector3 driveLinearVelocity;
-		Vector3 driveAngularVelocity;
+		Vector3 drivePosition = Vector3::ZERO;
+		Quaternion driveRotation = Quaternion::IDENTITY;
+		Vector3 driveLinearVelocity = Vector3::ZERO;
+		Vector3 driveAngularVelocity = Vector3::ZERO;
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 2 - 2
Source/BansheeCore/Include/BsJoint.h

@@ -91,8 +91,8 @@ namespace BansheeEngine
 		struct BodyInfo
 		struct BodyInfo
 		{
 		{
 			Rigidbody* body = nullptr;
 			Rigidbody* body = nullptr;
-			Vector3 position;
-			Quaternion rotation;
+			Vector3 position = Vector3::ZERO;
+			Quaternion rotation = Quaternion::IDENTITY;
 		};
 		};
 
 
 		BodyInfo bodies[2];
 		BodyInfo bodies[2];

+ 6 - 6
Source/BansheeCore/Include/BsPrefabDiff.h

@@ -31,7 +31,7 @@ namespace BansheeEngine
 	public:
 	public:
 		friend class PrefabComponentDiffRTTI;
 		friend class PrefabComponentDiffRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
+		RTTITypeBase* getRTTI() const override;
 	};
 	};
 
 
 	/** Flags that mark which portion of a scene-object is modified. */
 	/** Flags that mark which portion of a scene-object is modified. */
@@ -56,9 +56,9 @@ namespace BansheeEngine
 		UINT32 id = 0;
 		UINT32 id = 0;
 
 
 		String name;
 		String name;
-		Vector3 position;
-		Quaternion rotation;
-		Vector3 scale;
+		Vector3 position = Vector3::ZERO;
+		Quaternion rotation = Quaternion::IDENTITY;
+		Vector3 scale = Vector3::ZERO;
 		bool isActive = false;
 		bool isActive = false;
 		UINT32 soFlags = 0;
 		UINT32 soFlags = 0;
 
 
@@ -77,7 +77,7 @@ namespace BansheeEngine
 	public:
 	public:
 		friend class PrefabObjectDiffRTTI;
 		friend class PrefabObjectDiffRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
+		RTTITypeBase* getRTTI() const override;
 	};
 	};
 
 
 	/**
 	/**
@@ -155,7 +155,7 @@ namespace BansheeEngine
 	public:
 	public:
 		friend class PrefabDiffRTTI;
 		friend class PrefabDiffRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
+		RTTITypeBase* getRTTI() const override;
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 26 - 14
Source/BansheeCore/Source/BsAnimationCurve.cpp

@@ -139,6 +139,18 @@ namespace BansheeEngine
 		return rhs.inverse() * lhs;
 		return rhs.inverse() * lhs;
 	}
 	}
 
 
+	template <class T>
+	T getZero() { return 0.0f; }
+
+	template<>
+	float getZero<float>() { return 0.0f; }
+
+	template<>
+	Vector3 getZero<Vector3>() { return Vector3(BsZero); }
+
+	template<>
+	Quaternion getZero<Quaternion>() { return Quaternion(BsZero); }
+
 	template <class T>
 	template <class T>
 	const UINT32 TAnimationCurve<T>::CACHE_LOOKAHEAD = 3;
 	const UINT32 TAnimationCurve<T>::CACHE_LOOKAHEAD = 3;
 
 
@@ -184,7 +196,7 @@ namespace BansheeEngine
 	T TAnimationCurve<T>::evaluate(float time, const TCurveCache<T>& cache, bool loop) const
 	T TAnimationCurve<T>::evaluate(float time, const TCurveCache<T>& cache, bool loop) const
 	{
 	{
 		if (mKeyframes.size() == 0)
 		if (mKeyframes.size() == 0)
-			return T();
+			return getZero<T>();
 
 
 		// Wrap time if looping
 		// Wrap time if looping
 		if(loop)
 		if(loop)
@@ -205,9 +217,9 @@ namespace BansheeEngine
 			cache.cachedCurveStart = -std::numeric_limits<float>::infinity();
 			cache.cachedCurveStart = -std::numeric_limits<float>::infinity();
 			cache.cachedCurveEnd = mStart;
 			cache.cachedCurveEnd = mStart;
 			cache.cachedKey = 0;
 			cache.cachedKey = 0;
-			cache.cachedCubicCoefficients[0] = T();
-			cache.cachedCubicCoefficients[1] = T();
-			cache.cachedCubicCoefficients[2] = T();
+			cache.cachedCubicCoefficients[0] = getZero<T>();
+			cache.cachedCubicCoefficients[1] = getZero<T>();
+			cache.cachedCubicCoefficients[2] = getZero<T>();
 			cache.cachedCubicCoefficients[3] = mKeyframes[0].value;
 			cache.cachedCubicCoefficients[3] = mKeyframes[0].value;
 
 
 			return mKeyframes[0].value;
 			return mKeyframes[0].value;
@@ -220,9 +232,9 @@ namespace BansheeEngine
 			cache.cachedCurveStart = mEnd;
 			cache.cachedCurveStart = mEnd;
 			cache.cachedCurveEnd = std::numeric_limits<float>::infinity();
 			cache.cachedCurveEnd = std::numeric_limits<float>::infinity();
 			cache.cachedKey = lastKey;
 			cache.cachedKey = lastKey;
-			cache.cachedCubicCoefficients[0] = T();
-			cache.cachedCubicCoefficients[1] = T();
-			cache.cachedCubicCoefficients[2] = T();
+			cache.cachedCubicCoefficients[0] = getZero<T>();
+			cache.cachedCubicCoefficients[1] = getZero<T>();
+			cache.cachedCubicCoefficients[2] = getZero<T>();
 			cache.cachedCubicCoefficients[3] = mKeyframes[lastKey].value;
 			cache.cachedCubicCoefficients[3] = mKeyframes[lastKey].value;
 
 
 			return mKeyframes[lastKey].value;
 			return mKeyframes[lastKey].value;
@@ -255,7 +267,7 @@ namespace BansheeEngine
 	T TAnimationCurve<T>::evaluate(float time, bool loop) const
 	T TAnimationCurve<T>::evaluate(float time, bool loop) const
 	{
 	{
 		if (mKeyframes.size() == 0)
 		if (mKeyframes.size() == 0)
-			return T();
+			return getZero<T>();
 
 
 		AnimationUtility::wrapTime(time, mStart, mEnd, loop);
 		AnimationUtility::wrapTime(time, mStart, mEnd, loop);
 
 
@@ -271,13 +283,13 @@ namespace BansheeEngine
 		float length = rightKey.time - leftKey.time;
 		float length = rightKey.time - leftKey.time;
 		float t;
 		float t;
 		T leftTangent;
 		T leftTangent;
-		T rightTangent; // TODO - Remove zero init for vectors/quaternions by default
+		T rightTangent;
 
 
 		if (Math::approxEquals(length, 0.0f))
 		if (Math::approxEquals(length, 0.0f))
 		{
 		{
 			t = 0.0f;
 			t = 0.0f;
-			leftTangent = T();
-			rightTangent = T();
+			leftTangent = getZero<T>();
+			rightTangent = getZero<T>();
 		}
 		}
 		else
 		else
 		{
 		{
@@ -419,13 +431,13 @@ namespace BansheeEngine
 		float t;
 		float t;
 
 
 		T leftTangent;
 		T leftTangent;
-		T rightTangent; // TODO - Remove zero init for vectors/quaternions by default
+		T rightTangent;
 
 
 		if (Math::approxEquals(length, 0.0f))
 		if (Math::approxEquals(length, 0.0f))
 		{
 		{
 			t = 0.0f;
 			t = 0.0f;
-			leftTangent = T();
-			rightTangent = T();
+			leftTangent = getZero<T>();
+			rightTangent = getZero<T>();
 		}
 		}
 		else
 		else
 		{
 		{

+ 1 - 1
Source/BansheeCore/Source/BsAnimationUtility.cpp

@@ -101,7 +101,7 @@ namespace BansheeEngine
 		Vector<TKeyframe<Quaternion>> quatKeyframes(numKeys);
 		Vector<TKeyframe<Quaternion>> quatKeyframes(numKeys);
 
 
 		// Calculate key values
 		// Calculate key values
-		Quaternion lastQuat;
+		Quaternion lastQuat(BsZero);
 		for (INT32 i = 0; i < numKeys; i++)
 		for (INT32 i = 0; i < numKeys; i++)
 		{
 		{
 			float time = eulerCurve.getKeyFrame(i).time;
 			float time = eulerCurve.getKeyFrame(i).time;

+ 1 - 1
Source/BansheeCore/Source/BsAudioListener.cpp

@@ -6,7 +6,7 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	AudioListener::AudioListener()
 	AudioListener::AudioListener()
-		:mDirection(-Vector3::UNIT_Z), mUp(Vector3::UNIT_Y)
+		:mPosition(BsZero), mDirection(-Vector3::UNIT_Z), mUp(Vector3::UNIT_Y), mVelocity(BsZero)
 	{
 	{
 		
 		
 	}
 	}

+ 2 - 1
Source/BansheeCore/Source/BsAudioSource.cpp

@@ -7,7 +7,8 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	AudioSource::AudioSource()
 	AudioSource::AudioSource()
-		: mVolume(1.0f), mPitch(1.0f), mLoop(false), mPriority(0), mMinDistance(1.0f), mAttenuation(1.0f)
+		: mPosition(BsZero), mVelocity(BsZero), mVolume(1.0f), mPitch(1.0f), mLoop(false), mPriority(0)
+		, mMinDistance(1.0f), mAttenuation(1.0f)
 	{
 	{
 
 
 	}
 	}

+ 13 - 2
Source/BansheeCore/Source/BsCJoint.cpp

@@ -12,13 +12,25 @@ namespace BansheeEngine
 {
 {
 	CJoint::CJoint(JOINT_DESC& desc)
 	CJoint::CJoint(JOINT_DESC& desc)
 		:mDesc(desc)
 		:mDesc(desc)
-	{ }
+	{
+		mPositions[0] = Vector3::ZERO;
+		mPositions[1] = Vector3::ZERO;
+
+		mRotations[0] = Quaternion::IDENTITY;
+		mRotations[1] = Quaternion::IDENTITY;
+	}
 
 
 	CJoint::CJoint(const HSceneObject& parent, JOINT_DESC& desc)
 	CJoint::CJoint(const HSceneObject& parent, JOINT_DESC& desc)
 		: Component(parent), mDesc(desc)
 		: Component(parent), mDesc(desc)
 	{
 	{
 		setName("Joint");
 		setName("Joint");
 
 
+		mPositions[0] = Vector3::ZERO;
+		mPositions[1] = Vector3::ZERO;
+
+		mRotations[0] = Quaternion::IDENTITY;
+		mRotations[1] = Quaternion::IDENTITY;
+
 		mNotifyFlags = (TransformChangedFlags)(TCF_Parent | TCF_Transform);
 		mNotifyFlags = (TransformChangedFlags)(TCF_Parent | TCF_Transform);
 	}
 	}
 
 
@@ -241,7 +253,6 @@ namespace BansheeEngine
 	{
 	{
 		Vector3 localPos;
 		Vector3 localPos;
 		Quaternion localRot;
 		Quaternion localRot;
-
 		getLocalTransform(body, localPos, localRot);
 		getLocalTransform(body, localPos, localRot);
 
 
 		mInternal->setTransform(body, localPos, localRot);
 		mInternal->setTransform(body, localPos, localRot);

+ 6 - 10
Source/BansheeCore/Source/BsCamera.cpp

@@ -19,19 +19,15 @@ namespace BansheeEngine
 	const float CameraBase::INFINITE_FAR_PLANE_ADJUST = 0.00001f;
 	const float CameraBase::INFINITE_FAR_PLANE_ADJUST = 0.00001f;
 
 
 	CameraBase::CameraBase()
 	CameraBase::CameraBase()
-		: mLayers(0xFFFFFFFFFFFFFFFF), mCameraFlags(CameraFlag::HDR), mIsActive(true), mProjType(PT_PERSPECTIVE)
-		, mHorzFOV(Degree(90.0f)), mFarDist(1000.0f), mNearDist(0.05f), mAspect(1.33333333333333f), mOrthoHeight(5)
-		, mPriority(0), mCustomViewMatrix(false), mCustomProjMatrix(false), mMSAA(1), mFrustumExtentsManuallySet(false)
-		, mRecalcFrustum(true), mRecalcFrustumPlanes(true), mRecalcView(true)
+		: mLayers(0xFFFFFFFFFFFFFFFF), mCameraFlags(CameraFlag::HDR), mPosition(BsZero), mRotation(BsIdentity)
+		, mIsActive(true), mProjType(PT_PERSPECTIVE), mHorzFOV(Degree(90.0f)), mFarDist(1000.0f), mNearDist(0.05f)
+		, mAspect(1.33333333333333f), mOrthoHeight(5), mPriority(0), mCustomViewMatrix(false), mCustomProjMatrix(false)
+		, mMSAA(1), mFrustumExtentsManuallySet(false), mProjMatrixRS(BsZero), mProjMatrix(BsZero), mViewMatrix(BsZero)
+		, mProjMatrixRSInv(BsZero), mProjMatrixInv(BsZero), mViewMatrixInv(BsZero), mRecalcFrustum(true)
+		, mRecalcFrustumPlanes(true), mRecalcView(true)
 	{
 	{
 		mPPSettings = RendererManager::instance().getActive()->createPostProcessSettings();
 		mPPSettings = RendererManager::instance().getActive()->createPostProcessSettings();
 
 
-		mViewMatrix = Matrix4::ZERO;
-		mProjMatrixRS = Matrix4::ZERO;
-		mViewMatrixInv = Matrix4::ZERO;
-		mProjMatrixRSInv = Matrix4::ZERO;
-		mProjMatrixInv = Matrix4::ZERO;
-
 		invalidateFrustum();
 		invalidateFrustum();
 	}
 	}
 
 

+ 3 - 7
Source/BansheeCore/Source/BsMeshData.cpp

@@ -367,14 +367,10 @@ namespace BansheeEngine
 
 
 			if (getNumVertices() > 0)
 			if (getNumVertices() > 0)
 			{
 			{
-				Vector3 accum;
-				Vector3 min;
-				Vector3 max;
-
 				Vector3 curPosition = *(Vector3*)data;
 				Vector3 curPosition = *(Vector3*)data;
-				accum = curPosition;
-				min = curPosition;
-				max = curPosition;
+				Vector3 accum = curPosition;
+				Vector3 min = curPosition;
+				Vector3 max = curPosition;
 
 
 				for (UINT32 i = 1; i < getNumVertices(); i++)
 				for (UINT32 i = 1; i < getNumVertices(); i++)
 				{
 				{

+ 4 - 4
Source/BansheeCore/Source/BsMeshUtility.cpp

@@ -86,8 +86,8 @@ namespace BansheeEngine
 		{
 		{
 			ClipVert() { }
 			ClipVert() { }
 
 
-			Vector3 point;
-			Vector2 uv;
+			Vector3 point = Vector3::ZERO;
+			Vector2 uv = Vector2::ZERO;
 			float distance = 0.0f;
 			float distance = 0.0f;
 			UINT32 occurs = 0;
 			UINT32 occurs = 0;
 			bool visible = true;
 			bool visible = true;
@@ -110,7 +110,7 @@ namespace BansheeEngine
 
 
 			Vector<UINT32> edges;
 			Vector<UINT32> edges;
 			bool visible = true;
 			bool visible = true;
-			Vector3 normal;
+			Vector3 normal = Vector3::ZERO;
 		};
 		};
 
 
 		/** Contains vertices, edges and faces of the clipped mesh. */
 		/** Contains vertices, edges and faces of the clipped mesh. */
@@ -516,7 +516,7 @@ namespace BansheeEngine
 
 
 	Vector3 TriangleClipperBase::getNormal(UINT32* sortedVertices, UINT32 numVertices)
 	Vector3 TriangleClipperBase::getNormal(UINT32* sortedVertices, UINT32 numVertices)
 	{
 	{
-		Vector3 normal;
+		Vector3 normal(BsZero);
 		for (UINT32 i = 0; i <= numVertices - 2; i++)
 		for (UINT32 i = 0; i <= numVertices - 2; i++)
 			normal += Vector3::cross(mesh.verts[sortedVertices[i]].point, mesh.verts[sortedVertices[i + 1]].point);
 			normal += Vector3::cross(mesh.verts[sortedVertices[i]].point, mesh.verts[sortedVertices[i + 1]].point);
 
 

+ 1 - 1
Source/BansheeEditor/Include/BsSceneGrid.h

@@ -117,7 +117,7 @@ namespace BansheeEngine
 		SPtr<GpuParamsSetCore> mMaterialParams;
 		SPtr<GpuParamsSetCore> mMaterialParams;
 		float mSpacing = 1.0f;
 		float mSpacing = 1.0f;
 		bool mFadeGrid = true;
 		bool mFadeGrid = true;
-		Vector3 mGridPlaneNormal;
+		Vector3 mGridPlaneNormal = Vector3::ZERO;
 
 
 		MaterialParamMat4Core mViewProjParam;
 		MaterialParamMat4Core mViewProjParam;
 		MaterialParamVec4Core mWorldCameraPosParam;
 		MaterialParamVec4Core mWorldCameraPosParam;

+ 8 - 0
Source/BansheeEditor/Source/BsDockManager.cpp

@@ -454,6 +454,14 @@ namespace BansheeEngine
 		mLeftDropPolygon = bs_newN<Vector2>(4);
 		mLeftDropPolygon = bs_newN<Vector2>(4);
 		mRightDropPolygon = bs_newN<Vector2>(4);
 		mRightDropPolygon = bs_newN<Vector2>(4);
 
 
+		for(UINT32 i = 0; i < 4; i++)
+		{
+			mTopDropPolygon[i] = Vector2::ZERO;
+			mBotDropPolygon[i] = Vector2::ZERO;
+			mLeftDropPolygon[i] = Vector2::ZERO;
+			mRightDropPolygon[i] = Vector2::ZERO;
+		}
+
 		HMaterial dropOverlayMat = BuiltinEditorResources::instance().createDockDropOverlayMaterial();
 		HMaterial dropOverlayMat = BuiltinEditorResources::instance().createDockDropOverlayMaterial();
 
 
 		mCore.store(bs_new<DockOverlayRenderer>(), std::memory_order_release);
 		mCore.store(bs_new<DockOverlayRenderer>(), std::memory_order_release);

+ 20 - 18
Source/BansheeEditor/Source/BsGizmoManager.cpp

@@ -173,18 +173,19 @@ namespace BansheeEngine
 	void GizmoManager::drawCone(const Vector3& base, const Vector3& normal, float height, float radius, const Vector2& scale)
 	void GizmoManager::drawCone(const Vector3& base, const Vector3& normal, float height, float radius, const Vector2& scale)
 	{
 	{
 		mSolidConeData.push_back(ConeData());
 		mSolidConeData.push_back(ConeData());
-		ConeData& sphereData = mSolidConeData.back();
+		ConeData& coneData = mSolidConeData.back();
 
 
-		sphereData.idx = mCurrentIdx++;
-		sphereData.base = base;
-		sphereData.radius = radius;
-		sphereData.color = mColor;
-		sphereData.transform = mTransform;
-		sphereData.sceneObject = mActiveSO;
-		sphereData.pickable = mPickable;
+		coneData.idx = mCurrentIdx++;
+		coneData.base = base;
+		coneData.radius = radius;
+		coneData.color = mColor;
+		coneData.transform = mTransform;
+		coneData.sceneObject = mActiveSO;
+		coneData.pickable = mPickable;
+		coneData.scale = scale;
 
 
 		mDrawHelper->cone(base, normal, height, radius, scale);
 		mDrawHelper->cone(base, normal, height, radius, scale);
-		mIdxToSceneObjectMap[sphereData.idx] = mActiveSO;
+		mIdxToSceneObjectMap[coneData.idx] = mActiveSO;
 	}
 	}
 
 
 	void GizmoManager::drawWireCube(const Vector3& position, const Vector3& extents)
 	void GizmoManager::drawWireCube(const Vector3& position, const Vector3& extents)
@@ -260,18 +261,19 @@ namespace BansheeEngine
 	void GizmoManager::drawWireCone(const Vector3& base, const Vector3& normal, float height, float radius, const Vector2& scale)
 	void GizmoManager::drawWireCone(const Vector3& base, const Vector3& normal, float height, float radius, const Vector2& scale)
 	{
 	{
 		mWireConeData.push_back(ConeData());
 		mWireConeData.push_back(ConeData());
-		ConeData& sphereData = mWireConeData.back();
+		ConeData& coneData = mWireConeData.back();
 
 
-		sphereData.idx = mCurrentIdx++;
-		sphereData.base = base;
-		sphereData.radius = radius;
-		sphereData.color = mColor;
-		sphereData.transform = mTransform;
-		sphereData.sceneObject = mActiveSO;
-		sphereData.pickable = mPickable;
+		coneData.idx = mCurrentIdx++;
+		coneData.base = base;
+		coneData.radius = radius;
+		coneData.color = mColor;
+		coneData.transform = mTransform;
+		coneData.sceneObject = mActiveSO;
+		coneData.pickable = mPickable;
+		coneData.scale = scale;
 
 
 		mDrawHelper->wireCone(base, normal, height, radius, scale);
 		mDrawHelper->wireCone(base, normal, height, radius, scale);
-		mIdxToSceneObjectMap[sphereData.idx] = mActiveSO;
+		mIdxToSceneObjectMap[coneData.idx] = mActiveSO;
 	}
 	}
 
 
 	void GizmoManager::drawLine(const Vector3& start, const Vector3& end)
 	void GizmoManager::drawLine(const Vector3& start, const Vector3& end)

+ 2 - 2
Source/BansheeEditor/Source/BsHandleSlider.cpp

@@ -8,8 +8,8 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	HandleSlider::HandleSlider(bool fixedScale, UINT64 layer)
 	HandleSlider::HandleSlider(bool fixedScale, UINT64 layer)
-		: mFixedScale(fixedScale), mLayer(layer), mScale(Vector3::ONE), mDistanceScale(1.0f), mState(State::Inactive)
-		, mEnabled(true), mTransformDirty(true)
+		: mFixedScale(fixedScale), mLayer(layer), mPosition(BsZero), mRotation(BsZero), mScale(Vector3::ONE)
+		, mDistanceScale(1.0f), mState(State::Inactive), mEnabled(true), mTransformDirty(true)
 	{
 	{
 
 
 	}
 	}

+ 3 - 1
Source/BansheeEditor/Source/BsHandleSliderDisc.cpp

@@ -13,7 +13,8 @@ namespace BansheeEngine
 	const float HandleSliderDisc::TORUS_RADIUS = 0.1f;
 	const float HandleSliderDisc::TORUS_RADIUS = 0.1f;
 
 
 	HandleSliderDisc::HandleSliderDisc(const Vector3& normal, float radius, bool fixedScale, UINT64 layer)
 	HandleSliderDisc::HandleSliderDisc(const Vector3& normal, float radius, bool fixedScale, UINT64 layer)
-		:HandleSlider(fixedScale, layer), mNormal(normal), mRadius(radius), mHasCutoffPlane(false), mDelta(0.0f)
+		: HandleSlider(fixedScale, layer), mNormal(normal), mRadius(radius), mHasCutoffPlane(false), mDirection(BsZero)
+		, mStartPosition(BsZero), mDelta(0.0f)
 	{
 	{
 		mCollider = Torus(normal, radius, TORUS_RADIUS);
 		mCollider = Torus(normal, radius, TORUS_RADIUS);
 
 
@@ -139,6 +140,7 @@ namespace BansheeEngine
 
 
 		Vector3 clampedAnglePoint;
 		Vector3 clampedAnglePoint;
 		clampedAnglePoint.x = Math::cos(clampedAngle) * radius;
 		clampedAnglePoint.x = Math::cos(clampedAngle) * radius;
+		clampedAnglePoint.y = 0.0f;
 		clampedAnglePoint.z = Math::sin(clampedAngle) * radius;
 		clampedAnglePoint.z = Math::sin(clampedAngle) * radius;
 
 
 		return worldToPlane.inverseAffine().multiplyAffine(clampedAnglePoint);
 		return worldToPlane.inverseAffine().multiplyAffine(clampedAnglePoint);

+ 2 - 3
Source/BansheeEditor/Source/BsHandleSliderLine.cpp

@@ -14,10 +14,9 @@ namespace BansheeEngine
 	const float HandleSliderLine::SPHERE_RADIUS = 0.2f;
 	const float HandleSliderLine::SPHERE_RADIUS = 0.2f;
 
 
 	HandleSliderLine::HandleSliderLine(const Vector3& direction, float length, bool fixedScale, UINT64 layer)
 	HandleSliderLine::HandleSliderLine(const Vector3& direction, float length, bool fixedScale, UINT64 layer)
-		:HandleSlider(fixedScale, layer), mLength(length), mDelta(0.0f)
+		: HandleSlider(fixedScale, layer), mDirection(Vector3::normalize(direction)), mLength(length), mDelta(0.0f)
+		, mStartPosition(BsZero)
 	{
 	{
-		mDirection = Vector3::normalize(direction);
-
 		Vector3 start = Vector3::ZERO;
 		Vector3 start = Vector3::ZERO;
 		Vector3 end = start + mDirection * length;
 		Vector3 end = start + mDirection * length;
 
 

+ 2 - 4
Source/BansheeEditor/Source/BsHandleSliderPlane.cpp

@@ -11,11 +11,9 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	HandleSliderPlane::HandleSliderPlane(const Vector3& dir1, const Vector3& dir2, float length, bool fixedScale, UINT64 layer)
 	HandleSliderPlane::HandleSliderPlane(const Vector3& dir1, const Vector3& dir2, float length, bool fixedScale, UINT64 layer)
-		:HandleSlider(fixedScale, layer), mLength(length)
+		: HandleSlider(fixedScale, layer), mDirection1(Vector3::normalize(dir1)), mLength(length)
+		, mDirection2(Vector3::normalize(dir2)), mDelta(BsZero), mStartPlanePosition(BsZero), mStartClickPosition(BsZero)
 	{
 	{
-		mDirection1 = Vector3::normalize(dir1);
-		mDirection2 = Vector3::normalize(dir2);
-
 		float halfLength = length * 0.5f;
 		float halfLength = length * 0.5f;
 		std::array<Vector3, 2> axes = {{ mDirection1, mDirection2 }};
 		std::array<Vector3, 2> axes = {{ mDirection1, mDirection2 }};
 		std::array<float, 2> extents = {{ halfLength, halfLength }};
 		std::array<float, 2> extents = {{ halfLength, halfLength }};

+ 0 - 2
Source/BansheeEngine/Include/BsGUIWidget.h

@@ -171,8 +171,6 @@ namespace BansheeEngine
 		/**	Called when the parent window gained or lost focus. */
 		/**	Called when the parent window gained or lost focus. */
 		virtual void ownerWindowFocusChanged();
 		virtual void ownerWindowFocusChanged();
 	private:
 	private:
-		GUIWidget(const GUIWidget& other) { }
-
 		/**	Calculates widget bounds using the bounds of all child elements. */
 		/**	Calculates widget bounds using the bounds of all child elements. */
 		void updateBounds() const;
 		void updateBounds() const;
 
 

+ 2 - 2
Source/BansheeEngine/Source/BsDrawHelper.cpp

@@ -140,7 +140,7 @@ namespace BansheeEngine
 		mLineListData.push_back(LineListData());
 		mLineListData.push_back(LineListData());
 		LineListData& lineListData = mLineListData.back();
 		LineListData& lineListData = mLineListData.back();
 
 
-		Vector3 center;
+		Vector3 center(BsZero);
 		for (auto& point : lines)
 		for (auto& point : lines)
 			center += point;
 			center += point;
 
 
@@ -1154,7 +1154,7 @@ namespace BansheeEngine
 
 
 					Vector3 translation = text2DData.transform.getTranslation();
 					Vector3 translation = text2DData.transform.getTranslation();
 					
 					
-					Vector2 accum;
+					Vector2 accum(BsZero);
 					for (UINT32 j = 0; j < shapeData.numVertices; j++)
 					for (UINT32 j = 0; j < shapeData.numVertices; j++)
 						accum += tempVertices[j];
 						accum += tempVertices[j];
 
 

+ 3 - 2
Source/BansheeEngine/Source/BsGUICanvas.cpp

@@ -22,7 +22,8 @@ namespace BansheeEngine
 	}
 	}
 
 
 	GUICanvas::GUICanvas(const String& styleName, const GUIDimensions& dimensions)
 	GUICanvas::GUICanvas(const String& styleName, const GUIDimensions& dimensions)
-		:GUIElement(styleName, dimensions), mNumRenderElements(0), mDepthRange(1), mForceTriangleBuild(false)
+		: GUIElement(styleName, dimensions), mNumRenderElements(0), mDepthRange(1), mLastOffset(BsZero)
+		, mForceTriangleBuild(false)
 	{
 	{
 
 
 	}
 	}
@@ -410,7 +411,7 @@ namespace BansheeEngine
 			UINT8* uvDst = uvs + startVert * vertexStride;
 			UINT8* uvDst = uvs + startVert * vertexStride;
 			UINT32* indexDst = indices + startIndex;
 			UINT32* indexDst = indices + startIndex;
 
 
-			Vector2 zeroUV;
+			Vector2 zeroUV(BsZero);
 			for(UINT32 i = 0; i < element.clippedNumVertices; i++)
 			for(UINT32 i = 0; i < element.clippedNumVertices; i++)
 			{
 			{
 				memcpy(vertDst, &mClippedVertices[element.clippedVertexStart + i], sizeof(Vector2));
 				memcpy(vertDst, &mClippedVertices[element.clippedVertexStart + i], sizeof(Vector2));

+ 4 - 4
Source/BansheeEngine/Source/BsGUIWidget.cpp

@@ -15,15 +15,15 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	GUIWidget::GUIWidget(const SPtr<Camera>& camera)
 	GUIWidget::GUIWidget(const SPtr<Camera>& camera)
-		: mCamera(camera), mPanel(nullptr), mDepth(0), mIsActive(true), mTransform(Matrix4::IDENTITY), mCachedRTId(0)
-		, mWidgetIsDirty(false)
+		: mCamera(camera), mPanel(nullptr), mDepth(0), mIsActive(true), mPosition(BsZero), mRotation(BsIdentity)
+		, mScale(Vector3::ONE), mTransform(BsIdentity), mCachedRTId(0), mWidgetIsDirty(false)
 	{
 	{
 		construct(camera);
 		construct(camera);
 	}
 	}
 
 
 	GUIWidget::GUIWidget(const HCamera& camera)
 	GUIWidget::GUIWidget(const HCamera& camera)
-		: mCamera(camera->_getCamera()), mPanel(nullptr), mDepth(0), mIsActive(true), mTransform(Matrix4::IDENTITY)
-		, mCachedRTId(0), mWidgetIsDirty(false)
+		: mCamera(camera->_getCamera()), mPanel(nullptr), mDepth(0), mIsActive(true), mPosition(BsZero)
+		, mRotation(BsIdentity), mScale(Vector3::ONE), mTransform(BsIdentity), mCachedRTId(0), mWidgetIsDirty(false)
 	{
 	{
 		construct(mCamera);
 		construct(mCamera);
 	}
 	}

+ 8 - 4
Source/BansheeEngine/Source/BsLight.cpp

@@ -11,16 +11,17 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	LightBase::LightBase()
 	LightBase::LightBase()
-		: mType(LightType::Point), mCastsShadows(false), mColor(Color::White), mRange(10.0f), mIntensity(5.0f)
-		, mSpotAngle(45), mSpotFalloffAngle(35.0f), mIsActive(true), mPhysCorrectAtten(true)
+		: mPosition(BsZero), mRotation(BsIdentity), mType(LightType::Point), mCastsShadows(false), mColor(Color::White)
+		, mRange(10.0f), mIntensity(5.0f), mSpotAngle(45), mSpotFalloffAngle(35.0f), mIsActive(true), mPhysCorrectAtten(true)
 	{
 	{
 		updatePhysicallyCorrectRange();
 		updatePhysicallyCorrectRange();
 	}
 	}
 
 
 	LightBase::LightBase(LightType type, Color color,
 	LightBase::LightBase(LightType type, Color color,
 		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
 		float intensity, float range, bool castsShadows, Degree spotAngle, Degree spotFalloffAngle)
-		: mType(type), mCastsShadows(castsShadows), mColor(color), mRange(range), mIntensity(intensity)
-		, mSpotAngle(spotAngle), mSpotFalloffAngle(spotFalloffAngle), mIsActive(true), mPhysCorrectAtten(true)
+		: mPosition(BsZero), mRotation(BsIdentity), mType(type), mCastsShadows(castsShadows), mColor(color), mRange(range)
+		, mIntensity(intensity), mSpotAngle(spotAngle), mSpotFalloffAngle(spotFalloffAngle), mIsActive(true)
+		, mPhysCorrectAtten(true)
 	{
 	{
 		updatePhysicallyCorrectRange();
 		updatePhysicallyCorrectRange();
 	}
 	}
@@ -107,7 +108,10 @@ namespace BansheeEngine
 				offset = Vector3(0, 0, -(mRange - coneRadius));
 				offset = Vector3(0, 0, -(mRange - coneRadius));
 			}
 			}
 			else
 			else
+			{
 				radius = coneRadius;
 				radius = coneRadius;
+				offset = Vector3::ZERO;
+			}
 
 
 			Vector3 center = mPosition + mRotation.rotate(offset);
 			Vector3 center = mPosition + mRotation.rotate(offset);
 			mBounds = Sphere(center, radius);
 			mBounds = Sphere(center, radius);

+ 1 - 1
Source/BansheeEngine/Source/BsRenderable.cpp

@@ -26,7 +26,7 @@ namespace BansheeEngine
 
 
 	template<bool Core>
 	template<bool Core>
 	TRenderable<Core>::TRenderable()
 	TRenderable<Core>::TRenderable()
-		: mLayer(1), mUseOverrideBounds(false), mTransform(Matrix4::IDENTITY), mTransformNoScale(Matrix4::IDENTITY)
+		: mLayer(1), mUseOverrideBounds(false), mPosition(BsZero), mTransform(BsIdentity), mTransformNoScale(BsIdentity)
 		, mIsActive(true)
 		, mIsActive(true)
 	{
 	{
 		mMaterials.resize(1);
 		mMaterials.resize(1);

+ 1 - 1
Source/BansheeFBXImporter/Source/BsFBXUtility.cpp

@@ -10,7 +10,7 @@ namespace BansheeEngine
 	struct SmoothNormal
 	struct SmoothNormal
 	{
 	{
 		int group = 0;
 		int group = 0;
-		Vector3 normal;
+		Vector3 normal = Vector3::ZERO;
 
 
 		void addNormal(int group, const Vector3& normal)
 		void addNormal(int group, const Vector3& normal)
 		{
 		{

+ 1 - 0
Source/BansheePhysX/Source/BsPhysX.cpp

@@ -371,6 +371,7 @@ namespace BansheeEngine
 	{
 	{
 		output.point = fromPxVector(input.position);
 		output.point = fromPxVector(input.position);
 		output.normal = fromPxVector(input.normal);
 		output.normal = fromPxVector(input.normal);
+		output.uv = Vector2::ZERO;
 		output.distance = input.distance;
 		output.distance = input.distance;
 		output.triangleIdx = input.faceIndex;
 		output.triangleIdx = input.faceIndex;
 		output.colliderRaw = (Collider*)input.shape->userData;
 		output.colliderRaw = (Collider*)input.shape->userData;

+ 6 - 0
Source/BansheeUtility/Include/BsFwdDeclUtil.h

@@ -21,6 +21,12 @@ namespace BansheeEngine
 		ZYX
 		ZYX
 	};
 	};
 
 
+	/** Enum used for object construction specifying the object should be zero initializes. */
+	enum ZERO { BsZero };
+
+	/** Enum used for matrix/quaternion constructor specifying it should be initialized with an identity value. */
+	enum IDENTITY { BsIdentity };
+
 	/** @} */
 	/** @} */
 
 
 	/** @addtogroup Platform-Utility
 	/** @addtogroup Platform-Utility

+ 8 - 0
Source/BansheeUtility/Include/BsMatrix3.h

@@ -24,6 +24,14 @@ namespace BansheeEngine
     public:
     public:
 		Matrix3() {}
 		Matrix3() {}
 
 
+		Matrix3(ZERO zero)
+			:Matrix3(Matrix3::ZERO)
+		{ }
+
+		Matrix3(IDENTITY identity)
+			:Matrix3(Matrix3::IDENTITY)
+		{ }
+
         Matrix3(const Matrix3& mat)
         Matrix3(const Matrix3& mat)
 		{
 		{
 			memcpy(m, mat.m, 9*sizeof(float));
 			memcpy(m, mat.m, 9*sizeof(float));

+ 9 - 1
Source/BansheeUtility/Include/BsMatrix4.h

@@ -29,6 +29,14 @@ namespace BansheeEngine
         Matrix4()
         Matrix4()
         { }
         { }
 
 
+		Matrix4(ZERO zero)
+			:Matrix4(Matrix3::ZERO)
+		{ }
+
+		Matrix4(IDENTITY identity)
+			:Matrix4(Matrix3::IDENTITY)
+		{ }
+
         Matrix4(
         Matrix4(
             float m00, float m01, float m02, float m03,
             float m00, float m01, float m02, float m03,
             float m10, float m11, float m12, float m13,
             float m10, float m11, float m12, float m13,
@@ -401,7 +409,7 @@ namespace BansheeEngine
          */
          */
         Vector3 multiply(const Vector3& v) const
         Vector3 multiply(const Vector3& v) const
         {
         {
-            Vector3 r;
+            Vector3 r(BsZero);
 
 
             float fInvW = 1.0f / (m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3]);
             float fInvW = 1.0f / (m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3]);
 
 

+ 12 - 1
Source/BansheeUtility/Include/BsQuaternion.h

@@ -22,7 +22,18 @@ namespace BansheeEngine
 		};
 		};
 
 
     public:
     public:
-        Quaternion(float w = 1.0f, float x = 0.0f, float y = 0.0f, float z = 0.0f)
+		Quaternion()
+		{ }
+
+		Quaternion(ZERO zero)
+			:x(0.0f), y(0.0f), z(0.0f), w(0.0f)
+		{ }
+
+		Quaternion(IDENTITY identity)
+			:x(0.0f), y(0.0f), z(0.0f), w(1.0f)
+		{ }
+
+        Quaternion(float w, float x, float y, float z)
 			:x(x), y(y), z(z), w(w)
 			:x(x), y(y), z(z), w(w)
 		{ }
 		{ }
 
 

+ 5 - 2
Source/BansheeUtility/Include/BsVector2.h

@@ -18,7 +18,10 @@ namespace BansheeEngine
         float x, y;
         float x, y;
 
 
     public:
     public:
-        Vector2()
+		Vector2()
+		{ }
+
+        Vector2(ZERO zero)
 			:x(0.0f), y(0.0f)
 			:x(0.0f), y(0.0f)
         { }
         { }
 
 
@@ -331,7 +334,7 @@ namespace BansheeEngine
 			float len = Math::sqrt(val.x * val.x + val.y * val.y);
 			float len = Math::sqrt(val.x * val.x + val.y * val.y);
 
 
 			// Will also work for zero-sized vectors, but will change nothing
 			// Will also work for zero-sized vectors, but will change nothing
-			Vector2 normalizedVec;
+			Vector2 normalizedVec = val;
 			if (len > 1e-08)
 			if (len > 1e-08)
 			{
 			{
 				float invLen = 1.0f / len;
 				float invLen = 1.0f / len;

+ 4 - 1
Source/BansheeUtility/Include/BsVector3.h

@@ -20,7 +20,10 @@ namespace BansheeEngine
 		float x, y, z;
 		float x, y, z;
 
 
     public:
     public:
-        Vector3()
+		Vector3()
+		{ }
+
+        Vector3(ZERO zero)
 			:x(0.0f), y(0.0f), z(0.0f)
 			:x(0.0f), y(0.0f), z(0.0f)
         { }
         { }
 
 

+ 4 - 1
Source/BansheeUtility/Include/BsVector4.h

@@ -18,7 +18,10 @@ namespace BansheeEngine
         float x, y, z, w;
         float x, y, z, w;
 
 
     public:
     public:
-        Vector4()
+		Vector4()
+		{ }
+
+        Vector4(ZERO zero)
 			:x(0.0f), y(0.0f), z(0.0f), w(0.0f)
 			:x(0.0f), y(0.0f), z(0.0f), w(0.0f)
         { }
         { }
 
 

+ 5 - 6
Source/BansheeUtility/Source/BsAABox.cpp

@@ -73,7 +73,7 @@ namespace BansheeEngine
 		case NEAR_RIGHT_TOP:
 		case NEAR_RIGHT_TOP:
 			return mMaximum;
 			return mMaximum;
 		default:
 		default:
-			return Vector3();
+			return Vector3(BsZero);
 		}
 		}
 	}
 	}
 
 
@@ -95,12 +95,11 @@ namespace BansheeEngine
 
 
 	void AABox::transform(const Matrix4& matrix)
 	void AABox::transform(const Matrix4& matrix)
 	{
 	{
-		Vector3 oldMin, oldMax, currentCorner;
-
 		// Getting the old values so that we can use the existing merge method.
 		// Getting the old values so that we can use the existing merge method.
-		oldMin = mMinimum;
-		oldMax = mMaximum;
+		Vector3 oldMin = mMinimum;
+		Vector3 oldMax = mMaximum;
 
 
+		Vector3 currentCorner;
 		// We sequentially compute the corners in the following order :
 		// We sequentially compute the corners in the following order :
 		// 0, 6, 5, 1, 2, 4, 7, 3
 		// 0, 6, 5, 1, 2, 4, 7, 3
 		// This sequence allows us to only change one member at a time to get at all corners.
 		// This sequence allows us to only change one member at a time to get at all corners.
@@ -215,7 +214,7 @@ namespace BansheeEngine
 		float lowt = 0.0f;
 		float lowt = 0.0f;
 		float t;
 		float t;
 		bool hit = false;
 		bool hit = false;
-		Vector3 hitpoint;
+		Vector3 hitpoint(BsZero);
 		const Vector3& min = getMin();
 		const Vector3& min = getMin();
 		const Vector3& max = getMax();
 		const Vector3& max = getMax();
 		const Vector3& rayorig = ray.getOrigin();
 		const Vector3& rayorig = ray.getOrigin();

+ 1 - 0
Source/BansheeUtility/Source/BsLineSegment3.cpp

@@ -6,6 +6,7 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	LineSegment3::LineSegment3()
 	LineSegment3::LineSegment3()
+		:mStart(BsZero), mEnd(BsZero)
 	{ }
 	{ }
 
 
 	LineSegment3::LineSegment3(const Vector3& start, const Vector3& end)
 	LineSegment3::LineSegment3(const Vector3& start, const Vector3& end)

+ 9 - 17
Source/BansheeUtility/Source/BsPlane.cpp

@@ -10,32 +10,24 @@
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {
 	Plane::Plane()
 	Plane::Plane()
-	{
-		normal = Vector3::ZERO;
-		d = 0.0;
-	}
+		:normal(BsZero), d(0.0f)
+	{ }
 
 
 	Plane::Plane(const Plane& copy)
 	Plane::Plane(const Plane& copy)
-	{
-		normal = copy.normal;
-		d = copy.d;
-	}
+		:normal(copy.normal), d(copy.d)
+	{ }
 
 
 	Plane::Plane(const Vector3& normal, float d)
 	Plane::Plane(const Vector3& normal, float d)
-	{
-		this->normal = normal;
-		this->d = d;
-	}
+		:normal(normal), d(d)
+	{ }
 
 
 	Plane::Plane(float a, float b, float c, float _d)
 	Plane::Plane(float a, float b, float c, float _d)
-		: normal(a, b, c), d(_d)
+		:normal(a, b, c), d(_d)
 	{ }
 	{ }
 
 
 	Plane::Plane(const Vector3& normal, const Vector3& point)
 	Plane::Plane(const Vector3& normal, const Vector3& point)
-	{
-		this->normal = normal;
-		d = normal.dot(point);
-	}
+		:normal(normal), d(normal.dot(point))
+	{ }
 
 
 	Plane::Plane(const Vector3& point0, const Vector3& point1, const Vector3& point2)
 	Plane::Plane(const Vector3& point0, const Vector3& point1, const Vector3& point2)
 	{
 	{

+ 0 - 1
Source/BansheeUtility/Source/BsQuaternion.cpp

@@ -287,7 +287,6 @@ namespace BansheeEngine
 		Vector3 nrmForwardDir = Vector3::normalize(forwardDir);
 		Vector3 nrmForwardDir = Vector3::normalize(forwardDir);
 		Vector3 currentForwardDir = -zAxis();
 		Vector3 currentForwardDir = -zAxis();
 
 
-		Quaternion targetRotation;
 		if ((nrmForwardDir + currentForwardDir).squaredLength() < 0.00005f)
 		if ((nrmForwardDir + currentForwardDir).squaredLength() < 0.00005f)
 		{
 		{
 			// Oops, a 180 degree turn (infinite possible rotation axes)
 			// Oops, a 180 degree turn (infinite possible rotation axes)

+ 2 - 1
Source/BansheeUtility/Source/BsRect3.cpp

@@ -8,6 +8,7 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	Rect3::Rect3()
 	Rect3::Rect3()
+		:mCenter(BsZero), mAxisHorz(BsZero), mAxisVert(BsZero), mExtentHorz(0.0f), mExtentVert(0.0f)
 	{ }
 	{ }
 
 
 	Rect3::Rect3(const Vector3& center, const std::array<Vector3, 2>& axes,
 	Rect3::Rect3(const Vector3& center, const std::array<Vector3, 2>& axes,
@@ -25,7 +26,7 @@ namespace BansheeEngine
 
 
 		bool foundNearest = false;
 		bool foundNearest = false;
 		float t = 0.0f;
 		float t = 0.0f;
-		std::array<Vector3, 2> nearestPoints;
+		std::array<Vector3, 2> nearestPoints { Vector3::ZERO, Vector3::ZERO };
 		float distance = 0.0f;
 		float distance = 0.0f;
 
 
 		// Check if Ray intersects the rectangle
 		// Check if Ray intersects the rectangle

+ 1 - 1
Source/BansheeUtility/Source/BsTorus.cpp

@@ -8,7 +8,7 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	Torus::Torus()
 	Torus::Torus()
-		:outerRadius(0.0f), innerRadius(0.0f)
+		:normal(BsZero), outerRadius(0.0f), innerRadius(0.0f)
 	{ }
 	{ }
 
 
 	Torus::Torus(const Vector3& normal, float outerRadius, float innerRadius)
 	Torus::Torus(const Vector3& normal, float outerRadius, float innerRadius)

+ 3 - 0
Source/RenderBeast/Source/BsPostProcessing.cpp

@@ -259,6 +259,9 @@ namespace BansheeEngine
 		eyeAdaptationParams[2].x = Math::pow(2.0f, settings.exposureScale);
 		eyeAdaptationParams[2].x = Math::pow(2.0f, settings.exposureScale);
 		eyeAdaptationParams[2].y = frameDelta;
 		eyeAdaptationParams[2].y = frameDelta;
 
 
+		eyeAdaptationParams[2].z = 0.0f; // Unused
+		eyeAdaptationParams[2].w = 0.0f; // Unused
+
 		mParams.gEyeAdaptationParams.set(eyeAdaptationParams[0], 0);
 		mParams.gEyeAdaptationParams.set(eyeAdaptationParams[0], 0);
 		mParams.gEyeAdaptationParams.set(eyeAdaptationParams[1], 1);
 		mParams.gEyeAdaptationParams.set(eyeAdaptationParams[1], 1);
 		mParams.gEyeAdaptationParams.set(eyeAdaptationParams[2], 2);
 		mParams.gEyeAdaptationParams.set(eyeAdaptationParams[2], 2);

+ 9 - 9
Source/SBansheeEngine/Source/BsScriptSceneObject.cpp

@@ -200,7 +200,7 @@ namespace BansheeEngine
 		if (!checkIfDestroyed(nativeInstance))
 		if (!checkIfDestroyed(nativeInstance))
 			*value = nativeInstance->mSceneObject->getWorldPosition();
 			*value = nativeInstance->mSceneObject->getWorldPosition();
 		else
 		else
-			*value = Vector3();
+			*value = Vector3(BsZero);
 	}
 	}
 
 
 	void ScriptSceneObject::internal_getLocalPosition(ScriptSceneObject* nativeInstance, Vector3* value)
 	void ScriptSceneObject::internal_getLocalPosition(ScriptSceneObject* nativeInstance, Vector3* value)
@@ -208,7 +208,7 @@ namespace BansheeEngine
 		if (!checkIfDestroyed(nativeInstance))
 		if (!checkIfDestroyed(nativeInstance))
 			*value = nativeInstance->mSceneObject->getPosition();
 			*value = nativeInstance->mSceneObject->getPosition();
 		else
 		else
-			*value = Vector3();
+			*value = Vector3(BsZero);
 	}
 	}
 
 
 	void ScriptSceneObject::internal_getRotation(ScriptSceneObject* nativeInstance, Quaternion* value)
 	void ScriptSceneObject::internal_getRotation(ScriptSceneObject* nativeInstance, Quaternion* value)
@@ -216,7 +216,7 @@ namespace BansheeEngine
 		if (!checkIfDestroyed(nativeInstance))
 		if (!checkIfDestroyed(nativeInstance))
 			*value = nativeInstance->mSceneObject->getWorldRotation();
 			*value = nativeInstance->mSceneObject->getWorldRotation();
 		else
 		else
-			*value = Quaternion();
+			*value = Quaternion(BsIdentity);
 	}
 	}
 
 
 	void ScriptSceneObject::internal_getLocalRotation(ScriptSceneObject* nativeInstance, Quaternion* value)
 	void ScriptSceneObject::internal_getLocalRotation(ScriptSceneObject* nativeInstance, Quaternion* value)
@@ -224,7 +224,7 @@ namespace BansheeEngine
 		if (!checkIfDestroyed(nativeInstance))
 		if (!checkIfDestroyed(nativeInstance))
 			*value = nativeInstance->mSceneObject->getRotation();
 			*value = nativeInstance->mSceneObject->getRotation();
 		else
 		else
-			*value = Quaternion();
+			*value = Quaternion(BsIdentity);
 	}
 	}
 
 
 	void ScriptSceneObject::internal_getScale(ScriptSceneObject* nativeInstance, Vector3* value)
 	void ScriptSceneObject::internal_getScale(ScriptSceneObject* nativeInstance, Vector3* value)
@@ -232,7 +232,7 @@ namespace BansheeEngine
 		if (!checkIfDestroyed(nativeInstance))
 		if (!checkIfDestroyed(nativeInstance))
 			*value = nativeInstance->mSceneObject->getWorldScale();
 			*value = nativeInstance->mSceneObject->getWorldScale();
 		else
 		else
-			*value = Vector3();
+			*value = Vector3(Vector3::ONE);
 	}
 	}
 
 
 	void ScriptSceneObject::internal_getLocalScale(ScriptSceneObject* nativeInstance, Vector3* value)
 	void ScriptSceneObject::internal_getLocalScale(ScriptSceneObject* nativeInstance, Vector3* value)
@@ -240,7 +240,7 @@ namespace BansheeEngine
 		if (!checkIfDestroyed(nativeInstance))
 		if (!checkIfDestroyed(nativeInstance))
 			*value = nativeInstance->mSceneObject->getScale();
 			*value = nativeInstance->mSceneObject->getScale();
 		else
 		else
-			*value = Vector3();
+			*value = Vector3(Vector3::ONE);
 	}
 	}
 
 
 	void ScriptSceneObject::internal_setPosition(ScriptSceneObject* nativeInstance, Vector3* value)
 	void ScriptSceneObject::internal_setPosition(ScriptSceneObject* nativeInstance, Vector3* value)
@@ -342,7 +342,7 @@ namespace BansheeEngine
 		if (!checkIfDestroyed(nativeInstance))
 		if (!checkIfDestroyed(nativeInstance))
 			*value = nativeInstance->mSceneObject->getForward();
 			*value = nativeInstance->mSceneObject->getForward();
 		else
 		else
-			*value = Vector3();
+			*value = Vector3(-Vector3::UNIT_Z);
 	}
 	}
 
 
 	void ScriptSceneObject::internal_getUp(ScriptSceneObject* nativeInstance, Vector3* value)
 	void ScriptSceneObject::internal_getUp(ScriptSceneObject* nativeInstance, Vector3* value)
@@ -350,7 +350,7 @@ namespace BansheeEngine
 		if (!checkIfDestroyed(nativeInstance))
 		if (!checkIfDestroyed(nativeInstance))
 			*value = nativeInstance->mSceneObject->getUp();
 			*value = nativeInstance->mSceneObject->getUp();
 		else
 		else
-			*value = Vector3();
+			*value = Vector3(Vector3::UNIT_Y);
 	}
 	}
 
 
 	void ScriptSceneObject::internal_getRight(ScriptSceneObject* nativeInstance, Vector3* value)
 	void ScriptSceneObject::internal_getRight(ScriptSceneObject* nativeInstance, Vector3* value)
@@ -358,7 +358,7 @@ namespace BansheeEngine
 		if (!checkIfDestroyed(nativeInstance))
 		if (!checkIfDestroyed(nativeInstance))
 			*value = nativeInstance->mSceneObject->getRight();
 			*value = nativeInstance->mSceneObject->getRight();
 		else
 		else
-			*value = Vector3();
+			*value = Vector3(Vector3::UNIT_X);
 	}
 	}
 
 
 	void ScriptSceneObject::internal_destroy(ScriptSceneObject* nativeInstance, bool immediate)
 	void ScriptSceneObject::internal_destroy(ScriptSceneObject* nativeInstance, bool immediate)