Browse Source

BansheeUtility and BansheeCore now compiles fine with Clang (no errors, no warnings)
CMake now includes .cs projects in generated VS solution
WIP Utilities manual

BearishSun 9 years ago
parent
commit
4c421e2f74
100 changed files with 653 additions and 451 deletions
  1. 1 0
      .gitignore
  2. 199 0
      Documentation/Manuals/Native/utilities.md
  3. 1 1
      Source/BansheeCore/Include/BsCCharacterController.h
  4. 2 0
      Source/BansheeCore/Include/BsCCollider.h
  5. 1 0
      Source/BansheeCore/Include/BsCJoint.h
  6. 2 0
      Source/BansheeCore/Include/BsCRigidbody.h
  7. 1 0
      Source/BansheeCore/Include/BsCollider.h
  8. 19 18
      Source/BansheeCore/Include/BsCommandQueue.h
  9. 1 0
      Source/BansheeCore/Include/BsFCollider.h
  10. 2 0
      Source/BansheeCore/Include/BsFont.h
  11. 1 9
      Source/BansheeCore/Include/BsGameObjectHandle.h
  12. 40 44
      Source/BansheeCore/Include/BsGpuParam.h
  13. 21 22
      Source/BansheeCore/Include/BsGpuParams.h
  14. 1 1
      Source/BansheeCore/Include/BsGpuProgram.h
  15. 2 2
      Source/BansheeCore/Include/BsHString.h
  16. 3 3
      Source/BansheeCore/Include/BsInputFwd.h
  17. 2 1
      Source/BansheeCore/Include/BsJoint.h
  18. 30 33
      Source/BansheeCore/Include/BsMaterial.h
  19. 2 2
      Source/BansheeCore/Include/BsMaterialParam.h
  20. 1 1
      Source/BansheeCore/Include/BsMeshBaseRTTI.h
  21. 1 1
      Source/BansheeCore/Include/BsMeshDataRTTI.h
  22. 1 1
      Source/BansheeCore/Include/BsMeshRTTI.h
  23. 4 4
      Source/BansheeCore/Include/BsOSInputHandler.h
  24. 5 5
      Source/BansheeCore/Include/BsPlatform.h
  25. 2 0
      Source/BansheeCore/Include/BsPrefab.h
  26. 2 0
      Source/BansheeCore/Include/BsPrefabDiff.h
  27. 2 2
      Source/BansheeCore/Include/BsProfilerCPU.h
  28. 3 3
      Source/BansheeCore/Include/BsRenderStats.h
  29. 1 0
      Source/BansheeCore/Include/BsRenderTarget.h
  30. 1 1
      Source/BansheeCore/Include/BsRenderTexture.h
  31. 1 1
      Source/BansheeCore/Include/BsRenderWindow.h
  32. 27 31
      Source/BansheeCore/Include/BsResourceHandle.h
  33. 2 2
      Source/BansheeCore/Include/BsSamplerState.h
  34. 9 12
      Source/BansheeCore/Include/BsShader.h
  35. 1 1
      Source/BansheeCore/Include/BsShaderRTTI.h
  36. 1 1
      Source/BansheeCore/Include/BsStringTable.h
  37. 8 4
      Source/BansheeCore/Include/BsTechnique.h
  38. 1 1
      Source/BansheeCore/Include/BsVertexDataDescRTTI.h
  39. 1 1
      Source/BansheeCore/Include/BsVertexDeclarationRTTI.h
  40. 2 2
      Source/BansheeCore/Include/Win32/BsWin32DropTarget.h
  41. 1 1
      Source/BansheeCore/Source/BsComponent.cpp
  42. 2 2
      Source/BansheeCore/Source/BsCoreApplication.cpp
  43. 1 1
      Source/BansheeCore/Source/BsCoreObject.cpp
  44. 2 4
      Source/BansheeCore/Source/BsCoreObjectManager.cpp
  45. 3 3
      Source/BansheeCore/Source/BsCoreThread.cpp
  46. 1 1
      Source/BansheeCore/Source/BsGameObject.cpp
  47. 2 1
      Source/BansheeCore/Source/BsGpuBuffer.cpp
  48. 5 5
      Source/BansheeCore/Source/BsGpuParam.cpp
  49. 8 8
      Source/BansheeCore/Source/BsGpuParamBlockBuffer.cpp
  50. 6 6
      Source/BansheeCore/Source/BsGpuParams.cpp
  51. 4 5
      Source/BansheeCore/Source/BsGpuProgram.cpp
  52. 1 1
      Source/BansheeCore/Source/BsGpuProgramManager.cpp
  53. 1 1
      Source/BansheeCore/Source/BsGpuResourceData.cpp
  54. 1 1
      Source/BansheeCore/Source/BsIndexBuffer.cpp
  55. 1 1
      Source/BansheeCore/Source/BsInput.cpp
  56. 5 4
      Source/BansheeCore/Source/BsMaterial.cpp
  57. 2 0
      Source/BansheeCore/Source/BsMaterialParams.cpp
  58. 4 5
      Source/BansheeCore/Source/BsMesh.cpp
  59. 4 4
      Source/BansheeCore/Source/BsMeshBase.cpp
  60. 1 1
      Source/BansheeCore/Source/BsMeshData.cpp
  61. 3 5
      Source/BansheeCore/Source/BsMeshHeap.cpp
  62. 1 1
      Source/BansheeCore/Source/BsMeshUtility.cpp
  63. 2 2
      Source/BansheeCore/Source/BsMultiRenderTexture.cpp
  64. 7 5
      Source/BansheeCore/Source/BsOSInputHandler.cpp
  65. 7 0
      Source/BansheeCore/Source/BsPhysics.cpp
  66. 2 5
      Source/BansheeCore/Source/BsPixelUtil.cpp
  67. 2 2
      Source/BansheeCore/Source/BsPlatform.cpp
  68. 31 7
      Source/BansheeCore/Source/BsProfilerCPU.cpp
  69. 1 1
      Source/BansheeCore/Source/BsRenderStateManager.cpp
  70. 1 1
      Source/BansheeCore/Source/BsRenderTexture.cpp
  71. 1 1
      Source/BansheeCore/Source/BsSavedResourceData.cpp
  72. 5 5
      Source/BansheeCore/Source/BsSceneObject.cpp
  73. 8 8
      Source/BansheeCore/Source/BsShader.cpp
  74. 1 1
      Source/BansheeCore/Source/BsStringTable.cpp
  75. 5 6
      Source/BansheeCore/Source/BsTextData.cpp
  76. 2 3
      Source/BansheeCore/Source/BsTexture.cpp
  77. 1 1
      Source/BansheeCore/Source/BsTextureView.cpp
  78. 1 1
      Source/BansheeCore/Source/BsTransientMesh.cpp
  79. 2 3
      Source/BansheeCore/Source/BsVertexDataDesc.cpp
  80. 8 0
      Source/BansheeCore/Source/BsVertexDeclaration.cpp
  81. 3 3
      Source/BansheeCore/Source/BsViewport.cpp
  82. 0 2
      Source/BansheeCore/Source/Win32/BsWin32BrowseDialogs.cpp
  83. 3 10
      Source/BansheeCore/Source/Win32/BsWin32FolderMonitor.cpp
  84. 4 4
      Source/BansheeCore/Source/Win32/BsWin32Platform.cpp
  85. 2 2
      Source/BansheeEngine/Source/BsHEString.cpp
  86. 8 8
      Source/BansheeUtility/Include/BsBitwise.h
  87. 4 4
      Source/BansheeUtility/Include/BsColor.h
  88. 2 0
      Source/BansheeUtility/Include/BsFlags.h
  89. 2 2
      Source/BansheeUtility/Include/BsFrameAlloc.h
  90. 10 10
      Source/BansheeUtility/Include/BsPlatformDefines.h
  91. 3 1
      Source/BansheeUtility/Include/BsPrerequisitesUtil.h
  92. 1 1
      Source/BansheeUtility/Include/BsRTTIPlainField.h
  93. 35 35
      Source/BansheeUtility/Include/BsRTTIType.h
  94. 2 26
      Source/BansheeUtility/Include/BsStdHeaders.h
  95. 4 4
      Source/BansheeUtility/Include/BsString.h
  96. 2 2
      Source/BansheeUtility/Include/BsThreadDefines.h
  97. 2 0
      Source/BansheeUtility/Include/ThirdParty/md5.h
  98. 4 4
      Source/BansheeUtility/Include/Win32/BsWin32Window.h
  99. 9 8
      Source/BansheeUtility/Source/BsBinarySerializer.cpp
  100. 0 2
      Source/BansheeUtility/Source/BsDynLib.cpp

+ 1 - 0
.gitignore

@@ -13,3 +13,4 @@ Documentation/html
 *.aps
 *.opendb
 /Build/VS2015/BansheeEngine.VC.db
+/Build/Generated

+ 199 - 0
Documentation/Manuals/Native/utilities.md

@@ -0,0 +1,199 @@
+Utilities									{#utilities}
+===============
+[TOC]
+
+This manual will quickly go over all the important utility systems commonly used by Banshee. We won't go into major detail about these features, but will rather point you towards the relevant API documentation.
+
+# Module {#utilities_a}
+A @ref BansheeEngine::Module<T> "Module<T>" is a specialized form of singleton used for many of Banshee's systems. Unlike normal singletons it requires manual startup and shutdown, which solves many of the problems associated with traditional singletons.
+
+To use it for your own objects, simply inherit from it:
+~~~~~~~~~~~~~{.cpp}
+class MyModule : public Module<MyModule>
+{ };
+~~~~~~~~~~~~~
+
+Use @ref BansheeEngine::Module<T>::startUp "Module<T>::startUp" to start it up. Once started use @ref BansheeEngine::Module<T>::instance "Module<T>::instance" to access its instance. Once done with it call @ref BansheeEngine::Module<T>::shutDown "Module<T>::shutDown" to release it. For example:
+~~~~~~~~~~~~~{.cpp}
+MyModule::startUp();
+MyModule::instance().doSomething();
+MyModule::shutDown();
+~~~~~~~~~~~~~
+
+# Path {#utilities_b}
+Use @ref BansheeEngine::Path "Path" to manipulate file/folder paths. Initialize it with a path string and then call various methods to manipulate it. It is recommended to always store paths using @ref BansheeEngine::Path "Path" instead of raw strings.
+
+Some of the things you can do once a @ref BansheeEngine::Path "Path" is constructed:
+ - Retrieve the filename using @ref BansheeEngine::Path::getFilename "Path::getFilename"
+ - Retrieve the filename extension using @ref BansheeEngine::Path::getExtension "Path::getExtension"
+ - Get last element of path, either file or directory using @ref BansheeEngine::Path::getTail "Path::getTail"
+ - Iterate over directories, get drive, combine paths, convert relative to absolute paths and vice versa, and more...
+ 
+For example:
+~~~~~~~~~~~~~{.cpp}
+Path myPath("C:\\Path\\To\\File.txt");
+
+String filename = myPath.getFilename(); // Returns file
+myPath.setExtension(".jpg"); // Path is now "C:\Path\To\File.jpg"
+myPath.makeRelative("C:\\Path"); // Path is now "To\File.jpg"
+
+Path a("C:\\Path\\To\\");
+Path b("File.txt");
+Path combined = a + b; // // Path is now "C:\Path\To\File.txt"
+~~~~~~~~~~~~~
+ 
+All @ref BansheeEngine::Path "Path" methods that return strings come in two variants, one that returns a narrow (8-bit) character string like @ref BansheeEngine::Path::getFilename "Path::getFilename", and one that contains wide character string like @ref BansheeEngine::Path::getWFilename "Path::getWFilename".
+
+When setting paths be careful with setting backslashes or slashes at the end of the path. Path with a no backslash/slash on the end will be interpreted as a file path, and path with a backslash/slash will be interpreted as a folder path. For example:
+ - "C:\MyFolder" - "MyFolder" interpreted as a file, @ref BansheeEngine::Path::getFilename "Path::getFilename" returns "MyFolder"
+ - "C:\MyFolder\" - "MyFolder" interpreted as a folder, @ref BansheeEngine::Path::getFilename "Path::getFilename" returns an empty string
+ 
+# File system {#utilities_c}
+The @ref BansheeEngine::FileSystem "FileSystem" module allows you to open and create files, create folders, move/copy/remove files and folders, iterate all folder/files in a folder, get file size, check if folder/folder exists, get working path and others.
+
+An example creating a folder and a file:
+~~~~~~~~~~~~~{.cpp}
+FileSystem::createDir("C:\\Path\\To\\");
+SPtr<DataStreamPtr> fileStream = FileSystem::createAndOpenFile("C:\\Path\\To\\File.txt");
+... write to data stream...
+~~~~~~~~~~~~~
+# Data streams {#utilities_d}
+@ref BansheeEngine::DataStream "Data streams" allow you to easily write/read binary/text data from/to disk/memory/etc. The two primary types of streams are @ref BansheeEngine::MemoryDataStream "MemoryDataStream" for reading/writing directly to memory, and @ref BansheeEngine::FileDataStream "FileDataStream" for reading/writing to a file.
+
+You create memory streams by providing them with a pointer and size of a memory buffer, while you create file streams by calling @ref BansheeEngine::FileSystem::openFile "FileSystem::openFile" or @ref BansheeEngine::FileSystem::createAndOpenFile "FileSystem::createAndOpenFile". Once you are done with a stream make sure to close it by calling @ref BansheeEngine::DataStream::close "DataStream::close". Stream will also be automatically closed when it goes out of scope.
+
+Once you have a stream you can seek to a position within a stream and read/write to it. For example:
+~~~~~~~~~~~~~{.cpp}
+SPtr<DataStreamPtr> fileStream = FileSystem::createAndOpenFile("C:\\Path\\To\\File.txt");
+// Write some string data
+fileStream.writeString("Writing to a file");
+// Write some binary data
+UINT8* myBuffer = bs_alloc(1024);
+... fill up the buffer with some data ...
+fileStream.write(myBuffer, 1024);
+
+fileStream.close();
+~~~~~~~~~~~~~
+ 
+# Events {#utilities_e}
+@ref BansheeEngine::TEvent<RetType, Args> "Events" allow your objects to expose events that may trigger during execution. External objects interested in those events can then register callbacks with those events and be notified when they happen. They are useful because they allow two objects to communicate without necessarily knowing about each other's types, which can reduce class coupling and improve design.
+
+When creating an event, all you need to do it specify a format of the callback it sends out, for example:
+~~~~~~~~~~~~~{.cpp}
+class MySystem
+{
+	static Event<void()> myEvent; // Callback with no parameters
+	static Event<void(UINT32)> myEvent2; // Callback with a UINT32 parameter
+};
+~~~~~~~~~~~~~
+
+Then an external object can register itself with an event by calling @ref BansheeEngine::TEvent<RetType, Args> "Event::connect". This method will return an @ref BansheeEngine::HEvent "HEvent" handle. You can use this handle to manually disconnect from the event by calling @ref BansheeEngine::HEvent::disconnect "HEvent::disconnect". For example:
+~~~~~~~~~~~~~{.cpp}
+// Subscribe to an event we defined previously
+// Simply pass a function pointer matching the callback
+HEvent eventHandle = MySystem::myEvent2.connect(&myEventReceiver);
+
+void myEventReceiver(UINT32 val)
+{
+	// Do something
+}
+~~~~~~~~~~~~~
+
+When using non-static class methods as callbacks, things get a little bit more complicated. This is because each such method by default expects a pointer to an instance of itself (`this` pointer). This is normally hidden from the programmer and happens under the hood, but we must handle it when dealing with callbacks. We can do this by using `std::bind` which allows us to replace function arguments with constant values. For example:
+~~~~~~~~~~~~~{.cpp}
+class EventReceiver
+{
+	EventReceiver()
+	{
+		// Convert a method with signature void(EventReceiver*, UINT32) into void(UINT32) by binding the "EventReceiver*"
+		// argument to the value of "this". Read up on the C++ library for more information about std::bind.
+		MySystem::myEvent2.connect(std::bind(&EventReceiver::myEventReceiver, this, std::placeholders::_1));
+	}
+	
+	void myEventReceiver(UINT32 val)
+	{
+		// Do something
+	}
+};
+~~~~~~~~~~~~~
+
+Then when an object is ready to trigger an event simply call it like a functor:
+~~~~~~~~~~~~~{.cpp}
+MySystem::myEvent(); // Trigger an event with no arguments
+MySystem::myEvent2(5); // Trigger an event with a single argument
+~~~~~~~~~~~~~
+
+# Any {#utilities_f}
+Use the @ref BansheeEngine::Any "Any" type to easily store any kind of object in it. For example:
+~~~~~~~~~~~~~{.cpp}
+Any var1 = Vector<String>();
+
+struct MyStruct { int a; };
+Any var2 = MyStruct();
+~~~~~~~~~~~~~
+
+Use @ref BansheeEngine::any_cast "any_cast" and @ref BansheeEngine::any_cast_ref "any_cast_ref" to retrieve valid types from an @ref BansheeEngine::Any "Any" variable. For example:
+~~~~~~~~~~~~~{.cpp}
+Vector<String> val1 = any_cast<Vector<String>>(var1);
+MyStruct& val2 = any_cast_ref<MyStruct>(var2);
+~~~~~~~~~~~~~
+# Flags {#utilities_g}
+@ref BansheeEngine::Flags<Enum, Storage> "Flags" provide a wrapper around an `enum` and allow you to easily perform bitwise operations on them without having to cast to integers. For example when using raw C++ you must do something like this:
+~~~~~~~~~~~~~{.cpp}
+enum class MyFlag
+{
+	Flag1 = 1<<0,
+	Flag2 = 1<<1,
+	Flag3 = 1<<2
+};
+
+MyFlag combined = (MyFlag)((UINT32)MyFlag::Flag1 | (UINT32)MyFlag::Flag2);
+~~~~~~~~~~~~~
+
+Which is cumbersome. Flags require an additional step to define the enum, but after that allow you to manipulate values much more nicely. 
+
+To create @ref BansheeEngine::Flags<Enum, Storage> "Flags" for an enum simply define a `typedef` with your enum type provided as the template parameter. You must also follow that definition with a @ref BS_FLAGS_OPERATORS macro in order to ensure all operators are properly defined. For example:
+~~~~~~~~~~~~~{.cpp}
+typedef Flags<MyFlag> MyFlags;
+BS_FLAGS_OPERATORS(MyFlag)
+~~~~~~~~~~~~~
+
+Now you can do something like this:
+~~~~~~~~~~~~~{.cpp}
+MyFlags combined = MyFlag::Flag1 | MyFlag::Flag2;
+~~~~~~~~~~~~~
+# String {#utilities_h}
+Banshee uses @ref BansheeEngine::String "String" for narrow character strings (8-bit) and @ref BansheeEngine::WString "WString" for wide character strings. Wide character strings are different size depending on platform.
+
+A variety of string manipulation functionality is provided in @ref BansheeEngine::StringUtil "StringUtil", like matching, replacing, comparing, formating and similar.
+
+Conversion between various types (like int, float, bool, etc.) and string is provided via overloads of @ref BansheeEngine::toString "toString" and @ref BansheeEngine::toWString "toWString". You can also convert strings into different types by calling methods like @ref BansheeEngine::parseINT32 "parseINT32", @ref BansheeEngine::parseBool "parseBool", and similar for other types.
+
+# Threading {#utilities_i}
+## Primitives {#utilities_i_a}
+
+## Thread pool {#utilities_i_b}
+
+## Task scheduler {#utilities_i_c}
+
+# Math {#utilities_j}
+// Math, Vector, Matrix
+
+# Time {#utilities_k}
+
+# Logging {#utilities_l}
+
+# Crash handling {#utilities_m}
+
+# Dynamic libraries {#utilities_n}
+
+# Testing {#utilities_o}
+
+# Allocators {#utilities_p}
+## General {#utilities_p_a}
+
+## Frame {#utilities_p_b}
+
+## Stack {#utilities_p_c}
+
+## Static {#utilities_p_d}

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

@@ -111,6 +111,7 @@ namespace BansheeEngine
 		/************************************************************************/
 	protected:
 		friend class SceneObject;
+		using Component::destroyInternal;
 
 		/** @copydoc Component::onInitialized() */
 		void onInitialized() override;
@@ -127,7 +128,6 @@ namespace BansheeEngine
 		/** @copydoc Component::onTransformChanged() */
 		void onTransformChanged(TransformChangedFlags flags) override;
 
-    protected:
 		/** Updates the position by copying it from the controller to the component's scene object. */
 		void updatePositionFromController();
 

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

@@ -116,6 +116,8 @@ namespace BansheeEngine
 		void onTransformChanged(TransformChangedFlags flags) override;
 
     protected:
+		using Component::destroyInternal;
+
 		/** Creates the internal representation of the Collider for use by the component. */
 		virtual SPtr<Collider> createInternal() = 0;
 

+ 1 - 0
Source/BansheeCore/Include/BsCJoint.h

@@ -91,6 +91,7 @@ namespace BansheeEngine
 
     protected:
 		friend class CRigidbody;
+		using Component::destroyInternal;
 
 		/** Creates the internal representation of the Joint for use by the component. */
 		virtual SPtr<Joint> createInternal() = 0;

+ 2 - 0
Source/BansheeCore/Include/BsCRigidbody.h

@@ -179,6 +179,8 @@ namespace BansheeEngine
 	protected:
 		friend class CCollider;
 
+		using Component::destroyInternal;
+
 		/** 
 		 * Searches child scene objects for Collider components and attaches them to the rigidbody. Make sure to call
 		 * clearColliders() if you need to clear old colliders first. 

+ 1 - 0
Source/BansheeCore/Include/BsCollider.h

@@ -23,6 +23,7 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT Collider
 	{
 	public:
+		Collider() { }
 		virtual ~Collider() { }
 
 		/** @copydoc FCollider::getPosition */

+ 19 - 18
Source/BansheeCore/Include/BsCommandQueue.h

@@ -72,12 +72,13 @@ namespace BansheeEngine
 #if BS_DEBUG_MODE
 		QueuedCommand(std::function<void(AsyncOp&)> _callback, UINT32 _debugId, const SPtr<AsyncOpSyncData>& asyncOpSyncData,
 			bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callbackWithReturnValue(_callback), debugId(_debugId), returnsValue(true), 
-			notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(asyncOpSyncData)
+			: debugId(_debugId), callbackWithReturnValue(_callback), asyncOp(asyncOpSyncData), returnsValue(true)
+			, callbackId(_callbackId), notifyWhenComplete(_notifyWhenComplete)
 		{ }
 
 		QueuedCommand(std::function<void()> _callback, UINT32 _debugId, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callback(_callback), debugId(_debugId), returnsValue(false), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(AsyncOpEmpty())
+			:debugId(_debugId), callback(_callback), asyncOp(AsyncOpEmpty()), returnsValue(false), callbackId(_callbackId)
+			, notifyWhenComplete(_notifyWhenComplete)
 		{ }
 
 		UINT32 debugId;
@@ -302,14 +303,14 @@ namespace BansheeEngine
 		{
 #if BS_DEBUG_MODE
 #if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
+			if(!this->isValidThread(getThreadId()))
 				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
 #endif
 #endif
 
-			lock();
+			this->lock();
 			AsyncOp asyncOp = CommandQueueBase::queueReturn(commandCallback, _notifyWhenComplete, _callbackId);
-			unlock();
+			this->unlock();
 
 			return asyncOp;
 		}
@@ -319,14 +320,14 @@ namespace BansheeEngine
 		{
 #if BS_DEBUG_MODE
 #if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
+			if(!this->isValidThread(getThreadId()))
 				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
 #endif
 #endif
 
-			lock();
+			this->lock();
 			CommandQueueBase::queue(commandCallback, _notifyWhenComplete, _callbackId);
-			unlock();
+			this->unlock();
 		}
 
 		/** @copydoc CommandQueueBase::flush */
@@ -334,14 +335,14 @@ namespace BansheeEngine
 		{
 #if BS_DEBUG_MODE
 #if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
+			if(!this->isValidThread(getThreadId()))
 				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
 #endif
 #endif
 
-			lock();
+			this->lock();
 			BansheeEngine::Queue<QueuedCommand>* commands = CommandQueueBase::flush();
-			unlock();
+			this->unlock();
 
 			return commands;
 		}
@@ -351,14 +352,14 @@ namespace BansheeEngine
 		{
 #if BS_DEBUG_MODE
 #if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
+			if(!this->isValidThread(getThreadId()))
 				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
 #endif
 #endif
 
-			lock();
+			this->lock();
 			CommandQueueBase::cancelAll();
-			unlock();
+			this->unlock();
 		}
 
 		/** @copydoc CommandQueueBase::isEmpty */
@@ -366,14 +367,14 @@ namespace BansheeEngine
 		{
 #if BS_DEBUG_MODE
 #if BS_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
+			if(!this->isValidThread(getThreadId()))
 				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
 #endif
 #endif
 
-			lock();
+			this->lock();
 			bool empty = CommandQueueBase::isEmpty();
-			unlock();
+			this->unlock();
 
 			return empty;
 		}

+ 1 - 0
Source/BansheeCore/Include/BsFCollider.h

@@ -17,6 +17,7 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT FCollider
 	{
 	public:
+		FCollider() { }
 		virtual ~FCollider();
 
 		/** Returns the position of the collider. */

+ 2 - 0
Source/BansheeCore/Include/BsFont.h

@@ -57,6 +57,8 @@ namespace BansheeEngine
 		static HFont create(const Vector<SPtr<FontBitmap>>& fontInitData);
 
 	public: // ***** INTERNAL ******
+		using Resource::initialize;
+
 		/** @name Internal
 		 *  @{
 		 */

+ 1 - 9
Source/BansheeCore/Include/BsGameObjectHandle.h

@@ -17,7 +17,7 @@ namespace BansheeEngine
 	struct GameObjectInstanceData
 	{
 		GameObjectInstanceData()
-			:mInstanceId(0), object(nullptr)
+			:object(nullptr), mInstanceId(0)
 		{ }
 
 		SPtr<GameObject> object;
@@ -201,14 +201,6 @@ namespace BansheeEngine
 			return *this;
 		}
 
-		/**	Casts a specific handle to the base handle. */
-		operator GameObjectHandleBase()
-		{
-			GameObjectHandleBase base(mData);
-
-			return base;
-		}
-
 		/**
 		 * Returns a pointer to the referenced GameObject.
 		 *

+ 40 - 44
Source/BansheeCore/Include/BsGpuParam.h

@@ -30,6 +30,46 @@ namespace BansheeEngine
 	template<> struct TGpuParamSamplerStateType < false > { typedef SPtr<SamplerState> Type; };
 	template<> struct TGpuParamSamplerStateType < true > { typedef SPtr<SamplerStateCore> Type; };
 
+	template<bool Core> struct TGpuParamBufferType { };
+	template<> struct TGpuParamBufferType < false > { typedef SPtr<GpuParamBlockBuffer> Type; };
+	template<> struct TGpuParamBufferType < true > { typedef SPtr<GpuParamBlockBufferCore> Type; };
+
+	/**
+	 * Policy class that allows us to re-use this template class for matrices which might need transposing, and other 
+	 * types which do not. Matrix needs to be transposed for certain render systems depending on how they store them 
+	 * in memory.
+	 */
+	template<class Type>
+	struct TransposePolicy
+	{
+		static Type transpose(const Type& value) { return value; }
+		static bool transposeEnabled(bool enabled) { return false; }
+	};
+
+	/** Transpose policy for 3x3 matrix. */
+	template<>
+	struct TransposePolicy<Matrix3>
+	{
+		static Matrix3 transpose(const Matrix3& value) { return value.transpose(); }
+		static bool transposeEnabled(bool enabled) { return enabled; }
+	};
+
+	/**	Transpose policy for 4x4 matrix. */
+	template<>
+	struct TransposePolicy<Matrix4>
+	{
+		static Matrix4 transpose(const Matrix4& value) { return value.transpose(); }
+		static bool transposeEnabled(bool enabled) { return enabled; }
+	};
+
+	/**	Transpose policy for NxM matrix. */
+	template<int N, int M>
+	struct TransposePolicy<MatrixNxM<N, M>>
+	{
+		static MatrixNxM<N, M> transpose(const MatrixNxM<N, M>& value) { return value.transpose(); }
+		static bool transposeEnabled(bool enabled) { return enabled; }
+	};
+
 	/**
 	 * A handle that allows you to set a GpuProgram parameter. Internally keeps a reference to the GPU parameter buffer and
 	 * the necessary offsets. You should specialize this type for specific parameter types. 
@@ -50,49 +90,9 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT TGpuDataParam
 	{
 	private:
-		template<bool Core> struct TGpuParamBufferType { };
-		template<> struct TGpuParamBufferType < false > { typedef SPtr<GpuParamBlockBuffer> Type; };
-		template<> struct TGpuParamBufferType < true > { typedef SPtr<GpuParamBlockBufferCore> Type; };
-
 		typedef typename TGpuParamBufferType<Core>::Type GpuParamBufferType;
 		typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
 
-		/**
-		 * Policy class that allows us to re-use this template class for matrices which might need transposing, and other 
-		 * types which do not. Matrix needs to be transposed for certain render systems depending on how they store them 
-		 * in memory.
-		 */
-		template<class Type>
-		struct TransposePolicy
-		{
-			static Type transpose(const Type& value) { return value; }
-			static bool transposeEnabled(bool enabled) { return false; }
-		};
-
-		/** Transpose policy for 3x3 matrix. */
-		template<>
-		struct TransposePolicy<Matrix3>
-		{
-			static Matrix3 transpose(const Matrix3& value) { return value.transpose(); }
-			static bool transposeEnabled(bool enabled) { return enabled; }
-		};
-
-		/**	Transpose policy for 4x4 matrix. */
-		template<>
-		struct TransposePolicy<Matrix4>
-		{
-			static Matrix4 transpose(const Matrix4& value) { return value.transpose(); }
-			static bool transposeEnabled(bool enabled) { return enabled; }
-		};
-
-		/**	Transpose policy for NxM matrix. */
-		template<int N, int M>
-		struct TransposePolicy<MatrixNxM<N, M>>
-		{
-			static MatrixNxM<N, M> transpose(const MatrixNxM<N, M>& value) { return value.transpose(); }
-			static bool transposeEnabled(bool enabled) { return enabled; }
-		};
-
 	public:
 		TGpuDataParam();
 		TGpuDataParam(GpuParamDataDesc* paramDesc, const GpuParamsType& parent);
@@ -130,10 +130,6 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT TGpuParamStruct
 	{
 	public:
-		template<bool Core> struct TGpuParamBufferType { };
-		template<> struct TGpuParamBufferType < false > { typedef SPtr<GpuParamBlockBuffer> Type; };
-		template<> struct TGpuParamBufferType < true > { typedef SPtr<GpuParamBlockBufferCore> Type; };
-
 		typedef typename TGpuParamBufferType<Core>::Type GpuParamBufferType;
 		typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
 

+ 21 - 22
Source/BansheeCore/Include/BsGpuParams.h

@@ -128,33 +128,32 @@ namespace BansheeEngine
 		bool mTransposeMatrices;
 	};
 
+	template<bool Core> struct TGpuParamsTypes { };
+	template<> struct TGpuParamsTypes < false >
+	{
+		typedef GpuParams GpuParamsType;
+		typedef HTexture TextureType;
+		typedef SPtr<SamplerState> SamplerType;
+		typedef SPtr<GpuParamBlockBuffer> ParamsBufferType;
+	};
+
+	template<> struct TGpuParamsTypes < true >
+	{
+		typedef GpuParamsCore GpuParamsType;
+		typedef SPtr<TextureCore> TextureType;
+		typedef SPtr<SamplerStateCore> SamplerType;
+		typedef SPtr<GpuParamBlockBufferCore> ParamsBufferType;
+	};
+
 	/** Templated version of GpuParams that contains functionality for both sim and core thread versions of stored data. */
 	template <bool Core>
 	class BS_CORE_EXPORT TGpuParams : public GpuParamsBase
 	{
 	public:
-		template<bool Core> struct TTypes { };
-
-		template<> struct TTypes < false > 
-		{ 
-			typedef GpuParams GpuParamsType; 
-			typedef HTexture TextureType;
-			typedef SPtr<SamplerState> SamplerType;
-			typedef SPtr<GpuParamBlockBuffer> ParamsBufferType;
-		};
-
-		template<> struct TTypes < true > 
-		{ 
-			typedef GpuParamsCore GpuParamsType;
-			typedef SPtr<TextureCore> TextureType;
-			typedef SPtr<SamplerStateCore> SamplerType;
-			typedef SPtr<GpuParamBlockBufferCore> ParamsBufferType;
-		};
-
-		typedef typename TTypes<Core>::GpuParamsType GpuParamsType;
-		typedef typename TTypes<Core>::TextureType TextureType;
-		typedef typename TTypes<Core>::SamplerType SamplerType;
-		typedef typename TTypes<Core>::ParamsBufferType ParamsBufferType;
+		typedef typename TGpuParamsTypes<Core>::GpuParamsType GpuParamsType;
+		typedef typename TGpuParamsTypes<Core>::TextureType TextureType;
+		typedef typename TGpuParamsTypes<Core>::SamplerType SamplerType;
+		typedef typename TGpuParamsTypes<Core>::ParamsBufferType ParamsBufferType;
 
 		TGpuParams(const SPtr<GpuParamDesc>& paramDesc, bool transposeMatrices);
 

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

@@ -153,7 +153,7 @@ namespace BansheeEngine
 			GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired = false);
 
 		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const;
+		SPtr<CoreObjectCore> createCore() const override;
 
 	protected:
 		bool mNeedsAdjacencyInfo;

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

@@ -33,11 +33,11 @@ namespace BansheeEngine
 		 * string. If a string with that identifier already exists default language string will be updated.
 		 *
 		 * @param[in]	identifier		String you can use for later referencing the localized string.
-		 * @param[in]	default			Default string to assign to the specified identifier. Language to which it will be 
+		 * @param[in]	defaultString	Default string to assign to the specified identifier. Language to which it will be 
 		 *								assigned depends on the StringTable::DEFAULT_LANGUAGE value.
 		 * @param[in]	stringTableId	Unique identifier of the string table to retrieve the string from.
 		 */
-		explicit HString(const WString& identifier, const WString& default, UINT32 stringTableId = 0);
+		explicit HString(const WString& identifier, const WString& defaultString, UINT32 stringTableId = 0);
 
 		/**
 		 * Creates a new empty localized string.

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

@@ -23,7 +23,7 @@ namespace BansheeEngine
 	 * When storing these sequentially make sure to only reference the low order 2 bytes. Two high order bytes are used for 
 	 * various flags.
 	 */
-	enum ButtonCode
+	enum ButtonCode : UINT32
 	{
 		BC_UNASSIGNED  = 0x00,
 		BC_ESCAPE      = 0x01,
@@ -300,8 +300,8 @@ namespace BansheeEngine
 	{
 	public:
 		PointerEvent()
-			:mIsUsed(false), mouseWheelScrollAmount(0.0f), type(PointerEventType::CursorMoved),
-			shift(false), control(false), alt(false), button(PointerEventButton::Left)
+			: button(PointerEventButton::Left), type(PointerEventType::CursorMoved), shift(false)
+			, control(false), alt(false), mouseWheelScrollAmount(0.0f), mIsUsed(false)
 		{
 			buttonStates[0] = false;
 			buttonStates[1] = false;

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

@@ -21,6 +21,7 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT Joint
 	{
 	public:
+		Joint() { }
 		virtual ~Joint() { }
 
 		/** @copydoc FJoint::getBody */
@@ -137,7 +138,7 @@ namespace BansheeEngine
 		{ }
 
 		LimitCommon(const Spring& spring, float restitution = 0.0f)
-			:spring(spring), restitution(restitution)
+			: restitution(restitution), spring(spring)
 		{ }
 
 		/** 

+ 30 - 33
Source/BansheeCore/Include/BsMaterial.h

@@ -6,6 +6,7 @@
 #include "BsResource.h"
 #include "BsIResourceListener.h"
 #include "BsMaterialParam.h"
+#include "BsTechnique.h"
 #include "BsVector2.h"
 #include "BsVector3.h"
 #include "BsVector4.h"
@@ -59,14 +60,6 @@ namespace BansheeEngine
 		GpuParamsType mComputeParams;
 	};
 
-	template<bool Core> struct TGpuParamBlockBufferPtrType { };
-	template<> struct TGpuParamBlockBufferPtrType<false> { typedef SPtr<GpuParamBlockBuffer> Type; };
-	template<> struct TGpuParamBlockBufferPtrType<true> { typedef SPtr<GpuParamBlockBufferCore> Type; };
-
-	template<bool Core> struct TGpuProgramType { };
-	template<> struct TGpuProgramType<false> { typedef SPtr<GpuProgram> Type; };
-	template<> struct TGpuProgramType<true> { typedef SPtr<GpuProgramCore> Type; };
-
 	/** Contains sim thread pass parameters for each shader stage. */
 	class BS_CORE_EXPORT PassParameters : public TPassParameters<false>
 	{
@@ -81,6 +74,26 @@ namespace BansheeEngine
 		static const UINT32 NUM_PARAMS;
 	};
 
+	template<bool Core> struct TGpuParamBlockBufferPtrType { };
+	template<> struct TGpuParamBlockBufferPtrType<false> { typedef SPtr<GpuParamBlockBuffer> Type; };
+	template<> struct TGpuParamBlockBufferPtrType<true> { typedef SPtr<GpuParamBlockBufferCore> Type; };
+
+	template<bool Core> struct TGpuProgramType { };
+	template<> struct TGpuProgramType<false> { typedef SPtr<GpuProgram> Type; };
+	template<> struct TGpuProgramType<true> { typedef SPtr<GpuProgramCore> Type; };
+
+	template<bool Core> struct TShaderType {};
+	template<> struct TShaderType < false > { typedef HShader Type; };
+	template<> struct TShaderType < true > { typedef SPtr<ShaderCore> Type; };
+
+	template<bool Core> struct TGpuParamBlockBufferType {};
+	template<> struct TGpuParamBlockBufferType < false > { typedef GpuParamBlockBuffer Type; };
+	template<> struct TGpuParamBlockBufferType < true > { typedef GpuParamBlockBufferCore Type; };
+
+	template<bool Core> struct TPassParamsType {};
+	template<> struct TPassParamsType < false > { typedef PassParameters Type; };
+	template<> struct TPassParamsType < true > { typedef PassParametersCore Type; };
+
 	/**
 	 * Material that controls how objects are rendered. It is represented by a shader and parameters used to set up that
 	 * shader. It provides a simple interface for manipulating the parameters.
@@ -92,13 +105,15 @@ namespace BansheeEngine
 		struct StructData
 		{
 			StructData()
-				:size(0), data(nullptr)
+				:data(nullptr), size(0)
 			{ }
 
+
+
 			StructData(UINT32 _size)
 				:size(_size)
 			{
-				data = SPtr<void>(bs_alloc(_size), &bs_free);
+				data = std::shared_ptr<void>(bs_alloc(_size), (void(*)(void*))&bs_free);
 			}
 
 			/**
@@ -113,6 +128,7 @@ namespace BansheeEngine
 			UINT32 size;
 		};
 
+		MaterialBase() { }
 		virtual ~MaterialBase() { }
 
 	protected:
@@ -143,26 +159,6 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT TMaterial : public MaterialBase
 	{
 	public:
-		template<bool Core> struct TPassType {};
-		template<> struct TPassType < false > { typedef SPtr<Pass> Type; };
-		template<> struct TPassType < true > { typedef SPtr<PassCore> Type; };
-
-		template<bool Core> struct TTechniqueType {};
-		template<> struct TTechniqueType < false > { typedef SPtr<Technique> Type; };
-		template<> struct TTechniqueType < true > { typedef SPtr<TechniqueCore> Type; };
-
-		template<bool Core> struct TShaderType {};
-		template<> struct TShaderType < false > { typedef HShader Type; };
-		template<> struct TShaderType < true > { typedef SPtr<ShaderCore> Type; };
-
-		template<bool Core> struct TGpuParamBlockBufferType {};
-		template<> struct TGpuParamBlockBufferType < false > { typedef GpuParamBlockBuffer Type; };
-		template<> struct TGpuParamBlockBufferType < true > { typedef GpuParamBlockBufferCore Type; };
-
-		template<bool Core> struct TPassParamsType {};
-		template<> struct TPassParamsType < false > { typedef PassParameters Type; };
-		template<> struct TPassParamsType < true > { typedef PassParametersCore Type; };
-
 		typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
 		typedef typename TGpuParamTextureType<Core>::Type TextureType;
 		typedef typename TGpuParamSamplerStateType<Core>::Type SamplerStateType;
@@ -174,6 +170,7 @@ namespace BansheeEngine
 		typedef typename TShaderType<Core>::Type ShaderType;
 		typedef typename TPassParamsType<Core>::Type PassParamsType;
 
+		TMaterial() { }
 		virtual ~TMaterial() { }
 
 		/** Returns the currently active shader. */
@@ -183,7 +180,7 @@ namespace BansheeEngine
 		UINT32 getNumPasses() const;
 
 		/** Retrieves a specific shader pass. */
-		PassType getPass(UINT32 passIdx) const;
+		SPtr<PassType> getPass(UINT32 passIdx) const;
 
 		/**   
 		 * Assigns a float value to the shader parameter with the specified name. 
@@ -658,7 +655,7 @@ namespace BansheeEngine
 
 		Vector<SPtr<PassParamsType>> mParametersPerPass;
 		ShaderType mShader;
-		TechniqueType mBestTechnique;
+		SPtr<TechniqueType> mBestTechnique;
 	};
 
 	/** @} */
@@ -724,7 +721,7 @@ namespace BansheeEngine
 		void initialize() override;
 
 		/** Creates a deep copy of the material and returns the new object. */
-		HMaterial Material::clone();
+		HMaterial clone();
 
 		/**
 		 * Creates a new empty material.

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

@@ -35,7 +35,7 @@ namespace BansheeEngine
 
 	/** @copydoc TMaterialDataParam */
 	template<class T>
-	class BS_CORE_EXPORT TMaterialDataParam<T, false>
+	class TMaterialDataParam<T, false>
 	{
 	public:
 		TMaterialDataParam(const String& name, const SPtr<MaterialParams>& params, 
@@ -57,7 +57,7 @@ namespace BansheeEngine
 
 	/** @copydoc TMaterialDataParam */
 	template<class T>
-	class BS_CORE_EXPORT TMaterialDataParam<T, true>
+	class TMaterialDataParam<T, true>
 	{
 	public:
 		TMaterialDataParam(const SPtr<Vector<TGpuDataParam<T, true>>>& params);

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

@@ -49,7 +49,7 @@ namespace BansheeEngine
 		const String& getRTTIName() override
 		{
 			static String name = "MeshBase";
-			throw name;
+			return name;
 		}
 
 		UINT32 getRTTIId() override

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

@@ -71,7 +71,7 @@ namespace BansheeEngine
 		const String& getRTTIName() override
 		{
 			static String name = "MeshData";
-			throw name;
+			return name;
 		}
 
 		UINT32 getRTTIId() override

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

@@ -67,7 +67,7 @@ namespace BansheeEngine
 		const String& getRTTIName() override
 		{
 			static String name = "Mesh";
-			throw name;
+			return name;
 		}
 
 		UINT32 getRTTIId() override

+ 4 - 4
Source/BansheeCore/Include/BsOSInputHandler.h

@@ -113,28 +113,28 @@ namespace BansheeEngine
 		 * 			
 		 * @see		onCursorMoved
 		 */
-		void cursorMoved(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
+		void cursorMoved(const Vector2I& cursorPos, const OSPointerButtonStates& btnStates);
 
 		/**
 		 * Called from the message loop to notify user has pressed a mouse button.
 		 * 			
 		 * @see		onCursorPressed
 		 */
-		void cursorPressed(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
+		void cursorPressed(const Vector2I& cursorPos, OSMouseButton button, const OSPointerButtonStates& btnStates);
 
 		/**
 		 * Called from the message loop to notify user has released a mouse button.
 		 * 			
 		 * @see		onCursorReleased
 		 */
-		void cursorReleased(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
+		void cursorReleased(const Vector2I& cursorPos, OSMouseButton button, const OSPointerButtonStates& btnStates);
 
 		/**
 		 * Called from the message loop to notify user has double-clicked a mouse button.
 		 * 
 		 * @see		onDoubleClick
 		 */
-		void cursorDoubleClick(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
+		void cursorDoubleClick(const Vector2I& cursorPos, const OSPointerButtonStates& btnStates);
 
 		/**
 		 * Called from the message loop to notify user has entered an input command.

+ 5 - 5
Source/BansheeCore/Include/BsPlatform.h

@@ -65,7 +65,7 @@ namespace BansheeEngine
 			ctrl = false;
 		}
 
-		bool mouseButtons[OSMouseButton::Count];
+		bool mouseButtons[(UINT32)OSMouseButton::Count];
 		bool shift, ctrl;
 	};
 
@@ -386,28 +386,28 @@ namespace BansheeEngine
 		 *
 		 * @note	Core thread only.
 		 */
-		static Event<void(const Vector2I&, OSPointerButtonStates)> onCursorMoved;
+		static Event<void(const Vector2I&, const OSPointerButtonStates&)> onCursorMoved;
 
 		/**
 		 * Triggered whenever a pointer button is pressed.
 		 *
 		 * @note	Core thread only.
 		 */
-		static Event<void(const Vector2I&, OSMouseButton button, OSPointerButtonStates)> onCursorButtonPressed;
+		static Event<void(const Vector2I&, OSMouseButton button, const OSPointerButtonStates&)> onCursorButtonPressed;
 
 		/**
 		 * Triggered whenever pointer button is released.
 		 *
 		 * @note	Core thread only.
 		 */
-		static Event<void(const Vector2I&, OSMouseButton button, OSPointerButtonStates)> onCursorButtonReleased;
+		static Event<void(const Vector2I&, OSMouseButton button, const OSPointerButtonStates&)> onCursorButtonReleased;
 
 		/**
 		 * Triggered whenever a pointer button is double clicked.
 		 *
 		 * @note	Core thread only.
 		 */
-		static Event<void(const Vector2I&, OSPointerButtonStates)> onCursorDoubleClick;
+		static Event<void(const Vector2I&, const OSPointerButtonStates&)> onCursorDoubleClick;
 
 		/**
 		 * Triggered whenever an input command is entered.

+ 2 - 0
Source/BansheeCore/Include/BsPrefab.h

@@ -72,6 +72,8 @@ namespace BansheeEngine
 		/** @} */
 
 	private:
+		using CoreObject::initialize;
+
 		/**	Initializes the internal prefab hierarchy. Must be called druing creation. */
 		void initialize(const HSceneObject& sceneObject);
 

+ 2 - 0
Source/BansheeCore/Include/BsPrefabDiff.h

@@ -51,6 +51,8 @@ namespace BansheeEngine
 	 */
 	struct BS_CORE_EXPORT PrefabObjectDiff : public IReflectable
 	{
+		PrefabObjectDiff() { }
+
 		UINT32 id = 0;
 
 		String name;

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

@@ -415,9 +415,9 @@ namespace BansheeEngine
 
 	/** Shortcut for profiling a single function call. */
 #define PROFILE_CALL(call, name)							\
-	BansheeEngine::gProfilerCPU().beginSample(##name##);	\
+	BansheeEngine::gProfilerCPU().beginSample(name);		\
 	call;													\
-	BansheeEngine::gProfilerCPU().endSample(##name##);
+	BansheeEngine::gProfilerCPU().endSample(name);
 
 	/** @} */
 }

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

@@ -180,9 +180,9 @@ namespace BansheeEngine
 	};
 
 #if BS_PROFILING_ENABLED
-	#define BS_INC_RENDER_STAT_CAT(Stat, Category) RenderStats::instance().inc##Stat##((UINT32)##Category##)
-	#define BS_INC_RENDER_STAT(Stat) RenderStats::instance().inc##Stat##()
-	#define BS_ADD_RENDER_STAT(Stat, Count) RenderStats::instance().add##Stat##(##Count##)
+	#define BS_INC_RENDER_STAT_CAT(Stat, Category) RenderStats::instance().inc##Stat((UINT32)Category)
+	#define BS_INC_RENDER_STAT(Stat) RenderStats::instance().inc##Stat()
+	#define BS_ADD_RENDER_STAT(Stat, Count) RenderStats::instance().add##Stat(Count)
 #else
 	#define BS_INC_RENDER_STAT_CAT(Stat, Category)
 	#define BS_INC_RENDER_STAT(Stat)

+ 1 - 0
Source/BansheeCore/Include/BsRenderTarget.h

@@ -38,6 +38,7 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT RenderTargetProperties
 	{
 	public:
+		RenderTargetProperties() { }
 		virtual ~RenderTargetProperties() { }
 
 		/**

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

@@ -136,7 +136,7 @@ namespace BansheeEngine
 		virtual ~RenderTextureCore();
 
 		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize();
+		virtual void initialize() override;
 
 		/** @copydoc TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_CORE_DESC&) */
 		static SPtr<RenderTextureCore> create(const RENDER_TEXTURE_CORE_DESC& desc);

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

@@ -17,7 +17,7 @@ namespace BansheeEngine
 	struct BS_CORE_EXPORT RENDER_WINDOW_DESC
 	{
 		RENDER_WINDOW_DESC()
-		: vsync(false), vsyncInterval(1), fullscreen(false), hidden(false), depthBuffer(true)
+		: fullscreen(false), vsync(false), vsyncInterval(1), hidden(false), depthBuffer(true)
 			, multisampleCount(0), multisampleHint(""), gamma(false), left(-1), top(-1)
 			, title(""), border(WindowBorder::Normal), outerDimensions(false), enableDoubleClick(true)
 			, toolWindow(false), modal(false), hideUntilSwap(false)

+ 27 - 31
Source/BansheeCore/Include/BsResourceHandle.h

@@ -115,7 +115,8 @@ namespace BansheeEngine
 	 * Handles differences in reference counting depending if the handle is normal or weak.
 	 */
 	template <bool WeakHandle>
-	class BS_CORE_EXPORT TResourceHandleBase : public ResourceHandleBase { };
+	class BS_CORE_EXPORT TResourceHandleBase : public ResourceHandleBase
+	{ };
 
 	/**	Specialization of TResourceHandleBase for weak handles. Weak handles do no reference counting. */
 	template<>
@@ -173,28 +174,25 @@ namespace BansheeEngine
 	{
 	public:
 		TResourceHandle()
-			:TResourceHandleBase()
 		{ }
 
 		/**	Copy constructor. */
 		TResourceHandle(const TResourceHandle<T, WeakHandle>& ptr)
-			:TResourceHandleBase()
 		{
-			mData = ptr.getHandleData();
-
-			addRef();
+			this->mData = ptr.getHandleData();
+			this->addRef();
 		}
 
 		virtual ~TResourceHandle()
 		{
-			releaseRef();
+			this->releaseRef();
 		}
 
 		/**	Converts a specific handle to generic Resource handle. */
 		operator TResourceHandle<Resource, WeakHandle>() const
 		{
 			TResourceHandle<Resource, WeakHandle> handle;
-			handle.setHandleData(getHandleData());
+			handle.setHandleData(this->getHandleData());
 
 			return handle;
 		}
@@ -216,9 +214,9 @@ namespace BansheeEngine
 		/** Clears the handle making it invalid and releases any references held to the resource. */
 		TResourceHandle<T, WeakHandle>& operator=(std::nullptr_t ptr)
 		{ 	
-			releaseRef();
+			this->releaseRef();
+			this->mData = nullptr;
 
-			mData = nullptr;
 			return *this;
 		}
 
@@ -243,7 +241,7 @@ namespace BansheeEngine
 		 */
 		operator int Bool_struct<T>::*() const
 		{
-			return ((mData != nullptr && !mData->mUUID.empty()) ? &Bool_struct<T>::_Member : 0);
+			return ((this->mData != nullptr && !this->mData->mUUID.empty()) ? &Bool_struct<T>::_Member : 0);
 		}
 
 		/**
@@ -253,9 +251,9 @@ namespace BansheeEngine
 		 */
 		T* get() const 
 		{ 
-			throwIfNotLoaded();
+			this->throwIfNotLoaded();
 
-			return reinterpret_cast<T*>(mData->mPtr.get()); 
+			return reinterpret_cast<T*>(this->mData->mPtr.get());
 		}
 
 		/**
@@ -265,16 +263,16 @@ namespace BansheeEngine
 		 */
 		SPtr<T> getInternalPtr() const
 		{ 
-			throwIfNotLoaded();
+			this->throwIfNotLoaded();
 
-			return std::static_pointer_cast<T>(mData->mPtr); 
+			return std::static_pointer_cast<T>(this->mData->mPtr);
 		}
 
 		/** Converts a handle into a weak handle. */
 		TResourceHandle<T, true> getWeak() const
 		{
 			TResourceHandle<T, true> handle;
-			handle.setHandleData(getHandleData());
+			handle.setHandleData(this->getHandleData());
 
 			return handle;
 		}
@@ -294,10 +292,10 @@ namespace BansheeEngine
 		explicit TResourceHandle(T* ptr, const String& uuid)
 			:TResourceHandleBase()
 		{
-			mData = bs_shared_ptr_new<ResourceHandleData>();
-			addRef();
+			this->mData = bs_shared_ptr_new<ResourceHandleData>();
+			this->addRef();
 
-			setHandleData(SPtr<Resource>(ptr, uuid));
+			this->setHandleData(SPtr<Resource>(ptr), uuid);
 		}
 
 		/**
@@ -305,20 +303,18 @@ namespace BansheeEngine
 		 * pointer to make the handle valid.
 		 */
 		TResourceHandle(const String& uuid)
-			:TResourceHandleBase()
 		{
-			mData = bs_shared_ptr_new<ResourceHandleData>();
-			mData->mUUID = uuid;
+			this->mData = bs_shared_ptr_new<ResourceHandleData>();
+			this->mData->mUUID = uuid;
 
-			addRef();
+			this->addRef();
 		}
 
 		/**	Constructs a new valid handle for the provided resource with the provided UUID. */
 		TResourceHandle(const SPtr<T> ptr, const String& uuid)
-			:TResourceHandleBase()
 		{
-			mData = bs_shared_ptr_new<ResourceHandleData>();
-			addRef();
+			this->mData = bs_shared_ptr_new<ResourceHandleData>();
+			this->addRef();
 
 			setHandleData(ptr, uuid);
 		}
@@ -326,21 +322,21 @@ namespace BansheeEngine
 		/**	Replaces the internal handle data pointer, effectively transforming the handle into a different handle. */
 		void setHandleData(const SPtr<ResourceHandleData>& data)
 		{
-			releaseRef();
-			mData = data;
-			addRef();
+			this->releaseRef();
+			this->mData = data;
+			this->addRef();
 		}
 
 		/**	Converts a weak handle into a normal handle. */
 		TResourceHandle<T, false> lock() const
 		{
 			TResourceHandle<Resource, false> handle;
-			handle.setHandleData(getHandleData());
+			handle.setHandleData(this->getHandleData());
 
 			return handle;
 		}
 
-		using TResourceHandleBase::setHandleData;
+		using ResourceHandleBase::setHandleData;
 	};
 
 	/**	Checks if two handles point to the same resource. */

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

@@ -22,8 +22,8 @@ namespace BansheeEngine
 	{
 		SAMPLER_STATE_DESC()
 			: minFilter(FO_LINEAR), magFilter(FO_LINEAR), mipFilter(FO_POINT), 
-			maxAniso(0), mipmapBias(0), comparisonFunc(CMPF_ALWAYS_FAIL), mipMin(-FLT_MAX), 
-			mipMax(FLT_MAX), borderColor(Color::White)
+			maxAniso(0), mipmapBias(0), mipMin(-FLT_MAX), mipMax(FLT_MAX),
+			borderColor(Color::White), comparisonFunc(CMPF_ALWAYS_FAIL)
 		{ }
 
 		bool operator==(const SAMPLER_STATE_DESC& rhs) const;

+ 9 - 12
Source/BansheeCore/Include/BsShader.h

@@ -6,6 +6,7 @@
 #include "BsResource.h"
 #include "BsStringID.h"
 #include "BsResourceMetaData.h"
+#include "BsTechnique.h"
 
 namespace BansheeEngine
 {
@@ -58,18 +59,18 @@ namespace BansheeEngine
 	 *  @{
 	 */
 
+	template<bool Core> struct TTextureType {};
+	template<> struct TTextureType < false > { typedef HTexture Type; };
+	template<> struct TTextureType < true > { typedef SPtr<TextureCore> Type; };
+
+	template<bool Core> struct TSamplerStateType {};
+	template<> struct TSamplerStateType < false > { typedef SPtr<SamplerState> Type; };
+	template<> struct TSamplerStateType < true > { typedef SPtr<SamplerStateCore> Type; };
+
 	/** Structure used for initializing a shader. */
 	template<bool Core>
 	struct BS_CORE_EXPORT TSHADER_DESC
 	{
-		template<bool Core> struct TTextureType {};
-		template<> struct TTextureType < false > { typedef HTexture Type; };
-		template<> struct TTextureType < true > { typedef SPtr<TextureCore> Type; };
-
-		template<bool Core> struct TSamplerStateType {};
-		template<> struct TSamplerStateType < false > { typedef SPtr<SamplerState> Type; };
-		template<> struct TSamplerStateType < true > { typedef SPtr<SamplerStateCore> Type; };
-
 		typedef typename TTextureType<Core>::Type TextureType;
 		typedef typename TSamplerStateType<Core>::Type SamplerStateType;
 
@@ -235,10 +236,6 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT TShader
 	{
 	public:
-		template<bool Core> struct TTechniqueType {};
-		template<> struct TTechniqueType < false > { typedef Technique Type; };
-		template<> struct TTechniqueType < true > { typedef TechniqueCore Type; };
-
 		typedef typename TTechniqueType<Core>::Type TechniqueType;
 		typedef typename TSHADER_DESC<Core>::TextureType TextureType;
 		typedef typename TSHADER_DESC<Core>::SamplerStateType SamplerStateType;

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

@@ -312,7 +312,7 @@ namespace BansheeEngine
 			return TID_Shader;
 		}
 
-		SPtr<IReflectable> newRTTIObject()
+		SPtr<IReflectable> newRTTIObject() override
 		{
 			return Shader::createEmpty();
 		}

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

@@ -136,7 +136,7 @@ namespace BansheeEngine
 		Norwegian, 
 		Navaho, 
 		Nyanja, 
-		Provençal, 
+		Provencal, 
 		Ojibwa, 
 		Oromo, 
 		Oriya, 

+ 8 - 4
Source/BansheeCore/Include/BsTechnique.h

@@ -35,6 +35,14 @@ namespace BansheeEngine
 		StringID mRenderer;
 	};
 
+	template<bool Core> struct TPassType { };
+	template<> struct TPassType < false > { typedef Pass Type; };
+	template<> struct TPassType < true > { typedef PassCore Type; };
+
+	template<bool Core> struct TTechniqueType {};
+	template<> struct TTechniqueType < false > { typedef Technique Type; };
+	template<> struct TTechniqueType < true > { typedef TechniqueCore Type; };
+
 	/**
 	 * @copydoc	TechniqueBase
 	 *
@@ -44,10 +52,6 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT TTechnique : public TechniqueBase
 	{
 	public:
-		template<bool Core> struct TPassType { };
-		template<> struct TPassType < false > { typedef Pass Type; };
-		template<> struct TPassType < true > { typedef PassCore Type; };
-
 		typedef typename TPassType<Core>::Type PassType;
 		
 		TTechnique();

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

@@ -37,7 +37,7 @@ namespace BansheeEngine
 		const String& getRTTIName() override
 		{
 			static String name = "VertexDataDesc";
-			throw name;
+			return name;
 		}
 
 		UINT32 getRTTIId() override

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

@@ -70,7 +70,7 @@ namespace BansheeEngine
 		const String& getRTTIName() override
 		{
 			static String name = "VertexDeclaration";
-			throw name;
+			return name;
 		}
 
 		UINT32 getRTTIId() override

+ 2 - 2
Source/BansheeCore/Include/Win32/BsWin32DropTarget.h

@@ -55,7 +55,7 @@ namespace BansheeEngine
 
 	public:
 		Win32DropTarget(HWND hWnd)
-			:mHWnd(hWnd), mRefCount(1), mAcceptDrag(false)
+			:mRefCount(1), mHWnd(hWnd), mAcceptDrag(false)
 		{ }
 
 		~Win32DropTarget()
@@ -75,7 +75,7 @@ namespace BansheeEngine
 		void registerWithOS()
 		{
 			CoLockObjectExternal(this, TRUE, FALSE);
-			HRESULT hr = RegisterDragDrop(mHWnd, this);
+			RegisterDragDrop(mHWnd, this);
 		}
 
 		/** Unregisters the drop target with the operating system. Monitoring for drag and drop operations stops. */

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

@@ -7,7 +7,7 @@
 namespace BansheeEngine
 {
 	Component::Component(const HSceneObject& parent)
-		:mParent(parent), mNotifyFlags(TCF_None)
+		:mNotifyFlags(TCF_None), mParent(parent)
 	{
 		setName("Component");
 	}

+ 2 - 2
Source/BansheeCore/Source/BsCoreApplication.cpp

@@ -49,8 +49,8 @@
 namespace BansheeEngine
 {
 	CoreApplication::CoreApplication(START_UP_DESC desc)
-		:mPrimaryWindow(nullptr), mIsFrameRenderingFinished(true), mRunMainLoop(false), mLastFrameTime(0),
-		mRendererPlugin(nullptr), mSimThreadId(BS_THREAD_CURRENT_ID), mStartUpDesc(desc), mFrameStep(16666)
+		: mPrimaryWindow(nullptr), mStartUpDesc(desc), mFrameStep(16666), mLastFrameTime(0), mRendererPlugin(nullptr)
+		, mIsFrameRenderingFinished(true), mSimThreadId(BS_THREAD_CURRENT_ID), mRunMainLoop(false)
 	{ }
 
 	CoreApplication::~CoreApplication()

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

@@ -11,7 +11,7 @@ using namespace std::placeholders;
 namespace BansheeEngine
 {
 	CoreObject::CoreObject(bool initializeOnCoreThread)
-		: mFlags(0), mInternalID(0), mCoreDirtyFlags(0xFFFFFFFF)
+		:mFlags(0), mCoreDirtyFlags(0xFFFFFFFF), mInternalID(0)
 	{
 		mInternalID = CoreObjectManager::instance().registerObject(this);
 		mFlags = initializeOnCoreThread ? mFlags | CGO_INIT_ON_CORE_THREAD : mFlags;

+ 2 - 4
Source/BansheeCore/Source/BsCoreObjectManager.cpp

@@ -268,7 +268,7 @@ namespace BansheeEngine
 			[](const Vector<IndividualCoreSyncData>& data)
 		{
 			// Traverse in reverse to sync dependencies before dependants
-			for (auto& riter = data.rbegin(); riter != data.rend(); ++riter)
+			for (auto riter = data.rbegin(); riter != data.rend(); ++riter)
 			{
 				const IndividualCoreSyncData& entry = *riter;
 				entry.destination->syncToCore(entry.syncData);
@@ -385,10 +385,8 @@ namespace BansheeEngine
 
 		CoreStoredSyncData& syncData = mCoreSyncData.front();
 
-		for (auto& iter = syncData.entries.begin(); iter != syncData.entries.end(); ++iter)
+		for (auto& objSyncData : syncData.entries)
 		{
-			const CoreStoredSyncObjData& objSyncData = *iter;
-
 			SPtr<CoreObjectCore> destinationObj = objSyncData.destinationObj.lock();
 			if (destinationObj != nullptr)
 				destinationObj->syncToCore(objSyncData.syncData);

+ 3 - 3
Source/BansheeCore/Source/BsCoreThread.cpp

@@ -14,12 +14,12 @@ namespace BansheeEngine
 	BS_THREADLOCAL CoreThread::AccessorContainer* CoreThread::AccessorData::current = nullptr;
 
 	CoreThread::CoreThread()
-		: mCoreThreadShutdown(false)
+		: mActiveFrameAlloc(0)
+		, mCoreThreadShutdown(false)
+		, mCoreThreadStarted(false)
 		, mCommandQueue(nullptr)
 		, mMaxCommandNotifyId(0)
 		, mSyncedCoreAccessor(nullptr)
-		, mActiveFrameAlloc(0)
-		, mCoreThreadStarted(false)
 	{
 		for (UINT32 i = 0; i < NUM_FRAME_ALLOCS; i++)
 		{

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

@@ -7,7 +7,7 @@
 namespace BansheeEngine
 {
 	GameObject::GameObject()
-		:mIsDestroyed(false), mLinkId((UINT32)-1)
+		:mLinkId((UINT32)-1), mIsDestroyed(false)
 	{ }
 
 	GameObject::~GameObject()

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

@@ -9,7 +9,8 @@ namespace BansheeEngine
 {
 	GpuBufferProperties::GpuBufferProperties(UINT32 elementCount, UINT32 elementSize, GpuBufferType type,
 		GpuBufferUsage usage, bool randomGpuWrite, bool useCounter)
-		:mElementCount(elementCount), mElementSize(elementSize), mType(type), mUsage(usage), mRandomGpuWrite(randomGpuWrite), mUseCounter(useCounter)
+		: mType(type), mUsage(usage), mRandomGpuWrite(randomGpuWrite), mUseCounter(useCounter), mElementCount(elementCount)
+		, mElementSize(elementSize)
 	{
 
 	}

+ 5 - 5
Source/BansheeCore/Source/BsGpuParam.cpp

@@ -18,7 +18,7 @@ namespace BansheeEngine
 
 	template<class T, bool Core>
 	TGpuDataParam<T, Core>::TGpuDataParam(GpuParamDataDesc* paramDesc, const GpuParamsType& parent)
-		:mParamDesc(paramDesc), mParent(parent)
+		:mParent(parent), mParamDesc(paramDesc)
 	{ }
 
 	template<class T, bool Core>
@@ -97,7 +97,7 @@ namespace BansheeEngine
 
 	template<bool Core>
 	TGpuParamStruct<Core>::TGpuParamStruct(GpuParamDataDesc* paramDesc, const GpuParamsType& parent)
-		:mParamDesc(paramDesc), mParent(parent)
+		:mParent(parent), mParamDesc(paramDesc)
 	{ }
 
 	template<bool Core>
@@ -186,7 +186,7 @@ namespace BansheeEngine
 
 	template<bool Core>
 	TGpuParamTexture<Core>::TGpuParamTexture(GpuParamObjectDesc* paramDesc, const GpuParamsType& parent)
-		:mParamDesc(paramDesc), mParent(parent)
+		:mParent(parent), mParamDesc(paramDesc)
 	{ }
 
 	template<bool Core>
@@ -218,7 +218,7 @@ namespace BansheeEngine
 
 	template<bool Core>
 	TGpuParamLoadStoreTexture<Core>::TGpuParamLoadStoreTexture(GpuParamObjectDesc* paramDesc, const GpuParamsType& parent)
-		:mParamDesc(paramDesc), mParent(parent)
+		:mParent(parent), mParamDesc(paramDesc)
 	{ }
 
 	template<bool Core>
@@ -251,7 +251,7 @@ namespace BansheeEngine
 
 	template<bool Core>
 	TGpuParamSampState<Core>::TGpuParamSampState(GpuParamObjectDesc* paramDesc, const GpuParamsType& parent)
-		:mParamDesc(paramDesc), mParent(parent)
+		:mParent(parent), mParamDesc(paramDesc)
 	{ }
 
 	template<bool Core>

+ 8 - 8
Source/BansheeCore/Source/BsGpuParamBlockBuffer.cpp

@@ -7,7 +7,7 @@
 namespace BansheeEngine
 {
 	GpuParamBlockBufferCore::GpuParamBlockBufferCore(UINT32 size, GpuParamBlockUsage usage)
-		:mSize(size), mUsage(usage), mCachedData(nullptr), mGPUBufferDirty(false)
+		:mUsage(usage), mSize(size), mCachedData(nullptr), mGPUBufferDirty(false)
 	{
 		if (mSize > 0)
 			mCachedData = (UINT8*)bs_alloc(mSize);
@@ -24,7 +24,7 @@ namespace BansheeEngine
 	void GpuParamBlockBufferCore::write(UINT32 offset, const void* data, UINT32 size)
 	{
 #if BS_DEBUG_MODE
-		if (offset < 0 || (offset + size) > mSize)
+		if ((offset + size) > mSize)
 		{
 			BS_EXCEPT(InvalidParametersException, "Wanted range is out of buffer bounds. " \
 				"Available range: 0 .. " + toString(mSize) + ". " \
@@ -39,7 +39,7 @@ namespace BansheeEngine
 	void GpuParamBlockBufferCore::read(UINT32 offset, void* data, UINT32 size)
 	{
 #if BS_DEBUG_MODE
-		if (offset < 0 || (offset + size) > mSize)
+		if ((offset + size) > mSize)
 		{
 			BS_EXCEPT(InvalidParametersException, "Wanted range is out of buffer bounds. " \
 				"Available range: 0 .. " + toString(mSize) + ". " \
@@ -53,7 +53,7 @@ namespace BansheeEngine
 	void GpuParamBlockBufferCore::zeroOut(UINT32 offset, UINT32 size)
 	{
 #if BS_DEBUG_MODE
-		if (offset < 0 || (offset + size) > mSize)
+		if ((offset + size) > mSize)
 		{
 			BS_EXCEPT(InvalidParametersException, "Wanted range is out of buffer bounds. " \
 				"Available range: 0 .. " + toString(mSize) + ". " \
@@ -87,7 +87,7 @@ namespace BansheeEngine
 	}
 
 	GpuParamBlockBuffer::GpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage)
-		:mSize(size), mUsage(usage), mCachedData(nullptr)
+		:mUsage(usage), mSize(size), mCachedData(nullptr)
 	{
 		if (mSize > 0)
 			mCachedData = (UINT8*)bs_alloc(mSize);
@@ -104,7 +104,7 @@ namespace BansheeEngine
 	void GpuParamBlockBuffer::write(UINT32 offset, const void* data, UINT32 size)
 	{
 #if BS_DEBUG_MODE
-		if (offset < 0 || (offset + size) > mSize)
+		if ((offset + size) > mSize)
 		{
 			BS_EXCEPT(InvalidParametersException, "Wanted range is out of buffer bounds. " \
 				"Available range: 0 .. " + toString(mSize) + ". " \
@@ -119,7 +119,7 @@ namespace BansheeEngine
 	void GpuParamBlockBuffer::read(UINT32 offset, void* data, UINT32 size)
 	{
 #if BS_DEBUG_MODE
-		if (offset < 0 || (offset + size) > mSize)
+		if ((offset + size) > mSize)
 		{
 			BS_EXCEPT(InvalidParametersException, "Wanted range is out of buffer bounds. " \
 				"Available range: 0 .. " + toString(mSize) + ". " \
@@ -133,7 +133,7 @@ namespace BansheeEngine
 	void GpuParamBlockBuffer::zeroOut(UINT32 offset, UINT32 size)
 	{
 #if BS_DEBUG_MODE
-		if (offset < 0 || (offset + size) > mSize)
+		if ((offset + size) > mSize)
 		{
 			BS_EXCEPT(InvalidParametersException, "Wanted range is out of buffer bounds. " \
 				"Available range: 0 .. " + toString(mSize) + ". " \

+ 6 - 6
Source/BansheeCore/Source/BsGpuParams.cpp

@@ -15,8 +15,8 @@
 namespace BansheeEngine
 {
 	GpuParamsBase::GpuParamsBase(const SPtr<GpuParamDesc>& paramDesc, bool transposeMatrices)
-		:mParamDesc(paramDesc), mTransposeMatrices(transposeMatrices), mNumParamBlocks(0), mNumSamplerStates(0),
-		mNumTextures(0), mTextureInfo(nullptr)
+		: mParamDesc(paramDesc), mNumParamBlocks(0), mNumTextures(0), mNumSamplerStates(0), mTextureInfo(nullptr)
+		, mTransposeMatrices(transposeMatrices)
 	{
 		for (auto& paramBlock : mParamDesc->paramBlocks)
 		{
@@ -96,7 +96,7 @@ UINT32 GpuParamsBase::getDataParamSize(const String& name) const
 
 	bool GpuParamsBase::isLoadStoreTexture(UINT32 slot) const
 	{
-		if (slot < 0 || slot >= mNumTextures)
+		if (slot >= mNumTextures)
 		{
 			BS_EXCEPT(InvalidParametersException, "Index out of range: Valid range: 0 .. " +
 				toString(mNumTextures - 1) + ". Requested: " + toString(slot));
@@ -107,7 +107,7 @@ UINT32 GpuParamsBase::getDataParamSize(const String& name) const
 
 	void GpuParamsBase::setIsLoadStoreTexture(UINT32 slot, bool isLoadStore)
 	{
-		if (slot < 0 || slot >= mNumTextures)
+		if (slot >= mNumTextures)
 		{
 			BS_EXCEPT(InvalidParametersException, "Index out of range: Valid range: 0 .. " +
 				toString(mNumTextures - 1) + ". Requested: " + toString(slot));
@@ -118,7 +118,7 @@ UINT32 GpuParamsBase::getDataParamSize(const String& name) const
 
 	const TextureSurface& GpuParamsBase::getLoadStoreSurface(UINT32 slot) const
 	{
-		if (slot < 0 || slot >= mNumTextures)
+		if (slot >= mNumTextures)
 		{
 			BS_EXCEPT(InvalidParametersException, "Index out of range: Valid range: 0 .. " +
 				toString(mNumTextures - 1) + ". Requested: " + toString(slot));
@@ -129,7 +129,7 @@ UINT32 GpuParamsBase::getDataParamSize(const String& name) const
 
 	void GpuParamsBase::setLoadStoreSurface(UINT32 slot, const TextureSurface& surface) const
 	{
-		if (slot < 0 || slot >= mNumTextures)
+		if (slot >= mNumTextures)
 		{
 			BS_EXCEPT(InvalidParametersException, "Index out of range: Valid range: 0 .. " +
 				toString(mNumTextures - 1) + ". Requested: " + toString(slot));

+ 4 - 5
Source/BansheeCore/Source/BsGpuProgram.cpp

@@ -12,13 +12,12 @@ namespace BansheeEngine
 {
 	GpuProgramProperties::GpuProgramProperties(const String& source, const String& entryPoint,
 		GpuProgramType gptype, GpuProgramProfile profile)
-		:mSource(source), mEntryPoint(entryPoint), mType(gptype), mProfile(profile)
+		:mType(gptype), mEntryPoint(entryPoint), mProfile(profile), mSource(source)
 	{ }
 		
 	GpuProgramCore::GpuProgramCore(const String& source, const String& entryPoint,
 		GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired)
-		: mProperties(source, entryPoint, gptype, profile), mIsCompiled(false),
-		mNeedsAdjacencyInfo(isAdjacencyInfoRequired)
+		:mNeedsAdjacencyInfo(isAdjacencyInfoRequired), mIsCompiled(false), mProperties(source, entryPoint, gptype, profile)
 	{
 		mParametersDesc = bs_shared_ptr_new<GpuParamDesc>();
 	}
@@ -52,8 +51,8 @@ namespace BansheeEngine
 
 	GpuProgram::GpuProgram(const String& source, const String& entryPoint, const String& language,
 		GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired) 
-		: mProperties(source, entryPoint, gptype, profile), mLanguage(language),
-		 mNeedsAdjacencyInfo(isAdjacencyInfoRequired)
+		: mNeedsAdjacencyInfo(isAdjacencyInfoRequired), mLanguage(language)
+		, mProperties(source, entryPoint, gptype, profile)
     {
 
     }

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

@@ -12,7 +12,7 @@ namespace BansheeEngine
 	{
 	public:
 		NullProgramCore()
-			:GpuProgramCore("", "", GPT_VERTEX_PROGRAM, GPP_NONE, nullptr)
+			:GpuProgramCore("", "", GPT_VERTEX_PROGRAM, GPP_NONE, false)
 		{ }
 
 		~NullProgramCore() { }

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

@@ -8,7 +8,7 @@
 namespace BansheeEngine
 {
 	GpuResourceData::GpuResourceData()
-		:mData(nullptr), mLocked(false), mOwnsData(false)
+		:mData(nullptr), mOwnsData(false), mLocked(false)
 	{
 
 	}

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

@@ -32,7 +32,7 @@ namespace BansheeEngine
 	}
 
     IndexBuffer::IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage) 
-		: mUsage(usage), mProperties(idxType, numIndexes)
+		:mProperties(idxType, numIndexes), mUsage(usage)
     {
 
 	}

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

@@ -21,7 +21,7 @@ namespace BansheeEngine
 	}
 
 	Input::Input()
-		:mLastPositionSet(false), mPointerDoubleClicked(false)
+		:mPointerDoubleClicked(false), mLastPositionSet(false)
 	{ 
 		mOSInputHandler = bs_shared_ptr_new<OSInputHandler>();
 

+ 5 - 4
Source/BansheeCore/Source/BsMaterial.cpp

@@ -100,7 +100,6 @@ namespace BansheeEngine
 			// Check regular data params
 			for (auto iter2 = curDesc.params.begin(); iter2 != curDesc.params.end(); ++iter2)
 			{
-				bool isParameterValid = true;
 				const GpuParamDataDesc& curParam = iter2->second;
 
 				auto dataFindIter = validParams.find(iter2->first);
@@ -479,7 +478,7 @@ namespace BansheeEngine
 	}
 
 	template<bool Core>
-	typename TMaterial<Core>::PassType TMaterial<Core>::getPass(UINT32 passIdx) const
+	SPtr<typename TMaterial<Core>::PassType> TMaterial<Core>::getPass(UINT32 passIdx) const
 	{
 		if (passIdx < 0 || passIdx >= mShader->getBestTechnique()->getNumPasses())
 			BS_EXCEPT(InvalidParametersException, "Invalid pass index.");
@@ -694,7 +693,7 @@ namespace BansheeEngine
 
 			for (UINT32 i = 0; i < mBestTechnique->getNumPasses(); i++)
 			{
-				PassType curPass = mBestTechnique->getPass(i);
+				SPtr<PassType> curPass = mBestTechnique->getPass(i);
 				SPtr<PassParamsType> params = SPtr<PassParamsType>(new PassParamsType());
 
 				GpuProgramType vertProgram = curPass->getVertexProgram();
@@ -869,6 +868,8 @@ namespace BansheeEngine
 				}
 			}
 			break;
+			default:
+				break;
 			}
 		}
 
@@ -927,7 +928,7 @@ namespace BansheeEngine
 						if (paramPtr->hasParam(gpuVarName))
 						{
 							gpuParams->push_back(TGpuDataParam<T, Core>());
-							paramPtr->getParam<T>(gpuVarName, gpuParams->back());
+							paramPtr->template getParam<T>(gpuVarName, gpuParams->back());
 						}
 					}
 				}

+ 2 - 0
Source/BansheeCore/Source/BsMaterialParams.cpp

@@ -262,6 +262,8 @@ namespace BansheeEngine
 		case GetParamResult::IndexOutOfBounds:
 			LOGWRN("Parameter \"" + name + "\" array index " + toString(arrayIdx) + " out of range.");
 			break;
+		default:
+			break;
 		}
 	}
 

+ 4 - 5
Source/BansheeCore/Source/BsMesh.cpp

@@ -146,7 +146,6 @@ namespace BansheeEngine
 			}
 
 			SPtr<VertexBufferCore> vertexBuffer = mVertexData->getBuffer(i);
-			const VertexBufferProperties& vbProps = vertexBuffer->getProperties();
 
 			UINT32 bufferSize = meshData.getStreamSize(i);
 			UINT8* srcVertBufferData = meshData.getStreamData(i);
@@ -352,16 +351,16 @@ namespace BansheeEngine
 
 	Mesh::Mesh(const SPtr<MeshData>& initialMeshData, int usage, DrawOperationType drawOp)
 		:MeshBase(initialMeshData->getNumVertices(), initialMeshData->getNumIndices(), drawOp), 
-		mIndexType(initialMeshData->getIndexType()), mVertexDesc(initialMeshData->getVertexDesc()), 
-		mCPUData(initialMeshData), mUsage(usage)
+		mCPUData(initialMeshData), mVertexDesc(initialMeshData->getVertexDesc()),
+		mUsage(usage), mIndexType(initialMeshData->getIndexType())
 	{
 
 	}
 
 	Mesh::Mesh(const SPtr<MeshData>& initialMeshData, const Vector<SubMesh>& subMeshes, int usage)
 		:MeshBase(initialMeshData->getNumVertices(), initialMeshData->getNumIndices(), subMeshes),
-		mIndexType(initialMeshData->getIndexType()), mVertexDesc(initialMeshData->getVertexDesc()), 
-		mCPUData(initialMeshData), mUsage(usage)
+		mCPUData(initialMeshData), mVertexDesc(initialMeshData->getVertexDesc()), 
+		mUsage(usage), mIndexType(initialMeshData->getIndexType())
 	{
 
 	}

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

@@ -9,26 +9,26 @@
 namespace BansheeEngine
 {
 	MeshProperties::MeshProperties()
-		:mNumIndices(0), mNumVertices(0)
+		:mNumVertices(0), mNumIndices(0)
 	{
 		mSubMeshes.reserve(10);
 	}
 
 	MeshProperties::MeshProperties(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp)
-		:mNumIndices(numIndices), mNumVertices(numVertices)
+		:mNumVertices(numVertices), mNumIndices(numIndices)
 	{
 		mSubMeshes.push_back(SubMesh(0, numIndices, drawOp));
 	}
 
 	MeshProperties::MeshProperties(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes)
-		:mNumIndices(numIndices), mNumVertices(numVertices)
+		:mNumVertices(numVertices), mNumIndices(numIndices)
 	{
 		mSubMeshes = subMeshes;
 	}
 
 	const SubMesh& MeshProperties::getSubMesh(UINT32 subMeshIdx) const
 	{
-		if (subMeshIdx < 0 || subMeshIdx >= mSubMeshes.size())
+		if (subMeshIdx >= mSubMeshes.size())
 		{
 			BS_EXCEPT(InvalidParametersException, "Invalid sub-mesh index ("
 				+ toString(subMeshIdx) + "). Number of sub-meshes available: " + toString((int)mSubMeshes.size()));

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

@@ -15,7 +15,7 @@
 namespace BansheeEngine
 {
 	MeshData::MeshData(UINT32 numVertices, UINT32 numIndexes, const SPtr<VertexDataDesc>& vertexData, IndexType indexType)
-	   :mNumVertices(numVertices), mNumIndices(numIndexes), mVertexData(vertexData), mIndexType(indexType)
+	   :mNumVertices(numVertices), mNumIndices(numIndexes), mIndexType(indexType), mVertexData(vertexData)
 	{
 		allocateInternalBuffer();
 	}

+ 3 - 5
Source/BansheeCore/Source/BsMeshHeap.cpp

@@ -17,8 +17,8 @@ namespace BansheeEngine
 
 	MeshHeapCore::MeshHeapCore(UINT32 numVertices, UINT32 numIndices,
 		const SPtr<VertexDataDesc>& vertexDesc, IndexType indexType)
-		:mNumVertices(numVertices), mNumIndices(numIndices), mIndexType(indexType), 
-		mVertexDesc(vertexDesc), mCPUIndexData(nullptr), mNextQueryId(0)
+		: mNumVertices(numVertices), mNumIndices(numIndices), mCPUIndexData(nullptr), mVertexDesc(vertexDesc)
+		, mIndexType(indexType), mNextQueryId(0)
 	{
 		for (UINT32 i = 0; i <= mVertexDesc->getMaxStreamIdx(); i++)
 		{
@@ -224,7 +224,6 @@ namespace BansheeEngine
 			}
 
 			SPtr<VertexBufferCore> vertexBuffer = mVertexData->getBuffer(i);
-			const VertexBufferProperties& vbProps = vertexBuffer->getProperties();
 
 			UINT8* vertDest = mCPUVertexData[i] + vertChunkStart * vertSize;
 			memcpy(vertDest, meshData->getStreamData(i), meshData->getNumVertices() * vertSize);
@@ -636,8 +635,7 @@ namespace BansheeEngine
 
 	MeshHeap::MeshHeap(UINT32 numVertices, UINT32 numIndices, 
 		const SPtr<VertexDataDesc>& vertexDesc, IndexType indexType)
-		:mNumVertices(numVertices), mNumIndices(numIndices), mNextFreeId(0), 
-		mIndexType(indexType), mVertexDesc(vertexDesc)
+		:mNumVertices(numVertices), mNumIndices(numIndices), mVertexDesc(vertexDesc), mIndexType(indexType), mNextFreeId(0)
 	{
 	}
 

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

@@ -15,7 +15,7 @@ namespace BansheeEngine
 	struct VertexConnectivity
 	{
 		VertexConnectivity(UINT8* indices, UINT32 numVertices, UINT32 numFaces, UINT32 indexSize)
-			:vertexFaces(nullptr), mMaxFacesPerVertex(0), mFaces(nullptr), mNumVertices(numVertices)
+			:vertexFaces(nullptr), mMaxFacesPerVertex(0), mNumVertices(numVertices), mFaces(nullptr)
 		{
 			vertexFaces = bs_newN<VertexFaces>(numVertices);
 

+ 2 - 2
Source/BansheeCore/Source/BsMultiRenderTexture.cpp

@@ -194,7 +194,7 @@ namespace BansheeEngine
 
 	void MultiRenderTextureCore::copyToMemory(PixelData &dst, FrameBuffer buffer)
 	{
-		throw std::exception("The method or operation is not implemented.");
+		BS_EXCEPT(InternalErrorException,"The method or operation is not implemented.");
 	}
 
 	MultiRenderTexture::MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc)
@@ -252,7 +252,7 @@ namespace BansheeEngine
 
 		MultiRenderTextureProperties& props = const_cast<MultiRenderTextureProperties&>(getProperties());
 
-		memcpy(buffer, &props, size);
+		memcpy(buffer, (void*)&props, size);
 		return CoreSyncData(buffer, size);
 	}
 

+ 7 - 5
Source/BansheeCore/Source/BsOSInputHandler.cpp

@@ -10,7 +10,7 @@ using namespace std::placeholders;
 namespace BansheeEngine
 {
 	OSInputHandler::OSInputHandler()
-		:mMouseScroll(0.0f), mLastCursorPosSet(false)
+		:mLastCursorPosSet(false), mMouseScroll(0.0f)
 	{
 		mCharInputConn = Platform::onCharInput.connect(std::bind(&OSInputHandler::charInput, this, _1));
 		mCursorMovedConn = Platform::onCursorMoved.connect(std::bind(&OSInputHandler::cursorMoved, this, _1, _2));
@@ -113,6 +113,8 @@ namespace BansheeEngine
 			case OSMouseButton::Right:
 				event.button = PointerEventButton::Right;
 				break;
+			default:
+				break;
 			}
 			
 			event.screenPos = btnState.cursorPos;
@@ -182,7 +184,7 @@ namespace BansheeEngine
 		mInputString += character;
 	}
 
-	void OSInputHandler::cursorMoved(const Vector2I& cursorPos, OSPointerButtonStates& btnStates)
+	void OSInputHandler::cursorMoved(const Vector2I& cursorPos, const OSPointerButtonStates& btnStates)
 	{
 		BS_LOCK_MUTEX(mOSInputMutex);
 
@@ -191,7 +193,7 @@ namespace BansheeEngine
 	}
 
 	void OSInputHandler::cursorPressed(const Vector2I& cursorPos, 
-		OSMouseButton button, OSPointerButtonStates& btnStates)
+		OSMouseButton button, const OSPointerButtonStates& btnStates)
 	{
 		BS_LOCK_MUTEX(mOSInputMutex);
 
@@ -205,7 +207,7 @@ namespace BansheeEngine
 	}
 
 	void OSInputHandler::cursorReleased(const Vector2I& cursorPos, 
-		OSMouseButton button, OSPointerButtonStates& btnStates)
+		OSMouseButton button, const OSPointerButtonStates& btnStates)
 	{
 		BS_LOCK_MUTEX(mOSInputMutex);
 
@@ -218,7 +220,7 @@ namespace BansheeEngine
 		btnState.btnStates = btnStates;
 	}
 
-	void OSInputHandler::cursorDoubleClick(const Vector2I& cursorPos, OSPointerButtonStates& btnStates)
+	void OSInputHandler::cursorDoubleClick(const Vector2I& cursorPos, const OSPointerButtonStates& btnStates)
 	{
 		BS_LOCK_MUTEX(mOSInputMutex);
 

+ 7 - 0
Source/BansheeCore/Source/BsPhysics.cpp

@@ -24,6 +24,13 @@ namespace BansheeEngine
 	{
 		assert(groupA < CollisionMapSize && groupB < CollisionMapSize);
 
+		enum class MyFlag
+		{
+			Flag1 = 1 << 0,
+			Flag2 = 1 << 1,
+			Flag3 = 1 << 2
+		};
+
 		BS_LOCK_MUTEX(mMutex);
 		return mCollisionMap[groupA][groupB];
 	}

+ 2 - 5
Source/BansheeCore/Source/BsPixelUtil.cpp

@@ -901,10 +901,9 @@ namespace BansheeEngine
 			return nvtt::Format_BC4;
 		case PF_BC5:
 			return nvtt::Format_BC5;
+		default: // Unsupported format
+			return nvtt::Format_BC3;
 		}
-
-		// Unsupported format
-		return nvtt::Format_BC3;
 	}
 
 	nvtt::Quality toNVTTQuality(CompressionQuality quality)
@@ -1659,8 +1658,6 @@ namespace BansheeEngine
 		if (src.getDepth() != 1)
 			BS_EXCEPT(InvalidParametersException, "3D textures are not supported.");
 
-		PixelFormat pf = options.format;
-
 		if (isCompressed(src.getFormat()))
 			BS_EXCEPT(InvalidParametersException, "Source data cannot be compressed.");
 

+ 2 - 2
Source/BansheeCore/Source/BsPlatform.cpp

@@ -5,8 +5,8 @@
 namespace BansheeEngine
 {
 	OSDropTarget::OSDropTarget(const RenderWindow* ownerWindow, INT32 x, INT32 y, UINT32 width, UINT32 height)
-		:mOwnerWindow(ownerWindow), mX(x), mY(y), mWidth(width), mHeight(height), mDropType(OSDropType::None), 
-		mFileList(nullptr), mActive(false)
+		:mX(x), mY(y), mWidth(width), mHeight(height), mActive(false), mOwnerWindow(ownerWindow), 
+		mDropType(OSDropType::None), mFileList(nullptr)
 	{
 		
 	}

+ 31 - 7
Source/BansheeCore/Source/BsProfilerCPU.cpp

@@ -4,6 +4,14 @@
 #include "BsDebug.h"
 #include "BsPlatform.h"
 
+#if BS_COMPILER == BS_COMPILER_GNUC || BS_COMPILER == BS_COMPILER_CLANG
+	#include "cpuid.h"
+#endif
+
+#if BS_COMPILER == BS_COMPILER_CLANG
+	#include "intrin.h"
+#endif
+
 namespace BansheeEngine
 {
 	ProfilerCPU::Timer::Timer()
@@ -54,15 +62,31 @@ namespace BansheeEngine
 	inline UINT64 ProfilerCPU::TimerPrecise::getNumCycles() 
 	{
 #if BS_COMPILER == BS_COMPILER_GNUC
-		asm volatile("cpuid" : : : "%eax", "%ebx", "%ecx", "%edx" );
-		UINT32 __a,__d;
-		asm volatile("rdtsc" : "=a" (__a), "=d" (__d));
-		return ( UINT64(__a) | UINT64(__d) << 32 );
+		int a = 0;
+		int b[4];
+		__get_cpuid(a, &b[0], &b[1], &b[2], &b[3]);
+
+#if BS_ARCH_TYPE == BS_ARCHITECTURE_x86_64
+		UINT32 __a, __d;
+		__asm__ __volatile__ ("rdtsc" : "=a" (__a), "=d" (__d));
+		return (UINT64(__a) | UINT64(__d) << 32);
 #else
+		UINT64 x;
+		__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
+		return x;
+#endif
+#elif BS_COMPILER == BS_COMPILER_CLANG
+		UINT32 a = 0;
+		UINT32 b[4];
+		__get_cpuid(a, &b[0], &b[1], &b[2], &b[3]);
+		return __rdtsc();
+#elif BS_COMPILER == BS_COMPILER_MSVC
 		int a[4];
 		int b = 0;
 		__cpuid(a, b);
 		return __rdtsc();
+#else
+		static_assert("Unsupported compiler");
 #endif		
 	}
 
@@ -216,7 +240,7 @@ namespace BansheeEngine
 	}
 
 	ProfilerCPU::ProfiledBlock::ProfiledBlock(FrameAlloc* alloc)
-		:children(alloc), basic(alloc), precise(alloc)
+		:basic(alloc), precise(alloc), children(alloc)
 	{ }
 
 	ProfilerCPU::ProfiledBlock::~ProfiledBlock()
@@ -241,8 +265,8 @@ namespace BansheeEngine
 	}
 
 	ProfilerCPU::ProfilerCPU()
-		:mBasicTimerOverhead(0.0), mPreciseTimerOverhead(0), mBasicSamplingOverheadMs(0.0), mPreciseSamplingOverheadCycles(0),
-		mBasicSamplingOverheadCycles(0), mPreciseSamplingOverheadMs(0.0)
+		: mBasicTimerOverhead(0.0), mPreciseTimerOverhead(0), mBasicSamplingOverheadMs(0.0), mPreciseSamplingOverheadMs(0.0)
+		, mBasicSamplingOverheadCycles(0), mPreciseSamplingOverheadCycles(0)
 	{
 		// TODO - We only estimate overhead on program start. It might be better to estimate it each time beginThread is called,
 		// and keep separate values per thread.

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

@@ -105,7 +105,7 @@ namespace BansheeEngine
 	}
 
 	RenderStateCoreManager::RenderStateCoreManager()
-		:mNextBlendStateId(0), mNextDepthStencilStateId(0), mNextRasterizerStateId(0)
+		:mNextBlendStateId(0), mNextRasterizerStateId(0), mNextDepthStencilStateId(0)
 	{
 		
 	}

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

@@ -208,7 +208,7 @@ namespace BansheeEngine
 
 		RenderTextureProperties& props = const_cast<RenderTextureProperties&>(getProperties());
 
-		memcpy(buffer, &props, size);
+		memcpy(buffer, (void*)&props, size);
 		return CoreSyncData(buffer, size);
 	}
 

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

@@ -10,7 +10,7 @@ namespace BansheeEngine
 	{ }
 
 	SavedResourceData::SavedResourceData(const Vector<String>& dependencies, bool allowAsync)
-		: mAllowAsync(allowAsync), mDependencies(dependencies)
+		:mDependencies(dependencies), mAllowAsync(allowAsync)
 	{
 
 	}

+ 5 - 5
Source/BansheeCore/Source/BsSceneObject.cpp

@@ -15,10 +15,10 @@
 namespace BansheeEngine
 {
 	SceneObject::SceneObject(const String& name, UINT32 flags)
-		:GameObject(), mPosition(Vector3::ZERO), mRotation(Quaternion::IDENTITY), mScale(Vector3::ONE),
-		mWorldPosition(Vector3::ZERO), mWorldRotation(Quaternion::IDENTITY), mWorldScale(Vector3::ONE),
-		mCachedLocalTfrm(Matrix4::IDENTITY), mDirtyFlags(0xFFFFFFFF), mCachedWorldTfrm(Matrix4::IDENTITY), 
-		mActiveSelf(true), mActiveHierarchy(true), mDirtyHash(0), mFlags(flags), mPrefabHash(0)
+		: GameObject(), mPrefabHash(0), mFlags(flags), mPosition(Vector3::ZERO), mRotation(Quaternion::IDENTITY)
+		, mScale(Vector3::ONE), mWorldPosition(Vector3::ZERO), mWorldRotation(Quaternion::IDENTITY)
+		, mWorldScale(Vector3::ONE), mCachedLocalTfrm(Matrix4::IDENTITY), mCachedWorldTfrm(Matrix4::IDENTITY)
+		, mDirtyFlags(0xFFFFFFFF), mDirtyHash(0), mActiveSelf(true), mActiveHierarchy(true)
 	{
 		setName(name);
 	}
@@ -554,7 +554,7 @@ namespace BansheeEngine
 
 	HSceneObject SceneObject::getChild(UINT32 idx) const
 	{
-		if(idx < 0 || idx >= mChildren.size())
+		if(idx >= mChildren.size())
 		{
 			BS_EXCEPT(InternalErrorException, "Child index out of range.");
 		}

+ 8 - 8
Source/BansheeCore/Source/BsShader.cpp

@@ -13,11 +13,11 @@
 
 namespace BansheeEngine
 {
-	std::atomic<UINT32> ShaderCore::mNextShaderId = 0;
+	std::atomic<UINT32> ShaderCore::mNextShaderId;
 
 	template<bool Core>
 	TSHADER_DESC<Core>::TSHADER_DESC()
-		:queuePriority(0), queueSortType(QueueSortType::None), separablePasses(false), flags(0)
+		:queueSortType(QueueSortType::None), queuePriority(0), separablePasses(false), flags(0)
 	{
 
 	}
@@ -397,9 +397,9 @@ namespace BansheeEngine
 			case GPOT_SAMPLERCUBE:
 			case GPOT_SAMPLER2DMS:
 				return true;
+			default:
+				return false;
 		}
-
-		return false;
 	}
 
 	bool Shader::isTexture(GpuParamObjectType type)
@@ -412,9 +412,9 @@ namespace BansheeEngine
 		case GPOT_TEXTURECUBE:
 		case GPOT_TEXTURE2DMS:
 			return true;
+		default:
+			return false;
 		}
-
-		return false;
 	}
 
 	bool Shader::isBuffer(GpuParamObjectType type)
@@ -430,9 +430,9 @@ namespace BansheeEngine
 		case GPOT_RWSTRUCTURED_BUFFER_WITH_COUNTER:
 		case GPOT_RWTYPED_BUFFER:
 			return true;
+		default:
+			return false;
 		}
-
-		return false;
 	}
 
 	UINT32 Shader::getDataParamSize(GpuParamDataType type)

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

@@ -10,7 +10,7 @@ namespace BansheeEngine
 	const Language StringTable::DEFAULT_LANGUAGE = Language::EnglishUS;
 
 	LocalizedStringData::LocalizedStringData()
-		:parameterOffsets(nullptr), numParameters(0)
+		:numParameters(0), parameterOffsets(nullptr)
 	{
 
 	}

+ 5 - 6
Source/BansheeCore/Source/BsTextData.cpp

@@ -161,7 +161,6 @@ namespace BansheeEngine
 	{
 		UINT32 charWidth = 0;
 
-		UINT32 word = mWordsEnd;
 		if (!mIsEmpty)
 		{
 			TextWord& lastWord = MemBuffer->WordBuffer[mWordsEnd];
@@ -349,8 +348,8 @@ namespace BansheeEngine
 	}
 
 	TextDataBase::TextDataBase(const WString& text, const HFont& font, UINT32 fontSize, UINT32 width, UINT32 height, bool wordWrap, bool wordBreak)
-		:mFont(font), mChars(nullptr), mFontData(nullptr),
-		mNumChars(0), mWords(nullptr), mNumWords(0), mLines(nullptr), mNumLines(0), mPageInfos(nullptr), mNumPageInfos(0)
+		: mChars(nullptr), mNumChars(0), mWords(nullptr), mNumWords(0), mLines(nullptr), mNumLines(0), mPageInfos(nullptr)
+		, mNumPageInfos(0), mFont(font), mFontData(nullptr)
 	{
 		// In order to reduce number of memory allocations algorithm first calculates data into temporary buffers and then copies the results
 		initAlloc();
@@ -540,7 +539,7 @@ namespace BansheeEngine
 
 		dataPtr += lineArraySize;
 		mPageInfos = (PageInfo*)dataPtr;
-		memcpy(mPageInfos, &MemBuffer->PageBuffer[0], pageInfoArraySize);
+		memcpy((void*)mPageInfos, (void*)&MemBuffer->PageBuffer[0], pageInfoArraySize);
 
 		if (freeTemporary)
 			MemBuffer->deallocAll();
@@ -572,7 +571,7 @@ namespace BansheeEngine
 			MemBuffer = bs_new<BufferData>();
 	}
 
-	TextDataBase::BufferData* TextDataBase::MemBuffer = nullptr;
+	BS_THREADLOCAL TextDataBase::BufferData* TextDataBase::MemBuffer = nullptr;
 
 	TextDataBase::BufferData::BufferData()
 	{
@@ -645,7 +644,7 @@ namespace BansheeEngine
 		{
 			UINT32 newBufferSize = PageBufferSize * 2;
 			PageInfo* newBuffer = bs_newN<PageInfo>(newBufferSize);
-			memcpy(PageBuffer, newBuffer, PageBufferSize);
+			memcpy((void*)PageBuffer, (void*)newBuffer, PageBufferSize);
 
 			bs_deleteN(PageBuffer, PageBufferSize);
 			PageBuffer = newBuffer;

+ 2 - 3
Source/BansheeCore/Source/BsTexture.cpp

@@ -59,7 +59,6 @@ namespace BansheeEngine
 		UINT32 mip = 0;
 		mapFromSubresourceIdx(subresourceIdx, face, mip);
 
-		UINT32 numMips = getNumMipmaps();
 		UINT32 width = getWidth();
 		UINT32 height = getHeight();
 		UINT32 depth = getDepth();
@@ -157,10 +156,10 @@ namespace BansheeEngine
 	{
 		THROW_IF_NOT_CORE_THREAD;
 
-		if (mipLevel < 0 || mipLevel > mProperties.getNumMipmaps())
+		if (mipLevel > mProperties.getNumMipmaps())
 			BS_EXCEPT(InvalidParametersException, "Invalid mip level: " + toString(mipLevel) + ". Min is 0, max is " + toString(mProperties.getNumMipmaps()));
 
-		if (face < 0 || face >= mProperties.getNumFaces())
+		if (face >= mProperties.getNumFaces())
 			BS_EXCEPT(InvalidParametersException, "Invalid face index: " + toString(face) + ". Min is 0, max is " + toString(mProperties.getNumFaces()));
 
 		return lockImpl(options, mipLevel, face);

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

@@ -28,7 +28,7 @@ namespace BansheeEngine
 	{ }
 
 	TextureView::TextureView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc)
-		:mOwnerTexture(texture), mDesc(desc)
+		:mDesc(desc), mOwnerTexture(texture)
 	{
 
 	}

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

@@ -46,7 +46,7 @@ namespace BansheeEngine
 	}
 
 	TransientMesh::TransientMesh(const SPtr<MeshHeap>& parentHeap, UINT32 id, UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp)
-		:MeshBase(numVertices, numIndices, drawOp), mParentHeap(parentHeap), mId(id), mIsDestroyed(false)
+		:MeshBase(numVertices, numIndices, drawOp), mIsDestroyed(false), mParentHeap(parentHeap), mId(id)
 	{
 
 	}

+ 2 - 3
Source/BansheeCore/Source/BsVertexDataDesc.cpp

@@ -57,9 +57,9 @@ namespace BansheeEngine
 	UINT32 VertexDataDesc::getMaxStreamIdx() const
 	{
 		UINT32 maxStreamIdx = 0;
-		for(auto& vertElems : mVertexElements)
+		UINT32 numElems = (UINT32)mVertexElements.size();
+		for(UINT32 i = 0; i < numElems; i++)
 		{
-			UINT32 offset = 0;
 			for(auto& vertElem : mVertexElements)
 			{
 				maxStreamIdx = std::max((UINT32)maxStreamIdx, (UINT32)vertElem.getStreamIdx());
@@ -150,7 +150,6 @@ namespace BansheeEngine
 	UINT32 VertexDataDesc::getStreamOffset(UINT32 streamIdx) const
 	{
 		UINT32 streamOffset = 0;
-		bool found = false;
 		for(auto& element : mVertexElements)
 		{
 			if(element.getStreamIdx() == streamIdx)

+ 8 - 0
Source/BansheeCore/Source/BsVertexDeclaration.cpp

@@ -44,6 +44,10 @@ namespace BansheeEngine
 			return sizeof(short)*4;
 		case VET_UBYTE4:
 			return sizeof(unsigned char)*4;
+		case VET_UINT4:
+			return sizeof(UINT32) * 4;
+		case VET_SINT4:
+			return sizeof(INT32) * 4;
 		}
 
 		return 0;
@@ -75,6 +79,10 @@ namespace BansheeEngine
 			return 4;
 		case VET_UBYTE4:
 			return 4;
+		case VET_UINT4:
+			return 4;
+		case VET_SINT4:
+			return 4;
 		}
 
 		BS_EXCEPT(InvalidParametersException, "Invalid type");

+ 3 - 3
Source/BansheeCore/Source/BsViewport.cpp

@@ -10,11 +10,11 @@
 
 namespace BansheeEngine 
 {
-	const Color Viewport::DEFAULT_CLEAR_COLOR = Color(83.0f / 255.0f, 83.0f / 255.0f, 83.0f / 255.0f);
+	const Color ViewportBase::DEFAULT_CLEAR_COLOR = Color(83.0f / 255.0f, 83.0f / 255.0f, 83.0f / 255.0f);
 
 	ViewportBase::ViewportBase(float x, float y, float width, float height)
-         :mNormArea(x, y, width, height), mClearColor(DEFAULT_CLEAR_COLOR), mRequiresColorClear(true), 
-		 mRequiresDepthClear(true), mRequiresStencilClear(false), mStencilClearValue(0), mDepthClearValue(1.0f)
+		: mNormArea(x, y, width, height), mRequiresColorClear(true), mRequiresDepthClear(true)
+		, mRequiresStencilClear(false), mClearColor(DEFAULT_CLEAR_COLOR), mDepthClearValue(1.0f), mStencilClearValue(0)
     {
 
     }

+ 0 - 2
Source/BansheeCore/Source/Win32/BsWin32BrowseDialogs.cpp

@@ -5,7 +5,6 @@
 #include "BsAsyncOp.h"
 #include "BsCoreThread.h"
 #include "Win32/BsWin32Window.h"
-#include <atlbase.h>
 #include <ShObjIdl.h>
 
 using namespace std::placeholders;
@@ -15,7 +14,6 @@ namespace BansheeEngine
 	void addFiltersToDialog(IFileDialog* fileDialog, const WString& filterList)
 	{
 		const wchar_t EMPTY_WSTR[] = L"";
-		const wchar_t WILDCARD[] = L"*.*";
 
 		if (filterList.empty())
 			return;

+ 3 - 10
Source/BansheeCore/Source/Win32/BsWin32FolderMonitor.cpp

@@ -399,16 +399,7 @@ namespace BansheeEngine
 
 		if(mPimpl->mWorkerThread != nullptr)
 		{
-			try
-			{
-				watchInfo->startMonitor(mPimpl->mCompPortHandle);
-			}
-			catch (Exception* e)
-			{
-				mPimpl->mFoldersToWatch.erase(mPimpl->mFoldersToWatch.end() - 1);
-				bs_delete(watchInfo);
-				throw(e);
-			}
+			watchInfo->startMonitor(mPimpl->mCompPortHandle);
 		}
 		else
 		{
@@ -579,6 +570,8 @@ namespace BansheeEngine
 						}
 					}
 
+					break;
+				default:
 					break;
 				}
 			}

+ 4 - 4
Source/BansheeCore/Source/Win32/BsWin32Platform.cpp

@@ -14,10 +14,10 @@
 
 namespace BansheeEngine
 {
-	Event<void(const Vector2I&, OSPointerButtonStates)> Platform::onCursorMoved;
-	Event<void(const Vector2I&, OSMouseButton button, OSPointerButtonStates)> Platform::onCursorButtonPressed;
-	Event<void(const Vector2I&, OSMouseButton button, OSPointerButtonStates)> Platform::onCursorButtonReleased;
-	Event<void(const Vector2I&, OSPointerButtonStates)> Platform::onCursorDoubleClick;
+	Event<void(const Vector2I&, const OSPointerButtonStates&)> Platform::onCursorMoved;
+	Event<void(const Vector2I&, OSMouseButton button, const OSPointerButtonStates&)> Platform::onCursorButtonPressed;
+	Event<void(const Vector2I&, OSMouseButton button, const OSPointerButtonStates&)> Platform::onCursorButtonReleased;
+	Event<void(const Vector2I&, const OSPointerButtonStates&)> Platform::onCursorDoubleClick;
 	Event<void(InputCommandType)> Platform::onInputCommand;
 	Event<void(float)> Platform::onMouseWheelScrolled;
 	Event<void(UINT32)> Platform::onCharInput;

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

@@ -13,8 +13,8 @@ namespace BansheeEngine
 		
 	}
 
-	HEString::HEString(const WString& identifier, const WString& default)
-		: mInternal(identifier, default, ENGINE_STRING_TABLE_ID)
+	HEString::HEString(const WString& identifier, const WString& defaultString)
+		: mInternal(identifier, defaultString, ENGINE_STRING_TABLE_ID)
 	{
 		
 	}

+ 8 - 8
Source/BansheeUtility/Include/BsBitwise.h

@@ -62,7 +62,7 @@ namespace BansheeEngine
 
 		/** Takes a value with a given src bit mask, and produces another value with a desired bit mask. */
 		template<typename SrcT, typename DestT>
-        static inline DestT convertBitPattern(SrcT srcValue, SrcT srcBitMask, DestT destBitMask)
+        static DestT convertBitPattern(SrcT srcValue, SrcT srcBitMask, DestT destBitMask)
 		{
 			// Mask off irrelevant source value bits (if any)
 			srcValue = srcValue & srcBitMask;
@@ -87,7 +87,7 @@ namespace BansheeEngine
 		 * Convert N bit colour channel value to P bits. It fills P bits with the bit pattern repeated. 
 		 * (this is /((1<<n)-1) in fixed point).
 		 */
-        static inline unsigned int fixedToFixed(UINT32 value, unsigned int n, unsigned int p) 
+        static unsigned int fixedToFixed(UINT32 value, unsigned int n, unsigned int p) 
         {
             if(n > p) 
             {
@@ -185,9 +185,9 @@ namespace BansheeEngine
 		/** Converts float in UINT32 format to a a half in UINT16 format. */
         static UINT16 floatToHalfI(UINT32 i)
         {
-            register int s =  (i >> 16) & 0x00008000;
-            register int e = ((i >> 23) & 0x000000ff) - (127 - 15);
-            register int m =   i        & 0x007fffff;
+            int s =  (i >> 16) & 0x00008000;
+            int e = ((i >> 23) & 0x000000ff) - (127 - 15);
+            int m =   i        & 0x007fffff;
         
             if (e <= 0)
             {
@@ -233,9 +233,9 @@ namespace BansheeEngine
 		/** Converts a half in UINT16 format to a float in UINT32 format. */
         static UINT32 halfToFloatI(UINT16 y)
         {
-            register int s = (y >> 15) & 0x00000001;
-            register int e = (y >> 10) & 0x0000001f;
-            register int m =  y        & 0x000003ff;
+            int s = (y >> 15) & 0x00000001;
+            int e = (y >> 10) & 0x0000001f;
+            int m =  y        & 0x000003ff;
         
             if (e == 0)
             {

+ 4 - 4
Source/BansheeUtility/Include/BsColor.h

@@ -228,10 +228,10 @@ namespace BansheeEngine
 
             float fInv = 1.0f / rhs;
 
-            r *= rhs;
-            g *= rhs;
-            b *= rhs;
-            a *= rhs;
+            r *= fInv;
+            g *= fInv;
+            b *= fInv;
+            a *= fInv;
 
             return *this;
         }

+ 2 - 0
Source/BansheeUtility/Include/BsFlags.h

@@ -222,8 +222,10 @@ namespace BansheeEngine
 		Storage mBits;
 	};
 
+/** Defines global operators for a Flags<Enum, Storage> implementation. */
 #define BS_FLAGS_OPERATORS(Enum) BS_FLAGS_OPERATORS_EXT(Enum, UINT32)
 
+/** Defines global operators for a Flags<Enum, Storage> implementation. */
 #define BS_FLAGS_OPERATORS_EXT(Enum, Storage)																   \
 		inline Flags<Enum, Storage> operator|(Enum a, Enum b) { Flags<Enum, Storage> r(a); r |= b; return r; } \
 		inline Flags<Enum, Storage> operator&(Enum a, Enum b) { Flags<Enum, Storage> r(a); r &= b; return r; } \

+ 2 - 2
Source/BansheeUtility/Include/BsFrameAlloc.h

@@ -174,11 +174,11 @@ namespace BansheeEngine
 				return nullptr;
 
 			if (num > static_cast<size_t>(-1) / sizeof(T))
-				throw std::bad_array_new_length();
+				return nullptr; // Error
 
 			void* const pv = mFrameAlloc->alloc((UINT32)(num * sizeof(T)));
 			if (!pv)
-				throw std::bad_alloc();
+				return nullptr; // Error
 
 			return static_cast<T*>(pv);
 		}

+ 10 - 10
Source/BansheeUtility/Include/BsPlatformDefines.h

@@ -24,24 +24,24 @@
 #define BS_EDITOR_BUILD 1
 
 // Finds the compiler type and version.
-#if defined( _MSC_VER )
-#   define BS_COMPILER BS_COMPILER_MSVC
-#   define BS_COMP_VER _MSC_VER
-#	define BS_THREADLOCAL __declspec(thread)
-#elif defined( __GNUC__ )
+#if defined(__clang__)
+#   define BS_COMPILER BS_COMPILER_CLANG
+#	define BS_COMP_VER __clang_version__
+#   define BS_THREADLOCAL __thread
+#elif defined(__GNUC__) // Check after Clang, as Clang defines this too
 #   define BS_COMPILER BS_COMPILER_GNUC
 #   define BS_COMP_VER (((__GNUC__)*100) + \
         (__GNUC_MINOR__*10) + \
         __GNUC_PATCHLEVEL__)
 #   define BS_THREADLOCAL __thread
-#elif defined ( __INTEL_COMPILER )
+#elif defined (__INTEL_COMPILER)
 #   define BS_COMPILER BS_COMPILER_INTEL
 #	define BS_COMP_VER __INTEL_COMPILER
 	// BS_THREADLOCAL define is down below because Intel compiler defines it differently based on platform
-#elif defined ( __clang__ )
-#   define BS_COMPILER BS_COMPILER_CLANG
-#	define BS_COMP_VER __clang_major__
-#   define BS_THREADLOCAL __thread
+#elif defined(_MSC_VER) // Check after Clang and Intel, since we could be building with either within VS
+#   define BS_COMPILER BS_COMPILER_MSVC
+#   define BS_COMP_VER _MSC_VER
+#	define BS_THREADLOCAL __declspec(thread)
 #else
 #   pragma error "No known compiler. "
 

+ 3 - 1
Source/BansheeUtility/Include/BsPrerequisitesUtil.h

@@ -150,7 +150,9 @@
 //      - Right now I don't have an easier way to apply these warnings globally so I'm keeping it this way.
 
 // Secure versions aren't multiplatform, so we won't be using them
-#define _CRT_SECURE_NO_WARNINGS
+#if !defined(_CRT_SECURE_NO_WARNINGS)
+	#define _CRT_SECURE_NO_WARNINGS
+#endif
 
 // disable: "<type> needs to have dll-interface to be used by clients'
 // Happens on STL member variables which are not public therefore is ok

+ 1 - 1
Source/BansheeUtility/Include/BsRTTIPlainField.h

@@ -138,7 +138,7 @@ namespace BansheeEngine
 		void initArray(const String& name, UINT16 uniqueId, Any getter,
 			Any getSize, Any setter, Any setSize, UINT64 flags)
 		{
-			int typeId = RTTIPlainType<DataType>::id; // Just making sure provided type has a type ID
+			static_assert(RTTIPlainType<DataType>::id || true, ""); // Just making sure provided type has a type ID
 
 			static_assert((RTTIPlainType<DataType>::hasDynamicSize != 0 || (sizeof(DataType) <= 255)), 
 				"Trying to create a plain RTTI field with size larger than 255. In order to use larger sizes for plain types please specialize " \

+ 35 - 35
Source/BansheeUtility/Include/BsRTTIType.h

@@ -23,81 +23,81 @@ namespace BansheeEngine
 	 */
 
 	/** Similar to BS_PLAIN_MEMBER but allows you to specify name of the field and the variable it's referencing separately. */
-#define BS_PLAIN_MEMBER_NAMED(name, field)								\
-	decltype(OwnerType::##field)& get##name(OwnerType* obj) { return obj->##field; }				\
-	void set##name(OwnerType* obj, decltype(OwnerType::##field)& val) { obj->##field = val; } 
+#define BS_PLAIN_MEMBER_NAMED(name, field)														\
+	decltype(OwnerType::field)& get##name(OwnerType* obj) { return obj->field; }				\
+	void set##name(OwnerType* obj, decltype(OwnerType::field)& val) { obj->field = val; } 
 
 	/** Similar to BS_REFL_MEMBER but allows you to specify name of the field and the variable it's referencing separately. */
-#define BS_REFL_MEMBER_NAMED(name, field)								\
-	decltype(OwnerType::##field)& get##name(OwnerType* obj) { return obj->##field; }				\
-	void set##name(OwnerType* obj, decltype(OwnerType::##field)& val) { obj->##field = val; } 
+#define BS_REFL_MEMBER_NAMED(name, field)														\
+	decltype(OwnerType::field)& get##name(OwnerType* obj) { return obj->field; }				\
+	void set##name(OwnerType* obj, decltype(OwnerType::field)& val) { obj->field = val; } 
 
 	/** Similar to BS_REFLPTR_MEMBER but allows you to specify name of the field and the variable it's referencing separately. */
-#define BS_REFLPTR_MEMBER_NAMED(name, field)								\
-	decltype(OwnerType::##field) get##name(OwnerType* obj) { return obj->##field; }				\
-	void set##name(OwnerType* obj, decltype(OwnerType::##field) val) { obj->##field = val; } 
+#define BS_REFLPTR_MEMBER_NAMED(name, field)													\
+	decltype(OwnerType::field) get##name(OwnerType* obj) { return obj->field; }					\
+	void set##name(OwnerType* obj, decltype(OwnerType::field) val) { obj->field = val; } 
 
 	/** Shortcut for defining getter/setter methods for a RTTI plain field. */
-#define BS_PLAIN_MEMBER(name)								\
-	decltype(OwnerType::##name)& get##name(OwnerType* obj) { return obj->##name; }				\
-	void set##name(OwnerType* obj, decltype(OwnerType::##name)& val) { obj->##name = val; } 
+#define BS_PLAIN_MEMBER(name)																	\
+	decltype(OwnerType::name)& get##name(OwnerType* obj) { return obj->name; }					\
+	void set##name(OwnerType* obj, decltype(OwnerType::name)& val) { obj->name = val; } 
 
 	/** Shortcut for defining getter/setter methods for a RTTI reflectable field. */
-#define BS_REFL_MEMBER(name)								\
-	decltype(OwnerType::##name)& get##name(OwnerType* obj) { return obj->##name; }				\
-	void set##name(OwnerType* obj, decltype(OwnerType::##name)& val) { obj->##name = val; } 
+#define BS_REFL_MEMBER(name)																	\
+	decltype(OwnerType::name)& get##name(OwnerType* obj) { return obj->name; }					\
+	void set##name(OwnerType* obj, decltype(OwnerType::name)& val) { obj->name = val; } 
 
 	/** Shortcut for defining getter/setter methods for a RTTI reflectable pointer field. */
 #define BS_REFLPTR_MEMBER(name)								\
-	decltype(OwnerType::##name) get##name(OwnerType* obj) { return obj->##name; }				\
-	void set##name(OwnerType* obj, decltype(OwnerType::##name) val) { obj->##name = val; } 
+	decltype(OwnerType::name) get##name(OwnerType* obj) { return obj->name; }				\
+	void set##name(OwnerType* obj, decltype(OwnerType::name) val) { obj->name = val; } 
 
 	/** Registers a plain field defined with BS_PLAIN_MEMBER or BS_PLAIN_MEMBER_NAMED with the RTTI object. */
 #define BS_ADD_PLAIN_FIELD(name, id) \
-	addPlainField(#name, id##, &MyType::get##name, &MyType::set##name);
+	addPlainField(#name, id, &MyType::get##name, &MyType::set##name);
 
 	/** Registers a plain field defined with BS_REFL_MEMBER or BS_REFL_MEMBER_NAMED with the RTTI object. */
 #define BS_ADD_REFL_FIELD(name, id) \
-	addReflectableField(#name, id##, &MyType::get##name, &MyType::set##name);
+	addReflectableField(#name, id, &MyType::get##name, &MyType::set##name);
 
 	/** Registers a plain field defined with BS_REFLPTR_MEMBER or BS_REFLPTR_MEMBER_NAMED with the RTTI object. */
 #define BS_ADD_REFLPTR_FIELD(name, id) \
-	addReflectablePtrField(#name, id##, &MyType::get##name, &MyType::set##name);
+	addReflectablePtrField(#name, id, &MyType::get##name, &MyType::set##name);
 
 	/** Shortcut for defining getter/setter methods for a RTTI plain Vector<T> field. */
 #define BS_PLAIN_MEMBER_VEC(name)								\
-	std::common_type<decltype(OwnerType::##name)>::type::value_type& get##name(OwnerType* obj, UINT32 idx) { return obj->##name[idx]; }				\
-	void set##name(OwnerType* obj, UINT32 idx, std::common_type<decltype(OwnerType::##name)>::type::value_type& val) { obj->##name[idx] = val; }		\
-	UINT32 getSize##name(OwnerType* obj) { return (UINT32)obj->##name.size(); }	\
-	void setSize##name(OwnerType* obj, UINT32 val) { obj->##name.resize(val); }
+	std::common_type<decltype(OwnerType::name)>::type::value_type& get##name(OwnerType* obj, UINT32 idx) { return obj->name[idx]; }				\
+	void set##name(OwnerType* obj, UINT32 idx, std::common_type<decltype(OwnerType::name)>::type::value_type& val) { obj->name[idx] = val; }		\
+	UINT32 getSize##name(OwnerType* obj) { return (UINT32)obj->name.size(); }	\
+	void setSize##name(OwnerType* obj, UINT32 val) { obj->name.resize(val); }
 
 	/** Shortcut for defining getter/setter methods for a RTTI reflectable Vector<T> field. */
 #define BS_REFL_MEMBER_VEC(name)								\
-	std::common_type<decltype(OwnerType::##name)>::type::value_type& get##name(OwnerType* obj, UINT32 idx) { return obj->##name[idx]; }				\
-	void set##name(OwnerType* obj, UINT32 idx, std::common_type<decltype(OwnerType::##name)>::type::value_type& val) { obj->##name[idx] = val; }		\
-	UINT32 getSize##name(OwnerType* obj) { return (UINT32)obj->##name.size(); }	\
-	void setSize##name(OwnerType* obj, UINT32 val) { obj->##name.resize(val); }
+	std::common_type<decltype(OwnerType::name)>::type::value_type& get##name(OwnerType* obj, UINT32 idx) { return obj->name[idx]; }				\
+	void set##name(OwnerType* obj, UINT32 idx, std::common_type<decltype(OwnerType::name)>::type::value_type& val) { obj->name[idx] = val; }		\
+	UINT32 getSize##name(OwnerType* obj) { return (UINT32)obj->name.size(); }	\
+	void setSize##name(OwnerType* obj, UINT32 val) { obj->name.resize(val); }
 
 	/** Shortcut for defining getter/setter methods for a RTTI reflectable pointer Vector<T> field. */
 #define BS_REFLPTR_MEMBER_VEC(name)								\
-	std::common_type<decltype(OwnerType::##name)>::type::value_type get##name(OwnerType* obj, UINT32 idx) { return obj->##name[idx]; }				\
-	void set##name(OwnerType* obj, UINT32 idx, std::common_type<decltype(OwnerType::##name)>::type::value_type val) { obj->##name[idx] = val; }		\
-	UINT32 getSize##name(OwnerType* obj) { return (UINT32)obj->##name.size(); }	\
-	void setSize##name(OwnerType* obj, UINT32 val) { obj->##name.resize(val); }
+	std::common_type<decltype(OwnerType::name)>::type::value_type get##name(OwnerType* obj, UINT32 idx) { return obj->name[idx]; }				\
+	void set##name(OwnerType* obj, UINT32 idx, std::common_type<decltype(OwnerType::name)>::type::value_type val) { obj->name[idx] = val; }		\
+	UINT32 getSize##name(OwnerType* obj) { return (UINT32)obj->name.size(); }	\
+	void setSize##name(OwnerType* obj, UINT32 val) { obj->name.resize(val); }
 
 	/** Registers a plain array field defined with BS_PLAIN_MEMBER_VEC with the RTTI object. */
 #define BS_ADD_PLAIN_FIELD_ARR(name, id) \
-	addPlainArrayField(#name, id##, &MyType::get##name, &MyType::getSize##name, \
+	addPlainArrayField(#name, id, &MyType::get##name, &MyType::getSize##name, \
 	&MyType::set##name, &MyType::setSize##name);
 
 	/** Registers a reflectable object array field defined with BS_PLAIN_MEMBER_VEC with the RTTI object. */
 #define BS_ADD_REFL_FIELD_ARR(name, id) \
-	addReflectableArrayField(#name, id##, &MyType::get##name, &MyType::getSize##name, \
+	addReflectableArrayField(#name, id, &MyType::get##name, &MyType::getSize##name, \
 	&MyType::set##name, &MyType::setSize##name);
 
 	/** Registers a reflectable pointer array field defined with BS_PLAIN_MEMBER_VEC with the RTTI object. */
 #define BS_ADD_REFLPTR_FIELD_ARR(name, id) \
-	addReflectablePtrArrayField(#name, id##, &MyType::get##name, &MyType::getSize##name, \
+	addReflectablePtrArrayField(#name, id, &MyType::get##name, &MyType::getSize##name, \
 	&MyType::set##name, &MyType::setSize##name);
 
 	/** @} */

+ 2 - 26
Source/BansheeUtility/Include/BsStdHeaders.h

@@ -28,25 +28,8 @@
 #include <bitset>
 #include <array>
 
-// Note - not in the original STL, but exists in SGI STL and STLport
-// For gcc 4.3 see http://gcc.gnu.org/gcc-4.3/changes.html
-#if (BS_COMPILER == BS_COMPILER_GNUC)
-#   if BS_COMP_VER >= 430
-#       include <tr1/unordered_map>
-#       include <tr1/unordered_set> 
-#   else
-#       include <ext/hash_map>
-#       include <ext/hash_set>
-#   endif
-#else
-#   if (BS_COMPILER == BS_COMPILER_MSVC) && BS_COMP_VER >= 1600 // VC++ 10.0
-#    	include <unordered_map>
-#    	include <unordered_set>
-#	else
-#   	include <hash_set>
-#   	include <hash_map>
-#	endif
-#endif 
+#include <unordered_map>
+#include <unordered_set>
 
 // STL algorithms & functions
 #include <algorithm>
@@ -59,13 +42,6 @@
 #include <iomanip>
 #include <sstream>
 
-#ifdef __BORLANDC__
-namespace BansheeEngine
-{
-    using namespace std;
-}
-#endif
-
 extern "C" {
 
 #   include <sys/types.h>

+ 4 - 4
Source/BansheeUtility/Include/BsString.h

@@ -351,9 +351,9 @@ namespace BansheeEngine
 				StringUtil::toLowerCase(tmpPattern);
 			}
 
-			BasicString<T>::const_iterator strIt = tmpStr.begin();
-			BasicString<T>::const_iterator patIt = tmpPattern.begin();
-			BasicString<T>::const_iterator lastWildCardIt = tmpPattern.end();
+			typename BasicString<T>::const_iterator strIt = tmpStr.begin();
+			typename BasicString<T>::const_iterator patIt = tmpPattern.begin();
+			typename BasicString<T>::const_iterator lastWildCardIt = tmpPattern.end();
 			while (strIt != tmpStr.end() && patIt != tmpPattern.end())
 			{
 				if (*patIt == '*')
@@ -411,7 +411,7 @@ namespace BansheeEngine
 			const BasicString<T>& replaceWhat, const BasicString<T>& replaceWithWhat)
 		{
 			BasicString<T> result = source;
-			BasicString<T>::size_type pos = 0;
+			typename BasicString<T>::size_type pos = 0;
 			while(1)
 			{
 				pos = result.find(replaceWhat,pos);

+ 2 - 2
Source/BansheeUtility/Include/BsThreadDefines.h

@@ -19,7 +19,7 @@
 #define BS_MUTEX(name) mutable std::mutex name;
 #define BS_STATIC_MUTEX(name) static std::mutex name;
 #define BS_STATIC_MUTEX_INSTANCE(name) std::mutex name;
-#define BS_STATIC_MUTEX_CLASS_INSTANCE(name, classTypeName) std::mutex classTypeName##::name;
+#define BS_STATIC_MUTEX_CLASS_INSTANCE(name, classTypeName) std::mutex classTypeName::name;
 #define BS_LOCK_MUTEX(name) std::unique_lock<std::mutex> bsnameLock(name);
 #define BS_LOCK_MUTEX_NAMED(mutexName, lockName) std::unique_lock<std::mutex> lockName(mutexName);
 #define BS_LOCK_TYPE std::unique_lock<std::mutex>
@@ -31,7 +31,7 @@
 #define BS_MUTEX_CONDITIONAL(mutex) if (mutex)
 #define BS_THREAD_SYNCHRONISER(sync) std::condition_variable sync;
 #define BS_STATIC_THREAD_SYNCHRONISER(sync) static std::condition_variable sync;
-#define BS_STATIC_THREAD_SYNCHRONISER_CLASS_INSTANCE(sync, classTypeName) std::condition_variable classTypeName##::sync;
+#define BS_STATIC_THREAD_SYNCHRONISER_CLASS_INSTANCE(sync, classTypeName) std::condition_variable classTypeName::sync;
 #define BS_THREAD_WAIT(sync, mutex, lock) sync.wait(lock);
 #define BS_THREAD_WAIT_FOR(sync, mutex, lock, ms) sync.wait_for(lock, std::chrono::milliseconds(ms));
 #define BS_THREAD_NOTIFY_ONE(sync) sync.notify_one(); 

+ 2 - 0
Source/BansheeUtility/Include/ThirdParty/md5.h

@@ -35,7 +35,9 @@ documentation and/or software.
 #ifndef BZF_MD5_H
 #define BZF_MD5_H
 
+#if !defined(_CRT_SECURE_NO_WARNINGS)
 #define _CRT_SECURE_NO_WARNINGS
+#endif
 
 #include <cstring>
 #include <iostream>

+ 4 - 4
Source/BansheeUtility/Include/Win32/BsWin32Window.h

@@ -20,10 +20,10 @@ namespace BansheeEngine
 	struct BS_UTILITY_EXPORT WINDOW_DESC
 	{
 		WINDOW_DESC()
-			: module(nullptr), monitor(nullptr), parent(nullptr), external(nullptr), width(0), height(0), fullscreen(false)
-			, hidden(false), left(-1), top(-1), title(""), border(WindowBorder::Normal), outerDimensions(false)
-			, enableDoubleClick(true), toolWindow(false), creationParams(nullptr), alphaBlending(false), modal(false)
-			, wndProc(nullptr), backgroundPixels(nullptr), backgroundWidth(0), backgroundHeight(0)
+			: module(nullptr), monitor(nullptr), parent(nullptr), external(nullptr), creationParams(nullptr), width(0)
+			, height(0), fullscreen(false), hidden(false), left(-1), top(-1), title(""), border(WindowBorder::Normal)
+			, outerDimensions(false), enableDoubleClick(true), toolWindow(false), backgroundPixels(nullptr)
+			, backgroundWidth(0), backgroundHeight(0), alphaBlending(false), modal(false), wndProc(nullptr)
 		{ }
 
 		HINSTANCE module; /**< Instance to the local module. */

+ 9 - 8
Source/BansheeUtility/Source/BsBinarySerializer.cpp

@@ -25,17 +25,17 @@
  * @param	size   	Size of the data to copy
  */
 #define COPY_TO_BUFFER(dataIter, size)									\
-if((*bytesWritten + size##) > bufferLength)								\
+if((*bytesWritten + size) > bufferLength)								\
 {																		\
 	mTotalBytesWritten += *bytesWritten;								\
 	buffer = flushBufferCallback(buffer - *bytesWritten, *bytesWritten, bufferLength);	\
-	if(buffer == nullptr || bufferLength < size##) return nullptr;		\
+	if(buffer == nullptr || bufferLength < size) return nullptr;		\
 	*bytesWritten = 0;													\
 }																		\
 																		\
-memcpy(buffer, dataIter##, size##);										\
-buffer += size##;														\
-*bytesWritten += size##;
+memcpy(buffer, dataIter, size);											\
+buffer += size;															\
+*bytesWritten += size;
 
 namespace BansheeEngine
 {
@@ -52,9 +52,8 @@ namespace BansheeEngine
 		mLastUsedObjectId = 1;
 		*bytesWritten = 0;
 		mTotalBytesWritten = 0;
-		UINT8* bufferStart = buffer;
-		Vector<SPtr<IReflectable>> encodedObjects;
 
+		Vector<SPtr<IReflectable>> encodedObjects;
 		UINT32 objectId = findOrCreatePersistentId(object);
 		
 		// Encode primary object and its value types
@@ -71,7 +70,7 @@ namespace BansheeEngine
 		{
 			auto iter = mObjectsToEncode.begin();
 			bool foundObjectToProcess = false;
-			for(iter; iter != mObjectsToEncode.end(); ++iter)
+			for(; iter != mObjectsToEncode.end(); ++iter)
 			{
 				auto foundExisting = serializedObjects.find(iter->objectId);
 				if(foundExisting != serializedObjects.end())
@@ -998,6 +997,8 @@ namespace BansheeEngine
 						}
 					}
 						break;
+					default:
+						break;
 					}
 				}
 				else

+ 0 - 2
Source/BansheeUtility/Source/BsDynLib.cpp

@@ -52,8 +52,6 @@ namespace BansheeEngine
 #endif
         m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD(name.c_str());
 
-		DWORD lastError = GetLastError();
-
         if(!m_hInst)
 		{
             BS_EXCEPT(InternalErrorException,  

Some files were not shown because too many files changed in this diff