Browse Source

Update to latest bx.

woollybah 6 years ago
parent
commit
d62440109d
100 changed files with 1774 additions and 1315 deletions
  1. 4 4
      bx.mod/bx.bmx
  2. 3 3
      bx.mod/bx/.travis.yml
  3. 9 9
      bx.mod/bx/LICENSE
  4. 13 15
      bx.mod/bx/README.md
  5. 1 1
      bx.mod/bx/include/bx/allocator.h
  6. 1 1
      bx.mod/bx/include/bx/bx.h
  7. 1 1
      bx.mod/bx/include/bx/commandline.h
  8. 1 1
      bx.mod/bx/include/bx/config.h
  9. 1 1
      bx.mod/bx/include/bx/cpu.h
  10. 1 1
      bx.mod/bx/include/bx/debug.h
  11. 1 1
      bx.mod/bx/include/bx/easing.h
  12. 1 1
      bx.mod/bx/include/bx/endian.h
  13. 1 1
      bx.mod/bx/include/bx/error.h
  14. 59 14
      bx.mod/bx/include/bx/file.h
  15. 7 19
      bx.mod/bx/include/bx/filepath.h
  16. 1 1
      bx.mod/bx/include/bx/float4x4_t.h
  17. 1 1
      bx.mod/bx/include/bx/handlealloc.h
  18. 1 1
      bx.mod/bx/include/bx/hash.h
  19. 1 1
      bx.mod/bx/include/bx/inline/allocator.inl
  20. 1 1
      bx.mod/bx/include/bx/inline/bx.inl
  21. 1 1
      bx.mod/bx/include/bx/inline/cpu.inl
  22. 1 1
      bx.mod/bx/include/bx/inline/easing.inl
  23. 4 4
      bx.mod/bx/include/bx/inline/endian.inl
  24. 1 1
      bx.mod/bx/include/bx/inline/error.inl
  25. 1 1
      bx.mod/bx/include/bx/inline/float4x4_t.inl
  26. 1 1
      bx.mod/bx/include/bx/inline/handlealloc.inl
  27. 1 1
      bx.mod/bx/include/bx/inline/hash.inl
  28. 123 202
      bx.mod/bx/include/bx/inline/math.inl
  29. 1 1
      bx.mod/bx/include/bx/inline/mpscqueue.inl
  30. 1 1
      bx.mod/bx/include/bx/inline/mutex.inl
  31. 1 1
      bx.mod/bx/include/bx/inline/pixelformat.inl
  32. 19 7
      bx.mod/bx/include/bx/inline/readerwriter.inl
  33. 1 1
      bx.mod/bx/include/bx/inline/ringbuffer.inl
  34. 5 1
      bx.mod/bx/include/bx/inline/rng.inl
  35. 1 1
      bx.mod/bx/include/bx/inline/simd128_langext.inl
  36. 1 1
      bx.mod/bx/include/bx/inline/simd128_neon.inl
  37. 1 1
      bx.mod/bx/include/bx/inline/simd128_ref.inl
  38. 1 1
      bx.mod/bx/include/bx/inline/simd128_sse.inl
  39. 1 1
      bx.mod/bx/include/bx/inline/simd256_avx.inl
  40. 1 1
      bx.mod/bx/include/bx/inline/simd256_ref.inl
  41. 1 1
      bx.mod/bx/include/bx/inline/simd_ni.inl
  42. 1 1
      bx.mod/bx/include/bx/inline/sort.inl
  43. 5 2
      bx.mod/bx/include/bx/inline/spscqueue.inl
  44. 40 1
      bx.mod/bx/include/bx/inline/string.inl
  45. 4 15
      bx.mod/bx/include/bx/inline/uint32_t.inl
  46. 6 2
      bx.mod/bx/include/bx/macros.h
  47. 1 1
      bx.mod/bx/include/bx/maputil.h
  48. 164 134
      bx.mod/bx/include/bx/math.h
  49. 1 1
      bx.mod/bx/include/bx/mpscqueue.h
  50. 1 1
      bx.mod/bx/include/bx/mutex.h
  51. 1 1
      bx.mod/bx/include/bx/os.h
  52. 1 1
      bx.mod/bx/include/bx/pixelformat.h
  53. 46 3
      bx.mod/bx/include/bx/platform.h
  54. 1 1
      bx.mod/bx/include/bx/process.h
  55. 50 27
      bx.mod/bx/include/bx/readerwriter.h
  56. 1 1
      bx.mod/bx/include/bx/ringbuffer.h
  57. 2 4
      bx.mod/bx/include/bx/rng.h
  58. 1 1
      bx.mod/bx/include/bx/semaphore.h
  59. 1 1
      bx.mod/bx/include/bx/settings.h
  60. 1 1
      bx.mod/bx/include/bx/simd_t.h
  61. 1 1
      bx.mod/bx/include/bx/sort.h
  62. 1 1
      bx.mod/bx/include/bx/spscqueue.h
  63. 41 2
      bx.mod/bx/include/bx/string.h
  64. 1 1
      bx.mod/bx/include/bx/thread.h
  65. 1 1
      bx.mod/bx/include/bx/timer.h
  66. 4 7
      bx.mod/bx/include/bx/uint32_t.h
  67. 1 1
      bx.mod/bx/include/bx/url.h
  68. 570 277
      bx.mod/bx/include/compat/msvc/dirent.h
  69. 1 1
      bx.mod/bx/makefile
  70. 1 1
      bx.mod/bx/scripts/bin2c.lua
  71. 1 1
      bx.mod/bx/scripts/bx.lua
  72. 1 1
      bx.mod/bx/scripts/genie.lua
  73. 1 1
      bx.mod/bx/scripts/lemon.lua
  74. 2 41
      bx.mod/bx/scripts/toolchain.lua
  75. 1 1
      bx.mod/bx/src/allocator.cpp
  76. 1 1
      bx.mod/bx/src/amalgamated.cpp
  77. 1 1
      bx.mod/bx/src/bx.cpp
  78. 1 1
      bx.mod/bx/src/bx_p.h
  79. 2 2
      bx.mod/bx/src/commandline.cpp
  80. 1 1
      bx.mod/bx/src/crtnone.cpp
  81. 1 1
      bx.mod/bx/src/debug.cpp
  82. 1 1
      bx.mod/bx/src/dtoa.cpp
  83. 1 1
      bx.mod/bx/src/easing.cpp
  84. 373 21
      bx.mod/bx/src/file.cpp
  85. 19 184
      bx.mod/bx/src/filepath.cpp
  86. 1 1
      bx.mod/bx/src/hash.cpp
  87. 46 206
      bx.mod/bx/src/math.cpp
  88. 1 1
      bx.mod/bx/src/mutex.cpp
  89. 3 3
      bx.mod/bx/src/os.cpp
  90. 3 3
      bx.mod/bx/src/process.cpp
  91. 1 1
      bx.mod/bx/src/semaphore.cpp
  92. 1 1
      bx.mod/bx/src/settings.cpp
  93. 1 1
      bx.mod/bx/src/sort.cpp
  94. 35 7
      bx.mod/bx/src/string.cpp
  95. 43 26
      bx.mod/bx/src/thread.cpp
  96. 1 1
      bx.mod/bx/src/timer.cpp
  97. 1 1
      bx.mod/bx/src/url.cpp
  98. 1 1
      bx.mod/bx/tests/atomic_test.cpp
  99. 1 1
      bx.mod/bx/tests/crt_test.cpp
  100. 1 1
      bx.mod/bx/tests/dbg.h

+ 4 - 4
bx.mod/bx.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2015-2018 Bruce A Henderson
+' Copyright (c) 2015-2019 Bruce A Henderson
 ' All rights reserved.
 ' All rights reserved.
 ' 
 ' 
 ' Redistribution and use in source and binary forms, with or without
 ' Redistribution and use in source and binary forms, with or without
@@ -80,21 +80,21 @@ End Function
 Rem
 Rem
 bbdoc: 
 bbdoc: 
 End Rem
 End Rem
-Function mtxQuat(result:Float Ptr, quatVec4:Float Ptr)
+Function mtxQuat(result:Float Ptr, quatVec4:SQuatF)
 	bmx_bx_mtxQuat(result, quatVec4)
 	bmx_bx_mtxQuat(result, quatVec4)
 End Function
 End Function
 
 
 Rem
 Rem
 bbdoc: 
 bbdoc: 
 End Rem
 End Rem
-Function mtxQuatTranslation(result:Float Ptr, quatVec4:Float Ptr, translationVec3:Float Ptr)
+Function mtxQuatTranslation(result:Float Ptr, quatVec4:SQuatF, translationVec3:SVec3F)
 	bmx_bx_mtxQuatTranslation(result, quatVec4, translationVec3)
 	bmx_bx_mtxQuatTranslation(result, quatVec4, translationVec3)
 End Function
 End Function
 
 
 Rem
 Rem
 bbdoc: 
 bbdoc: 
 End Rem
 End Rem
-Function mtxQuatTranslationHMD(result:Float Ptr, quatVec4:Float Ptr, translationVec3:Float Ptr)
+Function mtxQuatTranslationHMD(result:Float Ptr, quatVec4:SQuatF, translationVec3:SVec3F)
 	bmx_bx_mtxQuatTranslationHMD(result, quatVec4, translationVec3)
 	bmx_bx_mtxQuatTranslationHMD(result, quatVec4, translationVec3)
 End Function
 End Function
 
 

+ 3 - 3
bx.mod/bx/.travis.yml

@@ -11,12 +11,12 @@ addons:
     sources:
     sources:
     - ubuntu-toolchain-r-test
     - ubuntu-toolchain-r-test
     packages:
     packages:
-    - gcc-5
-    - g++-5
+    - gcc-8
+    - g++-8
     - clang
     - clang
 
 
 script:
 script:
-  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then make test CXX="g++-5" CC="gcc-5"; fi
+  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then make test CXX="g++-8" CC="gcc-8"; fi
   - if [ "$TRAVIS_OS_NAME" == "osx" ]; then make test; fi
   - if [ "$TRAVIS_OS_NAME" == "osx" ]; then make test; fi
 
 
 branches:
 branches:

+ 9 - 9
bx.mod/bx/LICENSE

@@ -1,4 +1,4 @@
-Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+Copyright 2010-2019 Branimir Karadzic
 
 
 Redistribution and use in source and binary forms, with or without modification,
 Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:
 are permitted provided that the following conditions are met:
@@ -10,13 +10,13 @@ are permitted provided that the following conditions are met:
       this list of conditions and the following disclaimer in the documentation
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
       and/or other materials provided with the distribution.
 
 
-THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
-SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 OF THE POSSIBILITY OF SUCH DAMAGE.
 OF THE POSSIBILITY OF SUCH DAMAGE.

+ 13 - 15
bx.mod/bx/README.md

@@ -23,27 +23,25 @@ https://github.com/bkaradzic/bx
 <img align="right" src="http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png">
 <img align="right" src="http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png">
 </a>
 </a>
 
 
-	Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+	Copyright 2010-2019 Branimir Karadzic
 	
 	
-	https://github.com/bkaradzic/bx
+	Redistribution and use in source and binary forms, with or without modification,
+	are permitted provided that the following conditions are met:
 	
 	
-	Redistribution and use in source and binary forms, with or without
-	modification, are permitted provided that the following conditions are met:
-	
-	   1. Redistributions of source code must retain the above copyright notice,
-	      this list of conditions and the following disclaimer.
+	   1. Redistributions of source code must retain the above copyright notice, this
+	      list of conditions and the following disclaimer.
 	
 	
 	   2. Redistributions in binary form must reproduce the above copyright notice,
 	   2. Redistributions in binary form must reproduce the above copyright notice,
 	      this list of conditions and the following disclaimer in the documentation
 	      this list of conditions and the following disclaimer in the documentation
 	      and/or other materials provided with the distribution.
 	      and/or other materials provided with the distribution.
 	
 	
-	THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
-	IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-	MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-	EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+	ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+	WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+	IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 	INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 	INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 	BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 	BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-	LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-	OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-	ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+	OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+	OF THE POSSIBILITY OF SUCH DAMAGE.

+ 1 - 1
bx.mod/bx/include/bx/allocator.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/bx.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/commandline.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/config.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/cpu.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/debug.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/easing.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/endian.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/error.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 59 - 14
bx.mod/bx/include/bx/file.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -11,19 +11,19 @@
 
 
 namespace bx
 namespace bx
 {
 {
-	///
+	/// Returns standard input reader.
 	ReaderI* getStdIn();
 	ReaderI* getStdIn();
 
 
-	///
+	/// Returns standard output writer.
 	WriterI* getStdOut();
 	WriterI* getStdOut();
 
 
-	///
+	/// Returns standard error writer.
 	WriterI* getStdErr();
 	WriterI* getStdErr();
 
 
-	///
+	/// Returns null output writer.
 	WriterI* getNullOut();
 	WriterI* getNullOut();
 
 
-	///
+	/// File reader.
 	class FileReader : public FileReaderI
 	class FileReader : public FileReaderI
 	{
 	{
 	public:
 	public:
@@ -49,7 +49,7 @@ namespace bx
 		BX_ALIGN_DECL(16, uint8_t) m_internal[64];
 		BX_ALIGN_DECL(16, uint8_t) m_internal[64];
 	};
 	};
 
 
-	///
+	/// File writer.
 	class FileWriter : public FileWriterI
 	class FileWriter : public FileWriterI
 	{
 	{
 	public:
 	public:
@@ -75,23 +75,68 @@ namespace bx
 		BX_ALIGN_DECL(16, uint8_t) m_internal[64];
 		BX_ALIGN_DECL(16, uint8_t) m_internal[64];
 	};
 	};
 
 
-	///
-	struct FileInfo
+	/// File type.
+	struct FileType
 	{
 	{
+		/// File types:
 		enum Enum
 		enum Enum
 		{
 		{
-			Regular,
-			Directory,
+			File, //!< File.
+			Dir,  //!< Directory.
 
 
 			Count
 			Count
 		};
 		};
+	};
+
+	/// File info.
+	struct FileInfo
+	{
+		FilePath       filePath; //!< File path.
+		uint64_t       size;     //!< File size.
+		FileType::Enum type;     //!< File type.
+	};
+
+	/// Directory reader.
+	class DirectoryReader : public ReaderOpenI, public CloserI, public ReaderI
+	{
+	public:
+		///
+		DirectoryReader();
+
+		///
+		virtual ~DirectoryReader();
+
+		///
+		virtual bool open(const FilePath& _filePath, Error* _err) override;
+
+		///
+		virtual void close() override;
+
+		///
+		virtual int32_t read(void* _data, int32_t _size, Error* _err) override;
 
 
-		uint64_t m_size;
-		Enum m_type;
+	private:
+		BX_ALIGN_DECL(16, uint8_t) m_internal[sizeof(FilePath)+sizeof(FileInfo)+16];
 	};
 	};
 
 
+	/// FIle stat.
+	bool stat(FileInfo& _outFileInfo, const FilePath& _filePath);
+
+	/// Creates a directory named `_filePath`.
+	///
+	bool make(const FilePath& _filePath, Error* _err = NULL);
+
+	/// Creates a directory named `_filePath` along with all necessary parents.
+	///
+	bool makeAll(const FilePath& _filePath, Error* _err = NULL);
+
+	/// Removes file or directory.
+	///
+	bool remove(const FilePath& _filePath, Error* _err = NULL);
+
+	/// Removes file or directory recursivelly.
 	///
 	///
-	bool stat(const FilePath& _filePath, FileInfo& _outFileInfo);
+	bool removeAll(const FilePath& _filePath, Error* _err = NULL);
 
 
 } // namespace bx
 } // namespace bx
 
 

+ 7 - 19
bx.mod/bx/include/bx/filepath.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -79,9 +79,13 @@ namespace bx
 		///
 		///
 		void join(const StringView& _str);
 		void join(const StringView& _str);
 
 
-		/// Returns C string to file path.
+		/// Implicitly converts FilePath to StringView.
 		///
 		///
-		const char* get() const;
+		operator StringView() const;
+
+		/// Returns zero-terminated C string pointer to file path.
+		///
+		const char* getCPtr() const;
 
 
 		/// If path is `/abv/gd/555/333/pod.mac` returns `/abv/gd/555/333/`.
 		/// If path is `/abv/gd/555/333/pod.mac` returns `/abv/gd/555/333/`.
 		///
 		///
@@ -111,22 +115,6 @@ namespace bx
 		char m_filePath[kMaxFilePath];
 		char m_filePath[kMaxFilePath];
 	};
 	};
 
 
-	/// Creates a directory named `_filePath`.
-	///
-	bool make(const FilePath& _filePath, Error* _err = NULL);
-
-	/// Creates a directory named `_filePath` along with all necessary parents.
-	///
-	bool makeAll(const FilePath& _filePath, Error* _err = NULL);
-
-	/// Removes file or directory.
-	///
-	bool remove(const FilePath& _filePath, Error* _err = NULL);
-
-	/// Removes file or directory recursivelly.
-	///
-	bool removeAll(const FilePath& _filePath, Error* _err = NULL);
-
 } // namespace bx
 } // namespace bx
 
 
 #endif // BX_FILEPATH_H_HEADER_GUARD
 #endif // BX_FILEPATH_H_HEADER_GUARD

+ 1 - 1
bx.mod/bx/include/bx/float4x4_t.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/handlealloc.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/hash.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/allocator.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/bx.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/cpu.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/easing.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 4 - 4
bx.mod/bx/include/bx/inline/endian.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -46,7 +46,7 @@ namespace bx
 	}
 	}
 
 
 	template <typename Ty>
 	template <typename Ty>
-	inline Ty toLittleEndian(const Ty _in)
+	inline Ty toLittleEndian(Ty _in)
 	{
 	{
 #if BX_CPU_ENDIAN_BIG
 #if BX_CPU_ENDIAN_BIG
 		return endianSwap(_in);
 		return endianSwap(_in);
@@ -56,7 +56,7 @@ namespace bx
 	}
 	}
 
 
 	template <typename Ty>
 	template <typename Ty>
-	inline Ty toBigEndian(const Ty _in)
+	inline Ty toBigEndian(Ty _in)
 	{
 	{
 #if BX_CPU_ENDIAN_LITTLE
 #if BX_CPU_ENDIAN_LITTLE
 		return endianSwap(_in);
 		return endianSwap(_in);
@@ -66,7 +66,7 @@ namespace bx
 	}
 	}
 
 
 	template <typename Ty>
 	template <typename Ty>
-	inline Ty toHostEndian(const Ty _in, bool _fromLittleEndian)
+	inline Ty toHostEndian(Ty _in, bool _fromLittleEndian)
 	{
 	{
 #if BX_CPU_ENDIAN_LITTLE
 #if BX_CPU_ENDIAN_LITTLE
 		return _fromLittleEndian ? _in : endianSwap(_in);
 		return _fromLittleEndian ? _in : endianSwap(_in);

+ 1 - 1
bx.mod/bx/include/bx/inline/error.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/float4x4_t.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/handlealloc.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/hash.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 123 - 202
bx.mod/bx/include/bx/inline/math.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -277,7 +277,8 @@ namespace bx
 	inline BX_CONSTEXPR_FUNC bool equal(float _a, float _b, float _epsilon)
 	inline BX_CONSTEXPR_FUNC bool equal(float _a, float _b, float _epsilon)
 	{
 	{
 		// Reference(s):
 		// Reference(s):
-		// - https://web.archive.org/web/20181103180318/http://realtimecollisiondetection.net/blog/?p=89
+		// - Floating-point tolerances revisited
+		//   https://web.archive.org/web/20181103180318/http://realtimecollisiondetection.net/blog/?p=89
 		//
 		//
 		const float lhs = abs(_a - _b);
 		const float lhs = abs(_a - _b);
 		const float rhs = _epsilon * max(1.0f, abs(_a), abs(_b) );
 		const float rhs = _epsilon * max(1.0f, abs(_a), abs(_b) );
@@ -347,23 +348,46 @@ namespace bx
 		return _a + angleDiff(_a, _b) * _t;
 		return _a + angleDiff(_a, _b) * _t;
 	}
 	}
 
 
-	inline Vec3 load(const void* _ptr)
+	template<typename Ty>
+	inline Ty load(const void* _ptr)
 	{
 	{
-		const float* ptr = reinterpret_cast<const float*>(_ptr);
-		return
-		{
-			ptr[0],
-			ptr[1],
-			ptr[2],
-		};
+		Ty result;
+		memCopy(&result, _ptr, sizeof(Ty) );
+		return result;
 	}
 	}
 
 
-	inline void store(void* _ptr, const Vec3 _a)
+	template<typename Ty>
+	inline void store(void* _ptr, const Ty& _a)
 	{
 	{
-		float* ptr = reinterpret_cast<float*>(_ptr);
-		ptr[0] = _a.x;
-		ptr[1] = _a.y;
-		ptr[2] = _a.z;
+		memCopy(_ptr, &_a, sizeof(Ty) );
+	}
+
+	inline Vec3::Vec3()
+	{
+	}
+
+	constexpr Vec3::Vec3(float _v)
+		: x(_v)
+		, y(_v)
+		, z(_v)
+	{
+	}
+
+	constexpr Vec3::Vec3(float _x, float _y, float _z)
+		: x(_x)
+		, y(_y)
+		, z(_z)
+	{
+	}
+
+	inline BX_CONSTEXPR_FUNC Vec3 round(const Vec3 _a)
+	{
+		return
+		{
+			round(_a.x),
+			round(_a.y),
+			round(_a.z),
+		};
 	}
 	}
 
 
 	inline BX_CONSTEXPR_FUNC Vec3 abs(const Vec3 _a)
 	inline BX_CONSTEXPR_FUNC Vec3 abs(const Vec3 _a)
@@ -476,6 +500,17 @@ namespace bx
 		return sqrt(dot(_a, _a) );
 		return sqrt(dot(_a, _a) );
 	}
 	}
 
 
+	inline BX_CONST_FUNC float distanceSq(const Vec3 _a, const Vec3 _b)
+	{
+		const Vec3 ba = sub(_b, _a);
+		return dot(ba, ba);
+	}
+
+	inline BX_CONST_FUNC float distance(const Vec3 _a, const Vec3 _b)
+	{
+		return length(sub(_b, _a) );
+	}
+
 	inline BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t)
 	inline BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t)
 	{
 	{
 		return
 		return
@@ -593,8 +628,8 @@ namespace bx
 		const float phi   = atan2(_dir.x, _dir.z);
 		const float phi   = atan2(_dir.x, _dir.z);
 		const float theta = acos(_dir.y);
 		const float theta = acos(_dir.y);
 
 
-		*_outU = (bx::kPi + phi)/bx::kPi2;
-		*_outV = theta*bx::kInvPi;
+		*_outU = (kPi + phi)/kPi2;
+		*_outV = theta*kInvPi;
 	}
 	}
 
 
 	inline BX_CONSTEXPR_FUNC Quaternion invert(const Quaternion _a)
 	inline BX_CONSTEXPR_FUNC Quaternion invert(const Quaternion _a)
@@ -649,18 +684,10 @@ namespace bx
 		};
 		};
 	}
 	}
 
 
-	namespace detail
-	{
-		inline BX_CONSTEXPR_FUNC Quaternion loadQ(const Vec3 _v)
-		{
-			return { _v.x, _v.y, _v.z, 0.0f };
-		}
-	}
-
 	inline BX_CONSTEXPR_FUNC Vec3 mul(const Vec3 _v, const Quaternion _q)
 	inline BX_CONSTEXPR_FUNC Vec3 mul(const Vec3 _v, const Quaternion _q)
 	{
 	{
 		const Quaternion tmp0 = invert(_q);
 		const Quaternion tmp0 = invert(_q);
-		const Quaternion qv   = detail::loadQ(_v);
+		const Quaternion qv   = { _v.x, _v.y, _v.z, 0.0f };
 		const Quaternion tmp1 = mul(tmp0, qv);
 		const Quaternion tmp1 = mul(tmp0, qv);
 		const Vec3 result     = mulXyz(tmp1, _q);
 		const Vec3 result     = mulXyz(tmp1, _q);
 
 
@@ -773,25 +800,6 @@ namespace bx
 		};
 		};
 	}
 	}
 
 
-	inline void vec3Add(float* _result, const float* _a, const float* _b)
-	{
-		_result[0] = _a[0] + _b[0];
-		_result[1] = _a[1] + _b[1];
-		_result[2] = _a[2] + _b[2];
-	}
-
-	inline void vec3Sub(float* _result, const float* _a, const float* _b)
-	{
-		_result[0] = _a[0] - _b[0];
-		_result[1] = _a[1] - _b[1];
-		_result[2] = _a[2] - _b[2];
-	}
-
-	inline float vec3Dot(const float* _a, const float* _b)
-	{
-		return _a[0]*_b[0] + _a[1]*_b[1] + _a[2]*_b[2];
-	}
-
 	inline void mtxIdentity(float* _result)
 	inline void mtxIdentity(float* _result)
 	{
 	{
 		memSet(_result, 0, sizeof(float)*16);
 		memSet(_result, 0, sizeof(float)*16);
@@ -820,65 +828,63 @@ namespace bx
 		mtxScale(_result, _scale, _scale, _scale);
 		mtxScale(_result, _scale, _scale, _scale);
 	}
 	}
 
 
-	inline void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos)
+	inline void mtxFromNormal(float* _result, const Vec3& _normal, float _scale, const Vec3& _pos)
 	{
 	{
-		const bx::Vec3 normal = bx::load(_normal);
-		bx::Vec3 tangent;
-		bx::Vec3 bitangent;
-		calcTangentFrame(tangent, bitangent, normal);
+		Vec3 tangent;
+		Vec3 bitangent;
+		calcTangentFrame(tangent, bitangent, _normal);
 
 
 		store(&_result[ 0], mul(bitangent, _scale) );
 		store(&_result[ 0], mul(bitangent, _scale) );
-		store(&_result[ 4], mul(normal,    _scale) );
+		store(&_result[ 4], mul(_normal,   _scale) );
 		store(&_result[ 8], mul(tangent,   _scale) );
 		store(&_result[ 8], mul(tangent,   _scale) );
 
 
 		_result[ 3] = 0.0f;
 		_result[ 3] = 0.0f;
 		_result[ 7] = 0.0f;
 		_result[ 7] = 0.0f;
 		_result[11] = 0.0f;
 		_result[11] = 0.0f;
-		_result[12] = _pos[0];
-		_result[13] = _pos[1];
-		_result[14] = _pos[2];
+		_result[12] = _pos.x;
+		_result[13] = _pos.y;
+		_result[14] = _pos.z;
 		_result[15] = 1.0f;
 		_result[15] = 1.0f;
 	}
 	}
 
 
-	inline void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos, float _angle)
+	inline void mtxFromNormal(float* _result, const Vec3& _normal, float _scale, const Vec3& _pos, float _angle)
 	{
 	{
-		const bx::Vec3 normal = bx::load(_normal);
-		bx::Vec3 tangent;
-		bx::Vec3 bitangent;
-		calcTangentFrame(tangent, bitangent, normal, _angle);
+		Vec3 tangent;
+		Vec3 bitangent;
+		calcTangentFrame(tangent, bitangent, _normal, _angle);
 
 
 		store(&_result[0], mul(bitangent, _scale) );
 		store(&_result[0], mul(bitangent, _scale) );
-		store(&_result[4], mul(normal,    _scale) );
+		store(&_result[4], mul(_normal,   _scale) );
 		store(&_result[8], mul(tangent,   _scale) );
 		store(&_result[8], mul(tangent,   _scale) );
 
 
 		_result[ 3] = 0.0f;
 		_result[ 3] = 0.0f;
 		_result[ 7] = 0.0f;
 		_result[ 7] = 0.0f;
 		_result[11] = 0.0f;
 		_result[11] = 0.0f;
-		_result[12] = _pos[0];
-		_result[13] = _pos[1];
-		_result[14] = _pos[2];
+		_result[12] = _pos.x;
+		_result[13] = _pos.y;
+		_result[14] = _pos.z;
 		_result[15] = 1.0f;
 		_result[15] = 1.0f;
 	}
 	}
 
 
-	inline void mtxQuat(float* _result, const float* _quat)
+	inline void mtxQuat(float* _result, const Quaternion& _quat)
 	{
 	{
-		const float x = _quat[0];
-		const float y = _quat[1];
-		const float z = _quat[2];
-		const float w = _quat[3];
+		const float qx = _quat.x;
+		const float qy = _quat.y;
+		const float qz = _quat.z;
+		const float qw = _quat.w;
 
 
-		const float x2  =  x + x;
-		const float y2  =  y + y;
-		const float z2  =  z + z;
-		const float x2x = x2 * x;
-		const float x2y = x2 * y;
-		const float x2z = x2 * z;
-		const float x2w = x2 * w;
-		const float y2y = y2 * y;
-		const float y2z = y2 * z;
-		const float y2w = y2 * w;
-		const float z2z = z2 * z;
-		const float z2w = z2 * w;
+		const float x2  = qx + qx;
+		const float y2  = qy + qy;
+		const float z2  = qz + qz;
+		const float x2x = x2 * qx;
+		const float x2y = x2 * qy;
+		const float x2z = x2 * qz;
+		const float x2w = x2 * qw;
+		const float y2y = y2 * qy;
+		const float y2z = y2 * qz;
+		const float y2w = y2 * qw;
+		const float z2z = z2 * qz;
+		const float z2w = z2 * qw;
 
 
 		_result[ 0] = 1.0f - (y2y + z2z);
 		_result[ 0] = 1.0f - (y2y + z2z);
 		_result[ 1] =         x2y - z2w;
 		_result[ 1] =         x2y - z2w;
@@ -901,25 +907,25 @@ namespace bx
 		_result[15] = 1.0f;
 		_result[15] = 1.0f;
 	}
 	}
 
 
-	inline void mtxQuatTranslation(float* _result, const float* _quat, const float* _translation)
+	inline void mtxQuatTranslation(float* _result, const Quaternion& _quat, const Vec3& _translation)
 	{
 	{
 		mtxQuat(_result, _quat);
 		mtxQuat(_result, _quat);
-		_result[12] = -(_result[0]*_translation[0] + _result[4]*_translation[1] + _result[ 8]*_translation[2]);
-		_result[13] = -(_result[1]*_translation[0] + _result[5]*_translation[1] + _result[ 9]*_translation[2]);
-		_result[14] = -(_result[2]*_translation[0] + _result[6]*_translation[1] + _result[10]*_translation[2]);
+		store(&_result[12], neg(mulXyz0(_translation, _result) ) );
 	}
 	}
 
 
-	inline void mtxQuatTranslationHMD(float* _result, const float* _quat, const float* _translation)
+	inline void mtxQuatTranslationHMD(float* _result, const Quaternion& _quat, const Vec3& _translation)
 	{
 	{
-		float quat[4];
-		quat[0] = -_quat[0];
-		quat[1] = -_quat[1];
-		quat[2] =  _quat[2];
-		quat[3] =  _quat[3];
+		const Quaternion quat =
+		{
+			-_quat.x,
+			-_quat.y,
+			 _quat.z,
+			 _quat.w,
+		};
 		mtxQuatTranslation(_result, quat, _translation);
 		mtxQuatTranslation(_result, quat, _translation);
 	}
 	}
 
 
-	inline Vec3 mul(const Vec3 _vec, const float* _mat)
+	inline Vec3 mul(const Vec3& _vec, const float* _mat)
 	{
 	{
 		Vec3 result;
 		Vec3 result;
 		result.x = _vec.x * _mat[0] + _vec.y * _mat[4] + _vec.z * _mat[ 8] + _mat[12];
 		result.x = _vec.x * _mat[0] + _vec.y * _mat[4] + _vec.z * _mat[ 8] + _mat[12];
@@ -928,7 +934,7 @@ namespace bx
 		return result;
 		return result;
 	}
 	}
 
 
-	inline Vec3 mulXyz0(const Vec3 _vec, const float* _mat)
+	inline Vec3 mulXyz0(const Vec3& _vec, const float* _mat)
 	{
 	{
 		Vec3 result;
 		Vec3 result;
 		result.x = _vec.x * _mat[0] + _vec.y * _mat[4] + _vec.z * _mat[ 8];
 		result.x = _vec.x * _mat[0] + _vec.y * _mat[4] + _vec.z * _mat[ 8];
@@ -937,7 +943,7 @@ namespace bx
 		return result;
 		return result;
 	}
 	}
 
 
-	inline Vec3 mulH(const Vec3 _vec, const float* _mat)
+	inline Vec3 mulH(const Vec3& _vec, const float* _mat)
 	{
 	{
 		const float xx   = _vec.x * _mat[0] + _vec.y * _mat[4] + _vec.z * _mat[ 8] + _mat[12];
 		const float xx   = _vec.x * _mat[0] + _vec.y * _mat[4] + _vec.z * _mat[ 8] + _mat[12];
 		const float yy   = _vec.x * _mat[1] + _vec.y * _mat[5] + _vec.z * _mat[ 9] + _mat[13];
 		const float yy   = _vec.x * _mat[1] + _vec.y * _mat[5] + _vec.z * _mat[ 9] + _mat[13];
@@ -955,48 +961,6 @@ namespace bx
 		return result;
 		return result;
 	}
 	}
 
 
-	inline void vec3MulMtx(float* _result, const float* _vec, const float* _mat)
-	{
-		_result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _mat[12];
-		_result[1] = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _mat[13];
-		_result[2] = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _mat[14];
-	}
-
-	inline void vec3MulMtxXyz0(float* _result, const float* _vec, const float* _mat)
-	{
-		_result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8];
-		_result[1] = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9];
-		_result[2] = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10];
-	}
-
-	inline void vec3MulMtxH(float* _result, const float* _vec, const float* _mat)
-	{
-		float xx = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _mat[12];
-		float yy = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _mat[13];
-		float zz = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _mat[14];
-		float ww = _vec[0] * _mat[ 3] + _vec[1] * _mat[7] + _vec[2] * _mat[11] + _mat[15];
-		float invW = sign(ww)/ww;
-		_result[0] = xx*invW;
-		_result[1] = yy*invW;
-		_result[2] = zz*invW;
-	}
-
-	inline void vec4Mul(float* _result, const float* _a, const float* _b)
-	{
-		_result[0] = _a[0] * _b[0];
-		_result[1] = _a[1] * _b[1];
-		_result[2] = _a[2] * _b[2];
-		_result[3] = _a[3] * _b[3];
-	}
-
-	inline void vec4Mul(float* _result, const float* _a, float _b)
-	{
-		_result[0] = _a[0] * _b;
-		_result[1] = _a[1] * _b;
-		_result[2] = _a[2] * _b;
-		_result[3] = _a[3] * _b;
-	}
-
 	inline void vec4MulMtx(float* _result, const float* _vec, const float* _mat)
 	inline void vec4MulMtx(float* _result, const float* _vec, const float* _mat)
 	{
 	{
 		_result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _vec[3] * _mat[12];
 		_result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _vec[3] * _mat[12];
@@ -1033,73 +997,30 @@ namespace bx
 		_result[15] = _a[15];
 		_result[15] = _a[15];
 	}
 	}
 
 
-	/// Convert LH to RH projection matrix and vice versa.
-	inline void mtxProjFlipHandedness(float* _dst, const float* _src)
-	{
-		_dst[ 0] = -_src[ 0];
-		_dst[ 1] = -_src[ 1];
-		_dst[ 2] = -_src[ 2];
-		_dst[ 3] = -_src[ 3];
-		_dst[ 4] =  _src[ 4];
-		_dst[ 5] =  _src[ 5];
-		_dst[ 6] =  _src[ 6];
-		_dst[ 7] =  _src[ 7];
-		_dst[ 8] = -_src[ 8];
-		_dst[ 9] = -_src[ 9];
-		_dst[10] = -_src[10];
-		_dst[11] = -_src[11];
-		_dst[12] =  _src[12];
-		_dst[13] =  _src[13];
-		_dst[14] =  _src[14];
-		_dst[15] =  _src[15];
-	}
-
-	/// Convert LH to RH view matrix and vice versa.
-	inline void mtxViewFlipHandedness(float* _dst, const float* _src)
-	{
-		_dst[ 0] = -_src[ 0];
-		_dst[ 1] =  _src[ 1];
-		_dst[ 2] = -_src[ 2];
-		_dst[ 3] =  _src[ 3];
-		_dst[ 4] = -_src[ 4];
-		_dst[ 5] =  _src[ 5];
-		_dst[ 6] = -_src[ 6];
-		_dst[ 7] =  _src[ 7];
-		_dst[ 8] = -_src[ 8];
-		_dst[ 9] =  _src[ 9];
-		_dst[10] = -_src[10];
-		_dst[11] =  _src[11];
-		_dst[12] = -_src[12];
-		_dst[13] =  _src[13];
-		_dst[14] = -_src[14];
-		_dst[15] =  _src[15];
-	}
-
-	inline void calcNormal(float _result[3], const float _va[3], const float _vb[3], const float _vc[3])
-	{
-		const bx::Vec3 va    = bx::load(_va);
-		const bx::Vec3 vb    = bx::load(_vb);
-		const bx::Vec3 vc    = bx::load(_vc);
-		const bx::Vec3 ba    = bx::sub(vb, va);
-		const bx::Vec3 ca    = bx::sub(vc, va);
-		const bx::Vec3 baxca = bx::cross(ba, ca);
-
-		bx::store(_result, bx::normalize(baxca) );
-	}
-
-	inline void calcPlane(float _result[4], const float _va[3], const float _vb[3], const float _vc[3])
-	{
-		float normal[3];
-		calcNormal(normal, _va, _vb, _vc);
-		calcPlane(_result, normal, _va);
-	}
-
-	inline void calcPlane(float _result[4], const float _normal[3], const float _pos[3])
-	{
-		_result[0] = _normal[0];
-		_result[1] = _normal[1];
-		_result[2] = _normal[2];
-		_result[3] = -dot(bx::load(_normal), bx::load(_pos) );
+	inline Vec3 calcNormal(const Vec3& _va, const Vec3& _vb, const Vec3& _vc)
+	{
+		const Vec3 ba    = sub(_vb, _va);
+		const Vec3 ca    = sub(_vc, _va);
+		const Vec3 baxca = cross(ba, ca);
+
+		return normalize(baxca);
+	}
+
+	inline void calcPlane(Plane& _outPlane, const Vec3& _va, const Vec3& _vb, const Vec3& _vc)
+	{
+		Vec3 normal = calcNormal(_va, _vb, _vc);
+		calcPlane(_outPlane, normal, _va);
+	}
+
+	inline void calcPlane(Plane& _outPlane, const Vec3& _normal, const Vec3& _pos)
+	{
+		_outPlane.normal = _normal;
+		_outPlane.dist   = -dot(_normal, _pos);
+	}
+
+	inline float distance(const Plane& _plane, const Vec3& _pos)
+	{
+		return dot(_plane.normal, _pos) + _plane.dist;
 	}
 	}
 
 
 	inline BX_CONST_FUNC float toLinear(float _a)
 	inline BX_CONST_FUNC float toLinear(float _a)

+ 1 - 1
bx.mod/bx/include/bx/inline/mpscqueue.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/mutex.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/pixelformat.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 19 - 7
bx.mod/bx/include/bx/inline/readerwriter.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -273,7 +273,7 @@ namespace bx
 	}
 	}
 
 
 	template<typename Ty>
 	template<typename Ty>
-	int32_t read(ReaderI* _reader, Ty& _value, Error* _err)
+	inline int32_t read(ReaderI* _reader, Ty& _value, Error* _err)
 	{
 	{
 		BX_ERROR_SCOPE(_err);
 		BX_ERROR_SCOPE(_err);
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
@@ -281,7 +281,7 @@ namespace bx
 	}
 	}
 
 
 	template<typename Ty>
 	template<typename Ty>
-	int32_t readHE(ReaderI* _reader, Ty& _value, bool _fromLittleEndian, Error* _err)
+	inline int32_t readHE(ReaderI* _reader, Ty& _value, bool _fromLittleEndian, Error* _err)
 	{
 	{
 		BX_ERROR_SCOPE(_err);
 		BX_ERROR_SCOPE(_err);
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
@@ -329,7 +329,7 @@ namespace bx
 	}
 	}
 
 
 	template<typename Ty>
 	template<typename Ty>
-	int32_t write(WriterI* _writer, const Ty& _value, Error* _err)
+	inline int32_t write(WriterI* _writer, const Ty& _value, Error* _err)
 	{
 	{
 		BX_ERROR_SCOPE(_err);
 		BX_ERROR_SCOPE(_err);
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
@@ -337,7 +337,7 @@ namespace bx
 	}
 	}
 
 
 	template<typename Ty>
 	template<typename Ty>
-	int32_t writeLE(WriterI* _writer, const Ty& _value, Error* _err)
+	inline int32_t writeLE(WriterI* _writer, const Ty& _value, Error* _err)
 	{
 	{
 		BX_ERROR_SCOPE(_err);
 		BX_ERROR_SCOPE(_err);
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
@@ -346,8 +346,14 @@ namespace bx
 		return result;
 		return result;
 	}
 	}
 
 
+	template<>
+	inline int32_t writeLE(WriterI* _writer, const float& _value, Error* _err)
+	{
+		return writeLE(_writer, floatToBits(_value), _err);
+	}
+
 	template<typename Ty>
 	template<typename Ty>
-	int32_t writeBE(WriterI* _writer, const Ty& _value, Error* _err)
+	inline int32_t writeBE(WriterI* _writer, const Ty& _value, Error* _err)
 	{
 	{
 		BX_ERROR_SCOPE(_err);
 		BX_ERROR_SCOPE(_err);
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
@@ -356,6 +362,12 @@ namespace bx
 		return result;
 		return result;
 	}
 	}
 
 
+	template<>
+	inline int32_t writeBE(WriterI* _writer, const float& _value, Error* _err)
+	{
+		return writeBE(_writer, floatToBits(_value), _err);
+	}
+
 	inline int64_t skip(SeekerI* _seeker, int64_t _offset)
 	inline int64_t skip(SeekerI* _seeker, int64_t _offset)
 	{
 	{
 		return _seeker->seek(_offset, Whence::Current);
 		return _seeker->seek(_offset, Whence::Current);
@@ -392,7 +404,7 @@ namespace bx
 	}
 	}
 
 
 	template<typename Ty>
 	template<typename Ty>
-	int32_t peek(ReaderSeekerI* _reader, Ty& _value, Error* _err)
+	inline int32_t peek(ReaderSeekerI* _reader, Ty& _value, Error* _err)
 	{
 	{
 		BX_ERROR_SCOPE(_err);
 		BX_ERROR_SCOPE(_err);
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );
 		BX_STATIC_ASSERT(isTriviallyCopyable<Ty>() );

+ 1 - 1
bx.mod/bx/include/bx/inline/ringbuffer.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 5 - 1
bx.mod/bx/include/bx/inline/rng.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -103,6 +103,10 @@ namespace bx
 
 
 	inline void generateSphereHammersley(void* _data, uint32_t _stride, uint32_t _num, float _scale)
 	inline void generateSphereHammersley(void* _data, uint32_t _stride, uint32_t _num, float _scale)
 	{
 	{
+		// Reference(s):
+		// - Sampling with Hammersley and Halton Points
+		//   https://web.archive.org/web/20190207230709/http://www.cse.cuhk.edu.hk/~ttwong/papers/udpoint/udpoints.html
+
 		uint8_t* data = (uint8_t*)_data;
 		uint8_t* data = (uint8_t*)_data;
 
 
 		for (uint32_t ii = 0; ii < _num; ii++)
 		for (uint32_t ii = 0; ii < _num; ii++)

+ 1 - 1
bx.mod/bx/include/bx/inline/simd128_langext.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/simd128_neon.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/simd128_ref.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/simd128_sse.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/simd256_avx.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/simd256_ref.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/simd_ni.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/inline/sort.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 5 - 2
bx.mod/bx/include/bx/inline/spscqueue.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -9,7 +9,10 @@
 
 
 namespace bx
 namespace bx
 {
 {
-	// http://drdobbs.com/article/print?articleId=210604448&siteSectionName=
+	// Reference(s):
+	// - Writing Lock-Free Code: A Corrected Queue
+	//   https://web.archive.org/web/20190207230604/http://www.drdobbs.com/parallel/writing-lock-free-code-a-corrected-queue/210604448
+	//
 	inline SpScUnboundedQueue::SpScUnboundedQueue(AllocatorI* _allocator)
 	inline SpScUnboundedQueue::SpScUnboundedQueue(AllocatorI* _allocator)
 		: m_allocator(_allocator)
 		: m_allocator(_allocator)
 		, m_first(BX_NEW(m_allocator, Node)(NULL) )
 		, m_first(BX_NEW(m_allocator, Node)(NULL) )

+ 40 - 1
bx.mod/bx/include/bx/inline/string.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -241,4 +241,43 @@ namespace bx
 		return StringView(_str, _start, _len);
 		return StringView(_str, _start, _len);
 	}
 	}
 
 
+	inline LineReader::LineReader(const bx::StringView& _str)
+		: m_str(_str)
+	{
+		reset();
+	}
+
+	inline void LineReader::reset()
+	{
+		m_curr = m_str;
+		m_line = 0;
+	}
+
+	inline StringView LineReader::next()
+	{
+		if (m_curr.getPtr() != m_str.getTerm() )
+		{
+			++m_line;
+
+			StringView curr(m_curr);
+			m_curr = bx::strFindNl(m_curr);
+
+			StringView line(curr.getPtr(), m_curr.getPtr() );
+
+			return strRTrim(line, "\n\r");
+		}
+
+		return m_curr;
+	}
+
+	inline bool LineReader::isDone() const
+	{
+		return m_curr.getPtr() == m_str.getTerm();
+	}
+
+	inline uint32_t LineReader::getLine() const
+	{
+		return m_line;
+	}
+
 } // namespace bx
 } // namespace bx

+ 4 - 15
bx.mod/bx/include/bx/inline/uint32_t.inl

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -537,21 +537,10 @@ namespace bx
 		return result;
 		return result;
 	}
 	}
 
 
-	inline BX_CONSTEXPR_FUNC uint32_t strideAlign16(uint32_t _offset, uint32_t _stride)
-	{
-		const uint32_t align  = uint32_lcm(16, _stride);
-		const uint32_t mod    = uint32_mod(_offset, align);
-		const uint32_t mask   = uint32_cmpeq(mod, 0);
-		const uint32_t tmp0   = uint32_selb(mask, 0, align);
-		const uint32_t tmp1   = uint32_add(_offset, tmp0);
-		const uint32_t result = uint32_sub(tmp1, mod);
-
-		return result;
-	}
-
-	inline BX_CONSTEXPR_FUNC uint32_t strideAlign256(uint32_t _offset, uint32_t _stride)
+	template<uint32_t Min>
+	inline BX_CONSTEXPR_FUNC uint32_t strideAlign(uint32_t _offset, uint32_t _stride)
 	{
 	{
-		const uint32_t align  = uint32_lcm(256, _stride);
+		const uint32_t align  = uint32_lcm(Min, _stride);
 		const uint32_t mod    = uint32_mod(_offset, align);
 		const uint32_t mod    = uint32_mod(_offset, align);
 		const uint32_t mask   = uint32_cmpeq(mod, 0);
 		const uint32_t mask   = uint32_cmpeq(mod, 0);
 		const uint32_t tmp0   = uint32_selb(mask, 0, align);
 		const uint32_t tmp0   = uint32_selb(mask, 0, align);

+ 6 - 2
bx.mod/bx/include/bx/macros.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -115,7 +115,11 @@
 
 
 /// The return value of the function is solely a function of the arguments.
 /// The return value of the function is solely a function of the arguments.
 ///
 ///
-#define BX_CONSTEXPR_FUNC constexpr BX_CONST_FUNC
+#if (BX_COMPILER_MSVC && (BX_COMPILER_MSVC <= 1900)) || (BX_COMPILER_GCC && (__cplusplus < 201402L))
+#	define BX_CONSTEXPR_FUNC BX_CONST_FUNC
+#else
+#	define BX_CONSTEXPR_FUNC constexpr BX_CONST_FUNC
+#endif // BX_COMPILER_MSVC && (BX_COMPILER_MSVC <= 1900)
 
 
 ///
 ///
 #define BX_STATIC_ASSERT(_condition, ...) static_assert(_condition, "" __VA_ARGS__)
 #define BX_STATIC_ASSERT(_condition, ...) static_assert(_condition, "" __VA_ARGS__)

+ 1 - 1
bx.mod/bx/include/bx/maputil.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 164 - 134
bx.mod/bx/include/bx/math.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -53,9 +53,25 @@ namespace bx
 	///
 	///
 	struct Vec3
 	struct Vec3
 	{
 	{
+		///
+		Vec3();
+
+		///
+		explicit constexpr Vec3(float _v);
+
+		///
+		constexpr Vec3(float _x, float _y, float _z);
+
 		float x, y, z;
 		float x, y, z;
 	};
 	};
 
 
+	///
+	struct Plane
+	{
+		Vec3  normal;
+		float dist;
+	};
+
 	///
 	///
 	struct Quaternion
 	struct Quaternion
 	{
 	{
@@ -268,10 +284,15 @@ namespace bx
 	BX_CONST_FUNC float angleLerp(float _a, float _b, float _t);
 	BX_CONST_FUNC float angleLerp(float _a, float _b, float _t);
 
 
 	///
 	///
-	Vec3 load(const void* _ptr);
+	template<typename Ty>
+	Ty load(const void* _ptr);
+
+	///
+	template<typename Ty>
+	void store(void* _ptr, const Ty& _a);
 
 
 	///
 	///
-	void store(void* _ptr, const Vec3 _a);
+	BX_CONSTEXPR_FUNC Vec3 round(const Vec3 _a);
 
 
 	///
 	///
 	BX_CONSTEXPR_FUNC Vec3 abs(const Vec3 _a);
 	BX_CONSTEXPR_FUNC Vec3 abs(const Vec3 _a);
@@ -312,6 +333,12 @@ namespace bx
 	///
 	///
 	BX_CONST_FUNC float length(const Vec3 _a);
 	BX_CONST_FUNC float length(const Vec3 _a);
 
 
+	///
+	BX_CONST_FUNC float distanceSq(const Vec3 _a, const Vec3 _b);
+
+	///
+	BX_CONST_FUNC float distance(const Vec3 _a, const Vec3 _b);
+
 	///
 	///
 	BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t);
 	BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t);
 
 
@@ -375,15 +402,6 @@ namespace bx
 	///
 	///
 	BX_CONST_FUNC Quaternion rotateZ(float _az);
 	BX_CONST_FUNC Quaternion rotateZ(float _az);
 
 
-	///
-	void vec3Add(float* _result, const float* _a, const float* _b);
-
-	///
-	void vec3Sub(float* _result, const float* _a, const float* _b);
-
-	///
-	float vec3Dot(const float* _a, const float* _b);
-
 	///
 	///
 	void mtxIdentity(float* _result);
 	void mtxIdentity(float* _result);
 
 
@@ -397,109 +415,121 @@ namespace bx
 	void mtxScale(float* _result, float _scale);
 	void mtxScale(float* _result, float _scale);
 
 
 	///
 	///
-	void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos);
-
-	///
-	void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos, float _angle);
-
-	///
-	void mtxQuat(float* _result, const float* _quat);
-
-	///
-	void mtxQuatTranslation(float* _result, const float* _quat, const float* _translation);
-
-	///
-	void mtxQuatTranslationHMD(float* _result, const float* _quat, const float* _translation);
-
-	///
-	void mtxLookAtLh(float* _result, const Vec3& _eye, const Vec3& _at, const Vec3& _up = { 0.0f, 1.0f, 0.0f });
-
-	///
-	void mtxLookAtRh(float* _result, const Vec3& _eye, const Vec3& _at, const Vec3& _up = { 0.0f, 1.0f, 0.0f });
-
-	///
-	void mtxLookAt(float* _result, const Vec3& _eye, const Vec3& _at, const Vec3& _up = { 0.0f, 1.0f, 0.0f });
-
-	///
-	void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc);
-
-	///
-	void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc);
-
-	///
-	void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc);
-
-	///
-	void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc);
-
-	///
-	void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc);
-
-	///
-	void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc);
-
-	///
-	void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc);
-
-	///
-	void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc);
-
-	///
-	void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc);
-
-	///
-	void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc);
-
-	///
-	void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
-
-	///
-	void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
-
-	///
-	void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
-
-	///
-	void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc);
-
-	///
-	void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
-
-	///
-	void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
-
-	///
-	void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc);
-
-	///
-	void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
-
-	///
-	void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
-
-	///
-	void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc);
-
-	///
-	void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
-
-	///
-	void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
-
-	///
-	void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc);
-
-	///
-	void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
-
-	///
-	void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc);
-
-	///
-	void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc);
-
-	///
-	void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc);
+	void mtxFromNormal(
+		  float* _result
+		, const Vec3& _normal
+		, float _scale
+		, const Vec3& _pos
+		);
+
+	///
+	void mtxFromNormal(
+		  float* _result
+		, const Vec3& _normal
+		, float _scale
+		, const Vec3& _pos
+		, float _angle
+		);
+
+	///
+	void mtxQuat(float* _result, const Quaternion& _quat);
+
+	///
+	void mtxQuatTranslation(float* _result, const Quaternion& _quat, const Vec3& _translation);
+
+	///
+	void mtxQuatTranslationHMD(float* _result, const Quaternion& _quat, const Vec3& _translation);
+
+	///
+	void mtxLookAt(
+		  float* _result
+		, const Vec3& _eye
+		, const Vec3& _at
+		, const Vec3& _up = { 0.0f, 1.0f, 0.0f }
+		, Handness::Enum _handness = Handness::Left
+		);
+
+	///
+	void mtxProj(
+		  float* _result
+		, float _ut
+		, float _dt
+		, float _lt
+		, float _rt
+		, float _near
+		, float _far
+		, bool _homogeneousNdc
+		, Handness::Enum _handness = Handness::Left
+		);
+
+	///
+	void mtxProj(
+		  float* _result
+		, const float _fov[4]
+		, float _near
+		, float _far
+		, bool _homogeneousNdc
+		, Handness::Enum _handness = Handness::Left
+		);
+
+	///
+	void mtxProj(
+		  float* _result
+		, float _fovy
+		, float _aspect
+		, float _near
+		, float _far
+		, bool _homogeneousNdc
+		, Handness::Enum _handness = Handness::Left
+		);
+
+	///
+	void mtxProjInf(
+		  float* _result
+		, const float _fov[4]
+		, float _near
+		, bool _homogeneousNdc
+		, Handness::Enum _handness = Handness::Left
+		, NearFar::Enum _nearFar = NearFar::Default
+		);
+
+	///
+	void mtxProjInf(
+		  float* _result
+		, float _ut
+		, float _dt
+		, float _lt
+		, float _rt
+		, float _near
+		, bool _homogeneousNdc
+		, Handness::Enum _handness = Handness::Left
+		, NearFar::Enum _nearFar = NearFar::Default
+		);
+
+	///
+	void mtxProjInf(
+		  float* _result
+		, float _fovy
+		, float _aspect
+		, float _near
+		, bool _homogeneousNdc
+		, Handness::Enum _handness = Handness::Left
+		, NearFar::Enum _nearFar = NearFar::Default
+		);
+
+	///
+	void mtxOrtho(
+		  float* _result
+		, float _left
+		, float _right
+		, float _bottom
+		, float _top
+		, float _near
+		, float _far
+		, float _offset
+		, bool _homogeneousNdc
+		, Handness::Enum _handness = Handness::Left
+		);
 
 
 	///
 	///
 	void mtxRotateX(float* _result, float _ax);
 	void mtxRotateX(float* _result, float _ax);
@@ -520,22 +550,27 @@ namespace bx
 	void mtxRotateZYX(float* _result, float _ax, float _ay, float _az);
 	void mtxRotateZYX(float* _result, float _ax, float _ay, float _az);
 
 
 	///
 	///
-	void mtxSRT(float* _result, float _sx, float _sy, float _sz, float _ax, float _ay, float _az, float _tx, float _ty, float _tz);
+	void mtxSRT(
+		  float* _result
+		, float _sx
+		, float _sy
+		, float _sz
+		, float _ax
+		, float _ay
+		, float _az
+		, float _tx
+		, float _ty
+		, float _tz
+		);
 
 
 	///
 	///
-	void vec3MulMtx(float* _result, const float* _vec, const float* _mat);
+	Vec3 mul(const Vec3& _vec, const float* _mat);
 
 
 	///
 	///
-	void vec3MulMtxXyz0(float* _result, const float* _vec, const float* _mat);
+	Vec3 mulXyz0(const Vec3& _vec, const float* _mat);
 
 
 	///
 	///
-	void vec3MulMtxH(float* _result, const float* _vec, const float* _mat);
-
-	///
-	void vec4Mul(float* _result, const float* _a, const float* _b);
-
-	///
-	void vec4Mul(float* _result, const float* _a, float _b);
+	Vec3 mulH(const Vec3& _vec, const float* _mat);
 
 
 	///
 	///
 	void vec4MulMtx(float* _result, const float* _vec, const float* _mat);
 	void vec4MulMtx(float* _result, const float* _vec, const float* _mat);
@@ -552,22 +587,17 @@ namespace bx
 	///
 	///
 	void mtxInverse(float* _result, const float* _a);
 	void mtxInverse(float* _result, const float* _a);
 
 
-	/// Convert LH to RH projection matrix and vice versa.
-	///
-	void mtxProjFlipHandedness(float* _dst, const float* _src);
-
-	/// Convert LH to RH view matrix and vice versa.
 	///
 	///
-	void mtxViewFlipHandedness(float* _dst, const float* _src);
+	Vec3 calcNormal(const Vec3& _va, const Vec3& _vb, const Vec3& _vc);
 
 
 	///
 	///
-	void calcNormal(float _result[3], const float _va[3], const float _vb[3], const float _vc[3]);
+	void calcPlane(Plane& _outPlane, const Vec3& _va, const Vec3& _vb, const Vec3& _vc);
 
 
 	///
 	///
-	void calcPlane(float _result[4], const float _va[3], const float _vb[3], const float _vc[3]);
+	void calcPlane(Plane& _outPlane, const Vec3& _normal, const Vec3& _pos);
 
 
 	///
 	///
-	void calcPlane(float _result[4], const float _normal[3], const float _pos[3]);
+	float distance(const Plane& _plane, const Vec3& _pos);
 
 
 	///
 	///
 	void calcLinearFit2D(float _result[2], const void* _points, uint32_t _stride, uint32_t _numPoints);
 	void calcLinearFit2D(float _result[2], const void* _points, uint32_t _stride, uint32_t _numPoints);

+ 1 - 1
bx.mod/bx/include/bx/mpscqueue.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/mutex.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/os.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/pixelformat.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 46 - 3
bx.mod/bx/include/bx/platform.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -133,8 +133,14 @@
 #endif //
 #endif //
 
 
 #if BX_CPU_PPC
 #if BX_CPU_PPC
-#	undef  BX_CPU_ENDIAN_BIG
-#	define BX_CPU_ENDIAN_BIG 1
+// _LITTLE_ENDIAN exists on ppc64le.
+#	if _LITTLE_ENDIAN
+#		undef  BX_CPU_ENDIAN_LITTLE
+#		define BX_CPU_ENDIAN_LITTLE 1
+#	else
+#		undef  BX_CPU_ENDIAN_BIG
+#		define BX_CPU_ENDIAN_BIG 1
+#	endif
 #else
 #else
 #	undef  BX_CPU_ENDIAN_LITTLE
 #	undef  BX_CPU_ENDIAN_LITTLE
 #	define BX_CPU_ENDIAN_LITTLE 1
 #	define BX_CPU_ENDIAN_LITTLE 1
@@ -246,6 +252,7 @@
 #	endif // BX_CRT_*
 #	endif // BX_CRT_*
 #endif // !BX_CRT_NONE
 #endif // !BX_CRT_NONE
 
 
+///
 #define BX_PLATFORM_POSIX (0   \
 #define BX_PLATFORM_POSIX (0   \
 	||  BX_PLATFORM_ANDROID    \
 	||  BX_PLATFORM_ANDROID    \
 	||  BX_PLATFORM_BSD        \
 	||  BX_PLATFORM_BSD        \
@@ -260,6 +267,7 @@
 	||  BX_PLATFORM_STEAMLINK  \
 	||  BX_PLATFORM_STEAMLINK  \
 	)
 	)
 
 
+///
 #define BX_PLATFORM_NONE !(0   \
 #define BX_PLATFORM_NONE !(0   \
 	||  BX_PLATFORM_ANDROID    \
 	||  BX_PLATFORM_ANDROID    \
 	||  BX_PLATFORM_BSD        \
 	||  BX_PLATFORM_BSD        \
@@ -277,6 +285,41 @@
 	||  BX_PLATFORM_XBOXONE    \
 	||  BX_PLATFORM_XBOXONE    \
 	)
 	)
 
 
+///
+#define BX_PLATFORM_OS_CONSOLE  (0 \
+	||  BX_PLATFORM_NX             \
+	||  BX_PLATFORM_PS4            \
+	||  BX_PLATFORM_WINRT          \
+	||  BX_PLATFORM_XBOXONE        \
+	)
+
+///
+#define BX_PLATFORM_OS_DESKTOP  (0 \
+	||  BX_PLATFORM_BSD            \
+	||  BX_PLATFORM_HURD           \
+	||  BX_PLATFORM_LINUX          \
+	||  BX_PLATFORM_OSX            \
+	||  BX_PLATFORM_WINDOWS        \
+	)
+
+///
+#define BX_PLATFORM_OS_EMBEDDED (0 \
+	||  BX_PLATFORM_RPI            \
+	||  BX_PLATFORM_STEAMLINK      \
+	)
+
+///
+#define BX_PLATFORM_OS_MOBILE   (0 \
+	||  BX_PLATFORM_ANDROID        \
+	||  BX_PLATFORM_IOS            \
+	)
+
+///
+#define BX_PLATFORM_OS_WEB      (0 \
+	||  BX_PLATFORM_EMSCRIPTEN     \
+	)
+
+///
 #if BX_COMPILER_GCC
 #if BX_COMPILER_GCC
 #	define BX_COMPILER_NAME "GCC "       \
 #	define BX_COMPILER_NAME "GCC "       \
 		BX_STRINGIZE(__GNUC__) "."       \
 		BX_STRINGIZE(__GNUC__) "."       \

+ 1 - 1
bx.mod/bx/include/bx/process.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 50 - 27
bx.mod/bx/include/bx/readerwriter.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -10,6 +10,7 @@
 #include "endian.h"
 #include "endian.h"
 #include "error.h"
 #include "error.h"
 #include "filepath.h"
 #include "filepath.h"
+#include "math.h"
 #include "string.h"
 #include "string.h"
 #include "uint32_t.h"
 #include "uint32_t.h"
 
 
@@ -21,94 +22,116 @@ BX_ERROR_RESULT(BX_ERROR_READERWRITER_ALREADY_OPEN, BX_MAKEFOURCC('R', 'W', 0, 5
 
 
 namespace bx
 namespace bx
 {
 {
-	///
+	/// The position from where offset is added.
 	struct Whence
 	struct Whence
 	{
 	{
+		/// Whence values:
 		enum Enum
 		enum Enum
 		{
 		{
-			Begin,
-			Current,
-			End,
+			Begin,   //!< From begining of file.
+			Current, //!< From current position of file.
+			End,     //!< From end of file.
 		};
 		};
 	};
 	};
 
 
-	///
+	/// Reader interface.
 	struct BX_NO_VTABLE ReaderI
 	struct BX_NO_VTABLE ReaderI
 	{
 	{
+		///
 		virtual ~ReaderI() = 0;
 		virtual ~ReaderI() = 0;
+
+		///
 		virtual int32_t read(void* _data, int32_t _size, Error* _err) = 0;
 		virtual int32_t read(void* _data, int32_t _size, Error* _err) = 0;
 	};
 	};
 
 
-	///
+	/// Writer interface.
 	struct BX_NO_VTABLE WriterI
 	struct BX_NO_VTABLE WriterI
 	{
 	{
+		///
 		virtual ~WriterI() = 0;
 		virtual ~WriterI() = 0;
+
+		///
 		virtual int32_t write(const void* _data, int32_t _size, Error* _err) = 0;
 		virtual int32_t write(const void* _data, int32_t _size, Error* _err) = 0;
 	};
 	};
 
 
-	///
+	/// Seeker interface.
 	struct BX_NO_VTABLE SeekerI
 	struct BX_NO_VTABLE SeekerI
 	{
 	{
+		///
 		virtual ~SeekerI() = 0;
 		virtual ~SeekerI() = 0;
+
+		///
 		virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) = 0;
 		virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) = 0;
 	};
 	};
 
 
-	///
+	/// Reader seeker interface.
 	struct BX_NO_VTABLE ReaderSeekerI : public ReaderI, public SeekerI
 	struct BX_NO_VTABLE ReaderSeekerI : public ReaderI, public SeekerI
 	{
 	{
 	};
 	};
 
 
-	///
+	/// Writer seeker interface.
 	struct BX_NO_VTABLE WriterSeekerI : public WriterI, public SeekerI
 	struct BX_NO_VTABLE WriterSeekerI : public WriterI, public SeekerI
 	{
 	{
 	};
 	};
 
 
-	///
+	/// Open for reading interface.
 	struct BX_NO_VTABLE ReaderOpenI
 	struct BX_NO_VTABLE ReaderOpenI
 	{
 	{
+		///
 		virtual ~ReaderOpenI() = 0;
 		virtual ~ReaderOpenI() = 0;
+
+		///
 		virtual bool open(const FilePath& _filePath, Error* _err) = 0;
 		virtual bool open(const FilePath& _filePath, Error* _err) = 0;
 	};
 	};
 
 
-	///
+	/// Open for writing interface.
 	struct BX_NO_VTABLE WriterOpenI
 	struct BX_NO_VTABLE WriterOpenI
 	{
 	{
+		///
 		virtual ~WriterOpenI() = 0;
 		virtual ~WriterOpenI() = 0;
+
+		///
 		virtual bool open(const FilePath& _filePath, bool _append, Error* _err) = 0;
 		virtual bool open(const FilePath& _filePath, bool _append, Error* _err) = 0;
 	};
 	};
 
 
-	///
+	/// Open process interface.
 	struct BX_NO_VTABLE ProcessOpenI
 	struct BX_NO_VTABLE ProcessOpenI
 	{
 	{
+		///
 		virtual ~ProcessOpenI() = 0;
 		virtual ~ProcessOpenI() = 0;
+
+		///
 		virtual bool open(const FilePath& _filePath, const StringView& _args, Error* _err) = 0;
 		virtual bool open(const FilePath& _filePath, const StringView& _args, Error* _err) = 0;
 	};
 	};
 
 
-	///
+	/// Closer interface.
 	struct BX_NO_VTABLE CloserI
 	struct BX_NO_VTABLE CloserI
 	{
 	{
+		///
 		virtual ~CloserI() = 0;
 		virtual ~CloserI() = 0;
+
+		///
 		virtual void close() = 0;
 		virtual void close() = 0;
 	};
 	};
 
 
-	///
+	/// File reader interface.
 	struct BX_NO_VTABLE FileReaderI : public ReaderOpenI, public CloserI, public ReaderSeekerI
 	struct BX_NO_VTABLE FileReaderI : public ReaderOpenI, public CloserI, public ReaderSeekerI
 	{
 	{
 	};
 	};
 
 
-	///
+	/// File writer interface.
 	struct BX_NO_VTABLE FileWriterI : public WriterOpenI, public CloserI, public WriterSeekerI
 	struct BX_NO_VTABLE FileWriterI : public WriterOpenI, public CloserI, public WriterSeekerI
 	{
 	{
 	};
 	};
 
 
-	///
+	/// Memory block interface.
 	struct BX_NO_VTABLE MemoryBlockI
 	struct BX_NO_VTABLE MemoryBlockI
 	{
 	{
 		virtual void* more(uint32_t _size = 0) = 0;
 		virtual void* more(uint32_t _size = 0) = 0;
 		virtual uint32_t getSize() = 0;
 		virtual uint32_t getSize() = 0;
 	};
 	};
 
 
-	///
+	/// Static memory block interface.
 	class StaticMemoryBlock : public MemoryBlockI
 	class StaticMemoryBlock : public MemoryBlockI
 	{
 	{
 	public:
 	public:
@@ -125,11 +148,11 @@ namespace bx
 		virtual uint32_t getSize() override;
 		virtual uint32_t getSize() override;
 
 
 	private:
 	private:
-		void* m_data;
+		void*    m_data;
 		uint32_t m_size;
 		uint32_t m_size;
 	};
 	};
 
 
-	///
+	/// Memory block.
 	class MemoryBlock : public MemoryBlockI
 	class MemoryBlock : public MemoryBlockI
 	{
 	{
 	public:
 	public:
@@ -147,8 +170,8 @@ namespace bx
 
 
 	private:
 	private:
 		AllocatorI* m_allocator;
 		AllocatorI* m_allocator;
-		void* m_data;
-		uint32_t m_size;
+		void*       m_data;
+		uint32_t    m_size;
 	};
 	};
 
 
 	/// Sizer writer. Dummy writter that only counts number of bytes written into it.
 	/// Sizer writer. Dummy writter that only counts number of bytes written into it.
@@ -172,7 +195,7 @@ namespace bx
 		int64_t m_top;
 		int64_t m_top;
 	};
 	};
 
 
-	///
+	/// Memory reader.
 	class MemoryReader : public ReaderSeekerI
 	class MemoryReader : public ReaderSeekerI
 	{
 	{
 	public:
 	public:
@@ -203,7 +226,7 @@ namespace bx
 		int64_t m_top;
 		int64_t m_top;
 	};
 	};
 
 
-	///
+	/// Memory writer.
 	class MemoryWriter : public WriterSeekerI
 	class MemoryWriter : public WriterSeekerI
 	{
 	{
 	public:
 	public:
@@ -222,9 +245,9 @@ namespace bx
 	private:
 	private:
 		MemoryBlockI* m_memBlock;
 		MemoryBlockI* m_memBlock;
 		uint8_t* m_data;
 		uint8_t* m_data;
-		int64_t m_pos;
-		int64_t m_top;
-		int64_t m_size;
+		int64_t  m_pos;
+		int64_t  m_top;
+		int64_t  m_size;
 	};
 	};
 
 
 	/// Static (fixed size) memory block writer.
 	/// Static (fixed size) memory block writer.

+ 1 - 1
bx.mod/bx/include/bx/ringbuffer.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 2 - 4
bx.mod/bx/include/bx/rng.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -67,9 +67,7 @@ namespace bx
 	template <typename Ty>
 	template <typename Ty>
 	bx::Vec3 randUnitHemisphere(Ty* _rng, const bx::Vec3& _normal);
 	bx::Vec3 randUnitHemisphere(Ty* _rng, const bx::Vec3& _normal);
 
 
-	/// Sampling with Hammersley and Halton Points
-	/// http://www.cse.cuhk.edu.hk/~ttwong/papers/udpoint/udpoints.html
-	///
+	/// Sampling with Hammersley and Halton Points.
 	void generateSphereHammersley(void* _data, uint32_t _stride, uint32_t _num, float _scale = 1.0f);
 	void generateSphereHammersley(void* _data, uint32_t _stride, uint32_t _num, float _scale = 1.0f);
 
 
 	/// Fisher-Yates shuffle.
 	/// Fisher-Yates shuffle.

+ 1 - 1
bx.mod/bx/include/bx/semaphore.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/settings.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/simd_t.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/sort.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/spscqueue.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 41 - 2
bx.mod/bx/include/bx/string.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -21,6 +21,7 @@ namespace bx
 	};
 	};
 
 
 	/// Non-zero-terminated string view.
 	/// Non-zero-terminated string view.
+	///
 	class StringView
 	class StringView
 	{
 	{
 	public:
 	public:
@@ -77,9 +78,16 @@ namespace bx
 		///
 		///
 		void clear();
 		void clear();
 
 
+		/// Returns pointer to non-terminated string.
+		///
+		/// @attention Use of this pointer in standard C/C++ functions is not safe. You must use it
+		///   in conjunction with `getTerm()` or getLength()`.
 		///
 		///
 		const char* getPtr() const;
 		const char* getPtr() const;
 
 
+		/// Returns pointer past last character in string view.
+		///
+		/// @attention Dereferencing this pointer is not safe.
 		///
 		///
 		const char* getTerm() const;
 		const char* getTerm() const;
 
 
@@ -261,7 +269,7 @@ namespace bx
 	StringView findIdentifierMatch(const StringView& _str, const StringView& _word);
 	StringView findIdentifierMatch(const StringView& _str, const StringView& _word);
 
 
 	/// Finds any identifier from NULL terminated array of identifiers.
 	/// Finds any identifier from NULL terminated array of identifiers.
-	StringView findIdentifierMatch(const StringView& _str, const char** _words);
+	StringView findIdentifierMatch(const StringView& _str, const char** _words, int32_t _num = INT32_MAX);
 
 
 	/// Cross platform implementation of vsnprintf that returns number of
 	/// Cross platform implementation of vsnprintf that returns number of
 	/// characters which would have been written to the final string if
 	/// characters which would have been written to the final string if
@@ -273,6 +281,12 @@ namespace bx
 	/// enough space had been available.
 	/// enough space had been available.
 	int32_t snprintf(char* _out, int32_t _max, const char* _format, ...);
 	int32_t snprintf(char* _out, int32_t _max, const char* _format, ...);
 
 
+	///
+	int32_t vprintf(const char* _format, va_list _argList);
+
+	///
+	int32_t printf(const char* _format, ...);
+
 	/// Templatized snprintf.
 	/// Templatized snprintf.
 	template <typename Ty>
 	template <typename Ty>
 	void stringPrintfVargs(Ty& _out, const char* _format, va_list _argList);
 	void stringPrintfVargs(Ty& _out, const char* _format, va_list _argList);
@@ -321,6 +335,31 @@ namespace bx
 	/// Converts string to 32-bit unsigned integer value.
 	/// Converts string to 32-bit unsigned integer value.
 	bool fromString(uint32_t* _out, const StringView& _str);
 	bool fromString(uint32_t* _out, const StringView& _str);
 
 
+	///
+	class LineReader
+	{
+	public:
+		///
+		LineReader(const bx::StringView& _str);
+
+		///
+		void reset();
+
+		///
+		StringView next();
+
+		///
+		bool isDone() const;
+
+		///
+		uint32_t getLine() const;
+
+	private:
+		const bx::StringView m_str;
+		bx::StringView m_curr;
+		uint32_t m_line;
+	};
+
 } // namespace bx
 } // namespace bx
 
 
 #include "inline/string.inl"
 #include "inline/string.inl"

+ 1 - 1
bx.mod/bx/include/bx/thread.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/include/bx/timer.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 4 - 7
bx.mod/bx/include/bx/uint32_t.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -217,13 +217,10 @@ namespace bx
 	///
 	///
 	BX_CONSTEXPR_FUNC uint32_t strideAlign(uint32_t _offset, uint32_t _stride);
 	BX_CONSTEXPR_FUNC uint32_t strideAlign(uint32_t _offset, uint32_t _stride);
 
 
-	/// Align to arbitrary stride and 16-bytes.
+	/// Align to arbitrary stride and Min bytes.
 	///
 	///
-	BX_CONSTEXPR_FUNC uint32_t strideAlign16(uint32_t _offset, uint32_t _stride);
-
-	/// Align to arbitrary stride and 256-bytes.
-	///
-	BX_CONSTEXPR_FUNC uint32_t strideAlign256(uint32_t _offset, uint32_t _stride);
+	template<uint32_t Min>
+	BX_CONSTEXPR_FUNC uint32_t strideAlign(uint32_t _offset, uint32_t _stride);
 
 
 	/// Convert float to half-float.
 	/// Convert float to half-float.
 	///
 	///

+ 1 - 1
bx.mod/bx/include/bx/url.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

File diff suppressed because it is too large
+ 570 - 277
bx.mod/bx/include/compat/msvc/dirent.h


+ 1 - 1
bx.mod/bx/makefile

@@ -1,5 +1,5 @@
 #
 #
-# Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+# Copyright 2011-2019 Branimir Karadzic. All rights reserved.
 # License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 # License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 #
 #
 
 

+ 1 - 1
bx.mod/bx/scripts/bin2c.lua

@@ -1,5 +1,5 @@
 --
 --
--- Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 --
 --
 
 

+ 1 - 1
bx.mod/bx/scripts/bx.lua

@@ -1,5 +1,5 @@
 --
 --
--- Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 --
 --
 
 

+ 1 - 1
bx.mod/bx/scripts/genie.lua

@@ -1,5 +1,5 @@
 --
 --
--- Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 --
 --
 
 

+ 1 - 1
bx.mod/bx/scripts/lemon.lua

@@ -1,5 +1,5 @@
 --
 --
--- Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 --
 --
 
 

+ 2 - 41
bx.mod/bx/scripts/toolchain.lua

@@ -1,5 +1,5 @@
 --
 --
--- Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 --
 --
 
 
@@ -193,6 +193,7 @@ function toolchain(_buildDir, _libDir)
 	end
 	end
 
 
 	flags {
 	flags {
+		"Cpp14",
 		"ExtraWarnings",
 		"ExtraWarnings",
 	}
 	}
 
 
@@ -633,9 +634,6 @@ function toolchain(_buildDir, _libDir)
 			"-Wunused-value",
 			"-Wunused-value",
 			"-Wundef",
 			"-Wundef",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
 		linkoptions {
 		linkoptions {
 			"-Wl,--gc-sections",
 			"-Wl,--gc-sections",
 			"-static",
 			"-static",
@@ -722,9 +720,6 @@ function toolchain(_buildDir, _libDir)
 			"-Wundef",
 			"-Wundef",
 --			"-Wuseless-cast",
 --			"-Wuseless-cast",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
 		links {
 		links {
 			"rt",
 			"rt",
 			"dl",
 			"dl",
@@ -779,9 +774,6 @@ function toolchain(_buildDir, _libDir)
 			"-Wunused-value",
 			"-Wunused-value",
 			"-Wundef",
 			"-Wundef",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
 		links {
 		links {
 			"rt",
 			"rt",
 			"dl",
 			"dl",
@@ -798,9 +790,6 @@ function toolchain(_buildDir, _libDir)
 			"-Wunused-value",
 			"-Wunused-value",
 			"-Wundef",
 			"-Wundef",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
 		links {
 		links {
 			"rt",
 			"rt",
 			"dl",
 			"dl",
@@ -840,9 +829,6 @@ function toolchain(_buildDir, _libDir)
 			"-Wunused-value",
 			"-Wunused-value",
 			"-Wundef",
 			"-Wundef",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
 		linkoptions {
 		linkoptions {
 			"-no-canonical-prefixes",
 			"-no-canonical-prefixes",
 			"-Wl,--no-undefined",
 			"-Wl,--no-undefined",
@@ -860,7 +846,6 @@ function toolchain(_buildDir, _libDir)
 			"__STEAMLINK__=1", -- There is no special prefedined compiler symbol to detect SteamLink, faking it.
 			"__STEAMLINK__=1", -- There is no special prefedined compiler symbol to detect SteamLink, faking it.
 		}
 		}
 		buildoptions {
 		buildoptions {
-			"-std=c++14",
 			"-Wfatal-errors",
 			"-Wfatal-errors",
 			"-Wunused-value",
 			"-Wunused-value",
 			"-Wundef",
 			"-Wundef",
@@ -945,9 +930,6 @@ function toolchain(_buildDir, _libDir)
 			"-Wunused-value",
 			"-Wunused-value",
 			"-Wundef",
 			"-Wundef",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
 
 
 	configuration { "freebsd" }
 	configuration { "freebsd" }
 		targetdir (path.join(_buildDir, "freebsd/bin"))
 		targetdir (path.join(_buildDir, "freebsd/bin"))
@@ -1005,12 +987,6 @@ function toolchain(_buildDir, _libDir)
 		objdir (path.join(_buildDir, "osx_universal/bin"))
 		objdir (path.join(_buildDir, "osx_universal/bin"))
 
 
 	configuration { "osx" }
 	configuration { "osx" }
-		buildoptions_cpp {
-			"-std=c++14",
-		}
-		buildoptions_objcpp {
-			"-std=c++14",
-		}
 		buildoptions {
 		buildoptions {
 			"-Wfatal-errors",
 			"-Wfatal-errors",
 			"-msse2",
 			"-msse2",
@@ -1023,12 +999,6 @@ function toolchain(_buildDir, _libDir)
 		linkoptions {
 		linkoptions {
 			"-lc++",
 			"-lc++",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
-		buildoptions_objcpp {
-			"-std=c++14",
-		}
 		buildoptions {
 		buildoptions {
 			"-Wfatal-errors",
 			"-Wfatal-errors",
 			"-Wunused-value",
 			"-Wunused-value",
@@ -1172,9 +1142,6 @@ function toolchain(_buildDir, _libDir)
 			"$(SCE_ORBIS_SDK_DIR)/target/include",
 			"$(SCE_ORBIS_SDK_DIR)/target/include",
 			"$(SCE_ORBIS_SDK_DIR)/target/include_common",
 			"$(SCE_ORBIS_SDK_DIR)/target/include_common",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
 
 
 	configuration { "rpi" }
 	configuration { "rpi" }
 		targetdir (path.join(_buildDir, "rpi/bin"))
 		targetdir (path.join(_buildDir, "rpi/bin"))
@@ -1191,9 +1158,6 @@ function toolchain(_buildDir, _libDir)
 			"-Wunused-value",
 			"-Wunused-value",
 			"-Wundef",
 			"-Wundef",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
 		includedirs {
 		includedirs {
 			"/opt/vc/include",
 			"/opt/vc/include",
 			"/opt/vc/include/interface/vcos/pthreads",
 			"/opt/vc/include/interface/vcos/pthreads",
@@ -1223,9 +1187,6 @@ function toolchain(_buildDir, _libDir)
 			"-Wundef",
 			"-Wundef",
 			"--sysroot=$(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/riscv64-unknown-elf",
 			"--sysroot=$(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/riscv64-unknown-elf",
 		}
 		}
-		buildoptions_cpp {
-			"-std=c++14",
-		}
 
 
 	configuration {} -- reset configuration
 	configuration {} -- reset configuration
 
 

+ 1 - 1
bx.mod/bx/src/allocator.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/src/amalgamated.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- *  Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ *  Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  *  License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  *  License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/src/bx.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/src/bx_p.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 2 - 2
bx.mod/bx/src/commandline.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -39,7 +39,7 @@ namespace bx
 			switch (state)
 			switch (state)
 			{
 			{
 				case SkipWhitespace:
 				case SkipWhitespace:
-					for (; isSpace(*curr); ++curr) {}; // skip whitespace
+					for (; isSpace(*curr) && *curr!=_term; ++curr) {}; // skip whitespace
 					state = SetTerm;
 					state = SetTerm;
 					break;
 					break;
 
 

+ 1 - 1
bx.mod/bx/src/crtnone.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/src/debug.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/src/dtoa.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/src/easing.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 373 - 21
bx.mod/bx/src/file.cpp

@@ -1,24 +1,34 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
 #include "bx_p.h"
 #include "bx_p.h"
 #include <bx/file.h>
 #include <bx/file.h>
 
 
+#ifndef BX_CONFIG_CRT_FILE_READER_WRITER
+#	define BX_CONFIG_CRT_FILE_READER_WRITER !BX_CRT_NONE
+#endif // BX_CONFIG_CRT_FILE_READER_WRITER
+
+#ifndef BX_CONFIG_CRT_DIRECTORY_READER
+#	define BX_CONFIG_CRT_DIRECTORY_READER (BX_PLATFORM_OS_DESKTOP && !BX_CRT_NONE)
+#endif // BX_CONFIG_CRT_DIRECTORY_READER
+
 #if BX_CRT_NONE
 #if BX_CRT_NONE
 #	include "crt0.h"
 #	include "crt0.h"
 #else
 #else
-#	include <stdio.h>
-#	include <sys/stat.h>
+#	if BX_CONFIG_CRT_DIRECTORY_READER
+#		include <dirent.h>
+#	endif // BX_CONFIG_CRT_DIRECTORY_READER
+#	include <stdio.h>      // remove
+#	include <sys/stat.h>   // stat, mkdir
+#	if BX_CRT_MSVC
+#		include <direct.h> // _getcwd
+#	else
+#		include <unistd.h> // getcwd
+#	endif // BX_CRT_MSVC
 #endif // !BX_CRT_NONE
 #endif // !BX_CRT_NONE
 
 
-#ifndef BX_CONFIG_CRT_FILE_READER_WRITER
-#	define BX_CONFIG_CRT_FILE_READER_WRITER !(0 \
-			|| BX_CRT_NONE                      \
-			)
-#endif // BX_CONFIG_CRT_FILE_READER_WRITER
-
 namespace bx
 namespace bx
 {
 {
 	class NoopWriterImpl : public FileWriterI
 	class NoopWriterImpl : public FileWriterI
@@ -97,7 +107,7 @@ namespace bx
 				return false;
 				return false;
 			}
 			}
 
 
-			m_file = fopen(_filePath.get(), "rb");
+			m_file = fopen(_filePath.getCPtr(), "rb");
 			if (NULL == m_file)
 			if (NULL == m_file)
 			{
 			{
 				BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "FileReader: Failed to open file.");
 				BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "FileReader: Failed to open file.");
@@ -177,7 +187,7 @@ namespace bx
 				return false;
 				return false;
 			}
 			}
 
 
-			m_file = fopen(_filePath.get(), _append ? "ab" : "wb");
+			m_file = fopen(_filePath.getCPtr(), _append ? "ab" : "wb");
 
 
 			if (NULL == m_file)
 			if (NULL == m_file)
 			{
 			{
@@ -553,18 +563,193 @@ namespace bx
 		return impl->write(_data, _size, _err);
 		return impl->write(_data, _size, _err);
 	}
 	}
 
 
-	bool stat(const FilePath& _filePath, FileInfo& _outFileInfo)
+#if BX_CONFIG_CRT_DIRECTORY_READER
+
+	class DirectoryReaderImpl : public ReaderOpenI, public CloserI, public ReaderI
+	{
+	public:
+		DirectoryReaderImpl()
+			: m_dir(NULL)
+			, m_pos(0)
+		{
+		}
+
+		virtual ~DirectoryReaderImpl()
+		{
+			close();
+		}
+
+		virtual bool open(const FilePath& _filePath, Error* _err) override
+		{
+			BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+			m_dir = opendir(_filePath.getCPtr() );
+
+			if (NULL == m_dir)
+			{
+				BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "DirectoryReader: Failed to open directory.");
+				return false;
+			}
+
+			m_pos = 0;
+
+			return true;
+		}
+
+		virtual void close() override
+		{
+			if (NULL != m_dir)
+			{
+				closedir(m_dir);
+				m_dir = NULL;
+			}
+		}
+
+		virtual int32_t read(void* _data, int32_t _size, Error* _err) override
+		{
+			BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+			int32_t total = 0;
+
+			uint8_t* out = (uint8_t*)_data;
+
+			while (0 < _size)
+			{
+				if (0 == m_pos)
+				{
+					if (!fetch(m_cache, m_dir) )
+					{
+						BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "DirectoryReader: EOF.");
+						return total;
+					}
+				}
+
+				const uint8_t* src = (const uint8_t*)&m_cache;
+				int32_t size = min<int32_t>(_size, sizeof(m_cache)-m_pos);
+				memCopy(&out[total], &src[m_pos], size);
+				total += size;
+				_size -= size;
+
+				m_pos += size;
+				m_pos %= sizeof(m_cache);
+			}
+
+			return total;
+		}
+
+		static bool fetch(FileInfo& _out, DIR* _dir)
+		{
+			for (;;)
+			{
+				const dirent* item = readdir(_dir);
+
+				if (NULL == item)
+				{
+					break;
+				}
+
+				if (0 != (item->d_type & DT_DIR) )
+				{
+					_out.type = FileType::Dir;
+					_out.size = UINT64_MAX;
+					_out.filePath.set(item->d_name);
+					return true;
+				}
+
+				if (0 != (item->d_type & DT_REG) )
+				{
+					_out.type = FileType::File;
+					_out.size = UINT64_MAX;
+					_out.filePath.set(item->d_name);
+					return true;
+				}
+			}
+
+			return false;
+		}
+
+		FileInfo m_cache;
+		DIR*     m_dir;
+		int32_t  m_pos;
+	};
+
+#else
+
+	class DirectoryReaderImpl : public ReaderOpenI, public CloserI, public ReaderI
+	{
+	public:
+		DirectoryReaderImpl()
+		{
+		}
+
+		virtual ~DirectoryReaderImpl()
+		{
+		}
+
+		virtual bool open(const FilePath& _filePath, Error* _err) override
+		{
+			BX_UNUSED(_filePath);
+			BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "DirectoryReader: Failed to open directory.");
+			return false;
+		}
+
+		virtual void close() override
+		{
+		}
+
+		virtual int32_t read(void* _data, int32_t _size, Error* _err) override
+		{
+			BX_UNUSED(_data, _size);
+			BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+			BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "DirectoryReader: EOF.");
+			return 0;
+		}
+	};
+
+#endif // BX_CONFIG_CRT_DIRECTORY_READER
+
+	DirectoryReader::DirectoryReader()
+	{
+		BX_STATIC_ASSERT(sizeof(DirectoryReaderImpl) <= sizeof(m_internal) );
+		BX_PLACEMENT_NEW(m_internal, DirectoryReaderImpl);
+	}
+
+	DirectoryReader::~DirectoryReader()
+	{
+		DirectoryReaderImpl* impl = reinterpret_cast<DirectoryReaderImpl*>(m_internal);
+		impl->~DirectoryReaderImpl();
+	}
+
+	bool DirectoryReader::open(const FilePath& _filePath, Error* _err)
+	{
+		DirectoryReaderImpl* impl = reinterpret_cast<DirectoryReaderImpl*>(m_internal);
+		return impl->open(_filePath, _err);
+	}
+
+	void DirectoryReader::close()
+	{
+		DirectoryReaderImpl* impl = reinterpret_cast<DirectoryReaderImpl*>(m_internal);
+		impl->close();
+	}
+
+	int32_t DirectoryReader::read(void* _data, int32_t _size, Error* _err)
+	{
+		DirectoryReaderImpl* impl = reinterpret_cast<DirectoryReaderImpl*>(m_internal);
+		return impl->read(_data, _size, _err);
+	}
+
+	bool stat(FileInfo& _outFileInfo, const FilePath& _filePath)
 	{
 	{
 #if BX_CRT_NONE
 #if BX_CRT_NONE
 		BX_UNUSED(_filePath, _outFileInfo);
 		BX_UNUSED(_filePath, _outFileInfo);
 		return false;
 		return false;
 #else
 #else
-		_outFileInfo.m_size = 0;
-		_outFileInfo.m_type = FileInfo::Count;
+		_outFileInfo.size = 0;
+		_outFileInfo.type = FileType::Count;
 
 
 #	if BX_COMPILER_MSVC
 #	if BX_COMPILER_MSVC
 		struct ::_stat64 st;
 		struct ::_stat64 st;
-		int32_t result = ::_stat64(_filePath.get(), &st);
+		int32_t result = ::_stat64(_filePath.getCPtr(), &st);
 
 
 		if (0 != result)
 		if (0 != result)
 		{
 		{
@@ -573,15 +758,15 @@ namespace bx
 
 
 		if (0 != (st.st_mode & _S_IFREG) )
 		if (0 != (st.st_mode & _S_IFREG) )
 		{
 		{
-			_outFileInfo.m_type = FileInfo::Regular;
+			_outFileInfo.type = FileType::File;
 		}
 		}
 		else if (0 != (st.st_mode & _S_IFDIR) )
 		else if (0 != (st.st_mode & _S_IFDIR) )
 		{
 		{
-			_outFileInfo.m_type = FileInfo::Directory;
+			_outFileInfo.type = FileType::Dir;
 		}
 		}
 #	else
 #	else
 		struct ::stat st;
 		struct ::stat st;
-		int32_t result = ::stat(_filePath.get(), &st);
+		int32_t result = ::stat(_filePath.getCPtr(), &st);
 		if (0 != result)
 		if (0 != result)
 		{
 		{
 			return false;
 			return false;
@@ -589,18 +774,185 @@ namespace bx
 
 
 		if (0 != (st.st_mode & S_IFREG) )
 		if (0 != (st.st_mode & S_IFREG) )
 		{
 		{
-			_outFileInfo.m_type = FileInfo::Regular;
+			_outFileInfo.type = FileType::File;
 		}
 		}
 		else if (0 != (st.st_mode & S_IFDIR) )
 		else if (0 != (st.st_mode & S_IFDIR) )
 		{
 		{
-			_outFileInfo.m_type = FileInfo::Directory;
+			_outFileInfo.type = FileType::Dir;
 		}
 		}
 #	endif // BX_COMPILER_MSVC
 #	endif // BX_COMPILER_MSVC
 
 
-		_outFileInfo.m_size = st.st_size;
+		_outFileInfo.size = st.st_size;
 
 
 		return true;
 		return true;
 #endif // BX_CRT_NONE
 #endif // BX_CRT_NONE
 	}
 	}
 
 
+	bool make(const FilePath& _filePath, Error* _err)
+	{
+		BX_ERROR_SCOPE(_err);
+
+		if (!_err->isOk() )
+		{
+			return false;
+		}
+
+#if BX_CRT_MSVC
+		int32_t result = ::_mkdir(_filePath.getCPtr() );
+#elif BX_CRT_MINGW
+		int32_t result = ::mkdir(_filePath.getCPtr());
+#elif BX_CRT_NONE
+		BX_UNUSED(_filePath);
+		int32_t result = -1;
+#else
+		int32_t result = ::mkdir(_filePath.getCPtr(), 0700);
+#endif // BX_CRT_MSVC
+
+		if (0 != result)
+		{
+			BX_ERROR_SET(_err, BX_ERROR_ACCESS, "The parent directory does not allow write permission to the process.");
+			return false;
+		}
+
+		return true;
+	}
+
+	bool makeAll(const FilePath& _filePath, Error* _err)
+	{
+		BX_ERROR_SCOPE(_err);
+
+		if (!_err->isOk() )
+		{
+			return false;
+		}
+
+		FileInfo fi;
+
+		if (stat(fi, _filePath) )
+		{
+			if (FileType::Dir == fi.type)
+			{
+				return true;
+			}
+
+			BX_ERROR_SET(_err, BX_ERROR_NOT_DIRECTORY, "File already exist, and is not directory.");
+			return false;
+		}
+
+		const StringView dir   = strRTrim(_filePath, "/");
+		const StringView slash = strRFind(dir, '/');
+
+		if (!slash.isEmpty()
+		&&  slash.getPtr() - dir.getPtr() > 1)
+		{
+			if (!makeAll(StringView(dir.getPtr(), slash.getPtr() ), _err) )
+			{
+				return false;
+			}
+		}
+
+		FilePath path(dir);
+		return make(path, _err);
+	}
+
+	bool remove(const FilePath& _filePath, Error* _err)
+	{
+		BX_ERROR_SCOPE(_err);
+
+		if (!_err->isOk() )
+		{
+			return false;
+		}
+
+#if BX_CRT_MSVC
+		int32_t result = -1;
+		FileInfo fi;
+		if (stat(fi, _filePath) )
+		{
+			if (FileType::Dir == fi.type)
+			{
+				result = ::_rmdir(_filePath.getCPtr() );
+			}
+			else
+			{
+				result = ::remove(_filePath.getCPtr() );
+			}
+		}
+#elif BX_CRT_NONE
+		BX_UNUSED(_filePath);
+		int32_t result = -1;
+#else
+		int32_t result = ::remove(_filePath.getCPtr() );
+#endif // BX_CRT_MSVC
+
+		if (0 != result)
+		{
+			BX_ERROR_SET(_err, BX_ERROR_ACCESS, "The parent directory does not allow write permission to the process.");
+			return false;
+		}
+
+		return true;
+	}
+
+	bool removeAll(const FilePath& _filePath, Error* _err)
+	{
+		BX_ERROR_SCOPE(_err);
+
+		if (remove(_filePath, _err) )
+		{
+			return true;
+		}
+
+		_err->reset();
+
+		FileInfo fi;
+
+		if (!stat(fi, _filePath) )
+		{
+			BX_ERROR_SET(_err, BX_ERROR_ACCESS, "The parent directory does not allow write permission to the process.");
+			return false;
+		}
+
+		if (FileType::Dir != fi.type)
+		{
+			BX_ERROR_SET(_err, BX_ERROR_NOT_DIRECTORY, "File already exist, and is not directory.");
+			return false;
+		}
+
+		Error err;
+		DirectoryReader dr;
+
+		if (!bx::open(&dr, _filePath) )
+		{
+			BX_ERROR_SET(_err, BX_ERROR_NOT_DIRECTORY, "File already exist, and is not directory.");
+			return false;
+		}
+
+		while (err.isOk() )
+		{
+			bx::read(&dr, fi, &err);
+
+			if (err.isOk() )
+			{
+				if (0 == strCmp(fi.filePath, ".")
+				||  0 == strCmp(fi.filePath, "..") )
+				{
+					continue;
+				}
+
+				FilePath path(_filePath);
+				path.join(fi.filePath);
+				if (!removeAll(path, _err) )
+				{
+					_err->reset();
+					break;
+				}
+			}
+		}
+
+		bx::close(&dr);
+
+		return remove(_filePath, _err);
+	}
+
 } // namespace bx
 } // namespace bx

+ 19 - 184
bx.mod/bx/src/filepath.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -9,16 +9,12 @@
 #include <bx/readerwriter.h>
 #include <bx/readerwriter.h>
 
 
 #if !BX_CRT_NONE
 #if !BX_CRT_NONE
-#	include <stdio.h>  // remove
-#	include <dirent.h> // opendir
-
 #	if BX_CRT_MSVC
 #	if BX_CRT_MSVC
 #		include <direct.h>   // _getcwd
 #		include <direct.h>   // _getcwd
 #	else
 #	else
-#		include <sys/stat.h> // mkdir
 #		include <unistd.h>   // getcwd
 #		include <unistd.h>   // getcwd
 #	endif // BX_CRT_MSVC
 #	endif // BX_CRT_MSVC
-#endif // 0
+#endif // !BX_CRT_NONE
 
 
 #if BX_PLATFORM_WINDOWS
 #if BX_PLATFORM_WINDOWS
 extern "C" __declspec(dllimport) unsigned long __stdcall GetTempPathA(unsigned long _max, char* _ptr);
 extern "C" __declspec(dllimport) unsigned long __stdcall GetTempPathA(unsigned long _max, char* _ptr);
@@ -154,7 +150,7 @@ namespace bx
 		return size;
 		return size;
 	}
 	}
 
 
-	static bool getEnv(char* _out, uint32_t* _inOutSize, const StringView& _name, FileInfo::Enum _type)
+	static bool getEnv(char* _out, uint32_t* _inOutSize, const StringView& _name, FileType::Enum _type)
 	{
 	{
 		uint32_t len = *_inOutSize;
 		uint32_t len = *_inOutSize;
 		*_out = '\0';
 		*_out = '\0';
@@ -162,8 +158,8 @@ namespace bx
 		if (getEnv(_out, &len, _name) )
 		if (getEnv(_out, &len, _name) )
 		{
 		{
 			FileInfo fi;
 			FileInfo fi;
-			if (stat(_out, fi)
-			&&  _type == fi.m_type)
+			if (stat(fi, _out)
+			&&  _type == fi.type)
 			{
 			{
 				*_inOutSize = len;
 				*_inOutSize = len;
 				return true;
 				return true;
@@ -204,9 +200,9 @@ namespace bx
 	{
 	{
 		return false
 		return false
 #if BX_PLATFORM_WINDOWS
 #if BX_PLATFORM_WINDOWS
-			|| getEnv(_out, _inOutSize, "USERPROFILE", FileInfo::Directory)
+			|| getEnv(_out, _inOutSize, "USERPROFILE", FileType::Dir)
 #endif // BX_PLATFORM_WINDOWS
 #endif // BX_PLATFORM_WINDOWS
-			|| getEnv(_out, _inOutSize, "HOME", FileInfo::Directory)
+			|| getEnv(_out, _inOutSize, "HOME", FileType::Dir)
 			;
 			;
 	}
 	}
 
 
@@ -232,7 +228,7 @@ namespace bx
 		{
 		{
 			uint32_t len = *_inOutSize;
 			uint32_t len = *_inOutSize;
 			*_out = '\0';
 			*_out = '\0';
-			bool ok = getEnv(_out, &len, *tmp, FileInfo::Directory);
+			bool ok = getEnv(_out, &len, *tmp, FileType::Dir);
 
 
 			if (ok
 			if (ok
 			&&  len != 0
 			&&  len != 0
@@ -244,8 +240,8 @@ namespace bx
 		}
 		}
 
 
 		FileInfo fi;
 		FileInfo fi;
-		if (stat("/tmp", fi)
-		&&  FileInfo::Directory == fi.m_type)
+		if (stat(fi, "/tmp")
+		&&  FileType::Dir == fi.type)
 		{
 		{
 			strCopy(_out, *_inOutSize, "/tmp");
 			strCopy(_out, *_inOutSize, "/tmp");
 			*_inOutSize = 4;
 			*_inOutSize = 4;
@@ -336,7 +332,12 @@ namespace bx
 		set(tmp);
 		set(tmp);
 	}
 	}
 
 
-	const char* FilePath::get() const
+	FilePath::operator StringView() const
+	{
+		return StringView(m_filePath, strLen(m_filePath) );
+	}
+
+	const char* FilePath::getCPtr() const
 	{
 	{
 		return m_filePath;
 		return m_filePath;
 	}
 	}
@@ -360,7 +361,7 @@ namespace bx
 			return StringView(fileName.getPtr()+1);
 			return StringView(fileName.getPtr()+1);
 		}
 		}
 
 
-		return get();
+		return getCPtr();
 	}
 	}
 
 
 	StringView FilePath::getBaseName() const
 	StringView FilePath::getBaseName() const
@@ -385,7 +386,8 @@ namespace bx
 		const StringView fileName = getFileName();
 		const StringView fileName = getFileName();
 		if (!fileName.isEmpty() )
 		if (!fileName.isEmpty() )
 		{
 		{
-			return strFind(fileName, '.');
+			const StringView dot = strFind(fileName, '.');
+			return StringView(dot.getPtr(), fileName.getTerm() );
 		}
 		}
 
 
 		return StringView();
 		return StringView();
@@ -403,171 +405,4 @@ namespace bx
 		return 0 == strCmp(m_filePath, ".");
 		return 0 == strCmp(m_filePath, ".");
 	}
 	}
 
 
-	bool make(const FilePath& _filePath, Error* _err)
-	{
-		BX_ERROR_SCOPE(_err);
-
-		if (!_err->isOk() )
-		{
-			return false;
-		}
-
-#if BX_CRT_MSVC
-		int32_t result = ::_mkdir(_filePath.get() );
-#elif BX_CRT_MINGW
-		int32_t result = ::mkdir(_filePath.get());
-#elif BX_CRT_NONE
-		BX_UNUSED(_filePath);
-		int32_t result = -1;
-#else
-		int32_t result = ::mkdir(_filePath.get(), 0700);
-#endif // BX_CRT_MSVC
-
-		if (0 != result)
-		{
-			BX_ERROR_SET(_err, BX_ERROR_ACCESS, "The parent directory does not allow write permission to the process.");
-			return false;
-		}
-
-		return true;
-	}
-
-	bool makeAll(const FilePath& _filePath, Error* _err)
-	{
-		BX_ERROR_SCOPE(_err);
-
-		if (!_err->isOk() )
-		{
-			return false;
-		}
-
-		FileInfo fi;
-
-		if (stat(_filePath, fi) )
-		{
-			if (FileInfo::Directory == fi.m_type)
-			{
-				return true;
-			}
-
-			BX_ERROR_SET(_err, BX_ERROR_NOT_DIRECTORY, "File already exist, and is not directory.");
-			return false;
-		}
-
-		const StringView dir   = strRTrim(_filePath.get(), "/");
-		const StringView slash = strRFind(dir, '/');
-
-		if (!slash.isEmpty()
-		&&  slash.getPtr() - dir.getPtr() > 1)
-		{
-			if (!makeAll(StringView(dir.getPtr(), slash.getPtr() ), _err) )
-			{
-				return false;
-			}
-		}
-
-		FilePath path(dir);
-		return make(path, _err);
-	}
-
-	bool remove(const FilePath& _filePath, Error* _err)
-	{
-		BX_ERROR_SCOPE(_err);
-
-		if (!_err->isOk() )
-		{
-			return false;
-		}
-
-#if BX_CRT_MSVC
-		int32_t result = -1;
-		FileInfo fi;
-		if (stat(_filePath, fi) )
-		{
-			if (FileInfo::Directory == fi.m_type)
-			{
-				result = ::_rmdir(_filePath.get() );
-			}
-			else
-			{
-				result = ::remove(_filePath.get() );
-			}
-		}
-#elif BX_CRT_NONE
-		BX_UNUSED(_filePath);
-		int32_t result = -1;
-#else
-		int32_t result = ::remove(_filePath.get() );
-#endif // BX_CRT_MSVC
-
-		if (0 != result)
-		{
-			BX_ERROR_SET(_err, BX_ERROR_ACCESS, "The parent directory does not allow write permission to the process.");
-			return false;
-		}
-
-		return true;
-	}
-
-	bool removeAll(const FilePath& _filePath, Error* _err)
-	{
-		BX_ERROR_SCOPE(_err);
-
-		if (remove(_filePath, _err) )
-		{
-			return true;
-		}
-
-		_err->reset();
-
-		FileInfo fi;
-
-		if (!stat(_filePath, fi) )
-		{
-			BX_ERROR_SET(_err, BX_ERROR_ACCESS, "The parent directory does not allow write permission to the process.");
-			return false;
-		}
-
-		if (FileInfo::Directory != fi.m_type)
-		{
-			BX_ERROR_SET(_err, BX_ERROR_NOT_DIRECTORY, "File already exist, and is not directory.");
-			return false;
-		}
-
-#if BX_CRT_NONE
-		BX_UNUSED(_filePath);
-		return false;
-#elif  BX_PLATFORM_WINDOWS \
-	|| BX_PLATFORM_LINUX   \
-	|| BX_PLATFORM_OSX
-		DIR* dir = opendir(_filePath.get() );
-		if (NULL == dir)
-		{
-			BX_ERROR_SET(_err, BX_ERROR_NOT_DIRECTORY, "File already exist, and is not directory.");
-			return false;
-		}
-
-		for (dirent* item = readdir(dir); NULL != item; item = readdir(dir) )
-		{
-			if (0 == strCmp(item->d_name, ".")
-			||  0 == strCmp(item->d_name, "..") )
-			{
-				continue;
-			}
-
-			FilePath path(_filePath);
-			path.join(item->d_name);
-			if (!removeAll(path, _err) )
-			{
-				_err->reset();
-				break;
-			}
-		}
-
-		closedir(dir);
-#endif // !BX_CRT_NONE
-
-		return remove(_filePath, _err);
-	}
-
 } // namespace bx
 } // namespace bx

+ 1 - 1
bx.mod/bx/src/hash.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 46 - 206
bx.mod/bx/src/math.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -239,71 +239,53 @@ namespace bx
 		return result;
 		return result;
 	}
 	}
 
 
-	static void mtxLookAtImpl(float* _result, const Vec3& _eye, const Vec3& _view, const Vec3& _up)
+	void mtxLookAt(float* _result, const Vec3& _eye, const Vec3& _at, const Vec3& _up, Handness::Enum _handness)
 	{
 	{
-		const Vec3 uxv   = cross(_up, _view);
+		const Vec3 view = normalize(
+			  Handness::Right == _handness
+			? sub(_eye, _at)
+			: sub(_at, _eye)
+			);
+		const Vec3 uxv   = cross(_up, view);
 		const Vec3 right = normalize(uxv);
 		const Vec3 right = normalize(uxv);
-		const Vec3 up    = cross(_view, right);
+		const Vec3 up    = cross(view, right);
 
 
 		memSet(_result, 0, sizeof(float)*16);
 		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = right.x;
 		_result[ 0] = right.x;
 		_result[ 1] = up.x;
 		_result[ 1] = up.x;
-		_result[ 2] = _view.x;
+		_result[ 2] = view.x;
 
 
 		_result[ 4] = right.y;
 		_result[ 4] = right.y;
 		_result[ 5] = up.y;
 		_result[ 5] = up.y;
-		_result[ 6] = _view.y;
+		_result[ 6] = view.y;
 
 
 		_result[ 8] = right.z;
 		_result[ 8] = right.z;
 		_result[ 9] = up.z;
 		_result[ 9] = up.z;
-		_result[10] = _view.z;
+		_result[10] = view.z;
 
 
 		_result[12] = -dot(right, _eye);
 		_result[12] = -dot(right, _eye);
-		_result[13] = -dot(up, _eye);
-		_result[14] = -dot(_view, _eye);
+		_result[13] = -dot(up,    _eye);
+		_result[14] = -dot(view,  _eye);
 		_result[15] = 1.0f;
 		_result[15] = 1.0f;
 	}
 	}
 
 
-	void mtxLookAtLh(float* _result, const Vec3& _eye, const Vec3& _at, const Vec3& _up)
-	{
-		const Vec3 tmp  = sub(_at, _eye);
-		const Vec3 view = normalize(tmp);
-
-		mtxLookAtImpl(_result, _eye, view, _up);
-	}
-
-	void mtxLookAtRh(float* _result, const Vec3& _eye, const Vec3& _at, const Vec3& _up)
-	{
-		const Vec3 tmp = sub(_eye, _at);
-		const Vec3 view = normalize(tmp);
-
-		mtxLookAtImpl(_result, _eye, view, _up);
-	}
-
-	void mtxLookAt(float* _result, const Vec3& _eye, const Vec3& _at, const Vec3& _up)
-	{
-		mtxLookAtLh(_result, _eye, _at, _up);
-	}
-
-	template<Handness::Enum HandnessT>
-	void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc)
+	static void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _homogeneousNdc, Handness::Enum _handness)
 	{
 	{
 		const float diff = _far-_near;
 		const float diff = _far-_near;
-		const float aa = _oglNdc ? (     _far+_near)/diff : _far/diff;
-		const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa;
+		const float aa = _homogeneousNdc ? (     _far+_near)/diff : _far/diff;
+		const float bb = _homogeneousNdc ? (2.0f*_far*_near)/diff : _near*aa;
 
 
 		memSet(_result, 0, sizeof(float)*16);
 		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = _width;
 		_result[ 0] = _width;
 		_result[ 5] = _height;
 		_result[ 5] = _height;
-		_result[ 8] = (Handness::Right == HandnessT) ?    _x :  -_x;
-		_result[ 9] = (Handness::Right == HandnessT) ?    _y :  -_y;
-		_result[10] = (Handness::Right == HandnessT) ?   -aa :   aa;
-		_result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
+		_result[ 8] = (Handness::Right == _handness) ?    _x :  -_x;
+		_result[ 9] = (Handness::Right == _handness) ?    _y :  -_y;
+		_result[10] = (Handness::Right == _handness) ?   -aa :   aa;
+		_result[11] = (Handness::Right == _handness) ? -1.0f : 1.0f;
 		_result[14] = -bb;
 		_result[14] = -bb;
 	}
 	}
 
 
-	template<Handness::Enum HandnessT>
-	void mtxProjImpl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
+	void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _homogeneousNdc, Handness::Enum _handness)
 	{
 	{
 		const float invDiffRl = 1.0f/(_rt - _lt);
 		const float invDiffRl = 1.0f/(_rt - _lt);
 		const float invDiffUd = 1.0f/(_ut - _dt);
 		const float invDiffUd = 1.0f/(_ut - _dt);
@@ -311,96 +293,47 @@ namespace bx
 		const float height =  2.0f*_near * invDiffUd;
 		const float height =  2.0f*_near * invDiffUd;
 		const float xx     = (_rt + _lt) * invDiffRl;
 		const float xx     = (_rt + _lt) * invDiffRl;
 		const float yy     = (_ut + _dt) * invDiffUd;
 		const float yy     = (_ut + _dt) * invDiffUd;
-		mtxProjXYWH<HandnessT>(_result, xx, yy, width, height, _near, _far, _oglNdc);
+		mtxProjXYWH(_result, xx, yy, width, height, _near, _far, _homogeneousNdc, _handness);
 	}
 	}
 
 
-	template<Handness::Enum HandnessT>
-	void mtxProjImpl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
+	void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _homogeneousNdc, Handness::Enum _handness)
 	{
 	{
-		mtxProjImpl<HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
+		mtxProj(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _homogeneousNdc, _handness);
 	}
 	}
 
 
-	template<Handness::Enum HandnessT>
-	void mtxProjImpl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
+	void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _homogeneousNdc, Handness::Enum _handness)
 	{
 	{
 		const float height = 1.0f/tan(toRad(_fovy)*0.5f);
 		const float height = 1.0f/tan(toRad(_fovy)*0.5f);
 		const float width  = height * 1.0f/_aspect;
 		const float width  = height * 1.0f/_aspect;
-		mtxProjXYWH<HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
-	}
-
-	void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
-	{
-		mtxProjImpl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
-	}
-
-	void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
-	{
-		mtxProjImpl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
-	}
-
-	void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
-	{
-		mtxProjImpl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
-	}
-
-	void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
-	{
-		mtxProjImpl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
+		mtxProjXYWH(_result, 0.0f, 0.0f, width, height, _near, _far, _homogeneousNdc, _handness);
 	}
 	}
 
 
-	void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
-	{
-		mtxProjImpl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
-	}
-
-	void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
-	{
-		mtxProjImpl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
-	}
-
-	void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
-	{
-		mtxProjImpl<Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
-	}
-
-	void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
-	{
-		mtxProjImpl<Handness::Right>(_result, _fov, _near, _far, _oglNdc);
-	}
-
-	void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
-	{
-		mtxProjImpl<Handness::Right>(_result, _fovy, _aspect, _near, _far, _oglNdc);
-	}
-
-	template<NearFar::Enum NearFarT, Handness::Enum HandnessT>
-	void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc)
+	static void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _homogeneousNdc, Handness::Enum _handness, NearFar::Enum _nearFar)
 	{
 	{
 		float aa;
 		float aa;
 		float bb;
 		float bb;
-		if (BX_ENABLED(NearFar::Reverse == NearFarT) )
+		if (NearFar::Reverse == _nearFar)
 		{
 		{
-			aa = _oglNdc ?       -1.0f :   0.0f;
-			bb = _oglNdc ? -2.0f*_near : -_near;
+			aa = _homogeneousNdc ?       -1.0f :   0.0f;
+			bb = _homogeneousNdc ? -2.0f*_near : -_near;
 		}
 		}
 		else
 		else
 		{
 		{
 			aa = 1.0f;
 			aa = 1.0f;
-			bb = _oglNdc ? 2.0f*_near : _near;
+			bb = _homogeneousNdc ? 2.0f*_near : _near;
 		}
 		}
 
 
 		memSet(_result, 0, sizeof(float)*16);
 		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = _width;
 		_result[ 0] = _width;
 		_result[ 5] = _height;
 		_result[ 5] = _height;
-		_result[ 8] = (Handness::Right == HandnessT) ?    _x :  -_x;
-		_result[ 9] = (Handness::Right == HandnessT) ?    _y :  -_y;
-		_result[10] = (Handness::Right == HandnessT) ?   -aa :   aa;
-		_result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
+		_result[ 8] = (Handness::Right == _handness) ?    _x :  -_x;
+		_result[ 9] = (Handness::Right == _handness) ?    _y :  -_y;
+		_result[10] = (Handness::Right == _handness) ?   -aa :   aa;
+		_result[11] = (Handness::Right == _handness) ? -1.0f : 1.0f;
 		_result[14] = -bb;
 		_result[14] = -bb;
 	}
 	}
 
 
-	template<NearFar::Enum NearFarT, Handness::Enum HandnessT>
-	void mtxProjInfImpl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
+	void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _homogeneousNdc, Handness::Enum _handness, NearFar::Enum _nearFar)
 	{
 	{
 		const float invDiffRl = 1.0f/(_rt - _lt);
 		const float invDiffRl = 1.0f/(_rt - _lt);
 		const float invDiffUd = 1.0f/(_ut - _dt);
 		const float invDiffUd = 1.0f/(_ut - _dt);
@@ -408,107 +341,29 @@ namespace bx
 		const float height =  2.0f*_near * invDiffUd;
 		const float height =  2.0f*_near * invDiffUd;
 		const float xx     = (_rt + _lt) * invDiffRl;
 		const float xx     = (_rt + _lt) * invDiffRl;
 		const float yy     = (_ut + _dt) * invDiffUd;
 		const float yy     = (_ut + _dt) * invDiffUd;
-		mtxProjInfXYWH<NearFarT,HandnessT>(_result, xx, yy, width, height, _near, _oglNdc);
+		mtxProjInfXYWH(_result, xx, yy, width, height, _near, _homogeneousNdc, _handness, _nearFar);
 	}
 	}
 
 
-	template<NearFar::Enum NearFarT, Handness::Enum HandnessT>
-	void mtxProjInfImpl(float* _result, const float _fov[4], float _near, bool _oglNdc)
+	void mtxProjInf(float* _result, const float _fov[4], float _near, bool _homogeneousNdc, Handness::Enum _handness, NearFar::Enum _nearFar)
 	{
 	{
-		mtxProjInfImpl<NearFarT,HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc);
+		mtxProjInf(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _homogeneousNdc, _handness, _nearFar);
 	}
 	}
 
 
-	template<NearFar::Enum NearFarT, Handness::Enum HandnessT>
-	void mtxProjInfImpl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
+	void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _homogeneousNdc, Handness::Enum _handness, NearFar::Enum _nearFar)
 	{
 	{
 		const float height = 1.0f/tan(toRad(_fovy)*0.5f);
 		const float height = 1.0f/tan(toRad(_fovy)*0.5f);
 		const float width  = height * 1.0f/_aspect;
 		const float width  = height * 1.0f/_aspect;
-		mtxProjInfXYWH<NearFarT,HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _oglNdc);
-	}
-
-	void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
-	}
-
-	void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
-	}
-
-	void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
-	}
-
-	void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
-	}
-
-	void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
-	}
-
-	void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
-	}
-
-	void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Default,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
-	}
-
-	void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Default,Handness::Right>(_result, _fov, _near, _oglNdc);
-	}
-
-	void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Default,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
-	}
-
-	void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Reverse,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
-	}
-
-	void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Reverse,Handness::Left>(_result, _fov, _near, _oglNdc);
-	}
-
-	void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Reverse,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
-	}
-
-	void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Reverse,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
-	}
-
-	void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Reverse,Handness::Right>(_result, _fov, _near, _oglNdc);
+		mtxProjInfXYWH(_result, 0.0f, 0.0f, width, height, _near, _homogeneousNdc, _handness, _nearFar);
 	}
 	}
 
 
-	void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
-	{
-		mtxProjInfImpl<NearFar::Reverse,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
-	}
-
-	template<Handness::Enum HandnessT>
-	void mtxOrthoImpl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
+	void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _homogeneousNdc, Handness::Enum _handness)
 	{
 	{
 		const float aa = 2.0f/(_right - _left);
 		const float aa = 2.0f/(_right - _left);
 		const float bb = 2.0f/(_top - _bottom);
 		const float bb = 2.0f/(_top - _bottom);
-		const float cc = (_oglNdc ? 2.0f : 1.0f) / (_far - _near);
+		const float cc = (_homogeneousNdc ? 2.0f : 1.0f) / (_far - _near);
 		const float dd = (_left + _right )/(_left   - _right);
 		const float dd = (_left + _right )/(_left   - _right);
 		const float ee = (_top  + _bottom)/(_bottom - _top  );
 		const float ee = (_top  + _bottom)/(_bottom - _top  );
-		const float ff = _oglNdc
+		const float ff = _homogeneousNdc
 			? (_near + _far)/(_near - _far)
 			? (_near + _far)/(_near - _far)
 			:  _near        /(_near - _far)
 			:  _near        /(_near - _far)
 			;
 			;
@@ -516,28 +371,13 @@ namespace bx
 		memSet(_result, 0, sizeof(float)*16);
 		memSet(_result, 0, sizeof(float)*16);
 		_result[ 0] = aa;
 		_result[ 0] = aa;
 		_result[ 5] = bb;
 		_result[ 5] = bb;
-		_result[10] = (Handness::Right == HandnessT) ? -cc : cc;
+		_result[10] = Handness::Right == _handness ? -cc : cc;
 		_result[12] = dd + _offset;
 		_result[12] = dd + _offset;
 		_result[13] = ee;
 		_result[13] = ee;
 		_result[14] = ff;
 		_result[14] = ff;
 		_result[15] = 1.0f;
 		_result[15] = 1.0f;
 	}
 	}
 
 
-	void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
-	{
-		mtxOrthoImpl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
-	}
-
-	void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
-	{
-		mtxOrthoImpl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
-	}
-
-	void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
-	{
-		mtxOrthoImpl<Handness::Right>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
-	}
-
 	void mtxRotateX(float* _result, float _ax)
 	void mtxRotateX(float* _result, float _ax)
 	{
 	{
 		const float sx = sin(_ax);
 		const float sx = sin(_ax);

+ 1 - 1
bx.mod/bx/src/mutex.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 3 - 3
bx.mod/bx/src/os.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -174,7 +174,7 @@ namespace bx
 	void* dlopen(const FilePath& _filePath)
 	void* dlopen(const FilePath& _filePath)
 	{
 	{
 #if BX_PLATFORM_WINDOWS
 #if BX_PLATFORM_WINDOWS
-		return (void*)::LoadLibraryA(_filePath.get() );
+		return (void*)::LoadLibraryA(_filePath.getCPtr() );
 #elif  BX_PLATFORM_EMSCRIPTEN \
 #elif  BX_PLATFORM_EMSCRIPTEN \
 	|| BX_PLATFORM_PS4        \
 	|| BX_PLATFORM_PS4        \
 	|| BX_PLATFORM_XBOXONE    \
 	|| BX_PLATFORM_XBOXONE    \
@@ -183,7 +183,7 @@ namespace bx
 		BX_UNUSED(_filePath);
 		BX_UNUSED(_filePath);
 		return NULL;
 		return NULL;
 #else
 #else
-		return ::dlopen(_filePath.get(), RTLD_LOCAL|RTLD_LAZY);
+		return ::dlopen(_filePath.getCPtr(), RTLD_LOCAL|RTLD_LAZY);
 #endif // BX_PLATFORM_
 #endif // BX_PLATFORM_
 	}
 	}
 
 

+ 3 - 3
bx.mod/bx/src/process.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -48,7 +48,7 @@ namespace bx
 		}
 		}
 
 
 		char tmp[kMaxFilePath*2] = "\"";
 		char tmp[kMaxFilePath*2] = "\"";
-		strCat(tmp, BX_COUNTOF(tmp), _filePath.get() );
+		strCat(tmp, BX_COUNTOF(tmp), _filePath);
 		strCat(tmp, BX_COUNTOF(tmp), "\" ");
 		strCat(tmp, BX_COUNTOF(tmp), "\" ");
 		strCat(tmp, BX_COUNTOF(tmp), _args);
 		strCat(tmp, BX_COUNTOF(tmp), _args);
 
 
@@ -119,7 +119,7 @@ namespace bx
 		}
 		}
 
 
 		char tmp[kMaxFilePath*2] = "\"";
 		char tmp[kMaxFilePath*2] = "\"";
-		strCat(tmp, BX_COUNTOF(tmp), _filePath.get() );
+		strCat(tmp, BX_COUNTOF(tmp), _filePath);
 		strCat(tmp, BX_COUNTOF(tmp), "\" ");
 		strCat(tmp, BX_COUNTOF(tmp), "\" ");
 		strCat(tmp, BX_COUNTOF(tmp), _args);
 		strCat(tmp, BX_COUNTOF(tmp), _args);
 
 

+ 1 - 1
bx.mod/bx/src/semaphore.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/src/settings.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/src/sort.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 35 - 7
bx.mod/bx/src/string.cpp

@@ -1,12 +1,12 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
 #include "bx_p.h"
 #include "bx_p.h"
 #include <bx/allocator.h>
 #include <bx/allocator.h>
+#include <bx/file.h>
 #include <bx/hash.h>
 #include <bx/hash.h>
-#include <bx/readerwriter.h>
 #include <bx/string.h>
 #include <bx/string.h>
 
 
 namespace bx
 namespace bx
@@ -188,7 +188,12 @@ namespace bx
 			}
 			}
 		}
 		}
 
 
-		return 0 == max && _lhsMax == _rhsMax ? 0 : fn(*_lhs) - fn(*_rhs);
+		if (0 == max)
+		{
+			return _lhsMax == _rhsMax ? 0 : _lhsMax > _rhsMax ? 1 : -1;
+		}
+
+		return fn(*_lhs) - fn(*_rhs);
 	}
 	}
 
 
 	int32_t strCmp(const StringView& _lhs, const StringView& _rhs, int32_t _max)
 	int32_t strCmp(const StringView& _lhs, const StringView& _rhs, int32_t _max)
@@ -687,9 +692,10 @@ namespace bx
 		return StringView(_str.getTerm(), _str.getTerm() );
 		return StringView(_str.getTerm(), _str.getTerm() );
 	}
 	}
 
 
-	StringView findIdentifierMatch(const StringView& _str, const char** _words)
+	StringView findIdentifierMatch(const StringView& _str, const char** _words, int32_t _num)
 	{
 	{
-		for (StringView word = *_words; !word.isEmpty(); ++_words, word = *_words)
+		int32_t ii = 0;
+		for (StringView word = *_words; ii < _num && !word.isEmpty(); ++ii, ++_words, word = *_words)
 		{
 		{
 			StringView match = findIdentifierMatch(_str, word);
 			StringView match = findIdentifierMatch(_str, word);
 			if (!match.isEmpty() )
 			if (!match.isEmpty() )
@@ -1147,10 +1153,10 @@ namespace bx
 		SizerWriter sizer;
 		SizerWriter sizer;
 		va_list argListCopy;
 		va_list argListCopy;
 		va_copy(argListCopy, _argList);
 		va_copy(argListCopy, _argList);
-		int32_t size = write(&sizer, _format, argListCopy, &err);
+		int32_t total = write(&sizer, _format, argListCopy, &err);
 		va_end(argListCopy);
 		va_end(argListCopy);
 
 
-		return size;
+		return total;
 	}
 	}
 
 
 	int32_t snprintf(char* _out, int32_t _max, const char* _format, ...)
 	int32_t snprintf(char* _out, int32_t _max, const char* _format, ...)
@@ -1159,6 +1165,28 @@ namespace bx
 		va_start(argList, _format);
 		va_start(argList, _format);
 		int32_t total = vsnprintf(_out, _max, _format, argList);
 		int32_t total = vsnprintf(_out, _max, _format, argList);
 		va_end(argList);
 		va_end(argList);
+
+		return total;
+	}
+
+	int32_t vprintf(const char* _format, va_list _argList)
+	{
+		Error err;
+		va_list argListCopy;
+		va_copy(argListCopy, _argList);
+		int32_t total = write(getStdOut(), _format, argListCopy, &err);
+		va_end(argListCopy);
+
+		return total;
+	}
+
+	int32_t printf(const char* _format, ...)
+	{
+		va_list argList;
+		va_start(argList, _format);
+		int32_t total = vprintf(_format, argList);
+		va_end(argList);
+
 		return total;
 		return total;
 	}
 	}
 
 

+ 43 - 26
bx.mod/bx/src/thread.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 
@@ -8,6 +8,10 @@
 
 
 #if BX_CONFIG_SUPPORTS_THREADING
 #if BX_CONFIG_SUPPORTS_THREADING
 
 
+#if BX_PLATFORM_WINDOWS && !BX_CRT_NONE
+#	include <bx/string.h>
+#endif
+
 #if BX_CRT_NONE
 #if BX_CRT_NONE
 #	include "crt0.h"
 #	include "crt0.h"
 #elif  BX_PLATFORM_ANDROID \
 #elif  BX_PLATFORM_ANDROID \
@@ -240,33 +244,46 @@ namespace bx
 #	else
 #	else
 		pthread_set_name_np(ti->m_handle, _name);
 		pthread_set_name_np(ti->m_handle, _name);
 #	endif // defined(__NetBSD__)
 #	endif // defined(__NetBSD__)
-#elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
-#	pragma pack(push, 8)
-		struct ThreadName
-		{
-			DWORD  type;
-			LPCSTR name;
-			DWORD  id;
-			DWORD  flags;
-		};
-#	pragma pack(pop)
-		ThreadName tn;
-		tn.type  = 0x1000;
-		tn.name  = _name;
-		tn.id    = ti->m_threadId;
-		tn.flags = 0;
-
-		__try
-		{
-			RaiseException(0x406d1388
-					, 0
-					, sizeof(tn)/4
-					, reinterpret_cast<ULONG_PTR*>(&tn)
-					);
-		}
-		__except(EXCEPTION_EXECUTE_HANDLER)
+#elif BX_PLATFORM_WINDOWS
+		// Try to use the new thread naming API from Win10 Creators update onwards if we have it
+		typedef HRESULT (WINAPI *SetThreadDescriptionProc)(HANDLE, PCWSTR);
+		SetThreadDescriptionProc SetThreadDescription = (SetThreadDescriptionProc)(GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetThreadDescription"));
+		if (SetThreadDescription)
 		{
 		{
+			uint32_t length = (uint32_t)bx::strLen(_name)+1;
+			uint32_t size = length*sizeof(wchar_t);
+			wchar_t* name = (wchar_t*)alloca(size);
+			mbstowcs(name, _name, size-2);
+			SetThreadDescription(ti->m_handle, name);
 		}
 		}
+#	if BX_COMPILER_MSVC
+#		pragma pack(push, 8)
+			struct ThreadName
+			{
+				DWORD  type;
+				LPCSTR name;
+				DWORD  id;
+				DWORD  flags;
+			};
+#		pragma pack(pop)
+			ThreadName tn;
+			tn.type  = 0x1000;
+			tn.name  = _name;
+			tn.id    = ti->m_threadId;
+			tn.flags = 0;
+
+			__try
+			{
+				RaiseException(0x406d1388
+						, 0
+						, sizeof(tn)/4
+						, reinterpret_cast<ULONG_PTR*>(&tn)
+						);
+			}
+			__except(EXCEPTION_EXECUTE_HANDLER)
+			{
+			}
+#	endif // BX_COMPILER_MSVC
 #else
 #else
 		BX_UNUSED(_name);
 		BX_UNUSED(_name);
 #endif // BX_PLATFORM_
 #endif // BX_PLATFORM_

+ 1 - 1
bx.mod/bx/src/timer.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/src/url.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bnet#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bnet#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/tests/atomic_test.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/tests/crt_test.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

+ 1 - 1
bx.mod/bx/tests/dbg.h

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  */
  */
 
 

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