Преглед изворни кода

More documentation & input fixes

Marko Pintera пре 11 година
родитељ
комит
a713a99a65

+ 7 - 2
BansheeCore/Include/BsInput.h

@@ -104,9 +104,8 @@ namespace BansheeEngine
 		 *
 		 * @param	type		Type of axis to query. Usually a type from InputAxis but can be a custom value.
 		 * @param	deviceIdx	Index of the device in case more than one is hooked up (0 - primary).
-		 * @param	smooth		Should the returned value be smoothed.
 		 */
-		float getAxisValue(UINT32 type, UINT32 deviceIdx = 0, bool smooth = false) const;
+		float getAxisValue(UINT32 type, UINT32 deviceIdx = 0) const;
 
 		/**
 		 * @brief	Query if the provided button is currently being held (this frame or previous frames).
@@ -132,6 +131,12 @@ namespace BansheeEngine
 		 */
 		bool isButtonDown(ButtonCode keyCode, UINT32 deviceIdx = 0) const;
 
+		/**
+		 * @brief	Enables or disables mouse smoothing. Smoothing makes the changes to
+		 *			mouse axes more gradual.
+		 */
+		void setMouseSmoothing(bool enabled);
+
 	private:
 		/**
 		 * @brief	Triggered by input handler when a button is pressed.

+ 13 - 1
BansheeCore/Include/BsRawInputHandler.h

@@ -32,7 +32,10 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT RawInputHandler
 	{
 	public:
-		RawInputHandler() {}
+		RawInputHandler()
+			:mMouseSmoothingEnabled(false) 
+		{}
+
 		virtual ~RawInputHandler() {}
 
 		/**
@@ -70,5 +73,14 @@ namespace BansheeEngine
 		 * @note	Internal method.
 		 */
 		virtual void _inputWindowChanged(const RenderWindow& win) {}
+
+		/**
+		 * @brief	Enables or disables mouse smoothing. Smoothing makes the changes to
+		 *			mouse axes more gradual.
+		 */
+		void setMouseSmoothing(bool enabled) { mMouseSmoothingEnabled = enabled; }
+
+	protected:
+		bool mMouseSmoothingEnabled;
 	};
 }

+ 6 - 3
BansheeCore/Source/BsInput.cpp

@@ -184,13 +184,11 @@ namespace BansheeEngine
 		}
 	}
 
-	float Input::getAxisValue(UINT32 type, UINT32 deviceIdx, bool smooth) const
+	float Input::getAxisValue(UINT32 type, UINT32 deviceIdx) const
 	{
 		if (deviceIdx >= (UINT32)mDevices.size())
 			return 0.0f;
 
-		// TODO - Smooth parameter is ignored
-
 		const Vector<RawAxisState>& axes = mDevices[deviceIdx].axes;
 		if (type >= (UINT32)axes.size())
 			return 0.0f;
@@ -223,6 +221,11 @@ namespace BansheeEngine
 		return mDevices[deviceIdx].keyStates[button & 0x0000FFFF] == ButtonState::ToggledOn;
 	}
 
+	void Input::setMouseSmoothing(bool enable)
+	{
+		mRawInputHandler->setMouseSmoothing(enable);
+	}
+
 	Input& gInput()
 	{
 		return Input::instance();

+ 37 - 0
BansheeEngine/Include/BsApplication.h

@@ -6,6 +6,9 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Types of available render systems.
+	 */
 	enum class RenderSystemPlugin
 	{
 		DX11,
@@ -13,32 +16,66 @@ namespace BansheeEngine
 		OpenGL
 	};
 
+	/**
+	 * @brief	Types of available renderers.
+	 */
 	enum class RendererPlugin
 	{
 		Default
 	};
 
+	/**
+	 * @brief	Primary entry point for Banshee engine. Handles startup and shutdown.
+	 */
 	class BS_EXPORT Application : public CoreApplication
 	{
 	public:
 		Application(RENDER_WINDOW_DESC& primaryWindowDesc, RenderSystemPlugin renderSystem, RendererPlugin renderer);
 		virtual ~Application();
 
+		/**
+		 * @brief	Starts the Banshee engine.
+		 * 
+		 * @param	primaryWindowDesc	Description of the primary render window that will be created on startup.
+		 * @param	renderSystem		Render system to use.
+		 * @param	renderer			Renderer to use.
+		 */
 		static void startUp(RENDER_WINDOW_DESC& primaryWindowDesc, RenderSystemPlugin renderSystem, RendererPlugin renderer);
 
+		/**
+		 * @brief	Returns the primary viewport of the application.
+		 *
+		 * @note	e.g. player or game view.
+		 */
 		const ViewportPtr& getPrimaryViewport() const;
 	protected:
+		/**
+		 * @copydoc	Module::onStartUp
+		 */
 		virtual void onStartUp();
 
+		/**
+		 * @copydoc	CoreApplication::update.
+		 */
 		virtual void update();
 
 	private:
+		/**
+		 * @brief	Translates render system type into library name.
+		 */
 		static const String& getLibNameForRenderSystem(RenderSystemPlugin plugin);
+
+		/**
+		 * @brief	Translates renderer type into library name.
+		 */
 		static const String& getLibNameForRenderer(RendererPlugin plugin);
 
 		DynLib* mMonoPlugin;
 		DynLib* mSBansheeEnginePlugin;
 	};
 
+	/**
+	 * @copydoc	Application
+	 */
 	BS_EXPORT Application& gApplication();
 }

+ 80 - 2
BansheeEngine/Include/BsBuiltinMaterialManager.h

@@ -7,29 +7,72 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Handles creation of built-in materials for a specific render system.
+	 *			Needs to be specialized for each used render system.
+	 */
 	class BS_EXPORT BuiltinMaterialFactory
 	{
 	public:
 		virtual ~BuiltinMaterialFactory() {}
 
+		/**
+		 * @brief	Triggered when the factory is made active.
+		 */
 		virtual void startUp() {}
+
+		/**
+		 * @brief	Triggered before the factory is made inactive.
+		 */
 		virtual void shutDown() {}
 
+		/**
+		 * @brief	Returns the name of the render system this factory creates materials for.
+		 */
 		virtual const String& getSupportedRenderSystem() const = 0;
 
+		/**
+		 * @brief	Creates material used for textual sprite rendering (e.g. text in GUI).
+		 */
 		virtual HMaterial createSpriteTextMaterial() const = 0;
+
+		/**
+		 * @brief	Creates material used for image sprite rendering (e.g. images in GUI).
+		 */
 		virtual HMaterial createSpriteImageMaterial() const = 0;
+
+		/**
+		 * @brief	Creates a material used for debug drawing in clip space (e.g. 2D shapes that resize with the viewport).
+		 */
 		virtual HMaterial createDebugDraw2DClipSpaceMaterial() const = 0;
+
+		/**
+		 * @brief	Creates a material used for debug drawing in screen space (e.g. 2D shapes of fixed pixel size).
+		 */
 		virtual HMaterial createDebugDraw2DScreenSpaceMaterial() const = 0;
+
+		/**
+		 * @brief	Creates a material used for debug drawing in 3D.
+		 */
 		virtual HMaterial createDebugDraw3DMaterial() const = 0;
+
+		/**
+		 * @brief	Creates a material used for docking drop overlay used by the editor.
+		 *
+		 * TODO: Move this to Editor as it's editor-specific.
+		 */
 		virtual HMaterial createDockDropOverlayMaterial() const = 0;
+
+		/**
+		 * @brief	Creates a material used as a replacement when no other material is usable.
+		 */
 		virtual HMaterial createDummyMaterial() const = 0;
 	};
 
 	/**
 	 * @brief	Provides access to various materials that are required for core engine systems. 
-	 * 			Each render system implementation needs to provide its own implementation of this
-	 * 			module.
+	 * 			Each render system implementation needs to provide its own implementation of
+	 *			BuiltinMaterialFactory and register it with this module.
 	 */
 	class BS_EXPORT BuiltinMaterialManager : public Module<BuiltinMaterialManager>
 	{
@@ -37,15 +80,50 @@ namespace BansheeEngine
 		BuiltinMaterialManager();
 		~BuiltinMaterialManager();
 
+		/**
+		 * @copydoc	BuiltinMaterialFactory::createSpriteTextMaterial
+		 */
 		GUIMaterialInfo createSpriteTextMaterial() const;
+
+		/**
+		 * @copydoc	BuiltinMaterialFactory::createSpriteImageMaterial
+		 */
 		GUIMaterialInfo createSpriteImageMaterial() const;
+
+		/**
+		 * @copydoc	BuiltinMaterialFactory::createDebugDraw2DClipSpaceMaterial
+		 */
 		DebugDraw2DClipSpaceMatInfo createDebugDraw2DClipSpaceMaterial() const;
+
+		/**
+		 * @copydoc	BuiltinMaterialFactory::createDebugDraw2DScreenSpaceMaterial
+		 */
 		DebugDraw2DScreenSpaceMatInfo createDebugDraw2DScreenSpaceMaterial() const;
+
+		/**
+		 * @copydoc	BuiltinMaterialFactory::createDebugDraw3DMaterial
+		 */
 		DebugDraw3DMatInfo createDebugDraw3DMaterial() const;
+
+		/**
+		 * @copydoc	BuiltinMaterialFactory::createDockDropOverlayMaterial
+		 */
 		HMaterial createDockDropOverlayMaterial() const; // TODO - This belongs in editor
+
+		/**
+		 * @copydoc	BuiltinMaterialFactory::createDummyMaterial
+		 */
 		HMaterial createDummyMaterial() const;
 
+		/**
+		 * @brief	Registers a new material creation factory.
+		 */
 		void addFactory(BuiltinMaterialFactory* factory);
+
+		/**
+		 * @brief	Attempts to find a factory responsible for creating materials for the provided
+		 *			render system and makes it active.
+		 */
 		void setActive(const String& renderSystemName);
 
 	private:

+ 58 - 3
BansheeEngine/Include/BsBuiltinResources.h

@@ -10,28 +10,86 @@ namespace BansheeEngine
 {
 	// TODO - Currently this class will always import resources, but it would be better if it first
 	// checks for a pre-processed asset and only import it if that doesn't exist
+	/**
+	 * @brief	Holds references to built-in resources used by the core engine.
+	 */
 	class BS_EXPORT BuiltinResources : public BansheeEngine::Module<BuiltinResources>
 	{
 	public:
 		BuiltinResources();
 		~BuiltinResources();
 
+		/**
+		 * @brief	Returns the default skin used by engine GUI elements.
+		 */
 		const GUISkin& getGUISkin() const { return mSkin; }
 
+		/**
+		 * @brief	Returns a small entirely white texture.
+		 */
 		const HSpriteTexture getWhiteSpriteTexture() const { return mWhiteSpriteTexture; }
 
+		/**
+		 * @brief	Returns image data for an arrow cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorArrow(Vector2I& hotSpot);
+
+		/**
+		 * @brief	Returns image data for an arrow with dragged object cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorArrowDrag(Vector2I& hotSpot);
+		
+		/**
+		 * @brief	Returns image data for a wait cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorWait(Vector2I& hotSpot);
+		
+		/**
+		 * @brief	Returns image data for an "I" beam cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorIBeam(Vector2I& hotSpot);
+		
+		/**
+		 * @brief	Returns image data for a NESW resize cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorSizeNESW(Vector2I& hotSpot);
+		
+		/**
+		 * @brief	Returns image data for a NS resize cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorSizeNS(Vector2I& hotSpot);
+		
+		/**
+		 * @brief	Returns image data for a NWSE resize cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorSizeNWSE(Vector2I& hotSpot);
+		
+		/**
+		 * @brief	Returns image data for a WE resize cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorSizeWE(Vector2I& hotSpot);
+		
+		/**
+		 * @brief	Returns image data for a deny cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorDeny(Vector2I& hotSpot);
+		
+		/**
+		 * @brief	Returns image data for a move left-right cursor, along with its hotspot.
+		 */
 		const PixelData& getCursorMoveLeftRight(Vector2I& hotSpot);
 
 	private:
+		/**
+		 * @brief	Loads a GUI skin texture with the specified filename.
+		 */
+		static HSpriteTexture getSkinTexture(const WString& name);
+
+		/**
+		 * @brief	Loads a cursor texture with the specified filename.
+		 */
+		static HTexture getCursorTexture(const WString& name);
+
 		GUISkin mSkin;
 
 		PixelDataPtr mCursorArrow;
@@ -138,8 +196,5 @@ namespace BansheeEngine
 		static const Vector2I CursorSizeNSHotspot;
 		static const Vector2I CursorSizeNWSEHotspot;
 		static const Vector2I CursorSizeWEHotspot;
-
-		static HSpriteTexture getSkinTexture(const WString& name);
-		static HTexture getCursorTexture(const WString& name);
 	};
 }

+ 13 - 3
BansheeEngine/Include/BsCursor.h

@@ -14,6 +14,9 @@ namespace BansheeEngine
 	 */
 	class BS_EXPORT Cursor : public Module<Cursor>
 	{
+		/**
+		 * @brief	Internal container for data about a single cursor icon.
+		 */
 		struct CustomIcon
 		{
 			CustomIcon() {}
@@ -111,12 +114,19 @@ namespace BansheeEngine
 		void clearCursorIcon(CursorType type);
 
 	private:
+		/**
+		 * @brief	Restores the default cursor icon for the specified cursor type.
+		 */
+		void restoreCursorIcon(CursorType type);
+
+		/**
+		 * @brief	Sends the cursor image to the OS, making it active.
+		 */
+		void updateCursorImage();
+
 		UnorderedMap<String, UINT32> mCustomIconNameToId;
 		UnorderedMap<UINT32, CustomIcon> mCustomIcons;
 		UINT32 mNextUniqueId;
 		INT32 mActiveCursorId;
-
-		void restoreCursorIcon(CursorType type);
-		void updateCursorImage();
 	};
 }

+ 54 - 9
BansheeEngine/Include/BsD3D11BuiltinMaterialFactory.h

@@ -11,19 +11,72 @@ namespace BansheeEngine
 	class D3D11BuiltinMaterialFactory : public BuiltinMaterialFactory
 	{
 	public:
+		/** @copydoc BuiltinMaterialFactory::startUp */
 		void startUp();
+
+		/** @copydoc BuiltinMaterialFactory::startUp */
 		void shutDown();
+
+		/** @copydoc BuiltinMaterialFactory::getSupportedRenderSystem */
 		const String& getSupportedRenderSystem() const;
-		
+
+		/** @copydoc BuiltinMaterialFactory::createSpriteTextMaterial */
 		HMaterial createSpriteTextMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createSpriteImageMaterial */
 		HMaterial createSpriteImageMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDebugDraw2DClipSpaceMaterial */
 		HMaterial createDebugDraw2DClipSpaceMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDebugDraw2DScreenSpaceMaterial */
 		HMaterial createDebugDraw2DScreenSpaceMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDebugDraw3DMaterial */
 		HMaterial createDebugDraw3DMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDockDropOverlayMaterial */
 		HMaterial createDockDropOverlayMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDummyMaterial */
 		HMaterial createDummyMaterial() const;
 
 	protected:
+		/**
+		 * @brief	Loads an compiles a shader for text rendering.
+		 */
+		void initSpriteTextShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for image sprite rendering.
+		 */
+		void initSpriteImageShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for debug 2D clip space rendering.
+		 */
+		void initDebugDraw2DClipSpaceShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for debug 2D screen space rendering.
+		 */
+		void initDebugDraw2DScreenSpaceShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for debug 3D rendering.
+		 */
+		void initDebugDraw3DShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for dock overlay rendering.
+		 */
+		void initDockDropOverlayShader();
+
+		/**
+		 * @brief	Loads an compiles a simple shader to be used with no other is usable.
+		 */
+		void initDummyShader();
+
 		ShaderPtr mSpriteTextShader;
 		ShaderPtr mSpriteImageShader;
 		ShaderPtr mDebugDraw2DClipSpaceShader;
@@ -33,13 +86,5 @@ namespace BansheeEngine
 		ShaderPtr mDummyShader;
 
 		HSamplerState mGUISamplerState;
-
-		void initSpriteTextShader();
-		void initSpriteImageShader();
-		void initDebugDraw2DClipSpaceShader();
-		void initDebugDraw2DScreenSpaceShader();
-		void initDebugDraw3DShader();
-		void initDockDropOverlayShader();
-		void initDummyShader();
 	};
 }

+ 53 - 8
BansheeEngine/Include/BsD3D9BuiltinMaterialFactory.h

@@ -11,19 +11,72 @@ namespace BansheeEngine
 	class D3D9BuiltinMaterialFactory : public BuiltinMaterialFactory
 	{
 	public:
+		/** @copydoc BuiltinMaterialFactory::startUp */
 		void startUp();
+
+		/** @copydoc BuiltinMaterialFactory::startUp */
 		void shutDown();
+
+		/** @copydoc BuiltinMaterialFactory::getSupportedRenderSystem */
 		const String& getSupportedRenderSystem() const;
 
+		/** @copydoc BuiltinMaterialFactory::createSpriteTextMaterial */
 		HMaterial createSpriteTextMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createSpriteImageMaterial */
 		HMaterial createSpriteImageMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDebugDraw2DClipSpaceMaterial */
 		HMaterial createDebugDraw2DClipSpaceMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDebugDraw2DScreenSpaceMaterial */
 		HMaterial createDebugDraw2DScreenSpaceMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDebugDraw3DMaterial */
 		HMaterial createDebugDraw3DMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDockDropOverlayMaterial */
 		HMaterial createDockDropOverlayMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDummyMaterial */
 		HMaterial createDummyMaterial() const;
 
 	protected:
+		/**
+		 * @brief	Loads an compiles a shader for text rendering.
+		 */
+		void initSpriteTextShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for image sprite rendering.
+		 */
+		void initSpriteImageShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for debug 2D clip space rendering.
+		 */
+		void initDebugDraw2DClipSpaceShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for debug 2D screen space rendering.
+		 */
+		void initDebugDraw2DScreenSpaceShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for debug 3D rendering.
+		 */
+		void initDebugDraw3DShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for dock overlay rendering.
+		 */
+		void initDockDropOverlayShader();
+
+		/**
+		 * @brief	Loads an compiles a simple shader to be used with no other is usable.
+		 */
+		void initDummyShader();
+
 		ShaderPtr mSpriteTextShader;
 		ShaderPtr mSpriteImageShader;
 		ShaderPtr mDebugDraw2DClipSpaceShader;
@@ -33,13 +86,5 @@ namespace BansheeEngine
 		ShaderPtr mDummyShader;
 
 		HSamplerState mGUISamplerState;
-
-		void initSpriteTextShader();
-		void initSpriteImageShader();
-		void initDebugDraw2DClipSpaceShader();
-		void initDebugDraw2DScreenSpaceShader();
-		void initDebugDraw3DShader();
-		void initDockDropOverlayShader();
-		void initDummyShader();
 	};
 }

+ 12 - 0
BansheeEngine/Include/BsDebugDrawMaterialInfo.h

@@ -5,11 +5,19 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Contains data required for setting up and rendering with 
+	 *			material used for debug 2D clip space object rendering.
+	 */
 	struct DebugDraw2DClipSpaceMatInfo
 	{
 		HMaterial material;
 	};
 
+	/**
+	 * @brief	Contains data required for setting up and rendering with 
+	 *			material used for debug 2D screen space object rendering.
+	 */
 	struct DebugDraw2DScreenSpaceMatInfo
 	{
 		HMaterial material;
@@ -17,6 +25,10 @@ namespace BansheeEngine
 		GpuParamFloat invViewportHeight;
 	};
 
+	/**
+	 * @brief	Contains data required for setting up and rendering with 
+	 *			material used for debug 3D object rendering.
+	 */
 	struct DebugDraw3DMatInfo
 	{
 		HMaterial material;

+ 93 - 66
BansheeEngine/Include/BsDrawHelper2D.h

@@ -8,6 +8,9 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Helper class that makes it easy to construct and render various common 2D shapes.
+	 */
 	class BS_EXPORT DrawHelper2D : public DrawHelperTemplate<Vector2>, public Module<DrawHelper2D>
 	{
 	public:
@@ -29,102 +32,126 @@ namespace BansheeEngine
 		void quad(const RectF& area, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 		/**
-		 * @brief	Fills the mesh data with vertices representing a per-pixel line.
-		 *
-		 * @param	a				Start point of the line.
-		 * @param	b				End point of the line.
-		 * @param	color			Color of the line.
-		 * @param	meshData		Mesh data that will be populated.
-		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
-		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
-		 * 							
-		 * @note	Provided MeshData must have some specific elements at least:
-		 * 			  Vector2 VES_POSITION
-		 * 			  UINT32  VES_COLOR
-		 * 			  32bit index buffer
-		 * 			  Enough space for 2 vertices and 2 indices
+		 * @copydoc	DrawHelperTemplate::line_Pixel
 		 */
 		void line_Pixel(const Vector2& a, const Vector2& b, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 		/**
-		 * @brief	Fills the mesh data with vertices representing an anti-aliased line of specific width. Antialiasing is done using alpha blending.
-		 *
-		 * @param	a				Start point of the line.
-		 * @param	b				End point of the line.
-		 * @param	width			Width of the line.
-		 * @param	borderWidth		Width of the anti-aliased border.
-		 * @param	color			Color of the line.
-		 * @param	meshData		Mesh data that will be populated by this method.
-		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
-		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
-		 * 							
-		 * @note	Provided MeshData must have some specific elements at least:
-		 * 			  Vector2 VES_POSITION
-		 * 			  UINT32  VES_COLOR
-		 * 			  32bit index buffer
-		 *			  Enough space for 8 vertices and 30 indices
+		 * @copydoc	DrawHelperTemplate::line_AA
 		 */
 		void line_AA(const Vector2& a, const Vector2& b, float width, float borderWidth, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 		/**
-		 * @brief	Fills the mesh data with vertices representing per-pixel lines.
-		 *
-		 * @param	linePoints		A list of start and end points for the lines. Must be a multiple of 2.
-		 * @param	color			Color of the line.
-		 * @param	meshData		Mesh data that will be populated.
-		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
-		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
-		 * 							
-		 * @note	Provided MeshData must have some specific elements at least:
-		 * 			  Vector2 VES_POSITION
-		 * 			  UINT32  VES_COLOR
-		 * 			  32bit index buffer
-		 * 			  Enough space for (numLines * 2) vertices and (numLines * 2) indices
+		 * @copydoc	DrawHelperTemplate::lineList_Pixel
 		 */
 		void lineList_Pixel(const Vector<Vector2>& linePoints, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 		/**
-		 * @brief	Fills the mesh data with vertices representing anti-aliased lines of specific width. Antialiasing is done using alpha blending.
-		 *
-		 * @param	linePoints		A list of start and end points for the lines. Must be a multiple of 2.
-		 * @param	width			Width of the line.
-		 * @param	borderWidth		Width of the anti-aliased border.
-		 * @param	color			Color of the line.
-		 * @param	meshData		Mesh data that will be populated by this method.
-		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
-		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
-		 * 							
-		 * @note	Provided MeshData must have some specific elements at least:
-		 * 			  Vector2 VES_POSITION
-		 * 			  UINT32  VES_COLOR
-		 * 			  32bit index buffer
-		 *			  Enough space for (numLines * 8) vertices and (numLines * 30) indices
+		 * @copydoc	DrawHelperTemplate::lineList_AA
 		 */
 		void lineList_AA(const Vector<Vector2>& linePoints, float width, float borderWidth, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
+		/**
+		 * @brief	Constructs a quad and draws it in the specified camera. 
+		 *
+		 * @param	camera		Camera to draw the quad in.
+		 * @param	area		Area of the quad. Coordinates must be normalized in ([0, 1], [0, 1]) range. Coordinate origin is top left of the camera viewport.
+		 * @param	color		Color of the quad.
+		 * @param	coordType	How to handle viewport resizing. If mode is Pixel the quad will always retain its size in pixels, and if mode is Normalized
+		 *						the quad will stretch with the viewport so its normalized coordinates stay the same.
+		 * @param	timeout		Optional timeout on how long to display the quad in seconds. If 0 the quad will be displayed one frame.
+		 */
 		void drawQuad(const HCamera& camera, const RectF& area, const Color& color = Color::White, DebugDrawCoordType coordType = DebugDrawCoordType::Pixel, float timeout = 0.0f);
+
+		/**
+		 * @brief	Constructs a pixel perfect line and draws it in the specified camera. 
+		 *
+		 * @param	camera		Camera to draw the line in.
+		 * @param	x			Starting position of the line. Coordinates must be normalized in [0, 1] range. Coordinate origin is top left of the camera viewport.
+		 * @param	y			End position of the line. Coordinates must be normalized in [0, 1] range. Coordinate origin is top left of the camera viewport.
+		 * @param	color		Color of the line.
+		 * @param	coordType	How to handle viewport resizing. If mode is Pixel the line will always retain its size in pixels, and if mode is Normalized
+		 *						the line will stretch with the viewport so its normalized coordinates stay the same.
+		 * @param	timeout		Optional timeout on how long to display the line in seconds. If 0 the line will be displayed one frame.
+		 */
 		void drawLine_Pixel(const HCamera& camera, const Vector2& a, const Vector2& b, const Color& color = Color::White, 
 			DebugDrawCoordType coordType = DebugDrawCoordType::Pixel, float timeout = 0.0f);
+
+		/**
+		 * @brief	Constructs an antialiased line with custom width and draws it in the specified camera. 
+		 *
+		 * @param	camera		Camera to draw the line in.
+		 * @param	x			Starting position of the line. Coordinates must be normalized in [0, 1] range. Coordinate origin is top left of the camera viewport.
+		 * @param	y			End position of the line. Coordinates must be normalized in [0, 1] range. Coordinate origin is top left of the camera viewport.
+		 * @param	width		Width of the line in pixels.
+		 * @param	borderWidth	Width of the antialiased border in pixels.
+		 * @param	color		Color of the line.
+		 * @param	coordType	How to handle viewport resizing. If mode is Pixel the line will always retain its size in pixels, and if mode is Normalized
+		 *						the line will stretch with the viewport so its normalized coordinates stay the same.
+		 * @param	timeout		Optional timeout on how long to display the line in seconds. If 0 the line will be displayed one frame.
+		 */
 		void drawLine_AA(const HCamera& camera, const Vector2& a, const Vector2& b, float width, float borderWidth, 
 			const Color& color = Color::White, DebugDrawCoordType coordType = DebugDrawCoordType::Pixel, float timeout = 0.0f);
+
+		/**
+		 * @brief	Constructs a pixel perfect list of lines and draws them in the specified camera. 
+		 *
+		 * @param	camera		Camera to draw the line list in.
+		 * @param	linePoints	List of line start and end points. This list must be a multiple of 2, where each start point is followed by and end point.
+		 *						Coordinates must be normalized in ([0, 1], [0, 1]) range. Coordinate origin is top left of the camera viewport.
+		 * @param	color		Color of the line list.
+		 * @param	coordType	How to handle viewport resizing. If mode is Pixel the line list will always retain its size in pixels, and if mode is Normalized
+		 *						the line list will stretch with the viewport so its normalized coordinates stay the same.
+		 * @param	timeout		Optional timeout on how long to display the line list in seconds. If 0 the line list will be displayed one frame.
+		 */
 		void drawLineList_Pixel(const HCamera& camera, const Vector<Vector2>& linePoints, const Color& color = Color::White, 
 			DebugDrawCoordType coordType = DebugDrawCoordType::Pixel, float timeout = 0.0f);
+
+		/**
+		 * @brief	Constructs an list of antialiased lines with custom width and draws them in the specified camera. 
+		 *
+		 * @param	camera		Camera to draw the line list in.
+		 * @param	linePoints	List of line start and end points. This list must be a multiple of 2, where each start point is followed by and end point.
+		 *						Coordinates must be normalized in ([0, 1], [0, 1]) range. Coordinate origin is top left of the camera viewport.
+		 * @param	width		Width of the line in pixels.
+		 * @param	borderWidth	Width of the antialiased border in pixels.
+		 * @param	color		Color of the line list.
+		 * @param	coordType	How to handle viewport resizing. If mode is Pixel the line list will always retain its size in pixels, and if mode is Normalized
+		 *						the line list will stretch with the viewport so its normalized coordinates stay the same.
+		 * @param	timeout		Optional timeout on how long to display the line list in seconds. If 0 the line list will be displayed one frame.
+		 */
 		void drawLineList_AA(const HCamera& camera, const Vector<Vector2>& linePoints, float width, float borderWidth, 
 			const Color& color = Color::White, DebugDrawCoordType coordType = DebugDrawCoordType::Pixel, float timeout = 0.0f);
 
-	private:
-		DebugDraw2DClipSpaceMatInfo mMaterial2DClipSpace;
-
-		VertexDataDescPtr mVertexDesc;
-
-		RectF normalizedCoordToClipSpace(const RectF& area) const;
-		Vector2 normalizedCoordToClipSpace(const Vector2& pos) const;
-
 	protected:
+		/**
+		 * @copydoc	DrawHelperTemplate::line_AA(const Vector2&, const Vector2&, float, float, const Color&, UINT8*, UINT8*, UINT32, UINT32, UINT32*, UINT32)
+		 */
 		void line_AA(const Vector2& a, const Vector2& b, float width, float borderWidth, const Color& color, UINT8* outVertices, UINT8* outColors, 
 			UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset);
 
+		/**
+		 * @copydoc	DrawHelperTemplate::polygon_AA(const Vector<Vector2>&, float, const Color&, UINT8*, UINT8*, UINT32, UINT32, UINT32*, UINT32)
+		 */
 		void polygon_AA(const Vector<Vector2>& points, float borderWidth, const Color& color, UINT8* outVertices, UINT8* outColors, 
 			UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset);
+
+	private:
+		/**
+		 * @brief	Converts an area with normalized ([0, 1] range) coordinates and returns
+		 *			area in clip space coordinates.
+		 */
+		RectF normalizedCoordToClipSpace(const RectF& area) const;
+
+		/**
+		 * @brief	Converts a point with normalized ([0, 1] range) coordinates and returns
+		 *			a point in clip space coordinates.
+		 */
+		Vector2 normalizedCoordToClipSpace(const Vector2& pos) const;
+
+	private:
+		DebugDraw2DClipSpaceMatInfo mMaterial2DClipSpace;
+
+		VertexDataDescPtr mVertexDesc;
 	};
 }

+ 88 - 63
BansheeEngine/Include/BsDrawHelper3D.h

@@ -8,6 +8,9 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Helper class that makes it easy to construct and render various common 3D shapes.
+	 */
 	class BS_EXPORT DrawHelper3D : public DrawHelperTemplate<Vector3>, public Module<DrawHelper3D>
 	{
 	public:
@@ -30,101 +33,123 @@ namespace BansheeEngine
 		void aabox(const AABox& box, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 		/**
-		 * @brief	Fills the mesh data with vertices representing a per-pixel line.
-		 *
-		 * @param	a				Start point of the line.
-		 * @param	b				End point of the line.
-		 * @param	color			Color of the line.
-		 * @param	meshData		Mesh data that will be populated.
-		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
-		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
-		 * 							
-		 * @note	Provided MeshData must have some specific elements at least:
-		 * 			  Vector3 VES_POSITION
-		 * 			  UINT32  VES_COLOR
-		 * 			  32bit index buffer
-		 * 			  Enough space for 2 vertices and 2 indices
+		 * @copydoc	DrawHelperTemplate::line_Pixel
 		 */
 		void line_Pixel(const Vector3& a, const Vector3& b, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 		/**
-		 * @brief	Fills the mesh data with vertices representing an anti-aliased line of specific width. Antialiasing is done using alpha blending.
-		 *
-		 * @param	a				Start point of the line.
-		 * @param	b				End point of the line.
-		 * @param	width			Width of the line.
-		 * @param	borderWidth		Width of the anti-aliased border.
-		 * @param	color			Color of the line.
-		 * @param	meshData		Mesh data that will be populated by this method.
-		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
-		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
-		 * 							
-		 * @note	Provided MeshData must have some specific elements at least:
-		 * 			  Vector3 VES_POSITION
-		 * 			  UINT32  VES_COLOR
-		 * 			  32bit index buffer
-		 *			  Enough space for 8 vertices and 30 indices
+		 * @copydoc	DrawHelperTemplate::line_AA
 		 */
 		void line_AA(const Vector3& a, const Vector3& b, float width, float borderWidth, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 		/**
-		 * @brief	Fills the mesh data with vertices representing per-pixel lines.
-		 *
-		 * @param	linePoints		A list of start and end points for the lines. Must be a multiple of 2.
-		 * @param	color			Color of the line.
-		 * @param	meshData		Mesh data that will be populated.
-		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
-		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
-		 * 							
-		 * @note	Provided MeshData must have some specific elements at least:
-		 * 			  Vector3 VES_POSITION
-		 * 			  UINT32  VES_COLOR
-		 * 			  32bit index buffer
-		 * 			  Enough space for (numLines * 2) vertices and (numLines * 2) indices
+		 * @copydoc	DrawHelperTemplate::lineList_Pixel
 		 */
 		void lineList_Pixel(const Vector<Vector3>& linePoints, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 		/**
-		 * @brief	Fills the mesh data with vertices representing anti-aliased lines of specific width. Antialiasing is done using alpha blending.
-		 *
-		 * @param	linePoints		A list of start and end points for the lines. Must be a multiple of 2.
-		 * @param	width			Width of the line.
-		 * @param	borderWidth		Width of the anti-aliased border.
-		 * @param	color			Color of the line.
-		 * @param	meshData		Mesh data that will be populated by this method.
-		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
-		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
-		 * 							
-		 * @note	Provided MeshData must have some specific elements at least:
-		 * 			  Vector3 VES_POSITION
-		 * 			  UINT32  VES_COLOR
-		 * 			  32bit index buffer
-		 *			  Enough space for (numLines * 8) vertices and (numLines * 30) indices
+		 * @copydoc	DrawHelperTemplate::lineList_AA
 		 */
 		void lineList_AA(const Vector<Vector3>& linePoints, float width, float borderWidth, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
+		/**
+		 * @brief	Constructs a one-pixel wide line and draws it in the specified camera. 
+		 *
+		 * @param	camera		Camera to draw the line in.
+		 * @param	x			Starting position of the line. Coordinates must be normalized in [0, 1] range. Coordinate origin is top left of the camera viewport.
+		 * @param	y			End position of the line. Coordinates must be normalized in [0, 1] range. Coordinate origin is top left of the camera viewport.
+		 * @param	color		Color of the line.
+		 * @param	timeout		Optional timeout on how long to display the line in seconds. If 0 the line will be displayed one frame.
+		 */
 		void drawLine_Pixel(const HCamera& camera, const Vector3& a, const Vector3& b, const Color& color = Color::White, float timeout = 0.0f);
+
+		/**
+		 * @brief	Constructs an antialiased line with custom width and draws it in the specified camera. 
+		 *
+		 * @param	camera		Camera to draw the line in.
+		 * @param	x			Starting position of the line. Coordinates must be normalized in [0, 1] range. Coordinate origin is top left of the camera viewport.
+		 * @param	y			End position of the line. Coordinates must be normalized in [0, 1] range. Coordinate origin is top left of the camera viewport.
+		 * @param	width		Width of the line in pixels.
+		 * @param	borderWidth	Width of the antialiased border in pixels.
+		 * @param	color		Color of the line.
+		 * @param	timeout		Optional timeout on how long to display the line in seconds. If 0 the line will be displayed one frame.
+		 */
 		void drawLine_AA(const HCamera& camera, const Vector3& a, const Vector3& b, float width, float borderWidth, 
 			const Color& color = Color::White, float timeout = 0.0f);
+
+		/**
+		 * @brief	Constructs a pixel perfect list of lines and draws them in the specified camera. 
+		 *
+		 * @param	camera		Camera to draw the line list in.
+		 * @param	linePoints	List of line start and end points. This list must be a multiple of 2, where each start point is followed by and end point.
+		 *						Coordinates must be normalized in ([0, 1], [0, 1]) range. Coordinate origin is top left of the camera viewport.
+		 * @param	color		Color of the line list.
+		 * @param	timeout		Optional timeout on how long to display the line list in seconds. If 0 the line list will be displayed one frame.
+		 */
 		void drawLineList_Pixel(const HCamera& camera, const Vector<Vector3>& linePoints, const Color& color = Color::White, float timeout = 0.0f);
+
+		/**
+		 * @brief	Constructs an list of antialiased lines with custom width and draws them in the specified camera. 
+		 *
+		 * @param	camera		Camera to draw the line list in.
+		 * @param	linePoints	List of line start and end points. This list must be a multiple of 2, where each start point is followed by and end point.
+		 *						Coordinates must be normalized in ([0, 1], [0, 1]) range. Coordinate origin is top left of the camera viewport.
+		 * @param	width		Width of the line in pixels.
+		 * @param	borderWidth	Width of the antialiased border in pixels.
+		 * @param	color		Color of the line list.
+		 * @param	timeout		Optional timeout on how long to display the line list in seconds. If 0 the line list will be displayed one frame.
+		 */
 		void drawLineList_AA(const HCamera& camera, const Vector<Vector3>& linePoints, float width, float borderWidth, 
 			const Color& color = Color::White, float timeout = 0.0f);
 
+		/**
+		 * @brief	Constructs an axis aligned box and draws it in the specified camera.
+		 *
+		 * @param	camera		Camera to draw the box in.
+		 * @param	box			Box to draw.
+		 * @param	color		Color of the box.
+		 * @param	timeout		Optional timeout on how long to display the box in seconds. If 0 the box will be displayed one frame.
+		 */
 		void drawAABox(const HCamera& camera, const AABox& box, const Color& color = Color::White, float timeout = 0.0f);
 
-	private:
-		VertexDataDescPtr mVertexDesc;
-		
-		Vector3 calcCenter(UINT8* vertices, UINT32 numVertices, UINT32 vertexStride);
-
 	protected:
+		/**
+		 * @copydoc	DrawHelperTemplate::line_AA(const Vector2&, const Vector2&, float, float, const Color&, UINT8*, UINT8*, UINT32, UINT32, UINT32*, UINT32)
+		 */
 		void line_AA(const Vector3& a, const Vector3& b, float width, float borderWidth, const Color& color, UINT8* outVertices, UINT8* outColors, 
 			UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset);
 
+		/**
+		 * @copydoc	DrawHelperTemplate::polygon_AA(const Vector<Vector2>&, float, const Color&, UINT8*, UINT8*, UINT32, UINT32, UINT32*, UINT32)
+		 */
 		void polygon_AA(const Vector<Vector3>& points, float borderWidth, const Color& color, UINT8* outVertices, UINT8* outColors, 
 			UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset);
 
+		/**
+		 * @brief	Fills the provided buffers with position and index data representing an axis aligned box.
+		 *
+		 * @param	box				Box to create geometry for.
+		 * @param	outVertices		Output buffer that will store the vertex position data.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	vertexStride	Size of a single vertex, in bytes. (Same for both position and color buffer)
+		 * @param	outIndices		Output buffer that will store the index data. Indices are 32bit.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 */
 		void aabox(const AABox& box, UINT8* outVertices, UINT32 vertexOffset, UINT32 vertexStride, 
 			UINT32* outIndices, UINT32 indexOffset);
+
+	private:
+		/**
+		 * @brief	Calculates the center of the provided vertices.
+		 * 
+		 * @param	vertices		Buffer containing vertices. Vertices must be of three dimensions at least.
+		 * @param	numVertices		Number of vertices to calculate the center for.
+		 * @param	vertexStride	Number of bytes between two vertices in the buffer.
+		 *
+		 * @returns	Center point of the vertices.
+		 */
+		Vector3 calcCenter(UINT8* vertices, UINT32 numVertices, UINT32 vertexStride);
+
+		VertexDataDescPtr mVertexDesc;
 	};
 }

+ 151 - 7
BansheeEngine/Include/BsDrawHelperTemplate.h

@@ -7,19 +7,18 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Types of coordinates used in 2D debug drawing.
+	 */
 	enum class DebugDrawCoordType
 	{
 		Pixel,
 		Normalized
 	};
 
-	enum class DrawStyle
-	{
-		Fill,
-		Border,
-		FillAndBorder
-	};
-
+	/**
+	 * @brief	Internal type that determines how is a debug object drawn.
+	 */
 	enum class DebugDrawType
 	{
 		ClipSpace,
@@ -27,6 +26,10 @@ namespace BansheeEngine
 		WorldSpace
 	};
 
+	/**
+	 * @brief	Command containing all data requires for drawing a single
+	 *			debug draw object.
+	 */
 	struct DebugDrawCommand
 	{
 		HMesh mesh;
@@ -40,19 +43,46 @@ namespace BansheeEngine
 		float endTime;
 	};
 
+	/**
+	 * @brief	Abstract interface for a draw helper class. Allows a set of draw commands to be queued
+	 *			and retrieved by the renderer.
+	 */
 	class BS_EXPORT DrawHelperTemplateBase
 	{
 	public:
+		/**
+		 * @brief	Called by the renderer when it is ready to render objects into the provided camera.
+		 */
 		void render(const HCamera& camera, DrawList& drawList);
 
 	protected:
 		UnorderedMap<const Viewport*, Vector<DebugDrawCommand>> mCommandsPerViewport;
 	};
 
+	/**
+	 * @brief	Provides dimension-independant methods used for creating geometry 
+	 *			and drawing various common objects.
+	 */
 	template <class T>
 	class BS_EXPORT DrawHelperTemplate : public DrawHelperTemplateBase
 	{
 	protected:
+		/**
+		 * @brief	Fills the mesh data with vertices representing a per-pixel line.
+		 *
+		 * @param	a				Start point of the line.
+		 * @param	b				End point of the line.
+		 * @param	color			Color of the line.
+		 * @param	meshData		Mesh data that will be populated.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 * 							
+		 * @note	Provided MeshData must have some specific elements at least:
+		 * 			  T		  VES_POSITION
+		 * 			  UINT32  VES_COLOR
+		 * 			  32bit index buffer
+		 * 			  Enough space for 2 vertices and 2 indices
+		 */
 		void line_Pixel(const T& a, const T& b, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
 		{
 			UINT32* indexData = meshData->getIndices32();
@@ -65,6 +95,24 @@ namespace BansheeEngine
 			line_Pixel(a, b, color, positionData, colorData, vertexOffset, meshData->getVertexDesc()->getVertexStride(), indexData, indexOffset);
 		}
 
+		/**
+		 * @brief	Fills the mesh data with vertices representing an anti-aliased line of specific width. Antialiasing is done using alpha blending.
+		 *
+		 * @param	a				Start point of the line.
+		 * @param	b				End point of the line.
+		 * @param	width			Width of the line.
+		 * @param	borderWidth		Width of the anti-aliased border.
+		 * @param	color			Color of the line.
+		 * @param	meshData		Mesh data that will be populated by this method.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 * 							
+		 * @note	Provided MeshData must have some specific elements at least:
+		 * 			  T		  VES_POSITION
+		 * 			  UINT32  VES_COLOR
+		 * 			  32bit index buffer
+		 *			  Enough space for 8 vertices and 30 indices
+		 */
 		void line_AA(const T& a, const T& b, float width, float borderWidth, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
 		{
 			UINT32* indexData = meshData->getIndices32();
@@ -77,6 +125,21 @@ namespace BansheeEngine
 			line_AA(a, b, width, borderWidth, color, positionData, colorData, vertexOffset, meshData->getVertexDesc()->getVertexStride(), indexData, indexOffset);
 		}
 
+		/**
+		 * @brief	Fills the mesh data with vertices representing per-pixel lines.
+		 *
+		 * @param	linePoints		A list of start and end points for the lines. Must be a multiple of 2.
+		 * @param	color			Color of the line.
+		 * @param	meshData		Mesh data that will be populated.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 * 							
+		 * @note	Provided MeshData must have some specific elements at least:
+		 * 			  T		  VES_POSITION
+		 * 			  UINT32  VES_COLOR
+		 * 			  32bit index buffer
+		 * 			  Enough space for (numLines * 2) vertices and (numLines * 2) indices
+		 */
 		void lineList_Pixel(const typename Vector<T>& linePoints, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
 		{
 			assert(linePoints.size() % 2 == 0);
@@ -101,6 +164,23 @@ namespace BansheeEngine
 			}
 		}
 
+		/**
+		 * @brief	Fills the mesh data with vertices representing anti-aliased lines of specific width. Antialiasing is done using alpha blending.
+		 *
+		 * @param	linePoints		A list of start and end points for the lines. Must be a multiple of 2.
+		 * @param	width			Width of the line.
+		 * @param	borderWidth		Width of the anti-aliased border.
+		 * @param	color			Color of the line.
+		 * @param	meshData		Mesh data that will be populated by this method.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 * 							
+		 * @note	Provided MeshData must have some specific elements at least:
+		 * 			  T		  VES_POSITION
+		 * 			  UINT32  VES_COLOR
+		 * 			  32bit index buffer
+		 *			  Enough space for (numLines * 8) vertices and (numLines * 30) indices
+		 */
 		void lineList_AA(const typename Vector<T>& linePoints, float width, float borderWidth, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
 		{
 			assert(linePoints.size() % 2 == 0);
@@ -125,6 +205,19 @@ namespace BansheeEngine
 			}
 		}
 
+		/**
+		 * @brief	Fills the provided buffers with vertices representing a per-pixel line.
+		 *
+		 * @param	a				Start point of the line.
+		 * @param	b				End point of the line.
+		 * @param	color			Color of the line.
+		 * @param	outVertices		Output buffer that will store the vertex position data.
+		 * @param	outColors		Output buffer that will store the vertex color data.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	vertexStride	Size of a single vertex, in bytes. (Same for both position and color buffer)
+		 * @param	outIndices		Output buffer that will store the index data. Indices are 32bit.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 */
 		void line_Pixel(const T& a, const T& b, const Color& color, UINT8* outVertices, UINT8* outColors, 
 			UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset)
 		{
@@ -148,12 +241,51 @@ namespace BansheeEngine
 			outIndices[1] = vertexOffset + 1;
 		}
 
+		/**
+		 * @brief	Fills the provided buffers with vertices representing an antialiased line with a custom width.
+		 *
+		 * @param	a				Start point of the line.
+		 * @param	b				End point of the line.
+		 * @param	width			Width of the line.
+		 * @param	borderWidth		Width of the anti-aliased border.
+		 * @param	color			Color of the line.
+		 * @param	outVertices		Output buffer that will store the vertex position data.
+		 * @param	outColors		Output buffer that will store the vertex color data.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	vertexStride	Size of a single vertex, in bytes. (Same for both position and color buffer)
+		 * @param	outIndices		Output buffer that will store the index data. Indices are 32bit.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 */
 		virtual void line_AA(const T& a, const T& b, float width, float borderWidth, const Color& color, UINT8* outVertices, UINT8* outColors, 
 			UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset) = 0;
 
+		/**
+		 * @brief	Fills the provided buffers with vertices representing an antialiased polygon.
+		 *
+		 * @param	points			Points defining the polygon. First point is assumed to be the start and end point.
+		 * @param	borderWidth		Width of the anti-aliased border.
+		 * @param	color			Color of the polygon.
+		 * @param	outVertices		Output buffer that will store the vertex position data.
+		 * @param	outColors		Output buffer that will store the vertex color data.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	vertexStride	Size of a single vertex, in bytes. (Same for both position and color buffer)
+		 * @param	outIndices		Output buffer that will store the index data. Indices are 32bit.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 */
 		virtual void polygon_AA(const typename Vector<T>& points, float borderWidth, const Color& color, UINT8* outVertices, UINT8* outColors, 
 			UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset) = 0;
 
+		/**
+		 * @brief	Fills the provided buffers with position data and indices representing an inner 
+		 *			area of a polygon (basically a normal non-antialiased polygon).
+		 *
+		 * @param	points			Points defining the polygon. First point is assumed to be the start and end point.
+		 * @param	outVertices		Output buffer that will store the vertex position data.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	vertexStride	Size of a single vertex, in bytes. (Same for both position and color buffer)
+		 * @param	outIndices		Output buffer that will store the index data. Indices are 32bit.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 */
 		void polygonFill_Pixel(const typename Vector<T>& points, UINT8* outVertices, 
 			UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset)
 		{
@@ -178,6 +310,18 @@ namespace BansheeEngine
 			}
 		}
 
+		/**
+		 * @brief	Fills the provided buffers with vertices representing a pixel-wide polygon border.
+		 *
+		 * @param	points			Points defining the polygon. First point is assumed to be the start and end point.
+		 * @param	color			Color of the border.
+		 * @param	outVertices		Output buffer that will store the vertex position data.
+		 * @param	outColors		Output buffer that will store the vertex color data.
+		 * @param	vertexOffset	Offset in number of vertices from the start of the buffer to start writing at.
+		 * @param	vertexStride	Size of a single vertex, in bytes. (Same for both position and color buffer)
+		 * @param	outIndices		Output buffer that will store the index data. Indices are 32bit.
+		 * @param	indexOffset 	Offset in number of indices from the start of the buffer to start writing at.
+		 */
 		void polygonBorder_Pixel(const typename Vector<T>& points, const Color& color, UINT8* outVertices, UINT8* outColors, 
 			UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset)
 		{

+ 4 - 4
BansheeEngine/Include/BsEnums.h

@@ -2,6 +2,9 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Available cursor types.
+	 */
 	enum class CursorType
 	{
 		Arrow,
@@ -21,13 +24,10 @@ namespace BansheeEngine
 
 	/**
 	 * @brief	Contains a basic sent of renderable types that may be supported by a renderer.
-	 *			These can be used as a guide and renderer plugins can use their own types as needed.
+	 *			These can be used just as a guide since renderer plugins can use their own types as needed.
 	 */
 	enum RenderableType
 	{
-		RenType_UnlitUntextured,
-		RenType_UnlitTextured,
 		RenType_LitTextured
-		// TODO - Add more types as I improve the Renderer with advanced techniques
 	};
 }

+ 53 - 8
BansheeEngine/Include/BsGLBuiltinMaterialFactory.h

@@ -11,19 +11,72 @@ namespace BansheeEngine
 	class GLBuiltinMaterialFactory : public BuiltinMaterialFactory
 	{
 	public:
+		/** @copydoc BuiltinMaterialFactory::startUp */
 		void startUp();
+
+		/** @copydoc BuiltinMaterialFactory::startUp */
 		void shutDown();
+
+		/** @copydoc BuiltinMaterialFactory::getSupportedRenderSystem */
 		const String& getSupportedRenderSystem() const;
 
+		/** @copydoc BuiltinMaterialFactory::createSpriteTextMaterial */
 		HMaterial createSpriteTextMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createSpriteImageMaterial */
 		HMaterial createSpriteImageMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDebugDraw2DClipSpaceMaterial */
 		HMaterial createDebugDraw2DClipSpaceMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDebugDraw2DScreenSpaceMaterial */
 		HMaterial createDebugDraw2DScreenSpaceMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDebugDraw3DMaterial */
 		HMaterial createDebugDraw3DMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDockDropOverlayMaterial */
 		HMaterial createDockDropOverlayMaterial() const;
+
+		/** @copydoc BuiltinMaterialFactory::createDummyMaterial */
 		HMaterial createDummyMaterial() const;
 
 	protected:
+		/**
+		 * @brief	Loads an compiles a shader for text rendering.
+		 */
+		void initSpriteTextShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for image sprite rendering.
+		 */
+		void initSpriteImageShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for debug 2D clip space rendering.
+		 */
+		void initDebugDraw2DClipSpaceShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for debug 2D screen space rendering.
+		 */
+		void initDebugDraw2DScreenSpaceShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for debug 3D rendering.
+		 */
+		void initDebugDraw3DShader();
+
+		/**
+		 * @brief	Loads an compiles a shader for dock overlay rendering.
+		 */
+		void initDockDropOverlayShader();
+
+		/**
+		 * @brief	Loads an compiles a simple shader to be used with no other is usable.
+		 */
+		void initDummyShader();
+
 		ShaderPtr mSpriteTextShader;
 		ShaderPtr mSpriteImageShader;
 		ShaderPtr mDebugDraw2DClipSpaceShader;
@@ -33,13 +86,5 @@ namespace BansheeEngine
 		ShaderPtr mDummyShader;
 
 		HSamplerState mGUISamplerState;
-
-		void initSpriteTextShader();
-		void initSpriteImageShader();
-		void initDebugDraw2DClipSpaceShader();
-		void initDebugDraw2DScreenSpaceShader();
-		void initDebugDraw3DShader();
-		void initDockDropOverlayShader();
-		void initDummyShader();
 	};
 }

+ 1 - 2
BansheeEngine/Include/BsInputConfiguration.h

@@ -30,12 +30,11 @@ namespace BansheeEngine
 	struct BS_EXPORT VIRTUAL_AXIS_DESC
 	{
 		VIRTUAL_AXIS_DESC();
-		VIRTUAL_AXIS_DESC(UINT32 type, float deadZone = 0.0001f, float sensitivity = 1.0f, bool invert = false, bool smooth = true);
+		VIRTUAL_AXIS_DESC(UINT32 type, float deadZone = 0.0001f, float sensitivity = 1.0f, bool invert = false);
 
 		float deadZone;
 		float sensitivity;
 		bool invert;
-		bool smooth;
 		UINT32 type;
 	};
 

+ 27 - 2
BansheeEngine/Include/BsScriptManager.h

@@ -5,27 +5,52 @@
 
 namespace BansheeEngine 
 {
+	/**
+	 * @brief	Abstraction of a specific scripting system.
+	 */
 	class BS_EXPORT ScriptSystem
 	{
 	public:
 		virtual ~ScriptSystem() { }
 
+		/**
+		 * @brief	Called when the script system is being activated.
+		 */
 		virtual void initialize() = 0;
+
+		/**
+		 * @brief	Called when the script system is being destryoed.
+		 */
 		virtual void destroy() = 0;
 	};
 
+	/**
+	 * @brief	Handles initialization of a scripting system.
+	 */
 	class BS_EXPORT ScriptManager : public Module<ScriptManager>
 	{
 	public:
 		ScriptManager() { }
 		~ScriptManager() { }
 
+		/**
+		 * @brief	Initializes the script managed with the specified script system,
+		 *			making it active. Should be called right after construction.
+		 */
 		void initialize(const std::shared_ptr<ScriptSystem>& scriptSystem);
+
+		/**
+		 * @brief	Destroys the currently active script system. Must be called just
+		 *			before shutdown.
+		 */
 		void destroy();
 
 	private:
-		std::shared_ptr<ScriptSystem> mScriptSystem;
-
+		/**
+		 * @copydoc	ScriptManager::onShutDown
+		 */
 		void onShutDown();
+
+		std::shared_ptr<ScriptSystem> mScriptSystem;
 	};
 }

+ 3 - 3
BansheeEngine/Source/BsInputConfiguration.cpp

@@ -17,11 +17,11 @@ namespace BansheeEngine
 	{ }
 
 	VIRTUAL_AXIS_DESC::VIRTUAL_AXIS_DESC()
-		: type((UINT32)InputAxis::MouseX), deadZone(0.0001f), sensitivity(1.0f), invert(false), smooth(true)
+		: type((UINT32)InputAxis::MouseX), deadZone(0.0001f), sensitivity(1.0f), invert(false)
 	{ }
 
-	VIRTUAL_AXIS_DESC::VIRTUAL_AXIS_DESC(UINT32 type, float deadZone, float sensitivity, bool invert, bool smooth)
-		:type(type), deadZone(deadZone), sensitivity(sensitivity), invert(invert), smooth(smooth)
+	VIRTUAL_AXIS_DESC::VIRTUAL_AXIS_DESC(UINT32 type, float deadZone, float sensitivity, bool invert)
+		:type(type), deadZone(deadZone), sensitivity(sensitivity), invert(invert)
 	{ }
 
 	VirtualButton::VirtualButton()

+ 1 - 1
BansheeEngine/Source/BsVirtualInput.cpp

@@ -78,7 +78,7 @@ namespace BansheeEngine
 		VIRTUAL_AXIS_DESC axisDesc;
 		if (mInputConfiguration->_getAxis(axis, axisDesc))
 		{
-			float axisValue = gInput().getAxisValue((UINT32)axisDesc.type, deviceIdx, axisDesc.smooth);
+			float axisValue = gInput().getAxisValue((UINT32)axisDesc.type, deviceIdx);
 
 			if (axisDesc.deadZone > 0.0f)
 			{

+ 6 - 6
BansheeOISInput/BansheeOISInput.vcxproj

@@ -129,7 +129,7 @@
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Debug;./Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;CamelotOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
   </ItemDefinitionGroup>
@@ -144,7 +144,7 @@
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Debug;./Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;CamelotOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
   </ItemDefinitionGroup>
@@ -165,7 +165,7 @@
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Release;./Dependencies/lib/x86/Release</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;CamelotOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
   </ItemDefinitionGroup>
@@ -186,7 +186,7 @@
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/DebugRelease;./Dependencies/lib/x86/DebugRelease</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;CamelotOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
   </ItemDefinitionGroup>
@@ -207,7 +207,7 @@
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Release;./Dependencies/lib/x64/Release</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;CamelotOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
   </ItemDefinitionGroup>
@@ -228,7 +228,7 @@
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/DebugRelease;./Dependencies/lib/x64/DebugRelease</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;CamelotOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeOIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
   </ItemDefinitionGroup>

+ 32 - 1
BansheeOISInput/Include/BsInputHandlerOIS.h

@@ -118,13 +118,44 @@ namespace BansheeEngine
 	private:
 		friend class GamepadEventListener;
 
-		static const UINT32 MOUSE_SENSITIVITY; /**< Converts arbitrary mouse axis range to [-1, 1] range. */
+		/**
+		 * @brief	Smooths the input mouse axis value. Smoothing makes the changes to
+		 *			the axis more gradual depending on previous values.
+		 *
+		 * @param	value	Value to smooth.
+		 * @param	idx		Index of the mouse axis to smooth, 0 - horizontal, 1 - vertical.
+		 *
+		 * @returns	Smoothed value.
+		 */
+		float smoothMouse(float value, UINT32 idx);
+
+		/**
+		 * @brief	Default dots per inch reported by the mouse. 
+		 *
+		 * @note	This should be retrieved from the mouse driver but I am not aware of any decent 
+		 *			way of doing it. What this means is that if the user has a mouse with a different 
+		 *			DPI then he will need to adjust sensitivity.
+		 */
+		static const UINT32 MOUSE_DPI;
+
+		/**
+		 * @brief	How much does the user need to move the mouse in order to max out the mouse axis
+		 *			(either positive or negative), in inches.
+		 */
+		static const float MOUSE_MAX;
 
 		OIS::InputManager* mInputManager;
 		OIS::Mouse*	mMouse;
 		OIS::Keyboard* mKeyboard;
 		Vector<GamepadData> mGamepads;
 
+		float mTotalMouseSamplingTime[2];
+		UINT32 mTotalMouseNumSamples[2];
+		float mMouseZeroTime[2];
+		INT32 mMouseSampleAccumulator[2];
+		float mMouseSmoothedAxis[2];
+		UINT32 mLastMouseUpdateFrame;
+
 		UINT64 mTimestampClockOffset;
 	};
 }

+ 104 - 11
BansheeOISInput/Source/BsInputHandlerOIS.cpp

@@ -8,7 +8,8 @@
 
 namespace BansheeEngine
 {
-	const UINT32 InputHandlerOIS::MOUSE_SENSITIVITY = 1;
+	const UINT32 InputHandlerOIS::MOUSE_DPI = 800;
+	const float InputHandlerOIS::MOUSE_MAX = 0.05f;
 
 	GamepadEventListener::GamepadEventListener(InputHandlerOIS* parentHandler, UINT32 joystickIdx)
 		:mParentHandler(parentHandler), mGamepadIdx(joystickIdx)
@@ -52,8 +53,20 @@ namespace BansheeEngine
 	}
 
 	InputHandlerOIS::InputHandlerOIS(unsigned int hWnd)
-		:mInputManager(nullptr), mKeyboard(nullptr), mMouse(nullptr), mTimestampClockOffset(0)
+		:mInputManager(nullptr), mKeyboard(nullptr), mMouse(nullptr), mTimestampClockOffset(0),
+		mLastMouseUpdateFrame(0)
 	{
+		mMouseSampleAccumulator[0] = 0;
+		mMouseSampleAccumulator[1] = 0;
+		mTotalMouseSamplingTime[0] = 1.0f / 125.0f; // Use 125Hz as initial pooling rate for mice
+		mTotalMouseSamplingTime[1] = 1.0f / 125.0f;
+		mTotalMouseNumSamples[0] = 1;
+		mTotalMouseNumSamples[1] = 1;
+		mMouseSmoothedAxis[0] = 0.0f;
+		mMouseSmoothedAxis[1] = 0.0f;
+		mMouseZeroTime[0] = 0.0f;
+		mMouseZeroTime[1] = 0.0f;
+
 		OIS::ParamList pl;
 		std::ostringstream windowHndStr;
 		windowHndStr << hWnd;
@@ -128,6 +141,46 @@ namespace BansheeEngine
 		}
 	}
 
+	float InputHandlerOIS::smoothMouse(float value, UINT32 idx)
+	{
+		UINT32 sampleCount = 1;
+
+		float deltaTime = gTime().getFrameDelta();
+		if (deltaTime < 0.25f)
+		{
+			float secondsPerSample = mTotalMouseSamplingTime[idx] / mTotalMouseNumSamples[idx];
+
+			if (value == 0.0f)
+			{
+				mMouseZeroTime[idx] += deltaTime;
+				if (mMouseZeroTime[idx] < secondsPerSample)
+					value = mMouseSmoothedAxis[idx] * deltaTime / secondsPerSample;
+				else
+					mMouseSmoothedAxis[idx] = 0;
+			}
+			else
+			{
+				mMouseZeroTime[idx] = 0;
+				if (mMouseSmoothedAxis[idx] != 0)
+				{
+					if (deltaTime < secondsPerSample * (sampleCount + 1))
+						value = value * deltaTime / (secondsPerSample * sampleCount);
+					else
+						sampleCount = Math::roundToInt(deltaTime / secondsPerSample);
+				}
+
+				mMouseSmoothedAxis[idx] = value / sampleCount;
+			}
+		}
+		else
+		{
+			mMouseSmoothedAxis[idx] = 0.0f;
+			mMouseZeroTime[idx] = 0.0f;
+		}
+
+		return value;
+	}
+
 	void InputHandlerOIS::_update()
 	{
 		if (mMouse != nullptr)
@@ -140,6 +193,39 @@ namespace BansheeEngine
 		{
 			gamepadData.gamepad->capture();
 		}
+
+		float rawXValue = 0.0f;
+		float rawYValue = 0.0f;
+
+		// Smooth mouse axes if needed
+		if (mMouseSmoothingEnabled)
+		{
+			rawXValue = smoothMouse((float)mMouseSampleAccumulator[0], 0);
+			rawYValue = smoothMouse((float)mMouseSampleAccumulator[1], 1);
+		}
+		else
+		{
+			rawXValue = (float)mMouseSampleAccumulator[0];
+			rawYValue = (float)mMouseSampleAccumulator[1];
+		}
+
+		mMouseSampleAccumulator[0] = 0;
+		mMouseSampleAccumulator[1] = 0;
+
+		// Move the axis values in [-1.0, 1.0] range.
+		float maxAxis = MOUSE_DPI * MOUSE_MAX;
+
+		RawAxisState xState;
+		xState.rel = -Math::clamp(rawXValue / maxAxis, -1.0f, 1.0f);
+		xState.abs = xState.rel; // Abs value irrelevant for mouse
+
+		onAxisMoved(0, xState, (UINT32)InputAxis::MouseX);
+
+		RawAxisState yState;
+		yState.rel = -Math::clamp(rawYValue / maxAxis, -1.0f, 1.0f);
+		yState.abs = yState.rel; // Abs value irrelevant for mouse
+		
+		onAxisMoved(0, yState, (UINT32)InputAxis::MouseY);
 	}
 
 	void InputHandlerOIS::_inputWindowChanged(const RenderWindow& win)
@@ -166,17 +252,24 @@ namespace BansheeEngine
 
 	bool InputHandlerOIS::mouseMoved(const OIS::MouseEvent& arg)
 	{
-		RawAxisState xState;
-		xState.rel = Math::clamp(arg.state.X.rel / (float)MOUSE_SENSITIVITY, -1.0f, 1.0f);
-		xState.abs = xState.rel; // Abs value irrelevant for mouse
-		
-		onAxisMoved(0, xState, (UINT32)InputAxis::MouseX);
+		mMouseSampleAccumulator[0] += arg.state.X.rel;
+		mMouseSampleAccumulator[1] += arg.state.Y.rel;
 
-		RawAxisState yState;
-		yState.rel = Math::clamp(arg.state.Y.rel / (float)MOUSE_SENSITIVITY, -1.0f, 1.0f);
-		yState.abs = yState.rel; // Abs value irrelevant for mouse
+		mTotalMouseNumSamples[0] += Math::roundToInt(Math::abs((float)arg.state.X.rel));
+		mTotalMouseNumSamples[1] += Math::roundToInt(Math::abs((float)arg.state.Y.rel));
 
-		onAxisMoved(0, yState, (UINT32)InputAxis::MouseY);
+		// Update sample times used for determining sampling rate. But only if something was
+		// actually sampled, and only if this isn't the first non-zero sample.
+		if (mLastMouseUpdateFrame != gTime().getCurrentFrameNumber())
+		{
+			if (arg.state.X.rel != 0 && !Math::approxEquals(mMouseSmoothedAxis[0], 0.0f))
+				mTotalMouseSamplingTime[0] += gTime().getFrameDelta();
+
+			if (arg.state.Y.rel != 0 && !Math::approxEquals(mMouseSmoothedAxis[1], 0.0f))
+				mTotalMouseSamplingTime[1] += gTime().getFrameDelta();
+
+			mLastMouseUpdateFrame = gTime().getCurrentFrameNumber();
+		}
 
 		RawAxisState zState;
 		zState.abs = (float)arg.state.Z.abs;

+ 7 - 7
ExampleProject/CameraFlyer.cpp

@@ -14,7 +14,7 @@ namespace BansheeEngine
 	const float CameraFlyer::TOP_SPEED = 130.0f;
 	const float CameraFlyer::ACCELERATION = 10.0f;
 	const float CameraFlyer::FAST_MODE_MULTIPLIER = 2.0f;
-	const float CameraFlyer::ROTATION_SPEED = 0.5f; // Degrees/pixel
+	const float CameraFlyer::ROTATION_SPEED = 360.0f; // Degrees/second
 
 	CameraFlyer::CameraFlyer(const HSceneObject& parent)
 		:Component(parent), mPitch(0.0f), mYaw(0.0f), mLastButtonState(false)
@@ -59,6 +59,8 @@ namespace BansheeEngine
 		if (goingRight) direction += SO()->getRight();
 		if (goingLeft) direction -= SO()->getRight();
 
+		float frameDelta = gTime().getFrameDelta();
+
 		if (direction.squaredLength() != 0)
 		{
 			direction.normalize();
@@ -67,7 +69,7 @@ namespace BansheeEngine
 			if (fastMove)
 				multiplier = FAST_MODE_MULTIPLIER;
 
-			mCurrentSpeed = Math::clamp(mCurrentSpeed + ACCELERATION * gTime().getFrameDelta(), START_SPEED, TOP_SPEED);
+			mCurrentSpeed = Math::clamp(mCurrentSpeed + ACCELERATION * frameDelta, START_SPEED, TOP_SPEED);
 			mCurrentSpeed *= multiplier;
 		}
 		else
@@ -79,13 +81,13 @@ namespace BansheeEngine
 		if (mCurrentSpeed > tooSmall)
 		{
 			Vector3 velocity = direction * mCurrentSpeed;
-			SO()->move(velocity * gTime().getFrameDelta());
+			SO()->move(velocity * frameDelta);
 		}
 
 		if (camRotating)
 		{
-			mYaw += Degree(gVirtualInput().getAxisValue(mHorizontalAxis) * ROTATION_SPEED);
-			mPitch += Degree(gVirtualInput().getAxisValue(mVerticalAxis) * ROTATION_SPEED);
+			mYaw += Degree(gVirtualInput().getAxisValue(mHorizontalAxis) * ROTATION_SPEED * frameDelta);
+			mPitch += Degree(gVirtualInput().getAxisValue(mVerticalAxis) * ROTATION_SPEED * frameDelta);
 
 			Quaternion yRot;
 			yRot.fromAxisAngle(Vector3::UNIT_Y, Radian(mYaw));
@@ -97,7 +99,5 @@ namespace BansheeEngine
 
 			SO()->setRotation(camRot);
 		}
-
-		LOGWRN(toString(SO()->getPosition()));
 	}
 }

+ 1 - 0
Notes.txt

@@ -62,6 +62,7 @@ Reminders:
   - std::function allocates memory but I have no got way of using custom allocators as I'd have to wrap std::bind and that seems non-trivial
   - Add a TaskScheduler profiler that neatly shows time slices of each task and on which thread they are run on
   - Add support for BC6H and BC7 file format compression
+  - D-Pad on non-XInput devices will not be handled properly by the Input system because OIS reports it separately from other buttons (Simple to fix)
 
 Potential optimizations:
  - bulkPixelConversion is EXTREMELY poorly unoptimized. Each pixel it calls a separate method that does redudant operations every pixel.

+ 2 - 15
Polish.txt

@@ -2,7 +2,6 @@ Polish TODO:
  - Finish basic example, get a model rendering on screen
  - Fix FBX importer so proper number of vertices show
  - Test and fix full-screen transitions
- - Add virtual input axes
  - Compress and generate mips for texture on input (testing NVTT stuff)
  - Add frustum culling and sorting code
  - Finalize example
@@ -14,20 +13,8 @@ Polish TODO:
 
  Model triangles are inverted.
 
-Rebuild OIS with XINPUT support (OIS_WIN32_XINPUT_SUPPORT)
-Rename CamelotOIS to BansheeOIS
-
-OIS doesn't report D-pad as buttons
-
-Mouse sensitivity/sampling rate/whatever needs to be tweaked
- - Use DirectInput DIPROPRANGE and SetProperty/GetProperty?
-
-Add smoothing
-  - See http://www.flipcode.com/archives/Smooth_Mouse_Filtering.shtml or UE4 implementation
-  - UE4 seems to receive multiple mouse samples per frame. I only sample input once per frame
-    - Actually OIS seems to receive multiple samples too, but it just accumulates them automatically
-
-Scale input by FOV like in UE4?
+Re-test gamepad buttons now that XInput is active
+ CameraFlyer is broken and doesn't rotate around Y properly (e.g. looking up will cause it to roll instead of yaw)
 
 -----------------