Browse Source

Added wireframe mesh drawing to gizmo drawing

BearishSun 9 years ago
parent
commit
c1adc754b2

+ 342 - 342
Build/VS2015/BansheeSL.vcxproj

@@ -1,343 +1,343 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="DebugRelease|Win32">
-      <Configuration>DebugRelease</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="DebugRelease|x64">
-      <Configuration>DebugRelease</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Debug|x64">
-      <Configuration>Debug</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|x64">
-      <Configuration>Release</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{2BA791F1-87F6-4863-A784-D07FF605AC5E}</ProjectGuid>
-    <RootNamespace>BansheeSL</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings" />
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <OutDir>..\..\bin\x86\$(Configuration)\</OutDir>
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
-    <OutDir>..\..\bin\$(Platform)\$(Configuration)\</OutDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <OutDir>..\..\bin\x86\$(Configuration)\</OutDir>
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
-    <OutDir>..\..\bin\$(Platform)\$(Configuration)\</OutDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
-    <OutDir>..\..\bin\x86\$(Configuration)\</OutDir>
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
-    <OutDir>..\..\bin\$(Platform)\$(Configuration)\</OutDir>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <SDLCheck>false</SDLCheck>
-      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeTypeInfo>false</RuntimeTypeInfo>
-      <ExceptionHandling>false</ExceptionHandling>
-      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
-    </ClCompile>
-    <Link>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalLibraryDirectories>../../lib/x86/$(Configuration);../../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <ImportLibrary>..\..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-    <PreBuildEvent>
-      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
-"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
-xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
-xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
-del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
-    </PreBuildEvent>
-    <PreBuildEvent>
-      <Message>Building lexer/parser...</Message>
-    </PreBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <SDLCheck>false</SDLCheck>
-      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeTypeInfo>false</RuntimeTypeInfo>
-      <ExceptionHandling>false</ExceptionHandling>
-      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
-    </ClCompile>
-    <Link>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalLibraryDirectories>../../lib/$(Platform)/$(Configuration);../../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <ImportLibrary>..\..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-    <PreBuildEvent>
-      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
-"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
-xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
-xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
-del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
-    </PreBuildEvent>
-    <PreBuildEvent>
-      <Message>Building lexer/parser...</Message>
-    </PreBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <SDLCheck>false</SDLCheck>
-      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <DebugInformationFormat>None</DebugInformationFormat>
-      <RuntimeTypeInfo>false</RuntimeTypeInfo>
-      <ExceptionHandling>false</ExceptionHandling>
-      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
-    </ClCompile>
-    <Link>
-      <GenerateDebugInformation>false</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalLibraryDirectories>../../lib/x86/$(Configuration);../../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <ImportLibrary>..\..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-    <PreBuildEvent>
-      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
-"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
-xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
-xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
-del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
-    </PreBuildEvent>
-    <PreBuildEvent>
-      <Message>Building lexer/parser...</Message>
-    </PreBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <SDLCheck>false</SDLCheck>
-      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <DebugInformationFormat>None</DebugInformationFormat>
-      <RuntimeTypeInfo>false</RuntimeTypeInfo>
-      <ExceptionHandling>false</ExceptionHandling>
-      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
-    </ClCompile>
-    <Link>
-      <GenerateDebugInformation>false</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalLibraryDirectories>../../lib/$(Platform)/$(Configuration);../../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <ImportLibrary>..\..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-    <PreBuildEvent>
-      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
-"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
-xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
-xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
-del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
-    </PreBuildEvent>
-    <PreBuildEvent>
-      <Message>Building lexer/parser...</Message>
-    </PreBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <SDLCheck>false</SDLCheck>
-      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeTypeInfo>false</RuntimeTypeInfo>
-      <ExceptionHandling>false</ExceptionHandling>
-      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
-    </ClCompile>
-    <Link>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalLibraryDirectories>../../lib/x86/$(Configuration);../../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <ImportLibrary>..\..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-    <PreBuildEvent>
-      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
-"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
-xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
-xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
-del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
-    </PreBuildEvent>
-    <PreBuildEvent>
-      <Message>Building lexer/parser...</Message>
-    </PreBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <SDLCheck>false</SDLCheck>
-      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeTypeInfo>false</RuntimeTypeInfo>
-      <ExceptionHandling>false</ExceptionHandling>
-      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
-    </ClCompile>
-    <Link>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalLibraryDirectories>../../lib/$(Platform)/$(Configuration);../../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
-      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <ImportLibrary>..\..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-    <PreBuildEvent>
-      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
-"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
-xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
-xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
-xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
-del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
-    </PreBuildEvent>
-    <PreBuildEvent>
-      <Message>Building lexer/parser...</Message>
-    </PreBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsASTFX.h" />
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsIncludeHandler.h" />
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsLexerFX.h" />
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsParserFX.h" />
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLFXCompiler.h" />
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLImporter.h" />
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsMMAlloc.h" />
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLPrerequisites.h" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="BsParserFX.y" />
-    <None Include="BsLexerFX.l" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsASTFX.c" />
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsIncludeHandler.cpp" />
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsLexerFX.c" />
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BSMMAlloc.c" />
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsParserFX.c" />
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLFXCompiler.cpp" />
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLImporter.cpp" />
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLPlugin.cpp" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets" />
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="DebugRelease|Win32">
+      <Configuration>DebugRelease</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="DebugRelease|x64">
+      <Configuration>DebugRelease</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{2BA791F1-87F6-4863-A784-D07FF605AC5E}</ProjectGuid>
+    <RootNamespace>BansheeSL</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings" />
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <OutDir>..\..\bin\x86\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+    <OutDir>..\..\bin\$(Platform)\$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <OutDir>..\..\bin\x86\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+    <OutDir>..\..\bin\$(Platform)\$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
+    <OutDir>..\..\bin\x86\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+    <OutDir>..\..\bin\$(Platform)\$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeTypeInfo>false</RuntimeTypeInfo>
+      <ExceptionHandling>false</ExceptionHandling>
+      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>../../lib/x86/$(Configuration);../../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+    <PreBuildEvent>
+      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
+"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
+xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
+xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
+del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
+    </PreBuildEvent>
+    <PreBuildEvent>
+      <Message>Building lexer/parser...</Message>
+    </PreBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeTypeInfo>false</RuntimeTypeInfo>
+      <ExceptionHandling>false</ExceptionHandling>
+      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>../../lib/$(Platform)/$(Configuration);../../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+    <PreBuildEvent>
+      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
+"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
+xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
+xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
+del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
+    </PreBuildEvent>
+    <PreBuildEvent>
+      <Message>Building lexer/parser...</Message>
+    </PreBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <DebugInformationFormat>None</DebugInformationFormat>
+      <RuntimeTypeInfo>false</RuntimeTypeInfo>
+      <ExceptionHandling>false</ExceptionHandling>
+      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>../../lib/x86/$(Configuration);../../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+    <PreBuildEvent>
+      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
+"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
+xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
+xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
+del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
+    </PreBuildEvent>
+    <PreBuildEvent>
+      <Message>Building lexer/parser...</Message>
+    </PreBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <DebugInformationFormat>None</DebugInformationFormat>
+      <RuntimeTypeInfo>false</RuntimeTypeInfo>
+      <ExceptionHandling>false</ExceptionHandling>
+      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>../../lib/$(Platform)/$(Configuration);../../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+    <PreBuildEvent>
+      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
+"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
+xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
+xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
+del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
+    </PreBuildEvent>
+    <PreBuildEvent>
+      <Message>Building lexer/parser...</Message>
+    </PreBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeTypeInfo>false</RuntimeTypeInfo>
+      <ExceptionHandling>false</ExceptionHandling>
+      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>../../lib/x86/$(Configuration);../../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+    <PreBuildEvent>
+      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
+"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
+xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
+xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
+del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
+    </PreBuildEvent>
+    <PreBuildEvent>
+      <Message>Building lexer/parser...</Message>
+    </PreBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>../../Source/BansheeCore/Include;../../Source/BansheeUtility/Include;../../Source/BansheeEngine/Include;../../Source/BansheeSL/Include;..\..\Dependencies\Include;./</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>BS_SL_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeTypeInfo>false</RuntimeTypeInfo>
+      <ExceptionHandling>false</ExceptionHandling>
+      <DisableSpecificWarnings>4530;4577</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>../../lib/$(Platform)/$(Configuration);../../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>BansheeCore.lib;BansheeUtility.lib;BansheeEngine.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+    <PreBuildEvent>
+      <Command>"..\..\Source\BansheeSL\Dependencies\tools\flex\flex.exe" --wincompat "..\..\Source\BansheeSL\BsLexerFX.l"
+"..\..\Source\BansheeSL\Dependencies\tools\bison\bison.exe" "..\..\Source\BansheeSL\BsParserFX.y"
+xcopy /Y /I "BsLexerFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsLexerFX.c" "..\..\Source\BansheeSL\Source"
+xcopy /Y /I "BsParserFX.h" "..\..\Source\BansheeSL\Include"
+xcopy /Y /I "BsParserFX.c" "..\..\Source\BansheeSL\Source"
+del BsLexerFX.h BsLexerFX.c BsParserFX.h BsParserFX.c</Command>
+    </PreBuildEvent>
+    <PreBuildEvent>
+      <Message>Building lexer/parser...</Message>
+    </PreBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsASTFX.h" />
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsIncludeHandler.h" />
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsLexerFX.h" />
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsParserFX.h" />
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLFXCompiler.h" />
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLImporter.h" />
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsMMAlloc.h" />
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLPrerequisites.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\Source\BansheeSL\BsLexerFX.l" />
+    <None Include="..\..\Source\BansheeSL\BsParserFX.y" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsASTFX.c" />
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsIncludeHandler.cpp" />
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsLexerFX.c" />
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BSMMAlloc.c" />
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsParserFX.c" />
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLFXCompiler.cpp" />
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLImporter.cpp" />
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLPlugin.cpp" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets" />
 </Project>

+ 68 - 68
Build/VS2015/BansheeSL.vcxproj.filters

@@ -1,69 +1,69 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLPrerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsASTFX.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsMMAlloc.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLImporter.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLFXCompiler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsIncludeHandler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsLexerFX.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\Source\BansheeSL\Include\BsParserFX.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="BsLexerFX.l" />
-    <None Include="BsParserFX.y" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLPlugin.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsASTFX.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLImporter.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLFXCompiler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsIncludeHandler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BSMMAlloc.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsLexerFX.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\Source\BansheeSL\Source\BsParserFX.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsASTFX.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsMMAlloc.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLImporter.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsSLFXCompiler.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsIncludeHandler.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsLexerFX.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Source\BansheeSL\Include\BsParserFX.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\Source\BansheeSL\BsLexerFX.l" />
+    <None Include="..\..\Source\BansheeSL\BsParserFX.y" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsASTFX.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLImporter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsSLFXCompiler.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsIncludeHandler.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BSMMAlloc.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsLexerFX.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Source\BansheeSL\Source\BsParserFX.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 454 - 449
Source/BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -1,450 +1,455 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsEditorPrerequisites.h"
-#include "BsGUISkin.h"
-#include "BsModule.h"
-#include "BsGUIContent.h"
-#include "BsApplication.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup Utility-Editor
-	 *  @{
-	 */
-
-	/**	Types of valid icons used when viewing the project library. */
-	enum class ProjectIcon
-	{
-		Folder, Mesh, Font, Texture, PlainText, ScriptCode, SpriteTexture, Shader, ShaderInclude, Material, Prefab, GUISkin,
-		PhysicsMaterial, PhysicsMesh
-	};
-
-	/**	Types of icons that may be displayed on the tool bar. */
-	enum class ToolbarIcon
-	{
-		NewCamera, NewRenderable, NewPointLight, NewDirLight, NewSpotLight, NewSceneObject, NewCube, NewSphere, NewCone, 
-		NewQuad, NewMat, NewCSScript, NewShader, NewSpriteTex, Pause, Play, Step, Undo, Redo, OpenProject, SaveProject, 
-		SaveScene
-	};
-
-	/**	Types of icons that may be displayed in the scene window. */
-	enum class SceneWindowIcon
-	{
-		View, Move, Rotate, Scale, Pivot, Center, Local, World, MoveSnap, RotateSnap
-	};
-
-	/**	Types of icons that may be displayed in the inspector window. */
-	enum class InspectorWindowIcon
-	{
-		Create, Clone, Clear, Resize, Delete, MoveUp, MoveDown, Edit, Apply, Add, Cancel
-	};
-
-	/**	Types of icons that may be displayed in the library window. */
-	enum class LibraryWindowIcon
-	{
-		Home, Up, Clear, Options
-	};
-
-	/**	Types of icons used in various areas throughout the editor. */
-	enum class EditorIcon
-	{
-		XBtn
-	};
-
-	/**	Types of icons to be used along with log messages depending on their severity. */
-	enum class LogMessageIcon
-	{
-		Info, Warning, Error
-	};
-
-	/**	Contains a set of built-in resources used by the editor. */
-	class BS_ED_EXPORT BuiltinEditorResources : public BansheeEngine::Module<BuiltinEditorResources>
-	{
-	public:
-		BuiltinEditorResources();
-		~BuiltinEditorResources();
-
-		/**	Returns the default editor GUI skin. */
-		const HGUISkin& getSkin() const { return mSkin; }
-
-		/** Returns the default font used by the editor. */
-		const HFont& getDefaultFont() const { return mDefaultFont; }
-
-		/**	Creates a material used for docking drop overlay used by the editor. */
-		HMaterial createDockDropOverlayMaterial() const;
-
-		/**	Creates a material used for rendering the scene grid. */
-		HMaterial createSceneGridMaterial() const;
-
-		/**	Creates a material used for picking non-transparent objects in scene view. */
-		HMaterial createPicking(CullingMode cullMode) const;
-
-		/**	Creates a material used for picking transparent objects in scene view. */
-		HMaterial createPickingAlpha(CullingMode cullMode) const;
-
-		/**	Creates a material used for rendering wireframe gizmos. */
-		HMaterial createWireGizmoMat() const;
-
-		/**	Creates a material used for rendering solid gizmos. */
-		HMaterial createSolidGizmoMat() const;
-
-		/**	Creates a material used for rendering icon gizmos. */
-		HMaterial createIconGizmoMat() const;
-
-		/**	Creates a material used for picking non-transparent gizmos. */
-		HMaterial createGizmoPickingMat() const;
-
-		/**	Creates a material used for picking transparent gizmos. */
-		HMaterial createAlphaGizmoPickingMat() const;
-
-		/**	Creates a material used for rendering wireframe handles. */
-		HMaterial createWireHandleMat() const;
-
-		/**	Creates a material used for rendering solid handles. */
-		HMaterial createSolidHandleMat() const;
-
-		/** Creates a material used for rendering text for gizmos and handles. */
-		HMaterial createTextGizmoMat() const;
-
-		/** Creates a material used for clearing the alpha channel of the handle rendering texture. */
-		HMaterial createHandleClearAlphaMat() const;
-
-		/**	Creates a material used for displaying selected objects. */
-		HMaterial createSelectionMat() const;
-
-		/**
-		 * Retrieves an icon that represents a specific resource type that may be displayed when viewing the project 
-		 * library.
-		 */
-		HSpriteTexture getLibraryIcon(ProjectIcon icon, int size) const;
-
-		/**	Retrieves an icon that may be displayed on the main window's toolbar. */
-		HSpriteTexture getToolbarIcon(ToolbarIcon icon) const;
-
-		/**	Retrieves an icon that may be displayed on the scene window. */
-		GUIContentImages getSceneWindowIcon(SceneWindowIcon icon) const;
-
-		/**	Retrieves an icon that may be displayed on the library window. */
-		HSpriteTexture getLibraryWindowIcon(LibraryWindowIcon icon) const;
-
-		/**	Retrieves an icon that may be displayed on the inspector window. */
-		HSpriteTexture getInspectorWindowIcon(InspectorWindowIcon icon) const;
-
-		/**	Retrieves an icon that represents a specific generic editor icon. */
-		HSpriteTexture getIcon(EditorIcon icon) const;
-
-		/**	Retrieves an icon that represents a specific log message type. */
-		HSpriteTexture getLogMessageIcon(LogMessageIcon icon, UINT32 size, bool dark) const;
-
-		/**	Returns text contained in the default "empty" shader. */
-		WString getEmptyShaderCode() const;
-
-		/**	Returns text contained in the default "empty" C# script. */
-		WString getEmptyCSScriptCode() const;
-
-		/**	Returns path to the builtin shader include folder, relative to the working directory. */
-		static Path getShaderIncludeFolder();
-
-		/**	Returns path to the default widget layout file, relative to the working directory. */
-		static Path getDefaultWidgetLayoutPath();
-
-		static const String ObjectFieldStyleName;
-		static const String ObjectFieldLabelStyleName;
-		static const String ObjectFieldDropBtnStyleName;
-		static const String ObjectFieldClearBtnStyleName;
-
-		static const String TextureFieldStyleName;
-		static const String TextureFieldLabelStyleName;
-		static const String TextureFieldDropStyleName;
-		static const String TextureFieldClearBtnStyleName;
-
-	private:
-		/**
-		 * Imports all necessary resources and converts them to engine-ready format.
-		 *
-		 * @note	
-		 * Normally you only want to use this during development phase and then ship with engine-ready format only.
-		 */
-		void preprocess();
-
-		/**	Generates the default editor skin and all GUI element styles. */
-		GUISkinPtr generateGUISkin();
-
-		/**
-		 * Generates different sizes of resource icons. Expects maximum sizes of the icons to already be present. Resulting
-		 * textures will be saved to the same directory the maximum size textures are in.
-		 */
-		void generateResourceIcons(const Path& inputFolder, const ResourceManifestPtr& resourceManifest);
-
-		/**	Loads a GUI skin texture with the specified filename. */
-		HSpriteTexture getGUITexture(const WString& name) const;
-
-		/**	Loads a GUI icon with the specified filename. */
-		HSpriteTexture getGUIIcon(const WString& name) const;
-
-		/**	Loads a shader with the specified filename */
-		HShader getShader(const WString& name) const;
-
-		HShader mShaderDockOverlay;
-		HShader mShaderSceneGrid;
-		HShader mShaderPicking[3];
-		HShader mShaderPickingAlpha[3];
-		HShader mShaderGizmoSolid;
-		HShader mShaderGizmoWire;
-		HShader mShaderGizmoIcon;
-		HShader mShaderGizmoPicking;
-		HShader mShaderGizmoAlphaPicking;
-		HShader mShaderGizmoText;
-		HShader mShaderHandleSolid;
-		HShader mShaderHandleWire;
-		HShader mShaderHandleClearAlpha;
-		HShader mShaderSelection;
-
-		HFont mDefaultFont;
-		HGUISkin mSkin;
-
-		ResourceManifestPtr mResourceManifest;
-
-		static const char* ShaderFolder;
-		static const char* SkinFolder;
-		static const char* IconFolder;
-		static const char* ShaderIncludeFolder;
-
-		Path BuiltinDataFolder;
-		Path EditorSkinFolder;
-		Path EditorIconFolder;
-		Path EditorShaderFolder;
-		Path EditorShaderIncludeFolder;
-
-		Path BuiltinRawDataFolder;
-		Path EditorRawSkinFolder;
-		Path EditorRawShaderIncludeFolder;
-		Path EditorRawShaderFolder;
-
-		Path ResourceManifestPath;
-
-		static const WString DefaultFontFilename;
-		static const WString DefaultAAFontFilename;
-		static const UINT32 DefaultFontSize;
-		static const UINT32 TitleFontSize;
-
-		static const Color TextNormalColor;
-		static const Color TextActiveColor;
-
-		static const WString GUISkinFile;
-
-		static const WString FolderIconTex;
-		static const WString MeshIconTex;
-		static const WString TextureIconTex;
-		static const WString FontIconTex;
-		static const WString PlainTextIconTex;
-		static const WString ScriptCodeIconTex;
-		static const WString ShaderIconTex;
-		static const WString ShaderIncludeIconTex;
-		static const WString MaterialIconTex;
-		static const WString SpriteTextureIconTex;
-		static const WString PrefabIconTex;
-		static const WString GUISkinIconTex;
-		static const WString PhysicsMaterialIconTex;
-		static const WString PhysicsMeshIconTex;
-
-
-		static const WString WindowBackgroundTex;
-
-		static const WString WindowFrameNormal;
-		static const WString WindowFrameFocused;
-
-		static const WString TabBarBackgroundTex;
-		static const WString TitleBarBackgroundTex;
-
-		static const WString CloseButtonNormalTex;
-		static const WString CloseButtonHoverTex;
-		static const WString CloseButtonActiveTex;
-
-		static const WString MinButtonNormalTex;
-		static const WString MinButtonHoverTex;
-		static const WString MinButtonActiveTex;
-
-		static const WString MaxButtonNormalTex;
-		static const WString MaxButtonHoverTex;
-		static const WString MaxButtonActiveTex;
-
-		static const WString TabButtonNormalTex;
-		static const WString TabButtonFocusedTex;
-
-		static const WString ButtonNormalTex;
-		static const WString ButtonHoverTex;
-		static const WString ButtonActiveTex;
-
-		static const WString ButtonLeftNormalTex;
-		static const WString ButtonLeftHoverTex;
-		static const WString ButtonLeftActiveTex;
-
-		static const WString ButtonRightNormalTex;
-		static const WString ButtonRightHoverTex;
-		static const WString ButtonRightActiveTex;
-
-		static const WString ToggleNormalTex;
-		static const WString ToggleHoverTex;
-		static const WString ToggleNormalOnTex;
-		static const WString ToggleHoverOnTex;
-
-		static const WString ObjectDropBtnNormalTex;
-		static const WString ObjectDropBtnNormalOnTex;
-		static const WString ObjectClearBtnNormalTex;
-		static const WString ObjectClearBtnHoverTex;
-		static const WString ObjectClearBtnActiveTex;
-
-		static const WString SliderHBackgroundTex;
-		static const WString SliderHFillTex;
-		static const WString SliderVBackgroundTex;
-		static const WString SliderVFillTex;
-		static const WString SliderHandleNormalTex;
-		static const WString SliderHandleHoverTex;
-		static const WString SliderHandleActiveTex;
-
-		static const WString FoldoutOpenNormalTex;
-		static const WString FoldoutOpenHoverTex;
-		static const WString FoldoutOpenActiveTex;
-		static const WString FoldoutClosedNormalTex;
-		static const WString FoldoutClosedHoverTex;
-		static const WString FoldoutClosedActiveTex;
-
-		static const WString InputBoxNormalTex;
-		static const WString InputBoxHoverTex;
-		static const WString InputBoxFocusedTex;
-
-		static const WString ScrollBarUpNormalTex;
-		static const WString ScrollBarUpHoverTex;
-		static const WString ScrollBarUpActiveTex;
-
-		static const WString ScrollBarDownNormalTex;
-		static const WString ScrollBarDownHoverTex;
-		static const WString ScrollBarDownActiveTex;
-
-		static const WString ScrollBarLeftNormalTex;
-		static const WString ScrollBarLeftHoverTex;
-		static const WString ScrollBarLeftActiveTex;
-
-		static const WString ScrollBarRightNormalTex;
-		static const WString ScrollBarRightHoverTex;
-		static const WString ScrollBarRightActiveTex;
-
-		static const WString ScrollBarHandleHorzNormalTex;
-		static const WString ScrollBarHandleHorzHoverTex;
-		static const WString ScrollBarHandleHorzActiveTex;
-
-		static const WString ScrollBarHandleVertNormalTex;
-		static const WString ScrollBarHandleVertHoverTex;
-		static const WString ScrollBarHandleVertActiveTex;
-
-		static const WString ScrollBarHBgTex;
-		static const WString ScrollBarVBgTex;
-
-		static const WString DropDownBtnNormalTex;
-		static const WString DropDownBtnHoverTex;
-		static const WString DropDownBtnActiveTex;
-
-		static const WString DropDownBoxBgTex;
-		static const WString DropDownBoxSideBgTex;
-		static const WString DropDownBoxHandleTex;
-
-		static const WString DropDownBoxEntryNormalTex;
-		static const WString DropDownBoxEntryHoverTex;
-
-		static const WString DropDownBoxEntryToggleNormalTex;
-		static const WString DropDownBoxEntryToggleHoverTex;
-		static const WString DropDownBoxEntryToggleNormalOnTex;
-		static const WString DropDownBoxEntryToggleHoverOnTex;
-
-		static const WString DropDownBoxBtnUpNormalTex;
-		static const WString DropDownBoxBtnUpHoverTex;
-
-		static const WString DropDownBoxBtnDownNormalTex;
-		static const WString DropDownBoxBtnDownHoverTex;
-
-		static const WString DropDownBoxEntryExpNormalTex;
-		static const WString DropDownBoxEntryExpHoverTex;
-
-		static const WString DropDownSeparatorTex;
-
-		static const WString MenuBarBgTex;
-		static const WString MenuBarBansheeLogoTex;
-
-		static const WString MenuBarBtnNormalTex;
-		static const WString MenuBarBtnHoverTex;
-		static const WString MenuBarBtnActiveTex;
-
-		static const WString MenuBarLineNormalTex;
-		static const WString MenuBarLineActiveTex;
-
-		static const WString ToolBarBtnNormalTex;
-		static const WString ToolBarBtnHoverTex;
-		static const WString ToolBarBtnActiveTex;
-
-		static const WString ToolBarSeparatorTex;
-
-		static const WString DockSliderNormalTex;
-
-		static const WString TreeViewExpandButtonOffNormal;
-		static const WString TreeViewExpandButtonOffHover;
-		static const WString TreeViewExpandButtonOnNormal;
-		static const WString TreeViewExpandButtonOnHover;
-
-		static const WString TreeViewHighlightBackground;
-		static const WString TreeViewEditBox;
-
-		static const WString TreeViewElementHighlight;
-		static const WString TreeViewElementSepHighlight;
-
-		static const WString ColorPickerSliderHorzHandleTex;
-		static const WString ColorPickerSliderVertHandleTex;
-		static const WString ColorPickerSlider2DHandleTex;
-
-		static const WString ProgressBarFillTex;
-		static const WString ProgressBarBgTex;
-
-		static const WString SelectionAreaTex;
-		static const WString SelectionBgTex;
-
-		static const WString TextureDropTex;
-		static const WString TextureDropOnTex;
-
-		static const WString XButtonNormalTex;
-		static const WString XButtonHoverTex;
-		static const WString XButtonActiveTex;
-
-		static const WString StatusBarBgTex;
-		static const WString ScrollAreaBgTex;
-
-		static const WString InspectorTitleBgTex;
-		static const WString InspectorContentBgTex;
-		static const WString InspectorContentBgAlternateTex;
-
-		static const WString ShaderDockOverlayFile;
-		static const WString ShaderSceneGridFile;
-		static const WString ShaderPickingCullNoneFile;
-		static const WString ShaderPickingCullCWFile;
-		static const WString ShaderPickingCullCCWFile;
-		static const WString ShaderPickingAlphaCullNoneFile;
-		static const WString ShaderPickingAlphaCullCWFile;
-		static const WString ShaderPickingAlphaCullCCWFile;
-		static const WString ShaderWireGizmoFile;
-		static const WString ShaderSolidGizmoFile;
-		static const WString ShaderWireHandleFile;
-		static const WString ShaderSolidHandleFile;
-		static const WString ShaderHandleClearAlphaFile;
-		static const WString ShaderIconGizmoFile;
-		static const WString ShaderGizmoPickingFile;
-		static const WString ShaderGizmoPickingAlphaFile;
-		static const WString ShaderTextGizmoFile;
-		static const WString ShaderSelectionFile;
-
-		static const WString EmptyShaderCodeFile;
-		static const WString EmptyCSScriptCodeFile;
-	};
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "BsGUISkin.h"
+#include "BsModule.h"
+#include "BsGUIContent.h"
+#include "BsApplication.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Utility-Editor
+	 *  @{
+	 */
+
+	/**	Types of valid icons used when viewing the project library. */
+	enum class ProjectIcon
+	{
+		Folder, Mesh, Font, Texture, PlainText, ScriptCode, SpriteTexture, Shader, ShaderInclude, Material, Prefab, GUISkin,
+		PhysicsMaterial, PhysicsMesh
+	};
+
+	/**	Types of icons that may be displayed on the tool bar. */
+	enum class ToolbarIcon
+	{
+		NewCamera, NewRenderable, NewPointLight, NewDirLight, NewSpotLight, NewSceneObject, NewCube, NewSphere, NewCone, 
+		NewQuad, NewMat, NewCSScript, NewShader, NewSpriteTex, Pause, Play, Step, Undo, Redo, OpenProject, SaveProject, 
+		SaveScene
+	};
+
+	/**	Types of icons that may be displayed in the scene window. */
+	enum class SceneWindowIcon
+	{
+		View, Move, Rotate, Scale, Pivot, Center, Local, World, MoveSnap, RotateSnap
+	};
+
+	/**	Types of icons that may be displayed in the inspector window. */
+	enum class InspectorWindowIcon
+	{
+		Create, Clone, Clear, Resize, Delete, MoveUp, MoveDown, Edit, Apply, Add, Cancel
+	};
+
+	/**	Types of icons that may be displayed in the library window. */
+	enum class LibraryWindowIcon
+	{
+		Home, Up, Clear, Options
+	};
+
+	/**	Types of icons used in various areas throughout the editor. */
+	enum class EditorIcon
+	{
+		XBtn
+	};
+
+	/**	Types of icons to be used along with log messages depending on their severity. */
+	enum class LogMessageIcon
+	{
+		Info, Warning, Error
+	};
+
+	/**	Contains a set of built-in resources used by the editor. */
+	class BS_ED_EXPORT BuiltinEditorResources : public BansheeEngine::Module<BuiltinEditorResources>
+	{
+	public:
+		BuiltinEditorResources();
+		~BuiltinEditorResources();
+
+		/**	Returns the default editor GUI skin. */
+		const HGUISkin& getSkin() const { return mSkin; }
+
+		/** Returns the default font used by the editor. */
+		const HFont& getDefaultFont() const { return mDefaultFont; }
+
+		/**	Creates a material used for docking drop overlay used by the editor. */
+		HMaterial createDockDropOverlayMaterial() const;
+
+		/**	Creates a material used for rendering the scene grid. */
+		HMaterial createSceneGridMaterial() const;
+
+		/**	Creates a material used for picking non-transparent objects in scene view. */
+		HMaterial createPicking(CullingMode cullMode) const;
+
+		/**	Creates a material used for picking transparent objects in scene view. */
+		HMaterial createPickingAlpha(CullingMode cullMode) const;
+
+		/**	Creates a material used for rendering line gizmos. */
+		HMaterial createLineGizmoMat() const;
+
+		/**	Creates a material used for rendering solid gizmos. */
+		HMaterial createSolidGizmoMat() const;
+
+		/**	Creates a material used for rendering wireframe gizmos. */
+		HMaterial createWireGizmoMat() const;
+
+		/**	Creates a material used for rendering icon gizmos. */
+		HMaterial createIconGizmoMat() const;
+
+		/**	Creates a material used for picking non-transparent gizmos. */
+		HMaterial createGizmoPickingMat() const;
+
+		/**	Creates a material used for picking transparent gizmos. */
+		HMaterial createAlphaGizmoPickingMat() const;
+
+		/**	Creates a material used for rendering line handles. */
+		HMaterial createLineHandleMat() const;
+
+		/**	Creates a material used for rendering solid handles. */
+		HMaterial createSolidHandleMat() const;
+
+		/** Creates a material used for rendering text for gizmos and handles. */
+		HMaterial createTextGizmoMat() const;
+
+		/** Creates a material used for clearing the alpha channel of the handle rendering texture. */
+		HMaterial createHandleClearAlphaMat() const;
+
+		/**	Creates a material used for displaying selected objects. */
+		HMaterial createSelectionMat() const;
+
+		/**
+		 * Retrieves an icon that represents a specific resource type that may be displayed when viewing the project 
+		 * library.
+		 */
+		HSpriteTexture getLibraryIcon(ProjectIcon icon, int size) const;
+
+		/**	Retrieves an icon that may be displayed on the main window's toolbar. */
+		HSpriteTexture getToolbarIcon(ToolbarIcon icon) const;
+
+		/**	Retrieves an icon that may be displayed on the scene window. */
+		GUIContentImages getSceneWindowIcon(SceneWindowIcon icon) const;
+
+		/**	Retrieves an icon that may be displayed on the library window. */
+		HSpriteTexture getLibraryWindowIcon(LibraryWindowIcon icon) const;
+
+		/**	Retrieves an icon that may be displayed on the inspector window. */
+		HSpriteTexture getInspectorWindowIcon(InspectorWindowIcon icon) const;
+
+		/**	Retrieves an icon that represents a specific generic editor icon. */
+		HSpriteTexture getIcon(EditorIcon icon) const;
+
+		/**	Retrieves an icon that represents a specific log message type. */
+		HSpriteTexture getLogMessageIcon(LogMessageIcon icon, UINT32 size, bool dark) const;
+
+		/**	Returns text contained in the default "empty" shader. */
+		WString getEmptyShaderCode() const;
+
+		/**	Returns text contained in the default "empty" C# script. */
+		WString getEmptyCSScriptCode() const;
+
+		/**	Returns path to the builtin shader include folder, relative to the working directory. */
+		static Path getShaderIncludeFolder();
+
+		/**	Returns path to the default widget layout file, relative to the working directory. */
+		static Path getDefaultWidgetLayoutPath();
+
+		static const String ObjectFieldStyleName;
+		static const String ObjectFieldLabelStyleName;
+		static const String ObjectFieldDropBtnStyleName;
+		static const String ObjectFieldClearBtnStyleName;
+
+		static const String TextureFieldStyleName;
+		static const String TextureFieldLabelStyleName;
+		static const String TextureFieldDropStyleName;
+		static const String TextureFieldClearBtnStyleName;
+
+	private:
+		/**
+		 * Imports all necessary resources and converts them to engine-ready format.
+		 *
+		 * @note	
+		 * Normally you only want to use this during development phase and then ship with engine-ready format only.
+		 */
+		void preprocess();
+
+		/**	Generates the default editor skin and all GUI element styles. */
+		GUISkinPtr generateGUISkin();
+
+		/**
+		 * Generates different sizes of resource icons. Expects maximum sizes of the icons to already be present. Resulting
+		 * textures will be saved to the same directory the maximum size textures are in.
+		 */
+		void generateResourceIcons(const Path& inputFolder, const ResourceManifestPtr& resourceManifest);
+
+		/**	Loads a GUI skin texture with the specified filename. */
+		HSpriteTexture getGUITexture(const WString& name) const;
+
+		/**	Loads a GUI icon with the specified filename. */
+		HSpriteTexture getGUIIcon(const WString& name) const;
+
+		/**	Loads a shader with the specified filename */
+		HShader getShader(const WString& name) const;
+
+		HShader mShaderDockOverlay;
+		HShader mShaderSceneGrid;
+		HShader mShaderPicking[3];
+		HShader mShaderPickingAlpha[3];
+		HShader mShaderGizmoSolid;
+		HShader mShaderGizmoWire;
+		HShader mShaderGizmoLine;
+		HShader mShaderGizmoIcon;
+		HShader mShaderGizmoPicking;
+		HShader mShaderGizmoAlphaPicking;
+		HShader mShaderGizmoText;
+		HShader mShaderHandleSolid;
+		HShader mShaderHandleLine;
+		HShader mShaderHandleClearAlpha;
+		HShader mShaderSelection;
+
+		HFont mDefaultFont;
+		HGUISkin mSkin;
+
+		ResourceManifestPtr mResourceManifest;
+
+		static const char* ShaderFolder;
+		static const char* SkinFolder;
+		static const char* IconFolder;
+		static const char* ShaderIncludeFolder;
+
+		Path BuiltinDataFolder;
+		Path EditorSkinFolder;
+		Path EditorIconFolder;
+		Path EditorShaderFolder;
+		Path EditorShaderIncludeFolder;
+
+		Path BuiltinRawDataFolder;
+		Path EditorRawSkinFolder;
+		Path EditorRawShaderIncludeFolder;
+		Path EditorRawShaderFolder;
+
+		Path ResourceManifestPath;
+
+		static const WString DefaultFontFilename;
+		static const WString DefaultAAFontFilename;
+		static const UINT32 DefaultFontSize;
+		static const UINT32 TitleFontSize;
+
+		static const Color TextNormalColor;
+		static const Color TextActiveColor;
+
+		static const WString GUISkinFile;
+
+		static const WString FolderIconTex;
+		static const WString MeshIconTex;
+		static const WString TextureIconTex;
+		static const WString FontIconTex;
+		static const WString PlainTextIconTex;
+		static const WString ScriptCodeIconTex;
+		static const WString ShaderIconTex;
+		static const WString ShaderIncludeIconTex;
+		static const WString MaterialIconTex;
+		static const WString SpriteTextureIconTex;
+		static const WString PrefabIconTex;
+		static const WString GUISkinIconTex;
+		static const WString PhysicsMaterialIconTex;
+		static const WString PhysicsMeshIconTex;
+
+
+		static const WString WindowBackgroundTex;
+
+		static const WString WindowFrameNormal;
+		static const WString WindowFrameFocused;
+
+		static const WString TabBarBackgroundTex;
+		static const WString TitleBarBackgroundTex;
+
+		static const WString CloseButtonNormalTex;
+		static const WString CloseButtonHoverTex;
+		static const WString CloseButtonActiveTex;
+
+		static const WString MinButtonNormalTex;
+		static const WString MinButtonHoverTex;
+		static const WString MinButtonActiveTex;
+
+		static const WString MaxButtonNormalTex;
+		static const WString MaxButtonHoverTex;
+		static const WString MaxButtonActiveTex;
+
+		static const WString TabButtonNormalTex;
+		static const WString TabButtonFocusedTex;
+
+		static const WString ButtonNormalTex;
+		static const WString ButtonHoverTex;
+		static const WString ButtonActiveTex;
+
+		static const WString ButtonLeftNormalTex;
+		static const WString ButtonLeftHoverTex;
+		static const WString ButtonLeftActiveTex;
+
+		static const WString ButtonRightNormalTex;
+		static const WString ButtonRightHoverTex;
+		static const WString ButtonRightActiveTex;
+
+		static const WString ToggleNormalTex;
+		static const WString ToggleHoverTex;
+		static const WString ToggleNormalOnTex;
+		static const WString ToggleHoverOnTex;
+
+		static const WString ObjectDropBtnNormalTex;
+		static const WString ObjectDropBtnNormalOnTex;
+		static const WString ObjectClearBtnNormalTex;
+		static const WString ObjectClearBtnHoverTex;
+		static const WString ObjectClearBtnActiveTex;
+
+		static const WString SliderHBackgroundTex;
+		static const WString SliderHFillTex;
+		static const WString SliderVBackgroundTex;
+		static const WString SliderVFillTex;
+		static const WString SliderHandleNormalTex;
+		static const WString SliderHandleHoverTex;
+		static const WString SliderHandleActiveTex;
+
+		static const WString FoldoutOpenNormalTex;
+		static const WString FoldoutOpenHoverTex;
+		static const WString FoldoutOpenActiveTex;
+		static const WString FoldoutClosedNormalTex;
+		static const WString FoldoutClosedHoverTex;
+		static const WString FoldoutClosedActiveTex;
+
+		static const WString InputBoxNormalTex;
+		static const WString InputBoxHoverTex;
+		static const WString InputBoxFocusedTex;
+
+		static const WString ScrollBarUpNormalTex;
+		static const WString ScrollBarUpHoverTex;
+		static const WString ScrollBarUpActiveTex;
+
+		static const WString ScrollBarDownNormalTex;
+		static const WString ScrollBarDownHoverTex;
+		static const WString ScrollBarDownActiveTex;
+
+		static const WString ScrollBarLeftNormalTex;
+		static const WString ScrollBarLeftHoverTex;
+		static const WString ScrollBarLeftActiveTex;
+
+		static const WString ScrollBarRightNormalTex;
+		static const WString ScrollBarRightHoverTex;
+		static const WString ScrollBarRightActiveTex;
+
+		static const WString ScrollBarHandleHorzNormalTex;
+		static const WString ScrollBarHandleHorzHoverTex;
+		static const WString ScrollBarHandleHorzActiveTex;
+
+		static const WString ScrollBarHandleVertNormalTex;
+		static const WString ScrollBarHandleVertHoverTex;
+		static const WString ScrollBarHandleVertActiveTex;
+
+		static const WString ScrollBarHBgTex;
+		static const WString ScrollBarVBgTex;
+
+		static const WString DropDownBtnNormalTex;
+		static const WString DropDownBtnHoverTex;
+		static const WString DropDownBtnActiveTex;
+
+		static const WString DropDownBoxBgTex;
+		static const WString DropDownBoxSideBgTex;
+		static const WString DropDownBoxHandleTex;
+
+		static const WString DropDownBoxEntryNormalTex;
+		static const WString DropDownBoxEntryHoverTex;
+
+		static const WString DropDownBoxEntryToggleNormalTex;
+		static const WString DropDownBoxEntryToggleHoverTex;
+		static const WString DropDownBoxEntryToggleNormalOnTex;
+		static const WString DropDownBoxEntryToggleHoverOnTex;
+
+		static const WString DropDownBoxBtnUpNormalTex;
+		static const WString DropDownBoxBtnUpHoverTex;
+
+		static const WString DropDownBoxBtnDownNormalTex;
+		static const WString DropDownBoxBtnDownHoverTex;
+
+		static const WString DropDownBoxEntryExpNormalTex;
+		static const WString DropDownBoxEntryExpHoverTex;
+
+		static const WString DropDownSeparatorTex;
+
+		static const WString MenuBarBgTex;
+		static const WString MenuBarBansheeLogoTex;
+
+		static const WString MenuBarBtnNormalTex;
+		static const WString MenuBarBtnHoverTex;
+		static const WString MenuBarBtnActiveTex;
+
+		static const WString MenuBarLineNormalTex;
+		static const WString MenuBarLineActiveTex;
+
+		static const WString ToolBarBtnNormalTex;
+		static const WString ToolBarBtnHoverTex;
+		static const WString ToolBarBtnActiveTex;
+
+		static const WString ToolBarSeparatorTex;
+
+		static const WString DockSliderNormalTex;
+
+		static const WString TreeViewExpandButtonOffNormal;
+		static const WString TreeViewExpandButtonOffHover;
+		static const WString TreeViewExpandButtonOnNormal;
+		static const WString TreeViewExpandButtonOnHover;
+
+		static const WString TreeViewHighlightBackground;
+		static const WString TreeViewEditBox;
+
+		static const WString TreeViewElementHighlight;
+		static const WString TreeViewElementSepHighlight;
+
+		static const WString ColorPickerSliderHorzHandleTex;
+		static const WString ColorPickerSliderVertHandleTex;
+		static const WString ColorPickerSlider2DHandleTex;
+
+		static const WString ProgressBarFillTex;
+		static const WString ProgressBarBgTex;
+
+		static const WString SelectionAreaTex;
+		static const WString SelectionBgTex;
+
+		static const WString TextureDropTex;
+		static const WString TextureDropOnTex;
+
+		static const WString XButtonNormalTex;
+		static const WString XButtonHoverTex;
+		static const WString XButtonActiveTex;
+
+		static const WString StatusBarBgTex;
+		static const WString ScrollAreaBgTex;
+
+		static const WString InspectorTitleBgTex;
+		static const WString InspectorContentBgTex;
+		static const WString InspectorContentBgAlternateTex;
+
+		static const WString ShaderDockOverlayFile;
+		static const WString ShaderSceneGridFile;
+		static const WString ShaderPickingCullNoneFile;
+		static const WString ShaderPickingCullCWFile;
+		static const WString ShaderPickingCullCCWFile;
+		static const WString ShaderPickingAlphaCullNoneFile;
+		static const WString ShaderPickingAlphaCullCWFile;
+		static const WString ShaderPickingAlphaCullCCWFile;
+		static const WString ShaderLineGizmoFile;
+		static const WString ShaderSolidGizmoFile;
+		static const WString ShaderWireGizmoFile;
+		static const WString ShaderLineHandleFile;
+		static const WString ShaderSolidHandleFile;
+		static const WString ShaderHandleClearAlphaFile;
+		static const WString ShaderIconGizmoFile;
+		static const WString ShaderGizmoPickingFile;
+		static const WString ShaderGizmoPickingAlphaFile;
+		static const WString ShaderTextGizmoFile;
+		static const WString ShaderSelectionFile;
+
+		static const WString EmptyShaderCodeFile;
+		static const WString EmptyCSScriptCodeFile;
+	};
+
+	/** @} */
 }

+ 580 - 563
Source/BansheeEditor/Include/BsGizmoManager.h

@@ -1,564 +1,581 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsEditorPrerequisites.h"
-#include "BsModule.h"
-#include "BsColor.h"
-#include "BsVector2I.h"
-#include "BsMatrix4.h"
-#include "BsGpuParam.h"
-#include "BsDrawHelper.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup Scene-Editor
-	 *  @{
-	 */
-
-	class GizmoManagerCore;
-
-	/**
-	 * Handles the rendering and picking of gizmo elements. Gizmos are icons and 3D objects usually rendered in scene view
-	 * for various visualization purposes (e.g. a Camera component will have a gizmo that draws a Camera icon since
-	 * otherwise it has no visual representation). Aside from being rendered, gizmos can also be selected by the user as if
-	 * they were normal scene elements.
-	 */
-	class BS_ED_EXPORT GizmoManager : public Module<GizmoManager>
-	{
-	public:
-		GizmoManager();
-		~GizmoManager();
-
-		/**
-		 * Starts gizmo creation. All further call will be referencing this gizmo. Must be followed by a matching 
-		 * endGizmo().
-		 *
-		 * @param	gizmoParent	Scene object this gizmo is attached to. Selecting the gizmo will select this scene object.
-		 */
-		void startGizmo(const HSceneObject& gizmoParent);
-
-		/**	Ends gizmo creation. Must be called after a matching startGizmo(). */
-		void endGizmo();
-
-		/**	Changes the color of any further gizmo draw calls. */
-		void setColor(const Color& color);
-
-		/**	Changes the transform that will be applied to meshes of any further gizmo draw calls.  */
-		void setTransform(const Matrix4& transform);
-
-		/**
-		 * If pickable is set to true, gizmo can be selected by the user, otherwise it will be drawn but cannot be
-		 * interacted with.
-		 *
-		 * @note	Must be called between startGizmo/endGizmo calls.
-		 */
-		void setPickable(bool pickable) { mPickable = pickable; }
-
-		/**	Returns the currently set gizmo color. */
-		Color getColor() const { return mColor; }
-
-		/**	Returns the currently set gizmo transform. */
-		Matrix4 getTransform() const { return mTransform; }
-
-		/**
-		 * Draws an axis aligned cuboid.
-		 *
-		 * @param[in]	position	Center of the cuboid.
-		 * @param[in]	extents		Radius of the cuboid in each axis.
-		 *
-		 * @note	Must be called between startGizmo/endGizmo calls.
-		 */
-		void drawCube(const Vector3& position, const Vector3& extents);
-
-		/**
-		 * Draws a sphere.
-		 *
-		 * @note	Must be called between startGizmo/endGizmo calls.
-		 */
-		void drawSphere(const Vector3& position, float radius);
-
-		/**
-		 * Draws a wireframe axis aligned cuboid.
-		 *
-		 * @param[in]	position	Center of the cuboid.
-		 * @param[in]	extents		Radius of the cuboid in each axis.
-		 *
-		 * @note	Must be called between startGizmo/endGizmo calls.
-		 */
-		void drawWireCube(const Vector3& position, const Vector3& extents);
-
-		/**
-		 * Draws a wireframe sphere represented by three discs.
-		 *
-		 * @note	Must be called between startGizmo/endGizmo calls.
-		 */
-		void drawWireSphere(const Vector3& position, float radius);
-
-		/**
-		 * Draws a wireframe capsule.
-		 *
-		 * @param[in]	position	World coordinates of the center of the capsule.
-		 * @param[in]	height		Distance between the centers of the capsule's hemispheres.
-		 * @param[in]	radius		Distance of each point from the capsule's center-line.
-		 */
-		void drawWireCapsule(const Vector3& position, float height, float radius);
-
-		/**
-		 * Draws a line between two points.
-		 *
-		 * @note	Must be called between startGizmo/endGizmo calls.
-		 */
-		void drawLine(const Vector3& start, const Vector3& end);
-
-		/**
-		 * Draws a list of lines. Provided array must contain pairs of the line start point followed by an end point.
-		 *
-		 * @note	Must be called between startGizmo/endGizmo calls.
-		 */
-		void drawLineList(const Vector<Vector3>& linePoints);
-
-		/**
-		 * Draws a wireframe disc.
-		 *
-		 * @param[in]	position	Center of the disc.
-		 * @param[in]	normal		Orientation of the disc, pointing in the direction the disc is visible in.
-		 * @param[in]	radius		Radius of the disc.
-		 */
-		void drawWireDisc(const Vector3& position, const Vector3& normal, float radius);
-
-		/**
-		 * Draws a wireframe arc.
-		 *
-		 * @param[in]	position	Center of the arc.
-		 * @param[in]	normal		Orientation of the arc, pointing in the direction the arc is visible in.
-		 * @param[in]	radius		Radius of the arc.
-		 * @param[in]	startAngle	Angle at which to start the arc.
-		 * @param[in]	amountAngle	Length of the arc.
-		 */
-		void drawWireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle);
-
-		/**
-		 * Draws a wireframe frustum.
-		 *
-		 * @param[in]	position	Origin of the frustum, or the eye point.
-		 * @param[in]	aspect		Ratio of frustum width over frustum height.
-		 * @param[in]	FOV			Horizontal field of view in degrees.
-		 * @param[in]	near		Distance to the near frustum plane.
-		 * @param[in]	far			Distance to the far frustum plane.
-		 *
-		 * @note	Must be called between startGizmo/endGizmo calls.
-		 */
-		void drawFrustum(const Vector3& position, float aspect, Degree FOV, float near, float far);
-
-		/**
-		 * Draws an icon that always faces the camera.
-		 *
-		 * @param[in]	position	Position of the center of the icon.
-		 * @param[in]	image		Sprite image for the icon to draw.
-		 * @param[in]	fixedScale	If true then the icon will remain the same size regardless of the distance from camera.
-		 *
-		 * @note	Must be called between startGizmo/endGizmo calls.
-		 */
-		void drawIcon(Vector3 position, HSpriteTexture image, bool fixedScale);
-
-		/**
-		 * Draws a mesh representing 2D text with the specified properties. 
-		 *
-		 * @param[in]	position	Position to render the text at. Text will be centered around this point.
-		 * @param[in]	text		Text to draw.
-		 * @param[in]	font		Font to use for rendering the text's characters.
-		 * @param[in]	fontSize	Size of the characters, in points.
-		 */
-		void drawText(const Vector3& position, const WString& text, const HFont& font, UINT32 fontSize = 16);
-
-		/**
-		 * Clears all gizmo data, but doesn't update the meshes or the render data. (Calling update would create empty
-		 * meshes, but before calling update gizmos will still be drawn).
-		 */
-		void clearGizmos();
-
-		/**
-		 * Clears gizmo render data like meshes, but doesn't clear the original gizmo data (Calling update would just
-		 * recreate the render data).
-		 */
-		void clearRenderData();
-
-		/**
-		 * Returns a scene object that was attached to a specific gizmo.
-		 *
-		 * @param[in]	gizmoIdx	Index of the gizmo to look for.
-		 */
-		HSceneObject getSceneObject(UINT32 gizmoIdx);
-
-		/** @cond INTERNAL */
-
-		/**
-		 * Updates all the gizmo meshes to reflect all draw calls submitted since clearGizmos().
-		 *
-		 * @note	Internal method.
-		 */
-		void update(const CameraPtr& camera);
-
-		/**
-		 * @brief	Queues all gizmos to be rendered for picking. Each gizmo is draw with a separate
-		 *			color so we can identify them later.
-		 *
-		 * @param	camera				Camera to draw the gizmos on.
-		 * @param	idxToColorCallback	Callback that assigns a unique color to each gizmo index.
-		 *
-		 * @note	Internal method.
-		 */
-		void renderForPicking(const CameraPtr& camera, std::function<Color(UINT32)> idxToColorCallback);
-
-		/** @endcond */
-
-	private:
-		friend class GizmoManagerCore;
-
-		/**	Supported types of gizmo materials (i.e. shaders) */
-		enum class GizmoMaterial
-		{
-			Solid, Wire, Picking, PickingAlpha, Text
-		};
-
-		/**	Common data shared by all gizmo types. */
-		struct CommonData
-		{
-			UINT32 idx;
-			Color color;
-			Matrix4 transform;
-			HSceneObject sceneObject;
-			bool pickable;
-		};
-
-		/**	Data required for rendering a cuboid gizmo. */
-		struct CubeData : CommonData
-		{
-			Vector3 position;
-			Vector3 extents;
-		};
-
-		/**	Data required for rendering a sphere gizmo. */
-		struct SphereData : CommonData
-		{
-			Vector3 position;
-			float radius;
-		};
-
-		/**	Data required for rendering a line gizmo. */
-		struct LineData : CommonData
-		{
-			Vector3 start;
-			Vector3 end;
-		};
-
-		/**	Data required for rendering a list of lines. */
-		struct LineListData : CommonData
-		{
-			Vector<Vector3> linePoints;
-		};
-
-		/**	Data required for rendering a wireframe disc gizmo. */
-		struct WireDiscData : CommonData
-		{
-			Vector3 position;
-			Vector3 normal;
-			float radius;
-		};
-
-		/**	Data required for rendering a wireframe arc gizmo. */
-		struct WireArcData : CommonData
-		{
-			Vector3 position;
-			Vector3 normal;
-			float radius;
-			Degree startAngle;
-			Degree amountAngle;
-		};
-
-		/**	Data required for rendering a frustum gizmo. */
-		struct FrustumData : CommonData
-		{
-			Vector3 position;
-			float aspect;
-			Degree FOV;
-			float near;
-			float far;
-		};
-
-		/**	Data required for rendering an icon gizmo. */
-		struct IconData : CommonData
-		{
-			Vector3 position;
-			bool fixedScale;
-			HSpriteTexture texture;
-		};
-
-		/**	Data required for rendering text. */
-		struct TextData : CommonData
-		{
-			Vector3 position;
-			WString text;
-			HFont font;
-			UINT32 fontSize;
-		};
-
-		/**	Stores how many icons use a specific texture. */
-		struct IconRenderData
-		{
-			UINT32 count;
-			SPtr<TextureCore> texture;
-		};
-
-		/**	Data used for initializing the core thread equivalent of the gizmo manager. */
-		struct CoreInitData
-		{
-			SPtr<MaterialCore> solidMat;
-			SPtr<MaterialCore> wireMat;
-			SPtr<MaterialCore> iconMat;
-			SPtr<MaterialCore> textMat;
-			SPtr<MaterialCore> pickingMat;
-			SPtr<MaterialCore> alphaPickingMat;
-		};
-
-		typedef Vector<IconRenderData> IconRenderDataVec;
-		typedef std::shared_ptr<IconRenderDataVec> IconRenderDataVecPtr;
-
-		/**
-		 * Builds a brand new mesh that can be used for rendering all icon gizmos.
-		 *
-		 * @param[in]	camera		Camera the mesh will be rendered to.
-		 * @param[in]	iconData	A list of all icons and their properties.
-		 * @param[in]	forPicking	Whether the icons will be rendered normally, or with a special material for picking.
-		 * @param[in]	renderData	Output data that outlines the structure of the returned mesh. It tells us which portions
-		 *							of the mesh use which icon texture.
-		 *
-		 * @return					A mesh containing all of the visible icons. Mesh is allocated using the icon mesh heap
-		 *							and should be deallocated manually.
-		 */
-		TransientMeshPtr buildIconMesh(const CameraPtr& camera, const Vector<IconData>& iconData, bool forPicking, IconRenderDataVecPtr& renderData);
-
-		/**	Resizes the icon width/height so it is always scaled to optimal size (with preserved aspect). */
-		void limitIconSize(UINT32& width, UINT32& height);
-
-		/**
-		 * Calculates colors for an icon based on its position in the camera. e.g. icons too close to too far might be faded.
-		 *
-		 * @param[in]	tint		Primary tint for the icon.
-		 * @param[in]	camera		Camera in which the icon will be rendered in.
-		 * @param[in]	iconHeight	Height of the icon in pixels.
-		 * @param[in]	fixedScale	Whether the icon size changes depending on distance from the camera.
-		 * @param[in]	normalColor	Normal color of the icon.
-		 * @param[in]	fadedColor	Faded color to be used when icon is occluded by geometry.
-		 */
-		void calculateIconColors(const Color& tint, const CameraPtr& camera, UINT32 iconHeight, bool fixedScale,
-			Color& normalColor, Color& fadedColor);
-
-		/**	Initializes the core thread version of the gizmo manager. */
-		void initializeCore(const CoreInitData& initData);
-
-		/**	Destroys the core thread version of the gizmo manager. */
-		void destroyCore(GizmoManagerCore* core);
-
-		static const UINT32 VERTEX_BUFFER_GROWTH;
-		static const UINT32 INDEX_BUFFER_GROWTH;
-		static const UINT32 SPHERE_QUALITY;
-		static const UINT32 WIRE_SPHERE_QUALITY;
-		static const float MAX_ICON_RANGE;
-		static const UINT32 OPTIMAL_ICON_SIZE;
-		static const float ICON_TEXEL_WORLD_SIZE;
-
-		typedef Set<IconData, std::function<bool(const IconData&, const IconData&)>> IconSet;
-
-		Color mColor;
-		Matrix4 mTransform;
-		HSceneObject mActiveSO;
-		bool mPickable;
-		UINT32 mCurrentIdx;
-		bool mTransformDirty;
-		bool mColorDirty;
-
-		DrawHelper* mDrawHelper;
-		DrawHelper* mPickingDrawHelper;
-
-		Vector<CubeData> mSolidCubeData;
-		Vector<CubeData> mWireCubeData;
-		Vector<SphereData> mSolidSphereData;
-		Vector<SphereData> mWireSphereData;
-		Vector<LineData> mLineData;
-		Vector<LineListData> mLineListData;
-		Vector<WireDiscData> mWireDiscData;
-		Vector<WireArcData> mWireArcData;
-		Vector<FrustumData> mFrustumData;
-		Vector<IconData> mIconData;
-		Vector<TextData> mTextData;
-		Map<UINT32, HSceneObject> mIdxToSceneObjectMap;
-
-		Vector<DrawHelper::ShapeMeshData> mActiveMeshes;
-
-		MeshHeapPtr mIconMeshHeap;
-		TransientMeshPtr mIconMesh;
-
-		std::atomic<GizmoManagerCore*> mCore;
-
-		// Immutable
-		VertexDataDescPtr mIconVertexDesc;
-
-		// Transient
-		struct SortedIconData
-		{
-			float distance;
-			Vector2I screenPosition;
-			UINT32 iconIdx;
-		};
-
-		Vector<SortedIconData> mSortedIconData;
-	};
-
-	/** @cond INTERNAL */
-
-	/**
-	 * Core thread version of the gizmo manager that handles most of the rendering of meshes provided by the gizmo manager.
-	 */
-	class GizmoManagerCore
-	{
-		friend class GizmoManager;
-
-		/**	Solid gizmo material and parameter handles. */
-		struct SolidMaterialData
-		{
-			SPtr<MaterialCore> mat;
-			GpuParamMat4Core mViewProj;
-			GpuParamVec4Core mViewDir;
-		};
-
-		/**	Wire gizmo material and parameter handles. */
-		struct WireMaterialData
-		{
-			SPtr<MaterialCore> mat;
-			GpuParamMat4Core mViewProj;
-		};
-
-		/**	Icon gizmo material and parameter handles. */
-		struct IconMaterialData
-		{
-			SPtr<MaterialCore> mat;
-			SPtr<GpuParamsCore> mFragParams[2];
-			GpuParamMat4Core mViewProj[2];
-			GpuParamTextureCore mTexture[2];
-		};
-
-		/**	Text gizmo material and parameter handles. */
-		struct TextMaterialData
-		{
-			SPtr<MaterialCore> mat;
-			GpuParamMat4Core mViewProj;
-			GpuParamTextureCore mTexture;
-		};
-
-		/**	Gizmo material and parameter handles used for picking. */
-		struct PickingMaterialData
-		{
-			SPtr<MaterialCore> mat;
-			GpuParamMat4Core mViewProj;
-		};
-
-		/**
-		 * Gizmo material and parameter handles used for picking, with blending support (generally used for icon picking).
-		 */
-		struct AlphaPickingMaterialData
-		{
-			SPtr<MaterialCore> mat;
-			SPtr<GpuParamsCore> mFragParams;
-			GpuParamMat4Core mViewProj;
-			GpuParamTextureCore mTexture;
-		};
-
-		/** Type of mesh that can be drawn. */
-		enum class MeshType
-		{
-			Solid, Wire, Text
-		};
-
-		/** Data about a mesh rendered by the draw manager. */
-		struct MeshData
-		{
-			MeshData(const SPtr<MeshCoreBase>& mesh, SPtr<TextureCore> texture, MeshType type)
-				:mesh(mesh), texture(texture), type(type)
-			{ }
-
-			SPtr<MeshCoreBase> mesh;
-			SPtr<TextureCore> texture;
-			MeshType type;
-		};
-
-		struct PrivatelyConstuct { };
-
-	public:
-		GizmoManagerCore(const PrivatelyConstuct& dummy);
-		~GizmoManagerCore();
-
-	private:
-		/**	Initializes the core gizmo manager. Must be called right after creation. */
-		void initialize(const GizmoManager::CoreInitData& initData);
-
-		/**	Renders all gizmos in the parent camera. */
-		void render();
-
-		/**
-		 * Renders a non-icon gizmo mesh using the provided parameters.
-		 *
-		 * @param[in]	viewMatrix	View matrix of the camera we are rendering with.
-		 * @param[in]	projMatrix	Projection matrix of the camera we are rendering with.
-		 * @param[in]	viewDir		View direction of the camera we are rendering with.
-		 * @param[in]	mesh		Mesh to render. This is normally the solid or wireframe gizmo mesh.
-		 * @param[in]	texture		Texture to apply to the material, if the material supports a texture.
-		 * @param[in]	material	Material to use for rendering. This is normally the solid, wireframe or picking material.
-		 */
-		void renderGizmos(const Matrix4& viewMatrix, const Matrix4& projMatrix, const Vector3& viewDir, 
-			const SPtr<MeshCoreBase>& mesh, const SPtr<TextureCore>& texture, GizmoManager::GizmoMaterial material);
-
-		/**
-		 * Renders the icon gizmo mesh using the provided parameters.
-		 *
-		 * @param[in]	screenArea			Area of the viewport to render the gizmos in, in pixels.
-		 * @param[in]	mesh				Mesh containing the icons.
-		 * @param[in]	renderData			Icon render data outlining which parts of the icon mesh use which textures.
-		 * @param[in]	usePickingMaterial	Should the icons be rendered normally or for picking.
-		 */
-		void renderIconGizmos(Rect2I screenArea, SPtr<MeshCoreBase> mesh, GizmoManager::IconRenderDataVecPtr renderData, bool usePickingMaterial);
-
-		/**
-		 * Updates the internal data that is used for rendering. Normally you would call this after updating the camera or
-		 * meshes on the sim thread.
-		 *
-		 * @param[in]	camera			Sets the camera all rendering will be performed to.
-		 * @param[in]	meshes			Meshes to render.
-		 * @param[in]	iconMesh		Mesh containing icon meshes.
-		 * @param[in]	iconRenderData	Icon render data outlining which parts of the icon mesh use which textures.
-		 */
-		void updateData(const SPtr<CameraCore>& camera, const Vector<MeshData>& meshes, const SPtr<MeshCoreBase>& iconMesh, 
-			const GizmoManager::IconRenderDataVecPtr& iconRenderData);
-
-		static const float PICKING_ALPHA_CUTOFF;
-
-		SPtr<CameraCore> mCamera;
-
-		Vector<MeshData> mMeshes;
-		SPtr<MeshCoreBase> mIconMesh;
-		GizmoManager::IconRenderDataVecPtr mIconRenderData;
-
-		// Immutable
-		SolidMaterialData mSolidMaterial;
-		WireMaterialData mWireMaterial;
-		IconMaterialData mIconMaterial;
-		TextMaterialData mTextMaterial;
-
-		PickingMaterialData mPickingMaterial;
-		AlphaPickingMaterialData mAlphaPickingMaterial;
-	};
-
-	/** @endcond */
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "BsModule.h"
+#include "BsColor.h"
+#include "BsVector2I.h"
+#include "BsMatrix4.h"
+#include "BsGpuParam.h"
+#include "BsDrawHelper.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Scene-Editor
+	 *  @{
+	 */
+
+	class GizmoManagerCore;
+
+	/**
+	 * Handles the rendering and picking of gizmo elements. Gizmos are icons and 3D objects usually rendered in scene view
+	 * for various visualization purposes (e.g. a Camera component will have a gizmo that draws a Camera icon since
+	 * otherwise it has no visual representation). Aside from being rendered, gizmos can also be selected by the user as if
+	 * they were normal scene elements.
+	 */
+	class BS_ED_EXPORT GizmoManager : public Module<GizmoManager>
+	{
+	public:
+		GizmoManager();
+		~GizmoManager();
+
+		/**
+		 * Starts gizmo creation. All further call will be referencing this gizmo. Must be followed by a matching 
+		 * endGizmo().
+		 *
+		 * @param	gizmoParent	Scene object this gizmo is attached to. Selecting the gizmo will select this scene object.
+		 */
+		void startGizmo(const HSceneObject& gizmoParent);
+
+		/**	Ends gizmo creation. Must be called after a matching startGizmo(). */
+		void endGizmo();
+
+		/**	Changes the color of any further gizmo draw calls. */
+		void setColor(const Color& color);
+
+		/**	Changes the transform that will be applied to meshes of any further gizmo draw calls.  */
+		void setTransform(const Matrix4& transform);
+
+		/**
+		 * If pickable is set to true, gizmo can be selected by the user, otherwise it will be drawn but cannot be
+		 * interacted with.
+		 *
+		 * @note	Must be called between startGizmo/endGizmo calls.
+		 */
+		void setPickable(bool pickable) { mPickable = pickable; }
+
+		/**	Returns the currently set gizmo color. */
+		Color getColor() const { return mColor; }
+
+		/**	Returns the currently set gizmo transform. */
+		Matrix4 getTransform() const { return mTransform; }
+
+		/**
+		 * Draws an axis aligned cuboid.
+		 *
+		 * @param[in]	position	Center of the cuboid.
+		 * @param[in]	extents		Radius of the cuboid in each axis.
+		 *
+		 * @note	Must be called between startGizmo/endGizmo calls.
+		 */
+		void drawCube(const Vector3& position, const Vector3& extents);
+
+		/**
+		 * Draws a sphere.
+		 *
+		 * @note	Must be called between startGizmo/endGizmo calls.
+		 */
+		void drawSphere(const Vector3& position, float radius);
+
+		/**
+		 * Draws a wireframe axis aligned cuboid.
+		 *
+		 * @param[in]	position	Center of the cuboid.
+		 * @param[in]	extents		Radius of the cuboid in each axis.
+		 *
+		 * @note	Must be called between startGizmo/endGizmo calls.
+		 */
+		void drawWireCube(const Vector3& position, const Vector3& extents);
+
+		/**
+		 * Draws a wireframe sphere represented by three discs.
+		 *
+		 * @note	Must be called between startGizmo/endGizmo calls.
+		 */
+		void drawWireSphere(const Vector3& position, float radius);
+
+		/**
+		 * Draws a wireframe capsule.
+		 *
+		 * @param[in]	position	World coordinates of the center of the capsule.
+		 * @param[in]	height		Distance between the centers of the capsule's hemispheres.
+		 * @param[in]	radius		Distance of each point from the capsule's center-line.
+		 */
+		void drawWireCapsule(const Vector3& position, float height, float radius);
+
+		/**
+		 * Draws a line between two points.
+		 *
+		 * @note	Must be called between startGizmo/endGizmo calls.
+		 */
+		void drawLine(const Vector3& start, const Vector3& end);
+
+		/**
+		 * Draws a list of lines. Provided array must contain pairs of the line start point followed by an end point.
+		 *
+		 * @note	Must be called between startGizmo/endGizmo calls.
+		 */
+		void drawLineList(const Vector<Vector3>& linePoints);
+
+		/**
+		 * Draws a wireframe disc.
+		 *
+		 * @param[in]	position	Center of the disc.
+		 * @param[in]	normal		Orientation of the disc, pointing in the direction the disc is visible in.
+		 * @param[in]	radius		Radius of the disc.
+		 */
+		void drawWireDisc(const Vector3& position, const Vector3& normal, float radius);
+
+		/**
+		 * Draws a wireframe arc.
+		 *
+		 * @param[in]	position	Center of the arc.
+		 * @param[in]	normal		Orientation of the arc, pointing in the direction the arc is visible in.
+		 * @param[in]	radius		Radius of the arc.
+		 * @param[in]	startAngle	Angle at which to start the arc.
+		 * @param[in]	amountAngle	Length of the arc.
+		 */
+		void drawWireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle);
+
+		/** 
+		 * Draws a wireframe mesh.
+		 *
+		 * @param[in]	meshData	Object containing mesh vertices and indices. Vertices must be Vertex3 and indices 
+		 *							32-bit.
+		 */
+		void drawWireMesh(const MeshDataPtr& meshData);
+
+		/**
+		 * Draws a wireframe frustum.
+		 *
+		 * @param[in]	position	Origin of the frustum, or the eye point.
+		 * @param[in]	aspect		Ratio of frustum width over frustum height.
+		 * @param[in]	FOV			Horizontal field of view in degrees.
+		 * @param[in]	near		Distance to the near frustum plane.
+		 * @param[in]	far			Distance to the far frustum plane.
+		 *
+		 * @note	Must be called between startGizmo/endGizmo calls.
+		 */
+		void drawFrustum(const Vector3& position, float aspect, Degree FOV, float near, float far);
+
+		/**
+		 * Draws an icon that always faces the camera.
+		 *
+		 * @param[in]	position	Position of the center of the icon.
+		 * @param[in]	image		Sprite image for the icon to draw.
+		 * @param[in]	fixedScale	If true then the icon will remain the same size regardless of the distance from camera.
+		 *
+		 * @note	Must be called between startGizmo/endGizmo calls.
+		 */
+		void drawIcon(Vector3 position, HSpriteTexture image, bool fixedScale);
+
+		/**
+		 * Draws a mesh representing 2D text with the specified properties. 
+		 *
+		 * @param[in]	position	Position to render the text at. Text will be centered around this point.
+		 * @param[in]	text		Text to draw.
+		 * @param[in]	font		Font to use for rendering the text's characters.
+		 * @param[in]	fontSize	Size of the characters, in points.
+		 */
+		void drawText(const Vector3& position, const WString& text, const HFont& font, UINT32 fontSize = 16);
+
+		/**
+		 * Clears all gizmo data, but doesn't update the meshes or the render data. (Calling update would create empty
+		 * meshes, but before calling update gizmos will still be drawn).
+		 */
+		void clearGizmos();
+
+		/**
+		 * Clears gizmo render data like meshes, but doesn't clear the original gizmo data (Calling update would just
+		 * recreate the render data).
+		 */
+		void clearRenderData();
+
+		/**
+		 * Returns a scene object that was attached to a specific gizmo.
+		 *
+		 * @param[in]	gizmoIdx	Index of the gizmo to look for.
+		 */
+		HSceneObject getSceneObject(UINT32 gizmoIdx);
+
+		/** @cond INTERNAL */
+
+		/**
+		 * Updates all the gizmo meshes to reflect all draw calls submitted since clearGizmos().
+		 *
+		 * @note	Internal method.
+		 */
+		void update(const CameraPtr& camera);
+
+		/**
+		 * @brief	Queues all gizmos to be rendered for picking. Each gizmo is draw with a separate
+		 *			color so we can identify them later.
+		 *
+		 * @param	camera				Camera to draw the gizmos on.
+		 * @param	idxToColorCallback	Callback that assigns a unique color to each gizmo index.
+		 *
+		 * @note	Internal method.
+		 */
+		void renderForPicking(const CameraPtr& camera, std::function<Color(UINT32)> idxToColorCallback);
+
+		/** @endcond */
+
+	private:
+		friend class GizmoManagerCore;
+
+		/**	Supported types of gizmo materials (i.e. shaders) */
+		enum class GizmoMaterial
+		{
+			Solid, Wire, Line, Picking, PickingAlpha, Text
+		};
+
+		/**	Common data shared by all gizmo types. */
+		struct CommonData
+		{
+			UINT32 idx;
+			Color color;
+			Matrix4 transform;
+			HSceneObject sceneObject;
+			bool pickable;
+		};
+
+		/**	Data required for rendering a cuboid gizmo. */
+		struct CubeData : CommonData
+		{
+			Vector3 position;
+			Vector3 extents;
+		};
+
+		/**	Data required for rendering a sphere gizmo. */
+		struct SphereData : CommonData
+		{
+			Vector3 position;
+			float radius;
+		};
+
+		/**	Data required for rendering a line gizmo. */
+		struct LineData : CommonData
+		{
+			Vector3 start;
+			Vector3 end;
+		};
+
+		/**	Data required for rendering a list of lines. */
+		struct LineListData : CommonData
+		{
+			Vector<Vector3> linePoints;
+		};
+
+		/**	Data required for rendering a wireframe disc gizmo. */
+		struct WireDiscData : CommonData
+		{
+			Vector3 position;
+			Vector3 normal;
+			float radius;
+		};
+
+		/**	Data required for rendering a wireframe arc gizmo. */
+		struct WireArcData : CommonData
+		{
+			Vector3 position;
+			Vector3 normal;
+			float radius;
+			Degree startAngle;
+			Degree amountAngle;
+		};
+
+		/**	Data required for rendering a wireframe mesh gizmo. */
+		struct WireMeshData : CommonData
+		{
+			MeshDataPtr meshData;
+		};
+
+		/**	Data required for rendering a frustum gizmo. */
+		struct FrustumData : CommonData
+		{
+			Vector3 position;
+			float aspect;
+			Degree FOV;
+			float near;
+			float far;
+		};
+
+		/**	Data required for rendering an icon gizmo. */
+		struct IconData : CommonData
+		{
+			Vector3 position;
+			bool fixedScale;
+			HSpriteTexture texture;
+		};
+
+		/**	Data required for rendering text. */
+		struct TextData : CommonData
+		{
+			Vector3 position;
+			WString text;
+			HFont font;
+			UINT32 fontSize;
+		};
+
+		/**	Stores how many icons use a specific texture. */
+		struct IconRenderData
+		{
+			UINT32 count;
+			SPtr<TextureCore> texture;
+		};
+
+		/**	Data used for initializing the core thread equivalent of the gizmo manager. */
+		struct CoreInitData
+		{
+			SPtr<MaterialCore> solidMat;
+			SPtr<MaterialCore> wireMat;
+			SPtr<MaterialCore> lineMat;
+			SPtr<MaterialCore> iconMat;
+			SPtr<MaterialCore> textMat;
+			SPtr<MaterialCore> pickingMat;
+			SPtr<MaterialCore> alphaPickingMat;
+		};
+
+		typedef Vector<IconRenderData> IconRenderDataVec;
+		typedef std::shared_ptr<IconRenderDataVec> IconRenderDataVecPtr;
+
+		/**
+		 * Builds a brand new mesh that can be used for rendering all icon gizmos.
+		 *
+		 * @param[in]	camera		Camera the mesh will be rendered to.
+		 * @param[in]	iconData	A list of all icons and their properties.
+		 * @param[in]	forPicking	Whether the icons will be rendered normally, or with a special material for picking.
+		 * @param[in]	renderData	Output data that outlines the structure of the returned mesh. It tells us which portions
+		 *							of the mesh use which icon texture.
+		 *
+		 * @return					A mesh containing all of the visible icons. Mesh is allocated using the icon mesh heap
+		 *							and should be deallocated manually.
+		 */
+		TransientMeshPtr buildIconMesh(const CameraPtr& camera, const Vector<IconData>& iconData, bool forPicking, IconRenderDataVecPtr& renderData);
+
+		/**	Resizes the icon width/height so it is always scaled to optimal size (with preserved aspect). */
+		void limitIconSize(UINT32& width, UINT32& height);
+
+		/**
+		 * Calculates colors for an icon based on its position in the camera. e.g. icons too close to too far might be faded.
+		 *
+		 * @param[in]	tint		Primary tint for the icon.
+		 * @param[in]	camera		Camera in which the icon will be rendered in.
+		 * @param[in]	iconHeight	Height of the icon in pixels.
+		 * @param[in]	fixedScale	Whether the icon size changes depending on distance from the camera.
+		 * @param[in]	normalColor	Normal color of the icon.
+		 * @param[in]	fadedColor	Faded color to be used when icon is occluded by geometry.
+		 */
+		void calculateIconColors(const Color& tint, const CameraPtr& camera, UINT32 iconHeight, bool fixedScale,
+			Color& normalColor, Color& fadedColor);
+
+		/**	Initializes the core thread version of the gizmo manager. */
+		void initializeCore(const CoreInitData& initData);
+
+		/**	Destroys the core thread version of the gizmo manager. */
+		void destroyCore(GizmoManagerCore* core);
+
+		static const UINT32 VERTEX_BUFFER_GROWTH;
+		static const UINT32 INDEX_BUFFER_GROWTH;
+		static const UINT32 SPHERE_QUALITY;
+		static const UINT32 WIRE_SPHERE_QUALITY;
+		static const float MAX_ICON_RANGE;
+		static const UINT32 OPTIMAL_ICON_SIZE;
+		static const float ICON_TEXEL_WORLD_SIZE;
+
+		typedef Set<IconData, std::function<bool(const IconData&, const IconData&)>> IconSet;
+
+		Color mColor;
+		Matrix4 mTransform;
+		HSceneObject mActiveSO;
+		bool mPickable;
+		UINT32 mCurrentIdx;
+		bool mTransformDirty;
+		bool mColorDirty;
+
+		DrawHelper* mDrawHelper;
+		DrawHelper* mPickingDrawHelper;
+
+		Vector<CubeData> mSolidCubeData;
+		Vector<CubeData> mWireCubeData;
+		Vector<SphereData> mSolidSphereData;
+		Vector<SphereData> mWireSphereData;
+		Vector<LineData> mLineData;
+		Vector<LineListData> mLineListData;
+		Vector<WireDiscData> mWireDiscData;
+		Vector<WireArcData> mWireArcData;
+		Vector<WireMeshData> mWireMeshData;
+		Vector<FrustumData> mFrustumData;
+		Vector<IconData> mIconData;
+		Vector<TextData> mTextData;
+		Map<UINT32, HSceneObject> mIdxToSceneObjectMap;
+
+		Vector<DrawHelper::ShapeMeshData> mActiveMeshes;
+
+		MeshHeapPtr mIconMeshHeap;
+		TransientMeshPtr mIconMesh;
+
+		std::atomic<GizmoManagerCore*> mCore;
+
+		// Immutable
+		VertexDataDescPtr mIconVertexDesc;
+
+		// Transient
+		struct SortedIconData
+		{
+			float distance;
+			Vector2I screenPosition;
+			UINT32 iconIdx;
+		};
+
+		Vector<SortedIconData> mSortedIconData;
+	};
+
+	/** @cond INTERNAL */
+
+	/**
+	 * Core thread version of the gizmo manager that handles most of the rendering of meshes provided by the gizmo manager.
+	 */
+	class GizmoManagerCore
+	{
+		friend class GizmoManager;
+
+		/**	Solid gizmo material and parameter handles. */
+		struct SolidMaterialData
+		{
+			SPtr<MaterialCore> mat;
+			GpuParamMat4Core mViewProj;
+			GpuParamVec4Core mViewDir;
+		};
+
+		/**	Wire gizmo material and parameter handles. */
+		struct WireMaterialData
+		{
+			SPtr<MaterialCore> mat;
+			GpuParamMat4Core mViewProj;
+		};
+
+		/**	Icon gizmo material and parameter handles. */
+		struct IconMaterialData
+		{
+			SPtr<MaterialCore> mat;
+			SPtr<GpuParamsCore> mFragParams[2];
+			GpuParamMat4Core mViewProj[2];
+			GpuParamTextureCore mTexture[2];
+		};
+
+		/**	Text gizmo material and parameter handles. */
+		struct TextMaterialData
+		{
+			SPtr<MaterialCore> mat;
+			GpuParamMat4Core mViewProj;
+			GpuParamTextureCore mTexture;
+		};
+
+		/**	Gizmo material and parameter handles used for picking. */
+		struct PickingMaterialData
+		{
+			SPtr<MaterialCore> mat;
+			GpuParamMat4Core mViewProj;
+		};
+
+		/**
+		 * Gizmo material and parameter handles used for picking, with blending support (generally used for icon picking).
+		 */
+		struct AlphaPickingMaterialData
+		{
+			SPtr<MaterialCore> mat;
+			SPtr<GpuParamsCore> mFragParams;
+			GpuParamMat4Core mViewProj;
+			GpuParamTextureCore mTexture;
+		};
+
+		/** Type of mesh that can be drawn. */
+		enum class MeshType
+		{
+			Solid, Line, Wire, Text
+		};
+
+		/** Data about a mesh rendered by the draw manager. */
+		struct MeshData
+		{
+			MeshData(const SPtr<MeshCoreBase>& mesh, SPtr<TextureCore> texture, MeshType type)
+				:mesh(mesh), texture(texture), type(type)
+			{ }
+
+			SPtr<MeshCoreBase> mesh;
+			SPtr<TextureCore> texture;
+			MeshType type;
+		};
+
+		struct PrivatelyConstuct { };
+
+	public:
+		GizmoManagerCore(const PrivatelyConstuct& dummy);
+		~GizmoManagerCore();
+
+	private:
+		/**	Initializes the core gizmo manager. Must be called right after creation. */
+		void initialize(const GizmoManager::CoreInitData& initData);
+
+		/**	Renders all gizmos in the parent camera. */
+		void render();
+
+		/**
+		 * Renders a non-icon gizmo mesh using the provided parameters.
+		 *
+		 * @param[in]	viewMatrix	View matrix of the camera we are rendering with.
+		 * @param[in]	projMatrix	Projection matrix of the camera we are rendering with.
+		 * @param[in]	viewDir		View direction of the camera we are rendering with.
+		 * @param[in]	mesh		Mesh to render. This is normally the solid or wireframe gizmo mesh.
+		 * @param[in]	texture		Texture to apply to the material, if the material supports a texture.
+		 * @param[in]	material	Material to use for rendering. This is normally the solid, wireframe or picking material.
+		 */
+		void renderGizmos(const Matrix4& viewMatrix, const Matrix4& projMatrix, const Vector3& viewDir, 
+			const SPtr<MeshCoreBase>& mesh, const SPtr<TextureCore>& texture, GizmoManager::GizmoMaterial material);
+
+		/**
+		 * Renders the icon gizmo mesh using the provided parameters.
+		 *
+		 * @param[in]	screenArea			Area of the viewport to render the gizmos in, in pixels.
+		 * @param[in]	mesh				Mesh containing the icons.
+		 * @param[in]	renderData			Icon render data outlining which parts of the icon mesh use which textures.
+		 * @param[in]	usePickingMaterial	Should the icons be rendered normally or for picking.
+		 */
+		void renderIconGizmos(Rect2I screenArea, SPtr<MeshCoreBase> mesh, GizmoManager::IconRenderDataVecPtr renderData, bool usePickingMaterial);
+
+		/**
+		 * Updates the internal data that is used for rendering. Normally you would call this after updating the camera or
+		 * meshes on the sim thread.
+		 *
+		 * @param[in]	camera			Sets the camera all rendering will be performed to.
+		 * @param[in]	meshes			Meshes to render.
+		 * @param[in]	iconMesh		Mesh containing icon meshes.
+		 * @param[in]	iconRenderData	Icon render data outlining which parts of the icon mesh use which textures.
+		 */
+		void updateData(const SPtr<CameraCore>& camera, const Vector<MeshData>& meshes, const SPtr<MeshCoreBase>& iconMesh, 
+			const GizmoManager::IconRenderDataVecPtr& iconRenderData);
+
+		static const float PICKING_ALPHA_CUTOFF;
+
+		SPtr<CameraCore> mCamera;
+
+		Vector<MeshData> mMeshes;
+		SPtr<MeshCoreBase> mIconMesh;
+		GizmoManager::IconRenderDataVecPtr mIconRenderData;
+
+		// Immutable
+		SolidMaterialData mSolidMaterial;
+		SolidMaterialData mWireMaterial;
+		WireMaterialData mLineMaterial;
+		IconMaterialData mIconMaterial;
+		TextMaterialData mTextMaterial;
+
+		PickingMaterialData mPickingMaterial;
+		AlphaPickingMaterialData mAlphaPickingMaterial;
+	};
+
+	/** @endcond */
+	/** @} */
 }

+ 300 - 300
Source/BansheeEditor/Include/BsHandleDrawManager.h

@@ -1,301 +1,301 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsEditorPrerequisites.h"
-#include "BsGpuParams.h"
-#include "BsDrawHelper.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup Handles
-	 *  @{
-	 */
-
-	class HandleDrawManagerCore;
-
-	/**
-	 * Allows you to easily draw various kinds of simple shapes, primarily used for drawing handles in the scene view.
-	 *
-	 * Drawn elements only persist for a single draw() call and need to be re-queued after.
-	 */
-	class BS_ED_EXPORT HandleDrawManager
-	{
-	public:
-		HandleDrawManager();
-		~HandleDrawManager();
-
-		/**	Sets the color of all the following draw* calls. */
-		void setColor(const Color& color);
-
-		/** Sets the transform matrix that will be applied to all following draw* calls. */
-		void setTransform(const Matrix4& transform);
-
-		/**
-		 * Sets the layer bitfield that controls whether a handle is considered visible in a specific camera. Handle layer 
-		 * must match camera layer in order for the camera to render it
-		 */
-		void setLayer(UINT64 layer);
-
-		/**
-		 * Draws a solid cuboid.
-		 *
-		 * @param[in]	position	Center of the cuboid.
-		 * @param[in]	extents		Radius of the cuboid in all directions.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawCube(const Vector3& position, const Vector3& extents, float size = 1.0f);
-
-		/**
-		 * Draws a solid sphere.
-		 *
-		 * @param[in]	position	Center of the sphere.
-		 * @param[in]	radius		Radius of the sphere.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawSphere(const Vector3& position, float radius, float size = 1.0f);
-
-		/**
-		 * Draws a wireframe cuboid.
-		 *
-		 * @param[in]	position	Center of the cuboid.
-		 * @param[in]	extents		Radius of the cuboid in all directions.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawWireCube(const Vector3& position, const Vector3& extents, float size = 1.0f);
-
-		/**
-		 * Draws a wireframe sphere.
-		 *
-		 * @param[in]	position	Center of the sphere.
-		 * @param[in]	radius		Radius of the sphere.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawWireSphere(const Vector3& position, float radius, float size = 1.0f);
-
-		/**
-		 * Draws a solid cone.
-		 *
-		 * @param[in]	base		Position of the center of the base of the cone.
-		 * @param[in]	normal		Orientation of the cone, pointing from center base to the tip of the cone.
-		 * @param[in]	height		Height of the cone (along the normal).
-		 * @param[in]	radius		Radius of the base of the cone.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawCone(const Vector3& base, const Vector3& normal, float height, float radius, float size = 1.0f);
-
-		/**
-		 * Draws a line.
-		 *
-		 * @param[in]	start		Starting point for the line.
-		 * @param[in]	end			Ending point for the line.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawLine(const Vector3& start, const Vector3& end, float size = 1.0f);
-
-		/**
-		 * Draws a double-sided solid disc.
-		 *
-		 * @param[in]	position	Center of the disc.
-		 * @param[in]	normal		Orientation of the disc, pointing in the direction the disc is visible in.
-		 * @param[in]	radius		Radius of the disc.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawDisc(const Vector3& position, const Vector3& normal, float radius, float size = 1.0f);
-
-		/**
-		 * Draws a wireframe disc.
-		 *
-		 * @param[in]	position	Center of the disc.
-		 * @param[in]	normal		Orientation of the disc, pointing in the direction the disc is visible in.
-		 * @param[in]	radius		Radius of the disc.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawWireDisc(const Vector3& position, const Vector3& normal, float radius, float size = 1.0f);
-
-		/**
-		 * Draws a double-sided solid arc.
-		 *
-		 * @param[in]	position	Center of the arc.
-		 * @param[in]	normal		Orientation of the arc, pointing in the direction the arc is visible in.
-		 * @param[in]	radius		Radius of the arc.
-		 * @param[in]	startAngle	Angle at which to start the arc.
-		 * @param[in]	amountAngle	Length of the arc.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size = 1.0f);
-
-		/**
-		 * Draws a wireframe arc.
-		 *
-		 * @param[in]	position	Center of the arc.
-		 * @param[in]	normal		Orientation of the arc, pointing in the direction the arc is visible in.
-		 * @param[in]	radius		Radius of the arc.
-		 * @param[in]	startAngle	Angle at which to start the arc.
-		 * @param[in]	amountAngle	Length of the arc.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawWireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size = 1.0f);
-
-		/**
-		 * Draws a double-sided solid rectangle.
-		 *
-		 * @param[in]	area		Position and size of the rectangle.
-		 * @param[in]	size		Uniform scale of the object.
-		 */
-		void drawRect(const Rect3& area, float size = 1.0f);
-
-		/**
-		 * Draws a mesh representing 2D text with the specified properties. 
-		 *
-		 * @param[in]	position	Position to render the text at. Text will be centered around this point.
-		 * @param[in]	text		Text to draw.
-		 * @param[in]	font		Font to use for rendering the text's characters.
-		 * @param[in]	fontSize	Size of the characters, in points.
-		 * @param[in]	size		Uniform scale of the rendered mesh.
-		 */
-		void drawText(const Vector3& position, const WString& text, const HFont& font, UINT32 fontSize = 16, float size = 1.0f);
-
-		/**	Queues all the handle draw commands queued since the last call to clear() for rendering. */
-		void draw(const CameraPtr& camera);
-
-		/** Clears all handle draw commands. */
-		void clear();
-
-	private:
-		friend class HandleDrawManagerCore;
-
-		/**
-		 * Initializes the core thread portion of the draw manager.
-		 *
-		 * @param[in]	wireMat		Material used for drawing the wireframe objects.
-		 * @param[in]	solidMat	Material used for drawing the solid objects.
-		 * @param[in]	textMat		Material used for drawing the text.
-		 * @param[in]	clearMat	Material used for clearing the alpha channel in the empty areas.
-		 */
-		void initializeCore(const SPtr<MaterialCore>& wireMat, const SPtr<MaterialCore>& solidMat, 
-			const SPtr<MaterialCore>& textMat, const SPtr<MaterialCore>& clearMat);
-
-		/** Destroys the core thread portion of the draw manager. */
-		void destroyCore(HandleDrawManagerCore* core);
-
-		/** Destroys all meshes allocated since the last call to this method. */
-		void clearMeshes();
-
-		static const UINT32 SPHERE_QUALITY;
-		static const UINT32 WIRE_SPHERE_QUALITY;
-		static const UINT32 ARC_QUALITY;
-
-		Vector<Vector<DrawHelper::ShapeMeshData>> mActiveMeshes;
-		UINT64 mLastFrameIdx;
-
-		Matrix4 mTransform;
-		std::atomic<HandleDrawManagerCore*> mCore;
-		DrawHelper* mDrawHelper;
-	};
-
-	/** @cond INTERNAL */
-
-	/** Core thread specific portion of the HandleDrawManager that handles actual rendering. */
-	class BS_ED_EXPORT HandleDrawManagerCore
-	{
-		/** Contains information about the material used for drawing solid objects and its parameters. */
-		struct SolidMaterialData
-		{
-			SPtr<MaterialCore> mat;
-			GpuParamMat4Core viewProj;
-			GpuParamVec4Core viewDir;
-		};
-
-		/**	Contains information about the material used for drawing wireframe objects and its parameters. */
-		struct WireMaterialData
-		{
-			SPtr<MaterialCore> mat;
-			GpuParamMat4Core viewProj;
-		};
-
-		/**	Contains information about the material used for drawing text and its parameters. */
-		struct TextMaterialData
-		{
-			SPtr<MaterialCore> mat;
-			GpuParamMat4Core viewProj;
-			GpuParamTextureCore texture;
-		};
-
-		/**	Contains information about the material used for clearing the alpha channel in the empty areas. */
-		struct ClearAlphaMaterialData
-		{
-			SPtr<MaterialCore> mat;
-		};
-
-		/** Type of mesh that can be drawn. */
-		enum class MeshType
-		{
-			Solid, Wire, Text
-		};
-
-		/** Data about a mesh rendered by the draw manager. */
-		struct MeshData
-		{
-			MeshData(const SPtr<MeshCoreBase>& mesh, SPtr<TextureCore> texture, MeshType type)
-				:mesh(mesh), texture(texture), type(type)
-			{ }
-
-			SPtr<MeshCoreBase> mesh;
-			SPtr<TextureCore> texture;
-			MeshType type;
-		};
-
-		/** Data about a camera and the meshes that are queued for rendering on it */
-		struct QueuedData
-		{
-			SPtr<CameraCore> camera;
-			Vector<MeshData> meshes;
-		};
-
-		struct PrivatelyConstruct { };
-
-	public:
-		HandleDrawManagerCore(const PrivatelyConstruct& dummy) { }
-		~HandleDrawManagerCore();
-
-	private:
-		friend class HandleDrawManager;
-
-		/**
-		 * Initializes the object. Must be called right after construction.
-		 *
-		 * @param[in]	wireMat		Material used for drawing the wireframe objects.
-		 * @param[in]	solidMat	Material used for drawing the solid objects.
-		 * @param[in]	textMat		Material used for drawing the text.
-		 * @param[in]	clearMat	Material used for clearing the alpha channel in the empty areas.
-		 */
-		void initialize(const SPtr<MaterialCore>& wireMat, const SPtr<MaterialCore>& solidMat, 
-			const SPtr<MaterialCore>& textMat, const SPtr<MaterialCore>& clearMat);
-
-		/**
-		 * Queues new data for rendering.
-		 *
-		 * @param[in]	camera	Camera to render to.
-		 * @param[in]	meshes	Meshes to render.
-		 */
-		void queueForDraw(const SPtr<CameraCore>& camera, const Vector<MeshData>& meshes);
-
-		/** Deletes any meshes queued for rendering. */
-		void clearQueued();
-
-		/** Callback triggered by the renderer. Draws all queued meshes. */
-		void render(UINT32 queuedDataIdx);
-
-		Vector<QueuedData> mQueuedData;
-
-		// Immutable
-		SolidMaterialData mSolidMaterial;
-		WireMaterialData mWireMaterial;
-		TextMaterialData mTextMaterial;
-		WireMaterialData mClearMaterial;
-	};
-
-	/** @endcond */
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "BsGpuParams.h"
+#include "BsDrawHelper.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Handles
+	 *  @{
+	 */
+
+	class HandleDrawManagerCore;
+
+	/**
+	 * Allows you to easily draw various kinds of simple shapes, primarily used for drawing handles in the scene view.
+	 *
+	 * Drawn elements only persist for a single draw() call and need to be re-queued after.
+	 */
+	class BS_ED_EXPORT HandleDrawManager
+	{
+	public:
+		HandleDrawManager();
+		~HandleDrawManager();
+
+		/**	Sets the color of all the following draw* calls. */
+		void setColor(const Color& color);
+
+		/** Sets the transform matrix that will be applied to all following draw* calls. */
+		void setTransform(const Matrix4& transform);
+
+		/**
+		 * Sets the layer bitfield that controls whether a handle is considered visible in a specific camera. Handle layer 
+		 * must match camera layer in order for the camera to render it
+		 */
+		void setLayer(UINT64 layer);
+
+		/**
+		 * Draws a solid cuboid.
+		 *
+		 * @param[in]	position	Center of the cuboid.
+		 * @param[in]	extents		Radius of the cuboid in all directions.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawCube(const Vector3& position, const Vector3& extents, float size = 1.0f);
+
+		/**
+		 * Draws a solid sphere.
+		 *
+		 * @param[in]	position	Center of the sphere.
+		 * @param[in]	radius		Radius of the sphere.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawSphere(const Vector3& position, float radius, float size = 1.0f);
+
+		/**
+		 * Draws a wireframe cuboid.
+		 *
+		 * @param[in]	position	Center of the cuboid.
+		 * @param[in]	extents		Radius of the cuboid in all directions.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawWireCube(const Vector3& position, const Vector3& extents, float size = 1.0f);
+
+		/**
+		 * Draws a wireframe sphere.
+		 *
+		 * @param[in]	position	Center of the sphere.
+		 * @param[in]	radius		Radius of the sphere.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawWireSphere(const Vector3& position, float radius, float size = 1.0f);
+
+		/**
+		 * Draws a solid cone.
+		 *
+		 * @param[in]	base		Position of the center of the base of the cone.
+		 * @param[in]	normal		Orientation of the cone, pointing from center base to the tip of the cone.
+		 * @param[in]	height		Height of the cone (along the normal).
+		 * @param[in]	radius		Radius of the base of the cone.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawCone(const Vector3& base, const Vector3& normal, float height, float radius, float size = 1.0f);
+
+		/**
+		 * Draws a line.
+		 *
+		 * @param[in]	start		Starting point for the line.
+		 * @param[in]	end			Ending point for the line.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawLine(const Vector3& start, const Vector3& end, float size = 1.0f);
+
+		/**
+		 * Draws a double-sided solid disc.
+		 *
+		 * @param[in]	position	Center of the disc.
+		 * @param[in]	normal		Orientation of the disc, pointing in the direction the disc is visible in.
+		 * @param[in]	radius		Radius of the disc.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawDisc(const Vector3& position, const Vector3& normal, float radius, float size = 1.0f);
+
+		/**
+		 * Draws a wireframe disc.
+		 *
+		 * @param[in]	position	Center of the disc.
+		 * @param[in]	normal		Orientation of the disc, pointing in the direction the disc is visible in.
+		 * @param[in]	radius		Radius of the disc.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawWireDisc(const Vector3& position, const Vector3& normal, float radius, float size = 1.0f);
+
+		/**
+		 * Draws a double-sided solid arc.
+		 *
+		 * @param[in]	position	Center of the arc.
+		 * @param[in]	normal		Orientation of the arc, pointing in the direction the arc is visible in.
+		 * @param[in]	radius		Radius of the arc.
+		 * @param[in]	startAngle	Angle at which to start the arc.
+		 * @param[in]	amountAngle	Length of the arc.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size = 1.0f);
+
+		/**
+		 * Draws a wireframe arc.
+		 *
+		 * @param[in]	position	Center of the arc.
+		 * @param[in]	normal		Orientation of the arc, pointing in the direction the arc is visible in.
+		 * @param[in]	radius		Radius of the arc.
+		 * @param[in]	startAngle	Angle at which to start the arc.
+		 * @param[in]	amountAngle	Length of the arc.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawWireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size = 1.0f);
+
+		/**
+		 * Draws a double-sided solid rectangle.
+		 *
+		 * @param[in]	area		Position and size of the rectangle.
+		 * @param[in]	size		Uniform scale of the object.
+		 */
+		void drawRect(const Rect3& area, float size = 1.0f);
+
+		/**
+		 * Draws a mesh representing 2D text with the specified properties. 
+		 *
+		 * @param[in]	position	Position to render the text at. Text will be centered around this point.
+		 * @param[in]	text		Text to draw.
+		 * @param[in]	font		Font to use for rendering the text's characters.
+		 * @param[in]	fontSize	Size of the characters, in points.
+		 * @param[in]	size		Uniform scale of the rendered mesh.
+		 */
+		void drawText(const Vector3& position, const WString& text, const HFont& font, UINT32 fontSize = 16, float size = 1.0f);
+
+		/**	Queues all the handle draw commands queued since the last call to clear() for rendering. */
+		void draw(const CameraPtr& camera);
+
+		/** Clears all handle draw commands. */
+		void clear();
+
+	private:
+		friend class HandleDrawManagerCore;
+
+		/**
+		 * Initializes the core thread portion of the draw manager.
+		 *
+		 * @param[in]	lineMat		Material used for drawing the line objects.
+		 * @param[in]	solidMat	Material used for drawing the solid objects.
+		 * @param[in]	textMat		Material used for drawing the text.
+		 * @param[in]	clearMat	Material used for clearing the alpha channel in the empty areas.
+		 */
+		void initializeCore(const SPtr<MaterialCore>& lineMat, const SPtr<MaterialCore>& solidMat,
+			const SPtr<MaterialCore>& textMat, const SPtr<MaterialCore>& clearMat);
+
+		/** Destroys the core thread portion of the draw manager. */
+		void destroyCore(HandleDrawManagerCore* core);
+
+		/** Destroys all meshes allocated since the last call to this method. */
+		void clearMeshes();
+
+		static const UINT32 SPHERE_QUALITY;
+		static const UINT32 WIRE_SPHERE_QUALITY;
+		static const UINT32 ARC_QUALITY;
+
+		Vector<Vector<DrawHelper::ShapeMeshData>> mActiveMeshes;
+		UINT64 mLastFrameIdx;
+
+		Matrix4 mTransform;
+		std::atomic<HandleDrawManagerCore*> mCore;
+		DrawHelper* mDrawHelper;
+	};
+
+	/** @cond INTERNAL */
+
+	/** Core thread specific portion of the HandleDrawManager that handles actual rendering. */
+	class BS_ED_EXPORT HandleDrawManagerCore
+	{
+		/** Contains information about the material used for drawing solid objects and its parameters. */
+		struct SolidMaterialData
+		{
+			SPtr<MaterialCore> mat;
+			GpuParamMat4Core viewProj;
+			GpuParamVec4Core viewDir;
+		};
+
+		/**	Contains information about the material used for drawing line objects and its parameters. */
+		struct LineMaterialData
+		{
+			SPtr<MaterialCore> mat;
+			GpuParamMat4Core viewProj;
+		};
+
+		/**	Contains information about the material used for drawing text and its parameters. */
+		struct TextMaterialData
+		{
+			SPtr<MaterialCore> mat;
+			GpuParamMat4Core viewProj;
+			GpuParamTextureCore texture;
+		};
+
+		/**	Contains information about the material used for clearing the alpha channel in the empty areas. */
+		struct ClearAlphaMaterialData
+		{
+			SPtr<MaterialCore> mat;
+		};
+
+		/** Type of mesh that can be drawn. */
+		enum class MeshType
+		{
+			Solid, Line, Text
+		};
+
+		/** Data about a mesh rendered by the draw manager. */
+		struct MeshData
+		{
+			MeshData(const SPtr<MeshCoreBase>& mesh, SPtr<TextureCore> texture, MeshType type)
+				:mesh(mesh), texture(texture), type(type)
+			{ }
+
+			SPtr<MeshCoreBase> mesh;
+			SPtr<TextureCore> texture;
+			MeshType type;
+		};
+
+		/** Data about a camera and the meshes that are queued for rendering on it */
+		struct QueuedData
+		{
+			SPtr<CameraCore> camera;
+			Vector<MeshData> meshes;
+		};
+
+		struct PrivatelyConstruct { };
+
+	public:
+		HandleDrawManagerCore(const PrivatelyConstruct& dummy) { }
+		~HandleDrawManagerCore();
+
+	private:
+		friend class HandleDrawManager;
+
+		/**
+		 * Initializes the object. Must be called right after construction.
+		 *
+		 * @param[in]	lineMat		Material used for drawing the line objects.
+		 * @param[in]	solidMat	Material used for drawing the solid objects.
+		 * @param[in]	textMat		Material used for drawing the text.
+		 * @param[in]	clearMat	Material used for clearing the alpha channel in the empty areas.
+		 */
+		void initialize(const SPtr<MaterialCore>& lineMat, const SPtr<MaterialCore>& solidMat, 
+			const SPtr<MaterialCore>& textMat, const SPtr<MaterialCore>& clearMat);
+
+		/**
+		 * Queues new data for rendering.
+		 *
+		 * @param[in]	camera	Camera to render to.
+		 * @param[in]	meshes	Meshes to render.
+		 */
+		void queueForDraw(const SPtr<CameraCore>& camera, const Vector<MeshData>& meshes);
+
+		/** Deletes any meshes queued for rendering. */
+		void clearQueued();
+
+		/** Callback triggered by the renderer. Draws all queued meshes. */
+		void render(UINT32 queuedDataIdx);
+
+		Vector<QueuedData> mQueuedData;
+
+		// Immutable
+		SolidMaterialData mSolidMaterial;
+		LineMaterialData mLineMaterial;
+		TextMaterialData mTextMaterial;
+		ClearAlphaMaterialData mClearMaterial;
+	};
+
+	/** @endcond */
+	/** @} */
 }

+ 13 - 6
Source/BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -266,9 +266,10 @@ namespace BansheeEngine
 	const WString BuiltinEditorResources::ShaderPickingAlphaCullNoneFile = L"PickingAlphaCullNone.bsl";
 	const WString BuiltinEditorResources::ShaderPickingAlphaCullCWFile = L"PickingAlphaCullCW.bsl";
 	const WString BuiltinEditorResources::ShaderPickingAlphaCullCCWFile = L"PickingAlphaCullCCW.bsl";
+	const WString BuiltinEditorResources::ShaderLineGizmoFile = L"LineGizmo.bsl";
 	const WString BuiltinEditorResources::ShaderWireGizmoFile = L"WireGizmo.bsl";
 	const WString BuiltinEditorResources::ShaderSolidGizmoFile = L"SolidGizmo.bsl";
-	const WString BuiltinEditorResources::ShaderWireHandleFile = L"WireHandle.bsl";
+	const WString BuiltinEditorResources::ShaderLineHandleFile = L"LineHandle.bsl";
 	const WString BuiltinEditorResources::ShaderSolidHandleFile = L"SolidHandle.bsl";
 	const WString BuiltinEditorResources::ShaderHandleClearAlphaFile = L"ClearHandleAlpha.bsl";
 	const WString BuiltinEditorResources::ShaderIconGizmoFile = L"IconGizmo.bsl";
@@ -341,6 +342,7 @@ namespace BansheeEngine
 		mShaderPickingAlpha[(int)CULL_CLOCKWISE] = getShader(ShaderPickingAlphaCullCWFile);
 		mShaderPickingAlpha[(int)CULL_COUNTERCLOCKWISE] = getShader(ShaderPickingAlphaCullCCWFile);
 		mShaderGizmoSolid = getShader(ShaderSolidGizmoFile);
+		mShaderGizmoLine = getShader(ShaderLineGizmoFile);
 		mShaderGizmoWire = getShader(ShaderWireGizmoFile);
 		mShaderGizmoIcon = getShader(ShaderIconGizmoFile);
 		mShaderGizmoPicking = getShader(ShaderGizmoPickingFile);
@@ -348,7 +350,7 @@ namespace BansheeEngine
 		mShaderGizmoText = getShader(ShaderTextGizmoFile);
 		mShaderHandleSolid = getShader(ShaderSolidHandleFile);
 		mShaderHandleClearAlpha = getShader(ShaderHandleClearAlphaFile);
-		mShaderHandleWire = getShader(ShaderWireHandleFile);
+		mShaderHandleLine = getShader(ShaderLineHandleFile);
 		mShaderSelection = getShader(ShaderSelectionFile);
 
 		mDefaultFont = gResources().load<Font>(BuiltinDataFolder + (DefaultAAFontFilename + L".asset"));
@@ -1935,9 +1937,9 @@ namespace BansheeEngine
 		return Material::create(mShaderPickingAlpha[modeIdx]);
 	}
 
-	HMaterial BuiltinEditorResources::createWireGizmoMat() const
+	HMaterial BuiltinEditorResources::createLineGizmoMat() const
 	{
-		return Material::create(mShaderGizmoWire);
+		return Material::create(mShaderGizmoLine);
 	}
 
 	HMaterial BuiltinEditorResources::createSolidGizmoMat() const
@@ -1945,6 +1947,11 @@ namespace BansheeEngine
 		return Material::create(mShaderGizmoSolid);
 	}
 
+	HMaterial BuiltinEditorResources::createWireGizmoMat() const
+	{
+		return Material::create(mShaderGizmoWire);
+	}
+
 	HMaterial BuiltinEditorResources::createIconGizmoMat() const
 	{
 		return Material::create(mShaderGizmoIcon);
@@ -1960,9 +1967,9 @@ namespace BansheeEngine
 		return Material::create(mShaderGizmoAlphaPicking);
 	}
 
-	HMaterial BuiltinEditorResources::createWireHandleMat() const
+	HMaterial BuiltinEditorResources::createLineHandleMat() const
 	{
-		return Material::create(mShaderHandleWire);
+		return Material::create(mShaderHandleLine);
 	}
 
 	HMaterial BuiltinEditorResources::createTextGizmoMat() const

+ 55 - 3
Source/BansheeEditor/Source/BsGizmoManager.cpp

@@ -51,6 +51,7 @@ namespace BansheeEngine
 
 		HMaterial solidMaterial = BuiltinEditorResources::instance().createSolidGizmoMat();
 		HMaterial wireMaterial = BuiltinEditorResources::instance().createWireGizmoMat();
+		HMaterial lineMaterial = BuiltinEditorResources::instance().createLineGizmoMat();
 		HMaterial iconMaterial = BuiltinEditorResources::instance().createIconGizmoMat();
 		HMaterial textMaterial = BuiltinEditorResources::instance().createTextGizmoMat();
 		HMaterial pickingMaterial = BuiltinEditorResources::instance().createGizmoPickingMat();
@@ -60,6 +61,7 @@ namespace BansheeEngine
 
 		initData.solidMat = solidMaterial->getCore();
 		initData.wireMat = wireMaterial->getCore();
+		initData.lineMat = lineMaterial->getCore();
 		initData.iconMat = iconMaterial->getCore();
 		initData.textMat = textMaterial->getCore();
 		initData.pickingMat = pickingMaterial->getCore();
@@ -308,6 +310,22 @@ namespace BansheeEngine
 		mIdxToSceneObjectMap[wireArcData.idx] = mActiveSO;
 	}
 
+	void GizmoManager::drawWireMesh(const MeshDataPtr& meshData)
+	{
+		mWireMeshData.push_back(WireMeshData());
+		WireMeshData& wireMeshData = mWireMeshData.back();
+
+		wireMeshData.idx = mCurrentIdx++;
+		wireMeshData.meshData = meshData;
+		wireMeshData.color = mColor;
+		wireMeshData.transform = mTransform;
+		wireMeshData.sceneObject = mActiveSO;
+		wireMeshData.pickable = mPickable;
+
+		mDrawHelper->wireMesh(meshData);
+		mIdxToSceneObjectMap[wireMeshData.idx] = mActiveSO;
+	}
+
 	void GizmoManager::drawFrustum(const Vector3& position, float aspect, Degree FOV, float near, float far)
 	{
 		mFrustumData.push_back(FrustumData());
@@ -393,11 +411,16 @@ namespace BansheeEngine
 				proxyData.push_back(GizmoManagerCore::MeshData(
 					meshData.mesh->getCore(), tex, GizmoManagerCore::MeshType::Solid));
 			}
-			else if (meshData.type == DrawHelper::MeshType::Wire)
+			else if(meshData.type == DrawHelper::MeshType::Wire)
 			{
 				proxyData.push_back(GizmoManagerCore::MeshData(
 					meshData.mesh->getCore(), tex, GizmoManagerCore::MeshType::Wire));
 			}
+			else if (meshData.type == DrawHelper::MeshType::Line)
+			{
+				proxyData.push_back(GizmoManagerCore::MeshData(
+					meshData.mesh->getCore(), tex, GizmoManagerCore::MeshType::Line));
+			}
 			else // Text
 			{
 				proxyData.push_back(GizmoManagerCore::MeshData(
@@ -510,6 +533,17 @@ namespace BansheeEngine
 				wireArcDataEntry.startAngle, wireArcDataEntry.amountAngle);
 		}
 
+		for (auto& wireMeshData : mWireMeshData)
+		{
+			if (!wireMeshData.pickable)
+				continue;
+
+			mPickingDrawHelper->setColor(idxToColorCallback(wireMeshData.idx));
+			mPickingDrawHelper->setTransform(wireMeshData.transform);
+
+			mPickingDrawHelper->wireMesh(wireMeshData.meshData);
+		}
+
 		for (auto& frustumDataEntry : mFrustumData)
 		{
 			if (!frustumDataEntry.pickable)
@@ -592,6 +626,7 @@ namespace BansheeEngine
 		mLineListData.clear();
 		mWireDiscData.clear();
 		mWireArcData.clear();
+		mWireMeshData.clear();
 		mFrustumData.clear();
 		mTextData.clear();
 		mIconData.clear();
@@ -855,16 +890,17 @@ namespace BansheeEngine
 
 		mSolidMaterial.mat = initData.solidMat;
 		mWireMaterial.mat = initData.wireMat;
+		mLineMaterial.mat = initData.lineMat;
 		mTextMaterial.mat = initData.textMat;
 		mIconMaterial.mat = initData.iconMat;
 		mPickingMaterial.mat = initData.pickingMat;
 		mAlphaPickingMaterial.mat = initData.alphaPickingMat;
 
 		{
-			SPtr<MaterialCore> mat = mWireMaterial.mat;
+			SPtr<MaterialCore> mat = mLineMaterial.mat;
 			SPtr<GpuParamsCore> vertParams = mat->getPassParameters(0)->mVertParams;
 
-			vertParams->getParam("matViewProj", mWireMaterial.mViewProj);
+			vertParams->getParam("matViewProj", mLineMaterial.mViewProj);
 		}
 
 		{
@@ -876,6 +912,14 @@ namespace BansheeEngine
 			fragParams->getParam("viewDir", mSolidMaterial.mViewDir);
 		}
 
+		{
+			SPtr<MaterialCore> mat = mWireMaterial.mat;
+			SPtr<GpuParamsCore> vertParams = mat->getPassParameters(0)->mVertParams;
+			SPtr<GpuParamsCore> fragParams = mat->getPassParameters(0)->mFragParams;
+
+			vertParams->getParam("matViewProj", mWireMaterial.mViewProj);
+		}
+
 		{
 			SPtr<MaterialCore> mat = mIconMaterial.mat;
 			SPtr<PassParametersCore> pass0Params = mat->getPassParameters(0);
@@ -976,6 +1020,9 @@ namespace BansheeEngine
 			case MeshType::Wire:
 				material = GizmoManager::GizmoMaterial::Wire;
 				break;
+			case MeshType::Line:
+				material = GizmoManager::GizmoMaterial::Line;
+				break;
 			case MeshType::Text:
 				material = GizmoManager::GizmoMaterial::Text;
 				break;
@@ -1009,6 +1056,11 @@ namespace BansheeEngine
 			gRendererUtility().setPass(mWireMaterial.mat, 0);
 			gRendererUtility().setPassParams(mWireMaterial.mat);
 			break;
+		case GizmoManager::GizmoMaterial::Line:
+			mLineMaterial.mViewProj.set(viewProjMat);
+			gRendererUtility().setPass(mLineMaterial.mat, 0);
+			gRendererUtility().setPassParams(mLineMaterial.mat);
+			break;
 		case GizmoManager::GizmoMaterial::Picking:
 			mPickingMaterial.mViewProj.set(viewProjMat);
 			gRendererUtility().setPass(mPickingMaterial.mat, 0);

+ 376 - 376
Source/BansheeEditor/Source/BsHandleDrawManager.cpp

@@ -1,377 +1,377 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsHandleDrawManager.h"
-#include "BsDrawHelper.h"
-#include "BsMaterial.h"
-#include "BsBuiltinEditorResources.h"
-#include "BsCoreThread.h"
-#include "BsRendererManager.h"
-#include "BsCoreRenderer.h"
-#include "BsTransientMesh.h"
-#include "BsCamera.h"
-#include "BsRendererUtility.h"
-#include "BsTexture.h"
-#include "BsTime.h"
-#include "BsRenderAPI.h"
-
-using namespace std::placeholders;
-
-namespace BansheeEngine
-{
-	const UINT32 HandleDrawManager::SPHERE_QUALITY = 1;
-	const UINT32 HandleDrawManager::WIRE_SPHERE_QUALITY = 10;
-	const UINT32 HandleDrawManager::ARC_QUALITY = 10;
-
-	HandleDrawManager::HandleDrawManager()
-		:mCore(nullptr), mLastFrameIdx((UINT64)-1)
-	{
-		mTransform = Matrix4::IDENTITY;
-		mDrawHelper = bs_new<DrawHelper>();
-
-		HMaterial solidMaterial = BuiltinEditorResources::instance().createSolidHandleMat();
-		HMaterial wireMaterial = BuiltinEditorResources::instance().createWireHandleMat();
-		HMaterial textMaterial = BuiltinEditorResources::instance().createTextGizmoMat();
-		HMaterial clearMaterial = BuiltinEditorResources::instance().createHandleClearAlphaMat();
-
-		SPtr<MaterialCore> solidMaterialProxy = solidMaterial->getCore();
-		SPtr<MaterialCore> wireMaterialProxy = wireMaterial->getCore();
-		SPtr<MaterialCore> textMaterialProxy = textMaterial->getCore();
-		SPtr<MaterialCore> clearMaterialProxy = clearMaterial->getCore();
-
-		mCore.store(bs_new<HandleDrawManagerCore>(HandleDrawManagerCore::PrivatelyConstruct()), std::memory_order_release);
-
-		gCoreAccessor().queueCommand(std::bind(&HandleDrawManager::initializeCore, this, 
-			wireMaterialProxy, solidMaterialProxy, textMaterialProxy, clearMaterialProxy));
-	}
-
-	HandleDrawManager::~HandleDrawManager()
-	{
-		clearMeshes();
-		bs_delete(mDrawHelper);
-
-		gCoreAccessor().queueCommand(std::bind(&HandleDrawManager::destroyCore, this, mCore.load(std::memory_order_relaxed)));
-	}
-
-	void HandleDrawManager::initializeCore(const SPtr<MaterialCore>& wireMat, const SPtr<MaterialCore>& solidMat, 
-		const SPtr<MaterialCore>& textMat, const SPtr<MaterialCore>& clearMat)
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		mCore.load(std::memory_order_acquire)->initialize(wireMat, solidMat, textMat, clearMat);
-	}
-
-	void HandleDrawManager::destroyCore(HandleDrawManagerCore* core)
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		bs_delete(core);
-	}
-
-	void HandleDrawManager::setColor(const Color& color)
-	{
-		mDrawHelper->setColor(color);
-	}
-
-	void HandleDrawManager::setTransform(const Matrix4& transform)
-	{
-		mTransform = transform;
-	}
-
-	void HandleDrawManager::setLayer(UINT64 layer)
-	{
-		mDrawHelper->setLayer(layer);
-	}
-
-	void HandleDrawManager::drawCube(const Vector3& position, const Vector3& extents, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->cube(position, extents);
-	}
-
-	void HandleDrawManager::drawSphere(const Vector3& position, float radius, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->sphere(position, radius);
-	}
-
-	void HandleDrawManager::drawWireCube(const Vector3& position, const Vector3& extents, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->wireCube(position, extents);
-	}
-
-	void HandleDrawManager::drawWireSphere(const Vector3& position, float radius, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->wireSphere(position, radius);
-	}
-
-	void HandleDrawManager::drawCone(const Vector3& base, const Vector3& normal, float height, float radius, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-
-		mDrawHelper->setTransform(mTransform * scale);
-		mDrawHelper->cone(base, normal, height, radius);
-	}
-
-	void HandleDrawManager::drawLine(const Vector3& start, const Vector3& end, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->line(start, end);
-	}
-
-	void HandleDrawManager::drawDisc(const Vector3& position, const Vector3& normal, float radius, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->disc(position, normal, radius);
-	}
-
-	void HandleDrawManager::drawWireDisc(const Vector3& position, const Vector3& normal, float radius, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->wireDisc(position, normal, radius);
-	}
-
-	void HandleDrawManager::drawArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->arc(position, normal, radius, startAngle, amountAngle);
-	}
-
-	void HandleDrawManager::drawWireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->wireArc(position, normal, radius, startAngle, amountAngle);
-	}
-
-	void HandleDrawManager::drawRect(const Rect3& area, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		mDrawHelper->rectangle(area);
-	}
-
-	void HandleDrawManager::drawText(const Vector3& position, const WString& text, const HFont& font, UINT32 fontSize, float size)
-	{
-		Matrix4 scale = Matrix4::scaling(size);
-		mDrawHelper->setTransform(mTransform * scale);
-
-		HFont myFont = font;
-		if (myFont == nullptr)
-			myFont = BuiltinEditorResources::instance().getDefaultFont();
-
-		mDrawHelper->text(position, text, myFont, fontSize);
-	}
-
-	void HandleDrawManager::draw(const CameraPtr& camera)
-	{
-		HandleDrawManagerCore* core = mCore.load(std::memory_order_relaxed);
-
-		// Clear meshes from previous frame
-		UINT64 frameIdx = gTime().getFrameIdx();
-		if(frameIdx != mLastFrameIdx)
-		{
-			gCoreAccessor().queueCommand(std::bind(&HandleDrawManagerCore::clearQueued, core));
-
-			clearMeshes();
-			mLastFrameIdx = frameIdx;
-		}
-
-		mDrawHelper->buildMeshes(DrawHelper::SortType::BackToFront, camera->getPosition(), camera->getLayers());
-
-		const Vector<DrawHelper::ShapeMeshData>& meshes = mDrawHelper->getMeshes();
-		mActiveMeshes.push_back(meshes);
-
-		Vector<HandleDrawManagerCore::MeshData> proxyData;
-		for (auto& meshData : meshes)
-		{
-			SPtr<TextureCore> tex;
-			if (meshData.texture.isLoaded())
-				tex = meshData.texture->getCore();
-
-			if (meshData.type == DrawHelper::MeshType::Solid)
-			{
-				proxyData.push_back(HandleDrawManagerCore::MeshData(
-					meshData.mesh->getCore(), tex, HandleDrawManagerCore::MeshType::Solid));
-			}
-			else if (meshData.type == DrawHelper::MeshType::Wire)
-			{
-				proxyData.push_back(HandleDrawManagerCore::MeshData(
-					meshData.mesh->getCore(), tex, HandleDrawManagerCore::MeshType::Wire));
-			}
-			else // Text
-			{
-				proxyData.push_back(HandleDrawManagerCore::MeshData(
-					meshData.mesh->getCore(), tex, HandleDrawManagerCore::MeshType::Text));
-			}
-		}
-
-		gCoreAccessor().queueCommand(std::bind(&HandleDrawManagerCore::queueForDraw, core, camera->getCore(), proxyData));
-	}
-
-	void HandleDrawManager::clear()
-	{
-		mDrawHelper->clear();
-	}
-
-	void HandleDrawManager::clearMeshes()
-	{
-		for (auto entry : mActiveMeshes)
-			mDrawHelper->clearMeshes(entry);
-
-		mActiveMeshes.clear();
-	}
-
-	HandleDrawManagerCore::~HandleDrawManagerCore()
-	{
-		clearQueued();
-	}
-
-	void HandleDrawManagerCore::initialize(const SPtr<MaterialCore>& wireMat, const SPtr<MaterialCore>& solidMat, 
-		const SPtr<MaterialCore>& textMat, const SPtr<MaterialCore>& clearMat)
-	{
-		{
-			mWireMaterial.mat = wireMat;
-			SPtr<GpuParamsCore> vertParams = wireMat->getPassParameters(0)->mVertParams;
-
-			vertParams->getParam("matViewProj", mWireMaterial.viewProj);
-		}
-
-		{
-			mSolidMaterial.mat = solidMat;
-			SPtr<GpuParamsCore> vertParams = solidMat->getPassParameters(0)->mVertParams;
-			SPtr<GpuParamsCore> fragParams = solidMat->getPassParameters(0)->mFragParams;
-
-			vertParams->getParam("matViewProj", mSolidMaterial.viewProj);
-			fragParams->getParam("viewDir", mSolidMaterial.viewDir);
-		}
-		{
-			mTextMaterial.mat = textMat;
-
-			SPtr<GpuParamsCore> vertParams = textMat->getPassParameters(0)->mVertParams;
-			SPtr<GpuParamsCore> fragParams = textMat->getPassParameters(0)->mFragParams;
-
-			vertParams->getParam("matViewProj", mTextMaterial.viewProj);
-			fragParams->getTextureParam("mainTexture", mTextMaterial.texture);
-		}
-
-		{
-			mClearMaterial.mat = clearMat;
-		}
-	}
-
-	void HandleDrawManagerCore::queueForDraw(const SPtr<CameraCore>& camera, const Vector<MeshData>& meshes)
-	{
-		CoreRendererPtr activeRenderer = RendererManager::instance().getActive();
-		if (camera != nullptr)
-		{
-			UINT32 idx = (UINT32)mQueuedData.size();
-			mQueuedData.push_back({ camera, meshes });
-
-			activeRenderer->_registerRenderCallback(camera.get(), 20, std::bind(&HandleDrawManagerCore::render, this, idx));
-		}
-	}
-
-	void HandleDrawManagerCore::clearQueued()
-	{
-		CoreRendererPtr activeRenderer = RendererManager::instance().getActive();
-		for (auto& entry : mQueuedData)
-			activeRenderer->_unregisterRenderCallback(entry.camera.get(), 20);
-
-		mQueuedData.clear();
-	}
-
-	void HandleDrawManagerCore::render(UINT32 queuedDataIdx)
-	{
-		THROW_IF_NOT_CORE_THREAD;
-
-		const QueuedData& queueData = mQueuedData[queuedDataIdx];
-		SPtr<CameraCore> camera = queueData.camera;
-		const Vector<MeshData>& meshes = queueData.meshes;
-
-		SPtr<RenderTargetCore> renderTarget = camera->getViewport()->getTarget();
-
-		float width = (float)renderTarget->getProperties().getWidth();
-		float height = (float)renderTarget->getProperties().getHeight();
-
-		Rect2 normArea = camera->getViewport()->getNormArea();
-
-		Rect2I screenArea;
-		screenArea.x = (int)(normArea.x * width);
-		screenArea.y = (int)(normArea.y * height);
-		screenArea.width = (int)(normArea.width * width);
-		screenArea.height = (int)(normArea.height * height);
-
-		Matrix4 viewProjMat = camera->getProjectionMatrixRS() * camera->getViewMatrix();
-		mSolidMaterial.viewProj.set(viewProjMat);
-		mSolidMaterial.viewDir.set((Vector4)camera->getForward());
-		mWireMaterial.viewProj.set(viewProjMat);
-		mTextMaterial.viewProj.set(viewProjMat);
-
-		MeshType currentType = MeshType::Solid;
-		if (meshes.size() > 0)
-		{
-			currentType = meshes[0].type;
-
-			if (currentType == MeshType::Solid)
-				gRendererUtility().setPass(mSolidMaterial.mat, 0);
-			else if(currentType == MeshType::Wire)
-				gRendererUtility().setPass(mWireMaterial.mat, 0);
-			else
-			{
-				mTextMaterial.texture.set(meshes[0].texture);
-				gRendererUtility().setPass(mTextMaterial.mat, 0);
-			}
-		}
-
-		for (auto& meshData : meshes)
-		{
-			if (currentType != meshData.type)
-			{
-				if (meshData.type == MeshType::Solid)
-				{
-					gRendererUtility().setPass(mSolidMaterial.mat, 0);
-					gRendererUtility().setPassParams(mSolidMaterial.mat); // TODO - This call shouldn't be necessary, calling set() on parameters should be enough
-				}
-				else if (meshData.type == MeshType::Wire)
-				{
-					gRendererUtility().setPass(mWireMaterial.mat, 0);
-					gRendererUtility().setPassParams(mWireMaterial.mat); // TODO - This call shouldn't be necessary, calling set() on parameters should be enough
-				}
-				else
-				{
-					mTextMaterial.texture.set(meshData.texture);
-					gRendererUtility().setPass(mTextMaterial.mat, 0);
-					gRendererUtility().setPassParams(mTextMaterial.mat); // TODO - This call shouldn't be necessary, calling set() on parameters should be enough
-				}
-
-				currentType = meshData.type;
-			}
-
-			gRendererUtility().draw(meshData.mesh, meshData.mesh->getProperties().getSubMesh(0));
-		}
-
-		// Set alpha of everything that was drawn to 1 so we can overlay this texture onto GUI using transparency
-		gRendererUtility().setPass(mClearMaterial.mat, 0);
-		gRendererUtility().drawScreenQuad();
-	}
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsHandleDrawManager.h"
+#include "BsDrawHelper.h"
+#include "BsMaterial.h"
+#include "BsBuiltinEditorResources.h"
+#include "BsCoreThread.h"
+#include "BsRendererManager.h"
+#include "BsCoreRenderer.h"
+#include "BsTransientMesh.h"
+#include "BsCamera.h"
+#include "BsRendererUtility.h"
+#include "BsTexture.h"
+#include "BsTime.h"
+#include "BsRenderAPI.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	const UINT32 HandleDrawManager::SPHERE_QUALITY = 1;
+	const UINT32 HandleDrawManager::WIRE_SPHERE_QUALITY = 10;
+	const UINT32 HandleDrawManager::ARC_QUALITY = 10;
+
+	HandleDrawManager::HandleDrawManager()
+		:mCore(nullptr), mLastFrameIdx((UINT64)-1)
+	{
+		mTransform = Matrix4::IDENTITY;
+		mDrawHelper = bs_new<DrawHelper>();
+
+		HMaterial solidMaterial = BuiltinEditorResources::instance().createSolidHandleMat();
+		HMaterial lineMaterial = BuiltinEditorResources::instance().createLineHandleMat();
+		HMaterial textMaterial = BuiltinEditorResources::instance().createTextGizmoMat();
+		HMaterial clearMaterial = BuiltinEditorResources::instance().createHandleClearAlphaMat();
+
+		SPtr<MaterialCore> solidMaterialProxy = solidMaterial->getCore();
+		SPtr<MaterialCore> lineMaterialProxy = lineMaterial->getCore();
+		SPtr<MaterialCore> textMaterialProxy = textMaterial->getCore();
+		SPtr<MaterialCore> clearMaterialProxy = clearMaterial->getCore();
+
+		mCore.store(bs_new<HandleDrawManagerCore>(HandleDrawManagerCore::PrivatelyConstruct()), std::memory_order_release);
+
+		gCoreAccessor().queueCommand(std::bind(&HandleDrawManager::initializeCore, this, 
+			lineMaterialProxy, solidMaterialProxy, textMaterialProxy, clearMaterialProxy));
+	}
+
+	HandleDrawManager::~HandleDrawManager()
+	{
+		clearMeshes();
+		bs_delete(mDrawHelper);
+
+		gCoreAccessor().queueCommand(std::bind(&HandleDrawManager::destroyCore, this, mCore.load(std::memory_order_relaxed)));
+	}
+
+	void HandleDrawManager::initializeCore(const SPtr<MaterialCore>& lineMat, const SPtr<MaterialCore>& solidMat, 
+		const SPtr<MaterialCore>& textMat, const SPtr<MaterialCore>& clearMat)
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		mCore.load(std::memory_order_acquire)->initialize(lineMat, solidMat, textMat, clearMat);
+	}
+
+	void HandleDrawManager::destroyCore(HandleDrawManagerCore* core)
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		bs_delete(core);
+	}
+
+	void HandleDrawManager::setColor(const Color& color)
+	{
+		mDrawHelper->setColor(color);
+	}
+
+	void HandleDrawManager::setTransform(const Matrix4& transform)
+	{
+		mTransform = transform;
+	}
+
+	void HandleDrawManager::setLayer(UINT64 layer)
+	{
+		mDrawHelper->setLayer(layer);
+	}
+
+	void HandleDrawManager::drawCube(const Vector3& position, const Vector3& extents, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->cube(position, extents);
+	}
+
+	void HandleDrawManager::drawSphere(const Vector3& position, float radius, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->sphere(position, radius);
+	}
+
+	void HandleDrawManager::drawWireCube(const Vector3& position, const Vector3& extents, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->wireCube(position, extents);
+	}
+
+	void HandleDrawManager::drawWireSphere(const Vector3& position, float radius, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->wireSphere(position, radius);
+	}
+
+	void HandleDrawManager::drawCone(const Vector3& base, const Vector3& normal, float height, float radius, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+
+		mDrawHelper->setTransform(mTransform * scale);
+		mDrawHelper->cone(base, normal, height, radius);
+	}
+
+	void HandleDrawManager::drawLine(const Vector3& start, const Vector3& end, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->line(start, end);
+	}
+
+	void HandleDrawManager::drawDisc(const Vector3& position, const Vector3& normal, float radius, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->disc(position, normal, radius);
+	}
+
+	void HandleDrawManager::drawWireDisc(const Vector3& position, const Vector3& normal, float radius, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->wireDisc(position, normal, radius);
+	}
+
+	void HandleDrawManager::drawArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->arc(position, normal, radius, startAngle, amountAngle);
+	}
+
+	void HandleDrawManager::drawWireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->wireArc(position, normal, radius, startAngle, amountAngle);
+	}
+
+	void HandleDrawManager::drawRect(const Rect3& area, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		mDrawHelper->rectangle(area);
+	}
+
+	void HandleDrawManager::drawText(const Vector3& position, const WString& text, const HFont& font, UINT32 fontSize, float size)
+	{
+		Matrix4 scale = Matrix4::scaling(size);
+		mDrawHelper->setTransform(mTransform * scale);
+
+		HFont myFont = font;
+		if (myFont == nullptr)
+			myFont = BuiltinEditorResources::instance().getDefaultFont();
+
+		mDrawHelper->text(position, text, myFont, fontSize);
+	}
+
+	void HandleDrawManager::draw(const CameraPtr& camera)
+	{
+		HandleDrawManagerCore* core = mCore.load(std::memory_order_relaxed);
+
+		// Clear meshes from previous frame
+		UINT64 frameIdx = gTime().getFrameIdx();
+		if(frameIdx != mLastFrameIdx)
+		{
+			gCoreAccessor().queueCommand(std::bind(&HandleDrawManagerCore::clearQueued, core));
+
+			clearMeshes();
+			mLastFrameIdx = frameIdx;
+		}
+
+		mDrawHelper->buildMeshes(DrawHelper::SortType::BackToFront, camera->getPosition(), camera->getLayers());
+
+		const Vector<DrawHelper::ShapeMeshData>& meshes = mDrawHelper->getMeshes();
+		mActiveMeshes.push_back(meshes);
+
+		Vector<HandleDrawManagerCore::MeshData> proxyData;
+		for (auto& meshData : meshes)
+		{
+			SPtr<TextureCore> tex;
+			if (meshData.texture.isLoaded())
+				tex = meshData.texture->getCore();
+
+			if (meshData.type == DrawHelper::MeshType::Solid)
+			{
+				proxyData.push_back(HandleDrawManagerCore::MeshData(
+					meshData.mesh->getCore(), tex, HandleDrawManagerCore::MeshType::Solid));
+			}
+			else if (meshData.type == DrawHelper::MeshType::Line)
+			{
+				proxyData.push_back(HandleDrawManagerCore::MeshData(
+					meshData.mesh->getCore(), tex, HandleDrawManagerCore::MeshType::Line));
+			}
+			else // Text
+			{
+				proxyData.push_back(HandleDrawManagerCore::MeshData(
+					meshData.mesh->getCore(), tex, HandleDrawManagerCore::MeshType::Text));
+			}
+		}
+
+		gCoreAccessor().queueCommand(std::bind(&HandleDrawManagerCore::queueForDraw, core, camera->getCore(), proxyData));
+	}
+
+	void HandleDrawManager::clear()
+	{
+		mDrawHelper->clear();
+	}
+
+	void HandleDrawManager::clearMeshes()
+	{
+		for (auto entry : mActiveMeshes)
+			mDrawHelper->clearMeshes(entry);
+
+		mActiveMeshes.clear();
+	}
+
+	HandleDrawManagerCore::~HandleDrawManagerCore()
+	{
+		clearQueued();
+	}
+
+	void HandleDrawManagerCore::initialize(const SPtr<MaterialCore>& lineMat, const SPtr<MaterialCore>& solidMat, 
+		const SPtr<MaterialCore>& textMat, const SPtr<MaterialCore>& clearMat)
+	{
+		{
+			mLineMaterial.mat = lineMat;
+			SPtr<GpuParamsCore> vertParams = lineMat->getPassParameters(0)->mVertParams;
+
+			vertParams->getParam("matViewProj", mLineMaterial.viewProj);
+		}
+
+		{
+			mSolidMaterial.mat = solidMat;
+			SPtr<GpuParamsCore> vertParams = solidMat->getPassParameters(0)->mVertParams;
+			SPtr<GpuParamsCore> fragParams = solidMat->getPassParameters(0)->mFragParams;
+
+			vertParams->getParam("matViewProj", mSolidMaterial.viewProj);
+			fragParams->getParam("viewDir", mSolidMaterial.viewDir);
+		}
+		{
+			mTextMaterial.mat = textMat;
+
+			SPtr<GpuParamsCore> vertParams = textMat->getPassParameters(0)->mVertParams;
+			SPtr<GpuParamsCore> fragParams = textMat->getPassParameters(0)->mFragParams;
+
+			vertParams->getParam("matViewProj", mTextMaterial.viewProj);
+			fragParams->getTextureParam("mainTexture", mTextMaterial.texture);
+		}
+
+		{
+			mClearMaterial.mat = clearMat;
+		}
+	}
+
+	void HandleDrawManagerCore::queueForDraw(const SPtr<CameraCore>& camera, const Vector<MeshData>& meshes)
+	{
+		CoreRendererPtr activeRenderer = RendererManager::instance().getActive();
+		if (camera != nullptr)
+		{
+			UINT32 idx = (UINT32)mQueuedData.size();
+			mQueuedData.push_back({ camera, meshes });
+
+			activeRenderer->_registerRenderCallback(camera.get(), 20, std::bind(&HandleDrawManagerCore::render, this, idx));
+		}
+	}
+
+	void HandleDrawManagerCore::clearQueued()
+	{
+		CoreRendererPtr activeRenderer = RendererManager::instance().getActive();
+		for (auto& entry : mQueuedData)
+			activeRenderer->_unregisterRenderCallback(entry.camera.get(), 20);
+
+		mQueuedData.clear();
+	}
+
+	void HandleDrawManagerCore::render(UINT32 queuedDataIdx)
+	{
+		THROW_IF_NOT_CORE_THREAD;
+
+		const QueuedData& queueData = mQueuedData[queuedDataIdx];
+		SPtr<CameraCore> camera = queueData.camera;
+		const Vector<MeshData>& meshes = queueData.meshes;
+
+		SPtr<RenderTargetCore> renderTarget = camera->getViewport()->getTarget();
+
+		float width = (float)renderTarget->getProperties().getWidth();
+		float height = (float)renderTarget->getProperties().getHeight();
+
+		Rect2 normArea = camera->getViewport()->getNormArea();
+
+		Rect2I screenArea;
+		screenArea.x = (int)(normArea.x * width);
+		screenArea.y = (int)(normArea.y * height);
+		screenArea.width = (int)(normArea.width * width);
+		screenArea.height = (int)(normArea.height * height);
+
+		Matrix4 viewProjMat = camera->getProjectionMatrixRS() * camera->getViewMatrix();
+		mSolidMaterial.viewProj.set(viewProjMat);
+		mSolidMaterial.viewDir.set((Vector4)camera->getForward());
+		mLineMaterial.viewProj.set(viewProjMat);
+		mTextMaterial.viewProj.set(viewProjMat);
+
+		MeshType currentType = MeshType::Solid;
+		if (meshes.size() > 0)
+		{
+			currentType = meshes[0].type;
+
+			if (currentType == MeshType::Solid)
+				gRendererUtility().setPass(mSolidMaterial.mat, 0);
+			else if(currentType == MeshType::Line)
+				gRendererUtility().setPass(mLineMaterial.mat, 0);
+			else
+			{
+				mTextMaterial.texture.set(meshes[0].texture);
+				gRendererUtility().setPass(mTextMaterial.mat, 0);
+			}
+		}
+
+		for (auto& meshData : meshes)
+		{
+			if (currentType != meshData.type)
+			{
+				if (meshData.type == MeshType::Solid)
+				{
+					gRendererUtility().setPass(mSolidMaterial.mat, 0);
+					gRendererUtility().setPassParams(mSolidMaterial.mat); // TODO - This call shouldn't be necessary, calling set() on parameters should be enough
+				}
+				else if (meshData.type == MeshType::Line)
+				{
+					gRendererUtility().setPass(mLineMaterial.mat, 0);
+					gRendererUtility().setPassParams(mLineMaterial.mat); // TODO - This call shouldn't be necessary, calling set() on parameters should be enough
+				}
+				else
+				{
+					mTextMaterial.texture.set(meshData.texture);
+					gRendererUtility().setPass(mTextMaterial.mat, 0);
+					gRendererUtility().setPassParams(mTextMaterial.mat); // TODO - This call shouldn't be necessary, calling set() on parameters should be enough
+				}
+
+				currentType = meshData.type;
+			}
+
+			gRendererUtility().draw(meshData.mesh, meshData.mesh->getProperties().getSubMesh(0));
+		}
+
+		// Set alpha of everything that was drawn to 1 so we can overlay this texture onto GUI using transparency
+		gRendererUtility().setPass(mClearMaterial.mat, 0);
+		gRendererUtility().drawScreenQuad();
+	}
 }

+ 261 - 250
Source/BansheeEngine/Include/BsDrawHelper.h

@@ -1,251 +1,262 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsMatrix4.h"
-#include "BsVector3.h"
-#include "BsColor.h"
-#include "BsRect3.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup Utility-Engine
-	 *  @{
-	 */
-
-	/**	Helper class for immediate drawing of common geometric shapes. */
-	class BS_EXPORT DrawHelper
-	{
-	public:
-		/** Controls in what order will elements be rendered, depending on some reference point. */
-		enum class SortType
-		{
-			BackToFront,
-			FrontToBack,
-			None
-		};
-
-		/**	Type of meshes that are output by DrawHelper. */
-		enum class MeshType
-		{
-			Solid, Wire, Text
-		};
-
-		/**	Container for mesh of a specific type output by the DrawHelper. */
-		struct ShapeMeshData
-		{
-			TransientMeshPtr mesh;
-			MeshType type;
-			HTexture texture;
-		};
-
-		DrawHelper();
-		~DrawHelper();
-
-		/**	Sets a color that will be used for any shapes recorded after this call. */
-		void setColor(const Color& color);
-
-		/**	Sets a transform matrix that will be used for any shapes recorded after this call. */
-		void setTransform(const Matrix4& transform);
-
-		/** Sets the layer bitfield that can be used for filtering which objects are output into the final mesh. */
-		void setLayer(UINT64 layer);
-
-		/**	Records a solid cuboid with the specified properties in the internal draw queue. */
-		void cube(const Vector3& position, const Vector3& extents);
-
-		/**	Records a solid sphere with the specified properties in the internal draw queue. */
-		void sphere(const Vector3& position, float radius, UINT32 quality = 1);
-
-		/**	Records a wireframe cube with the specified properties in the internal draw queue. */
-		void wireCube(const Vector3& position, const Vector3& extents);
-
-		/**	Records a wireframe sphere with the specified properties in the internal draw queue. */
-		void wireSphere(const Vector3& position, float radius, UINT32 quality = 10);
-
-		/**	Records a line with the specified properties in the internal draw queue. */
-		void line(const Vector3& start, const Vector3& end);
-
-		/**	
-		 * Records a list of lines in the internal draw queue. The list must contain lines as pair of vertices, starting
-		 * point followed by an end point, and so on.
-		 */
-		void lineList(const Vector<Vector3>& lines);
-
-		/**	Records a wireframe frustum with the specified properties in the internal draw queue. */
-		void frustum(const Vector3& position, float aspect, Degree FOV, float near, float far);
-
-		/**	Records a solid cone with the specified properties in the internal draw queue. */
-		void cone(const Vector3& base, const Vector3& normal, float height, float radius, UINT32 quality = 10);
-
-		/**	Records a solid disc with the specified properties in the internal draw queue. */
-		void disc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality = 10);
-
-		/**	Records a wireframe disc with the specified properties in the internal draw queue. */
-		void wireDisc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality = 10);
-
-		/**	Records a solid arc with the specified properties in the internal draw queue. */
-		void arc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, 
-			UINT32 quality = 10);
-
-		/**	Records a wireframe arc with the specified properties in the internal draw queue. */
-		void wireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, 
-			UINT32 quality = 10);
-
-		/**	Records a solid rectangle with the specified properties in the internal draw queue. */
-		void rectangle(const Rect3& area);
-
-		/**
-		 * Records a mesh representing 2D text with the specified properties in the internal draw queue. 
-		 *
-		 * @param[in]	position	Position to render the text at. Text will be centered around this point.
-		 * @param[in]	text		Text to draw.
-		 * @param[in]	font		Font to use for rendering the text's characters.
-		 * @param[in]	size		Size of the characters, in points.
-		 */
-		void text(const Vector3& position, const WString& text, const HFont& font, UINT32 size = 10);
-
-		/**	Clears all recorded shapes. */
-		void clear();
-
-		/**
-		 * Generates a set of meshes from all the recorded solid and wireframe shapes. The meshes can be accessed via 
-		 * getMeshes() and released via clearMeshes().
-		 *
-		 * @param	sorting		(optional) Determines how (and if) should elements be sorted
-		 *						based on their distance from the reference point.
-		 * @param	reference	(optional) Reference point to use for determining distance when
-		 *						sorting.
-		 * @param	layers		(optional) Layers bitfield that can be used for controlling which shapes will be included
-		 *						in the mesh. This bitfield will be ANDed with the layer specified when recording the shape.
-		 *
-		 * @note	You must call clearMeshes() when done.
-		 */
-		void buildMeshes(SortType sorting = SortType::None, const Vector3& reference = Vector3::ZERO, 
-			UINT64 layers = 0xFFFFFFFFFFFFFFFF);
-
-		/** Returns a set of meshes that were built using the last call to buildMeshes(). */
-		const Vector<ShapeMeshData>& getMeshes() const { return mMeshes; }
-
-		/** Deallocates meshes previously built with buildMeshes(). */
-		void clearMeshes(const Vector<ShapeMeshData>& meshes);
-
-	private:
-		struct CommonData
-		{
-			Color color;
-			Matrix4 transform;
-			Vector3 center;
-			UINT64 layer;
-		};
-
-		struct CubeData : CommonData
-		{
-			Vector3 position;
-			Vector3 extents;
-		};
-
-		struct SphereData : CommonData
-		{
-			Vector3 position;
-			float radius;
-			UINT32 quality;
-		};
-
-		struct LineData : CommonData
-		{
-			Vector3 start;
-			Vector3 end;
-		};
-
-		struct LineListData : CommonData
-		{
-			Vector<Vector3> lines;
-		};
-
-		struct Rect3Data : CommonData
-		{
-			Rect3 area;
-		};
-
-		struct FrustumData : CommonData
-		{
-			Vector3 position;
-			float aspect;
-			Degree FOV;
-			float near;
-			float far;
-		};
-
-		struct ConeData : CommonData
-		{
-			Vector3 base;
-			Vector3 normal;
-			float height;
-			float radius;
-			UINT32 quality;
-		};
-
-		struct DiscData : CommonData
-		{
-			Vector3 position;
-			Vector3 normal;
-			float radius;
-			UINT32 quality;
-		};
-
-		struct ArcData : CommonData
-		{
-			Vector3 position;
-			Vector3 normal;
-			float radius;
-			Degree startAngle;
-			Degree amountAngle;
-			UINT32 quality;
-		};
-
-		struct Text2DData : CommonData
-		{
-			Vector3 position;
-			WString text;
-			HFont font;
-			UINT32 size;
-		};
-
-		static const UINT32 VERTEX_BUFFER_GROWTH;
-		static const UINT32 INDEX_BUFFER_GROWTH;
-
-		Color mColor;
-		Matrix4 mTransform;
-		UINT64 mLayer;
-
-		Vector<CubeData> mSolidCubeData;
-		Vector<CubeData> mWireCubeData;
-		Vector<SphereData> mSolidSphereData;
-		Vector<SphereData> mWireSphereData;
-		Vector<LineData> mLineData;
-		Vector<LineListData> mLineListData;
-		Vector<Rect3Data> mRect3Data;
-		Vector<FrustumData> mFrustumData;
-		Vector<ConeData> mConeData;
-		Vector<DiscData> mDiscData;
-		Vector<DiscData> mWireDiscData;
-		Vector<ArcData> mArcData;
-		Vector<ArcData> mWireArcData;
-		Vector<Text2DData> mText2DData;
-
-		Vector<ShapeMeshData> mMeshes;
-		UINT32 mNumActiveMeshes;
-
-		MeshHeapPtr mSolidMeshHeap;
-		MeshHeapPtr mWireMeshHeap;
-		MeshHeapPtr mTextMeshHeap;
-
-		VertexDataDescPtr mSolidVertexDesc;
-		VertexDataDescPtr mWireVertexDesc;
-		VertexDataDescPtr mTextVertexDesc;
-	};
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsMatrix4.h"
+#include "BsVector3.h"
+#include "BsColor.h"
+#include "BsRect3.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Utility-Engine
+	 *  @{
+	 */
+
+	/**	Helper class for immediate drawing of common geometric shapes. */
+	class BS_EXPORT DrawHelper
+	{
+	public:
+		/** Controls in what order will elements be rendered, depending on some reference point. */
+		enum class SortType
+		{
+			BackToFront,
+			FrontToBack,
+			None
+		};
+
+		/**	Type of meshes that are output by DrawHelper. */
+		enum class MeshType
+		{
+			Solid, Wire, Line, Text
+		};
+
+		/**	Container for mesh of a specific type output by the DrawHelper. */
+		struct ShapeMeshData
+		{
+			TransientMeshPtr mesh;
+			MeshType type;
+			HTexture texture;
+		};
+
+		DrawHelper();
+		~DrawHelper();
+
+		/**	Sets a color that will be used for any shapes recorded after this call. */
+		void setColor(const Color& color);
+
+		/**	Sets a transform matrix that will be used for any shapes recorded after this call. */
+		void setTransform(const Matrix4& transform);
+
+		/** Sets the layer bitfield that can be used for filtering which objects are output into the final mesh. */
+		void setLayer(UINT64 layer);
+
+		/**	Records a solid cuboid with the specified properties in the internal draw queue. */
+		void cube(const Vector3& position, const Vector3& extents);
+
+		/**	Records a solid sphere with the specified properties in the internal draw queue. */
+		void sphere(const Vector3& position, float radius, UINT32 quality = 1);
+
+		/**	Records a wireframe cube with the specified properties in the internal draw queue. */
+		void wireCube(const Vector3& position, const Vector3& extents);
+
+		/**	Records a wireframe sphere with the specified properties in the internal draw queue. */
+		void wireSphere(const Vector3& position, float radius, UINT32 quality = 10);
+
+		/**	Records a line with the specified properties in the internal draw queue. */
+		void line(const Vector3& start, const Vector3& end);
+
+		/**	
+		 * Records a list of lines in the internal draw queue. The list must contain lines as pair of vertices, starting
+		 * point followed by an end point, and so on.
+		 */
+		void lineList(const Vector<Vector3>& lines);
+
+		/**	Records a wireframe frustum with the specified properties in the internal draw queue. */
+		void frustum(const Vector3& position, float aspect, Degree FOV, float near, float far);
+
+		/**	Records a solid cone with the specified properties in the internal draw queue. */
+		void cone(const Vector3& base, const Vector3& normal, float height, float radius, UINT32 quality = 10);
+
+		/**	Records a solid disc with the specified properties in the internal draw queue. */
+		void disc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality = 10);
+
+		/**	Records a wireframe disc with the specified properties in the internal draw queue. */
+		void wireDisc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality = 10);
+
+		/**	Records a solid arc with the specified properties in the internal draw queue. */
+		void arc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, 
+			UINT32 quality = 10);
+
+		/**	Records a wireframe arc with the specified properties in the internal draw queue. */
+		void wireArc(const Vector3& position, const Vector3& normal, float radius, Degree startAngle, Degree amountAngle, 
+			UINT32 quality = 10);
+
+		/** Records a 3D mesh to be drawn as wireframe in the internal draw queue. */
+		void wireMesh(const MeshDataPtr& meshData);
+
+		/**	Records a solid rectangle with the specified properties in the internal draw queue. */
+		void rectangle(const Rect3& area);
+
+		/**
+		 * Records a mesh representing 2D text with the specified properties in the internal draw queue. 
+		 *
+		 * @param[in]	position	Position to render the text at. Text will be centered around this point.
+		 * @param[in]	text		Text to draw.
+		 * @param[in]	font		Font to use for rendering the text's characters.
+		 * @param[in]	size		Size of the characters, in points.
+		 */
+		void text(const Vector3& position, const WString& text, const HFont& font, UINT32 size = 10);
+
+		/**	Clears all recorded shapes. */
+		void clear();
+
+		/**
+		 * Generates a set of meshes from all the recorded solid and wireframe shapes. The meshes can be accessed via 
+		 * getMeshes() and released via clearMeshes().
+		 *
+		 * @param	sorting		(optional) Determines how (and if) should elements be sorted
+		 *						based on their distance from the reference point.
+		 * @param	reference	(optional) Reference point to use for determining distance when
+		 *						sorting.
+		 * @param	layers		(optional) Layers bitfield that can be used for controlling which shapes will be included
+		 *						in the mesh. This bitfield will be ANDed with the layer specified when recording the shape.
+		 *
+		 * @note	You must call clearMeshes() when done.
+		 */
+		void buildMeshes(SortType sorting = SortType::None, const Vector3& reference = Vector3::ZERO, 
+			UINT64 layers = 0xFFFFFFFFFFFFFFFF);
+
+		/** Returns a set of meshes that were built using the last call to buildMeshes(). */
+		const Vector<ShapeMeshData>& getMeshes() const { return mMeshes; }
+
+		/** Deallocates meshes previously built with buildMeshes(). */
+		void clearMeshes(const Vector<ShapeMeshData>& meshes);
+
+	private:
+		struct CommonData
+		{
+			Color color;
+			Matrix4 transform;
+			Vector3 center;
+			UINT64 layer;
+		};
+
+		struct CubeData : CommonData
+		{
+			Vector3 position;
+			Vector3 extents;
+		};
+
+		struct SphereData : CommonData
+		{
+			Vector3 position;
+			float radius;
+			UINT32 quality;
+		};
+
+		struct LineData : CommonData
+		{
+			Vector3 start;
+			Vector3 end;
+		};
+
+		struct LineListData : CommonData
+		{
+			Vector<Vector3> lines;
+		};
+
+		struct Rect3Data : CommonData
+		{
+			Rect3 area;
+		};
+
+		struct FrustumData : CommonData
+		{
+			Vector3 position;
+			float aspect;
+			Degree FOV;
+			float near;
+			float far;
+		};
+
+		struct ConeData : CommonData
+		{
+			Vector3 base;
+			Vector3 normal;
+			float height;
+			float radius;
+			UINT32 quality;
+		};
+
+		struct DiscData : CommonData
+		{
+			Vector3 position;
+			Vector3 normal;
+			float radius;
+			UINT32 quality;
+		};
+
+		struct ArcData : CommonData
+		{
+			Vector3 position;
+			Vector3 normal;
+			float radius;
+			Degree startAngle;
+			Degree amountAngle;
+			UINT32 quality;
+		};
+
+		struct Text2DData : CommonData
+		{
+			Vector3 position;
+			WString text;
+			HFont font;
+			UINT32 size;
+		};
+
+		struct WireMeshData : CommonData
+		{
+			MeshDataPtr meshData;
+		};
+
+		static const UINT32 VERTEX_BUFFER_GROWTH;
+		static const UINT32 INDEX_BUFFER_GROWTH;
+
+		Color mColor;
+		Matrix4 mTransform;
+		UINT64 mLayer;
+
+		Vector<CubeData> mSolidCubeData;
+		Vector<CubeData> mWireCubeData;
+		Vector<SphereData> mSolidSphereData;
+		Vector<SphereData> mWireSphereData;
+		Vector<LineData> mLineData;
+		Vector<LineListData> mLineListData;
+		Vector<Rect3Data> mRect3Data;
+		Vector<FrustumData> mFrustumData;
+		Vector<ConeData> mConeData;
+		Vector<DiscData> mDiscData;
+		Vector<DiscData> mWireDiscData;
+		Vector<ArcData> mArcData;
+		Vector<ArcData> mWireArcData;
+		Vector<Text2DData> mText2DData;
+		Vector<WireMeshData> mWireMeshData;
+
+		Vector<ShapeMeshData> mMeshes;
+		UINT32 mNumActiveMeshes;
+
+		MeshHeapPtr mSolidMeshHeap;
+		MeshHeapPtr mWireMeshHeap;
+		MeshHeapPtr mLineMeshHeap;
+		MeshHeapPtr mTextMeshHeap;
+
+		VertexDataDescPtr mSolidVertexDesc;
+		VertexDataDescPtr mWireVertexDesc;
+		VertexDataDescPtr mLineVertexDesc;
+		VertexDataDescPtr mTextVertexDesc;
+	};
+
+	/** @} */
 }

+ 1161 - 1060
Source/BansheeEngine/Source/BsDrawHelper.cpp

@@ -1,1061 +1,1162 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsDrawHelper.h"
-#include "BsMesh.h"
-#include "BsAABox.h"
-#include "BsSphere.h"
-#include "BsVertexDataDesc.h"
-#include "BsMeshHeap.h"
-#include "BsShapeMeshes3D.h"
-#include "BsTextData.h"
-#include "BsVector2.h"
-#include "BsQuaternion.h"
-
-namespace BansheeEngine
-{
-	const UINT32 DrawHelper::VERTEX_BUFFER_GROWTH = 4096;
-	const UINT32 DrawHelper::INDEX_BUFFER_GROWTH = 4096 * 2;
-
-	DrawHelper::DrawHelper()
-		:mLayer(1), mNumActiveMeshes(0)
-	{
-		mTransform = Matrix4::IDENTITY;
-
-		mSolidVertexDesc = bs_shared_ptr_new<VertexDataDesc>();
-		mSolidVertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
-		mSolidVertexDesc->addVertElem(VET_FLOAT3, VES_NORMAL);
-		mSolidVertexDesc->addVertElem(VET_COLOR, VES_COLOR);
-
-		mWireVertexDesc = bs_shared_ptr_new<VertexDataDesc>();
-		mWireVertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
-		mWireVertexDesc->addVertElem(VET_COLOR, VES_COLOR);
-
-		mTextVertexDesc = bs_shared_ptr_new<VertexDataDesc>();
-		mTextVertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
-		mTextVertexDesc->addVertElem(VET_FLOAT2, VES_TEXCOORD);
-		mTextVertexDesc->addVertElem(VET_COLOR, VES_COLOR);
-
-		mSolidMeshHeap = MeshHeap::create(VERTEX_BUFFER_GROWTH, INDEX_BUFFER_GROWTH, mSolidVertexDesc);
-		mWireMeshHeap = MeshHeap::create(VERTEX_BUFFER_GROWTH, INDEX_BUFFER_GROWTH, mWireVertexDesc);
-		mTextMeshHeap = MeshHeap::create(VERTEX_BUFFER_GROWTH, INDEX_BUFFER_GROWTH, mTextVertexDesc);
-	}
-
-	DrawHelper::~DrawHelper()
-	{
-		BS_ASSERT(mNumActiveMeshes == 0 && "Not all DrawHelper meshes were freed on shutdown.");
-	}
-
-	void DrawHelper::setColor(const Color& color)
-	{
-		mColor = color;
-	}
-
-	void DrawHelper::setTransform(const Matrix4& transform)
-	{
-		mTransform = transform;
-	}
-
-	void DrawHelper::setLayer(UINT64 layer)
-	{
-		mLayer = layer;
-	}
-
-	void DrawHelper::cube(const Vector3& position, const Vector3& extents)
-	{
-		mSolidCubeData.push_back(CubeData());
-		CubeData& cubeData = mSolidCubeData.back();
-
-		cubeData.position = position;
-		cubeData.extents = extents;
-		cubeData.color = mColor;
-		cubeData.transform = mTransform;
-		cubeData.layer = mLayer;
-		cubeData.center = mTransform.multiplyAffine(position);
-	}
-
-	void DrawHelper::sphere(const Vector3& position, float radius, UINT32 quality)
-	{
-		mSolidSphereData.push_back(SphereData());
-		SphereData& sphereData = mSolidSphereData.back();
-
-		sphereData.position = position;
-		sphereData.radius = radius;
-		sphereData.quality = quality;
-		sphereData.color = mColor;
-		sphereData.transform = mTransform;
-		sphereData.layer = mLayer;
-		sphereData.center = mTransform.multiplyAffine(position);
-	}
-
-	void DrawHelper::wireCube(const Vector3& position, const Vector3& extents)
-	{
-		mWireCubeData.push_back(CubeData());
-		CubeData& cubeData = mWireCubeData.back();
-
-		cubeData.position = position;
-		cubeData.extents = extents;
-		cubeData.color = mColor;
-		cubeData.transform = mTransform;
-		cubeData.layer = mLayer;
-		cubeData.center = mTransform.multiplyAffine(position);
-	}
-
-	void DrawHelper::wireSphere(const Vector3& position, float radius, UINT32 quality)
-	{
-		mWireSphereData.push_back(SphereData());
-		SphereData& sphereData = mWireSphereData.back();
-
-		sphereData.position = position;
-		sphereData.radius = radius;
-		sphereData.quality = quality;
-		sphereData.color = mColor;
-		sphereData.transform = mTransform;
-		sphereData.layer = mLayer;
-		sphereData.center = mTransform.multiplyAffine(position);
-	}
-
-	void DrawHelper::line(const Vector3& start, const Vector3& end)
-	{
-		mLineData.push_back(LineData());
-		LineData& lineData = mLineData.back();
-
-		lineData.start = start;
-		lineData.end = end;
-		lineData.color = mColor;
-		lineData.transform = mTransform;
-		lineData.layer = mLayer;
-		lineData.center = mTransform.multiplyAffine((start + end) * 0.5f);
-	}
-
-	void DrawHelper::lineList(const Vector<Vector3>& lines)
-	{
-		if (lines.size() < 2)
-			return;
-
-		mLineListData.push_back(LineListData());
-		LineListData& lineListData = mLineListData.back();
-
-		Vector3 center;
-		for (auto& point : lines)
-			center += point;
-
-		lineListData.lines = lines;
-		lineListData.color = mColor;
-		lineListData.transform = mTransform;
-		lineListData.layer = mLayer;
-		lineListData.center = center / (float)lines.size();;
-	}
-
-	void DrawHelper::frustum(const Vector3& position, float aspect, Degree FOV, float near, float far)
-	{
-		mFrustumData.push_back(FrustumData());
-		FrustumData& frustumData = mFrustumData.back();
-
-		frustumData.position = position;
-		frustumData.aspect = aspect;
-		frustumData.FOV = FOV;
-		frustumData.near = near;
-		frustumData.far = far;
-		frustumData.color = mColor;
-		frustumData.transform = mTransform;
-		frustumData.layer = mLayer;
-		frustumData.center = mTransform.multiplyAffine(position);
-	}
-
-	void DrawHelper::cone(const Vector3& base, const Vector3& normal, float height, float radius, UINT32 quality)
-	{
-		mConeData.push_back(ConeData());
-		ConeData& coneData = mConeData.back();
-
-		coneData.base = base;
-		coneData.normal = normal;
-		coneData.height = height;
-		coneData.radius = radius;
-		coneData.quality = quality;
-		coneData.color = mColor;
-		coneData.transform = mTransform;
-		coneData.layer = mLayer;
-		coneData.center = mTransform.multiplyAffine(base + normal * height * 0.5f);
-	}
-
-	void DrawHelper::disc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality)
-	{
-		mDiscData.push_back(DiscData());
-		DiscData& discData = mDiscData.back();
-
-		discData.position = position;
-		discData.normal = normal;
-		discData.radius = radius;
-		discData.quality = quality;
-		discData.color = mColor;
-		discData.transform = mTransform;
-		discData.layer = mLayer;
-		discData.center = mTransform.multiplyAffine(position);
-	}
-
-	void DrawHelper::wireDisc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality)
-	{
-		mWireDiscData.push_back(DiscData());
-		DiscData& discData = mWireDiscData.back();
-
-		discData.position = position;
-		discData.normal = normal;
-		discData.radius = radius;
-		discData.quality = quality;
-		discData.color = mColor;
-		discData.transform = mTransform;
-		discData.layer = mLayer;
-		discData.center = mTransform.multiplyAffine(position);
-	}
-
-	void DrawHelper::arc(const Vector3& position, const Vector3& normal, float radius, 
-		Degree startAngle, Degree amountAngle, UINT32 quality)
-	{
-		mArcData.push_back(ArcData());
-		ArcData& arcData = mArcData.back();
-
-		arcData.position = position;
-		arcData.normal = normal;
-		arcData.radius = radius;
-		arcData.startAngle = startAngle;
-		arcData.amountAngle = amountAngle;
-		arcData.quality = quality;
-		arcData.color = mColor;
-		arcData.transform = mTransform;
-		arcData.layer = mLayer;
-		arcData.center = mTransform.multiplyAffine(position);
-	}
-
-	void DrawHelper::wireArc(const Vector3& position, const Vector3& normal, float radius, 
-		Degree startAngle, Degree amountAngle, UINT32 quality)
-	{
-		mWireArcData.push_back(ArcData());
-		ArcData& arcData = mWireArcData.back();
-
-		arcData.position = position;
-		arcData.normal = normal;
-		arcData.radius = radius;
-		arcData.startAngle = startAngle;
-		arcData.amountAngle = amountAngle;
-		arcData.quality = quality;
-		arcData.color = mColor;
-		arcData.transform = mTransform;
-		arcData.layer = mLayer;
-		arcData.center = mTransform.multiplyAffine(position);
-	}
-
-	void DrawHelper::rectangle(const Rect3& area)
-	{
-		mRect3Data.push_back(Rect3Data());
-		Rect3Data& rectData = mRect3Data.back();
-
-		rectData.area = area;
-		rectData.color = mColor;
-		rectData.transform = mTransform;
-		rectData.layer = mLayer;
-		rectData.center = mTransform.multiplyAffine(area.getCenter());
-	}
-
-	void DrawHelper::text(const Vector3& position, const WString& text, const HFont& font, UINT32 size)
-	{
-		if (!font.isLoaded() || text.empty())
-			return;
-
-		mText2DData.push_back(Text2DData());
-		Text2DData& textData = mText2DData.back();
-
-		textData.position = position;
-		textData.color = mColor;
-		textData.transform = mTransform;
-		textData.layer = mLayer;
-		textData.center = mTransform.multiplyAffine(position);
-		textData.text = text;
-		textData.font = font;
-		textData.size = size;
-	}
-
-	void DrawHelper::clear()
-	{
-		mSolidCubeData.clear();
-		mWireCubeData.clear();
-		mSolidSphereData.clear();
-		mWireSphereData.clear();
-		mLineData.clear();
-		mLineListData.clear();
-		mRect3Data.clear();
-		mFrustumData.clear();
-		mFrustumData.clear();
-		mDiscData.clear();
-		mWireDiscData.clear();
-		mArcData.clear();
-		mWireArcData.clear();
-		mConeData.clear();
-		mText2DData.clear();
-	}
-
-	void DrawHelper::buildMeshes(SortType sorting, const Vector3& reference, UINT64 layers)
-	{
-		mMeshes.clear();
-
-		enum class ShapeType
-		{
-			Cube, Sphere, WireCube, WireSphere, Line, LineList, Frustum, 
-			Cone, Disc, WireDisc, Arc, WireArc, Rectangle, Text
-		};
-
-		struct RawData
-		{
-			ShapeType shapeType;
-			MeshType meshType;
-			UINT32 idx;
-			UINT32 textIdx;
-			float distance;
-			UINT32 numVertices;
-			UINT32 numIndices;
-		};
-
-		/************************************************************************/
-		/* 			Sort everything according to specified sorting rule         */
-		/************************************************************************/
-
-		UINT32 idx = 0;
-		Vector<RawData> allShapes;
-
-		UINT32 localIdx = 0;
-		for (auto& shapeData : mSolidCubeData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Solid;
-			rawData.shapeType = ShapeType::Cube;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsAABox(rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mSolidSphereData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Solid;
-			rawData.shapeType = ShapeType::Sphere;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsSphere(shapeData.quality, 
-				rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mConeData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Solid;
-			rawData.shapeType = ShapeType::Cone;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsCone(shapeData.quality, 
-				rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mDiscData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Solid;
-			rawData.shapeType = ShapeType::Disc;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsDisc(shapeData.quality,
-				rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mArcData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Solid;
-			rawData.shapeType = ShapeType::Arc;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsArc(shapeData.quality, 
-				rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mRect3Data)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Solid;
-			rawData.shapeType = ShapeType::Rectangle;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsQuad(rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mWireCubeData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Wire;
-			rawData.shapeType = ShapeType::WireCube;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsWireAABox(rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mWireSphereData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Wire;
-			rawData.shapeType = ShapeType::WireSphere;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsWireSphere(shapeData.quality,
-				rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mLineData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Wire;
-			rawData.shapeType = ShapeType::Line;
-			rawData.distance = shapeData.center.distance(reference);
-			rawData.numVertices = 2;
-			rawData.numIndices = 2;
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mLineListData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			UINT32 numLines = (UINT32)shapeData.lines.size() / 2;
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Wire;
-			rawData.shapeType = ShapeType::LineList;
-			rawData.distance = shapeData.center.distance(reference);
-			rawData.numVertices = numLines * 2;
-			rawData.numIndices = numLines * 2;
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mFrustumData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Wire;
-			rawData.shapeType = ShapeType::Frustum;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsFrustum(rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mWireDiscData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Wire;
-			rawData.shapeType = ShapeType::WireDisc;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsWireDisc(shapeData.quality, 
-				rawData.numVertices, rawData.numIndices);
-		}
-
-		localIdx = 0;
-		for (auto& shapeData : mWireArcData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			allShapes.push_back(RawData());
-			RawData& rawData = allShapes.back();
-
-			rawData.idx = localIdx++;
-			rawData.textIdx = 0;
-			rawData.meshType = MeshType::Wire;
-			rawData.shapeType = ShapeType::WireArc;
-			rawData.distance = shapeData.center.distance(reference);
-
-			ShapeMeshes3D::getNumElementsWireArc(shapeData.quality,
-				rawData.numVertices, rawData.numIndices);
-		}
-
-		struct TextRenderData
-		{
-			UINT32 page;
-			SPtr<TextData<>> textData;
-		};
-
-		UnorderedMap<UINT32, TextRenderData> textRenderData;
-		UINT32 textIdx = 0;
-
-		localIdx = 0;
-		for (auto& shapeData : mText2DData)
-		{
-			if ((shapeData.layer & layers) == 0)
-			{
-				localIdx++;
-				continue;
-			}
-
-			SPtr<TextData<>> textData = bs_shared_ptr_new<TextData<>>(shapeData.text, shapeData.font, shapeData.size);
-
-			UINT32 numPages = textData->getNumPages();
-			for (UINT32 j = 0; j < numPages; j++)
-			{
-				UINT32 numQuads = textData->getNumQuadsForPage(j);
-
-				allShapes.push_back(RawData());
-				RawData& rawData = allShapes.back();
-
-				rawData.idx = localIdx;
-				rawData.textIdx = textIdx;
-				rawData.meshType = MeshType::Text;
-				rawData.shapeType = ShapeType::Text;
-				rawData.distance = shapeData.center.distance(reference);
-				rawData.numVertices = numQuads * 4; 
-				rawData.numIndices = numQuads * 6;
-
-				TextRenderData& renderData = textRenderData[textIdx];
-				renderData.page = j;
-				renderData.textData = textData;
-
-				textIdx++;
-				idx++;
-			}
-
-			localIdx++;
-		}
-
-		if (sorting == SortType::FrontToBack)
-		{
-			std::sort(begin(allShapes), end(allShapes),
-				[&](const RawData& x, const RawData& y)
-			{
-				return x.distance < y.distance;
-			});
-		}
-		else if (sorting == SortType::BackToFront)
-		{
-			std::sort(begin(allShapes), end(allShapes),
-				[&](const RawData& x, const RawData& y)
-			{
-				return y.distance < x.distance;
-			});
-		}
-
-		/************************************************************************/
-		/* 							Create batches                      		*/
-		/************************************************************************/
-		struct Batch
-		{
-			MeshType type;
-			HTexture texture;
-			UINT32 startIdx;
-			UINT32 endIdx;
-			UINT32 numVertices;
-			UINT32 numIndices;
-		};
-
-		UINT32 numShapes = (UINT32)allShapes.size();
-
-		Vector<Batch> batches;
-		if (numShapes > 0)
-		{
-			batches.push_back(Batch());
-
-			{
-				Batch& currentBatch = batches.back();
-				currentBatch.startIdx = 0;
-				currentBatch.type = allShapes[0].meshType;
-				currentBatch.numVertices = allShapes[0].numVertices;
-				currentBatch.numIndices = allShapes[0].numIndices;
-
-				if (allShapes[0].meshType == MeshType::Text)
-				{
-					TextRenderData& renderData = textRenderData[allShapes[0].textIdx];
-					currentBatch.texture = renderData.textData->getTextureForPage(renderData.page);
-				}
-			}
-
-			for (UINT32 i = 1; i < numShapes; i++)
-			{
-				Batch& currentBatch = batches.back();
-
-				HTexture texture;
-				if (allShapes[i].meshType == MeshType::Text)
-				{
-					TextRenderData& renderData = textRenderData[allShapes[i].textIdx];
-					texture = renderData.textData->getTextureForPage(renderData.page);
-				}
-
-				bool startNewBatch = allShapes[i].meshType != currentBatch.type || texture != currentBatch.texture;
-				if (startNewBatch)
-				{
-					currentBatch.endIdx = i - 1;
-
-					batches.push_back(Batch());
-
-					Batch& newBatch = batches.back();
-					newBatch.startIdx = i;
-					newBatch.type = allShapes[i].meshType;
-					newBatch.numVertices = allShapes[i].numVertices;
-					newBatch.numIndices = allShapes[i].numIndices;
-					newBatch.texture = texture;
-				}
-				else
-				{
-					currentBatch.endIdx = i;
-					currentBatch.numVertices += allShapes[i].numVertices;
-					currentBatch.numIndices += allShapes[i].numIndices;
-				}
-			}
-
-			{
-				Batch& currentBatch = batches.back();
-				currentBatch.endIdx = numShapes - 1;
-			}
-		}
-
-		/************************************************************************/
-		/* 					Generate geometry for each batch                    */
-		/************************************************************************/
-		for (auto& batch : batches)
-		{
-			if (batch.type == MeshType::Solid)
-			{
-				MeshDataPtr meshData = bs_shared_ptr_new<MeshData>(batch.numVertices, batch.numIndices, mSolidVertexDesc);
-
-				UINT32 curVertexOffset = 0;
-				UINT32 curIndexOffet = 0;
-
-				auto positionIter = meshData->getVec3DataIter(VES_POSITION);
-				auto normalIter = meshData->getVec3DataIter(VES_NORMAL);
-				auto colorIter = meshData->getDWORDDataIter(VES_COLOR);
-
-				for (UINT32 i = batch.startIdx; i <= batch.endIdx; i++)
-				{
-					RawData& shapeData = allShapes[i];
-
-					Matrix4* transform = nullptr;
-					RGBA color = 0;
-
-					switch (shapeData.shapeType)
-					{
-					case ShapeType::Cube:
-					{
-						CubeData& cubeData = mSolidCubeData[shapeData.idx];
-						AABox box(cubeData.position - cubeData.extents, cubeData.position + cubeData.extents);
-						ShapeMeshes3D::solidAABox(box, meshData, curVertexOffset, curIndexOffet);
-
-						transform = &cubeData.transform;
-						color = cubeData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::Sphere:
-					{
-						SphereData& sphereData = mSolidSphereData[shapeData.idx];
-						Sphere sphere(sphereData.position, sphereData.radius);
-						ShapeMeshes3D::solidSphere(sphere, meshData, curVertexOffset, curIndexOffet, sphereData.quality);
-
-						transform = &sphereData.transform;
-						color = sphereData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::Cone:
-					{
-						ConeData& coneData = mConeData[shapeData.idx];
-						ShapeMeshes3D::solidCone(coneData.base, coneData.normal, coneData.height, coneData.radius,
-							meshData, curVertexOffset, curIndexOffet, coneData.quality);
-
-						transform = &coneData.transform;
-						color = coneData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::Disc:
-					{
-						DiscData& discData = mDiscData[shapeData.idx];
-						ShapeMeshes3D::solidDisc(discData.position, discData.radius, discData.normal,
-							meshData, curVertexOffset, curIndexOffet, discData.quality);
-
-						transform = &discData.transform;
-						color = discData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::Arc:
-					{
-						ArcData& arcData = mArcData[shapeData.idx];
-						ShapeMeshes3D::solidArc(arcData.position, arcData.radius, arcData.normal,
-							arcData.startAngle, arcData.amountAngle, meshData, curVertexOffset, curIndexOffet, arcData.quality);
-
-						transform = &arcData.transform;
-						color = arcData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::Rectangle:
-					{
-						Rect3Data rectData = mRect3Data[shapeData.idx];
-						ShapeMeshes3D::solidQuad(rectData.area, meshData, curVertexOffset, curIndexOffet);
-
-						transform = &rectData.transform;
-						color = rectData.color.getAsRGBA();
-					}
-						break;
-					}
-
-					Matrix4 transformIT = transform->inverseAffine().transpose();
-					for (UINT32 i = 0; i < shapeData.numVertices; i++)
-					{
-						Vector3 worldPos = transform->multiplyAffine(positionIter.getValue());
-						Vector3 worldNormal = transformIT.multiplyAffine(normalIter.getValue());
-
-						positionIter.addValue(worldPos);
-						normalIter.addValue(worldNormal);
-						colorIter.addValue(color);
-					}
-
-					curVertexOffset += shapeData.numVertices;
-					curIndexOffet += shapeData.numIndices;
-				}
-
-				mMeshes.push_back(ShapeMeshData());
-				ShapeMeshData& newMesh = mMeshes.back();
-				newMesh.mesh = mSolidMeshHeap->alloc(meshData, DOT_TRIANGLE_LIST);
-				newMesh.type = MeshType::Solid;
-			}
-			else if(batch.type == MeshType::Wire)
-			{
-				MeshDataPtr meshData = bs_shared_ptr_new<MeshData>(batch.numVertices,
-					batch.numIndices, mWireVertexDesc);
-
-				UINT32 curVertexOffset = 0;
-				UINT32 curIndexOffet = 0;
-
-				auto positionIter = meshData->getVec3DataIter(VES_POSITION);
-				auto colorIter = meshData->getDWORDDataIter(VES_COLOR);
-
-				for (UINT32 i = batch.startIdx; i <= batch.endIdx; i++)
-				{
-					RawData& shapeData = allShapes[i];
-
-					Matrix4* transform = nullptr;
-					RGBA color = 0;
-
-					switch (shapeData.shapeType)
-					{
-					case ShapeType::WireCube:
-					{
-						CubeData& cubeData = mWireCubeData[shapeData.idx];
-
-						AABox box(cubeData.position - cubeData.extents, cubeData.position + cubeData.extents);
-						ShapeMeshes3D::wireAABox(box, meshData, curVertexOffset, curIndexOffet);
-
-						transform = &cubeData.transform;
-						color = cubeData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::WireSphere:
-					{
-						SphereData& sphereData = mWireSphereData[shapeData.idx];
-
-						Sphere sphere(sphereData.position, sphereData.radius);
-						ShapeMeshes3D::wireSphere(sphere, meshData, curVertexOffset, curIndexOffet, sphereData.quality);
-
-						transform = &sphereData.transform;
-						color = sphereData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::Line:
-					{
-						LineData& lineData = mLineData[shapeData.idx];
-
-						ShapeMeshes3D::pixelLine(lineData.start, lineData.end, meshData, curVertexOffset, curIndexOffet);
-
-						transform = &lineData.transform;
-						color = lineData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::LineList:
-					{
-						LineListData& lineListData = mLineListData[shapeData.idx];
-
-						ShapeMeshes3D::pixelLineList(lineListData.lines, meshData, curVertexOffset, curIndexOffet);
-
-						transform = &lineListData.transform;
-						color = lineListData.color.getAsRGBA();
-					}
-					break;
-					case ShapeType::Frustum:
-					{
-						FrustumData& frustumData = mFrustumData[shapeData.idx];
-
-						ShapeMeshes3D::wireFrustum(frustumData.position, frustumData.aspect, frustumData.FOV, frustumData.near,
-							frustumData.far, meshData, curVertexOffset, curIndexOffet);
-
-						transform = &frustumData.transform;
-						color = frustumData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::WireDisc:
-					{
-						DiscData& discData = mWireDiscData[shapeData.idx];
-
-						ShapeMeshes3D::wireDisc(discData.position, discData.radius, discData.normal,
-							meshData, curVertexOffset, curIndexOffet, discData.quality);
-
-						transform = &discData.transform;
-						color = discData.color.getAsRGBA();
-					}
-						break;
-					case ShapeType::WireArc:
-					{
-						ArcData& arcData = mWireArcData[shapeData.idx];
-
-						ShapeMeshes3D::wireArc(arcData.position, arcData.radius, arcData.normal,
-							arcData.startAngle, arcData.amountAngle, meshData, curVertexOffset, curIndexOffet, arcData.quality);
-
-						transform = &arcData.transform;
-						color = arcData.color.getAsRGBA();
-					}
-						break;
-					}
-
-					for (UINT32 i = 0; i < shapeData.numVertices; i++)
-					{
-						Vector3 worldPos = transform->multiplyAffine(positionIter.getValue());
-
-						positionIter.addValue(worldPos);
-						colorIter.addValue(color);
-					}
-
-					curVertexOffset += shapeData.numVertices;
-					curIndexOffet += shapeData.numIndices;
-				}
-
-				mMeshes.push_back(ShapeMeshData());
-				ShapeMeshData& newMesh = mMeshes.back();
-				newMesh.mesh = mWireMeshHeap->alloc(meshData, DOT_LINE_LIST);
-				newMesh.type = MeshType::Wire;
-			}
-			else // Text
-			{
-				MeshDataPtr meshData = bs_shared_ptr_new<MeshData>(batch.numVertices,
-					batch.numIndices, mTextVertexDesc);
-
-				UINT32 curVertexOffset = 0;
-				UINT32 curIndexOffet = 0;
-
-				auto positionIter = meshData->getVec3DataIter(VES_POSITION);
-				auto uvIter = meshData->getVec2DataIter(VES_TEXCOORD);
-				auto colorIter = meshData->getDWORDDataIter(VES_COLOR);
-
-				for (UINT32 i = batch.startIdx; i <= batch.endIdx; i++)
-				{
-					RawData& shapeData = allShapes[i];
-					Text2DData& text2DData = mText2DData[shapeData.idx];
-
-					TextRenderData& renderData = textRenderData[shapeData.textIdx];
-					UINT32 numQuads = renderData.textData->getNumQuadsForPage(renderData.page);
-
-					UINT32* indices = meshData->getIndices32();
-
-					// Note: Need temporary buffers because TextLine doesn't support arbitrary vertex stride. Eventually
-					// that should be supported (should be almost trivial to implement)
-					Vector2* tempVertices = bs_stack_alloc<Vector2>(shapeData.numVertices);
-					Vector2* tempUVs = bs_stack_alloc<Vector2>(shapeData.numVertices);
-
-					UINT32 numLines = renderData.textData->getNumLines();
-					UINT32 quadOffset = 0;
-					for (UINT32 j = 0; j < numLines; j++)
-					{
-						const TextDataBase::TextLine& line = renderData.textData->getLine(j);
-						UINT32 writtenQuads = line.fillBuffer(renderData.page, tempVertices, tempUVs, indices, quadOffset, numQuads);
-
-						quadOffset += writtenQuads;
-					}
-
-					Vector3 translation = text2DData.transform.getTranslation();
-					
-					Vector2 accum;
-					for (UINT32 j = 0; j < shapeData.numVertices; j++)
-						accum += tempVertices[j];
-
-					Vector2 center2D = accum / (float)shapeData.numVertices;
-					Vector3 lookAt = Vector3::normalize(reference - translation);
-
-					Quaternion rotation;
-					rotation.lookRotation(lookAt, Vector3::UNIT_Y);
-
-					float scale = translation.distance(reference) * 0.0025f; // 0.0025 = arbitrary scale to make the text look okay in world space
-
-					// Scale by negative because we want to flip the vertices (they're upside down because GUI shader expects them as such)
-					Matrix4 transform = Matrix4::TRS(translation, rotation, Vector3::ONE);
-
-					for (UINT32 j = 0; j < shapeData.numVertices; j++)
-					{
-						Vector2 localPos2D = tempVertices[j] - center2D;
-						localPos2D = localPos2D * -scale;
-
-						Vector3 localPos(localPos2D.x, localPos2D.y, 0.0f);
-						Vector3 worldPos = transform.multiplyAffine(localPos);
-
-						positionIter.addValue(worldPos);
-						uvIter.addValue(tempUVs[j]);
-						colorIter.addValue(text2DData.color.getAsRGBA());
-					}
-
-					bs_stack_free(tempUVs);
-					bs_stack_free(tempVertices);
-
-					curVertexOffset += shapeData.numVertices;
-					curIndexOffet += shapeData.numIndices;
-				}
-
-				mMeshes.push_back(ShapeMeshData());
-				ShapeMeshData& newMesh = mMeshes.back();
-				newMesh.mesh = mTextMeshHeap->alloc(meshData, DOT_TRIANGLE_LIST);
-				newMesh.type = MeshType::Text;
-				newMesh.texture = batch.texture;
-			}
-		}
-
-		mNumActiveMeshes += (UINT32)mMeshes.size();
-	}
-
-	void DrawHelper::clearMeshes(const Vector<ShapeMeshData>& meshes)
-	{
-		for (auto meshData : meshes)
-		{
-			if (meshData.type == MeshType::Solid)
-				mSolidMeshHeap->dealloc(meshData.mesh);
-			else if (meshData.type == MeshType::Wire)
-				mWireMeshHeap->dealloc(meshData.mesh);
-			else // Text
-				mTextMeshHeap->dealloc(meshData.mesh);
-		}
-
-		mNumActiveMeshes -= (UINT32)meshes.size();
-	}
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsDrawHelper.h"
+#include "BsMesh.h"
+#include "BsAABox.h"
+#include "BsSphere.h"
+#include "BsVertexDataDesc.h"
+#include "BsMeshHeap.h"
+#include "BsShapeMeshes3D.h"
+#include "BsTextData.h"
+#include "BsVector2.h"
+#include "BsQuaternion.h"
+
+namespace BansheeEngine
+{
+	const UINT32 DrawHelper::VERTEX_BUFFER_GROWTH = 4096;
+	const UINT32 DrawHelper::INDEX_BUFFER_GROWTH = 4096 * 2;
+
+	DrawHelper::DrawHelper()
+		:mLayer(1), mNumActiveMeshes(0)
+	{
+		mTransform = Matrix4::IDENTITY;
+
+		mSolidVertexDesc = bs_shared_ptr_new<VertexDataDesc>();
+		mSolidVertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
+		mSolidVertexDesc->addVertElem(VET_FLOAT3, VES_NORMAL);
+		mSolidVertexDesc->addVertElem(VET_COLOR, VES_COLOR);
+
+		mWireVertexDesc = bs_shared_ptr_new<VertexDataDesc>();
+		mWireVertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
+		mWireVertexDesc->addVertElem(VET_COLOR, VES_COLOR);
+
+		mLineVertexDesc = bs_shared_ptr_new<VertexDataDesc>();
+		mLineVertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
+		mLineVertexDesc->addVertElem(VET_COLOR, VES_COLOR);
+
+		mTextVertexDesc = bs_shared_ptr_new<VertexDataDesc>();
+		mTextVertexDesc->addVertElem(VET_FLOAT3, VES_POSITION);
+		mTextVertexDesc->addVertElem(VET_FLOAT2, VES_TEXCOORD);
+		mTextVertexDesc->addVertElem(VET_COLOR, VES_COLOR);
+
+		mSolidMeshHeap = MeshHeap::create(VERTEX_BUFFER_GROWTH, INDEX_BUFFER_GROWTH, mSolidVertexDesc);
+		mWireMeshHeap = MeshHeap::create(VERTEX_BUFFER_GROWTH, INDEX_BUFFER_GROWTH, mWireVertexDesc);
+		mLineMeshHeap = MeshHeap::create(VERTEX_BUFFER_GROWTH, INDEX_BUFFER_GROWTH, mLineVertexDesc);
+		mTextMeshHeap = MeshHeap::create(VERTEX_BUFFER_GROWTH, INDEX_BUFFER_GROWTH, mTextVertexDesc);
+	}
+
+	DrawHelper::~DrawHelper()
+	{
+		BS_ASSERT(mNumActiveMeshes == 0 && "Not all DrawHelper meshes were freed on shutdown.");
+	}
+
+	void DrawHelper::setColor(const Color& color)
+	{
+		mColor = color;
+	}
+
+	void DrawHelper::setTransform(const Matrix4& transform)
+	{
+		mTransform = transform;
+	}
+
+	void DrawHelper::setLayer(UINT64 layer)
+	{
+		mLayer = layer;
+	}
+
+	void DrawHelper::cube(const Vector3& position, const Vector3& extents)
+	{
+		mSolidCubeData.push_back(CubeData());
+		CubeData& cubeData = mSolidCubeData.back();
+
+		cubeData.position = position;
+		cubeData.extents = extents;
+		cubeData.color = mColor;
+		cubeData.transform = mTransform;
+		cubeData.layer = mLayer;
+		cubeData.center = mTransform.multiplyAffine(position);
+	}
+
+	void DrawHelper::sphere(const Vector3& position, float radius, UINT32 quality)
+	{
+		mSolidSphereData.push_back(SphereData());
+		SphereData& sphereData = mSolidSphereData.back();
+
+		sphereData.position = position;
+		sphereData.radius = radius;
+		sphereData.quality = quality;
+		sphereData.color = mColor;
+		sphereData.transform = mTransform;
+		sphereData.layer = mLayer;
+		sphereData.center = mTransform.multiplyAffine(position);
+	}
+
+	void DrawHelper::wireCube(const Vector3& position, const Vector3& extents)
+	{
+		mWireCubeData.push_back(CubeData());
+		CubeData& cubeData = mWireCubeData.back();
+
+		cubeData.position = position;
+		cubeData.extents = extents;
+		cubeData.color = mColor;
+		cubeData.transform = mTransform;
+		cubeData.layer = mLayer;
+		cubeData.center = mTransform.multiplyAffine(position);
+	}
+
+	void DrawHelper::wireSphere(const Vector3& position, float radius, UINT32 quality)
+	{
+		mWireSphereData.push_back(SphereData());
+		SphereData& sphereData = mWireSphereData.back();
+
+		sphereData.position = position;
+		sphereData.radius = radius;
+		sphereData.quality = quality;
+		sphereData.color = mColor;
+		sphereData.transform = mTransform;
+		sphereData.layer = mLayer;
+		sphereData.center = mTransform.multiplyAffine(position);
+	}
+
+	void DrawHelper::line(const Vector3& start, const Vector3& end)
+	{
+		mLineData.push_back(LineData());
+		LineData& lineData = mLineData.back();
+
+		lineData.start = start;
+		lineData.end = end;
+		lineData.color = mColor;
+		lineData.transform = mTransform;
+		lineData.layer = mLayer;
+		lineData.center = mTransform.multiplyAffine((start + end) * 0.5f);
+	}
+
+	void DrawHelper::lineList(const Vector<Vector3>& lines)
+	{
+		if (lines.size() < 2)
+			return;
+
+		mLineListData.push_back(LineListData());
+		LineListData& lineListData = mLineListData.back();
+
+		Vector3 center;
+		for (auto& point : lines)
+			center += point;
+
+		lineListData.lines = lines;
+		lineListData.color = mColor;
+		lineListData.transform = mTransform;
+		lineListData.layer = mLayer;
+		lineListData.center = center / (float)lines.size();;
+	}
+
+	void DrawHelper::frustum(const Vector3& position, float aspect, Degree FOV, float near, float far)
+	{
+		mFrustumData.push_back(FrustumData());
+		FrustumData& frustumData = mFrustumData.back();
+
+		frustumData.position = position;
+		frustumData.aspect = aspect;
+		frustumData.FOV = FOV;
+		frustumData.near = near;
+		frustumData.far = far;
+		frustumData.color = mColor;
+		frustumData.transform = mTransform;
+		frustumData.layer = mLayer;
+		frustumData.center = mTransform.multiplyAffine(position);
+	}
+
+	void DrawHelper::cone(const Vector3& base, const Vector3& normal, float height, float radius, UINT32 quality)
+	{
+		mConeData.push_back(ConeData());
+		ConeData& coneData = mConeData.back();
+
+		coneData.base = base;
+		coneData.normal = normal;
+		coneData.height = height;
+		coneData.radius = radius;
+		coneData.quality = quality;
+		coneData.color = mColor;
+		coneData.transform = mTransform;
+		coneData.layer = mLayer;
+		coneData.center = mTransform.multiplyAffine(base + normal * height * 0.5f);
+	}
+
+	void DrawHelper::disc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality)
+	{
+		mDiscData.push_back(DiscData());
+		DiscData& discData = mDiscData.back();
+
+		discData.position = position;
+		discData.normal = normal;
+		discData.radius = radius;
+		discData.quality = quality;
+		discData.color = mColor;
+		discData.transform = mTransform;
+		discData.layer = mLayer;
+		discData.center = mTransform.multiplyAffine(position);
+	}
+
+	void DrawHelper::wireDisc(const Vector3& position, const Vector3& normal, float radius, UINT32 quality)
+	{
+		mWireDiscData.push_back(DiscData());
+		DiscData& discData = mWireDiscData.back();
+
+		discData.position = position;
+		discData.normal = normal;
+		discData.radius = radius;
+		discData.quality = quality;
+		discData.color = mColor;
+		discData.transform = mTransform;
+		discData.layer = mLayer;
+		discData.center = mTransform.multiplyAffine(position);
+	}
+
+	void DrawHelper::arc(const Vector3& position, const Vector3& normal, float radius, 
+		Degree startAngle, Degree amountAngle, UINT32 quality)
+	{
+		mArcData.push_back(ArcData());
+		ArcData& arcData = mArcData.back();
+
+		arcData.position = position;
+		arcData.normal = normal;
+		arcData.radius = radius;
+		arcData.startAngle = startAngle;
+		arcData.amountAngle = amountAngle;
+		arcData.quality = quality;
+		arcData.color = mColor;
+		arcData.transform = mTransform;
+		arcData.layer = mLayer;
+		arcData.center = mTransform.multiplyAffine(position);
+	}
+
+	void DrawHelper::wireArc(const Vector3& position, const Vector3& normal, float radius, 
+		Degree startAngle, Degree amountAngle, UINT32 quality)
+	{
+		mWireArcData.push_back(ArcData());
+		ArcData& arcData = mWireArcData.back();
+
+		arcData.position = position;
+		arcData.normal = normal;
+		arcData.radius = radius;
+		arcData.startAngle = startAngle;
+		arcData.amountAngle = amountAngle;
+		arcData.quality = quality;
+		arcData.color = mColor;
+		arcData.transform = mTransform;
+		arcData.layer = mLayer;
+		arcData.center = mTransform.multiplyAffine(position);
+	}
+
+	void DrawHelper::rectangle(const Rect3& area)
+	{
+		mRect3Data.push_back(Rect3Data());
+		Rect3Data& rectData = mRect3Data.back();
+
+		rectData.area = area;
+		rectData.color = mColor;
+		rectData.transform = mTransform;
+		rectData.layer = mLayer;
+		rectData.center = mTransform.multiplyAffine(area.getCenter());
+	}
+
+	void DrawHelper::text(const Vector3& position, const WString& text, const HFont& font, UINT32 size)
+	{
+		if (!font.isLoaded() || text.empty())
+			return;
+
+		mText2DData.push_back(Text2DData());
+		Text2DData& textData = mText2DData.back();
+
+		textData.position = position;
+		textData.color = mColor;
+		textData.transform = mTransform;
+		textData.layer = mLayer;
+		textData.center = mTransform.multiplyAffine(position);
+		textData.text = text;
+		textData.font = font;
+		textData.size = size;
+	}
+
+	void DrawHelper::wireMesh(const MeshDataPtr& meshData)
+	{
+		if (meshData == nullptr)
+			return;
+
+		mWireMeshData.push_back(WireMeshData());
+		WireMeshData& wireMeshData = mWireMeshData.back();
+
+		wireMeshData.meshData = meshData;
+		wireMeshData.color = mColor;
+		wireMeshData.transform = mTransform;
+		wireMeshData.layer = mLayer;
+		wireMeshData.center = mTransform.multiplyAffine(Vector3::ZERO);
+	}
+
+	void DrawHelper::clear()
+	{
+		mSolidCubeData.clear();
+		mWireCubeData.clear();
+		mSolidSphereData.clear();
+		mWireSphereData.clear();
+		mLineData.clear();
+		mLineListData.clear();
+		mRect3Data.clear();
+		mFrustumData.clear();
+		mFrustumData.clear();
+		mDiscData.clear();
+		mWireDiscData.clear();
+		mArcData.clear();
+		mWireArcData.clear();
+		mConeData.clear();
+		mText2DData.clear();
+		mWireMeshData.clear();
+	}
+
+	void DrawHelper::buildMeshes(SortType sorting, const Vector3& reference, UINT64 layers)
+	{
+		mMeshes.clear();
+
+		enum class ShapeType
+		{
+			Cube, Sphere, WireCube, WireSphere, Line, LineList, Frustum, 
+			Cone, Disc, WireDisc, Arc, WireArc, Rectangle, Text, WireMesh
+		};
+
+		struct RawData
+		{
+			ShapeType shapeType;
+			MeshType meshType;
+			UINT32 idx;
+			UINT32 textIdx;
+			float distance;
+			UINT32 numVertices;
+			UINT32 numIndices;
+		};
+
+		/************************************************************************/
+		/* 			Sort everything according to specified sorting rule         */
+		/************************************************************************/
+
+		UINT32 idx = 0;
+		Vector<RawData> allShapes;
+
+		UINT32 localIdx = 0;
+		for (auto& shapeData : mSolidCubeData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Solid;
+			rawData.shapeType = ShapeType::Cube;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsAABox(rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mSolidSphereData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Solid;
+			rawData.shapeType = ShapeType::Sphere;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsSphere(shapeData.quality, 
+				rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mConeData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Solid;
+			rawData.shapeType = ShapeType::Cone;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsCone(shapeData.quality, 
+				rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mDiscData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Solid;
+			rawData.shapeType = ShapeType::Disc;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsDisc(shapeData.quality,
+				rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mArcData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Solid;
+			rawData.shapeType = ShapeType::Arc;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsArc(shapeData.quality, 
+				rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mRect3Data)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Solid;
+			rawData.shapeType = ShapeType::Rectangle;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsQuad(rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mWireCubeData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Line;
+			rawData.shapeType = ShapeType::WireCube;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsWireAABox(rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mWireSphereData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Line;
+			rawData.shapeType = ShapeType::WireSphere;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsWireSphere(shapeData.quality,
+				rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mLineData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Line;
+			rawData.shapeType = ShapeType::Line;
+			rawData.distance = shapeData.center.distance(reference);
+			rawData.numVertices = 2;
+			rawData.numIndices = 2;
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mLineListData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			UINT32 numLines = (UINT32)shapeData.lines.size() / 2;
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Line;
+			rawData.shapeType = ShapeType::LineList;
+			rawData.distance = shapeData.center.distance(reference);
+			rawData.numVertices = numLines * 2;
+			rawData.numIndices = numLines * 2;
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mFrustumData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Line;
+			rawData.shapeType = ShapeType::Frustum;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsFrustum(rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mWireDiscData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Line;
+			rawData.shapeType = ShapeType::WireDisc;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsWireDisc(shapeData.quality, 
+				rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mWireArcData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Line;
+			rawData.shapeType = ShapeType::WireArc;
+			rawData.distance = shapeData.center.distance(reference);
+
+			ShapeMeshes3D::getNumElementsWireArc(shapeData.quality,
+				rawData.numVertices, rawData.numIndices);
+		}
+
+		localIdx = 0;
+		for (auto& shapeData : mWireMeshData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			allShapes.push_back(RawData());
+			RawData& rawData = allShapes.back();
+
+			rawData.idx = localIdx++;
+			rawData.textIdx = 0;
+			rawData.meshType = MeshType::Wire;
+			rawData.shapeType = ShapeType::WireMesh;
+			rawData.distance = shapeData.center.distance(reference);
+			rawData.numVertices = shapeData.meshData->getNumVertices();
+			rawData.numIndices = shapeData.meshData->getNumIndices();
+		}
+
+		struct TextRenderData
+		{
+			UINT32 page;
+			SPtr<TextData<>> textData;
+		};
+
+		UnorderedMap<UINT32, TextRenderData> textRenderData;
+		UINT32 textIdx = 0;
+
+		localIdx = 0;
+		for (auto& shapeData : mText2DData)
+		{
+			if ((shapeData.layer & layers) == 0)
+			{
+				localIdx++;
+				continue;
+			}
+
+			SPtr<TextData<>> textData = bs_shared_ptr_new<TextData<>>(shapeData.text, shapeData.font, shapeData.size);
+
+			UINT32 numPages = textData->getNumPages();
+			for (UINT32 j = 0; j < numPages; j++)
+			{
+				UINT32 numQuads = textData->getNumQuadsForPage(j);
+
+				allShapes.push_back(RawData());
+				RawData& rawData = allShapes.back();
+
+				rawData.idx = localIdx;
+				rawData.textIdx = textIdx;
+				rawData.meshType = MeshType::Text;
+				rawData.shapeType = ShapeType::Text;
+				rawData.distance = shapeData.center.distance(reference);
+				rawData.numVertices = numQuads * 4; 
+				rawData.numIndices = numQuads * 6;
+
+				TextRenderData& renderData = textRenderData[textIdx];
+				renderData.page = j;
+				renderData.textData = textData;
+
+				textIdx++;
+				idx++;
+			}
+
+			localIdx++;
+		}
+
+		if (sorting == SortType::FrontToBack)
+		{
+			std::sort(begin(allShapes), end(allShapes),
+				[&](const RawData& x, const RawData& y)
+			{
+				return x.distance < y.distance;
+			});
+		}
+		else if (sorting == SortType::BackToFront)
+		{
+			std::sort(begin(allShapes), end(allShapes),
+				[&](const RawData& x, const RawData& y)
+			{
+				return y.distance < x.distance;
+			});
+		}
+
+		/************************************************************************/
+		/* 							Create batches                      		*/
+		/************************************************************************/
+		struct Batch
+		{
+			MeshType type;
+			HTexture texture;
+			UINT32 startIdx;
+			UINT32 endIdx;
+			UINT32 numVertices;
+			UINT32 numIndices;
+		};
+
+		UINT32 numShapes = (UINT32)allShapes.size();
+
+		Vector<Batch> batches;
+		if (numShapes > 0)
+		{
+			batches.push_back(Batch());
+
+			{
+				Batch& currentBatch = batches.back();
+				currentBatch.startIdx = 0;
+				currentBatch.type = allShapes[0].meshType;
+				currentBatch.numVertices = allShapes[0].numVertices;
+				currentBatch.numIndices = allShapes[0].numIndices;
+
+				if (allShapes[0].meshType == MeshType::Text)
+				{
+					TextRenderData& renderData = textRenderData[allShapes[0].textIdx];
+					currentBatch.texture = renderData.textData->getTextureForPage(renderData.page);
+				}
+			}
+
+			for (UINT32 i = 1; i < numShapes; i++)
+			{
+				Batch& currentBatch = batches.back();
+
+				HTexture texture;
+				if (allShapes[i].meshType == MeshType::Text)
+				{
+					TextRenderData& renderData = textRenderData[allShapes[i].textIdx];
+					texture = renderData.textData->getTextureForPage(renderData.page);
+				}
+
+				bool startNewBatch = allShapes[i].meshType != currentBatch.type || texture != currentBatch.texture;
+				if (startNewBatch)
+				{
+					currentBatch.endIdx = i - 1;
+
+					batches.push_back(Batch());
+
+					Batch& newBatch = batches.back();
+					newBatch.startIdx = i;
+					newBatch.type = allShapes[i].meshType;
+					newBatch.numVertices = allShapes[i].numVertices;
+					newBatch.numIndices = allShapes[i].numIndices;
+					newBatch.texture = texture;
+				}
+				else
+				{
+					currentBatch.endIdx = i;
+					currentBatch.numVertices += allShapes[i].numVertices;
+					currentBatch.numIndices += allShapes[i].numIndices;
+				}
+			}
+
+			{
+				Batch& currentBatch = batches.back();
+				currentBatch.endIdx = numShapes - 1;
+			}
+		}
+
+		/************************************************************************/
+		/* 					Generate geometry for each batch                    */
+		/************************************************************************/
+		for (auto& batch : batches)
+		{
+			if (batch.type == MeshType::Solid)
+			{
+				MeshDataPtr meshData = bs_shared_ptr_new<MeshData>(batch.numVertices, batch.numIndices, mSolidVertexDesc);
+
+				UINT32 curVertexOffset = 0;
+				UINT32 curIndexOffet = 0;
+
+				auto positionIter = meshData->getVec3DataIter(VES_POSITION);
+				auto normalIter = meshData->getVec3DataIter(VES_NORMAL);
+				auto colorIter = meshData->getDWORDDataIter(VES_COLOR);
+
+				for (UINT32 i = batch.startIdx; i <= batch.endIdx; i++)
+				{
+					RawData& shapeData = allShapes[i];
+
+					Matrix4* transform = nullptr;
+					RGBA color = 0;
+
+					switch (shapeData.shapeType)
+					{
+					case ShapeType::Cube:
+					{
+						CubeData& cubeData = mSolidCubeData[shapeData.idx];
+						AABox box(cubeData.position - cubeData.extents, cubeData.position + cubeData.extents);
+						ShapeMeshes3D::solidAABox(box, meshData, curVertexOffset, curIndexOffet);
+
+						transform = &cubeData.transform;
+						color = cubeData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::Sphere:
+					{
+						SphereData& sphereData = mSolidSphereData[shapeData.idx];
+						Sphere sphere(sphereData.position, sphereData.radius);
+						ShapeMeshes3D::solidSphere(sphere, meshData, curVertexOffset, curIndexOffet, sphereData.quality);
+
+						transform = &sphereData.transform;
+						color = sphereData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::Cone:
+					{
+						ConeData& coneData = mConeData[shapeData.idx];
+						ShapeMeshes3D::solidCone(coneData.base, coneData.normal, coneData.height, coneData.radius,
+							meshData, curVertexOffset, curIndexOffet, coneData.quality);
+
+						transform = &coneData.transform;
+						color = coneData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::Disc:
+					{
+						DiscData& discData = mDiscData[shapeData.idx];
+						ShapeMeshes3D::solidDisc(discData.position, discData.radius, discData.normal,
+							meshData, curVertexOffset, curIndexOffet, discData.quality);
+
+						transform = &discData.transform;
+						color = discData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::Arc:
+					{
+						ArcData& arcData = mArcData[shapeData.idx];
+						ShapeMeshes3D::solidArc(arcData.position, arcData.radius, arcData.normal,
+							arcData.startAngle, arcData.amountAngle, meshData, curVertexOffset, curIndexOffet, arcData.quality);
+
+						transform = &arcData.transform;
+						color = arcData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::Rectangle:
+					{
+						Rect3Data rectData = mRect3Data[shapeData.idx];
+						ShapeMeshes3D::solidQuad(rectData.area, meshData, curVertexOffset, curIndexOffet);
+
+						transform = &rectData.transform;
+						color = rectData.color.getAsRGBA();
+					}
+						break;
+					default:
+						break;
+					}
+
+					Matrix4 transformIT = transform->inverseAffine().transpose();
+					for (UINT32 i = 0; i < shapeData.numVertices; i++)
+					{
+						Vector3 worldPos = transform->multiplyAffine(positionIter.getValue());
+						Vector3 worldNormal = transformIT.multiplyAffine(normalIter.getValue());
+
+						positionIter.addValue(worldPos);
+						normalIter.addValue(worldNormal);
+						colorIter.addValue(color);
+					}
+
+					curVertexOffset += shapeData.numVertices;
+					curIndexOffet += shapeData.numIndices;
+				}
+
+				mMeshes.push_back(ShapeMeshData());
+				ShapeMeshData& newMesh = mMeshes.back();
+				newMesh.mesh = mSolidMeshHeap->alloc(meshData, DOT_TRIANGLE_LIST);
+				newMesh.type = MeshType::Solid;
+			}
+			else if (batch.type == MeshType::Wire)
+			{
+				MeshDataPtr meshData = bs_shared_ptr_new<MeshData>(batch.numVertices, batch.numIndices, mWireVertexDesc);
+
+				UINT32 curIndexOffset = 0;
+
+				auto positionIter = meshData->getVec3DataIter(VES_POSITION);
+				auto colorIter = meshData->getDWORDDataIter(VES_COLOR);
+
+				for (UINT32 i = batch.startIdx; i <= batch.endIdx; i++)
+				{
+					RawData& shapeData = allShapes[i];
+
+					Matrix4* transform = nullptr;
+					RGBA color = 0;
+
+					switch (shapeData.shapeType)
+					{
+					case ShapeType::WireMesh:
+					{
+						WireMeshData& wireMeshData = mWireMeshData[shapeData.idx];
+
+						transform = &wireMeshData.transform;
+						color = wireMeshData.color.getAsRGBA();
+
+						auto vertIterRead = wireMeshData.meshData->getVec3DataIter(VES_POSITION);
+						for (UINT32 i = 0; i < vertIterRead.getNumElements(); i++)
+						{
+							Vector3 worldPos = transform->multiplyAffine(vertIterRead.getValue());
+
+							positionIter.addValue(worldPos);
+							colorIter.addValue(color);
+
+							vertIterRead.moveNext();
+						}
+
+						UINT32* srcIndexData = wireMeshData.meshData->getIndices32();
+						UINT32* destIndexData = meshData->getIndices32() + curIndexOffset;
+
+						memcpy(destIndexData, srcIndexData, sizeof(UINT32) * shapeData.numIndices);
+						curIndexOffset += shapeData.numIndices;
+					}
+					break;
+					default:
+						break;
+					}
+
+					mMeshes.push_back(ShapeMeshData());
+					ShapeMeshData& newMesh = mMeshes.back();
+					newMesh.mesh = mWireMeshHeap->alloc(meshData, DOT_TRIANGLE_LIST);
+					newMesh.type = MeshType::Wire;
+				}
+			}
+			else if(batch.type == MeshType::Line)
+			{
+				MeshDataPtr meshData = bs_shared_ptr_new<MeshData>(batch.numVertices,
+					batch.numIndices, mLineVertexDesc);
+
+				UINT32 curVertexOffset = 0;
+				UINT32 curIndexOffet = 0;
+
+				auto positionIter = meshData->getVec3DataIter(VES_POSITION);
+				auto colorIter = meshData->getDWORDDataIter(VES_COLOR);
+
+				for (UINT32 i = batch.startIdx; i <= batch.endIdx; i++)
+				{
+					RawData& shapeData = allShapes[i];
+
+					Matrix4* transform = nullptr;
+					RGBA color = 0;
+
+					switch (shapeData.shapeType)
+					{
+					case ShapeType::WireCube:
+					{
+						CubeData& cubeData = mWireCubeData[shapeData.idx];
+
+						AABox box(cubeData.position - cubeData.extents, cubeData.position + cubeData.extents);
+						ShapeMeshes3D::wireAABox(box, meshData, curVertexOffset, curIndexOffet);
+
+						transform = &cubeData.transform;
+						color = cubeData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::WireSphere:
+					{
+						SphereData& sphereData = mWireSphereData[shapeData.idx];
+
+						Sphere sphere(sphereData.position, sphereData.radius);
+						ShapeMeshes3D::wireSphere(sphere, meshData, curVertexOffset, curIndexOffet, sphereData.quality);
+
+						transform = &sphereData.transform;
+						color = sphereData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::Line:
+					{
+						LineData& lineData = mLineData[shapeData.idx];
+
+						ShapeMeshes3D::pixelLine(lineData.start, lineData.end, meshData, curVertexOffset, curIndexOffet);
+
+						transform = &lineData.transform;
+						color = lineData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::LineList:
+					{
+						LineListData& lineListData = mLineListData[shapeData.idx];
+
+						ShapeMeshes3D::pixelLineList(lineListData.lines, meshData, curVertexOffset, curIndexOffet);
+
+						transform = &lineListData.transform;
+						color = lineListData.color.getAsRGBA();
+					}
+					break;
+					case ShapeType::Frustum:
+					{
+						FrustumData& frustumData = mFrustumData[shapeData.idx];
+
+						ShapeMeshes3D::wireFrustum(frustumData.position, frustumData.aspect, frustumData.FOV, frustumData.near,
+							frustumData.far, meshData, curVertexOffset, curIndexOffet);
+
+						transform = &frustumData.transform;
+						color = frustumData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::WireDisc:
+					{
+						DiscData& discData = mWireDiscData[shapeData.idx];
+
+						ShapeMeshes3D::wireDisc(discData.position, discData.radius, discData.normal,
+							meshData, curVertexOffset, curIndexOffet, discData.quality);
+
+						transform = &discData.transform;
+						color = discData.color.getAsRGBA();
+					}
+						break;
+					case ShapeType::WireArc:
+					{
+						ArcData& arcData = mWireArcData[shapeData.idx];
+
+						ShapeMeshes3D::wireArc(arcData.position, arcData.radius, arcData.normal,
+							arcData.startAngle, arcData.amountAngle, meshData, curVertexOffset, curIndexOffet, arcData.quality);
+
+						transform = &arcData.transform;
+						color = arcData.color.getAsRGBA();
+					}
+						break;
+					default:
+						break;
+					}
+
+					for (UINT32 i = 0; i < shapeData.numVertices; i++)
+					{
+						Vector3 worldPos = transform->multiplyAffine(positionIter.getValue());
+
+						positionIter.addValue(worldPos);
+						colorIter.addValue(color);
+					}
+
+					curVertexOffset += shapeData.numVertices;
+					curIndexOffet += shapeData.numIndices;
+				}
+
+				mMeshes.push_back(ShapeMeshData());
+				ShapeMeshData& newMesh = mMeshes.back();
+				newMesh.mesh = mLineMeshHeap->alloc(meshData, DOT_LINE_LIST);
+				newMesh.type = MeshType::Line;
+			}
+			else // Text
+			{
+				MeshDataPtr meshData = bs_shared_ptr_new<MeshData>(batch.numVertices,
+					batch.numIndices, mTextVertexDesc);
+
+				UINT32 curVertexOffset = 0;
+				UINT32 curIndexOffet = 0;
+
+				auto positionIter = meshData->getVec3DataIter(VES_POSITION);
+				auto uvIter = meshData->getVec2DataIter(VES_TEXCOORD);
+				auto colorIter = meshData->getDWORDDataIter(VES_COLOR);
+
+				for (UINT32 i = batch.startIdx; i <= batch.endIdx; i++)
+				{
+					RawData& shapeData = allShapes[i];
+					Text2DData& text2DData = mText2DData[shapeData.idx];
+
+					TextRenderData& renderData = textRenderData[shapeData.textIdx];
+					UINT32 numQuads = renderData.textData->getNumQuadsForPage(renderData.page);
+
+					UINT32* indices = meshData->getIndices32();
+
+					// Note: Need temporary buffers because TextLine doesn't support arbitrary vertex stride. Eventually
+					// that should be supported (should be almost trivial to implement)
+					Vector2* tempVertices = bs_stack_alloc<Vector2>(shapeData.numVertices);
+					Vector2* tempUVs = bs_stack_alloc<Vector2>(shapeData.numVertices);
+
+					UINT32 numLines = renderData.textData->getNumLines();
+					UINT32 quadOffset = 0;
+					for (UINT32 j = 0; j < numLines; j++)
+					{
+						const TextDataBase::TextLine& line = renderData.textData->getLine(j);
+						UINT32 writtenQuads = line.fillBuffer(renderData.page, tempVertices, tempUVs, indices, quadOffset, numQuads);
+
+						quadOffset += writtenQuads;
+					}
+
+					Vector3 translation = text2DData.transform.getTranslation();
+					
+					Vector2 accum;
+					for (UINT32 j = 0; j < shapeData.numVertices; j++)
+						accum += tempVertices[j];
+
+					Vector2 center2D = accum / (float)shapeData.numVertices;
+					Vector3 lookAt = Vector3::normalize(reference - translation);
+
+					Quaternion rotation;
+					rotation.lookRotation(lookAt, Vector3::UNIT_Y);
+
+					float scale = translation.distance(reference) * 0.0025f; // 0.0025 = arbitrary scale to make the text look okay in world space
+
+					// Scale by negative because we want to flip the vertices (they're upside down because GUI shader expects them as such)
+					Matrix4 transform = Matrix4::TRS(translation, rotation, Vector3::ONE);
+
+					for (UINT32 j = 0; j < shapeData.numVertices; j++)
+					{
+						Vector2 localPos2D = tempVertices[j] - center2D;
+						localPos2D = localPos2D * -scale;
+
+						Vector3 localPos(localPos2D.x, localPos2D.y, 0.0f);
+						Vector3 worldPos = transform.multiplyAffine(localPos);
+
+						positionIter.addValue(worldPos);
+						uvIter.addValue(tempUVs[j]);
+						colorIter.addValue(text2DData.color.getAsRGBA());
+					}
+
+					bs_stack_free(tempUVs);
+					bs_stack_free(tempVertices);
+
+					curVertexOffset += shapeData.numVertices;
+					curIndexOffet += shapeData.numIndices;
+				}
+
+				mMeshes.push_back(ShapeMeshData());
+				ShapeMeshData& newMesh = mMeshes.back();
+				newMesh.mesh = mTextMeshHeap->alloc(meshData, DOT_TRIANGLE_LIST);
+				newMesh.type = MeshType::Text;
+				newMesh.texture = batch.texture;
+			}
+		}
+
+		mNumActiveMeshes += (UINT32)mMeshes.size();
+	}
+
+	void DrawHelper::clearMeshes(const Vector<ShapeMeshData>& meshes)
+	{
+		for (auto meshData : meshes)
+		{
+			if (meshData.type == MeshType::Solid)
+				mSolidMeshHeap->dealloc(meshData.mesh);
+			if (meshData.type == MeshType::Wire)
+				mWireMeshHeap->dealloc(meshData.mesh);
+			else if (meshData.type == MeshType::Line)
+				mLineMeshHeap->dealloc(meshData.mesh);
+			else // Text
+				mTextMeshHeap->dealloc(meshData.mesh);
+		}
+
+		mNumActiveMeshes -= (UINT32)meshes.size();
+	}
 }

+ 2 - 2
Source/BansheePhysX/Source/BsPhysXMeshCollider.cpp

@@ -10,7 +10,7 @@ namespace BansheeEngine
 {
 	PhysXMeshCollider::PhysXMeshCollider(PxPhysics* physx, const Vector3& position, const Quaternion& rotation)
 	{
-		PxConvexMeshGeometry geometry;
+		PxSphereGeometry geometry(0.01f); // Dummy
 
 		PxShape* shape = physx->createShape(geometry, *gPhysX().getDefaultMaterial(), true);
 		shape->setLocalPose(toPxTransform(position, rotation));
@@ -39,7 +39,7 @@ namespace BansheeEngine
 	{
 		if (!mMesh.isLoaded())
 		{
-			PxConvexMeshGeometry geometry;
+			PxSphereGeometry geometry(0.01f); // Dummy
 			getInternal()->_getShape()->setGeometry(geometry);
 			return;
 		}

+ 250 - 234
Source/MBansheeEditor/Scene/Gizmos.cs

@@ -1,235 +1,251 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Runtime.CompilerServices;
-using BansheeEngine;
-
-namespace BansheeEditor
-{
-    /// <summary>
-    /// Provides functionality for drawing gizmos. This class should only be used in methods defined with 
-    /// <see cref="DrawGizmo"/> attribute.
-    /// </summary>
-    public class Gizmos
-    {
-        /// <summary>
-        /// Determines the color that will be used on any following draw method.
-        /// </summary>
-        public static Color Color
-        {
-            get
-            {
-                Color value;
-                Internal_GetColor(out value); 
-                return value; 
-            }
-
-            set
-            {
-                Internal_SetColor(ref value);
-            }
-        }
-
-        /// <summary>
-        /// Determines the world transform that will be applied to any following draw method.
-        /// </summary>
-        public static Matrix4 Transform
-        {
-            get
-            {
-                Matrix4 value;
-                Internal_GetTransform(out value);
-                return value; 
-            }
-
-            set
-            {
-                Internal_SetTransform(ref value);
-            }
-        }
-
-        /// <summary>
-        /// Draws an axis aligned solid cube.
-        /// </summary>
-        /// <param name="position">World coordinates of the center of the cube.</param>
-        /// <param name="extents">Extents defining the half-size of the cube in each dimension.</param>
-        public static void DrawCube(Vector3 position, Vector3 extents)
-        {
-            Internal_DrawCube(ref position, ref extents);
-        }
-
-        /// <summary>
-        /// Draws a solid sphere.
-        /// </summary>
-        /// <param name="position">World coordinates of the center of the sphere.</param>
-        /// <param name="radius">Sphere radius.</param>
-        public static void DrawSphere(Vector3 position, float radius)
-        {
-            Internal_DrawSphere(ref position, radius);
-        }
-
-        /// <summary>
-        /// Draws an axis aligned wireframe cube.
-        /// </summary>
-        /// <param name="position">World coordinates of the center of the cube.</param>
-        /// <param name="extents">Extents defining the half-size of the cube in each dimension.</param>
-        public static void DrawWireCube(Vector3 position, Vector3 extents)
-        {
-            Internal_DrawWireCube(ref position, ref extents);
-        }
-
-        /// <summary>
-        /// Draws a wireframe sphere.
-        /// </summary>
-        /// <param name="position">World coordinates of the center of the sphere.</param>
-        /// <param name="radius">Sphere radius.</param>
-        public static void DrawWireSphere(Vector3 position, float radius)
-        {
-            Internal_DrawWireSphere(ref position, radius);
-        }
-
-        /// <summary>
-        /// Draws a wireframe capsule. Capsule is assumed to be extending along the Y axis.
-        /// </summary>
-        /// <param name="position">World coordinates of the center of the capsule.</param>
-        /// <param name="height">Distance between the centers of the capsule's hemispheres.</param>
-        /// <param name="radius">Distance of each point from the capsule's center-line.</param>
-        public static void DrawWireCapsule(Vector3 position, float height, float radius)
-        {
-            Internal_DrawWireCapsule(ref position, height, radius);
-        }
-
-        /// <summary>
-        /// Draws a 3D line.
-        /// </summary>
-        /// <param name="start">Starting point for the line.</param>
-        /// <param name="end">Ending point for the line.</param>
-        public static void DrawLine(Vector3 start, Vector3 end)
-        {
-            Internal_DrawLine(ref start, ref end);
-        }
-
-        /// <summary>
-        /// Draws a list of 3D lines.
-        /// </summary>
-        /// <param name="linePoints">A list of line point pairs, start point followed by end point, and so on.</param>
-        public static void DrawLineList(Vector3[] linePoints)
-        {
-            Internal_DrawLineList(linePoints);
-        }
-
-        /// <summary>
-        /// Draws a wireframe disc.
-        /// </summary>
-        /// <param name="position">Center of the disc.</param>
-        /// <param name="normal">Normal towards which to orient the disc.</param>
-        /// <param name="radius">Radius of the disc.</param>
-        public static void DrawWireDisc(Vector3 position, Vector3 normal, float radius)
-        {
-            Internal_DrawWireDisc(ref position, ref normal, radius);
-        }
-
-        /// <summary>
-        /// Draws a wireframe arc.
-        /// </summary>
-        /// <param name="position">Center of the disc out of which the arc is cut out of.</param>
-        /// <param name="normal">Normal towards which to orient the arc.</param>
-        /// <param name="radius">Radius of the  disc out of which the arc is cut out of.</param>
-        /// <param name="startAngle">Angle at which the arc starts.</param>
-        /// <param name="amountAngle">Length of the arc.</param>
-        public static void DrawWireArc(Vector3 position, Vector3 normal, float radius, Degree startAngle, Degree amountAngle)
-        {
-            Internal_DrawWireArc(ref position, ref normal, radius, startAngle.Degrees, amountAngle.Degrees);
-        }
-
-        /// <summary>
-        /// Draws a wireframe camera frustum.
-        /// </summary>
-        /// <param name="position">Origin of the frustum (place where the camera origin would normally be).</param>
-        /// <param name="aspect">Aspect radio (width/height).</param>
-        /// <param name="FOV">Horizontal field of view.</param>
-        /// <param name="near">Distance from the origin to the near plane.</param>
-        /// <param name="far">Distance from the origin to the far plane.</param>
-        public static void DrawFrustum(Vector3 position, float aspect, Degree FOV, float near, float far)
-        {
-            Internal_DrawFrustum(ref position, aspect, ref FOV, near, far);
-        }
-
-        /// <summary>
-        /// Draws a texture as a camera-facing quad at a specific position.
-        /// </summary>
-        /// <param name="position">World position of the center of the quad the texture will be drawn on.</param>
-        /// <param name="image">Texture to draw.</param>
-        /// <param name="fixedScale">If true the icon will remain consistent size regardless of distance from camera. 
-        ///                          If false normal perspective foreshortening effect will occurr.</param>
-        public static void DrawIcon(Vector3 position, SpriteTexture image, bool fixedScale)
-        {
-            Internal_DrawIcon(ref position, image, fixedScale);
-        }
-
-        /// <summary>
-        /// Draws camera aligned text at the specified position.
-        /// </summary>
-        /// <param name="position">World position to center the text on.</param>
-        /// <param name="text">String to draw.</param>
-        /// <param name="font">Font used for drawing the characters.</param>
-        /// <param name="size">Size of the characters, in points.</param>
-        public static void DrawText(Vector3 position, string text, Font font = null, int size = 16)
-        {
-            IntPtr scriptFont = IntPtr.Zero;
-            if (font != null)
-                scriptFont = font.GetCachedPtr();
-
-            Internal_DrawText(ref position, text, scriptFont, size);
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetColor(ref Color color);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetColor(out Color color);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetTransform(ref Matrix4 transform);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetTransform(out Matrix4 transform);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawCube(ref Vector3 position, ref Vector3 extents);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawSphere(ref Vector3 position, float radius);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawWireCube(ref Vector3 position, ref Vector3 extents);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawWireSphere(ref Vector3 position, float radius);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawWireCapsule(ref Vector3 position, float height, float radius);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawLine(ref Vector3 start, ref Vector3 end);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawLineList(Vector3[] linePoints);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawWireDisc(ref Vector3 position, ref Vector3 normal, float radius);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawWireArc(ref Vector3 position, ref Vector3 normal, float radius, 
-            float startAngle, float amountAngle);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawFrustum(ref Vector3 position, float aspect, ref Degree FOV, float near, float far);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawIcon(ref Vector3 position, SpriteTexture image, bool fixedScale);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DrawText(ref Vector3 position, string text, IntPtr font, int size);
-    }
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+using System;
+using System.Runtime.CompilerServices;
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    /// <summary>
+    /// Provides functionality for drawing gizmos. This class should only be used in methods defined with 
+    /// <see cref="DrawGizmo"/> attribute.
+    /// </summary>
+    public class Gizmos
+    {
+        /// <summary>
+        /// Determines the color that will be used on any following draw method.
+        /// </summary>
+        public static Color Color
+        {
+            get
+            {
+                Color value;
+                Internal_GetColor(out value); 
+                return value; 
+            }
+
+            set
+            {
+                Internal_SetColor(ref value);
+            }
+        }
+
+        /// <summary>
+        /// Determines the world transform that will be applied to any following draw method.
+        /// </summary>
+        public static Matrix4 Transform
+        {
+            get
+            {
+                Matrix4 value;
+                Internal_GetTransform(out value);
+                return value; 
+            }
+
+            set
+            {
+                Internal_SetTransform(ref value);
+            }
+        }
+
+        /// <summary>
+        /// Draws an axis aligned solid cube.
+        /// </summary>
+        /// <param name="position">World coordinates of the center of the cube.</param>
+        /// <param name="extents">Extents defining the half-size of the cube in each dimension.</param>
+        public static void DrawCube(Vector3 position, Vector3 extents)
+        {
+            Internal_DrawCube(ref position, ref extents);
+        }
+
+        /// <summary>
+        /// Draws a solid sphere.
+        /// </summary>
+        /// <param name="position">World coordinates of the center of the sphere.</param>
+        /// <param name="radius">Sphere radius.</param>
+        public static void DrawSphere(Vector3 position, float radius)
+        {
+            Internal_DrawSphere(ref position, radius);
+        }
+
+        /// <summary>
+        /// Draws an axis aligned wireframe cube.
+        /// </summary>
+        /// <param name="position">World coordinates of the center of the cube.</param>
+        /// <param name="extents">Extents defining the half-size of the cube in each dimension.</param>
+        public static void DrawWireCube(Vector3 position, Vector3 extents)
+        {
+            Internal_DrawWireCube(ref position, ref extents);
+        }
+
+        /// <summary>
+        /// Draws a wireframe sphere.
+        /// </summary>
+        /// <param name="position">World coordinates of the center of the sphere.</param>
+        /// <param name="radius">Sphere radius.</param>
+        public static void DrawWireSphere(Vector3 position, float radius)
+        {
+            Internal_DrawWireSphere(ref position, radius);
+        }
+
+        /// <summary>
+        /// Draws a wireframe capsule. Capsule is assumed to be extending along the Y axis.
+        /// </summary>
+        /// <param name="position">World coordinates of the center of the capsule.</param>
+        /// <param name="height">Distance between the centers of the capsule's hemispheres.</param>
+        /// <param name="radius">Distance of each point from the capsule's center-line.</param>
+        public static void DrawWireCapsule(Vector3 position, float height, float radius)
+        {
+            Internal_DrawWireCapsule(ref position, height, radius);
+        }
+
+        /// <summary>
+        /// Draws a 3D line.
+        /// </summary>
+        /// <param name="start">Starting point for the line.</param>
+        /// <param name="end">Ending point for the line.</param>
+        public static void DrawLine(Vector3 start, Vector3 end)
+        {
+            Internal_DrawLine(ref start, ref end);
+        }
+
+        /// <summary>
+        /// Draws a list of 3D lines.
+        /// </summary>
+        /// <param name="linePoints">A list of line point pairs, start point followed by end point, and so on.</param>
+        public static void DrawLineList(Vector3[] linePoints)
+        {
+            Internal_DrawLineList(linePoints);
+        }
+
+        /// <summary>
+        /// Draws a wireframe disc.
+        /// </summary>
+        /// <param name="position">Center of the disc.</param>
+        /// <param name="normal">Normal towards which to orient the disc.</param>
+        /// <param name="radius">Radius of the disc.</param>
+        public static void DrawWireDisc(Vector3 position, Vector3 normal, float radius)
+        {
+            Internal_DrawWireDisc(ref position, ref normal, radius);
+        }
+
+        /// <summary>
+        /// Draws a wireframe arc.
+        /// </summary>
+        /// <param name="position">Center of the disc out of which the arc is cut out of.</param>
+        /// <param name="normal">Normal towards which to orient the arc.</param>
+        /// <param name="radius">Radius of the  disc out of which the arc is cut out of.</param>
+        /// <param name="startAngle">Angle at which the arc starts.</param>
+        /// <param name="amountAngle">Length of the arc.</param>
+        public static void DrawWireArc(Vector3 position, Vector3 normal, float radius, Degree startAngle, Degree amountAngle)
+        {
+            Internal_DrawWireArc(ref position, ref normal, radius, startAngle.Degrees, amountAngle.Degrees);
+        }
+
+        /// <summary>
+        /// Draws a wireframe mesh.
+        /// </summary>
+        /// <param name="meshData">Object containing vertices and indices of the mesh.</param>
+        public static void DrawWireMesh(MeshData meshData)
+        {
+            IntPtr meshDataPtr = IntPtr.Zero;
+            if (meshData != null)
+                meshDataPtr = meshData.GetCachedPtr();
+
+            Internal_DrawWireMesh(meshDataPtr);
+        }
+
+        /// <summary>
+        /// Draws a wireframe camera frustum.
+        /// </summary>
+        /// <param name="position">Origin of the frustum (place where the camera origin would normally be).</param>
+        /// <param name="aspect">Aspect radio (width/height).</param>
+        /// <param name="FOV">Horizontal field of view.</param>
+        /// <param name="near">Distance from the origin to the near plane.</param>
+        /// <param name="far">Distance from the origin to the far plane.</param>
+        public static void DrawFrustum(Vector3 position, float aspect, Degree FOV, float near, float far)
+        {
+            Internal_DrawFrustum(ref position, aspect, ref FOV, near, far);
+        }
+
+        /// <summary>
+        /// Draws a texture as a camera-facing quad at a specific position.
+        /// </summary>
+        /// <param name="position">World position of the center of the quad the texture will be drawn on.</param>
+        /// <param name="image">Texture to draw.</param>
+        /// <param name="fixedScale">If true the icon will remain consistent size regardless of distance from camera. 
+        ///                          If false normal perspective foreshortening effect will occurr.</param>
+        public static void DrawIcon(Vector3 position, SpriteTexture image, bool fixedScale)
+        {
+            Internal_DrawIcon(ref position, image, fixedScale);
+        }
+
+        /// <summary>
+        /// Draws camera aligned text at the specified position.
+        /// </summary>
+        /// <param name="position">World position to center the text on.</param>
+        /// <param name="text">String to draw.</param>
+        /// <param name="font">Font used for drawing the characters.</param>
+        /// <param name="size">Size of the characters, in points.</param>
+        public static void DrawText(Vector3 position, string text, Font font = null, int size = 16)
+        {
+            IntPtr scriptFont = IntPtr.Zero;
+            if (font != null)
+                scriptFont = font.GetCachedPtr();
+
+            Internal_DrawText(ref position, text, scriptFont, size);
+        }
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetColor(ref Color color);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_GetColor(out Color color);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetTransform(ref Matrix4 transform);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_GetTransform(out Matrix4 transform);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawCube(ref Vector3 position, ref Vector3 extents);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawSphere(ref Vector3 position, float radius);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawWireCube(ref Vector3 position, ref Vector3 extents);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawWireSphere(ref Vector3 position, float radius);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawWireCapsule(ref Vector3 position, float height, float radius);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawLine(ref Vector3 start, ref Vector3 end);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawLineList(Vector3[] linePoints);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawWireDisc(ref Vector3 position, ref Vector3 normal, float radius);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawWireArc(ref Vector3 position, ref Vector3 normal, float radius, 
+            float startAngle, float amountAngle);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawWireMesh(IntPtr meshData);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawFrustum(ref Vector3 position, float aspect, ref Degree FOV, float near, float far);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawIcon(ref Vector3 position, SpriteTexture image, bool fixedScale);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawText(ref Vector3 position, string text, IntPtr font, int size);
+    }
 }

+ 1 - 21
Source/MBansheeEditor/Scene/Gizmos/ColliderGizmos.cs

@@ -87,27 +87,7 @@ namespace BansheeEditor
             Gizmos.Transform = so.WorldTransform;
 
             MeshData meshData = mesh.MeshData;
-
-            int numTriangles = meshData.IndexCount/3;
-            int[] indices = meshData.Indices;
-            Vector3[] vertices = meshData.Positions;
-            Vector3[] linePoints = new Vector3[numTriangles*6];
-
-            for (int i = 0; i < numTriangles; i++)
-            {
-                int lineIdx = i*6;
-
-                linePoints[lineIdx + 0] = vertices[indices[i * 3 + 0]];
-                linePoints[lineIdx + 1] = vertices[indices[i * 3 + 1]];
-
-                linePoints[lineIdx + 2] = vertices[indices[i * 3 + 1]];
-                linePoints[lineIdx + 3] = vertices[indices[i * 3 + 2]];
-
-                linePoints[lineIdx + 4] = vertices[indices[i * 3 + 2]];
-                linePoints[lineIdx + 5] = vertices[indices[i * 3 + 0]];
-            }
-
-            Gizmos.DrawLineList(linePoints);
+            Gizmos.DrawWireMesh(meshData);
         }
 
         /// <summary>

+ 42 - 41
Source/SBansheeEditor/Include/BsScriptGizmos.h

@@ -1,42 +1,43 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsScriptEditorPrerequisites.h"
-#include "BsScriptObject.h"
-#include "BsVector3.h"
-#include "BsMatrix4.h"
-#include "BsColor.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Interop class between C++ & CLR for GizmoManager.
-	 */
-	class BS_SCR_BED_EXPORT ScriptGizmos : public ScriptObject<ScriptGizmos>
-	{
-	public:
-		SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "Gizmos")
-
-	private:
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_SetColor(Color* color);
-		static void internal_GetColor(Color* color);
-		static void internal_SetTransform(Matrix4* transform);
-		static void internal_GetTransform(Matrix4* transform);
-		static void internal_DrawCube(Vector3* position, Vector3* extents);
-		static void internal_DrawSphere(Vector3* position, float radius);
-		static void internal_DrawWireCube(Vector3* position, Vector3* extents);
-		static void internal_DrawWireSphere(Vector3* position, float radius);
-		static void internal_DrawWireCapsule(Vector3* position, float height, float radius);
-		static void internal_DrawLine(Vector3* start, Vector3* end);
-		static void internal_DrawLineList(MonoArray* linePoints);
-		static void internal_DrawWireDisc(Vector3* position, Vector3* normal, float radius);
-		static void internal_DrawWireArc(Vector3* position, Vector3* normal, float radius, float startAngle, float amountAngle);
-		static void internal_DrawFrustum(Vector3* position, float aspect, Degree* FOV, float near, float far);
-		static void internal_DrawIcon(Vector3* position, MonoObject* image, bool fixedScale);
-		static void internal_DrawText(Vector3* position, MonoString* text, ScriptFont* font, int size);
-	};
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsScriptEditorPrerequisites.h"
+#include "BsScriptObject.h"
+#include "BsVector3.h"
+#include "BsMatrix4.h"
+#include "BsColor.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Interop class between C++ & CLR for GizmoManager.
+	 */
+	class BS_SCR_BED_EXPORT ScriptGizmos : public ScriptObject<ScriptGizmos>
+	{
+	public:
+		SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "Gizmos")
+
+	private:
+		/************************************************************************/
+		/* 								CLR HOOKS						   		*/
+		/************************************************************************/
+		static void internal_SetColor(Color* color);
+		static void internal_GetColor(Color* color);
+		static void internal_SetTransform(Matrix4* transform);
+		static void internal_GetTransform(Matrix4* transform);
+		static void internal_DrawCube(Vector3* position, Vector3* extents);
+		static void internal_DrawSphere(Vector3* position, float radius);
+		static void internal_DrawWireCube(Vector3* position, Vector3* extents);
+		static void internal_DrawWireSphere(Vector3* position, float radius);
+		static void internal_DrawWireCapsule(Vector3* position, float height, float radius);
+		static void internal_DrawLine(Vector3* start, Vector3* end);
+		static void internal_DrawLineList(MonoArray* linePoints);
+		static void internal_DrawWireDisc(Vector3* position, Vector3* normal, float radius);
+		static void internal_DrawWireArc(Vector3* position, Vector3* normal, float radius, float startAngle, float amountAngle);
+		static void internal_DrawWireMesh(ScriptMeshData* meshData);
+		static void internal_DrawFrustum(Vector3* position, float aspect, Degree* FOV, float near, float far);
+		static void internal_DrawIcon(Vector3* position, MonoObject* image, bool fixedScale);
+		static void internal_DrawText(Vector3* position, MonoString* text, ScriptFont* font, int size);
+	};
 }

+ 140 - 129
Source/SBansheeEditor/Source/BsScriptGizmos.cpp

@@ -1,130 +1,141 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsScriptGizmos.h"
-#include "BsScriptMeta.h"
-#include "BsMonoClass.h"
-#include "BsScriptSpriteTexture.h"
-#include "BsGizmoManager.h"
-#include "BsMonoUtil.h"
-#include "BsScriptFont.h"
-
-namespace BansheeEngine
-{
-	void ScriptGizmos::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_SetColor", &ScriptGizmos::internal_SetColor);
-		metaData.scriptClass->addInternalCall("Internal_GetColor", &ScriptGizmos::internal_GetColor);
-		metaData.scriptClass->addInternalCall("Internal_SetTransform", &ScriptGizmos::internal_SetTransform);
-		metaData.scriptClass->addInternalCall("Internal_GetTransform", &ScriptGizmos::internal_GetTransform);
-		metaData.scriptClass->addInternalCall("Internal_DrawCube", &ScriptGizmos::internal_DrawCube);
-		metaData.scriptClass->addInternalCall("Internal_DrawSphere", &ScriptGizmos::internal_DrawSphere);
-		metaData.scriptClass->addInternalCall("Internal_DrawWireCube", &ScriptGizmos::internal_DrawWireCube);
-		metaData.scriptClass->addInternalCall("Internal_DrawWireSphere", &ScriptGizmos::internal_DrawWireSphere);
-		metaData.scriptClass->addInternalCall("Internal_DrawWireCapsule", &ScriptGizmos::internal_DrawWireCapsule);
-		metaData.scriptClass->addInternalCall("Internal_DrawWireDisc", &ScriptGizmos::internal_DrawWireDisc);
-		metaData.scriptClass->addInternalCall("Internal_DrawWireArc", &ScriptGizmos::internal_DrawWireArc);
-		metaData.scriptClass->addInternalCall("Internal_DrawLine", &ScriptGizmos::internal_DrawLine);
-		metaData.scriptClass->addInternalCall("Internal_DrawLineList", &ScriptGizmos::internal_DrawLineList);
-		metaData.scriptClass->addInternalCall("Internal_DrawFrustum", &ScriptGizmos::internal_DrawFrustum);
-		metaData.scriptClass->addInternalCall("Internal_DrawIcon", &ScriptGizmos::internal_DrawIcon);
-		metaData.scriptClass->addInternalCall("Internal_DrawText", &ScriptGizmos::internal_DrawText);
-	}
-
-	void ScriptGizmos::internal_SetColor(Color* color)
-	{
-		GizmoManager::instance().setColor(*color);
-	}
-
-	void ScriptGizmos::internal_GetColor(Color* color)
-	{
-		*color = GizmoManager::instance().getColor();
-	}
-
-	void ScriptGizmos::internal_SetTransform(Matrix4* transform)
-	{
-		GizmoManager::instance().setTransform(*transform);
-	}
-
-	void ScriptGizmos::internal_GetTransform(Matrix4* transform)
-	{
-		*transform = GizmoManager::instance().getTransform();
-	}
-
-	void ScriptGizmos::internal_DrawCube(Vector3* position, Vector3* extents)
-	{
-		GizmoManager::instance().drawCube(*position, *extents);
-	}
-
-	void ScriptGizmos::internal_DrawSphere(Vector3* position, float radius)
-	{
-		GizmoManager::instance().drawSphere(*position, radius);
-	}
-
-	void ScriptGizmos::internal_DrawWireCube(Vector3* position, Vector3* extents)
-	{
-		GizmoManager::instance().drawWireCube(*position, *extents);
-	}
-
-	void ScriptGizmos::internal_DrawWireSphere(Vector3* position, float radius)
-	{
-		GizmoManager::instance().drawWireSphere(*position, radius);
-	}
-
-	void ScriptGizmos::internal_DrawWireCapsule(Vector3* position, float height, float radius)
-	{
-		GizmoManager::instance().drawWireCapsule(*position, height, radius);
-	}
-
-	void ScriptGizmos::internal_DrawLine(Vector3* start, Vector3* end)
-	{
-		GizmoManager::instance().drawLine(*start, *end);
-	}
-
-	void ScriptGizmos::internal_DrawLineList(MonoArray* linePoints)
-	{
-		ScriptArray lineArray(linePoints);
-
-		UINT32 numElements = lineArray.size();
-		Vector<Vector3> points(numElements);
-		for (UINT32 i = 0; i < numElements; i++)
-			points[i] = lineArray.get<Vector3>(i);
-
-		GizmoManager::instance().drawLineList(points);
-	}
-
-	void ScriptGizmos::internal_DrawWireDisc(Vector3* position, Vector3* normal, float radius)
-	{
-		GizmoManager::instance().drawWireDisc(*position, *normal, radius);
-	}
-
-	void ScriptGizmos::internal_DrawWireArc(Vector3* position, Vector3* normal, float radius, float startAngle, 
-		float amountAngle)
-	{
-		GizmoManager::instance().drawWireArc(*position, *normal, radius, Degree(startAngle), Degree(amountAngle));
-	}
-
-	void ScriptGizmos::internal_DrawFrustum(Vector3* position, float aspect, Degree* FOV, float near, float far)
-	{
-		GizmoManager::instance().drawFrustum(*position, aspect, *FOV, near, far);
-	}
-
-	void ScriptGizmos::internal_DrawIcon(Vector3* position, MonoObject* image, bool fixedScale)
-	{
-		HSpriteTexture nativeTexture;
-		if (image != nullptr)
-			nativeTexture = ScriptSpriteTexture::toNative(image)->getHandle();
-
-		GizmoManager::instance().drawIcon(*position, nativeTexture, fixedScale);
-	}
-
-	void ScriptGizmos::internal_DrawText(Vector3* position, MonoString* text, ScriptFont* font, int size)
-	{
-		WString nativeText = MonoUtil::monoToWString(text);
-
-		HFont fontHandle;
-		if (font != nullptr)
-			fontHandle = font->getHandle();
-
-		GizmoManager::instance().drawText(*position, nativeText, fontHandle, size);
-	}
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsScriptGizmos.h"
+#include "BsScriptMeta.h"
+#include "BsMonoClass.h"
+#include "BsScriptSpriteTexture.h"
+#include "BsGizmoManager.h"
+#include "BsMonoUtil.h"
+#include "BsScriptFont.h"
+#include "BsScriptMeshData.h"
+
+namespace BansheeEngine
+{
+	void ScriptGizmos::initRuntimeData()
+	{
+		metaData.scriptClass->addInternalCall("Internal_SetColor", &ScriptGizmos::internal_SetColor);
+		metaData.scriptClass->addInternalCall("Internal_GetColor", &ScriptGizmos::internal_GetColor);
+		metaData.scriptClass->addInternalCall("Internal_SetTransform", &ScriptGizmos::internal_SetTransform);
+		metaData.scriptClass->addInternalCall("Internal_GetTransform", &ScriptGizmos::internal_GetTransform);
+		metaData.scriptClass->addInternalCall("Internal_DrawCube", &ScriptGizmos::internal_DrawCube);
+		metaData.scriptClass->addInternalCall("Internal_DrawSphere", &ScriptGizmos::internal_DrawSphere);
+		metaData.scriptClass->addInternalCall("Internal_DrawWireCube", &ScriptGizmos::internal_DrawWireCube);
+		metaData.scriptClass->addInternalCall("Internal_DrawWireSphere", &ScriptGizmos::internal_DrawWireSphere);
+		metaData.scriptClass->addInternalCall("Internal_DrawWireCapsule", &ScriptGizmos::internal_DrawWireCapsule);
+		metaData.scriptClass->addInternalCall("Internal_DrawWireDisc", &ScriptGizmos::internal_DrawWireDisc);
+		metaData.scriptClass->addInternalCall("Internal_DrawWireArc", &ScriptGizmos::internal_DrawWireArc);
+		metaData.scriptClass->addInternalCall("Internal_DrawWireMesh", &ScriptGizmos::internal_DrawWireMesh);
+		metaData.scriptClass->addInternalCall("Internal_DrawLine", &ScriptGizmos::internal_DrawLine);
+		metaData.scriptClass->addInternalCall("Internal_DrawLineList", &ScriptGizmos::internal_DrawLineList);
+		metaData.scriptClass->addInternalCall("Internal_DrawFrustum", &ScriptGizmos::internal_DrawFrustum);
+		metaData.scriptClass->addInternalCall("Internal_DrawIcon", &ScriptGizmos::internal_DrawIcon);
+		metaData.scriptClass->addInternalCall("Internal_DrawText", &ScriptGizmos::internal_DrawText);
+	}
+
+	void ScriptGizmos::internal_SetColor(Color* color)
+	{
+		GizmoManager::instance().setColor(*color);
+	}
+
+	void ScriptGizmos::internal_GetColor(Color* color)
+	{
+		*color = GizmoManager::instance().getColor();
+	}
+
+	void ScriptGizmos::internal_SetTransform(Matrix4* transform)
+	{
+		GizmoManager::instance().setTransform(*transform);
+	}
+
+	void ScriptGizmos::internal_GetTransform(Matrix4* transform)
+	{
+		*transform = GizmoManager::instance().getTransform();
+	}
+
+	void ScriptGizmos::internal_DrawCube(Vector3* position, Vector3* extents)
+	{
+		GizmoManager::instance().drawCube(*position, *extents);
+	}
+
+	void ScriptGizmos::internal_DrawSphere(Vector3* position, float radius)
+	{
+		GizmoManager::instance().drawSphere(*position, radius);
+	}
+
+	void ScriptGizmos::internal_DrawWireCube(Vector3* position, Vector3* extents)
+	{
+		GizmoManager::instance().drawWireCube(*position, *extents);
+	}
+
+	void ScriptGizmos::internal_DrawWireSphere(Vector3* position, float radius)
+	{
+		GizmoManager::instance().drawWireSphere(*position, radius);
+	}
+
+	void ScriptGizmos::internal_DrawWireCapsule(Vector3* position, float height, float radius)
+	{
+		GizmoManager::instance().drawWireCapsule(*position, height, radius);
+	}
+
+	void ScriptGizmos::internal_DrawLine(Vector3* start, Vector3* end)
+	{
+		GizmoManager::instance().drawLine(*start, *end);
+	}
+
+	void ScriptGizmos::internal_DrawLineList(MonoArray* linePoints)
+	{
+		ScriptArray lineArray(linePoints);
+
+		UINT32 numElements = lineArray.size();
+		Vector<Vector3> points(numElements);
+		for (UINT32 i = 0; i < numElements; i++)
+			points[i] = lineArray.get<Vector3>(i);
+
+		GizmoManager::instance().drawLineList(points);
+	}
+
+	void ScriptGizmos::internal_DrawWireDisc(Vector3* position, Vector3* normal, float radius)
+	{
+		GizmoManager::instance().drawWireDisc(*position, *normal, radius);
+	}
+
+	void ScriptGizmos::internal_DrawWireArc(Vector3* position, Vector3* normal, float radius, float startAngle, 
+		float amountAngle)
+	{
+		GizmoManager::instance().drawWireArc(*position, *normal, radius, Degree(startAngle), Degree(amountAngle));
+	}
+
+	void ScriptGizmos::internal_DrawWireMesh(ScriptMeshData* meshData)
+	{
+		if (meshData != nullptr)
+		{
+			MeshDataPtr nativeMeshData = meshData->getInternalValue()->getData();
+			GizmoManager::instance().drawWireMesh(nativeMeshData);
+		}
+	}
+
+	void ScriptGizmos::internal_DrawFrustum(Vector3* position, float aspect, Degree* FOV, float near, float far)
+	{
+		GizmoManager::instance().drawFrustum(*position, aspect, *FOV, near, far);
+	}
+
+	void ScriptGizmos::internal_DrawIcon(Vector3* position, MonoObject* image, bool fixedScale)
+	{
+		HSpriteTexture nativeTexture;
+		if (image != nullptr)
+			nativeTexture = ScriptSpriteTexture::toNative(image)->getHandle();
+
+		GizmoManager::instance().drawIcon(*position, nativeTexture, fixedScale);
+	}
+
+	void ScriptGizmos::internal_DrawText(Vector3* position, MonoString* text, ScriptFont* font, int size)
+	{
+		WString nativeText = MonoUtil::monoToWString(text);
+
+		HFont fontHandle;
+		if (font != nullptr)
+			fontHandle = font->getHandle();
+
+		GizmoManager::instance().drawText(*position, nativeText, fontHandle, size);
+	}
 }