Bläddra i källkod

Merge branch 'master' into console

Conflicts:
	engine/Game.cpp
	engine/Game.h
	engine/lua/LuaEnvironment.h
	src/ConsoleServer.h
	src/Game.h
mikymod 12 år sedan
förälder
incheckning
dcb44844b6
100 ändrade filer med 139 tillägg och 193 borttagningar
  1. 1 1
      .gitignore
  2. 4 29
      CMakeLists.txt
  3. 0 1
      engine/Android.mk
  4. 0 0
      engine/Application.mk
  5. 0 0
      engine/ArchiveBundle.cpp
  6. 0 0
      engine/ArchiveBundle.h
  7. 0 0
      engine/Bundle.h
  8. 72 37
      engine/CMakeLists.txt
  9. 0 0
      engine/Camera.cpp
  10. 0 0
      engine/Camera.h
  11. 0 0
      engine/Config.h.in
  12. 0 0
      engine/ConsoleServer.cpp
  13. 0 0
      engine/ConsoleServer.h
  14. 0 0
      engine/Crown.h
  15. 1 1
      engine/Device.cpp
  16. 2 2
      engine/Device.h
  17. 0 0
      engine/FPSSystem.cpp
  18. 0 0
      engine/FPSSystem.h
  19. 0 0
      engine/FileBundle.cpp
  20. 0 0
      engine/FileBundle.h
  21. 2 8
      engine/FontResource.cpp
  22. 0 0
      engine/FontResource.h
  23. 0 0
      engine/Glyph.h
  24. 0 0
      engine/JSONParser.cpp
  25. 0 0
      engine/JSONParser.h
  26. 2 9
      engine/MaterialResource.cpp
  27. 0 0
      engine/MaterialResource.h
  28. 0 0
      engine/PixelShaderResource.cpp
  29. 0 0
      engine/PixelShaderResource.h
  30. 0 0
      engine/Resource.h
  31. 0 0
      engine/ResourceManager.cpp
  32. 0 0
      engine/ResourceManager.h
  33. 0 0
      engine/TextResource.cpp
  34. 0 0
      engine/TextResource.h
  35. 0 0
      engine/TextureResource.cpp
  36. 0 0
      engine/TextureResource.h
  37. 0 0
      engine/VertexShaderResource.cpp
  38. 0 0
      engine/VertexShaderResource.h
  39. 0 0
      engine/core/Args.cpp
  40. 0 0
      engine/core/Args.h
  41. 0 0
      engine/core/Assert.h
  42. 0 0
      engine/core/Log.cpp
  43. 0 0
      engine/core/Log.h
  44. 5 4
      engine/core/Types.h
  45. 0 0
      engine/core/bv/Box.h
  46. 0 0
      engine/core/bv/Circle.cpp
  47. 0 0
      engine/core/bv/Circle.h
  48. 0 0
      engine/core/bv/Frustum.cpp
  49. 0 0
      engine/core/bv/Frustum.h
  50. 0 0
      engine/core/bv/Rect.cpp
  51. 0 0
      engine/core/bv/Rect.h
  52. 0 0
      engine/core/bv/Sphere.h
  53. 0 0
      engine/core/compressors/Compressor.h
  54. 3 19
      engine/core/compressors/ZipCompressor.cpp
  55. 0 0
      engine/core/compressors/ZipCompressor.h
  56. 0 0
      engine/core/containers/Dictionary.h
  57. 0 0
      engine/core/containers/Generic.cpp
  58. 0 0
      engine/core/containers/Generic.h
  59. 0 0
      engine/core/containers/IdTable.h
  60. 0 0
      engine/core/containers/List.h
  61. 0 0
      engine/core/containers/Queue.h
  62. 0 0
      engine/core/containers/RBTree.h
  63. 0 0
      engine/core/filesystem/BinaryReader.cpp
  64. 0 0
      engine/core/filesystem/BinaryReader.h
  65. 0 0
      engine/core/filesystem/BinaryWriter.cpp
  66. 0 0
      engine/core/filesystem/BinaryWriter.h
  67. 0 0
      engine/core/filesystem/DiskFile.cpp
  68. 0 0
      engine/core/filesystem/DiskFile.h
  69. 0 0
      engine/core/filesystem/File.cpp
  70. 0 0
      engine/core/filesystem/File.h
  71. 0 0
      engine/core/filesystem/Filesystem.cpp
  72. 0 0
      engine/core/filesystem/Filesystem.h
  73. 0 0
      engine/core/filesystem/MemoryFile.cpp
  74. 0 0
      engine/core/filesystem/MemoryFile.h
  75. 0 0
      engine/core/filesystem/NullFile.h
  76. 0 0
      engine/core/filesystem/TextReader.cpp
  77. 0 0
      engine/core/filesystem/TextReader.h
  78. 0 0
      engine/core/filesystem/TextWriter.cpp
  79. 0 0
      engine/core/filesystem/TextWriter.h
  80. 0 0
      engine/core/math/Color4.cpp
  81. 0 0
      engine/core/math/Color4.h
  82. 0 0
      engine/core/math/Interpolation.h
  83. 0 0
      engine/core/math/Intersection.h
  84. 0 0
      engine/core/math/Mat3.cpp
  85. 0 0
      engine/core/math/Mat3.h
  86. 0 0
      engine/core/math/Mat4.cpp
  87. 0 0
      engine/core/math/Mat4.h
  88. 47 82
      engine/core/math/MathUtils.h
  89. 0 0
      engine/core/math/Plane.cpp
  90. 0 0
      engine/core/math/Plane.h
  91. 0 0
      engine/core/math/Point2.cpp
  92. 0 0
      engine/core/math/Point2.h
  93. 0 0
      engine/core/math/Quat.cpp
  94. 0 0
      engine/core/math/Quat.h
  95. 0 0
      engine/core/math/Random.h
  96. 0 0
      engine/core/math/Ray.h
  97. 0 0
      engine/core/math/Shape.cpp
  98. 0 0
      engine/core/math/Shape.h
  99. 0 0
      engine/core/math/Triangle.h
  100. 0 0
      engine/core/math/Vec2.cpp

+ 1 - 1
.gitignore

@@ -2,7 +2,7 @@
 /build
 
 # Ignore CMake-generated config files
-/src/Config.h
+/engine/Config.h
 /tools/Config.h
 
 # Ignore some android directories

+ 4 - 29
CMakeLists.txt

@@ -4,7 +4,7 @@ project(crown)
 
 set (CROWN_VERSION_MAJOR 0)
 set (CROWN_VERSION_MINOR 1)
-set (CROWN_VERSION_MICRO 6)
+set (CROWN_VERSION_MICRO 7)
 
 option (CROWN_BUILD_SAMPLES "Whether to build the samples" ON)
 option (CROWN_BUILD_TOOLS "Whether to build the tools" ON)
@@ -13,31 +13,6 @@ option (CROWN_BUILD_TESTS "Whether to build unit tests" OFF)
 # always debug mode for now
 set (CROWN_DEBUG 1)
 
-# detect architecture
-if (CROWN_ARCH MATCHES "x86")
-	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/third/x86)
-endif (CROWN_ARCH MATCHES "x86")
-
-if (CROWN_ARCH MATCHES "x86_64")
-	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/third/x86_64)
-endif (CROWN_ARCH MATCHES "x86_64")
-
-if (CROWN_ARCH MATCHES "win64")
-	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/third/win64)
-endif (CROWN_ARCH MATCHES "win64")
-
-if (CROWN_ARCH MATCHES "ARMv7")
-	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/third/ARMv7)
-endif (CROWN_ARCH MATCHES "ARMv7")
-
-set (CROWN_THIRD_INCLUDES
-	${CROWN_THIRD}/luajit/include/luajit-2.0
-)
-
-set (CROWN_THIRD_LIBS
-	${CROWN_THIRD}/luajit/lib
-)
-
 # detect operating system
 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 	set (LINUX 1)
@@ -47,10 +22,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 	set(WINDOWS 1)
 endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 
-# add build directories
-add_subdirectory(src)
-add_subdirectory(${CROWN_THIRD}) #necessary?
+# always build the engine
+add_subdirectory(engine)
 
+# select optional projects to build
 if (CROWN_BUILD_TOOLS)
 	add_subdirectory(tools)
 endif (CROWN_BUILD_TOOLS)

+ 0 - 1
src/Android.mk → engine/Android.mk

@@ -33,7 +33,6 @@ LOCAL_SRC_FILES :=\
 	core/math/Color4.cpp\
 	core/math/Mat3.cpp\
 	core/math/Mat4.cpp\
-	core/math/MathUtils.cpp\
 	core/math/Plane.cpp\
 	core/math/Quat.cpp\
 	core/math/Shape.cpp\

+ 0 - 0
src/Application.mk → engine/Application.mk


+ 0 - 0
src/ArchiveBundle.cpp → engine/ArchiveBundle.cpp


+ 0 - 0
src/ArchiveBundle.h → engine/ArchiveBundle.h


+ 0 - 0
src/Bundle.h → engine/Bundle.h


+ 72 - 37
src/CMakeLists.txt → engine/CMakeLists.txt

@@ -1,22 +1,59 @@
 cmake_minimum_required(VERSION 2.8)
 
+# detect architecture
+if (CROWN_ARCH MATCHES "x86")
+	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/x86)
+endif (CROWN_ARCH MATCHES "x86")
+
+if (CROWN_ARCH MATCHES "x86_64")
+	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/x86_64)
+endif (CROWN_ARCH MATCHES "x86_64")
+
+if (CROWN_ARCH MATCHES "win32")
+	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/win32)
+endif (CROWN_ARCH MATCHES "win32")
+
+if (CROWN_ARCH MATCHES "win64")
+	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/win64)
+endif (CROWN_ARCH MATCHES "win64")
+
+if (CROWN_ARCH MATCHES "ARMv7")
+	set (CROWN_THIRD ${CMAKE_SOURCE_DIR}/engine/third/ARMv7)
+endif (CROWN_ARCH MATCHES "ARMv7")
+
+# architecture dependent includes
+set (CROWN_THIRD_INCLUDES
+	${CROWN_THIRD}/luajit/include/luajit-2.0
+	${CROWN_THIRD}/glew-1.9.0/include
+	${CROWN_THIRD}/zlib/include	
+)
+
+# architecture dependent libraries
+set (CROWN_THIRD_LIBS
+	${CROWN_THIRD}/luajit/lib
+	${CROWN_THIRD}/glew-1.9.0/lib
+	${CROWN_THIRD}/zlib/lib
+)
+
+add_subdirectory(${CROWN_THIRD})
+
 # platform independent includes
 set (CROWN_INCLUDES
-	${CMAKE_SOURCE_DIR}/src
-	${CMAKE_SOURCE_DIR}/src/core
-	${CMAKE_SOURCE_DIR}/src/core/bv
-	${CMAKE_SOURCE_DIR}/src/core/containers
-	${CMAKE_SOURCE_DIR}/src/core/math
-	${CMAKE_SOURCE_DIR}/src/core/mem
-	${CMAKE_SOURCE_DIR}/src/core/compressors
-	${CMAKE_SOURCE_DIR}/src/core/filesystem
-	${CMAKE_SOURCE_DIR}/src/core/strings
-	${CMAKE_SOURCE_DIR}/src/core/settings
-	${CMAKE_SOURCE_DIR}/src/os
-	${CMAKE_SOURCE_DIR}/src/input
-	${CMAKE_SOURCE_DIR}/src/renderers
-	${CMAKE_SOURCE_DIR}/src/network
-	${CMAKE_SOURCE_DIR}/src/lua
+	${CMAKE_SOURCE_DIR}/engine
+	${CMAKE_SOURCE_DIR}/engine/core
+	${CMAKE_SOURCE_DIR}/engine/core/bv
+	${CMAKE_SOURCE_DIR}/engine/core/containers
+	${CMAKE_SOURCE_DIR}/engine/core/math
+	${CMAKE_SOURCE_DIR}/engine/core/mem
+	${CMAKE_SOURCE_DIR}/engine/core/compressors
+	${CMAKE_SOURCE_DIR}/engine/core/filesystem
+	${CMAKE_SOURCE_DIR}/engine/core/strings
+	${CMAKE_SOURCE_DIR}/engine/core/settings
+	${CMAKE_SOURCE_DIR}/engine/os
+	${CMAKE_SOURCE_DIR}/engine/input
+	${CMAKE_SOURCE_DIR}/engine/renderers
+	${CMAKE_SOURCE_DIR}/engine/network
+	${CMAKE_SOURCE_DIR}/engine/lua
 )
 
 set (SRC
@@ -107,7 +144,6 @@ set (MATH_SRC
 	core/math/Color4.cpp
 	core/math/Mat3.cpp
 	core/math/Mat4.cpp
-	core/math/MathUtils.cpp
 	core/math/Plane.cpp
 	core/math/Point2.cpp
 	core/math/Quat.cpp
@@ -286,29 +322,13 @@ set(LUA_HEADERS
 	lua/LuaEnvironment.h
 )
 
-
 set (CROWN_LIBRARIES)
 
-set (COMPILER_FLAGS
-	-pipe
-	-std=c++03
-	-ansi
-	-pedantic-errors
-	-Wall
-	-Wextra
-	-Wno-long-long
-	-Wno-variadic-macros
-	-g
-	-pg
-	-fPIC
-	-Wl,-E
-)
-
 # Platform specific stuff
 if (LINUX)
 	list (APPEND CROWN_INCLUDES
-		${CMAKE_SOURCE_DIR}/src/os/linux
-		${CMAKE_SOURCE_DIR}/src/renderers/gl/glx
+		${CMAKE_SOURCE_DIR}/engine/os/linux
+		${CMAKE_SOURCE_DIR}/engine/renderers/gl/glx
 	)
 
 	list (APPEND OS_HEADERS
@@ -356,14 +376,29 @@ if (LINUX)
 		luajit-5.1
 	)
 
+	set (COMPILER_FLAGS
+		-pipe
+		-std=c++03
+		-ansi
+		-pedantic-errors
+		-Wall
+		-Wextra
+		-Wno-long-long
+		-Wno-variadic-macros
+		-g
+		-pg
+		-fPIC
+		-Wl,-E
+	)
+
 	set (CROWN_EXECUTABLE_NAME crown-linux)
 	set (CROWN_MAIN_SRC os/linux/main.cpp)
 endif (LINUX)
 
 if (WINDOWS)
 	list (APPEND CROWN_INCLUDES
-		${CMAKE_SOURCE_DIR}/src/os/win
-		${CMAKE_SOURCE_DIR}/src/renderers/gl/wgl
+		${CMAKE_SOURCE_DIR}/engine/os/win
+		${CMAKE_SOURCE_DIR}/engine/renderers/gl/wgl
 	)
 
 	list (APPEND OS_HEADERS
@@ -402,7 +437,7 @@ if (WINDOWS)
 		lua51
 	)
 
-	set (COMPILER_FLAGS /link /OPT:NOREF)
+	set (COMPILER_FLAGS)
 	
 	set (CROWN_EXECUTABLE_NAME crown-win)
 	set (CROWN_MAIN_SRC os/win/main.cpp)

+ 0 - 0
src/Camera.cpp → engine/Camera.cpp


+ 0 - 0
src/Camera.h → engine/Camera.h


+ 0 - 0
src/Config.h.in → engine/Config.h.in


+ 0 - 0
src/ConsoleServer.cpp → engine/ConsoleServer.cpp


+ 0 - 0
src/ConsoleServer.h → engine/ConsoleServer.h


+ 0 - 0
src/Crown.h → engine/Crown.h


+ 1 - 1
src/Device.cpp → engine/Device.cpp

@@ -354,7 +354,7 @@ void Device::frame()
 	m_resource_manager->bring_loaded_online();
 
 	m_window->frame();
-	m_input_manager->frame();
+	m_input_manager->frame(frame_count());
 
 	m_lua_environment->game_frame(last_delta_time());
 

+ 2 - 2
src/Device.h → engine/Device.h

@@ -54,7 +54,7 @@ class ConsoleServer;
 /// The Engine.
 /// It is the place where to look for accessing all of
 /// the engine subsystems and related stuff.
-class Device
+class CE_EXPORT Device
 {
 public:
 
@@ -187,7 +187,7 @@ private:
 	Device& operator=(const Device&);
 };
 
-Device* device();
+CE_EXPORT Device* device();
 
 } // namespace crown
 

+ 0 - 0
src/FPSSystem.cpp → engine/FPSSystem.cpp


+ 0 - 0
src/FPSSystem.h → engine/FPSSystem.h


+ 0 - 0
src/FileBundle.cpp → engine/FileBundle.cpp


+ 0 - 0
src/FileBundle.h → engine/FileBundle.h


+ 2 - 8
src/FontResource.cpp → engine/FontResource.cpp

@@ -32,12 +32,8 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-void* FontResource::load(Allocator& allocator, Bundle& bundle, ResourceId id)
+void* FontResource::load(Allocator& /*allocator*/, Bundle& /*bundle*/, ResourceId /*id*/)
 {
-	(void)allocator;
-	(void)bundle;
-	(void)id;
-
 	return NULL;
 }
 
@@ -48,10 +44,8 @@ void FontResource::online(void* resource)
 }
 
 //-----------------------------------------------------------------------------
-void FontResource::unload(Allocator& allocator, void* resource)
+void FontResource::unload(Allocator& /*allocator*/, void* /*resource*/)
 {
-	(void)allocator;
-	(void)resource;
 }
 
 //-----------------------------------------------------------------------------

+ 0 - 0
src/FontResource.h → engine/FontResource.h


+ 0 - 0
src/Glyph.h → engine/Glyph.h


+ 0 - 0
src/JSONParser.cpp → engine/JSONParser.cpp


+ 0 - 0
src/JSONParser.h → engine/JSONParser.h


+ 2 - 9
src/MaterialResource.cpp → engine/MaterialResource.cpp

@@ -32,13 +32,8 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-void* MaterialResource::load(Allocator& allocator, Bundle& bundle, ResourceId id)
+void* MaterialResource::load(Allocator& /*allocator*/, Bundle& /*bundle*/, ResourceId /*id*/)
 {
-	(void)allocator;
-	(void)bundle;
-	(void)id;
-	// TODO
-
 	return NULL;
 }
 
@@ -50,10 +45,8 @@ void MaterialResource::online(void* material)
 }
 
 //-----------------------------------------------------------------------------
-void MaterialResource::unload(Allocator& allocator, void* material)
+void MaterialResource::unload(Allocator& /*allocator*/, void* /*material*/)
 {
-	(void)allocator;
-	(void)material;
 	// TODO
 }
 

+ 0 - 0
src/MaterialResource.h → engine/MaterialResource.h


+ 0 - 0
src/PixelShaderResource.cpp → engine/PixelShaderResource.cpp


+ 0 - 0
src/PixelShaderResource.h → engine/PixelShaderResource.h


+ 0 - 0
src/Resource.h → engine/Resource.h


+ 0 - 0
src/ResourceManager.cpp → engine/ResourceManager.cpp


+ 0 - 0
src/ResourceManager.h → engine/ResourceManager.h


+ 0 - 0
src/TextResource.cpp → engine/TextResource.cpp


+ 0 - 0
src/TextResource.h → engine/TextResource.h


+ 0 - 0
src/TextureResource.cpp → engine/TextureResource.cpp


+ 0 - 0
src/TextureResource.h → engine/TextureResource.h


+ 0 - 0
src/VertexShaderResource.cpp → engine/VertexShaderResource.cpp


+ 0 - 0
src/VertexShaderResource.h → engine/VertexShaderResource.h


+ 0 - 0
src/core/Args.cpp → engine/core/Args.cpp


+ 0 - 0
src/core/Args.h → engine/core/Args.h


+ 0 - 0
src/core/Assert.h → engine/core/Assert.h


+ 0 - 0
src/core/Log.cpp → engine/core/Log.cpp


+ 0 - 0
src/core/Log.h → engine/core/Log.h


+ 5 - 4
src/core/Types.h → engine/core/Types.h

@@ -31,8 +31,11 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Config.h"
 
-namespace crown
-{
+#ifdef WINDOWS
+	#define CE_EXPORT __declspec(dllexport)
+#else
+	#define CE_EXPORT
+#endif
 
 #ifndef NULL
 #ifdef __cplusplus
@@ -42,5 +45,3 @@ namespace crown
 #endif
 #endif
 
-} // namespace crown
-

+ 0 - 0
src/core/bv/Box.h → engine/core/bv/Box.h


+ 0 - 0
src/core/bv/Circle.cpp → engine/core/bv/Circle.cpp


+ 0 - 0
src/core/bv/Circle.h → engine/core/bv/Circle.h


+ 0 - 0
src/core/bv/Frustum.cpp → engine/core/bv/Frustum.cpp


+ 0 - 0
src/core/bv/Frustum.h → engine/core/bv/Frustum.h


+ 0 - 0
src/core/bv/Rect.cpp → engine/core/bv/Rect.cpp


+ 0 - 0
src/core/bv/Rect.h → engine/core/bv/Rect.h


+ 0 - 0
src/core/bv/Sphere.h → engine/core/bv/Sphere.h


+ 0 - 0
src/core/compressors/Compressor.h → engine/core/compressors/Compressor.h


+ 3 - 19
src/core/compressors/ZipCompressor.cpp → engine/core/compressors/ZipCompressor.cpp

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include <cstring>
 
-#include "zlib.h"
+//#include "zlib.h"
 #include "Assert.h"
 #include "ZipCompressor.h"
 
@@ -47,29 +47,13 @@ ZipCompressor::~ZipCompressor()
 //-----------------------------------------------------------------------------
 uint8_t* ZipCompressor::compress(const void* data, size_t in_size, size_t& out_size)
 {
-	out_size = in_size + in_size * 0.1f + 12;
-	
- 	uint8_t* dest = (uint8_t*)m_allocator.allocate(out_size);
-	
-	int32_t ret = ::compress((Bytef*)dest, (uLongf*)&out_size, (const Bytef*)data, (uLongf)in_size);
-	
-	CE_ASSERT(ret == Z_OK, "Failed to compress the data");
-	
-	return dest;
+	return NULL;
 }
 
 //-----------------------------------------------------------------------------
 uint8_t* ZipCompressor::uncompress(const void* data, size_t in_size, size_t& out_size)
 {
-	out_size = in_size + in_size * 0.1f + 12;
-	
- 	uint8_t* dest = (uint8_t*)m_allocator.allocate(out_size);
-	
-	int32_t ret = ::uncompress((Bytef*)dest, (uLongf*)&out_size, (const Bytef*)data, (uLongf)in_size);
-	
-	CE_ASSERT(ret == Z_OK, "Failed to uncompress the data");
-	
-	return dest;
+	return NULL;
 }
 
 } // namespace crown

+ 0 - 0
src/core/compressors/ZipCompressor.h → engine/core/compressors/ZipCompressor.h


+ 0 - 0
src/core/containers/Dictionary.h → engine/core/containers/Dictionary.h


+ 0 - 0
src/core/containers/Generic.cpp → engine/core/containers/Generic.cpp


+ 0 - 0
src/core/containers/Generic.h → engine/core/containers/Generic.h


+ 0 - 0
src/core/containers/IdTable.h → engine/core/containers/IdTable.h


+ 0 - 0
src/core/containers/List.h → engine/core/containers/List.h


+ 0 - 0
src/core/containers/Queue.h → engine/core/containers/Queue.h


+ 0 - 0
src/core/containers/RBTree.h → engine/core/containers/RBTree.h


+ 0 - 0
src/core/filesystem/BinaryReader.cpp → engine/core/filesystem/BinaryReader.cpp


+ 0 - 0
src/core/filesystem/BinaryReader.h → engine/core/filesystem/BinaryReader.h


+ 0 - 0
src/core/filesystem/BinaryWriter.cpp → engine/core/filesystem/BinaryWriter.cpp


+ 0 - 0
src/core/filesystem/BinaryWriter.h → engine/core/filesystem/BinaryWriter.h


+ 0 - 0
src/core/filesystem/DiskFile.cpp → engine/core/filesystem/DiskFile.cpp


+ 0 - 0
src/core/filesystem/DiskFile.h → engine/core/filesystem/DiskFile.h


+ 0 - 0
src/core/filesystem/File.cpp → engine/core/filesystem/File.cpp


+ 0 - 0
src/core/filesystem/File.h → engine/core/filesystem/File.h


+ 0 - 0
src/core/filesystem/Filesystem.cpp → engine/core/filesystem/Filesystem.cpp


+ 0 - 0
src/core/filesystem/Filesystem.h → engine/core/filesystem/Filesystem.h


+ 0 - 0
src/core/filesystem/MemoryFile.cpp → engine/core/filesystem/MemoryFile.cpp


+ 0 - 0
src/core/filesystem/MemoryFile.h → engine/core/filesystem/MemoryFile.h


+ 0 - 0
src/core/filesystem/NullFile.h → engine/core/filesystem/NullFile.h


+ 0 - 0
src/core/filesystem/TextReader.cpp → engine/core/filesystem/TextReader.cpp


+ 0 - 0
src/core/filesystem/TextReader.h → engine/core/filesystem/TextReader.h


+ 0 - 0
src/core/filesystem/TextWriter.cpp → engine/core/filesystem/TextWriter.cpp


+ 0 - 0
src/core/filesystem/TextWriter.h → engine/core/filesystem/TextWriter.h


+ 0 - 0
src/core/math/Color4.cpp → engine/core/math/Color4.cpp


+ 0 - 0
src/core/math/Color4.h → engine/core/math/Color4.h


+ 0 - 0
src/core/math/Interpolation.h → engine/core/math/Interpolation.h


+ 0 - 0
src/core/math/Intersection.h → engine/core/math/Intersection.h


+ 0 - 0
src/core/math/Mat3.cpp → engine/core/math/Mat3.cpp


+ 0 - 0
src/core/math/Mat3.h → engine/core/math/Mat3.h


+ 0 - 0
src/core/math/Mat4.cpp → engine/core/math/Mat4.cpp


+ 0 - 0
src/core/math/Mat4.h → engine/core/math/Mat4.h


+ 47 - 82
src/core/math/MathUtils.h → engine/core/math/MathUtils.h

@@ -29,10 +29,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 #undef min
 #undef max
 
-#include "Assert.h"
 #include <cmath>
+
+#include "Assert.h"
 #include "Types.h"
-#include <cstdio>
 
 #define BIT(i) (1 << i)
 
@@ -56,97 +56,20 @@ const float		FOUR_OVER_THREE				= (float)(4.0 / 3.0);
 const float		FOUR_OVER_THREE_TIMES_PI	= FOUR_OVER_THREE * PI;
 
 const float		ONE_OVER_THREE				= (float)(1.0 / 3.0);
+const float		ONE_OVER_FOUR				= (float)(1.0 / 4.0);
 const float		ONE_OVER_255				= (float)(1.0 / 255.0);
 
 const float		FLOAT_PRECISION				= (float)1.0e-7f;
 const double	DOUBLE_PRECISION			= (float)1.0e-9;
 
-bool			equals(float a, float b, float precision = FLOAT_PRECISION);
-bool			equals(double a, double b, double precision = DOUBLE_PRECISION);
-
-/// Tests agains the specified @a bitmask and returns true only if all bits are satisfied
-bool			test_bitmask(int32_t value, int32_t bitmask);
-
-/// Sets the specified @a bitmask	
-int32_t			set_bitmask(int32_t value, int32_t bitmask);
-
-/// Removes the specified @a bitmask	
-int32_t			unset_bitmask(int32_t value, int32_t bitmask);	
-
-/// Returns minimum between @a a and @a b
-template <typename T> T		min(const T& a, const T& b);
-
-/// Returns maximum between @a a and @a b
-template <typename T> T		max(const T& a, const T& b);
-
-/// Returns the arithmetic mean of @a a and @a b	
-template <typename T> T		avg(const T& a, const T& b);
-
-/// Clamps a value to a specific range (min < max)	
-template <typename T> T		clamp_to_range(const T& min, const T& max, const T& value);	
-
-/// Swaps @a a and @a b
-template <typename T> void	swap(T& a, T& b);				
-
-/// Returns @a deg in radians
-float			deg_to_rad(float deg);
-
-/// Returns @a rad in degrees
-float			rad_to_deg(float rad);
-
-/// Returns the nearest power of two to @a x
-uint32_t		next_pow_2(uint32_t x);
-
-/// Returns whether @a x is a power of two			
-bool			is_pow_2(uint32_t x);	
-
-/// Returns the smallest integral value that is not less than @a x
-float			ceil(float x);		
-
-/// Returns the largest integral value that is not greater than @a x			
-float			floor(float x);	
-
-/// Returns the square root of @a x				
-float			sqrt(float x);	
-
-/// Returns the inverse square root of @a x				
-float			inv_sqrt(float x);
-
-/// Returns the sine of @a x				
-float			sin(float x);	
-
-/// Returns the cosine of @a x				
-float			cos(float x);
-
-/// Returns the arc sine of @a x					
-float			asin(float x);	
-
-/// Returns the arc cosine of @a x				
-float			acos(float x);	
-
-/// Returns the tangent of @a x				
-float			tan(float x);		
-
-/// Returns the arc tangent of @a y/@a x			
-float			atan2(float y, float x);	
-
-/// Returns the absolute value of @a x		
-float			abs(float x);			
-
-/// Returns the floating-point remainder of numerator/denominator		
-float			fmod(float n, float d);			
-
-/// Returns true if there are solutions and puts them in 'x1' and 'x2' (x1 <= x2)
-bool			solve_quadratic_equation(float a, float b, float c, float& x1, float& x2);
-
 //-----------------------------------------------------------------------------
-inline bool equals(float a, float b, float precision)
+inline bool equals(float a, float b, float precision  = FLOAT_PRECISION)
 {
 	return ((b <= (a + precision)) && (b >= (a - precision)));
 }
 
 //-----------------------------------------------------------------------------
-inline bool equals(double a, double b, double precision)
+inline bool equals(double a, double b, double precision  = DOUBLE_PRECISION)
 {
 	return ((b <= (a + precision)) && (b >= (a - precision)));
 }
@@ -176,6 +99,20 @@ inline T min(const T& a, const T& b)
 	return a < b ? a : b;
 }
 
+//-----------------------------------------------------------------------------
+template <typename T>
+inline T min(const T& a, const T& b, const T& c)
+{
+	return math::min(math::min(a, b), math::min(a, c));
+}
+
+//-----------------------------------------------------------------------------
+template <typename T>
+inline T min(const T& a, const T& b, const T& c, const T& d)
+{
+	return math::min(math::min(a, b, c), math::min(a, b, d), math::min(a, c, d));
+}
+
 //-----------------------------------------------------------------------------
 template <typename T>
 inline T max(const T& a, const T& b)
@@ -183,6 +120,20 @@ inline T max(const T& a, const T& b)
 	return a < b ? b : a;
 }
 
+//-----------------------------------------------------------------------------
+template <typename T>
+inline T max(const T& a, const T& b, const T& c)
+{
+	return math::max(math::max(a, b), math::max(a, c));
+}
+
+//-----------------------------------------------------------------------------
+template <typename T>
+inline T max(const T& a, const T& b, const T& c, const T& d)
+{
+	return math::max(math::max(a, b, c), math::max(a, b, d), math::max(a, c, d));
+}
+
 //-----------------------------------------------------------------------------
 template <typename T>
 inline T avg(const T& a, const T& b)
@@ -190,6 +141,20 @@ inline T avg(const T& a, const T& b)
 	return (a + b) * 0.5;
 }
 
+//-----------------------------------------------------------------------------
+template <typename T>
+inline T avg(const T& a, const T& b, const T& c)
+{
+	return (a + b + c) * ONE_OVER_THREE;
+}
+
+//-----------------------------------------------------------------------------
+template <typename T>
+inline T avg(const T& a, const T& b, const T& c, const T& d)
+{
+	return (a + b + c + d) * ONE_OVER_FOUR;
+}
+
 //-----------------------------------------------------------------------------
 template <typename T>
 inline T clamp_to_range(const T& min, const T& max, const T& value)

+ 0 - 0
src/core/math/Plane.cpp → engine/core/math/Plane.cpp


+ 0 - 0
src/core/math/Plane.h → engine/core/math/Plane.h


+ 0 - 0
src/core/math/Point2.cpp → engine/core/math/Point2.cpp


+ 0 - 0
src/core/math/Point2.h → engine/core/math/Point2.h


+ 0 - 0
src/core/math/Quat.cpp → engine/core/math/Quat.cpp


+ 0 - 0
src/core/math/Quat.h → engine/core/math/Quat.h


+ 0 - 0
src/core/math/Random.h → engine/core/math/Random.h


+ 0 - 0
src/core/math/Ray.h → engine/core/math/Ray.h


+ 0 - 0
src/core/math/Shape.cpp → engine/core/math/Shape.cpp


+ 0 - 0
src/core/math/Shape.h → engine/core/math/Shape.h


+ 0 - 0
src/core/math/Triangle.h → engine/core/math/Triangle.h


+ 0 - 0
src/core/math/Vec2.cpp → engine/core/math/Vec2.cpp


Vissa filer visades inte eftersom för många filer har ändrats