Browse Source

Move a few inline function definitions to headers

Marc Legendre 9 years ago
parent
commit
fee099749f

+ 9 - 3
Source/BansheeUtility/Include/BsMemStack.h

@@ -262,7 +262,10 @@ namespace BansheeEngine
 	 */
 
 	/** @copydoc MemStackInternal::alloc() */
-	BS_UTILITY_EXPORT inline void* bs_stack_alloc(UINT32 amount);
+	BS_UTILITY_EXPORT inline void* bs_stack_alloc(UINT32 amount)
+	{
+		return (void*)MemStack::alloc(amount);
+	}
 
 	/**
 	 * Allocates enough memory to hold the specified type, on the stack, but does not initialize the object. 
@@ -348,7 +351,10 @@ namespace BansheeEngine
 	}
 
 	/** @copydoc MemStackInternal::dealloc() */
-	BS_UTILITY_EXPORT inline void bs_stack_free(void* data);
+	BS_UTILITY_EXPORT inline void bs_stack_free(void* data)
+	{
+		return MemStack::deallocLast((UINT8*)data);
+	}
 
 	/** @} */
 	/** @addtogroup Internal-Utility
@@ -390,4 +396,4 @@ namespace BansheeEngine
 
 	/** @} */
 	/** @} */
-}
+}

+ 21 - 2
Source/BansheeUtility/Include/BsVector3.h

@@ -2,6 +2,8 @@
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #pragma once
 
+#include <cmath>
+
 #include "BsPrerequisitesUtil.h"
 #include "BsRadian.h"
 
@@ -240,7 +242,10 @@ namespace BansheeEngine
         }
 
         /** Returns the length (magnitude) of the vector. */
-		inline float length() const;
+		inline float length() const
+		{
+			return std::sqrt(x * x + y * y + z * z);
+		}
 
         /** Returns the square of the length(magnitude) of the vector. */
         float squaredLength() const
@@ -267,7 +272,21 @@ namespace BansheeEngine
         }
 
         /** Normalizes the vector. */
-		inline float normalize();
+		inline float normalize()
+		{
+			float len = length();
+
+			// Will also work for zero-sized vectors, but will change nothing
+			if (len > 1e-08)
+			{
+				float invLen = 1.0f / len;
+				x *= invLen;
+				y *= invLen;
+				z *= invLen;
+			}
+			return len;
+		}
+
 
         /** Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both. */
         Vector3 cross(const Vector3& other) const

+ 1 - 11
Source/BansheeUtility/Source/BsMemStack.cpp

@@ -37,14 +37,4 @@ namespace BansheeEngine
 
 		ThreadMemStack->dealloc(data);
 	}
-
-	void* bs_stack_alloc(UINT32 numBytes)
-	{
-		return (void*)MemStack::alloc(numBytes);
-	}
-
-	void bs_stack_free(void* data)
-	{
-		return MemStack::deallocLast((UINT8*)data);
-	}
-}
+}

+ 0 - 21
Source/BansheeUtility/Source/BsVector3.cpp

@@ -12,27 +12,6 @@ namespace BansheeEngine
 
 	}
 
-	float Vector3::length() const
-	{
-		return Math::sqrt(x * x + y * y + z * z);
-	}
-
-	float Vector3::normalize()
-	{
-		float len = Math::sqrt(x * x + y * y + z * z);
-
-		// Will also work for zero-sized vectors, but will change nothing
-		if (len > 1e-08)
-		{
-			float invLen = 1.0f / len;
-			x *= invLen;
-			y *= invLen;
-			z *= invLen;
-		}
-
-		return len;
-	}
-
 	Radian Vector3::angleBetween(const Vector3& dest) const
 	{
 		float lenProduct = length() * dest.length();