فهرست منبع

Merge branch 'master' into world

Conflicts:
	engine/Camera.cpp
	engine/Camera.h
	engine/audio/SoundRenderer.h
	engine/core/math/Matrix4x4.cpp
	engine/core/math/Matrix4x4.h
	engine/core/math/Quaternion.cpp
	engine/core/math/Quaternion.h
	engine/lua/LuaCamera.cpp
	engine/lua/LuaQuaternion.cpp
	engine/lua/LuaStack.cpp
	engine/lua/LuaStack.h
Daniele Bartolini 12 سال پیش
والد
کامیت
06c5ef0a03
79فایلهای تغییر یافته به همراه1938 افزوده شده و 1519 حذف شده
  1. 10 10
      engine/Android.mk
  2. 16 16
      engine/CMakeLists.txt
  3. 15 15
      engine/Camera.cpp
  4. 15 15
      engine/Camera.h
  5. 6 6
      engine/Crown.h
  6. 17 17
      engine/Mesh.cpp
  7. 15 15
      engine/Mesh.h
  8. 2 2
      engine/RenderWorld.cpp
  9. 3 3
      engine/RenderWorld.h
  10. 17 17
      engine/SceneGraph.cpp
  11. 13 13
      engine/SceneGraph.h
  12. 11 11
      engine/Unit.cpp
  13. 13 13
      engine/Unit.h
  14. 6 6
      engine/World.cpp
  15. 7 7
      engine/World.h
  16. 8 8
      engine/audio/SoundRenderer.h
  17. 12 12
      engine/audio/al/ALRenderer.cpp
  18. 10 10
      engine/audio/al/ALRenderer.h
  19. 11 11
      engine/audio/sles/SLESRenderer.cpp
  20. 1 1
      engine/audio/sles/SLESRenderer.h
  21. 3 3
      engine/compilers/mesh/MeshCompiler.cpp
  22. 5 5
      engine/compilers/mesh/MeshCompiler.h
  23. 36 36
      engine/core/bv/Box.h
  24. 8 8
      engine/core/bv/Circle.h
  25. 6 6
      engine/core/bv/Frustum.cpp
  26. 5 5
      engine/core/bv/Frustum.h
  27. 11 11
      engine/core/bv/Rect.cpp
  28. 19 19
      engine/core/bv/Rect.h
  29. 13 13
      engine/core/bv/Sphere.h
  30. 48 48
      engine/core/math/Intersection.h
  31. 63 63
      engine/core/math/Matrix3x3.cpp
  32. 41 41
      engine/core/math/Matrix3x3.h
  33. 94 92
      engine/core/math/Matrix4x4.cpp
  34. 54 54
      engine/core/math/Matrix4x4.h
  35. 7 7
      engine/core/math/Plane.cpp
  36. 5 5
      engine/core/math/Plane.h
  37. 8 8
      engine/core/math/Point2.h
  38. 30 30
      engine/core/math/Quaternion.cpp
  39. 16 16
      engine/core/math/Quaternion.h
  40. 13 13
      engine/core/math/Ray.h
  41. 22 22
      engine/core/math/Triangle.h
  42. 5 5
      engine/core/math/Vector2.cpp
  43. 74 74
      engine/core/math/Vector2.h
  44. 6 6
      engine/core/math/Vector3.cpp
  45. 81 81
      engine/core/math/Vector3.h
  46. 7 7
      engine/core/math/Vector4.cpp
  47. 72 72
      engine/core/math/Vector4.h
  48. 3 3
      engine/input/Accelerometer.h
  49. 8 8
      engine/input/Mouse.h
  50. 5 5
      engine/input/Touch.h
  51. 1 1
      engine/lua/LuaAccelerometer.cpp
  52. 12 12
      engine/lua/LuaCamera.cpp
  53. 4 4
      engine/lua/LuaEnvironment.cpp
  54. 4 4
      engine/lua/LuaEnvironment.h
  55. 139 139
      engine/lua/LuaMatrix4x4.cpp
  56. 10 10
      engine/lua/LuaMesh.cpp
  57. 4 4
      engine/lua/LuaMouse.cpp
  58. 37 37
      engine/lua/LuaQuaternion.cpp
  59. 33 32
      engine/lua/LuaStack.cpp
  60. 12 12
      engine/lua/LuaStack.h
  61. 9 9
      engine/lua/LuaUnit.cpp
  62. 70 70
      engine/lua/LuaVector2.cpp
  63. 73 73
      engine/lua/LuaVector3.cpp
  64. 8 8
      engine/lua/LuaWorld.cpp
  65. 3 3
      engine/network/BitMessage.cpp
  66. 3 3
      engine/network/BitMessage.h
  67. 410 0
      engine/os/win/OsSocket.h
  68. 6 0
      engine/os/win/main.cpp
  69. 22 22
      engine/renderers/DebugRenderer.cpp
  70. 7 7
      engine/renderers/DebugRenderer.h
  71. 8 8
      engine/renderers/RenderContext.h
  72. 3 3
      engine/renderers/Renderer.h
  73. 5 5
      engine/renderers/gl/GLRenderer.cpp
  74. 1 1
      engine/resource/MaterialResource.h
  75. 3 3
      engine/tests/messages.cpp
  76. 16 16
      samples/terrain/Terrain.cpp
  77. 9 9
      samples/terrain/Terrain.h
  78. 4 4
      samples/terrain/terrain_main.cpp
  79. 46 46
      tools/gui/console/MainWindow.cs

+ 10 - 10
engine/Android.mk

@@ -46,13 +46,13 @@ LOCAL_SRC_FILES :=\
 	core/json/JSONParser.cpp\
 \
 	core/math/Color4.cpp\
-	core/math/Mat3.cpp\
-	core/math/Mat4.cpp\
+	core/math/Matrix3x3.cpp\
+	core/math/Matrix4x4.cpp\
 	core/math/Plane.cpp\
-	core/math/Quat.cpp\
-	core/math/Vec2.cpp\
-	core/math/Vec3.cpp\
-	core/math/Vec4.cpp\
+	core/math/Quaternion.cpp\
+	core/math/Vector2.cpp\
+	core/math/Vector3.cpp\
+	core/math/Vector4.cpp\
 \
 	core/mem/HeapAllocator.cpp\
 	core/mem/LinearAllocator.cpp\
@@ -91,13 +91,13 @@ LOCAL_SRC_FILES :=\
 	lua/LuaAccelerometer.cpp\
 	lua/LuaDevice.cpp\
 	lua/LuaKeyboard.cpp\
-	lua/LuaMat4.cpp\
+	lua/LuaMatrix4x4.cpp\
 	lua/LuaMath.cpp\
 	lua/LuaMouse.cpp\
-	lua/LuaQuat.cpp\
+	lua/LuaQuaternion.cpp\
 	lua/LuaTouch.cpp\
-	lua/LuaVec2.cpp\
-	lua/LuaVec3.cpp\
+	lua/LuaVector2.cpp\
+	lua/LuaVector3.cpp\
 	lua/LuaWindow.cpp\
 	lua/LuaIntSetting.cpp\
 	lua/LuaFloatSetting.cpp\

+ 16 - 16
engine/CMakeLists.txt

@@ -135,32 +135,32 @@ set (CONTAINERS_HEADERS
 
 set (MATH_SRC
 	core/math/Color4.cpp
-	core/math/Mat3.cpp
-	core/math/Mat4.cpp
+	core/math/Matrix3x3.cpp
+	core/math/Matrix4x4.cpp
 	core/math/Plane.cpp
 	core/math/Point2.cpp
-	core/math/Quat.cpp
-	core/math/Vec2.cpp
-	core/math/Vec3.cpp
-	core/math/Vec4.cpp
+	core/math/Quaternion.cpp
+	core/math/Vector2.cpp
+	core/math/Vector3.cpp
+	core/math/Vector4.cpp
 )
 
 set (MATH_HEADERS
 	core/math/Color4.h
 	core/math/Interpolation.h
 	core/math/Intersection.h
-	core/math/Mat3.h
-	core/math/Mat4.h
+	core/math/Matrix3x3.h
+	core/math/Matrix4x4.h
 	core/math/MathUtils.h
 	core/math/Plane.h
 	core/math/Point2.h
-	core/math/Quat.h
+	core/math/Quaternion.h
 	core/math/Random.h
 	core/math/Ray.h
 	core/math/Triangle.h
-	core/math/Vec2.h
-	core/math/Vec3.h
-	core/math/Vec4.h
+	core/math/Vector2.h
+	core/math/Vector3.h
+	core/math/Vector4.h
 )
 
 set (FILESYSTEM_SRC
@@ -326,10 +326,10 @@ set (LUA_SRC
 	lua/LuaIntSetting.cpp
 	lua/LuaFloatSetting.cpp
 	lua/LuaStringSetting.cpp
-	lua/LuaVec2.cpp
-	lua/LuaVec3.cpp
-	lua/LuaMat4.cpp
-	lua/LuaQuat.cpp
+	lua/LuaVector2.cpp
+	lua/LuaVector3.cpp
+	lua/LuaMatrix4x4.cpp
+	lua/LuaQuaternion.cpp
 	lua/LuaMath.cpp
 	lua/LuaMouse.cpp
 	lua/LuaKeyboard.cpp

+ 15 - 15
engine/Camera.cpp

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Camera.h"
 #include "Types.h"
 #include "MathUtils.h"
-#include "Quat.h"
+#include "Quaternion.h"
 #include "Unit.h"
 #include "Assert.h"
 
@@ -35,7 +35,7 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------
-void Camera::create(int32_t node, const Vec3& pos, const Quat& rot)
+void Camera::create(int32_t node, const Vector3& pos, const Quaternion& rot)
 {
 	m_node = node;
 	m_projection_type = ProjectionType::PERSPECTIVE;
@@ -46,59 +46,59 @@ void Camera::create(int32_t node, const Vec3& pos, const Quat& rot)
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Camera::local_position() const
+Vector3 Camera::local_position() const
 {
 	return m_local_pose.translation();
 }
 
 //-----------------------------------------------------------------------------
-Quat Camera::local_rotation() const
+Quaternion Camera::local_rotation() const
 {
-	return Quat(Vec3(1, 0, 0), 0.0f);
+	return Quaternion(Vector3(1, 0, 0), 0.0f);
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Camera::local_pose() const
+Matrix4x4 Camera::local_pose() const
 {
 	return m_local_pose;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Camera::world_position() const
+Vector3 Camera::world_position() const
 {
 	return m_world_pose.translation();
 }
 
 //-----------------------------------------------------------------------------
-Quat Camera::world_rotation() const
+Quaternion Camera::world_rotation() const
 {
-	return Quat(Vec3(1, 0, 0), 0.0f);
+	return Quaternion(Vector3(1, 0, 0), 0.0f);
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Camera::world_pose() const
+Matrix4x4 Camera::world_pose() const
 {
 	return m_world_pose;
 }
 
 //-----------------------------------------------------------------------------
-void Camera::set_local_position(const Vec3& pos)
+void Camera::set_local_position(const Vector3& pos)
 {
 	m_local_pose.set_translation(pos);
 }
 
 //-----------------------------------------------------------------------------
-void Camera::set_local_rotation(const Quat& rot)
+void Camera::set_local_rotation(const Quaternion& rot)
 {
-	Mat4& local_pose = m_local_pose;
+	Matrix4x4& local_pose = m_local_pose;
 
-	Vec3 local_translation = local_pose.translation();
+	Vector3 local_translation = local_pose.translation();
 	local_pose = rot.to_mat4();
 	local_pose.set_translation(local_translation);
 }
 
 //-----------------------------------------------------------------------------
-void Camera::set_local_pose(const Mat4& pose)
+void Camera::set_local_pose(const Matrix4x4& pose)
 {
 	m_local_pose = pose;
 }

+ 15 - 15
engine/Camera.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Frustum.h"
-#include "Mat4.h"
+#include "Matrix4x4.h"
 
 namespace crown
 {
@@ -42,25 +42,25 @@ struct ProjectionType
 	};
 };
 
-class Quat;
+class Quaternion;
 class Unit;
 
 /// Represents the point of view into the game world.
 struct Camera
 {
-	void					create(int32_t node, const Vec3& pos, const Quat& rot);
+	void					create(int32_t node, const Vector3& pos, const Quaternion& rot);
 
-	Vec3					local_position() const;
-	Quat					local_rotation() const;
-	Mat4					local_pose() const;
+	Vector3					local_position() const;
+	Quaternion					local_rotation() const;
+	Matrix4x4					local_pose() const;
 
-	Vec3					world_position() const;
-	Quat					world_rotation() const;
-	Mat4					world_pose() const;
+	Vector3					world_position() const;
+	Quaternion					world_rotation() const;
+	Matrix4x4					world_pose() const;
 
-	void					set_local_position(const Vec3& pos);
-	void					set_local_rotation(const Quat& rot);
-	void					set_local_pose(const Mat4& pose);
+	void					set_local_position(const Vector3& pos);
+	void					set_local_rotation(const Quaternion& rot);
+	void					set_local_pose(const Matrix4x4& pose);
 
 	void					set_projection_type(ProjectionType::Enum type);
 	ProjectionType::Enum	projection_type() const;
@@ -84,11 +84,11 @@ public:
 public:
 
 	int32_t					m_node;
-	Mat4					m_local_pose;
-	Mat4					m_world_pose;
+	Matrix4x4					m_local_pose;
+	Matrix4x4					m_world_pose;
 
 	ProjectionType::Enum	m_projection_type;
-	Mat4					m_projection;
+	Matrix4x4					m_projection;
 
 	Frustum					m_frustum;
 	float					m_FOV;

+ 6 - 6
engine/Crown.h

@@ -36,18 +36,18 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Color4.h"
 #include "Interpolation.h"
 #include "Intersection.h"
-#include "Mat3.h"
-#include "Mat4.h"
+#include "Matrix3x3.h"
+#include "Matrix4x4.h"
 #include "MathUtils.h"
 #include "Plane.h"
 #include "Point2.h"
-#include "Quat.h"
+#include "Quaternion.h"
 #include "Random.h"
 #include "Ray.h"
 #include "Triangle.h"
-#include "Vec2.h"
-#include "Vec3.h"
-#include "Vec4.h"
+#include "Vector2.h"
+#include "Vector3.h"
+#include "Vector4.h"
 
 // Core/Bv
 #include "Box.h"

+ 17 - 17
engine/Mesh.cpp

@@ -26,15 +26,15 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Mesh.h"
 #include "MeshResource.h"
-#include "Vec3.h"
-#include "Mat4.h"
-#include "Quat.h"
+#include "Vector3.h"
+#include "Matrix4x4.h"
+#include "Quaternion.h"
 
 namespace crown
 {
 
 //-----------------------------------------------------------------------------
-void Mesh::create(const MeshResource* mr, const Vec3& pos, const Quat& rot)
+void Mesh::create(const MeshResource* mr, const Vector3& pos, const Quaternion& rot)
 {
 	m_vbuffer = mr->m_vbuffer;
 	m_ibuffer = mr->m_ibuffer;
@@ -44,59 +44,59 @@ void Mesh::create(const MeshResource* mr, const Vec3& pos, const Quat& rot)
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mesh::local_position() const
+Vector3 Mesh::local_position() const
 {
 	return m_local_pose.translation();
 }
 
 //-----------------------------------------------------------------------------
-Quat Mesh::local_rotation() const
+Quaternion Mesh::local_rotation() const
 {
-	return Quat(Vec3(1, 0, 0), 0.0f);
+	return Quaternion(Vector3(1, 0, 0), 0.0f);
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mesh::local_pose() const
+Matrix4x4 Mesh::local_pose() const
 {
 	return m_local_pose;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mesh::world_position() const
+Vector3 Mesh::world_position() const
 {
 	return m_world_pose.translation();
 }
 
 //-----------------------------------------------------------------------------
-Quat Mesh::world_rotation() const
+Quaternion Mesh::world_rotation() const
 {
-	return Quat(Vec3(1, 0, 0), 0.0f);
+	return Quaternion(Vector3(1, 0, 0), 0.0f);
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mesh::world_pose() const
+Matrix4x4 Mesh::world_pose() const
 {
 	return m_world_pose;
 }
 
 //-----------------------------------------------------------------------------
-void Mesh::set_local_position(const Vec3& pos)
+void Mesh::set_local_position(const Vector3& pos)
 {
 	m_local_pose.set_translation(pos);
 }
 
 //-----------------------------------------------------------------------------
-void Mesh::set_local_rotation(const Quat& rot)
+void Mesh::set_local_rotation(const Quaternion& rot)
 {
-	Mat4& local_pose = m_local_pose;
+	Matrix4x4& local_pose = m_local_pose;
 
-	Vec3 local_translation = local_pose.translation();
+	Vector3 local_translation = local_pose.translation();
 	local_pose = rot.to_mat4();
 	local_pose.set_translation(local_translation);
 }
 
 //-----------------------------------------------------------------------------
-void Mesh::set_local_pose(const Mat4& pose)
+void Mesh::set_local_pose(const Matrix4x4& pose)
 {
 	m_local_pose = pose;
 }

+ 15 - 15
engine/Mesh.h

@@ -27,37 +27,37 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "RendererTypes.h"
-#include "Mat4.h"
+#include "Matrix4x4.h"
 
 namespace crown
 {
 
 struct MeshResource;
-class Vec3;
-class Quat;
+class Vector3;
+class Quaternion;
 
 struct Mesh
 {
-	void			create(const MeshResource* mr, const Vec3& pos, const Quat& rot);
+	void			create(const MeshResource* mr, const Vector3& pos, const Quaternion& rot);
 
-	Vec3			local_position() const;
-	Quat			local_rotation() const;
-	Mat4			local_pose() const;
+	Vector3			local_position() const;
+	Quaternion			local_rotation() const;
+	Matrix4x4			local_pose() const;
 
-	Vec3			world_position() const;
-	Quat			world_rotation() const;
-	Mat4			world_pose() const;
+	Vector3			world_position() const;
+	Quaternion			world_rotation() const;
+	Matrix4x4			world_pose() const;
 
-	void			set_local_position(const Vec3& pos);
-	void			set_local_rotation(const Quat& rot);
-	void			set_local_pose(const Mat4& pose);
+	void			set_local_position(const Vector3& pos);
+	void			set_local_rotation(const Quaternion& rot);
+	void			set_local_pose(const Matrix4x4& pose);
 
 public:
 
 	int32_t m_node;
 
-	Mat4 m_local_pose;
-	Mat4 m_world_pose;
+	Matrix4x4 m_local_pose;
+	Matrix4x4 m_world_pose;
 
 	VertexBufferId m_vbuffer;
 	IndexBufferId m_ibuffer;

+ 2 - 2
engine/RenderWorld.cpp

@@ -120,7 +120,7 @@ RenderWorld::~RenderWorld()
 }
 
 //-----------------------------------------------------------------------------
-MeshId RenderWorld::create_mesh(const char* name, const Vec3& pos, const Quat& rot)
+MeshId RenderWorld::create_mesh(const char* name, const Vector3& pos, const Quaternion& rot)
 {
 	MeshResource* mr = (MeshResource*) device()->resource_manager()->lookup("mesh", name);
 
@@ -140,7 +140,7 @@ void RenderWorld::update(Camera& camera, float /*dt*/)
 {
 	Renderer* r = device()->renderer();
 
-	Mat4 camera_view = camera.local_pose();
+	Matrix4x4 camera_view = camera.local_pose();
 	camera_view.invert();
 
 	r->set_layer_view(0, camera_view);

+ 3 - 3
engine/RenderWorld.h

@@ -29,8 +29,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "IdTable.h"
 #include "Mesh.h"
 #include "List.h"
-#include "Vec3.h"
-#include "Quat.h"
+#include "Vector3.h"
+#include "Quaternion.h"
 
 #define MAX_MESHES 100
 
@@ -47,7 +47,7 @@ public:
 	RenderWorld();
 	~RenderWorld();
 
-	MeshId create_mesh(const char* mesh, const Vec3& pos = Vec3::ZERO, const Quat& rot = Quat::IDENTITY);
+	MeshId create_mesh(const char* mesh, const Vector3& pos = Vector3::ZERO, const Quaternion& rot = Quaternion::IDENTITY);
 	void destroy_mesh(MeshId id);
 
 	void update(Camera& camera, float dt);

+ 17 - 17
engine/SceneGraph.cpp

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "SceneGraph.h"
-#include "Quat.h"
+#include "Quaternion.h"
 #include "Allocator.h"
 
 namespace crown
@@ -40,9 +40,9 @@ SceneGraph::SceneGraph()
 }
 
 //-----------------------------------------------------------------------------
-int32_t SceneGraph::create_node(int32_t parent, const Vec3& pos, const Quat& rot)
+int32_t SceneGraph::create_node(int32_t parent, const Vector3& pos, const Quaternion& rot)
 {
-	Mat4 pose(rot, pos);
+	Matrix4x4 pose(rot, pos);
 
 	m_world_poses.push_back(pose);
 	m_local_poses.push_back(pose);
@@ -72,60 +72,60 @@ void SceneGraph::unlink(int32_t child)
 }
 
 //-----------------------------------------------------------------------------
-void SceneGraph::set_local_position(int32_t node, const Vec3& pos)
+void SceneGraph::set_local_position(int32_t node, const Vector3& pos)
 {
-	Mat4& local_pose = m_local_poses[node];
+	Matrix4x4& local_pose = m_local_poses[node];
 	local_pose.set_translation(pos);
 }
 
 //-----------------------------------------------------------------------------
-void SceneGraph::set_local_rotation(int32_t node, const Quat& rot)
+void SceneGraph::set_local_rotation(int32_t node, const Quaternion& rot)
 {
-	Mat4& local_pose = m_local_poses[node];
+	Matrix4x4& local_pose = m_local_poses[node];
 
-	Vec3 local_translation = local_pose.translation();
+	Vector3 local_translation = local_pose.translation();
 	local_pose = rot.to_mat4();
 	local_pose.set_translation(local_translation);
 }
 
 //-----------------------------------------------------------------------------
-void SceneGraph::set_local_pose(int32_t node, const Mat4& pose)
+void SceneGraph::set_local_pose(int32_t node, const Matrix4x4& pose)
 {
 	m_local_poses[node] = pose;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 SceneGraph::local_position(int32_t node) const
+Vector3 SceneGraph::local_position(int32_t node) const
 {
 	return m_local_poses[node].translation();
 }
 
 //-----------------------------------------------------------------------------
-Quat SceneGraph::local_rotation(int32_t /*node*/) const
+Quaternion SceneGraph::local_rotation(int32_t /*node*/) const
 {
-	return Quat(Vec3(1, 0, 0), 0.0f);
+	return Quaternion(Vector3(1, 0, 0), 0.0f);
 }
 
 //-----------------------------------------------------------------------------
-Mat4 SceneGraph::local_pose(int32_t node) const
+Matrix4x4 SceneGraph::local_pose(int32_t node) const
 {
 	return m_local_poses[node];
 }
 
 //-----------------------------------------------------------------------------
-Vec3 SceneGraph::world_position(int32_t node) const
+Vector3 SceneGraph::world_position(int32_t node) const
 {
 	return m_world_poses[node].translation();
 }
 
 //-----------------------------------------------------------------------------
-Quat SceneGraph::world_rotation(int32_t /*node*/) const
+Quaternion SceneGraph::world_rotation(int32_t /*node*/) const
 {
-	return Quat(Vec3(1, 0, 0), 0.0f);
+	return Quaternion(Vector3(1, 0, 0), 0.0f);
 }
 
 //-----------------------------------------------------------------------------
-Mat4 SceneGraph::world_pose(int32_t node) const
+Matrix4x4 SceneGraph::world_pose(int32_t node) const
 {
 	return m_world_poses[node];
 }

+ 13 - 13
engine/SceneGraph.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "Mat4.h"
+#include "Matrix4x4.h"
 #include "List.h"
 
 namespace crown
@@ -36,30 +36,30 @@ namespace crown
 struct SceneGraph
 {
 					SceneGraph();
-	int32_t			create_node(int32_t parent, const Vec3& pos, const Quat& rot);
+	int32_t			create_node(int32_t parent, const Vector3& pos, const Quaternion& rot);
 	void			destroy_node(int32_t id);
 
 	void			link(int32_t child, int32_t parent);
 	void			unlink(int32_t child);
 
-	void			set_local_position(int32_t node, const Vec3& pos);
-	void			set_local_rotation(int32_t node, const Quat& rot);
-	void			set_local_pose(int32_t node, const Mat4& pose);
+	void			set_local_position(int32_t node, const Vector3& pos);
+	void			set_local_rotation(int32_t node, const Quaternion& rot);
+	void			set_local_pose(int32_t node, const Matrix4x4& pose);
 
-	Vec3			local_position(int32_t node) const;
-	Quat			local_rotation(int32_t node) const;
-	Mat4			local_pose(int32_t node) const;
+	Vector3			local_position(int32_t node) const;
+	Quaternion			local_rotation(int32_t node) const;
+	Matrix4x4			local_pose(int32_t node) const;
 
-	Vec3			world_position(int32_t node) const;
-	Quat			world_rotation(int32_t node) const;
-	Mat4			world_pose(int32_t node) const;
+	Vector3			world_position(int32_t node) const;
+	Quaternion			world_rotation(int32_t node) const;
+	Matrix4x4			world_pose(int32_t node) const;
 
 	void			update();
 
 public:
 
-	List<Mat4>		m_world_poses;
-	List<Mat4>		m_local_poses;
+	List<Matrix4x4>		m_world_poses;
+	List<Matrix4x4>		m_local_poses;
 	List<int32_t>	m_parents;
 };
 

+ 11 - 11
engine/Unit.cpp

@@ -43,12 +43,12 @@ Unit::Unit()
 }
 
 //-----------------------------------------------------------------------------
-void Unit::create(World& creator, const Vec3& pos, const Quat& rot)
+void Unit::create(World& creator, const Vector3& pos, const Quaternion& rot)
 {
 	m_creator = &creator;
 	m_root_node = m_scene_graph.create_node(-1, pos, rot);
 
-	int32_t camera_node = m_scene_graph.create_node(m_root_node, Vec3::ZERO, Quat::IDENTITY);
+	int32_t camera_node = m_scene_graph.create_node(m_root_node, Vector3::ZERO, Quaternion::IDENTITY);
 	CameraId camera = m_creator->create_camera(camera_node);
 	m_camera = m_creator->lookup_camera(camera);
 }
@@ -77,55 +77,55 @@ void Unit::reload(UnitResource* new_ur)
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Unit::local_position(int32_t node) const
+Vector3 Unit::local_position(int32_t node) const
 {
 	return m_scene_graph.local_position(node);
 }
 
 //-----------------------------------------------------------------------------
-Quat Unit::local_rotation(int32_t node) const
+Quaternion Unit::local_rotation(int32_t node) const
 {
 	return m_scene_graph.local_rotation(node);
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Unit::local_pose(int32_t node) const
+Matrix4x4 Unit::local_pose(int32_t node) const
 {
 	return m_scene_graph.local_pose(node);
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Unit::world_position(int32_t node) const
+Vector3 Unit::world_position(int32_t node) const
 {
 	return m_scene_graph.world_position(node);
 }
 
 //-----------------------------------------------------------------------------
-Quat Unit::world_rotation(int32_t node) const
+Quaternion Unit::world_rotation(int32_t node) const
 {
 	return m_scene_graph.world_rotation(node);
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Unit::world_pose(int32_t node) const
+Matrix4x4 Unit::world_pose(int32_t node) const
 {
 	return m_scene_graph.world_pose(node);
 }
 
 //-----------------------------------------------------------------------------
-void Unit::set_local_position(const Vec3& pos, int32_t node)
+void Unit::set_local_position(const Vector3& pos, int32_t node)
 {
 	m_scene_graph.set_local_position(node, pos);
 }
 
 //-----------------------------------------------------------------------------
-void Unit::set_local_rotation(const Quat& rot, int32_t node)
+void Unit::set_local_rotation(const Quaternion& rot, int32_t node)
 {
 	m_scene_graph.set_local_rotation(node, rot);
 }
 
 //-----------------------------------------------------------------------------
-void Unit::set_local_pose(const Mat4& pose, int32_t node)
+void Unit::set_local_pose(const Matrix4x4& pose, int32_t node)
 {
 	m_scene_graph.set_local_pose(node, pose);
 }

+ 13 - 13
engine/Unit.h

@@ -26,9 +26,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include "Vec3.h"
-#include "Quat.h"
-#include "Mat4.h"
+#include "Vector3.h"
+#include "Quaternion.h"
+#include "Matrix4x4.h"
 #include "Hash.h"
 #include "IdTable.h"
 #include "SceneGraph.h"
@@ -69,24 +69,24 @@ class World;
 struct Unit
 {
 					Unit();
-	void			create(World& creator, const Vec3& pos, const Quat& rot);
+	void			create(World& creator, const Vector3& pos, const Quaternion& rot);
 	void			destroy();
 
 	void			load(UnitResource* ur);
 	void			unload();
 	void			reload(UnitResource* new_ur);
 
-	Vec3			local_position(int32_t node = 0) const;
-	Quat			local_rotation(int32_t node = 0) const;
-	Mat4			local_pose(int32_t node = 0) const;
+	Vector3			local_position(int32_t node = 0) const;
+	Quaternion			local_rotation(int32_t node = 0) const;
+	Matrix4x4			local_pose(int32_t node = 0) const;
 
-	Vec3			world_position(int32_t node = 0) const;
-	Quat			world_rotation(int32_t node = 0) const;
-	Mat4			world_pose(int32_t node = 0) const;
+	Vector3			world_position(int32_t node = 0) const;
+	Quaternion			world_rotation(int32_t node = 0) const;
+	Matrix4x4			world_pose(int32_t node = 0) const;
 
-	void			set_local_position(const Vec3& pos, int32_t node = 0);
-	void			set_local_rotation(const Quat& rot, int32_t node = 0);
-	void			set_local_pose(const Mat4& pose, int32_t node = 0);
+	void			set_local_position(const Vector3& pos, int32_t node = 0);
+	void			set_local_rotation(const Quaternion& rot, int32_t node = 0);
+	void			set_local_pose(const Matrix4x4& pose, int32_t node = 0);
 
 	void			add_component(const char* name, uint32_t type, ComponentId component);
 	void			remove_component(const char* name);

+ 6 - 6
engine/World.cpp

@@ -53,7 +53,7 @@ void World::shutdown()
 }
 
 //-----------------------------------------------------------------------------
-UnitId World::spawn_unit(const char* /*name*/, const Vec3& pos, const Quat& rot)
+UnitId World::spawn_unit(const char* /*name*/, const Vector3& pos, const Quaternion& rot)
 {
 	const UnitId unit = m_unit_table.create();
 
@@ -124,7 +124,7 @@ RenderWorld& World::render_world()
 }
 
 //-----------------------------------------------------------------------------
-CameraId World::create_camera(int32_t node, const Vec3& pos, const Quat& rot)
+CameraId World::create_camera(int32_t node, const Vector3& pos, const Quaternion& rot)
 {
 	CameraId camera = m_camera_table.create();
 
@@ -145,7 +145,7 @@ Mesh* World::mesh()
 }
 
 //-----------------------------------------------------------------------------
-SoundInstanceId World::play_sound(const char* name, const bool loop, const float volume, const Vec3& pos, const float range)
+SoundInstanceId World::play_sound(const char* name, const bool loop, const float volume, const Vector3& pos, const float range)
 {
 	SoundInstanceId id = m_sound_table.create();
 
@@ -177,18 +177,18 @@ void World::link_sound(SoundInstanceId sound, UnitId unit)
 	CE_ASSERT(m_unit_table.has(unit), "Unit does not exists");
 	CE_ASSERT(m_sound_table.has(sound), "SoundInstance does not exists");
 
-	Vec3 pos = m_units[unit.index].world_position();
+	Vector3 pos = m_units[unit.index].world_position();
 	device()->sound_renderer()->set_sound_position(m_sound[sound.index].m_sound, pos);
 }
 
 //-----------------------------------------------------------------------------
-void World::set_listener(const Vec3& pos, const Vec3& vel, const Vec3& or_up, const Vec3& or_at)
+void World::set_listener(const Vector3& pos, const Vector3& vel, const Vector3& or_up, const Vector3& or_at)
 {
 	device()->sound_renderer()->set_listener(pos, vel, or_up, or_at);
 }
 
 //-----------------------------------------------------------------------------
-void World::set_sound_position(SoundInstanceId sound, const Vec3& pos)
+void World::set_sound_position(SoundInstanceId sound, const Vector3& pos)
 {
 	CE_ASSERT(m_sound_table.has(sound), "SoundInstance does not exists");
 

+ 7 - 7
engine/World.h

@@ -51,8 +51,8 @@ struct SoundInstance
 	SoundId m_sound;
 };
 
-class Vec3;
-class Quat;
+class Vector3;
+class Quaternion;
 
 class World
 {
@@ -62,7 +62,7 @@ public:
 	void					init();
 	void					shutdown();
 
-	UnitId					spawn_unit(const char* name, const Vec3& pos = Vec3::ZERO, const Quat& rot = Quat(Vec3(0, 1, 0), 0.0f));
+	UnitId					spawn_unit(const char* name, const Vector3& pos = Vector3::ZERO, const Quaternion& rot = Quaternion(Vector3(0, 1, 0), 0.0f));
 	void					kill_unit(UnitId unit);
 
 	void					link_unit(UnitId child, UnitId parent);
@@ -74,16 +74,16 @@ public:
 	RenderWorld&			render_world();
 	void					update(Camera& camera, float dt);
 
-	CameraId				create_camera(int32_t node, const Vec3& pos = Vec3::ZERO, const Quat& rot = Quat::IDENTITY);
+	CameraId				create_camera(int32_t node, const Vector3& pos = Vector3::ZERO, const Quaternion& rot = Quaternion::IDENTITY);
 	void					destroy_camera(CameraId camera);
 
 	Mesh*					mesh();
 
-	SoundInstanceId			play_sound(const char* name, const bool loop = false, const float volume = 1.0f, const Vec3& pos = Vec3::ZERO, const float range = 50.0f);
+	SoundInstanceId			play_sound(const char* name, const bool loop = false, const float volume = 1.0f, const Vector3& pos = Vector3::ZERO, const float range = 50.0f);
 	void					pause_sound(SoundInstanceId sound);
 	void 					link_sound(SoundInstanceId sound, UnitId unit);
-	void					set_listener(const Vec3& pos, const Vec3& vel, const Vec3& or_up, const Vec3& or_at);
-	void					set_sound_position(SoundInstanceId sound, const Vec3& pos);
+	void					set_listener(const Vector3& pos, const Vector3& vel, const Vector3& or_up, const Vector3& or_at);
+	void					set_sound_position(SoundInstanceId sound, const Vector3& pos);
 	void					set_sound_range(SoundInstanceId sound, const float range);
 	void					set_sound_volume(SoundInstanceId sound, const float vol);
 	

+ 8 - 8
engine/audio/SoundRenderer.h

@@ -40,7 +40,7 @@ typedef 	Id 		SoundId;
 //-----------------------------------------------------------------------------
 class SoundRendererImpl;
 class SoundResource;
-class Vec3;
+class Vector3;
 
 //-----------------------------------------------------------------------------
 class SoundRenderer
@@ -65,7 +65,7 @@ public:
 
 	/// Sets listener parameters. @a position affects audibility of sounds, 
 	/// @a velocity affects doppler shift and @a orientation affects how a sound could be heard
-	void					set_listener(const Vec3& pos, const Vec3& vel, const Vec3& or_up, const Vec3& or_at) const;
+	void					set_listener(const Vector3& pos, const Vector3& vel, const Vector3& or_up, const Vector3& or_at) const;
 
 	/// Creates a sound of sound 
 	SoundId					create_sound(SoundResource* resource);
@@ -91,13 +91,13 @@ public:
 	void					set_sound_max_distance(SoundId id, const float max_distance);
 
 	/// Sets sound's @a position. It affects sound audibility
-	void					set_sound_position(SoundId id, const Vec3& pos);
+	void					set_sound_position(SoundId id, const Vector3& pos);
 
 	/// Sets sound's @a velocity. It affects doppler shift
-	void					set_sound_velocity(SoundId id, const Vec3& vel);
+	void					set_sound_velocity(SoundId id, const Vector3& vel);
 
 	/// Sets sound's @a direction. It affects how a sound could be heard
-	void					set_sound_direction(SoundId id, const Vec3& dir);
+	void					set_sound_direction(SoundId id, const Vector3& dir);
 
 	/// Sets sound's @a pitch.
 	void					set_sound_pitch(SoundId id, const float pitch);
@@ -115,13 +115,13 @@ public:
 	float					sound_max_distance(SoundId id) const;
 	
 	/// Returns position of @a id
-	Vec3					sound_position(SoundId id) const;
+	Vector3					sound_position(SoundId id) const;
 
 	/// Returns velocity of @a id
-	Vec3					sound_velocity(SoundId id) const;
+	Vector3					sound_velocity(SoundId id) const;
 
 	/// Returns direction of @a id
-	Vec3					sound_direction(SoundId id) const;
+	Vector3					sound_direction(SoundId id) const;
 
 	/// Returns pitch of @a id
 	float					sound_pitch(SoundId id) const;

+ 12 - 12
engine/audio/al/ALRenderer.cpp

@@ -70,10 +70,10 @@ public:
 		AL_CHECK(alDopplerVelocity(343.0f));
 
 		// Default listener
-		Vec3 pos(0.0f, 0.0f, 0.0f);
-		Vec3 vel(0.0f, 0.0f, 0.0f);
-		Vec3 at(0.0f, 0.0f, -1.0f);
-		Vec3 up(0.0f, 1.0f, 0.0f);
+		Vector3 pos(0.0f, 0.0f, 0.0f);
+		Vector3 vel(0.0f, 0.0f, 0.0f);
+		Vector3 at(0.0f, 0.0f, -1.0f);
+		Vector3 up(0.0f, 1.0f, 0.0f);
 
 		set_listener(pos, vel, at, up);		
 	}
@@ -86,7 +86,7 @@ public:
 	}
 
 	//-----------------------------------------------------------------------------
-	void set_listener(const Vec3& pos, const Vec3& vel, const Vec3& or_up, const Vec3& or_at)
+	void set_listener(const Vector3& pos, const Vector3& vel, const Vector3& or_up, const Vector3& or_at)
 	{
 		AL_CHECK(alListener3f(AL_POSITION, pos.x, pos.y, pos.z));
 		AL_CHECK(alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z));
@@ -160,7 +160,7 @@ uint32_t SoundRenderer::num_sounds()
 }
 
 //-----------------------------------------------------------------------------
-void SoundRenderer::set_listener(const Vec3& pos, const Vec3& vel, const Vec3& or_up, const Vec3& or_at) const
+void SoundRenderer::set_listener(const Vector3& pos, const Vector3& vel, const Vector3& or_up, const Vector3& or_at) const
 {
 	m_impl->set_listener(pos, vel, or_up, or_at);
 }
@@ -230,7 +230,7 @@ void SoundRenderer::set_sound_max_distance(SoundId id, const float max_distance)
 }
 
 //-----------------------------------------------------------------------------
-void SoundRenderer::set_sound_position(SoundId id, const Vec3& pos)
+void SoundRenderer::set_sound_position(SoundId id, const Vector3& pos)
 {
 	CE_ASSERT(m_sounds_id_table.has(id), "Sound does not exists");
 
@@ -238,7 +238,7 @@ void SoundRenderer::set_sound_position(SoundId id, const Vec3& pos)
 }
 
 //-----------------------------------------------------------------------------
-void SoundRenderer::set_sound_velocity(SoundId id, const Vec3& vel)
+void SoundRenderer::set_sound_velocity(SoundId id, const Vector3& vel)
 {
 	CE_ASSERT(m_sounds_id_table.has(id), "Sound does not exists");
 
@@ -246,7 +246,7 @@ void SoundRenderer::set_sound_velocity(SoundId id, const Vec3& vel)
 }
 
 //-----------------------------------------------------------------------------
-void SoundRenderer::set_sound_direction(SoundId id, const Vec3& dir)
+void SoundRenderer::set_sound_direction(SoundId id, const Vector3& dir)
 {
 	CE_ASSERT(m_sounds_id_table.has(id), "Sound does not exists");
 
@@ -294,7 +294,7 @@ float SoundRenderer::sound_max_distance(SoundId id) const
 }
 
 //-----------------------------------------------------------------------------
-Vec3 SoundRenderer::sound_position(SoundId id) const
+Vector3 SoundRenderer::sound_position(SoundId id) const
 {
 	CE_ASSERT(m_sounds_id_table.has(id), "Sound does not exists");
 
@@ -302,7 +302,7 @@ Vec3 SoundRenderer::sound_position(SoundId id) const
 }
 
 //-----------------------------------------------------------------------------
-Vec3 SoundRenderer::sound_velocity(SoundId id) const
+Vector3 SoundRenderer::sound_velocity(SoundId id) const
 {
 	CE_ASSERT(m_sounds_id_table.has(id), "Sound does not exists");
 
@@ -310,7 +310,7 @@ Vec3 SoundRenderer::sound_velocity(SoundId id) const
 }
 
 //-----------------------------------------------------------------------------
-Vec3 SoundRenderer::sound_direction(SoundId id) const
+Vector3 SoundRenderer::sound_direction(SoundId id) const
 {
 	CE_ASSERT(m_sounds_id_table.has(id), "Sound does not exists");
 

+ 10 - 10
engine/audio/al/ALRenderer.h

@@ -31,7 +31,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "SoundResource.h"
 #include "OggDecoder.h"
-#include "Vec3.h"
+#include "Vector3.h"
 #include "Log.h"
 
 namespace crown
@@ -209,19 +209,19 @@ public:
 	}
 
 	//-----------------------------------------------------------------------------
-	void set_position(const Vec3& pos)
+	void set_position(const Vector3& pos)
 	{
 		AL_CHECK(alSource3f(m_id, AL_POSITION, pos.x, pos.y, pos.z));
 	}
 
 	//-----------------------------------------------------------------------------
-	void set_velocity(const Vec3& vel)
+	void set_velocity(const Vector3& vel)
 	{
 		AL_CHECK(alSource3f(m_id, AL_VELOCITY, vel.x, vel.y, vel.z));
 	}
 
 	//-----------------------------------------------------------------------------
-	void set_direction(const Vec3& dir)
+	void set_direction(const Vector3& dir)
 	{
 		AL_CHECK(alSource3f(m_id, AL_DIRECTION, dir.x, dir.y, dir.z));
 	}
@@ -265,12 +265,12 @@ public:
 	}
 
 	//-----------------------------------------------------------------------------
-	Vec3 position() const
+	Vector3 position() const
 	{
 		ALfloat tmp[3];
 		alGetSourcefv(m_id, AL_POSITION, tmp);
 
-		Vec3 pos;
+		Vector3 pos;
 		pos.x = tmp[0];
 		pos.y = tmp[1];
 		pos.z = tmp[2];
@@ -279,12 +279,12 @@ public:
 	}
 
 	//-----------------------------------------------------------------------------
-	Vec3 velocity() const
+	Vector3 velocity() const
 	{
 		ALfloat tmp[3];
 		alGetSourcefv(m_id, AL_VELOCITY, tmp);
 
-		Vec3 vel;
+		Vector3 vel;
 		vel.x = tmp[0];
 		vel.y = tmp[1];
 		vel.z = tmp[2];
@@ -293,12 +293,12 @@ public:
 	}
 
 	//-----------------------------------------------------------------------------
-	Vec3 direction() const
+	Vector3 direction() const
 	{
 		ALfloat tmp[3];
 		alGetSourcefv(m_id, AL_DIRECTION, tmp);
 
-		Vec3 dir;
+		Vector3 dir;
 		dir.x = tmp[0];
 		dir.y = tmp[1];
 		dir.z = tmp[2];

+ 11 - 11
engine/audio/sles/SLESRenderer.cpp

@@ -32,7 +32,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Assert.h"
 #include "SoundRenderer.h"
 #include "SLESRenderer.h"
-#include "Vec3.h"
+#include "Vector3.h"
 
 namespace crown
 {
@@ -227,7 +227,7 @@ bool SoundRenderer::sound_playing(SoundId id)
 }
 
 //-----------------------------------------------------------------------------
-void SoundRenderer::set_listener(const Vec3& /*pos*/, const Vec3& /*vel*/, const Vec3& /*or_up*/, const Vec3& /*or_at*/) const
+void SoundRenderer::set_listener(const Vector3& /*pos*/, const Vector3& /*vel*/, const Vector3& /*or_up*/, const Vector3& /*or_at*/) const
 {
 	Log::w("Stub");
 }
@@ -245,19 +245,19 @@ void SoundRenderer::set_sound_max_distance(SoundId /*id*/,  const float /*max_di
 }
 
 //-----------------------------------------------------------------------------
-void SoundRenderer::set_sound_position(SoundId /*id*/, const Vec3& /*pos*/)
+void SoundRenderer::set_sound_position(SoundId /*id*/, const Vector3& /*pos*/)
 {
 	Log::w("Stub");
 }
 
 //-----------------------------------------------------------------------------
-void SoundRenderer::set_sound_velocity(SoundId /*id*/, const Vec3& /*vel*/)
+void SoundRenderer::set_sound_velocity(SoundId /*id*/, const Vector3& /*vel*/)
 {
 	Log::w("Stub");
 }
 
 //-----------------------------------------------------------------------------
-void SoundRenderer::set_sound_direction(SoundId /*id*/, const Vec3& /*dir*/)
+void SoundRenderer::set_sound_direction(SoundId /*id*/, const Vector3& /*dir*/)
 {
 	Log::w("Stub");
 }
@@ -297,27 +297,27 @@ float SoundRenderer::sound_max_distance(SoundId /*id*/) const
 }
 
 //-----------------------------------------------------------------------------
-Vec3 SoundRenderer::sound_position(SoundId /*id*/) const
+Vector3 SoundRenderer::sound_position(SoundId /*id*/) const
 {
 	Log::w("Stub");
 
-	return Vec3::ZERO;
+	return Vector3::ZERO;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 SoundRenderer::sound_velocity(SoundId /*id*/) const
+Vector3 SoundRenderer::sound_velocity(SoundId /*id*/) const
 {
 	Log::w("Stub");
 
-	return Vec3::ZERO;
+	return Vector3::ZERO;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 SoundRenderer::sound_direction(SoundId /*id*/) const
+Vector3 SoundRenderer::sound_direction(SoundId /*id*/) const
 {
 	Log::w("Stub");
 
-	return Vec3::ZERO;
+	return Vector3::ZERO;
 }
 
 //-----------------------------------------------------------------------------

+ 1 - 1
engine/audio/sles/SLESRenderer.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "SoundResource.h"
 #include "OggDecoder.h"
-#include "Vec3.h"
+#include "Vector3.h"
 #include "Log.h"
 
 namespace crown

+ 3 - 3
engine/compilers/mesh/MeshCompiler.cpp

@@ -117,18 +117,18 @@ size_t MeshCompiler::compile_impl(Filesystem& fs, const char* resource_path)
 		MeshVertex v;
 
 		uint16_t p_idx = position_index[i] * 3;
-		v.position = Vec3(position_array[p_idx], position_array[p_idx + 1], position_array[p_idx + 2]);
+		v.position = Vector3(position_array[p_idx], position_array[p_idx + 1], position_array[p_idx + 2]);
 
 		if (m_has_normal)
 		{
 			uint16_t n_idx = normal_index[i] * 3;
-			v.normal = Vec3(normal_array[n_idx], normal_array[n_idx + 1], normal_array[n_idx + 2]);
+			v.normal = Vector3(normal_array[n_idx], normal_array[n_idx + 1], normal_array[n_idx + 2]);
 		}
 
 		if (m_has_texcoord)
 		{
 			uint16_t t_idx = texcoord_index[i] * 2;
-			v.texcoord = Vec2(texcoord_array[t_idx], texcoord_array[t_idx + 1]);
+			v.texcoord = Vector2(texcoord_array[t_idx], texcoord_array[t_idx + 1]);
 		}
 
 

+ 5 - 5
engine/compilers/mesh/MeshCompiler.h

@@ -28,8 +28,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Compiler.h"
 #include "MeshResource.h"
-#include "Vec3.h"
-#include "Vec2.h"
+#include "Vector3.h"
+#include "Vector2.h"
 #include "List.h"
 
 namespace crown
@@ -37,9 +37,9 @@ namespace crown
 
 struct MeshVertex
 {
-	Vec3 position;
-	Vec3 normal;
-	Vec2 texcoord;
+	Vector3 position;
+	Vector3 normal;
+	Vector2 texcoord;
 
 	bool operator==(const MeshVertex& other)
 	{

+ 36 - 36
engine/core/bv/Box.h

@@ -28,8 +28,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Assert.h"
 #include "Types.h"
-#include "Mat4.h"
-#include "Vec3.h"
+#include "Matrix4x4.h"
+#include "Vector3.h"
 #include "Sphere.h"
 
 namespace crown
@@ -46,35 +46,35 @@ public:
 					Box();
 
 	/// Constructs from @a min and @a max.
-					Box(const Vec3& min, const Vec3& max);			
+					Box(const Vector3& min, const Vector3& max);			
 					Box(const Box& box);
 
-	const Vec3&		min() const;
-	const Vec3&		max() const;
-	void			set_min(const Vec3& min);
-	void			set_max(const Vec3& max);
+	const Vector3&		min() const;
+	const Vector3&		max() const;
+	void			set_min(const Vector3& min);
+	void			set_max(const Vector3& max);
 
-	Vec3			center() const;
+	Vector3			center() const;
 	float			radius() const;
 	float			volume() const;
 
 	/// Adds @a count @a points expanding if necessary.
-	void			add_points(const Vec3* points, uint32_t count);
+	void			add_points(const Vector3* points, uint32_t count);
 
 	/// Adds @a count @a boxes expanding if necessay.
 	void			add_boxes(const Box* boxes, uint32_t count);
 
 	/// Returns whether point @a p is contained in the box.
-	bool			contains_point(const Vec3& p) const;
+	bool			contains_point(const Vector3& p) const;
 
 	/// Returns the @a index -th vertex of the box.
-	Vec3			vertex(uint32_t index) const;		
+	Vector3			vertex(uint32_t index) const;		
 
 	/// Returns the box trasformed according to @a mat matrix into @a result.
-	void			transformed(const Mat4& mat, Box& result) const;	
+	void			transformed(const Matrix4x4& mat, Box& result) const;	
 
 	/// Returns the eight vertices of the box.
-	void			to_vertices(Vec3 v[8]) const;	
+	void			to_vertices(Vector3 v[8]) const;	
 
 	/// Returns as a sphere.						
 	Sphere			to_sphere() const;										
@@ -84,8 +84,8 @@ public:
 
 private:
 
-	Vec3			m_min;
-	Vec3			m_max;
+	Vector3			m_min;
+	Vector3			m_max;
 };
 
 //-----------------------------------------------------------------------------
@@ -99,40 +99,40 @@ inline Box::Box(const Box& box) : m_min(box.m_min), m_max(box.m_max)
 }
 
 //-----------------------------------------------------------------------------
-inline Box::Box(const Vec3& min, const Vec3& max) : m_min(min), m_max(max)
+inline Box::Box(const Vector3& min, const Vector3& max) : m_min(min), m_max(max)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec3& Box::min() const
+inline const Vector3& Box::min() const
 {
 	return m_min;
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::set_min(const Vec3& min)
+inline void Box::set_min(const Vector3& min)
 {
 	m_min = min;
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec3& Box::max() const
+inline const Vector3& Box::max() const
 {
 	return m_max;
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::set_max(const Vec3& max)
+inline void Box::set_max(const Vector3& max)
 {
 	m_max = max;
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::add_points(const Vec3* points, uint32_t count)
+inline void Box::add_points(const Vector3* points, uint32_t count)
 {
 	for (uint32_t i = 0; i < count; i++)
 	{
-		const Vec3& p = points[i];
+		const Vector3& p = points[i];
 
 		if (p.x < m_min.x)
 		{
@@ -206,14 +206,14 @@ inline void Box::add_boxes(const Box* boxes, uint32_t count)
 }
 
 //-----------------------------------------------------------------------------
-inline bool Box::contains_point(const Vec3& p) const
+inline bool Box::contains_point(const Vector3& p) const
 {
 	return (p.x > m_min.x && p.y > m_min.y && p.z > m_min.z &&
 		p.x < m_max.x && p.y < m_max.y && p.z < m_max.z);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Box::center() const
+inline Vector3 Box::center() const
 {
 	return (m_min + m_max) * 0.5;
 }
@@ -225,7 +225,7 @@ inline float Box::radius() const
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::to_vertices(Vec3 v[8]) const
+inline void Box::to_vertices(Vector3 v[8]) const
 {
 	// 7 ---- 6
 	// |      |
@@ -270,35 +270,35 @@ inline void Box::to_vertices(Vec3 v[8]) const
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Box::vertex(uint32_t index) const
+inline Vector3 Box::vertex(uint32_t index) const
 {
 	CE_ASSERT(index < 8, "Index must be < 8");
 
 	switch (index)
 	{
 		case 0:
-			return Vec3(m_min.x, m_min.y, m_min.z);
+			return Vector3(m_min.x, m_min.y, m_min.z);
 		case 1:
-			return Vec3(m_max.x, m_min.y, m_min.z);
+			return Vector3(m_max.x, m_min.y, m_min.z);
 		case 2:
-			return Vec3(m_max.x, m_min.y, m_max.z);
+			return Vector3(m_max.x, m_min.y, m_max.z);
 		case 3:
-			return Vec3(m_min.x, m_min.y, m_max.z);
+			return Vector3(m_min.x, m_min.y, m_max.z);
 		case 4:
-			return Vec3(m_min.x, m_max.y, m_min.z);
+			return Vector3(m_min.x, m_max.y, m_min.z);
 		case 5:
-			return Vec3(m_max.x, m_max.y, m_min.z);
+			return Vector3(m_max.x, m_max.y, m_min.z);
 		case 6:
-			return Vec3(m_max.x, m_max.y, m_max.z);
+			return Vector3(m_max.x, m_max.y, m_max.z);
 		case 7:
-			return Vec3(m_min.x, m_max.y, m_max.z);
+			return Vector3(m_min.x, m_max.y, m_max.z);
 	}
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::transformed(const Mat4& mat, Box& result) const
+inline void Box::transformed(const Matrix4x4& mat, Box& result) const
 {
-	Vec3 vertices[8];
+	Vector3 vertices[8];
 
 	to_vertices(vertices);
 

+ 8 - 8
engine/core/bv/Circle.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "Vec2.h"
+#include "Vector2.h"
 #include "MathUtils.h"
 
 namespace crown
@@ -46,12 +46,12 @@ public:
 					Circle();
 					
 	/// Constructs from @a center and @a radius.
-					Circle(const Vec2& center, float radius);	
+					Circle(const Vector2& center, float radius);	
 					Circle(const Circle& circle);				
 
-	const Vec2&		center() const;							
+	const Vector2&		center() const;							
 	float			radius() const;	
-	void			set_center(const Vec2& center);			
+	void			set_center(const Vector2& center);			
 	void			set_radius(float radius);				
 
 	float			area() const;						
@@ -61,7 +61,7 @@ public:
 
 private:
 
-	Vec2			m_center;
+	Vector2			m_center;
 	float			m_radius;
 };
 
@@ -71,7 +71,7 @@ inline Circle::Circle()
 }
 
 //-----------------------------------------------------------------------------
-inline Circle::Circle(const Vec2& center, float radius) : m_center(center), m_radius(radius)
+inline Circle::Circle(const Vector2& center, float radius) : m_center(center), m_radius(radius)
 {
 }
 
@@ -81,7 +81,7 @@ inline Circle::Circle(const Circle& circle) : m_center(circle.m_center), m_radiu
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec2& Circle::center() const
+inline const Vector2& Circle::center() const
 {
 	return m_center;
 }
@@ -93,7 +93,7 @@ inline float Circle::radius() const
 }
 
 //-----------------------------------------------------------------------------
-inline void Circle::set_center(const Vec2& center)
+inline void Circle::set_center(const Vector2& center)
 {
 	m_center = center;
 }

+ 6 - 6
engine/core/bv/Frustum.cpp

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Frustum.h"
 #include "Types.h"
 #include "Intersection.h"
-#include "Mat4.h"
+#include "Matrix4x4.h"
 
 namespace crown
 {
@@ -49,7 +49,7 @@ Frustum::Frustum(const Frustum& frustum)
 }
 
 //-----------------------------------------------------------------------------
-bool Frustum::contains_point(const Vec3& point) const
+bool Frustum::contains_point(const Vector3& point) const
 {
 	if (m_planes[FP_LEFT].distance_to_point(point) < 0.0) return false;
 	if (m_planes[FP_RIGHT].distance_to_point(point) < 0.0) return false;
@@ -62,7 +62,7 @@ bool Frustum::contains_point(const Vec3& point) const
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Frustum::vertex(uint32_t index) const
+Vector3 Frustum::vertex(uint32_t index) const
 {
 	CE_ASSERT(index < 8, "Index must be < 8");
 
@@ -75,7 +75,7 @@ Vec3 Frustum::vertex(uint32_t index) const
 	// 6 = Far top right
 	// 7 = Far top left
 
-	Vec3 ip;
+	Vector3 ip;
 
 	switch (index)
 	{
@@ -103,7 +103,7 @@ Vec3 Frustum::vertex(uint32_t index) const
 }
 
 //-----------------------------------------------------------------------------
-void Frustum::from_matrix(const Mat4& m)
+void Frustum::from_matrix(const Matrix4x4& m)
 {
 	// Left plane
 	m_planes[FP_LEFT].n.x		= m.m[3] + m.m[0];
@@ -155,7 +155,7 @@ Box Frustum::to_box() const
 	Box tmp;
 	tmp.zero();
 
-	Vec3 vertices[8];
+	Vector3 vertices[8];
 	vertices[0] = vertex(0);
 	vertices[1] = vertex(1);
 	vertices[2] = vertex(2);

+ 5 - 5
engine/core/bv/Frustum.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Box.h"
-#include "Vec3.h"
+#include "Vector3.h"
 #include "Plane.h"
 
 namespace crown
@@ -44,7 +44,7 @@ enum FrustumPlane
 	FP_FAR		= 5
 };
 
-class Mat4;
+class Matrix4x4;
 
 class Frustum
 {
@@ -55,13 +55,13 @@ public:
 				Frustum(const Frustum& frustum);
 
 	/// Returns whether @a point is contained into the frustum.
-	bool		contains_point(const Vec3& point) const;	
+	bool		contains_point(const Vector3& point) const;	
 
 	/// Returns one of the eight frustum's corners.
-	Vec3		vertex(uint32_t index) const;			
+	Vector3		vertex(uint32_t index) const;			
 
 	/// Builds the view frustum according to the matrix @a m.
-	void		from_matrix(const Mat4& m);				
+	void		from_matrix(const Matrix4x4& m);				
 
 	/// Returns a Box containing the frustum volume.
 	Box			to_box() const;							

+ 11 - 11
engine/core/bv/Rect.cpp

@@ -33,7 +33,7 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-bool Rect::contains_point(const Vec2& point) const
+bool Rect::contains_point(const Vector2& point) const
 {
 	return (point.x >= m_min.x && point.y >= m_min.y &&
 			point.x <= m_max.x && point.y <= m_max.y);
@@ -48,7 +48,7 @@ bool Rect::intersects_rect(const Rect& rect) const
 }
 
 //-----------------------------------------------------------------------------
-void Rect::set_from_center_and_dimensions(Vec2 center, float width, float height)
+void Rect::set_from_center_and_dimensions(Vector2 center, float width, float height)
 {
 	m_min.x = (float)(center.x - width  / 2.0);
 	m_min.y = (float)(center.y - height / 2.0);
@@ -57,7 +57,7 @@ void Rect::set_from_center_and_dimensions(Vec2 center, float width, float height
 }
 
 //-----------------------------------------------------------------------------
-void Rect::vertices(Vec2 v[4]) const
+void Rect::vertices(Vector2 v[4]) const
 {
 	// 3 ---- 2
 	// |      |
@@ -74,27 +74,27 @@ void Rect::vertices(Vec2 v[4]) const
 }
 
 //-----------------------------------------------------------------------------
-Vec2 Rect::vertex(uint32_t index) const
+Vector2 Rect::vertex(uint32_t index) const
 {
 	CE_ASSERT(index < 4, "Index must be < 4");
 
 	switch (index)
 	{
 		case 0:
-			return Vec2(m_min.x, m_min.y);
+			return Vector2(m_min.x, m_min.y);
 		case 1:
-			return Vec2(m_max.x, m_min.y);
+			return Vector2(m_max.x, m_min.y);
 		case 2:
-			return Vec2(m_max.x, m_max.y);
+			return Vector2(m_max.x, m_max.y);
 		case 3:
-			return Vec2(m_min.x, m_max.y);
+			return Vector2(m_min.x, m_max.y);
 	}
 
-	return Vec2::ZERO;
+	return Vector2::ZERO;
 }
 
 //-----------------------------------------------------------------------------
-Vec2 Rect::center() const
+Vector2 Rect::center() const
 {
 	return (m_min + m_max) * 0.5;
 }
@@ -112,7 +112,7 @@ float Rect::area() const
 }
 
 //-----------------------------------------------------------------------------
-Vec2 Rect::size() const
+Vector2 Rect::size() const
 {
 	return (m_max - m_min);
 }

+ 19 - 19
engine/core/bv/Rect.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "Vec2.h"
+#include "Vector2.h"
 
 namespace crown
 {
@@ -45,35 +45,35 @@ public:
 					Rect();		
 
 	/// Constructs from  @a min and @a max
-					Rect(const Vec2& min, const Vec2& max);		
+					Rect(const Vector2& min, const Vector2& max);		
 					Rect(const Rect& rect);	
 
-	const Vec2&		min() const;					
-	const Vec2&		max() const;					
-	void			set_min(const Vec2& min);				
-	void			set_max(const Vec2& max);			
+	const Vector2&		min() const;					
+	const Vector2&		max() const;					
+	void			set_min(const Vector2& min);				
+	void			set_max(const Vector2& max);			
 
-	Vec2			center() const;					
+	Vector2			center() const;					
 	float			radius() const;					
 	float			area() const;		
 
 	/// Returns the diagonal of the rect.
-	Vec2			size() const;						
+	Vector2			size() const;						
 
 	/// Returns whether @a point point is contained into the rect.
-	bool			contains_point(const Vec2& point) const;
+	bool			contains_point(const Vector2& point) const;
 
 	/// Returns whether the rect intersects @a r.
 	bool			intersects_rect(const Rect& rect) const;	
 
 	/// Sets the Rect from a @a center and a @a width - @a height
-	void			set_from_center_and_dimensions(Vec2 center, float width, float height);	
+	void			set_from_center_and_dimensions(Vector2 center, float width, float height);	
 
 	/// Returns the four vertices of the rect.
-	void			vertices(Vec2 v[4]) const;
+	void			vertices(Vector2 v[4]) const;
 
 	/// Returns the @a index -th vetex of the rect.
-	Vec2			vertex(uint32_t index) const;			
+	Vector2			vertex(uint32_t index) const;			
 
 	/// Returns the equivalent circle.
 	Circle			to_circle() const;
@@ -83,8 +83,8 @@ public:
 
 private:
 
-	Vec2			m_min;
-	Vec2			m_max;
+	Vector2			m_min;
+	Vector2			m_max;
 };
 
 //-----------------------------------------------------------------------------
@@ -93,7 +93,7 @@ inline Rect::Rect()
 }
 
 //-----------------------------------------------------------------------------
-inline Rect::Rect(const Vec2& min, const Vec2& max) : m_min(min), m_max(max)
+inline Rect::Rect(const Vector2& min, const Vector2& max) : m_min(min), m_max(max)
 {
 }
 
@@ -103,25 +103,25 @@ inline Rect::Rect(const Rect& rect) : m_min(rect.m_min), m_max(rect.m_max)
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec2& Rect::min() const
+inline const Vector2& Rect::min() const
 {
 	return m_min;
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec2& Rect::max() const
+inline const Vector2& Rect::max() const
 {
 	return m_max;
 }
 
 //-----------------------------------------------------------------------------
-inline void Rect::set_min(const Vec2& min)
+inline void Rect::set_min(const Vector2& min)
 {
 	m_min = min;
 }
 
 //-----------------------------------------------------------------------------
-inline void Rect::set_max(const Vec2& max)
+inline void Rect::set_max(const Vector2& max)
 {
 	m_max = max;
 }

+ 13 - 13
engine/core/bv/Sphere.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "MathUtils.h"
-#include "Vec3.h"
+#include "Vector3.h"
 
 namespace crown
 {
@@ -45,28 +45,28 @@ public:
 					Sphere();
 
 	/// Constructs from @a center and @a radius.
-					Sphere(const Vec3& center, float radius);
+					Sphere(const Vector3& center, float radius);
 					Sphere(const Sphere& a);
 
-	const Vec3&		center() const;		
+	const Vector3&		center() const;		
 	float			radius() const;	
 	float			volume() const;	
 
-	void			set_center(const Vec3& center);
+	void			set_center(const Vector3& center);
 	void			set_radius(float radius);
 
 	/// Adds @a count @a points to the sphere expanding if necessary.
-	void			add_points(const Vec3* points, uint32_t count);	
+	void			add_points(const Vector3* points, uint32_t count);	
 
 	/// Adds @a count @a spheres expanding if necessary.
 	void			add_spheres(const Sphere* spheres, uint32_t count);	
 
 	/// Returns whether point @a p is contained into the sphere.
-	bool			contains_point(const Vec3& p) const;		
+	bool			contains_point(const Vector3& p) const;		
 
 private:
 
-	Vec3			m_center;
+	Vector3			m_center;
 	float			m_radius;
 };
 
@@ -76,7 +76,7 @@ inline Sphere::Sphere()
 }
 
 //-----------------------------------------------------------------------------
-inline Sphere::Sphere(const Vec3& center, float radius) : m_center(center), m_radius(radius)
+inline Sphere::Sphere(const Vector3& center, float radius) : m_center(center), m_radius(radius)
 {
 }
 
@@ -86,7 +86,7 @@ inline Sphere::Sphere(const Sphere& a) : m_center(a.m_center), m_radius(a.m_radi
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec3& Sphere::center() const
+inline const Vector3& Sphere::center() const
 {
 	return m_center;
 }
@@ -104,7 +104,7 @@ inline float Sphere::volume() const
 }
 
 //-----------------------------------------------------------------------------
-inline void Sphere::set_center(const Vec3& center)
+inline void Sphere::set_center(const Vector3& center)
 {
 	m_center = center;
 }
@@ -116,11 +116,11 @@ inline void Sphere::set_radius(float radius)
 }
 
 //-----------------------------------------------------------------------------
-inline void Sphere::add_points(const Vec3* points, uint32_t count)
+inline void Sphere::add_points(const Vector3* points, uint32_t count)
 {
 	for (uint32_t i = 0; i < count; i++)
 	{
-		const Vec3& p = points[i];
+		const Vector3& p = points[i];
 
 		float dist = (p - m_center).squared_length();
 
@@ -151,7 +151,7 @@ inline void Sphere::add_spheres(const Sphere* spheres, uint32_t count)
 }
 
 //-----------------------------------------------------------------------------
-inline bool Sphere::contains_point(const Vec3& p) const
+inline bool Sphere::contains_point(const Vector3& p) const
 {
 	float dist = (p - m_center).squared_length();
 	return (dist < m_radius * m_radius);

+ 48 - 48
engine/core/math/Intersection.h

@@ -82,29 +82,29 @@ class Intersection
 {
 public:
 
-	static bool test_ray_plane(const Ray& r, const Plane& p, float& distance, Vec3& inttersectionPoint_t);
-	static bool test_ray_sphere(const Ray& r, const Sphere& s, float& distance, Vec3& intersectionPoint);
-	static bool test_ray_box(const Ray& r, const Box& b, float& distance, Vec3& intersectionPoint);
-	static bool test_ray_triangle(const Ray& r, const Triangle& t, float& distance, Vec3& intersectionPoint);
+	static bool test_ray_plane(const Ray& r, const Plane& p, float& distance, Vector3& inttersectionPoint_t);
+	static bool test_ray_sphere(const Ray& r, const Sphere& s, float& distance, Vector3& intersectionPoint);
+	static bool test_ray_box(const Ray& r, const Box& b, float& distance, Vector3& intersectionPoint);
+	static bool test_ray_triangle(const Ray& r, const Triangle& t, float& distance, Vector3& intersectionPoint);
 
-	static bool test_plane_3(const Plane& p1, const Plane& p2, const Plane& p3, Vec3& ip);
+	static bool test_plane_3(const Plane& p1, const Plane& p2, const Plane& p3, Vector3& ip);
 
 	static bool test_static_sphere_plane(const Sphere& s, const Plane& p);
 	static bool test_static_sphere_sphere(const Sphere& a, const Sphere& b);
-	static bool test_dynamic_sphere_plane(const Sphere& s, const Vec3& d, const Plane& p, float& it, Vec3& intersectionPoint);
-	static bool test_dynamic_sphere_triangle(const Sphere& s, const Vec3& d, const Triangle& tri, float& it, Vec3& intersectionPoint);
-	static bool test_dynamic_sphere_sphere(const Sphere& s1, const Vec3& d1, const Sphere& s2, const Vec3& d2, float& it, Vec3& intersectionPoint);
+	static bool test_dynamic_sphere_plane(const Sphere& s, const Vector3& d, const Plane& p, float& it, Vector3& intersectionPoint);
+	static bool test_dynamic_sphere_triangle(const Sphere& s, const Vector3& d, const Triangle& tri, float& it, Vector3& intersectionPoint);
+	static bool test_dynamic_sphere_sphere(const Sphere& s1, const Vector3& d1, const Sphere& s2, const Vector3& d2, float& it, Vector3& intersectionPoint);
 
 	static bool test_static_box_box(const Box& b1, const Box& b2);
-	static bool test_dynamic_box_box(const Box& b1, const Vec3& v1, const Box& b2, const Vec3& v2, float& it);
+	static bool test_dynamic_box_box(const Box& b1, const Vector3& v1, const Box& b2, const Vector3& v2, float& it);
 
 	static bool test_frustum_sphere(const Frustum& f, const Sphere& s);
 	static bool test_frustum_box(const Frustum& f, const Box& box);
 
-	static bool test_circle_circle(const Circle& c1, const Circle& c2, Vec2& penetration);
-	static bool test_dynamic_circle_circle(const Circle& c1, const Vec2& d1, const Circle& c2, const Vec2& d2, float& it);
-	static bool test_rect_rect(const Rect& r1, const Rect& r2, Vec2& penetration);
-	static bool test_circle_rect(const Circle& c1, const Rect& r2, Vec2& penetration);
+	static bool test_circle_circle(const Circle& c1, const Circle& c2, Vector2& penetration);
+	static bool test_dynamic_circle_circle(const Circle& c1, const Vector2& d1, const Circle& c2, const Vector2& d2, float& it);
+	static bool test_rect_rect(const Rect& r1, const Rect& r2, Vector2& penetration);
+	static bool test_circle_rect(const Circle& c1, const Rect& r2, Vector2& penetration);
 
 private:
 
@@ -113,7 +113,7 @@ private:
 };
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_ray_plane(const Ray& r, const Plane& p, float& distance, Vec3& intersectionPoint)
+inline bool Intersection::test_ray_plane(const Ray& r, const Plane& p, float& distance, Vector3& intersectionPoint)
 {
 	float nd = r.direction().dot(p.n);
 	float orpn = r.origin().dot(p.n);
@@ -133,9 +133,9 @@ inline bool Intersection::test_ray_plane(const Ray& r, const Plane& p, float& di
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_ray_sphere(const Ray& r, const Sphere& s, float& distance, Vec3& intersectionPoint)
+inline bool Intersection::test_ray_sphere(const Ray& r, const Sphere& s, float& distance, Vector3& intersectionPoint)
 {
-	Vec3 v = s.center() - r.origin();
+	Vector3 v = s.center() - r.origin();
 	float b = v.dot(r.direction());
 	float det = (s.radius() * s.radius()) - v.dot(v) + (b * b);
 
@@ -151,7 +151,7 @@ inline bool Intersection::test_ray_sphere(const Ray& r, const Sphere& s, float&
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_ray_box(const Ray& r, const Box& b, float& /*distance*/, Vec3& /*intersectionPoint*/)
+inline bool Intersection::test_ray_box(const Ray& r, const Box& b, float& /*distance*/, Vector3& /*intersectionPoint*/)
 {
 	if (r.origin().x < b.min().x)
 	{
@@ -208,7 +208,7 @@ inline bool Intersection::test_ray_box(const Ray& r, const Box& b, float& /*dist
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_ray_triangle(const Ray& r, const Triangle& t, float& distance, Vec3& intersectionPoint)
+inline bool Intersection::test_ray_triangle(const Ray& r, const Triangle& t, float& distance, Vector3& intersectionPoint)
 {
 	if (Intersection::test_ray_plane(r, t.to_plane(), distance, intersectionPoint))
 	{
@@ -222,11 +222,11 @@ inline bool Intersection::test_ray_triangle(const Ray& r, const Triangle& t, flo
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_plane_3(const Plane& p1, const Plane& p2, const Plane& p3, Vec3& ip)
+inline bool Intersection::test_plane_3(const Plane& p1, const Plane& p2, const Plane& p3, Vector3& ip)
 {
-	const Vec3& n1 = p1.n;
-	const Vec3& n2 = p2.n;
-	const Vec3& n3 = p3.n;
+	const Vector3& n1 = p1.n;
+	const Vector3& n2 = p2.n;
+	const Vector3& n3 = p3.n;
 
 	float den = -n1.cross(n2).dot(n3);
 
@@ -235,7 +235,7 @@ inline bool Intersection::test_plane_3(const Plane& p1, const Plane& p2, const P
 		return false;
 	}
 
-	Vec3 res = p1.d * n2.cross(n3) + p2.d * n3.cross(n1) + p3.d * n1.cross(n2);
+	Vector3 res = p1.d * n2.cross(n3) + p2.d * n3.cross(n1) + p3.d * n1.cross(n2);
 	ip = res / den;
 
 	return true;
@@ -260,9 +260,9 @@ inline bool Intersection::test_static_sphere_sphere(const Sphere& a, const Spher
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_dynamic_sphere_plane(const Sphere& s, const Vec3& d, const Plane& p, float& it, Vec3& intersectionPoint)
+inline bool Intersection::test_dynamic_sphere_plane(const Sphere& s, const Vector3& d, const Plane& p, float& it, Vector3& intersectionPoint)
 {
-	const Vec3& sphereCenter = s.center();
+	const Vector3& sphereCenter = s.center();
 	const float sphereRadius = s.radius();
 
 	float t0;	// Time at which the sphere int32_tersects the plane remaining at the front side of the plane
@@ -308,7 +308,7 @@ inline bool Intersection::test_dynamic_sphere_plane(const Sphere& s, const Vec3&
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_dynamic_sphere_triangle(const Sphere& s, const Vec3& d, const Triangle& tri, float& it, Vec3& intersectionPoint)
+inline bool Intersection::test_dynamic_sphere_triangle(const Sphere& s, const Vector3& d, const Triangle& tri, float& it, Vector3& intersectionPoint)
 {
 	Plane triPlane = tri.to_plane();
 
@@ -370,8 +370,8 @@ inline bool Intersection::test_dynamic_sphere_triangle(const Sphere& s, const Ve
 	}
 
 	// Check for collisions against the edges
-	Vec3 edge;
-	Vec3 centerToVertex;
+	Vector3 edge;
+	Vector3 centerToVertex;
 	float edgeDotVelocity;
 	float edgeDotCenterToVertex;
 	float edgeSquaredLength;
@@ -458,17 +458,17 @@ inline bool Intersection::test_dynamic_sphere_triangle(const Sphere& s, const Ve
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_dynamic_sphere_sphere(const Sphere& s1, const Vec3& d1, const Sphere& s2, const Vec3& d2, float& it, Vec3& /*intersectionPoint*/)
+inline bool Intersection::test_dynamic_sphere_sphere(const Sphere& s1, const Vector3& d1, const Sphere& s2, const Vector3& d2, float& it, Vector3& /*intersectionPoint*/)
 {
 	// s1 == static sphere
 	// s2 == moving sphere
-	Vec3 d = d2 - d1;
+	Vector3 d = d2 - d1;
 	d.normalize();
 
-	const Vec3& cs = s1.center();
-	const Vec3& cm = s2.center();
+	const Vector3& cs = s1.center();
+	const Vector3& cm = s2.center();
 
-	Vec3 e = cs - cm;
+	Vector3 e = cs - cm;
 	float r = s1.radius() + s2.radius();
 
 	// If ||e|| < r, int32_tersection occurs at t = 0
@@ -523,16 +523,16 @@ inline bool Intersection::test_static_box_box(const Box& b1, const Box& b2)
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_dynamic_box_box(const Box& b1, const Vec3& v1, const Box& b2, const Vec3& v2, float& it)
+inline bool Intersection::test_dynamic_box_box(const Box& b1, const Vector3& v1, const Box& b2, const Vector3& v2, float& it)
 {
 	// b1 == static box
 	// b2 == moving box
-	Vec3 d = v2 - v1;
+	Vector3 d = v2 - v1;
 
 	// Start time of int32_tersection aint64_t each axis
-	Vec3 tEnterXYZ(0.0, 0.0, 0.0);
+	Vector3 tEnterXYZ(0.0, 0.0, 0.0);
 	// Stop time of int32_tersection aint64_t each axis
-	Vec3 tLeaveXYZ(1.0, 1.0, 1.0);
+	Vector3 tLeaveXYZ(1.0, 1.0, 1.0);
 
 	// If the resulting displacement equals zero, then fallback to static int32_tersection test
 	if (math::equals(d.x, (float)0.0))
@@ -653,9 +653,9 @@ inline bool Intersection::test_frustum_box(const Frustum& f, const Box& b)
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_circle_circle(const Circle& c1, const Circle& c2, Vec2& penetration)
+inline bool Intersection::test_circle_circle(const Circle& c1, const Circle& c2, Vector2& penetration)
 {
-	Vec2 distance = c1.center() - c2.center();
+	Vector2 distance = c1.center() - c2.center();
 	float distanceLen2 = distance.squared_length();
 	float radiusSum = c1.radius() + c2.radius();
 	if (distanceLen2 > radiusSum*radiusSum)
@@ -665,7 +665,7 @@ inline bool Intersection::test_circle_circle(const Circle& c1, const Circle& c2,
 
 	if (distanceLen2 < 0.001)
 	{
-		penetration = Vec2(c1.radius(), 0.0);
+		penetration = Vector2(c1.radius(), 0.0);
 	}
 	else
 	{
@@ -676,17 +676,17 @@ inline bool Intersection::test_circle_circle(const Circle& c1, const Circle& c2,
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_dynamic_circle_circle(const Circle& c1, const Vec2& d1, const Circle& c2, const Vec2& d2, float& it)
+inline bool Intersection::test_dynamic_circle_circle(const Circle& c1, const Vector2& d1, const Circle& c2, const Vector2& d2, float& it)
 {
 	// c1 == static circle
 	// c2 == moving circle
-	Vec2 d = d2 - d1;
+	Vector2 d = d2 - d1;
 	d.normalize();
 
-	const Vec2& cs = c1.center();
-	const Vec2& cm = c2.center();
+	const Vector2& cs = c1.center();
+	const Vector2& cm = c2.center();
 
-	Vec2 e = cs - cm;
+	Vector2 e = cs - cm;
 	float r = c1.radius() + c2.radius();
 
 	// If ||e|| < r, int32_tersection occurs at t = 0
@@ -720,7 +720,7 @@ inline bool Intersection::test_dynamic_circle_circle(const Circle& c1, const Vec
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_rect_rect(const Rect& r1, const Rect& r2, Vec2& penetration)
+inline bool Intersection::test_rect_rect(const Rect& r1, const Rect& r2, Vector2& penetration)
 {
 	//x
 	float min1MinusMax2 = r1.min().x - r2.max().x;
@@ -777,7 +777,7 @@ inline bool Intersection::test_rect_rect(const Rect& r1, const Rect& r2, Vec2& p
 }
 
 //-----------------------------------------------------------------------------
-inline bool Intersection::test_circle_rect(const Circle& c1, const Rect& r2, Vec2& penetration)
+inline bool Intersection::test_circle_rect(const Circle& c1, const Rect& r2, Vector2& penetration)
 {
 	bool circleIsAtRight;
 	if (c1.center().x > (r2.min().x + r2.max().x) / 2)
@@ -828,7 +828,7 @@ inline bool Intersection::test_circle_rect(const Circle& c1, const Rect& r2, Vec
 	//}
 	else
 	{
-		penetration += Vec2(c1.radius(), c1.radius());
+		penetration += Vector2(c1.radius(), c1.radius());
 		float len = math::sqrt(penetration.squared_length());
 		if (len > c1.radius())
 		{

+ 63 - 63
engine/core/math/Mat3.cpp → engine/core/math/Matrix3x3.cpp

@@ -25,25 +25,25 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "Assert.h"
-#include "Mat3.h"
+#include "Matrix3x3.h"
 #include "Types.h"
-#include "Mat4.h"
+#include "Matrix4x4.h"
 #include "MathUtils.h"
-#include "Quat.h"
-#include "Vec3.h"
+#include "Quaternion.h"
+#include "Vector3.h"
 
 namespace crown
 {
 
-const Mat3 Mat3::IDENTITY = Mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
+const Matrix3x3 Matrix3x3::IDENTITY = Matrix3x3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
 
 //-----------------------------------------------------------------------------
-Mat3::Mat3()
+Matrix3x3::Matrix3x3()
 {
 }
 
 //-----------------------------------------------------------------------------
-Mat3::Mat3(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2,
+Matrix3x3::Matrix3x3(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2,
 	float r1c3, float r2c3, float r3c3)
 {
 	m[0] = r1c1;
@@ -58,7 +58,7 @@ Mat3::Mat3(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c
 }
 
 //-----------------------------------------------------------------------------
-Mat3::Mat3(const float v[9])
+Matrix3x3::Matrix3x3(const float v[9])
 {
 	m[0] = v[0];
 	m[1] = v[1];
@@ -72,7 +72,7 @@ Mat3::Mat3(const float v[9])
 }
 
 //-----------------------------------------------------------------------------
-Mat3::Mat3(const Mat3& a)
+Matrix3x3::Matrix3x3(const Matrix3x3& a)
 {
 	m[0] = a.m[0];
 	m[1] = a.m[1];
@@ -86,7 +86,7 @@ Mat3::Mat3(const Mat3& a)
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::operator=(const Mat3& a)
+Matrix3x3& Matrix3x3::operator=(const Matrix3x3& a)
 {
 	m[0] = a.m[0];
 	m[1] = a.m[1];
@@ -102,7 +102,7 @@ Mat3& Mat3::operator=(const Mat3& a)
 }
 
 //-----------------------------------------------------------------------------
-float Mat3::operator[](uint32_t i) const
+float Matrix3x3::operator[](uint32_t i) const
 {
 	CE_ASSERT(i < 9, "Index must be < 9");
 
@@ -110,7 +110,7 @@ float Mat3::operator[](uint32_t i) const
 }
 
 //-----------------------------------------------------------------------------
-float& Mat3::operator[](uint32_t i)
+float& Matrix3x3::operator[](uint32_t i)
 {
 	CE_ASSERT(i < 9, "Index must be < 9");
 
@@ -118,7 +118,7 @@ float& Mat3::operator[](uint32_t i)
 }
 
 //-----------------------------------------------------------------------------
-float Mat3::operator()(uint32_t row, uint32_t column) const
+float Matrix3x3::operator()(uint32_t row, uint32_t column) const
 {
 	CE_ASSERT(row < 3 && column < 3, "Row and column must be < 3");
 
@@ -126,9 +126,9 @@ float Mat3::operator()(uint32_t row, uint32_t column) const
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Mat3::operator+(const Mat3& a) const
+Matrix3x3 Matrix3x3::operator+(const Matrix3x3& a) const
 {
-	Mat3 tmp;
+	Matrix3x3 tmp;
 
 	tmp.m[0] = m[0] + a.m[0];
 	tmp.m[1] = m[1] + a.m[1];
@@ -144,7 +144,7 @@ Mat3 Mat3::operator+(const Mat3& a) const
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::operator+=(const Mat3& a)
+Matrix3x3& Matrix3x3::operator+=(const Matrix3x3& a)
 {
 	m[0] = m[0] + a.m[0];
 	m[1] = m[1] + a.m[1];
@@ -160,9 +160,9 @@ Mat3& Mat3::operator+=(const Mat3& a)
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Mat3::operator-(const Mat3& a) const
+Matrix3x3 Matrix3x3::operator-(const Matrix3x3& a) const
 {
-	Mat3 tmp;
+	Matrix3x3 tmp;
 
 	tmp.m[0] = m[0] - a.m[0];
 	tmp.m[1] = m[1] - a.m[1];
@@ -178,7 +178,7 @@ Mat3 Mat3::operator-(const Mat3& a) const
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::operator-=(const Mat3& a)
+Matrix3x3& Matrix3x3::operator-=(const Matrix3x3& a)
 {
 	m[0] = m[0] - a.m[0];
 	m[1] = m[1] - a.m[1];
@@ -194,9 +194,9 @@ Mat3& Mat3::operator-=(const Mat3& a)
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Mat3::operator*(float k) const
+Matrix3x3 Matrix3x3::operator*(float k) const
 {
-	Mat3 tmp;
+	Matrix3x3 tmp;
 
 	tmp.m[0] = m[0] * k;
 	tmp.m[1] = m[1] * k;
@@ -212,7 +212,7 @@ Mat3 Mat3::operator*(float k) const
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::operator*=(float k)
+Matrix3x3& Matrix3x3::operator*=(float k)
 {
 	m[0] *= k;
 	m[1] *= k;
@@ -228,9 +228,9 @@ Mat3& Mat3::operator*=(float k)
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Mat3::operator/(float k) const
+Matrix3x3 Matrix3x3::operator/(float k) const
 {
-	Mat3 tmp;
+	Matrix3x3 tmp;
 
 	k = (float)1.0 / k;
 
@@ -248,7 +248,7 @@ Mat3 Mat3::operator/(float k) const
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::operator/=(float k)
+Matrix3x3& Matrix3x3::operator/=(float k)
 {
 	k = (float)1.0 / k;
 
@@ -266,9 +266,9 @@ Mat3& Mat3::operator/=(float k)
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat3::operator*(const Vec3& v) const
+Vector3 Matrix3x3::operator*(const Vector3& v) const
 {
-	Vec3 tmp;
+	Vector3 tmp;
 
 	tmp.x = m[0] * v.x + m[3] * v.y + m[6] * v.z;
 	tmp.y = m[1] * v.x + m[4] * v.y + m[7] * v.z;
@@ -278,9 +278,9 @@ Vec3 Mat3::operator*(const Vec3& v) const
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Mat3::operator*(const Mat3& a) const
+Matrix3x3 Matrix3x3::operator*(const Matrix3x3& a) const
 {
-	Mat3 tmp;
+	Matrix3x3 tmp;
 
 	tmp.m[0] = m[0] * a.m[0] + m[3] * a.m[1] + m[6] * a.m[2];
 	tmp.m[1] = m[1] * a.m[0] + m[4] * a.m[1] + m[7] * a.m[2];
@@ -298,9 +298,9 @@ Mat3 Mat3::operator*(const Mat3& a) const
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::operator*=(const Mat3& a)
+Matrix3x3& Matrix3x3::operator*=(const Matrix3x3& a)
 {
-	Mat3 tmp;
+	Matrix3x3 tmp;
 
 	tmp.m[0] = m[0] * a.m[0] + m[3] * a.m[1] + m[6] * a.m[2];
 	tmp.m[1] = m[1] * a.m[0] + m[4] * a.m[1] + m[7] * a.m[2];
@@ -320,13 +320,13 @@ Mat3& Mat3::operator*=(const Mat3& a)
 }
 
 //-----------------------------------------------------------------------------
-Mat3 operator*(float k, const Mat3& a)
+Matrix3x3 operator*(float k, const Matrix3x3& a)
 {
 	return a * k;
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::build_rotation_x(float radians)
+void Matrix3x3::build_rotation_x(float radians)
 {
 	m[0] = 1.0;
 	m[1] = 0.0;
@@ -340,7 +340,7 @@ void Mat3::build_rotation_x(float radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::build_rotation_y(float radians)
+void Matrix3x3::build_rotation_y(float radians)
 {
 	m[0] = math::cos(radians);
 	m[1] = 0.0;
@@ -354,7 +354,7 @@ void Mat3::build_rotation_y(float radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::build_rotation_z(float radians)
+void Matrix3x3::build_rotation_z(float radians)
 {
 	m[0] = math::cos(radians);
 	m[1] = math::sin(radians);
@@ -368,7 +368,7 @@ void Mat3::build_rotation_z(float radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::build_rotation(const Vec3& n, float radians)
+void Matrix3x3::build_rotation(const Vector3& n, float radians)
 {
 	float a = (float)1.0 - math::cos(radians);
 	float sin_a = math::sin(radians);
@@ -386,7 +386,7 @@ void Mat3::build_rotation(const Vec3& n, float radians)
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::transpose()
+Matrix3x3& Matrix3x3::transpose()
 {
 	float tmp;
 
@@ -406,9 +406,9 @@ Mat3& Mat3::transpose()
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Mat3::get_transposed() const
+Matrix3x3 Matrix3x3::get_transposed() const
 {
-	Mat3 tmp;
+	Matrix3x3 tmp;
 
 	tmp.m[0] = m[0];
 	tmp.m[1] = m[3];
@@ -424,7 +424,7 @@ Mat3 Mat3::get_transposed() const
 }
 
 //-----------------------------------------------------------------------------
-float Mat3::get_determinant() const
+float Matrix3x3::get_determinant() const
 {
 	float det;
 
@@ -436,9 +436,9 @@ float Mat3::get_determinant() const
 }
 
 //-----------------------------------------------------------------------------
-Mat3& Mat3::invert()
+Matrix3x3& Matrix3x3::invert()
 {
-	Mat3 mat;
+	Matrix3x3 mat;
 	float det;
 
 	mat.m[0] = (m[4] * m[8] - m[7] * m[5]);
@@ -469,40 +469,40 @@ Mat3& Mat3::invert()
 }
 
 //-----------------------------------------------------------------------------
-inline Mat3 Mat3::get_inverted() const
+inline Matrix3x3 Matrix3x3::get_inverted() const
 {
-	Mat3 tmp(*this);
+	Matrix3x3 tmp(*this);
 
 	return tmp.invert();
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::load_identity()
+void Matrix3x3::load_identity()
 {
 	m[0] = m[4] = m[8] = 1.0;
 	m[1] = m[2] = m[3] = m[5] = m[6] = m[7] = 0.0;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat3::x() const
+Vector3 Matrix3x3::x() const
 {
-	return Vec3(m[0], m[1], m[2]);
+	return Vector3(m[0], m[1], m[2]);
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat3::y() const
+Vector3 Matrix3x3::y() const
 {
-	return Vec3(m[3], m[4], m[5]);
+	return Vector3(m[3], m[4], m[5]);
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat3::z() const
+Vector3 Matrix3x3::z() const
 {
-	return Vec3(m[6], m[7], m[8]);
+	return Vector3(m[6], m[7], m[8]);
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::set_x(const Vec3& x)
+void Matrix3x3::set_x(const Vector3& x)
 {
 	m[0] = x.x;
 	m[1] = x.y;
@@ -510,7 +510,7 @@ void Mat3::set_x(const Vec3& x)
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::set_y(const Vec3& y)
+void Matrix3x3::set_y(const Vector3& y)
 {
 	m[3] = y.x;
 	m[4] = y.y;
@@ -518,7 +518,7 @@ void Mat3::set_y(const Vec3& y)
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::set_z(const Vec3& z)
+void Matrix3x3::set_z(const Vector3& z)
 {
 	m[6] = z.x;
 	m[7] = z.y;
@@ -526,9 +526,9 @@ void Mat3::set_z(const Vec3& z)
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat3::get_scale() const
+Vector3 Matrix3x3::get_scale() const
 {
-	Vec3 tmp;
+	Vector3 tmp;
 
 	tmp.x = m[0];
 	tmp.y = m[4];
@@ -538,7 +538,7 @@ Vec3 Mat3::get_scale() const
 }
 
 //-----------------------------------------------------------------------------
-void Mat3::set_scale(const Vec3& scale)
+void Matrix3x3::set_scale(const Vector3& scale)
 {
 	m[0] = scale.x;
 	m[4] = scale.y;
@@ -546,21 +546,21 @@ void Mat3::set_scale(const Vec3& scale)
 }
 
 //-----------------------------------------------------------------------------
-float* Mat3::to_float_ptr()
+float* Matrix3x3::to_float_ptr()
 {
 	return &m[0];
 }
 
 //-----------------------------------------------------------------------------
-const float* Mat3::to_float_ptr() const
+const float* Matrix3x3::to_float_ptr() const
 {
 	return &m[0];
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mat3::to_mat4() const
+Matrix4x4 Matrix3x3::to_mat4() const
 {
-	Mat4 tmp;
+	Matrix4x4 tmp;
 
 	tmp.m[0] = m[0];
 	tmp.m[1] = m[1];
@@ -583,9 +583,9 @@ Mat4 Mat3::to_mat4() const
 }
 
 //-----------------------------------------------------------------------------
-Quat Mat3::to_quat() const
+Quaternion Matrix3x3::to_quat() const
 {
-	Quat tmp;
+	Quaternion tmp;
 
 	float fourWSquaredMinusOne = m[0] + m[4] + m[8];
 	float fourXSquaredMinusOne = m[0] - m[4] - m[8];

+ 41 - 41
engine/core/math/Mat3.h → engine/core/math/Matrix3x3.h

@@ -31,9 +31,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Mat4;
-class Quat;
-class Vec3;
+class Matrix4x4;
+class Quaternion;
+class Vector3;
 
 /// Column major 3x3 matrix.
 /// 
@@ -55,7 +55,7 @@ class Vec3;
 /// 2 | Xy  Yy  Zy |
 /// 3 [ Xz  Yz  Zz ]
 ///     1   2   3
-class Mat3
+class Matrix3x3
 {
 
 public:
@@ -63,17 +63,17 @@ public:
 	float				m[9];
 
 	/// Does nothing for efficiency.
-						Mat3();			
+						Matrix3x3();			
 
 	/// Constructs from a set of float
-						Mat3(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3);
+						Matrix3x3(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3);
 	
 	/// Constructs from the @a v array
-						Mat3(const float v[9]);						
-						Mat3(const Mat3& a);	
+						Matrix3x3(const float v[9]);						
+						Matrix3x3(const Matrix3x3& a);	
 
 	/// Assignment operator (copies the data)
-	Mat3&				operator=(const Mat3& a);					
+	Matrix3x3&			operator=(const Matrix3x3& a);					
 
 	/// Random access by index
 	float				operator[](uint32_t i) const;		
@@ -84,20 +84,20 @@ public:
 	/// Random access by row/column pair
 	float				operator()(uint32_t row, uint32_t column) const;	
 
-	Mat3				operator+(const Mat3& a) const;				
-	Mat3&				operator+=(const Mat3& a);					
-	Mat3				operator-(const Mat3& a) const;				
-	Mat3&				operator-=(const Mat3& a);					
-	Mat3				operator*(float k) const;					
-	Mat3&				operator*=(float k);						
-	Mat3				operator/(float k) const;					
-	Mat3&				operator/=(float k);							
-	Vec3				operator*(const Vec3& v) const;			
-	Mat3				operator*(const Mat3& a) const;				
-	Mat3&				operator*=(const Mat3& a);			
+	Matrix3x3			operator+(const Matrix3x3& a) const;				
+	Matrix3x3&			operator+=(const Matrix3x3& a);					
+	Matrix3x3			operator-(const Matrix3x3& a) const;				
+	Matrix3x3&			operator-=(const Matrix3x3& a);					
+	Matrix3x3			operator*(float k) const;					
+	Matrix3x3&			operator*=(float k);						
+	Matrix3x3			operator/(float k) const;					
+	Matrix3x3&			operator/=(float k);							
+	Vector3				operator*(const Vector3& v) const;			
+	Matrix3x3			operator*(const Matrix3x3& a) const;				
+	Matrix3x3&			operator*=(const Matrix3x3& a);			
 
 	/// For simmetry
-	friend Mat3			operator*(float k, const Mat3& a);			
+	friend Matrix3x3		operator*(float k, const Matrix3x3& a);			
 
 	/// Builds a rotation matrix about the X axis of @a radians radians
 	void				build_rotation_x(float radians);			
@@ -109,40 +109,40 @@ public:
 	void				build_rotation_z(float radians);	
 
 	/// Builds a rotation matrix about an arbitrary axis of "radians" radians			
-	void				build_rotation(const Vec3& n, float radians);
+	void				build_rotation(const Vector3& n, float radians);
 
-	Mat3&				transpose();								
-	Mat3				get_transposed() const;						
+	Matrix3x3&			transpose();								
+	Matrix3x3			get_transposed() const;						
 	float				get_determinant() const;					
-	Mat3&				invert();									
-	Mat3				get_inverted() const;						
+	Matrix3x3&			invert();									
+	Matrix3x3			get_inverted() const;						
 
 	/// Builds the identity matrix
 	void				load_identity();							
 
-	/// Returns a Vec3 containing the matrix's x base vector.
-	Vec3				x() const;
+	/// Returns a Vector3 containing the matrix's x base vector.
+	Vector3				x() const;
 
-	/// Returns a Vec3 containing the matrix's y base vector.
-	Vec3				y() const;
+	/// Returns a Vector3 containing the matrix's y base vector.
+	Vector3				y() const;
 
-	/// Returns a Vec3 containing the matrix's z base vector.
-	Vec3				z() const;
+	/// Returns a Vector3 containing the matrix's z base vector.
+	Vector3				z() const;
 
 	/// Sets the matrix's x base vector.
-	void				set_x(const Vec3& x);
+	void				set_x(const Vector3& x);
 
 	/// Sets the matrix's y base vector.
-	void				set_y(const Vec3& y);
+	void				set_y(const Vector3& y);
 
 	/// Sets the matrix's z base vector.
-	void				set_z(const Vec3& z);
+	void				set_z(const Vector3& z);
 
-	/// Returns a Vec3 containing the matrix's scale portion
-	Vec3				get_scale() const;	
+	/// Returns a Vector3 containing the matrix's scale portion
+	Vector3				get_scale() const;	
 
 	/// Fills the matrix's scale portion with the values contained in @a scale				
-	void				set_scale(const Vec3& scale);				
+	void				set_scale(const Vector3& scale);				
 
 	/// Returns the pointer to the matrix's data
 	float*				to_float_ptr();				
@@ -151,12 +151,12 @@ public:
 	const float*		to_float_ptr() const;
 
 	/// Returns a 4x4 matrix according to the matrix's rotation portion						
-	Mat4				to_mat4() const;
+	Matrix4x4			to_mat4() const;
 
 	/// Returns a quaternion according to the matrix's rotation portion							
-	Quat				to_quat() const;							
+	Quaternion			to_quat() const;							
 
-	static const Mat3	IDENTITY;
+	static const Matrix3x3	IDENTITY;
 };
 
 } // namespace crown

+ 94 - 92
engine/core/math/Mat4.cpp → engine/core/math/Matrix4x4.cpp

@@ -25,27 +25,29 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "Assert.h"
-#include "Mat3.h"
+#include "Matrix3x3.h"
 #include "Types.h"
-#include "Mat4.h"
+#include "Matrix4x4.h"
 #include "MathUtils.h"
-#include "Quat.h"
-#include "Vec3.h"
-#include "Vec4.h"
+#include "Quaternion.h"
+#include "Vector3.h"
+#include "Vector4.h"
 
 namespace crown
 {
 
-const Mat4 Mat4::IDENTITY = Mat4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
+const Matrix4x4 Matrix4x4::IDENTITY = Matrix4x4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
 
 //-----------------------------------------------------------------------------
-Mat4::Mat4()
+Matrix4x4::Matrix4x4()
 {
 }
 
 //-----------------------------------------------------------------------------
-Mat4::Mat4(float r1c1, float r2c1, float r3c1, float r4c1, float r1c2, float r2c2, float r3c2, float r4c2,
-	float r1c3, float r2c3, float r3c3, float r4c3, float r1c4, float r2c4, float r3c4, float r4c4)
+Matrix4x4::Matrix4x4(float r1c1, float r2c1, float r3c1, float r4c1,
+						float r1c2, float r2c2, float r3c2, float r4c2,
+						float r1c3, float r2c3, float r3c3, float r4c3,
+						float r1c4, float r2c4, float r3c4, float r4c4)
 {
 	m[0] = r1c1;
 	m[1] = r2c1;
@@ -66,7 +68,7 @@ Mat4::Mat4(float r1c1, float r2c1, float r3c1, float r4c1, float r1c2, float r2c
 }
 
 //-----------------------------------------------------------------------------
-Mat4::Mat4(const Quat& r, const Vec3& p)
+Matrix4x4::Matrix4x4(const Quaternion& r, const Vector3& p)
 {
 	const float& rx = r.v.x;
 	const float& ry = r.v.y;
@@ -92,7 +94,7 @@ Mat4::Mat4(const Quat& r, const Vec3& p)
 }
 
 //-----------------------------------------------------------------------------
-Mat4::Mat4(const float v[16])
+Matrix4x4::Matrix4x4(const float v[16])
 {
 	m[0] = v[0];
 	m[1] = v[1];
@@ -113,7 +115,7 @@ Mat4::Mat4(const float v[16])
 }
 
 //-----------------------------------------------------------------------------
-Mat4::Mat4(const Mat4& a)
+Matrix4x4::Matrix4x4(const Matrix4x4& a)
 {
 	m[0] = a.m[0];
 	m[1] = a.m[1];
@@ -134,7 +136,7 @@ Mat4::Mat4(const Mat4& a)
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::operator=(const Mat4& a)
+Matrix4x4& Matrix4x4::operator=(const Matrix4x4& a)
 {
 	m[0] = a.m[0];
 	m[1] = a.m[1];
@@ -157,7 +159,7 @@ Mat4& Mat4::operator=(const Mat4& a)
 }
 
 //-----------------------------------------------------------------------------
-float Mat4::operator[](uint32_t i) const
+float Matrix4x4::operator[](uint32_t i) const
 {
 	CE_ASSERT(i < 16, "Index must be < 16");
 
@@ -165,7 +167,7 @@ float Mat4::operator[](uint32_t i) const
 }
 
 //-----------------------------------------------------------------------------
-float& Mat4::operator[](uint32_t i)
+float& Matrix4x4::operator[](uint32_t i)
 {
 	CE_ASSERT(i < 16, "Index must be < 16");
 
@@ -173,7 +175,7 @@ float& Mat4::operator[](uint32_t i)
 }
 
 //-----------------------------------------------------------------------------
-float Mat4::operator()(uint32_t row, uint32_t column) const
+float Matrix4x4::operator()(uint32_t row, uint32_t column) const
 {
 	CE_ASSERT(row < 4 && column < 4, "Row and column must be < 4");
 
@@ -181,9 +183,9 @@ float Mat4::operator()(uint32_t row, uint32_t column) const
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mat4::operator+(const Mat4& a) const
+Matrix4x4 Matrix4x4::operator+(const Matrix4x4& a) const
 {
-	Mat4 tmp;
+	Matrix4x4 tmp;
 
 	tmp.m[0] = m[0] + a.m[0];
 	tmp.m[1] = m[1] + a.m[1];
@@ -206,7 +208,7 @@ Mat4 Mat4::operator+(const Mat4& a) const
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::operator+=(const Mat4& a)
+Matrix4x4& Matrix4x4::operator+=(const Matrix4x4& a)
 {
 	m[0] = m[0] + a.m[0];
 	m[1] = m[1] + a.m[1];
@@ -229,9 +231,9 @@ Mat4& Mat4::operator+=(const Mat4& a)
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mat4::operator-(const Mat4& a) const
+Matrix4x4 Matrix4x4::operator-(const Matrix4x4& a) const
 {
-	Mat4 tmp;
+	Matrix4x4 tmp;
 
 	tmp.m[0] = m[0] - a.m[0];
 	tmp.m[1] = m[1] - a.m[1];
@@ -254,7 +256,7 @@ Mat4 Mat4::operator-(const Mat4& a) const
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::operator-=(const Mat4& a)
+Matrix4x4& Matrix4x4::operator-=(const Matrix4x4& a)
 {
 	m[0] = m[0] - a.m[0];
 	m[1] = m[1] - a.m[1];
@@ -277,9 +279,9 @@ Mat4& Mat4::operator-=(const Mat4& a)
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mat4::operator*(float k) const
+Matrix4x4 Matrix4x4::operator*(float k) const
 {
-	Mat4 tmp;
+	Matrix4x4 tmp;
 
 	tmp.m[0] = m[0] * k;
 	tmp.m[1] = m[1] * k;
@@ -302,7 +304,7 @@ Mat4 Mat4::operator*(float k) const
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::operator*=(float k)
+Matrix4x4& Matrix4x4::operator*=(float k)
 {
 	m[0] *= k;
 	m[1] *= k;
@@ -325,9 +327,9 @@ Mat4& Mat4::operator*=(float k)
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mat4::operator/(float k) const
+Matrix4x4 Matrix4x4::operator/(float k) const
 {
-	Mat4 tmp;
+	Matrix4x4 tmp;
 
 	k = (float)1.0 / k;
 
@@ -352,7 +354,7 @@ Mat4 Mat4::operator/(float k) const
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::operator/=(float k)
+Matrix4x4& Matrix4x4::operator/=(float k)
 {
 	k = (float)1.0 / k;
 
@@ -377,9 +379,9 @@ Mat4& Mat4::operator/=(float k)
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat4::operator*(const Vec3& v) const
+Vector3 Matrix4x4::operator*(const Vector3& v) const
 {
-	Vec3 tmp;
+	Vector3 tmp;
 
 	tmp.x = m[0] * v.x + m[4] * v.y + m[8] * v.z + m[12];
 	tmp.y = m[1] * v.x + m[5] * v.y + m[9] * v.z + m[13];
@@ -389,9 +391,9 @@ Vec3 Mat4::operator*(const Vec3& v) const
 }
 
 //-----------------------------------------------------------------------------
-Vec4 Mat4::operator*(const Vec4& v) const
+Vector4 Matrix4x4::operator*(const Vector4& v) const
 {
-	Vec4 tmp;
+	Vector4 tmp;
 
 	tmp.x = m[0] * v.x + m[4] * v.y + m[8] * v.z + m[12] * v.w;
 	tmp.y = m[1] * v.x + m[5] * v.y + m[9] * v.z + m[13] * v.w;
@@ -402,9 +404,9 @@ Vec4 Mat4::operator*(const Vec4& v) const
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mat4::operator*(const Mat4& a) const
+Matrix4x4 Matrix4x4::operator*(const Matrix4x4& a) const
 {
-	Mat4 tmp;
+	Matrix4x4 tmp;
 
 	tmp.m[0] = m[0] * a.m[0] + m[4] * a.m[1] + m[8] * a.m[2] + m[12] * a.m[3];
 	tmp.m[1] = m[1] * a.m[0] + m[5] * a.m[1] + m[9] * a.m[2] + m[13] * a.m[3];
@@ -430,9 +432,9 @@ Mat4 Mat4::operator*(const Mat4& a) const
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::operator*=(const Mat4& a)
+Matrix4x4& Matrix4x4::operator*=(const Matrix4x4& a)
 {
-	Mat4 tmp;
+	Matrix4x4 tmp;
 
 	tmp.m[0] = m[0] * a.m[0] + m[4] * a.m[1] + m[8] * a.m[2] + m[12] * a.m[3];
 	tmp.m[1] = m[1] * a.m[0] + m[5] * a.m[1] + m[9] * a.m[2] + m[13] * a.m[3];
@@ -459,13 +461,13 @@ Mat4& Mat4::operator*=(const Mat4& a)
 	return *this;
 }
 
-Mat4 operator*(float k, const Mat4& a)
+Matrix4x4 operator*(float k, const Matrix4x4& a)
 {
 	return a * k;
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_rotation_x(float radians)
+void Matrix4x4::build_rotation_x(float radians)
 {
 	m[0] = 1.0;
 	m[1] = 0.0;
@@ -486,7 +488,7 @@ void Mat4::build_rotation_x(float radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_rotation_y(float radians)
+void Matrix4x4::build_rotation_y(float radians)
 {
 	m[0] = math::cos(radians);
 	m[1] = 0.0;
@@ -507,7 +509,7 @@ void Mat4::build_rotation_y(float radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_rotation_z(float radians)
+void Matrix4x4::build_rotation_z(float radians)
 {
 	m[0] = math::cos(radians);
 	m[1] = math::sin(radians);
@@ -528,7 +530,7 @@ void Mat4::build_rotation_z(float radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_rotation(const Vec3& n, float radians)
+void Matrix4x4::build_rotation(const Vector3& n, float radians)
 {
 	float a = (float)1.0 - math::cos(radians);
 	float sin_a = math::sin(radians);
@@ -553,7 +555,7 @@ void Mat4::build_rotation(const Vec3& n, float radians)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_projection_perspective_rh(float fovy, float aspect, float near, float far)
+void Matrix4x4::build_projection_perspective_rh(float fovy, float aspect, float near, float far)
 {
 	double top, right;
 
@@ -579,7 +581,7 @@ void Mat4::build_projection_perspective_rh(float fovy, float aspect, float near,
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_projection_perspective_lh(float fovy, float aspect, float near, float far)
+void Matrix4x4::build_projection_perspective_lh(float fovy, float aspect, float near, float far)
 {
 	double top, right;
 
@@ -605,7 +607,7 @@ void Mat4::build_projection_perspective_lh(float fovy, float aspect, float near,
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_projection_ortho_rh(float width, float height, float near, float far)
+void Matrix4x4::build_projection_ortho_rh(float width, float height, float near, float far)
 {
 	m[0] = (float)2.0 / width;
 	m[1] = 0.0;
@@ -626,7 +628,7 @@ void Mat4::build_projection_ortho_rh(float width, float height, float near, floa
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_projection_ortho_lh(float width, float height, float near, float far)
+void Matrix4x4::build_projection_ortho_lh(float width, float height, float near, float far)
 {
 	m[0] = (float)2.0 / width;
 	m[1] = 0.0;
@@ -647,7 +649,7 @@ void Mat4::build_projection_ortho_lh(float width, float height, float near, floa
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_projection_ortho_2d_rh(float width, float height, float near, float far)
+void Matrix4x4::build_projection_ortho_2d_rh(float width, float height, float near, float far)
 {
 	m[0] = (float)2.0 / width;
 	m[1] = 0.0;
@@ -668,7 +670,7 @@ void Mat4::build_projection_ortho_2d_rh(float width, float height, float near, f
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::transpose()
+Matrix4x4& Matrix4x4::transpose()
 {
 	float tmp;
 
@@ -700,9 +702,9 @@ Mat4& Mat4::transpose()
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Mat4::get_transposed() const
+Matrix4x4 Matrix4x4::get_transposed() const
 {
-	Mat4 tmp;
+	Matrix4x4 tmp;
 
 	tmp.m[0] = m[0];
 	tmp.m[1] = m[4];
@@ -725,13 +727,13 @@ Mat4 Mat4::get_transposed() const
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_look_at_rh(const Vec3& pos, const Vec3& target, const Vec3& up)
+void Matrix4x4::build_look_at_rh(const Vector3& pos, const Vector3& target, const Vector3& up)
 {
-	Vec3 zAxis =  pos - target;
+	Vector3 zAxis =  pos - target;
 	zAxis.normalize();
 
-	Vec3 xAxis = up.cross(zAxis);
-	Vec3 yAxis = zAxis.cross(xAxis);
+	Vector3 xAxis = up.cross(zAxis);
+	Vector3 yAxis = zAxis.cross(xAxis);
 
 	m[0] = xAxis.x;
 	m[1] = yAxis.x;
@@ -752,13 +754,13 @@ void Mat4::build_look_at_rh(const Vec3& pos, const Vec3& target, const Vec3& up)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_look_at_lh(const Vec3& pos, const Vec3& target, const Vec3& up)
+void Matrix4x4::build_look_at_lh(const Vector3& pos, const Vector3& target, const Vector3& up)
 {
-	Vec3 zAxis =  target - pos;
+	Vector3 zAxis =  target - pos;
 	zAxis.normalize();
 
-	Vec3 xAxis = up.cross(zAxis);
-	Vec3 yAxis = zAxis.cross(xAxis);
+	Vector3 xAxis = up.cross(zAxis);
+	Vector3 yAxis = zAxis.cross(xAxis);
 
 	m[0] = xAxis.x;
 	m[1] = yAxis.x;
@@ -779,13 +781,13 @@ void Mat4::build_look_at_lh(const Vec3& pos, const Vec3& target, const Vec3& up)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_viewpoint_billboard(const Vec3& pos, const Vec3& target, const Vec3& up)
+void Matrix4x4::build_viewpoint_billboard(const Vector3& pos, const Vector3& target, const Vector3& up)
 {
-	Vec3 zAxis = target - pos;
+	Vector3 zAxis = target - pos;
 	zAxis.normalize();
 
-	Vec3 xAxis = up.cross(zAxis).normalize();
-	Vec3 yAxis = zAxis.cross(xAxis).normalize();
+	Vector3 xAxis = up.cross(zAxis).normalize();
+	Vector3 yAxis = zAxis.cross(xAxis).normalize();
 
 	m[0] = xAxis.x;
 	m[1] = xAxis.y;
@@ -806,13 +808,13 @@ void Mat4::build_viewpoint_billboard(const Vec3& pos, const Vec3& target, const
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::build_axis_billboard(const Vec3& pos, const Vec3& target, const Vec3& axis)
+void Matrix4x4::build_axis_billboard(const Vector3& pos, const Vector3& target, const Vector3& axis)
 {
-	Vec3 zAxis = target - pos;
+	Vector3 zAxis = target - pos;
 
-	Vec3 xAxis = axis.cross(zAxis).normalize();
+	Vector3 xAxis = axis.cross(zAxis).normalize();
 	zAxis = axis.cross(xAxis).normalize();
-	const Vec3& yAxis = axis;
+	const Vector3& yAxis = axis;
 
 	m[0] = xAxis.x;
 	m[1] = xAxis.y;
@@ -833,7 +835,7 @@ void Mat4::build_axis_billboard(const Vec3& pos, const Vec3& target, const Vec3&
 }
 
 //-----------------------------------------------------------------------------
-float Mat4::get_determinant() const
+float Matrix4x4::get_determinant() const
 {
 	float det;
 
@@ -853,9 +855,9 @@ float Mat4::get_determinant() const
 }
 
 //-----------------------------------------------------------------------------
-Mat4& Mat4::invert()
+Matrix4x4& Matrix4x4::invert()
 {
-	Mat4 mat;
+	Matrix4x4 mat;
 	float det;
 
 	float m01m06_m05m02 = m[1] * m[6] - m[5] * m[2];
@@ -919,40 +921,40 @@ Mat4& Mat4::invert()
 }
 
 //-----------------------------------------------------------------------------
-inline Mat4 Mat4::get_inverted() const
+inline Matrix4x4 Matrix4x4::get_inverted() const
 {
-	Mat4 tmp(*this);
+	Matrix4x4 tmp(*this);
 
 	return tmp.invert();
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::load_identity()
+void Matrix4x4::load_identity()
 {
 	m[0] = m[5] = m[10] = m[15] = 1.0;
 	m[1] = m[2] = m[3] = m[4] = m[6] = m[7] = m[8] = m[9] = m[11] = m[12] = m[13] = m[14] = 0.0;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat4::x() const
+Vector3 Matrix4x4::x() const
 {
-	return Vec3(m[0], m[1], m[2]);
+	return Vector3(m[0], m[1], m[2]);
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat4::y() const
+Vector3 Matrix4x4::y() const
 {
-	return Vec3(m[4], m[5], m[6]);
+	return Vector3(m[4], m[5], m[6]);
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat4::z() const
+Vector3 Matrix4x4::z() const
 {
-	return Vec3(m[8], m[9], m[10]);
+	return Vector3(m[8], m[9], m[10]);
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::set_x(const Vec3& x)
+void Matrix4x4::set_x(const Vector3& x)
 {
 	m[0] = x.x;
 	m[1] = x.y;
@@ -960,7 +962,7 @@ void Mat4::set_x(const Vec3& x)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::set_y(const Vec3& y)
+void Matrix4x4::set_y(const Vector3& y)
 {
 	m[4] = y.x;
 	m[5] = y.y;
@@ -968,7 +970,7 @@ void Mat4::set_y(const Vec3& y)
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::set_z(const Vec3& z)
+void Matrix4x4::set_z(const Vector3& z)
 {
 	m[8] = z.x;
 	m[9] = z.y;
@@ -976,9 +978,9 @@ void Mat4::set_z(const Vec3& z)
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat4::translation() const
+Vector3 Matrix4x4::translation() const
 {
-	Vec3 tmp;
+	Vector3 tmp;
 
 	tmp.x = m[12];
 	tmp.y = m[13];
@@ -988,7 +990,7 @@ Vec3 Mat4::translation() const
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::set_translation(const Vec3& trans)
+void Matrix4x4::set_translation(const Vector3& trans)
 {
 	m[12] = trans.x;
 	m[13] = trans.y;
@@ -996,9 +998,9 @@ void Mat4::set_translation(const Vec3& trans)
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Mat4::get_scale() const
+Vector3 Matrix4x4::get_scale() const
 {
-	Vec3 tmp;
+	Vector3 tmp;
 
 	tmp.x = m[0];
 	tmp.y = m[5];
@@ -1008,7 +1010,7 @@ Vec3 Mat4::get_scale() const
 }
 
 //-----------------------------------------------------------------------------
-void Mat4::set_scale(const Vec3& scale)
+void Matrix4x4::set_scale(const Vector3& scale)
 {
 	m[0] = scale.x;
 	m[5] = scale.y;
@@ -1016,21 +1018,21 @@ void Mat4::set_scale(const Vec3& scale)
 }
 
 //-----------------------------------------------------------------------------
-float* Mat4::to_float_ptr()
+float* Matrix4x4::to_float_ptr()
 {
 	return &m[0];
 }
 
 //-----------------------------------------------------------------------------
-const float* Mat4::to_float_ptr() const
+const float* Matrix4x4::to_float_ptr() const
 {
 	return &m[0];
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Mat4::to_mat3() const
+Matrix3x3 Matrix4x4::to_mat3() const
 {
-	Mat3 tmp;
+	Matrix3x3 tmp;
 
 	tmp.m[0] = m[0];
 	tmp.m[1] = m[1];
@@ -1046,9 +1048,9 @@ Mat3 Mat4::to_mat3() const
 }
 
 //-----------------------------------------------------------------------------
-Quat Mat4::to_quat() const
+Quaternion Matrix4x4::to_quat() const
 {
-	Quat tmp;
+	Quaternion tmp;
 	float fourWSquaredMinusOne = m[0] + m[5] + m[10];
 	float fourXSquaredMinusOne = m[0] - m[5] - m[10];
 	float fourYSquaredMinusOne = -m[0] + m[5] - m[10];

+ 54 - 54
engine/core/math/Mat4.h → engine/core/math/Matrix4x4.h

@@ -31,10 +31,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Mat3;
-class Quat;
-class Vec3;
-class Vec4;
+class Matrix3x3;
+class Quaternion;
+class Vector3;
+class Vector4;
 
 /// Column-major 4x4 matrix.
 /// 
@@ -58,7 +58,7 @@ class Vec4;
 /// 3 | Xz  Yz  Zz  Tz |
 /// 4 [ 0   0   0   1  ]
 ///     1   2   3   4
-class Mat4
+class Matrix4x4
 {
 
 public:
@@ -66,23 +66,23 @@ public:
 	float				m[16];
 
 	/// Does nothing for efficiency.
-						Mat4();	
+						Matrix4x4();	
 
 	/// Constructs from a set of float
-						Mat4(float r1c1, float r2c1, float r3c1, float r4c1,
-								float r1c2, float r2c2, float r3c2, float r4c2,
-								float r1c3, float r2c3, float r3c3, float r4c3,
-								float r1c4, float r2c4, float r3c4, float r4c4);
+						Matrix4x4(float r1c1, float r2c1, float r3c1, float r4c1,
+									float r1c2, float r2c2, float r3c2, float r4c2,
+									float r1c3, float r2c3, float r3c3, float r4c3,
+									float r1c4, float r2c4, float r3c4, float r4c4);
 
 	/// Constructs from rotation @a r and position @a p.
-						Mat4(const Quat& r, const Vec3& p);
+						Matrix4x4(const Quaternion& r, const Vector3& p);
 	
 	/// Contructs from the @a v array
-						Mat4(const float v[16]);						
-						Mat4(const Mat4& a);					
+						Matrix4x4(const float v[16]);						
+						Matrix4x4(const Matrix4x4& a);					
 
 	/// Assignment operator (copies the data)
-	Mat4&				operator=(const Mat4& a);					
+	Matrix4x4&			operator=(const Matrix4x4& a);					
 
 	/// Random access by index
 	float				operator[](uint32_t i) const;
@@ -92,21 +92,21 @@ public:
 
 	float				operator()(uint32_t row, uint32_t column) const;	//!< Random access by row/column pair
 
-	Mat4				operator+(const Mat4& a) const;
-	Mat4&				operator+=(const Mat4& a);					
-	Mat4				operator-(const Mat4& a) const;				
-	Mat4&				operator-=(const Mat4& a);					
-	Mat4				operator*(float k) const;				
-	Mat4&				operator*=(float k);							
-	Mat4				operator/(float k) const;					
-	Mat4&				operator/=(float k);							
-	Vec3				operator*(const Vec3& v) const;				
-	Vec4				operator*(const Vec4& v) const;				
-	Mat4				operator*(const Mat4& a) const;			
-	Mat4&				operator*=(const Mat4& a);
+	Matrix4x4			operator+(const Matrix4x4& a) const;
+	Matrix4x4&			operator+=(const Matrix4x4& a);					
+	Matrix4x4			operator-(const Matrix4x4& a) const;				
+	Matrix4x4&			operator-=(const Matrix4x4& a);					
+	Matrix4x4			operator*(float k) const;				
+	Matrix4x4&			operator*=(float k);							
+	Matrix4x4			operator/(float k) const;					
+	Matrix4x4&			operator/=(float k);							
+	Vector3				operator*(const Vector3& v) const;				
+	Vector4				operator*(const Vector4& v) const;				
+	Matrix4x4			operator*(const Matrix4x4& a) const;			
+	Matrix4x4&			operator*=(const Matrix4x4& a);
 
 	/// For simmetry
-	friend Mat4			operator*(float k, const Mat4& a);			
+	friend Matrix4x4	operator*(float k, const Matrix4x4& a);			
 
 	/// Builds a rotation matrix about the X axis of @a radians radians
 	void				build_rotation_x(float radians);
@@ -118,7 +118,7 @@ public:
 	void				build_rotation_z(float radians);		
 
 	/// Builds a rotation matrix about an arbitrary axis of "radians" radians		
-	void				build_rotation(const Vec3& n, float radians);
+	void				build_rotation(const Vector3& n, float radians);
 
 	/// Builds a perspetive projection matrix suited to Right-Handed coordinate systems
 	void				build_projection_perspective_rh(float fovy, float aspect, float near, float far);
@@ -136,55 +136,55 @@ public:
 	void				build_projection_ortho_2d_rh(float width, float height, float near, float far);	
 
 	/// Builds a "Righ-Handed look-at" matrix from a position, a target, and an up vector
-	void				build_look_at_rh(const Vec3& pos, const Vec3& target, const Vec3& up);
+	void				build_look_at_rh(const Vector3& pos, const Vector3& target, const Vector3& up);
 
 	/// Builds a "Left-Handed look-at" matrix from a position, a target, and an up vector	
-	void				build_look_at_lh(const Vec3& pos, const Vec3& target, const Vec3& up);
+	void				build_look_at_lh(const Vector3& pos, const Vector3& target, const Vector3& up);
 
 	/// Builds a "Viewpoint-Oriented billboard" matrix which can be used to make an object face a specific point in space	
-	void				build_viewpoint_billboard(const Vec3& pos, const Vec3& target, const Vec3& up);	
+	void				build_viewpoint_billboard(const Vector3& pos, const Vector3& target, const Vector3& up);	
 
 	/// Builds a "Arbitrary-Axis billboard" matrix which can be used to make an object face a specific point in space
-	void				build_axis_billboard(const Vec3& pos, const Vec3& target, const Vec3& axis);	
+	void				build_axis_billboard(const Vector3& pos, const Vector3& target, const Vector3& axis);	
 
-	Mat4&				transpose();								
-	Mat4				get_transposed() const;						
+	Matrix4x4&			transpose();								
+	Matrix4x4			get_transposed() const;						
 	float				get_determinant() const;					
-	Mat4&				invert();									
-	Mat4				get_inverted() const;						
+	Matrix4x4&			invert();									
+	Matrix4x4			get_inverted() const;						
 
 	/// Builds the identity matrix
 	void				load_identity();							
 
-	/// Returns a Vec3 containing the matrix's x base vector.
-	Vec3				x() const;
+	/// Returns a Vector3 containing the matrix's x base vector.
+	Vector3				x() const;
 
-	/// Returns a Vec3 containing the matrix's y base vector.
-	Vec3				y() const;
+	/// Returns a Vector3 containing the matrix's y base vector.
+	Vector3				y() const;
 
-	/// Returns a Vec3 containing the matrix's z base vector.
-	Vec3				z() const;
+	/// Returns a Vector3 containing the matrix's z base vector.
+	Vector3				z() const;
 
 	/// Sets the matrix's x base vector.
-	void				set_x(const Vec3& x);
+	void				set_x(const Vector3& x);
 
 	/// Sets the matrix's y base vector.
-	void				set_y(const Vec3& y);
+	void				set_y(const Vector3& y);
 
 	/// Sets the matrix's z base vector.
-	void				set_z(const Vec3& z);
+	void				set_z(const Vector3& z);
 
-	/// Returns a Vec3 containing the matrix's translation portion
-	Vec3				translation() const;	
+	/// Returns a Vector3 containing the matrix's translation portion
+	Vector3				translation() const;	
 
 	/// Fills the matrix's translation portion values contained in @a trans				
-	void				set_translation(const Vec3& trans);			
+	void				set_translation(const Vector3& trans);			
 
-	/// Returns a Vec3 containing the matrix's scale portion
-	Vec3				get_scale() const;
+	/// Returns a Vector3 containing the matrix's scale portion
+	Vector3				get_scale() const;
 
 	/// Fills the matrix's scale portion with the values contained in @a scale							
-	void				set_scale(const Vec3& scale);				
+	void				set_scale(const Vector3& scale);				
 
 	/// Returns the pointer to the matrix's data
 	float*				to_float_ptr();
@@ -193,12 +193,12 @@ public:
 	const float*		to_float_ptr() const;
 
 	/// Returns a 3x3 matrix according to the matrix's rotation portion						
-	Mat3				to_mat3() const;
+	Matrix3x3			to_mat3() const;
 
 	/// Returns a quaternion according to the matrix's rotation portion							
-	Quat				to_quat() const;							
+	Quaternion			to_quat() const;							
 
-	static const Mat4	IDENTITY;
+	static const Matrix4x4	IDENTITY;
 };
 
 } // namespace crown

+ 7 - 7
engine/core/math/Plane.cpp

@@ -31,10 +31,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-const Plane Plane::ZERO = Plane(Vec3::ZERO, 0.0);
-const Plane	Plane::XAXIS = Plane(Vec3::XAXIS, 0.0);
-const Plane	Plane::YAXIS = Plane(Vec3::YAXIS, 0.0);
-const Plane	Plane::ZAXIS = Plane(Vec3::ZAXIS, 0.0);
+const Plane Plane::ZERO = Plane(Vector3::ZERO, 0.0);
+const Plane	Plane::XAXIS = Plane(Vector3::XAXIS, 0.0);
+const Plane	Plane::YAXIS = Plane(Vector3::YAXIS, 0.0);
+const Plane	Plane::ZAXIS = Plane(Vector3::ZAXIS, 0.0);
 
 //-----------------------------------------------------------------------------
 Plane::Plane()
@@ -47,7 +47,7 @@ Plane::Plane(const Plane& p) : n(p.n), d(p.d)
 }
 
 //-----------------------------------------------------------------------------
-Plane::Plane(const Vec3& normal, float dist) : n(normal), d(dist)
+Plane::Plane(const Vector3& normal, float dist) : n(normal), d(dist)
 {
 }
 
@@ -70,13 +70,13 @@ Plane& Plane::normalize()
 }
 
 //-----------------------------------------------------------------------------
-float Plane::distance_to_point(const Vec3& p) const
+float Plane::distance_to_point(const Vector3& p) const
 {
 	return n.dot(p) + d;
 }
 
 //-----------------------------------------------------------------------------
-bool Plane::contains_point(const Vec3& p) const
+bool Plane::contains_point(const Vector3& p) const
 {
 	return math::equals(n.dot(p) + d, (float)0.0);
 }

+ 5 - 5
engine/core/math/Plane.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Sphere.h"
-#include "Vec3.h"
+#include "Vector3.h"
 
 namespace crown
 {
@@ -41,7 +41,7 @@ class Plane
 {
 public:
 
-	Vec3				n;
+	Vector3				n;
 	float				d;
 
 public:
@@ -51,16 +51,16 @@ public:
 						Plane(const Plane& p);
 
 	/// Constructs from a normal and distance factor						
-						Plane(const Vec3& normal, float dist);		
+						Plane(const Vector3& normal, float dist);		
 
 	/// Normalizes the plane
 	Plane&				normalize();							
 
 	/// Returns the signed distance between point @a p and the plane
-	float				distance_to_point(const Vec3& p) const;	
+	float				distance_to_point(const Vector3& p) const;	
 
 	/// Returns whether the plane contains the point @a p	
-	bool				contains_point(const Vec3& p) const;		
+	bool				contains_point(const Vector3& p) const;		
 
 	static const Plane	ZERO;
 	static const Plane	XAXIS;

+ 8 - 8
engine/core/math/Point2.h

@@ -29,8 +29,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Assert.h"
 #include "Types.h"
 #include "MathUtils.h"
-#include "Vec2.h"
-#include "Vec3.h"
+#include "Vector2.h"
+#include "Vector3.h"
 
 namespace crown
 {
@@ -83,8 +83,8 @@ public:
 
 	int32_t*				to_int_ptr();						//! Returns the point32_ter to the point32_t's data
 	const int32_t*			to_int_ptr() const;					//! Returns the point32_ter to the point32_t's data
-	Vec2					to_vec2() const;					//! Returns a vector from this point32_t
-	Vec3					to_vec3() const;					//! Returns a vector from this point32_t
+	Vector2					to_vec2() const;					//! Returns a vector from this point32_t
+	Vector3					to_vec3() const;					//! Returns a vector from this point32_t
 
 	static const Point2		ZERO;
 	static const Point2		ONE;
@@ -290,15 +290,15 @@ inline const int32_t* Point2::to_int_ptr() const
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Point2::to_vec2() const
+inline Vector2 Point2::to_vec2() const
 {
-	return Vec2((float)x, (float)y);
+	return Vector2((float)x, (float)y);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Point2::to_vec3() const
+inline Vector3 Point2::to_vec3() const
 {
-	return Vec3((float)x, (float)y, 0.0);
+	return Vector3((float)x, (float)y, 0.0);
 }
 
 } // namespace crown

+ 30 - 30
engine/core/math/Quat.cpp → engine/core/math/Quaternion.cpp

@@ -24,46 +24,46 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Mat3.h"
-#include "Mat4.h"
+#include "Matrix3x3.h"
+#include "Matrix4x4.h"
 #include "Types.h"
 #include "MathUtils.h"
-#include "Quat.h"
-#include "Vec3.h"
+#include "Quaternion.h"
+#include "Vector3.h"
 
 namespace crown
 {
 
-const Quat Quat::IDENTITY = Quat(0.0, 0.0, 0.0, 1.0);
+const Quaternion Quaternion::IDENTITY = Quaternion(0.0, 0.0, 0.0, 1.0);
 
 //-----------------------------------------------------------------------------
-Quat::Quat()
+Quaternion::Quaternion()
 {
 }
 
 //-----------------------------------------------------------------------------
-Quat::Quat(float nx, float ny, float nz, float nw) :
+Quaternion::Quaternion(float nx, float ny, float nz, float nw) :
 	v(nx, ny, nz),
 	w(nw)
 {
 }
 
 //-----------------------------------------------------------------------------
-Quat::Quat(const Vec3& axis, float angle) :
+Quaternion::Quaternion(const Vector3& axis, float angle) :
 	v(axis * math::sin(angle * 0.5)),
 	w(math::cos(angle * 0.5))
 {
 }
 
 //-----------------------------------------------------------------------------
-void Quat::negate()
+void Quaternion::negate()
 {
 	w = -w;
 	v.negate();
 }
 
 //-----------------------------------------------------------------------------
-void Quat::load_identity()
+void Quaternion::load_identity()
 {
 	w = 1.0;
 	v.x = 0.0;
@@ -72,37 +72,37 @@ void Quat::load_identity()
 }
 
 //-----------------------------------------------------------------------------
-float Quat::length() const
+float Quaternion::length() const
 {
 	return math::sqrt(w * w + v.x * v.x + v.y * v.y + v.z * v.z);
 }
 
 //-----------------------------------------------------------------------------
-void Quat::conjugate()
+void Quaternion::conjugate()
 {
 	v = -v;
 }
 
 //-----------------------------------------------------------------------------
-Quat Quat::get_conjugate() const
+Quaternion Quaternion::get_conjugate() const
 {
-	return Quat(-v, w);
+	return Quaternion(-v, w);
 }
 
 //-----------------------------------------------------------------------------
-Quat Quat::get_inverse() const
+Quaternion Quaternion::get_inverse() const
 {
 	return get_conjugate() * (1.0 / length());
 }
 
 //-----------------------------------------------------------------------------
-Mat3 Quat::to_mat3() const
+Matrix3x3 Quaternion::to_mat3() const
 {
 	const float& x = v.x;
 	const float& y = v.y;
 	const float& z = v.z;
 
-	Mat3 tmp;
+	Matrix3x3 tmp;
 
 	tmp.m[0] = (float)(1.0 - 2.0*y*y - 2.0*z*z);
 	tmp.m[1] = (float)(2.0*x*y + 2.0*w*z);
@@ -118,13 +118,13 @@ Mat3 Quat::to_mat3() const
 }
 
 //-----------------------------------------------------------------------------
-Mat4 Quat::to_mat4() const
+Matrix4x4 Quaternion::to_mat4() const
 {
 	const float& x = v.x;
 	const float& y = v.y;
 	const float& z = v.z;
 
-	Mat4 tmp;
+	Matrix4x4 tmp;
 
 	tmp.m[0] = (float)(1.0 - 2.0*y*y - 2.0*z*z);
 	tmp.m[1] = (float)(2.0*x*y + 2.0*w*z);
@@ -147,9 +147,9 @@ Mat4 Quat::to_mat4() const
 }
 
 //-----------------------------------------------------------------------------
-Quat Quat::operator*(const Quat& b) const
+Quaternion Quaternion::operator*(const Quaternion& b) const
 {
-	Quat tmp;
+	Quaternion tmp;
 
 	tmp.w = w * b.w - v.dot(b.v);
 	tmp.v = w * b.v + b.w * v + b.v.cross(v);
@@ -158,9 +158,9 @@ Quat Quat::operator*(const Quat& b) const
 }
 
 //-----------------------------------------------------------------------------
-Quat Quat::operator*(const float& k) const
+Quaternion Quaternion::operator*(const float& k) const
 {
-	Quat tmp;
+	Quaternion tmp;
 
 	tmp.w = w * k;
 	tmp.v = v * k;
@@ -169,9 +169,9 @@ Quat Quat::operator*(const float& k) const
 }
 
 //-----------------------------------------------------------------------------
-Quat Quat::power(float exp)
+Quaternion Quaternion::power(float exp)
 {
-	Quat tmp;
+	Quaternion tmp;
 
 	if (math::abs(w) < 0.9999)
 	{
@@ -192,21 +192,21 @@ Quat Quat::power(float exp)
 }
 
 /*
-The geometric interpretation of the Quat dot product is similar to the interpretation of
-the vector dot product; the larger the absolute value of the Quat dot product axb, the more
+The geometric interpretation of the Quaternion dot product is similar to the interpretation of
+the vector dot product; the larger the absolute value of the Quaternion dot product axb, the more
 "similar" the angular displacements represented by a and b.
 */
 //-----------------------------------------------------------------------------
-float dot(const Quat& a, const Quat& b)
+float dot(const Quaternion& a, const Quaternion& b)
 {
 	return a.w * b.w + a.v.dot(b.v);
 }
 
 // Spherical Linear interpolation
 //-----------------------------------------------------------------------------
-Quat slerp(const Quat& start, const Quat& end, float t)
+Quaternion slerp(const Quaternion& start, const Quaternion& end, float t)
 {
-	Quat delta = end * start.get_inverse();
+	Quaternion delta = end * start.get_inverse();
 	delta = delta.power(t);
 
 	return delta * start;

+ 16 - 16
engine/core/math/Quat.h → engine/core/math/Quaternion.h

@@ -27,13 +27,13 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "Vec3.h"
+#include "Vector3.h"
 
 namespace crown
 {
 
-class Mat3;
-class Mat4;
+class Matrix3x3;
+class Matrix4x4;
 
 /// Quaternion.
 ///
@@ -46,23 +46,23 @@ class Mat4;
 /// p' = (ba)p(ba)^-1 where p is the point and (ba) the concatenation of two successive rotations
 /// In this case, the point p is first rotated by the quaternion a and then by the quaternion b.
 /// The transformation order is reversed.
-class Quat
+class Quaternion
 {
 public:
 
-	Vec3		v;
+	Vector3		v;
 	float		w;
 
 public:
 
 	/// Does nothing
-						Quat();
+						Quaternion();
 
 	/// Constructs from individual components.
-						Quat(float nx, float ny, float nz, float nw);
+						Quaternion(float nx, float ny, float nz, float nw);
 
 	/// Builds the quaternion from an @a axis and a @a angle.							
-						Quat(const Vec3& axis, float angle);	
+						Quaternion(const Vector3& axis, float angle);	
 
 	/// Negates the quaternion.
 	void				negate();
@@ -77,25 +77,25 @@ public:
 	void				conjugate();
 
 	/// Returns the quaternion's conjugate.
-	Quat				get_conjugate() const;
+	Quaternion				get_conjugate() const;
 
 	/// Quaternion's inverse				
-	Quat				get_inverse() const;
+	Quaternion				get_inverse() const;
 
-	Mat3				to_mat3() const;
-	Mat4				to_mat4() const;
+	Matrix3x3				to_mat3() const;
+	Matrix4x4				to_mat4() const;
 
 	/// Cross product
-	Quat				operator*(const Quat& b) const;
+	Quaternion				operator*(const Quaternion& b) const;
 
 	/// Multiplication by a scalar		
-	Quat				operator*(const float& k) const;
+	Quaternion				operator*(const float& k) const;
 
-	Quat				power(float exp);
+	Quaternion				power(float exp);
 
 public:
 
-	static const Quat	IDENTITY;
+	static const Quaternion	IDENTITY;
 };
 
 } // namespace crown

+ 13 - 13
engine/core/math/Ray.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "Vec3.h"
+#include "Vector3.h"
 
 namespace crown
 {
@@ -43,19 +43,19 @@ public:
 					Ray();
 
 	/// Constructs from @a origin and @a direction
-					Ray(const Vec3& origin, const Vec3& direction);
+					Ray(const Vector3& origin, const Vector3& direction);
 					Ray(const Ray& ray);
 
-	const Vec3&		origin() const;
-	const Vec3&		direction() const;
+	const Vector3&		origin() const;
+	const Vector3&		direction() const;
 
-	void			set_origin(const Vec3& origin);
-	void			set_direction(const Vec3& direction);
+	void			set_origin(const Vector3& origin);
+	void			set_direction(const Vector3& direction);
 
 private:
 
-	Vec3			m_origin;
-	Vec3			m_direction;
+	Vector3			m_origin;
+	Vector3			m_direction;
 };
 
 //-----------------------------------------------------------------------------
@@ -64,7 +64,7 @@ inline Ray::Ray()
 }
 
 //-----------------------------------------------------------------------------
-inline Ray::Ray(const Vec3& origin, const Vec3& direction) : m_origin(origin), m_direction(direction)
+inline Ray::Ray(const Vector3& origin, const Vector3& direction) : m_origin(origin), m_direction(direction)
 {
 }
 
@@ -74,25 +74,25 @@ inline Ray::Ray(const Ray& ray) : m_origin(ray.m_origin), m_direction(ray.m_dire
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec3& Ray::origin() const
+inline const Vector3& Ray::origin() const
 {
 	return m_origin;
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec3& Ray::direction() const
+inline const Vector3& Ray::direction() const
 {
 	return m_direction;
 }
 
 //-----------------------------------------------------------------------------
-inline void Ray::set_origin(const Vec3& origin)
+inline void Ray::set_origin(const Vector3& origin)
 {
 	m_origin = origin;
 }
 
 //-----------------------------------------------------------------------------
-inline void Ray::set_direction(const Vec3& direction)
+inline void Ray::set_direction(const Vector3& direction)
 {
 	m_direction = direction;
 }

+ 22 - 22
engine/core/math/Triangle.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include "Vec3.h"
+#include "Vector3.h"
 #include "Plane.h"
 #include "MathUtils.h"
 
@@ -43,19 +43,19 @@ public:
 
 	/// Does nothing for efficiency.
 				Triangle();
-				Triangle(const Vec3& v1, const Vec3& v2, const Vec3& v3);
+				Triangle(const Vector3& v1, const Vector3& v2, const Vector3& v3);
 				~Triangle();
 
 	float		area() const;
 
 	/// Returns the center of gravity (a.k.a. "centroid").
-	Vec3		centroid() const;
+	Vector3		centroid() const;
 
 	/// Returns the barycentric coordinates of point @a p in respect to the triangle.
-	Vec3		barycentric_coords(const Vec3& p) const;
+	Vector3		barycentric_coords(const Vector3& p) const;
 
 	/// Returns whether the triangle contains the @a p point.
-	bool		contains_point(const Vec3& p) const;
+	bool		contains_point(const Vector3& p) const;
 
 	/// Returns the plane containing the triangle.
 	Plane		to_plane() const;
@@ -63,7 +63,7 @@ public:
 private:
 
 	// Vertices in CCW order
-	Vec3		m_vertex[3];
+	Vector3		m_vertex[3];
 
 	friend class Intersection;
 };
@@ -74,7 +74,7 @@ inline Triangle::Triangle()
 }
 
 //-----------------------------------------------------------------------------
-inline Triangle::Triangle(const Vec3& v1, const Vec3& v2, const Vec3& v3)
+inline Triangle::Triangle(const Vector3& v1, const Vector3& v2, const Vector3& v3)
 {
 	m_vertex[0] = v1;
 	m_vertex[1] = v2;
@@ -93,23 +93,23 @@ inline float Triangle::area() const
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Triangle::centroid() const
+inline Vector3 Triangle::centroid() const
 {
 	return (m_vertex[0] + m_vertex[1] + m_vertex[2]) * math::ONE_OVER_THREE;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Triangle::barycentric_coords(const Vec3& p) const
+inline Vector3 Triangle::barycentric_coords(const Vector3& p) const
 {
-	Vec3 e1 = m_vertex[2] - m_vertex[1];
-	Vec3 e2 = m_vertex[0] - m_vertex[2];
-	Vec3 e3 = m_vertex[1] - m_vertex[0];
+	Vector3 e1 = m_vertex[2] - m_vertex[1];
+	Vector3 e2 = m_vertex[0] - m_vertex[2];
+	Vector3 e3 = m_vertex[1] - m_vertex[0];
 
-	Vec3 d1 = p - m_vertex[0];
-	Vec3 d2 = p - m_vertex[1];
-	Vec3 d3 = p - m_vertex[2];
+	Vector3 d1 = p - m_vertex[0];
+	Vector3 d2 = p - m_vertex[1];
+	Vector3 d3 = p - m_vertex[2];
 
-	Vec3 n = e1.cross(e2) / e1.cross(e2).length();
+	Vector3 n = e1.cross(e2) / e1.cross(e2).length();
 
 	// Signed areas
 	float at = (float)(e1.cross(e2).dot(n) * 0.5);
@@ -120,13 +120,13 @@ inline Vec3 Triangle::barycentric_coords(const Vec3& p) const
 
 	float oneOverAt = (float)(1.0 / at);
 
-	return Vec3(at1 * oneOverAt, at2 * oneOverAt, at3 * oneOverAt);
+	return Vector3(at1 * oneOverAt, at2 * oneOverAt, at3 * oneOverAt);
 }
 
 //-----------------------------------------------------------------------------
-inline bool Triangle::contains_point(const Vec3& p) const
+inline bool Triangle::contains_point(const Vector3& p) const
 {
-	Vec3 bc = barycentric_coords(p);
+	Vector3 bc = barycentric_coords(p);
 
 	if (bc.x < 0.0 || bc.y < 0.0 || bc.z < 0.0)
 	{
@@ -139,10 +139,10 @@ inline bool Triangle::contains_point(const Vec3& p) const
 //-----------------------------------------------------------------------------
 inline Plane Triangle::to_plane() const
 {
-	Vec3 e1 = m_vertex[2] - m_vertex[1];
-	Vec3 e2 = m_vertex[1] - m_vertex[0];
+	Vector3 e1 = m_vertex[2] - m_vertex[1];
+	Vector3 e2 = m_vertex[1] - m_vertex[0];
 
-	Vec3 n = e2.cross(e1).normalize();
+	Vector3 n = e2.cross(e1).normalize();
 	float d = -n.dot(m_vertex[0]);
 
 	return Plane(n, d);

+ 5 - 5
engine/core/math/Vec2.cpp → engine/core/math/Vector2.cpp

@@ -24,15 +24,15 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Vec2.h"
+#include "Vector2.h"
 
 namespace crown
 {
 
-const Vec2 Vec2::ZERO	= Vec2(0.0, 0.0);
-const Vec2 Vec2::ONE	= Vec2(1.0, 1.0);
-const Vec2 Vec2::XAXIS	= Vec2(1.0, 0.0);
-const Vec2 Vec2::YAXIS	= Vec2(0.0, 1.0);
+const Vector2 Vector2::ZERO	= Vector2(0.0, 0.0);
+const Vector2 Vector2::ONE	= Vector2(1.0, 1.0);
+const Vector2 Vector2::XAXIS	= Vector2(1.0, 0.0);
+const Vector2 Vector2::YAXIS	= Vector2(0.0, 1.0);
 
 } // namespace crown
 

+ 74 - 74
engine/core/math/Vec2.h → engine/core/math/Vector2.h

@@ -34,24 +34,24 @@ namespace crown
 {
 
 /// 2D column vector.
-class Vec2
+class Vector2
 {
 public:
 
 	float				x, y;
 
 	/// Does nothing for efficiency.
-						Vec2();		
+						Vector2();		
 
 	/// Initializes all the components to val							
-						Vec2(float val);	
+						Vector2(float val);	
 
 	/// Constructs from two components						
-						Vec2(float nx, float ny);
+						Vector2(float nx, float ny);
 
 	/// Constructs from array
-						Vec2(const float v[2]);
-						Vec2(const Vec2& a);					
+						Vector2(const float v[2]);
+						Vector2(const Vector2& a);					
 
 	/// Random access by index
 	float				operator[](uint32_t i) const;
@@ -59,29 +59,29 @@ public:
 	/// Random access by index			
 	float&				operator[](uint32_t i);					
 
-	Vec2				operator+(const Vec2& a) const;			
-	Vec2&				operator+=(const Vec2& a);				
-	Vec2 				operator-(const Vec2& a) const;			
-	Vec2&				operator-=(const Vec2& a);				
-	Vec2				operator*(float k) const;				
-	Vec2&				operator*=(float k);						
-	Vec2				operator/(float k) const;				
-	Vec2&				operator/=(float k);
+	Vector2				operator+(const Vector2& a) const;			
+	Vector2&			operator+=(const Vector2& a);				
+	Vector2 			operator-(const Vector2& a) const;			
+	Vector2&			operator-=(const Vector2& a);				
+	Vector2				operator*(float k) const;				
+	Vector2&			operator*=(float k);						
+	Vector2				operator/(float k) const;				
+	Vector2&			operator/=(float k);
 
 	/// Dot product						
-	float				dot(const Vec2& a) const;				
+	float				dot(const Vector2& a) const;				
 
 	/// For simmetry
-	friend Vec2			operator*(float k, const Vec2& a);		
+	friend Vector2		operator*(float k, const Vector2& a);		
 
-	bool				operator==(const Vec2& other) const;	
-	bool				operator!=(const Vec2& other) const;
+	bool				operator==(const Vector2& other) const;	
+	bool				operator!=(const Vector2& other) const;
 
 	/// Returns whether all the components of this vector are smaller than all of the @a other vector	
-	bool				operator<(const Vec2& other) const;		
+	bool				operator<(const Vector2& other) const;		
 
 	/// Returns whether all the components of this vector are greater than all of the @a other vector
-	bool				operator>(const Vec2& other) const;		
+	bool				operator>(const Vector2& other) const;		
 
 	/// Returns the vector's length
 	float				length() const;
@@ -95,22 +95,22 @@ public:
 	float				get_angle_2d() const;
 
 	/// Normalizes the vector
-	Vec2&				normalize();
+	Vector2&			normalize();
 
 	/// Returns the normalized vector							
-	Vec2				get_normalized() const;
+	Vector2				get_normalized() const;
 
 	/// Negates the vector (i.e. builds the inverse)					
-	Vec2&				negate();
+	Vector2&			negate();
 
 	/// Negates the vector (i.e. builds the inverse)								
-	Vec2				operator-() const;						
+	Vector2				operator-() const;						
 
 	/// Returns the distance
-	float				get_distance_to(const Vec2& a) const;
+	float				get_distance_to(const Vector2& a) const;
 
 	/// Returns the angle in radian	
-	float				get_angle_between(const Vec2& a) const;
+	float				get_angle_between(const Vector2& a) const;
 
 	/// Sets all components to zero
 	void				zero();
@@ -119,41 +119,41 @@ public:
 	float*				to_float_ptr();	
 
 	/// Returns the pointer to the vector's data						
-	const float*			to_float_ptr() const;					
+	const float*		to_float_ptr() const;					
 
-	static const Vec2	ZERO;
-	static const Vec2	ONE;
-	static const Vec2	XAXIS;
-	static const Vec2	YAXIS;
+	static const Vector2	ZERO;
+	static const Vector2	ONE;
+	static const Vector2	XAXIS;
+	static const Vector2	YAXIS;
 };
 
 //-----------------------------------------------------------------------------
-inline Vec2::Vec2()
+inline Vector2::Vector2()
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2::Vec2(float val) : x(val), y(val)
+inline Vector2::Vector2(float val) : x(val), y(val)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2::Vec2(float nx, float ny) : x(nx), y(ny)
+inline Vector2::Vector2(float nx, float ny) : x(nx), y(ny)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2::Vec2(const float a[2]) : x(a[0]), y(a[1])
+inline Vector2::Vector2(const float a[2]) : x(a[0]), y(a[1])
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2::Vec2(const Vec2& a) : x(a.x), y(a.y)
+inline Vector2::Vector2(const Vector2& a) : x(a.x), y(a.y)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec2::operator[](uint32_t i) const
+inline float Vector2::operator[](uint32_t i) const
 {
 	CE_ASSERT(i < 2, "Index must be < 2");
 
@@ -161,7 +161,7 @@ inline float Vec2::operator[](uint32_t i) const
 }
 
 //-----------------------------------------------------------------------------
-inline float& Vec2::operator[](uint32_t i)
+inline float& Vector2::operator[](uint32_t i)
 {
 	CE_ASSERT(i < 2, "Index must be < 2");
 
@@ -169,13 +169,13 @@ inline float& Vec2::operator[](uint32_t i)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Vec2::operator+(const Vec2& a) const
+inline Vector2 Vector2::operator+(const Vector2& a) const
 {
-	return Vec2(x + a.x, y + a.y);
+	return Vector2(x + a.x, y + a.y);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2& Vec2::operator+=(const Vec2& a)
+inline Vector2& Vector2::operator+=(const Vector2& a)
 {
 	x += a.x;
 	y += a.y;
@@ -184,13 +184,13 @@ inline Vec2& Vec2::operator+=(const Vec2& a)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Vec2::operator-(const Vec2& a) const
+inline Vector2 Vector2::operator-(const Vector2& a) const
 {
-	return Vec2(x - a.x, y - a.y);
+	return Vector2(x - a.x, y - a.y);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2& Vec2::operator-=(const Vec2& a)
+inline Vector2& Vector2::operator-=(const Vector2& a)
 {
 	x -= a.x;
 	y -= a.y;
@@ -199,13 +199,13 @@ inline Vec2& Vec2::operator-=(const Vec2& a)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Vec2::operator*(float k) const
+inline Vector2 Vector2::operator*(float k) const
 {
-	return Vec2(x * k, y * k);
+	return Vector2(x * k, y * k);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2& Vec2::operator*=(float k)
+inline Vector2& Vector2::operator*=(float k)
 {
 	x *= k;
 	y *= k;
@@ -214,17 +214,17 @@ inline Vec2& Vec2::operator*=(float k)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Vec2::operator/(float k) const
+inline Vector2 Vector2::operator/(float k) const
 {
 	CE_ASSERT(k != (float)0.0, "Division by zero");
 
 	float inv = (float)(1.0 / k);
 
-	return Vec2(x * inv, y * inv);
+	return Vector2(x * inv, y * inv);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2& Vec2::operator/=(float k)
+inline Vector2& Vector2::operator/=(float k)
 {
 	CE_ASSERT(k != (float)0.0, "Division by zero");
 
@@ -237,49 +237,49 @@ inline Vec2& Vec2::operator/=(float k)
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec2::dot(const Vec2& a) const
+inline float Vector2::dot(const Vector2& a) const
 {
 	return x * a.x + y * a.y;
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec2::operator==(const Vec2& other) const
+inline bool Vector2::operator==(const Vector2& other) const
 {
 	return math::equals(x, other.x) && math::equals(y, other.y);
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec2::operator!=(const Vec2& other) const
+inline bool Vector2::operator!=(const Vector2& other) const
 {
 	return !math::equals(x, other.x) || !math::equals(y, other.y);
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec2::operator<(const Vec2& other) const
+inline bool Vector2::operator<(const Vector2& other) const
 {
 	return ((x < other.x) && (y < other.y));
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec2::operator>(const Vec2& other) const
+inline bool Vector2::operator>(const Vector2& other) const
 {
 	return ((x > other.x) && (y > other.y));
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec2::length() const
+inline float Vector2::length() const
 {
 	return math::sqrt(x * x + y * y);
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec2::squared_length() const
+inline float Vector2::squared_length() const
 {
 	return x * x + y * y;
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec2::set_length(float len)
+inline void Vector2::set_length(float len)
 {
 	normalize();
 
@@ -288,19 +288,19 @@ inline void Vec2::set_length(float len)
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec2::get_angle() const
+inline float Vector2::get_angle() const
 {
 	return math::atan2(y, x);
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec2::get_angle_2d() const
+inline float Vector2::get_angle_2d() const
 {
 	return math::atan2(-y, x);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2& Vec2::normalize()
+inline Vector2& Vector2::normalize()
 {
 	float len = length();
 
@@ -316,15 +316,15 @@ inline Vec2& Vec2::normalize()
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Vec2::get_normalized() const
+inline Vector2 Vector2::get_normalized() const
 {
-	Vec2 tmp(x, y);
+	Vector2 tmp(x, y);
 
 	return tmp.normalize();
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2& Vec2::negate()
+inline Vector2& Vector2::negate()
 {
 	x = -x;
 	y = -y;
@@ -333,44 +333,44 @@ inline Vec2& Vec2::negate()
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Vec2::operator-() const
+inline Vector2 Vector2::operator-() const
 {
-	return Vec2(-x, -y);
+	return Vector2(-x, -y);
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec2::get_distance_to(const Vec2& a) const
+inline float Vector2::get_distance_to(const Vector2& a) const
 {
 	return (*this - a).length();
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec2::get_angle_between(const Vec2& a) const
+inline float Vector2::get_angle_between(const Vector2& a) const
 {
 	return math::acos(this->dot(a) / (this->length() * a.length()));
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec2::zero()
+inline void Vector2::zero()
 {
 	x = 0.0;
 	y = 0.0;
 }
 
 //-----------------------------------------------------------------------------
-inline float* Vec2::to_float_ptr()
+inline float* Vector2::to_float_ptr()
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline const float* Vec2::to_float_ptr() const
+inline const float* Vector2::to_float_ptr() const
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 get_projected_parallel(const Vec2& v, const Vec2& n)
+inline Vector2 get_projected_parallel(const Vector2& v, const Vector2& n)
 {
 	float n_len_q;
 	n_len_q = n.length();
@@ -380,13 +380,13 @@ inline Vec2 get_projected_parallel(const Vec2& v, const Vec2& n)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 get_projected_perpendicular(const Vec2& v, const Vec2& n)
+inline Vector2 get_projected_perpendicular(const Vector2& v, const Vector2& n)
 {
 	return v - get_projected_parallel(v, n);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 operator*(float k, const Vec2& a)
+inline Vector2 operator*(float k, const Vector2& a)
 {
 	return a * k;
 }

+ 6 - 6
engine/core/math/Vec3.cpp → engine/core/math/Vector3.cpp

@@ -24,16 +24,16 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Vec3.h"
+#include "Vector3.h"
 
 namespace crown
 {
 
-const Vec3 Vec3::ZERO	= Vec3(0.0, 0.0, 0.0);
-const Vec3 Vec3::ONE	= Vec3(1.0, 1.0, 1.0);
-const Vec3 Vec3::XAXIS	= Vec3(1.0, 0.0, 0.0);
-const Vec3 Vec3::YAXIS	= Vec3(0.0, 1.0, 0.0);
-const Vec3 Vec3::ZAXIS	= Vec3(0.0, 0.0, 1.0);
+const Vector3 Vector3::ZERO	= Vector3(0.0, 0.0, 0.0);
+const Vector3 Vector3::ONE	= Vector3(1.0, 1.0, 1.0);
+const Vector3 Vector3::XAXIS	= Vector3(1.0, 0.0, 0.0);
+const Vector3 Vector3::YAXIS	= Vector3(0.0, 1.0, 0.0);
+const Vector3 Vector3::ZAXIS	= Vector3(0.0, 0.0, 1.0);
 
 } // namespace crown
 

+ 81 - 81
engine/core/math/Vec3.h → engine/core/math/Vector3.h

@@ -29,30 +29,30 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Assert.h"
 #include "Types.h"
 #include "MathUtils.h"
-#include "Vec2.h"
+#include "Vector2.h"
 
 namespace crown
 {
 
 /// 3D column vector.
-class Vec3
+class Vector3
 {
 public:
 
 	float				x, y, z;
 
 	/// Does nothing for efficiency.
-						Vec3();	
+						Vector3();	
 
 	/// Initializes all the components to val								
-						Vec3(float val);	
+						Vector3(float val);	
 
 	/// Constructs from three components						
-						Vec3(float nx, float ny, float nz);
+						Vector3(float nx, float ny, float nz);
 						
 	/// Constructs from array		
-						Vec3(const float v[3]);					
-						Vec3(const Vec3& a);	
+						Vector3(const float v[3]);					
+						Vector3(const Vector3& a);	
 
 	/// Random access by index
 	float				operator[](uint32_t i) const;
@@ -60,32 +60,32 @@ public:
 	/// Random access by index			
 	float&				operator[](uint32_t i);					
 
-	Vec3				operator+(const Vec3& a) const;			
-	Vec3&				operator+=(const Vec3& a);				
-	Vec3 				operator-(const Vec3& a) const;			
-	Vec3&				operator-=(const Vec3& a);				
-	Vec3				operator*(float k) const;				
-	Vec3&				operator*=(float k);						
-	Vec3				operator/(float k) const;				
-	Vec3&				operator/=(float k);
+	Vector3				operator+(const Vector3& a) const;			
+	Vector3&			operator+=(const Vector3& a);				
+	Vector3 			operator-(const Vector3& a) const;			
+	Vector3&			operator-=(const Vector3& a);				
+	Vector3				operator*(float k) const;				
+	Vector3&			operator*=(float k);						
+	Vector3				operator/(float k) const;				
+	Vector3&			operator/=(float k);
 
 	/// Dot product						
-	float				dot(const Vec3& a) const;
+	float				dot(const Vector3& a) const;
 
 	/// Cross product				
-	Vec3				cross(const Vec3& a) const;				
+	Vector3				cross(const Vector3& a) const;				
 
 	/// For simmetry
-	friend Vec3			operator*(float k, const Vec3& a);		
+	friend Vector3		operator*(float k, const Vector3& a);		
 
-	bool				operator==(const Vec3& other) const;	
-	bool				operator!=(const Vec3& other) const;
+	bool				operator==(const Vector3& other) const;	
+	bool				operator!=(const Vector3& other) const;
 
 	/// Returns whether all the components of this vector are smaller than all of the "other" vector	
-	bool				operator<(const Vec3& other) const;
+	bool				operator<(const Vector3& other) const;
 
 	/// Returns whether all the components of this vector are greater than all of the "other" vector		
-	bool				operator>(const Vec3& other) const;		
+	bool				operator>(const Vector3& other) const;		
 
 	/// Returns the vector's length
 	float				length() const;	
@@ -97,22 +97,22 @@ public:
 	void				set_length(float len);
 
 	/// Normalizes the vector					
-	Vec3&				normalize();
+	Vector3&			normalize();
 
 	/// Returns the normalized vector							
-	Vec3				get_normalized() const;		
+	Vector3				get_normalized() const;		
 
 	/// Negates the vector (i.e. builds the inverse)			
-	Vec3&				negate();
+	Vector3&			negate();
 
 	/// Negates the vector (i.e. builds the inverse)								
-	Vec3				operator-() const;						
+	Vector3				operator-() const;						
 
 	/// Returns the distance
-	float				get_distance_to(const Vec3& a) const;	
+	float				get_distance_to(const Vector3& a) const;	
 
 	/// Returns the angle in radians
-	float				get_angle_between(const Vec3& a) const;	
+	float				get_angle_between(const Vector3& a) const;	
 
 	/// Sets all components to zero
 	void				zero();									
@@ -121,45 +121,45 @@ public:
 	float*				to_float_ptr();	
 
 	/// Returns the pointer to the vector's data						
-	const float*			to_float_ptr() const;
+	const float*		to_float_ptr() const;
 
-	/// Returns a Vec2 with only x and y coordinates					
-	Vec2				to_vec2() const;						
+	/// Returns a Vector2 with only x and y coordinates					
+	Vector2				to_vec2() const;						
 
-	static const Vec3	ZERO;
-	static const Vec3	ONE;
-	static const Vec3	XAXIS;
-	static const Vec3	YAXIS;
-	static const Vec3	ZAXIS;
+	static const Vector3	ZERO;
+	static const Vector3	ONE;
+	static const Vector3	XAXIS;
+	static const Vector3	YAXIS;
+	static const Vector3	ZAXIS;
 };
 
 //-----------------------------------------------------------------------------
-inline Vec3::Vec3()
+inline Vector3::Vector3()
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3::Vec3(float val) : x(val), y(val), z(val)
+inline Vector3::Vector3(float val) : x(val), y(val), z(val)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3::Vec3(float nx, float ny, float nz) : x(nx), y(ny), z(nz)
+inline Vector3::Vector3(float nx, float ny, float nz) : x(nx), y(ny), z(nz)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3::Vec3(const float v[3]) : x(v[0]), y(v[1]), z(v[2])
+inline Vector3::Vector3(const float v[3]) : x(v[0]), y(v[1]), z(v[2])
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3::Vec3(const Vec3& a) : x(a.x), y(a.y), z(a.z)
+inline Vector3::Vector3(const Vector3& a) : x(a.x), y(a.y), z(a.z)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec3::operator[](uint32_t i) const
+inline float Vector3::operator[](uint32_t i) const
 {
 	CE_ASSERT(i < 3, "Index must be < 3");
 
@@ -167,7 +167,7 @@ inline float Vec3::operator[](uint32_t i) const
 }
 
 //-----------------------------------------------------------------------------
-inline float& Vec3::operator[](uint32_t i)
+inline float& Vector3::operator[](uint32_t i)
 {
 	CE_ASSERT(i < 3, "Index must be < 3");
 
@@ -175,13 +175,13 @@ inline float& Vec3::operator[](uint32_t i)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Vec3::operator+(const Vec3& a) const
+inline Vector3 Vector3::operator+(const Vector3& a) const
 {
-	return Vec3(x + a.x, y + a.y, z + a.z);
+	return Vector3(x + a.x, y + a.y, z + a.z);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3& Vec3::operator+=(const Vec3& a)
+inline Vector3& Vector3::operator+=(const Vector3& a)
 {
 	x += a.x;
 	y += a.y;
@@ -191,13 +191,13 @@ inline Vec3& Vec3::operator+=(const Vec3& a)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Vec3::operator-(const Vec3& a) const
+inline Vector3 Vector3::operator-(const Vector3& a) const
 {
-	return Vec3(x - a.x, y - a.y, z - a.z);
+	return Vector3(x - a.x, y - a.y, z - a.z);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3& Vec3::operator-=(const Vec3& a)
+inline Vector3& Vector3::operator-=(const Vector3& a)
 {
 	x -= a.x;
 	y -= a.y;
@@ -207,13 +207,13 @@ inline Vec3& Vec3::operator-=(const Vec3& a)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Vec3::operator*(float k) const
+inline Vector3 Vector3::operator*(float k) const
 {
-	return Vec3(x * k, y * k, z * k);
+	return Vector3(x * k, y * k, z * k);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3& Vec3::operator*=(float k)
+inline Vector3& Vector3::operator*=(float k)
 {
 	x *= k;
 	y *= k;
@@ -223,17 +223,17 @@ inline Vec3& Vec3::operator*=(float k)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Vec3::operator/(float k) const
+inline Vector3 Vector3::operator/(float k) const
 {
 	CE_ASSERT(k != (float)0.0, "Division by zero");
 
 	float inv = (float)(1.0 / k);
 
-	return Vec3(x * inv, y * inv, z * inv);
+	return Vector3(x * inv, y * inv, z * inv);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3& Vec3::operator/=(float k)
+inline Vector3& Vector3::operator/=(float k)
 {
 	CE_ASSERT(k != (float)0.0, "Division by zero");
 
@@ -247,61 +247,61 @@ inline Vec3& Vec3::operator/=(float k)
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec3::dot(const Vec3& a) const
+inline float Vector3::dot(const Vector3& a) const
 {
 	return x * a.x + y * a.y + z * a.z;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Vec3::cross(const Vec3& a) const
+inline Vector3 Vector3::cross(const Vector3& a) const
 {
-	return Vec3(y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x);
+	return Vector3(y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 operator*(float k, const Vec3& a)
+inline Vector3 operator*(float k, const Vector3& a)
 {
 	return a * k;
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec3::operator==(const Vec3& other) const
+inline bool Vector3::operator==(const Vector3& other) const
 {
 	return math::equals(x, other.x) && math::equals(y, other.y) && math::equals(z, other.z);
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec3::operator!=(const Vec3& other) const
+inline bool Vector3::operator!=(const Vector3& other) const
 {
 	return !math::equals(x, other.x) || !math::equals(y, other.y) || !math::equals(z, other.z);
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec3::operator<(const Vec3& other) const
+inline bool Vector3::operator<(const Vector3& other) const
 {
 	return ((x < other.x) && (y < other.y) && (z < other.z));
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec3::operator>(const Vec3& other) const
+inline bool Vector3::operator>(const Vector3& other) const
 {
 	return ((x > other.x) && (y > other.y) && (z > other.z));
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec3::length() const
+inline float Vector3::length() const
 {
 	return math::sqrt(x * x + y * y + z * z);
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec3::squared_length() const
+inline float Vector3::squared_length() const
 {
 	return x * x + y * y + z * z;
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec3::set_length(float len)
+inline void Vector3::set_length(float len)
 {
 	normalize();
 
@@ -311,7 +311,7 @@ inline void Vec3::set_length(float len)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3& Vec3::normalize()
+inline Vector3& Vector3::normalize()
 {
 	float len = length();
 
@@ -330,15 +330,15 @@ inline Vec3& Vec3::normalize()
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Vec3::get_normalized() const
+inline Vector3 Vector3::get_normalized() const
 {
-	Vec3 tmp(x, y, z);
+	Vector3 tmp(x, y, z);
 
 	return tmp.normalize();
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3& Vec3::negate()
+inline Vector3& Vector3::negate()
 {
 	x = -x;
 	y = -y;
@@ -348,25 +348,25 @@ inline Vec3& Vec3::negate()
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Vec3::operator-() const
+inline Vector3 Vector3::operator-() const
 {
-	return Vec3(-x, -y, -z);
+	return Vector3(-x, -y, -z);
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec3::get_distance_to(const Vec3& a) const
+inline float Vector3::get_distance_to(const Vector3& a) const
 {
 	return (*this - a).length();
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec3::get_angle_between(const Vec3& a) const
+inline float Vector3::get_angle_between(const Vector3& a) const
 {
 	return math::acos(this->dot(a) / (this->length() * a.length()));
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec3::zero()
+inline void Vector3::zero()
 {
 	x = 0.0;
 	y = 0.0;
@@ -374,26 +374,26 @@ inline void Vec3::zero()
 }
 
 //-----------------------------------------------------------------------------
-inline float* Vec3::to_float_ptr()
+inline float* Vector3::to_float_ptr()
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline const float* Vec3::to_float_ptr() const
+inline const float* Vector3::to_float_ptr() const
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec2 Vec3::to_vec2() const
+inline Vector2 Vector3::to_vec2() const
 {
-	return Vec2(x, y);
+	return Vector2(x, y);
 }
 
 //-----------------------------------------------------------------------------
 /// Returns the parallel portion of "v" projected onto "n"
-inline Vec3 get_projected_parallel(const Vec3& v, const Vec3& n)
+inline Vector3 get_projected_parallel(const Vector3& v, const Vector3& n)
 {
 	float n_len_q;
 	n_len_q = n.length();
@@ -404,7 +404,7 @@ inline Vec3 get_projected_parallel(const Vec3& v, const Vec3& n)
 
 //-----------------------------------------------------------------------------
 /// Returns the perpendicular portion of "v" projected onto "n"
-inline Vec3 get_projected_perpendicular(const Vec3& v, const Vec3& n)
+inline Vector3 get_projected_perpendicular(const Vector3& v, const Vector3& n)
 {
 	return v - get_projected_parallel(v, n);
 }

+ 7 - 7
engine/core/math/Vec4.cpp → engine/core/math/Vector4.cpp

@@ -24,18 +24,18 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Vec4.h"
+#include "Vector4.h"
 #include "Types.h"
 
 namespace crown
 {
 
-const Vec4 Vec4::ZERO	= Vec4(0.0, 0.0, 0.0, 0.0);
-const Vec4 Vec4::ONE	= Vec4(1.0, 1.0, 1.0, 1.0);
-const Vec4 Vec4::XAXIS	= Vec4(1.0, 0.0, 0.0, 0.0);
-const Vec4 Vec4::YAXIS	= Vec4(0.0, 1.0, 0.0, 0.0);
-const Vec4 Vec4::ZAXIS	= Vec4(0.0, 0.0, 1.0, 0.0);
-const Vec4 Vec4::WAXIS	= Vec4(0.0, 0.0, 0.0, 1.0);
+const Vector4 Vector4::ZERO	= Vector4(0.0, 0.0, 0.0, 0.0);
+const Vector4 Vector4::ONE	= Vector4(1.0, 1.0, 1.0, 1.0);
+const Vector4 Vector4::XAXIS	= Vector4(1.0, 0.0, 0.0, 0.0);
+const Vector4 Vector4::YAXIS	= Vector4(0.0, 1.0, 0.0, 0.0);
+const Vector4 Vector4::ZAXIS	= Vector4(0.0, 0.0, 1.0, 0.0);
+const Vector4 Vector4::WAXIS	= Vector4(0.0, 0.0, 0.0, 1.0);
 
 } // namespace crown
 

+ 72 - 72
engine/core/math/Vec4.h → engine/core/math/Vector4.h

@@ -34,24 +34,24 @@ namespace crown
 {
 
 /// 4D column vector.
-class Vec4
+class Vector4
 {
 public:
 
 	float				x, y, z, w;
 
 	/// Does nothing for efficiency.
-						Vec4();	
+						Vector4();	
 
 	/// Initializes all the components to val						
-						Vec4(float val);
+						Vector4(float val);
 
 	/// Constructs from four components								
-						Vec4(float nx, float ny, float nz, float nw);
+						Vector4(float nx, float ny, float nz, float nw);
 
 	/// Constructs from array	
-						Vec4(const float v[4]);						
-						Vec4(const Vec4& a);
+						Vector4(const float v[4]);						
+						Vector4(const Vector4& a);
 
 	/// Random access by index
 	float				operator[](uint32_t i) const;	
@@ -59,29 +59,29 @@ public:
 	/// Random access by index
 	float&				operator[](uint32_t i);						
 
-	Vec4				operator+(const Vec4& a) const;				
-	Vec4&				operator+=(const Vec4& a);					
-	Vec4 				operator-(const Vec4& a) const;				
-	Vec4&				operator-=(const Vec4& a);					
-	Vec4				operator*(float k) const;					
-	Vec4&				operator*=(float k);							
-	Vec4				operator/(float k) const;					
-	Vec4&				operator/=(float k);
+	Vector4				operator+(const Vector4& a) const;				
+	Vector4&			operator+=(const Vector4& a);					
+	Vector4 			operator-(const Vector4& a) const;				
+	Vector4&			operator-=(const Vector4& a);					
+	Vector4				operator*(float k) const;					
+	Vector4&			operator*=(float k);							
+	Vector4				operator/(float k) const;					
+	Vector4&			operator/=(float k);
 
 	/// Dot product							
-	float				dot(const Vec4& a) const;					
+	float				dot(const Vector4& a) const;					
 
 	/// For simmetry
-	friend Vec4			operator*(float k, const Vec4& a);			
+	friend Vector4		operator*(float k, const Vector4& a);			
 
-	bool				operator==(const Vec4& other) const;		
-	bool				operator!=(const Vec4& other) const;
+	bool				operator==(const Vector4& other) const;		
+	bool				operator!=(const Vector4& other) const;
 
 	/// Returns whether all the components of this vector are smaller than all of the @a other vector	
-	bool				operator<(const Vec4& other) const;	
+	bool				operator<(const Vector4& other) const;	
 
 	/// Returns whether all the components of this vector are greater than all of the @a other vector		
-	bool				operator>(const Vec4& other) const;			
+	bool				operator>(const Vector4& other) const;			
 
 	/// Returns the vector's length
 	float				length() const;	
@@ -93,22 +93,22 @@ public:
 	void				set_length(float len);
 
 	/// Normalizes the vector						
-	Vec4&				normalize();
+	Vector4&			normalize();
 
 	/// Returns the normalized vector								
-	Vec4				get_normalized() const;
+	Vector4				get_normalized() const;
 
 	/// Negates the vector (i.e. builds the inverse)						
-	Vec4&				negate();	
+	Vector4&			negate();	
 
 	/// Negates the vector (i.e. builds the inverse)								
-	Vec4				operator-() const;							
+	Vector4				operator-() const;							
 
 	/// Returns the distance
-	float				get_distance_to(const Vec4& a) const;
+	float				get_distance_to(const Vector4& a) const;
 
 	/// Returns the angle in radians		
-	float				get_angle_between(const Vec4& a) const;		
+	float				get_angle_between(const Vector4& a) const;		
 
 	/// Sets all components to zero
 	void				zero();										
@@ -117,43 +117,43 @@ public:
 	float*				to_float_ptr();	
 
 	/// Returns the pointer to the vector's data							
-	const float*			to_float_ptr() const;						
-
-	static const Vec4	ZERO;
-	static const Vec4	ONE;
-	static const Vec4	XAXIS;
-	static const Vec4	YAXIS;
-	static const Vec4	ZAXIS;
-	static const Vec4	WAXIS;
+	const float*		to_float_ptr() const;						
+
+	static const Vector4	ZERO;
+	static const Vector4	ONE;
+	static const Vector4	XAXIS;
+	static const Vector4	YAXIS;
+	static const Vector4	ZAXIS;
+	static const Vector4	WAXIS;
 };
 
 //-----------------------------------------------------------------------------
-inline Vec4::Vec4()
+inline Vector4::Vector4()
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4::Vec4(float val) : x(val), y(val), z(val), w(val)
+inline Vector4::Vector4(float val) : x(val), y(val), z(val), w(val)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4::Vec4(float nx, float ny, float nz, float nw) : x(nx), y(ny), z(nz), w(nw)
+inline Vector4::Vector4(float nx, float ny, float nz, float nw) : x(nx), y(ny), z(nz), w(nw)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4::Vec4(const float a[4]) : x(a[0]), y(a[1]), z(a[2]), w(a[3])
+inline Vector4::Vector4(const float a[4]) : x(a[0]), y(a[1]), z(a[2]), w(a[3])
 {
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4::Vec4(const Vec4& a) : x(a.x), y(a.y), z(a.z), w(a.w)
+inline Vector4::Vector4(const Vector4& a) : x(a.x), y(a.y), z(a.z), w(a.w)
 {
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec4::operator[](uint32_t i) const
+inline float Vector4::operator[](uint32_t i) const
 {
 	CE_ASSERT(i < 4, "Index must be < 4");
 
@@ -161,7 +161,7 @@ inline float Vec4::operator[](uint32_t i) const
 }
 
 //-----------------------------------------------------------------------------
-inline float& Vec4::operator[](uint32_t i)
+inline float& Vector4::operator[](uint32_t i)
 {
 	CE_ASSERT(i < 4, "Index must be < 4");
 
@@ -169,13 +169,13 @@ inline float& Vec4::operator[](uint32_t i)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4 Vec4::operator+(const Vec4& a) const
+inline Vector4 Vector4::operator+(const Vector4& a) const
 {
-	return Vec4(x + a.x, y + a.y, z + a.z, w + a.w);
+	return Vector4(x + a.x, y + a.y, z + a.z, w + a.w);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4& Vec4::operator+=(const Vec4& a)
+inline Vector4& Vector4::operator+=(const Vector4& a)
 {
 	x += a.x;
 	y += a.y;
@@ -186,13 +186,13 @@ inline Vec4& Vec4::operator+=(const Vec4& a)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4 Vec4::operator-(const Vec4& a) const
+inline Vector4 Vector4::operator-(const Vector4& a) const
 {
-	return Vec4(x - a.x, y - a.y, z - a.z, w - a.w);
+	return Vector4(x - a.x, y - a.y, z - a.z, w - a.w);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4& Vec4::operator-=(const Vec4& a)
+inline Vector4& Vector4::operator-=(const Vector4& a)
 {
 	x -= a.x;
 	y -= a.y;
@@ -203,13 +203,13 @@ inline Vec4& Vec4::operator-=(const Vec4& a)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4 Vec4::operator*(float k) const
+inline Vector4 Vector4::operator*(float k) const
 {
-	return Vec4(x * k, y * k, z * k, w * k);
+	return Vector4(x * k, y * k, z * k, w * k);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4& Vec4::operator*=(float k)
+inline Vector4& Vector4::operator*=(float k)
 {
 	x *= k;
 	y *= k;
@@ -220,17 +220,17 @@ inline Vec4& Vec4::operator*=(float k)
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4 Vec4::operator/(float k) const
+inline Vector4 Vector4::operator/(float k) const
 {
 	CE_ASSERT(k != (float)0.0, "Division by zero");
 
 	float inv = (float)(1.0 / k);
 
-	return Vec4(x * inv, y * inv, z * inv, w * inv);
+	return Vector4(x * inv, y * inv, z * inv, w * inv);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4& Vec4::operator/=(float k)
+inline Vector4& Vector4::operator/=(float k)
 {
 	CE_ASSERT(k != (float)0.0, "Division by zero");
 
@@ -245,55 +245,55 @@ inline Vec4& Vec4::operator/=(float k)
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec4::dot(const Vec4& a) const
+inline float Vector4::dot(const Vector4& a) const
 {
 	return x * a.x + y * a.y + z * a.z + w * a.w;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4 operator*(float k, const Vec4& a)
+inline Vector4 operator*(float k, const Vector4& a)
 {
 	return a * k;
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec4::operator==(const Vec4& other) const
+inline bool Vector4::operator==(const Vector4& other) const
 {
 	return math::equals(x, other.x) && math::equals(y, other.y) && math::equals(z, other.z) && math::equals(w, other.w);
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec4::operator!=(const Vec4& other) const
+inline bool Vector4::operator!=(const Vector4& other) const
 {
 	return !math::equals(x, other.x) || !math::equals(y, other.y) || !math::equals(z, other.z) || !math::equals(w, other.w);
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec4::operator<(const Vec4& other) const
+inline bool Vector4::operator<(const Vector4& other) const
 {
 	return ((x < other.x) && (y < other.y) && (z < other.z) && (w < other.w));
 }
 
 //-----------------------------------------------------------------------------
-inline bool Vec4::operator>(const Vec4& other) const
+inline bool Vector4::operator>(const Vector4& other) const
 {
 	return ((x > other.x) && (y > other.y) && (z > other.z) && (w > other.w));
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec4::length() const
+inline float Vector4::length() const
 {
 	return math::sqrt(x * x + y * y + z * z + w * w);
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec4::squared_length() const
+inline float Vector4::squared_length() const
 {
 	return x * x + y * y + z * z + w * w;
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4& Vec4::normalize()
+inline Vector4& Vector4::normalize()
 {
 	float len = length();
 
@@ -313,15 +313,15 @@ inline Vec4& Vec4::normalize()
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4 Vec4::get_normalized() const
+inline Vector4 Vector4::get_normalized() const
 {
-	Vec4 tmp(x, y, z, w);
+	Vector4 tmp(x, y, z, w);
 
 	return tmp.normalize();
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4& Vec4::negate()
+inline Vector4& Vector4::negate()
 {
 	x = -x;
 	y = -y;
@@ -332,25 +332,25 @@ inline Vec4& Vec4::negate()
 }
 
 //-----------------------------------------------------------------------------
-inline Vec4 Vec4::operator-() const
+inline Vector4 Vector4::operator-() const
 {
-	return Vec4(-x, -y, -z, -w);
+	return Vector4(-x, -y, -z, -w);
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec4::get_distance_to(const Vec4& a) const
+inline float Vector4::get_distance_to(const Vector4& a) const
 {
 	return (*this - a).length();
 }
 
 //-----------------------------------------------------------------------------
-inline float Vec4::get_angle_between(const Vec4& a) const
+inline float Vector4::get_angle_between(const Vector4& a) const
 {
 	return math::acos(this->dot(a) / (this->length() * a.length()));
 }
 
 //-----------------------------------------------------------------------------
-inline void Vec4::zero()
+inline void Vector4::zero()
 {
 	x = 0.0;
 	y = 0.0;
@@ -359,13 +359,13 @@ inline void Vec4::zero()
 }
 
 //-----------------------------------------------------------------------------
-inline float* Vec4::to_float_ptr()
+inline float* Vector4::to_float_ptr()
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline const float* Vec4::to_float_ptr() const
+inline const float* Vector4::to_float_ptr() const
 {
 	return &x;
 }

+ 3 - 3
engine/input/Accelerometer.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "Vec3.h"
+#include "Vector3.h"
 
 namespace crown
 {
@@ -43,14 +43,14 @@ struct Accelerometer
 
 	/// Returns the orientation of the accelerometer.
 	/// FIXME NEED MORE DOCUMENTATION
-	const Vec3& orientation() const
+	const Vector3& orientation() const
 	{
 		return m_orientation;
 	}
 
 public:
 
-	Vec3			m_orientation;
+	Vector3			m_orientation;
 };
 
 } // namespace crown

+ 8 - 8
engine/input/Mouse.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include <cstring>
 #include "Types.h"
-#include "Vec2.h"
+#include "Vector2.h"
 
 namespace crown
 {
@@ -88,9 +88,9 @@ public:
 	/// Coordinates in window space have the origin at the
 	/// upper-left corner of the window. +X extends from left
 	/// to right and +Y extends from top to bottom.
-	Vec2 cursor_xy()
+	Vector2 cursor_xy()
 	{
-		return Vec2(m_x, m_y);
+		return Vector2(m_x, m_y);
 	}
 
 	/// Sets the position of the cursor in window space.
@@ -98,7 +98,7 @@ public:
 	/// Coordinates in window space have the origin at the
 	/// upper-left corner of the window. +X extends from left
 	/// to right and +Y extends from top to bottom.
-	void set_cursor_xy(const Vec2& position)
+	void set_cursor_xy(const Vector2& position)
 	{
 		m_x = (uint16_t) position.x;
 		m_y = (uint16_t) position.y;
@@ -113,9 +113,9 @@ public:
 	/// Relative coordinates are mapped to a float varying
 	/// from 0.0 to 1.0 where 0.0 is the origin and 1.0 the
 	/// maximum extent of the cosidered axis.
-	Vec2 cursor_relative_xy()
+	Vector2 cursor_relative_xy()
 	{
-		return Vec2(m_x / m_width, m_y / m_height);
+		return Vector2(m_x / m_width, m_y / m_height);
 	}
 
 	/// Sets the relative position of the cursor in window space.
@@ -127,9 +127,9 @@ public:
 	/// Relative coordinates are mapped to a float varying
 	/// from 0.0 to 1.0 where 0.0 is the origin and 1.0 the
 	/// maximum extent of the cosidered axis.
-	void set_cursor_relative_xy(const Vec2& position)
+	void set_cursor_relative_xy(const Vector2& position)
 	{
-		set_cursor_xy(Vec2(position.x * (float) m_width, position.y * (float) m_height));
+		set_cursor_xy(Vector2(position.x * (float) m_width, position.y * (float) m_height));
 	}
 
 	//-----------------------------------------------------------------------------

+ 5 - 5
engine/input/Touch.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "Vec2.h"
+#include "Vector2.h"
 
 namespace crown
 {
@@ -63,11 +63,11 @@ struct Touch
 	/// Coordinates in window space have the origin at the
 	/// upper-left corner of the window. +X extends from left
 	/// to right and +Y extends from top to bottom.
-	Vec2 touch_xy(uint16_t id) const
+	Vector2 touch_xy(uint16_t id) const
 	{
 		const PointerData& data = m_pointers[id];
 
-		return Vec2(data.x, data.y);
+		return Vector2(data.x, data.y);
 	}
 
 	/// Returns the relative position of the pointer @a id in window space.
@@ -79,11 +79,11 @@ struct Touch
 	/// Relative coordinates are mapped to a float varying
 	/// from 0.0 to 1.0 where 0.0 is the origin and 1.0 the
 	/// maximum extent of the cosidered axis.
-	Vec2 touch_relative_xy(uint16_t id)
+	Vector2 touch_relative_xy(uint16_t id)
 	{
 		const PointerData& data = m_pointers[id];
 
-		return Vec2(data.relative_x, data.relative_y);
+		return Vector2(data.relative_x, data.relative_y);
 	}
 
 public:

+ 1 - 1
engine/lua/LuaAccelerometer.cpp

@@ -37,7 +37,7 @@ CE_EXPORT int accelerometer_orientation(lua_State* L)
 {
 	LuaStack stack(L);
 
-	stack.push_vec3(device()->accelerometer()->orientation());
+	stack.push_vector3(device()->accelerometer()->orientation());
 
 	return 1;
 }

+ 12 - 12
engine/lua/LuaCamera.cpp

@@ -25,9 +25,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "Camera.h"
-#include "Vec3.h"
-#include "Quat.h"
-#include "Mat4.h"
+#include "Vector3.h"
+#include "Quaternion.h"
+#include "Matrix4x4.h"
 #include "LuaStack.h"
 #include "LuaEnvironment.h"
 
@@ -41,7 +41,7 @@ CE_EXPORT int camera_local_position(lua_State* L)
 
 	Camera* camera = stack.get_camera(1);
 
-	stack.push_vec3(camera->local_position());
+	stack.push_vector3(camera->local_position());
 	return 1;
 }
 
@@ -52,7 +52,7 @@ CE_EXPORT int camera_local_rotation(lua_State* L)
 
 	Camera* camera = stack.get_camera(1);
 
-	stack.push_quat(camera->local_rotation());
+	stack.push_quaternion(camera->local_rotation());
 	return 1;
 }
 
@@ -63,7 +63,7 @@ CE_EXPORT int camera_local_pose(lua_State* L)
 
 	Camera* camera = stack.get_camera(1);
 
-	stack.push_mat4(camera->local_pose());
+	stack.push_matrix4x4(camera->local_pose());
 	return 1;
 }
 
@@ -74,7 +74,7 @@ CE_EXPORT int camera_world_position(lua_State* L)
 
 	Camera* camera = stack.get_camera(1);
 
-	stack.push_vec3(camera->world_position());
+	stack.push_vector3(camera->world_position());
 	return 1;
 }
 
@@ -85,7 +85,7 @@ CE_EXPORT int camera_world_rotation(lua_State* L)
 
 	Camera* camera = stack.get_camera(1);
 
-	stack.push_quat(camera->world_rotation());
+	stack.push_quaternion(camera->world_rotation());
 	return 1;
 }
 
@@ -96,7 +96,7 @@ CE_EXPORT int camera_world_pose(lua_State* L)
 
 	Camera* camera = stack.get_camera(1);
 
-	stack.push_mat4(camera->world_pose());
+	stack.push_matrix4x4(camera->world_pose());
 	return 1;
 }
 
@@ -106,7 +106,7 @@ CE_EXPORT int camera_set_local_position(lua_State* L)
 	LuaStack stack(L);
 
 	Camera* camera = stack.get_camera(1);
-	const Vec3 pos = stack.get_vec3(2);
+	const Vector3 pos = stack.get_vector3(2);
 
 	camera->set_local_position(pos);
 	return 0;
@@ -118,7 +118,7 @@ CE_EXPORT int camera_set_local_rotation(lua_State* L)
 	LuaStack stack(L);
 
 	Camera* camera = stack.get_camera(1);
-	const Quat rot = stack.get_quat(2);
+	const Quaternion rot = stack.get_quaternion(2);
 
 	camera->set_local_rotation(rot);
 	return 0;
@@ -130,7 +130,7 @@ CE_EXPORT int camera_set_local_pose(lua_State* L)
 	LuaStack stack(L);
 
 	Camera* camera = stack.get_camera(1);
-	const Mat4 pose = stack.get_mat4(2);
+	const Matrix4x4 pose = stack.get_matrix4x4(2);
 
 	camera->set_local_pose(pose);
 	return 0;

+ 4 - 4
engine/lua/LuaEnvironment.cpp

@@ -46,10 +46,10 @@ CE_EXPORT int luaopen_libcrown(lua_State* /*L*/)
 	load_float_setting(*env);
 	load_string_setting(*env);
 
-	load_vec2(*env);
-	load_vec3(*env);
-	load_mat4(*env);
-	load_quat(*env);
+	load_vector2(*env);
+	load_vector3(*env);
+	load_matrix4x4(*env);
+	load_quaternion(*env);
 	load_math(*env);
 	load_window(*env);
 	load_mouse(*env);

+ 4 - 4
engine/lua/LuaEnvironment.h

@@ -96,10 +96,10 @@ void load_int_setting(LuaEnvironment& env);
 void load_float_setting(LuaEnvironment& env);
 void load_string_setting(LuaEnvironment& env);
 
-void load_vec2(LuaEnvironment& env);
-void load_vec3(LuaEnvironment& env);
-void load_mat4(LuaEnvironment& env);
-void load_quat(LuaEnvironment& env);
+void load_vector2(LuaEnvironment& env);
+void load_vector3(LuaEnvironment& env);
+void load_matrix4x4(LuaEnvironment& env);
+void load_quaternion(LuaEnvironment& env);
 void load_math(LuaEnvironment& env);
 void load_mouse(LuaEnvironment& env);
 void load_keyboard(LuaEnvironment& env);

+ 139 - 139
engine/lua/LuaMat4.cpp → engine/lua/LuaMatrix4x4.cpp

@@ -24,8 +24,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Mat4.h"
-#include "Vec3.h"
+#include "Matrix4x4.h"
+#include "Vector3.h"
 #include "LuaStack.h"
 #include "LuaEnvironment.h"
 #include "OS.h"
@@ -34,7 +34,7 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4(lua_State* L)
+CE_EXPORT int matrix4x4(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -55,82 +55,82 @@ CE_EXPORT int mat4(lua_State* L)
 	float m14 = stack.get_float(15);
 	float m15 = stack.get_float(16);
 
-	stack.push_mat4(Mat4(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15));
+	stack.push_matrix4x4(Matrix4x4(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15));
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------					
-CE_EXPORT int mat4_add(lua_State* L)
+CE_EXPORT int matrix4x4_add(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Mat4& b = stack.get_mat4(2);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Matrix4x4& b = stack.get_matrix4x4(2);
 
-	stack.push_mat4(a + b);
+	stack.push_matrix4x4(a + b);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_subtract(lua_State* L)
+CE_EXPORT int matrix4x4_subtract(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Mat4& b = stack.get_mat4(2);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Matrix4x4& b = stack.get_matrix4x4(2);
 
-	stack.push_mat4(a - b);
+	stack.push_matrix4x4(a - b);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_multiply(lua_State* L)
+CE_EXPORT int matrix4x4_multiply(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Mat4& b = stack.get_mat4(2);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Matrix4x4& b = stack.get_matrix4x4(2);
 
-	stack.push_mat4(a * b);
+	stack.push_matrix4x4(a * b);
 
 	return 1;
 }	
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_multiply_by_scalar(lua_State* L)
+CE_EXPORT int matrix4x4_multiply_by_scalar(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float k = stack.get_float(2);
 
-	stack.push_mat4(a * k);
+	stack.push_matrix4x4(a * k);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_divide_by_scalar(lua_State* L)
+CE_EXPORT int matrix4x4_divide_by_scalar(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float k = stack.get_float(2);
 
-	stack.push_mat4(a / k);
+	stack.push_matrix4x4(a / k);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_rotation_x(lua_State* L)
+CE_EXPORT int matrix4x4_build_rotation_x(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float k = stack.get_float(2);
 
 	a.build_rotation_x(k);
@@ -139,11 +139,11 @@ CE_EXPORT int mat4_build_rotation_x(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_rotation_y(lua_State* L)
+CE_EXPORT int matrix4x4_build_rotation_y(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float k = stack.get_float(2);
 
 	a.build_rotation_y(k);
@@ -152,11 +152,11 @@ CE_EXPORT int mat4_build_rotation_y(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_rotation_z(lua_State* L)
+CE_EXPORT int matrix4x4_build_rotation_z(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float k = stack.get_float(2);
 
 	a.build_rotation_z(k);
@@ -165,12 +165,12 @@ CE_EXPORT int mat4_build_rotation_z(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_rotation(lua_State* L)
+CE_EXPORT int matrix4x4_build_rotation(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& d = stack.get_vec3(2);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& d = stack.get_vector3(2);
 	float k = stack.get_float(3);
 
 	a.build_rotation(d, k);
@@ -179,11 +179,11 @@ CE_EXPORT int mat4_build_rotation(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_projection_perspective_rh(lua_State* L)
+CE_EXPORT int matrix4x4_build_projection_perspective_rh(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float fovy = stack.get_float(2);
 	float aspect = stack.get_float(3);
 	float near = stack.get_float(4);
@@ -195,11 +195,11 @@ CE_EXPORT int mat4_build_projection_perspective_rh(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_projection_perspective_lh(lua_State* L)
+CE_EXPORT int matrix4x4_build_projection_perspective_lh(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float fovy = stack.get_float(2);
 	float aspect = stack.get_float(3);
 	float near = stack.get_float(4);
@@ -211,11 +211,11 @@ CE_EXPORT int mat4_build_projection_perspective_lh(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_projection_ortho_rh(lua_State* L)
+CE_EXPORT int matrix4x4_build_projection_ortho_rh(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float width = stack.get_float(2);
 	float height = stack.get_float(3);
 	float near = stack.get_float(4);
@@ -227,11 +227,11 @@ CE_EXPORT int mat4_build_projection_ortho_rh(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_projection_ortho_lh(lua_State* L)
+CE_EXPORT int matrix4x4_build_projection_ortho_lh(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float width = stack.get_float(2);
 	float height = stack.get_float(3);
 	float near = stack.get_float(4);
@@ -243,11 +243,11 @@ CE_EXPORT int mat4_build_projection_ortho_lh(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_projection_ortho_2d_rh(lua_State* L)
+CE_EXPORT int matrix4x4_build_projection_ortho_2d_rh(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 	float width = stack.get_float(2);
 	float height = stack.get_float(3);
 	float near = stack.get_float(4);
@@ -259,14 +259,14 @@ CE_EXPORT int mat4_build_projection_ortho_2d_rh(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_look_at_rh(lua_State* L)
+CE_EXPORT int matrix4x4_build_look_at_rh(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& pos = stack.get_vec3(2);
-	Vec3& target = stack.get_vec3(3);
-	Vec3& up = stack.get_vec3(4);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& pos = stack.get_vector3(2);
+	Vector3& target = stack.get_vector3(3);
+	Vector3& up = stack.get_vector3(4);
 
 	a.build_look_at_rh(pos, target, up);
 
@@ -274,14 +274,14 @@ CE_EXPORT int mat4_build_look_at_rh(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_look_at_lh(lua_State* L)
+CE_EXPORT int matrix4x4_build_look_at_lh(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& pos = stack.get_vec3(2);
-	Vec3& target = stack.get_vec3(3);
-	Vec3& up = stack.get_vec3(4);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& pos = stack.get_vector3(2);
+	Vector3& target = stack.get_vector3(3);
+	Vector3& up = stack.get_vector3(4);
 
 	a.build_look_at_lh(pos, target, up);
 
@@ -289,14 +289,14 @@ CE_EXPORT int mat4_build_look_at_lh(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_viewpoint_billboard(lua_State* L)
+CE_EXPORT int matrix4x4_build_viewpoint_billboard(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& pos = stack.get_vec3(2);
-	Vec3& target = stack.get_vec3(3);
-	Vec3& up = stack.get_vec3(4);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& pos = stack.get_vector3(2);
+	Vector3& target = stack.get_vector3(3);
+	Vector3& up = stack.get_vector3(4);
 
 	a.build_viewpoint_billboard(pos, target, up);
 
@@ -304,14 +304,14 @@ CE_EXPORT int mat4_build_viewpoint_billboard(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_build_axis_billboard(lua_State* L)
+CE_EXPORT int matrix4x4_build_axis_billboard(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& pos = stack.get_vec3(2);
-	Vec3& target = stack.get_vec3(3);
-	Vec3& up = stack.get_vec3(4);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& pos = stack.get_vector3(2);
+	Vector3& target = stack.get_vector3(3);
+	Vector3& up = stack.get_vector3(4);
 
 	a.build_axis_billboard(pos, target, up);
 
@@ -319,23 +319,23 @@ CE_EXPORT int mat4_build_axis_billboard(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_transpose(lua_State* L)
+CE_EXPORT int matrix4x4_transpose(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
-	stack.push_mat4(a.transpose());
+	stack.push_matrix4x4(a.transpose());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_determinant(lua_State* L)
+CE_EXPORT int matrix4x4_determinant(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
 	stack.push_float(a.get_determinant());
 
@@ -343,23 +343,23 @@ CE_EXPORT int mat4_determinant(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_invert(lua_State* L)
+CE_EXPORT int matrix4x4_invert(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
-	stack.push_mat4(a.invert());
+	stack.push_matrix4x4(a.invert());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_load_identity(lua_State* L)
+CE_EXPORT int matrix4x4_load_identity(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
 	a.load_identity();
 
@@ -367,48 +367,48 @@ CE_EXPORT int mat4_load_identity(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_x(lua_State* L)
+CE_EXPORT int matrix4x4_x(lua_State* L)
 {	
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
-	stack.push_vec3(a.x());
+	stack.push_vector3(a.x());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_y(lua_State* L)
+CE_EXPORT int matrix4x4_y(lua_State* L)
 {	
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
-	stack.push_vec3(a.y());
+	stack.push_vector3(a.y());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_z(lua_State* L)
+CE_EXPORT int matrix4x4_z(lua_State* L)
 {	
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
-	stack.push_vec3(a.z());
+	stack.push_vector3(a.z());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_set_x(lua_State* L)
+CE_EXPORT int matrix4x4_set_x(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& x = stack.get_vec3(2);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& x = stack.get_vector3(2);
 
 	a.set_x(x);
 
@@ -416,12 +416,12 @@ CE_EXPORT int mat4_set_x(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_set_y(lua_State* L)
+CE_EXPORT int matrix4x4_set_y(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& y = stack.get_vec3(2);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& y = stack.get_vector3(2);
 
 	a.set_y(y);
 
@@ -429,12 +429,12 @@ CE_EXPORT int mat4_set_y(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_set_z(lua_State* L)
+CE_EXPORT int matrix4x4_set_z(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& z = stack.get_vec3(2);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& z = stack.get_vector3(2);
 
 	a.set_z(z);
 
@@ -442,24 +442,24 @@ CE_EXPORT int mat4_set_z(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_translation(lua_State* L)
+CE_EXPORT int matrix4x4_translation(lua_State* L)
 {	
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
-	stack.push_vec3(a.translation());
+	stack.push_vector3(a.translation());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_set_translation(lua_State* L)
+CE_EXPORT int matrix4x4_set_translation(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& trans = stack.get_vec3(2);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& trans = stack.get_vector3(2);
 
 	a.set_translation(trans);
 
@@ -467,24 +467,24 @@ CE_EXPORT int mat4_set_translation(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_get_scale(lua_State* L)
+CE_EXPORT int matrix4x4_get_scale(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
-	stack.push_vec3(a.get_scale());
+	stack.push_vector3(a.get_scale());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_set_scale(lua_State* L)
+CE_EXPORT int matrix4x4_set_scale(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
-	Vec3& scale = stack.get_vec3(2);
+	Matrix4x4& a = stack.get_matrix4x4(1);
+	Vector3& scale = stack.get_vector3(2);
 
 	a.set_scale(scale);
 
@@ -492,11 +492,11 @@ CE_EXPORT int mat4_set_scale(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int mat4_print(lua_State* L)
+CE_EXPORT int matrix4x4_print(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Mat4& a = stack.get_mat4(1);
+	Matrix4x4& a = stack.get_matrix4x4(1);
 
 	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", a.m[0], a.m[4], a.m[8], a.m[12]);
 	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", a.m[1], a.m[5], a.m[9], a.m[13]);
@@ -507,42 +507,42 @@ CE_EXPORT int mat4_print(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-void load_mat4(LuaEnvironment& env)
-{
-	env.load_module_function("Mat4", "new", 							mat4);
-	env.load_module_function("Mat4", "add", 							mat4_add);
-	env.load_module_function("Mat4", "sub", 							mat4_subtract);
-	env.load_module_function("Mat4", "mul", 							mat4_multiply);
-	env.load_module_function("Mat4", "muls", 							mat4_multiply_by_scalar);
-	env.load_module_function("Mat4", "divs", 							mat4_divide_by_scalar);
-	env.load_module_function("Mat4", "build_rotation_x", 				mat4_build_rotation_x);
-	env.load_module_function("Mat4", "build_rotation_y", 				mat4_build_rotation_y);
-	env.load_module_function("Mat4", "build_rotation_z", 				mat4_build_rotation_z);
-	env.load_module_function("Mat4", "build_rotation", 					mat4_build_rotation);
-	env.load_module_function("Mat4", "build_projection_perspective_rh", mat4_build_projection_perspective_rh);
-	env.load_module_function("Mat4", "build_projection_perspective_lh", mat4_build_projection_perspective_lh);
-	env.load_module_function("Mat4", "build_projection_ortho_rh", 		mat4_build_projection_ortho_rh);
-	env.load_module_function("Mat4", "build_projection_ortho_lh", 		mat4_build_projection_ortho_lh);
-	env.load_module_function("Mat4", "build_projection_ortho_2d_rh", 	mat4_build_projection_ortho_2d_rh);
-	env.load_module_function("Mat4", "build_look_at_rh", 				mat4_build_look_at_rh);
-	env.load_module_function("Mat4", "build_look_at_lh", 				mat4_build_look_at_rh);
-	env.load_module_function("Mat4", "build_viewpoint_billboard", 		mat4_build_viewpoint_billboard);
-	env.load_module_function("Mat4", "build_axis_billboard", 			mat4_build_axis_billboard);
-	env.load_module_function("Mat4", "transpose", 						mat4_transpose);
-	env.load_module_function("Mat4", "determinant", 					mat4_determinant);
-	env.load_module_function("Mat4", "invert", 							mat4_invert);
-	env.load_module_function("Mat4", "load_identity", 					mat4_load_identity);
-	env.load_module_function("Mat4", "x",								mat4_x);
-	env.load_module_function("Mat4", "y",								mat4_y);
-	env.load_module_function("Mat4", "z",								mat4_z);
-	env.load_module_function("Mat4", "set_x",							mat4_set_x);
-	env.load_module_function("Mat4", "set_y",							mat4_set_y);
-	env.load_module_function("Mat4", "set_z",							mat4_set_z);
-	env.load_module_function("Mat4", "translation", 					mat4_translation);
-	env.load_module_function("Mat4", "set_translation", 				mat4_set_translation);
-	env.load_module_function("Mat4", "get_scale", 						mat4_get_scale);
-	env.load_module_function("Mat4", "set_scale", 						mat4_set_scale);
-	env.load_module_function("Mat4", "print", 							mat4_print);
+void load_matrix4x4(LuaEnvironment& env)
+{
+	env.load_module_function("Matrix4x4", "new", 							matrix4x4);
+	env.load_module_function("Matrix4x4", "add", 							matrix4x4_add);
+	env.load_module_function("Matrix4x4", "sub", 							matrix4x4_subtract);
+	env.load_module_function("Matrix4x4", "mul", 							matrix4x4_multiply);
+	env.load_module_function("Matrix4x4", "muls", 							matrix4x4_multiply_by_scalar);
+	env.load_module_function("Matrix4x4", "divs", 							matrix4x4_divide_by_scalar);
+	env.load_module_function("Matrix4x4", "build_rotation_x", 				matrix4x4_build_rotation_x);
+	env.load_module_function("Matrix4x4", "build_rotation_y", 				matrix4x4_build_rotation_y);
+	env.load_module_function("Matrix4x4", "build_rotation_z", 				matrix4x4_build_rotation_z);
+	env.load_module_function("Matrix4x4", "build_rotation", 				matrix4x4_build_rotation);
+	env.load_module_function("Matrix4x4", "build_projection_perspective_rh", matrix4x4_build_projection_perspective_rh);
+	env.load_module_function("Matrix4x4", "build_projection_perspective_lh", matrix4x4_build_projection_perspective_lh);
+	env.load_module_function("Matrix4x4", "build_projection_ortho_rh", 		matrix4x4_build_projection_ortho_rh);
+	env.load_module_function("Matrix4x4", "build_projection_ortho_lh", 		matrix4x4_build_projection_ortho_lh);
+	env.load_module_function("Matrix4x4", "build_projection_ortho_2d_rh", 	matrix4x4_build_projection_ortho_2d_rh);
+	env.load_module_function("Matrix4x4", "build_look_at_rh", 				matrix4x4_build_look_at_rh);
+	env.load_module_function("Matrix4x4", "build_look_at_lh", 				matrix4x4_build_look_at_rh);
+	env.load_module_function("Matrix4x4", "build_viewpoint_billboard", 		matrix4x4_build_viewpoint_billboard);
+	env.load_module_function("Matrix4x4", "build_axis_billboard", 			matrix4x4_build_axis_billboard);
+	env.load_module_function("Matrix4x4", "transpose", 						matrix4x4_transpose);
+	env.load_module_function("Matrix4x4", "determinant", 					matrix4x4_determinant);
+	env.load_module_function("Matrix4x4", "invert", 						matrix4x4_invert);
+	env.load_module_function("Matrix4x4", "load_identity", 					matrix4x4_load_identity);
+	env.load_module_function("Matrix4x4", "x",								matrix4x4_x);
+	env.load_module_function("Matrix4x4", "y",								matrix4x4_y);
+	env.load_module_function("Matrix4x4", "z",								matrix4x4_z);
+	env.load_module_function("Matrix4x4", "set_x",							matrix4x4_set_x);
+	env.load_module_function("Matrix4x4", "set_y",							matrix4x4_set_y);
+	env.load_module_function("Matrix4x4", "set_z",							matrix4x4_set_z);
+	env.load_module_function("Matrix4x4", "translation", 					matrix4x4_translation);
+	env.load_module_function("Matrix4x4", "set_translation", 				matrix4x4_set_translation);
+	env.load_module_function("Matrix4x4", "get_scale", 						matrix4x4_get_scale);
+	env.load_module_function("Matrix4x4", "set_scale", 						matrix4x4_set_scale);
+	env.load_module_function("Matrix4x4", "print", 							matrix4x4_print);
 }
 
 } //namespace crown

+ 10 - 10
engine/lua/LuaMesh.cpp

@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "Mesh.h"
-#include "Quat.h"
+#include "Quaternion.h"
 #include "LuaStack.h"
 #include "LuaEnvironment.h"
 
@@ -39,7 +39,7 @@ CE_EXPORT int mesh_local_position(lua_State* L)
 
 	Mesh* mesh = stack.get_mesh(1);
 
-	stack.push_vec3(mesh->local_position());
+	stack.push_vector3(mesh->local_position());
 	return 1;
 }
 
@@ -50,7 +50,7 @@ CE_EXPORT int mesh_local_rotation(lua_State* L)
 
 	Mesh* mesh = stack.get_mesh(1);
 
-	stack.push_quat(mesh->local_rotation());
+	stack.push_quaternion(mesh->local_rotation());
 	return 1;
 }
 
@@ -61,7 +61,7 @@ CE_EXPORT int mesh_local_pose(lua_State* L)
 
 	Mesh* mesh = stack.get_mesh(1);
 
-	stack.push_mat4(mesh->local_pose());
+	stack.push_matrix4x4(mesh->local_pose());
 	return 1;
 }
 
@@ -72,7 +72,7 @@ CE_EXPORT int mesh_world_position(lua_State* L)
 
 	Mesh* mesh = stack.get_mesh(1);
 
-	stack.push_vec3(mesh->world_position());
+	stack.push_vector3(mesh->world_position());
 	return 1;
 }
 
@@ -83,7 +83,7 @@ CE_EXPORT int mesh_world_rotation(lua_State* L)
 
 	Mesh* mesh = stack.get_mesh(1);
 
-	stack.push_quat(mesh->world_rotation());
+	stack.push_quaternion(mesh->world_rotation());
 	return 1;
 }
 
@@ -94,7 +94,7 @@ CE_EXPORT int mesh_world_pose(lua_State* L)
 
 	Mesh* mesh = stack.get_mesh(1);
 
-	stack.push_mat4(mesh->world_pose());
+	stack.push_matrix4x4(mesh->world_pose());
 	return 1;
 }
 
@@ -104,7 +104,7 @@ CE_EXPORT int mesh_set_local_position(lua_State* L)
 	LuaStack stack(L);
 
 	Mesh* mesh = stack.get_mesh(1);
-	const Vec3 pos = stack.get_vec3(2);
+	const Vector3 pos = stack.get_vector3(2);
 
 	mesh->set_local_position(pos);
 	return 0;
@@ -116,7 +116,7 @@ CE_EXPORT int mesh_set_local_rotation(lua_State* L)
 	LuaStack stack(L);
 
 	Mesh* mesh = stack.get_mesh(1);
-	const Quat rot = stack.get_quat(2);
+	const Quaternion rot = stack.get_quaternion(2);
 
 	mesh->set_local_rotation(rot);
 	return 0;
@@ -128,7 +128,7 @@ CE_EXPORT int mesh_set_local_pose(lua_State* L)
 	LuaStack stack(L);
 
 	Mesh* mesh = stack.get_mesh(1);
-	const Mat4 pose = stack.get_mat4(2);
+	const Matrix4x4 pose = stack.get_matrix4x4(2);
 
 	mesh->set_local_pose(pose);
 	return 0;

+ 4 - 4
engine/lua/LuaMouse.cpp

@@ -82,7 +82,7 @@ CE_EXPORT int mouse_cursor_xy(lua_State* L)
 {
 	LuaStack stack(L);
 
-	stack.push_vec2(device()->mouse()->cursor_xy());
+	stack.push_vector2(device()->mouse()->cursor_xy());
 
 	return 1;
 }
@@ -92,7 +92,7 @@ CE_EXPORT int mouse_set_cursor_xy(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& xy = stack.get_vec2(1);
+	Vector2& xy = stack.get_vector2(1);
 
 	device()->mouse()->set_cursor_xy(xy);
 
@@ -104,7 +104,7 @@ CE_EXPORT int mouse_cursor_relative_xy(lua_State* L)
 {
 	LuaStack stack(L);
 
-	stack.push_vec2(device()->mouse()->cursor_relative_xy());
+	stack.push_vector2(device()->mouse()->cursor_relative_xy());
 
 	return 1;
 }
@@ -114,7 +114,7 @@ CE_EXPORT int mouse_set_cursor_relative_xy(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& xy = stack.get_vec2(1);
+	Vector2& xy = stack.get_vector2(1);
 
 	device()->mouse()->set_cursor_relative_xy(xy);
 

+ 37 - 37
engine/lua/LuaQuat.cpp → engine/lua/LuaQuaternion.cpp

@@ -24,8 +24,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Quat.h"
-#include "Vec3.h"
+#include "Quaternion.h"
+#include "Vector3.h"
 #include "LuaStack.h"
 #include "LuaEnvironment.h"
 
@@ -34,24 +34,24 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int quat(lua_State* L)
+CE_EXPORT int quaternion(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& v = stack.get_vec3(1);
+	Vector3& v = stack.get_vector3(1);
 	float w = stack.get_float(2);
 
-	stack.push_quat(Quat(v, w));
+	stack.push_quaternion(Quaternion(v, w));
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int quat_negate(lua_State* L)
+CE_EXPORT int quaternion_negate(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Quat& q = stack.get_quat(1);
+	Quaternion& q = stack.get_quaternion(1);
 
 	q.negate();
 
@@ -59,11 +59,11 @@ CE_EXPORT int quat_negate(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int quat_load_identity(lua_State* L)
+CE_EXPORT int quaternion_load_identity(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Quat& q = stack.get_quat(1);
+	Quaternion& q = stack.get_quaternion(1);
 
 	q.load_identity();
 
@@ -71,11 +71,11 @@ CE_EXPORT int quat_load_identity(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int quat_length(lua_State* L)
+CE_EXPORT int quaternion_length(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Quat& q = stack.get_quat(1);
+	Quaternion& q = stack.get_quaternion(1);
 
 	stack.push_float(q.length());
 
@@ -83,80 +83,80 @@ CE_EXPORT int quat_length(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int quat_conjugate(lua_State* L)
+CE_EXPORT int quaternion_conjugate(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Quat& q = stack.get_quat(1);
+	Quaternion& q = stack.get_quaternion(1);
 
-	stack.push_quat(q.get_conjugate());
+	stack.push_quaternion(q.get_conjugate());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int quat_inverse(lua_State* L)
+CE_EXPORT int quaternion_inverse(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Quat& q = stack.get_quat(1);
+	Quaternion& q = stack.get_quaternion(1);
 
-	stack.push_quat(q.get_inverse());
+	stack.push_quaternion(q.get_inverse());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int quat_cross(lua_State* L)
+CE_EXPORT int quaternion_cross(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Quat& q1 = stack.get_quat(1);
-	Quat& q2 = stack.get_quat(2);
+	Quaternion& q1 = stack.get_quaternion(1);
+	Quaternion& q2 = stack.get_quaternion(2);
 
-	stack.push_quat(q1 * q2);
+	stack.push_quaternion(q1 * q2);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int quat_multiply(lua_State* L)
+CE_EXPORT int quaternion_multiply(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Quat& q = stack.get_quat(1);
+	Quaternion& q = stack.get_quaternion(1);
 	float k = stack.get_float(2);
 
-	stack.push_quat(q * k);
+	stack.push_quaternion(q * k);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int quat_power(lua_State* L)
+CE_EXPORT int quaternion_power(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Quat& q = stack.get_quat(1);
+	Quaternion& q = stack.get_quaternion(1);
 	float k = stack.get_float(2);
 
-	stack.push_quat(q.power(k));
+	stack.push_quaternion(q.power(k));
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-void load_quat(LuaEnvironment& env)
+void load_quaternion(LuaEnvironment& env)
 {
-	env.load_module_function("Quat", "new",				quat);
-	env.load_module_function("Quat", "negate",			quat_negate);
-	env.load_module_function("Quat", "load_identity",	quat_load_identity);
-	env.load_module_function("Quat", "length",			quat_length);
-	env.load_module_function("Quat", "conjugate",		quat_conjugate);
-	env.load_module_function("Quat", "inverse",			quat_inverse);
-	env.load_module_function("Quat", "cross",			quat_cross);
-	env.load_module_function("Quat", "mul",				quat_multiply);
-	env.load_module_function("Quat", "pow",				quat_power);
+	env.load_module_function("Quaternion", "new",			quaternion);
+	env.load_module_function("Quaternion", "negate",		quaternion_negate);
+	env.load_module_function("Quaternion", "load_identity",	quaternion_load_identity);
+	env.load_module_function("Quaternion", "length",		quaternion_length);
+	env.load_module_function("Quaternion", "conjugate",		quaternion_conjugate);
+	env.load_module_function("Quaternion", "inverse",		quaternion_inverse);
+	env.load_module_function("Quaternion", "cross",			quaternion_cross);
+	env.load_module_function("Quaternion", "mul",			quaternion_multiply);
+	env.load_module_function("Quaternion", "pow",			quaternion_power);
 }
 
 } //namespace crown

+ 33 - 32
engine/lua/LuaStack.cpp

@@ -26,133 +26,134 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "LuaStack.h"
 #include "Assert.h"
-#include "Vec2.h"
-#include "Vec3.h"
-#include "Mat4.h"
-#include "Quat.h"
+#include "Vector2.h"
+#include "Vector3.h"
+#include "Matrix4x4.h"
+#include "Quaternion.h"
 
 namespace crown
 {
 
 static const uint32_t 	LUA_VEC2_BUFFER_SIZE = 4096;
-static Vec2 			g_vec2_buffer[LUA_VEC2_BUFFER_SIZE];
+static Vector2 			g_vec2_buffer[LUA_VEC2_BUFFER_SIZE];
 static uint32_t 		g_vec2_used = 0;
 
 static const uint32_t 	LUA_VEC3_BUFFER_SIZE = 4096;
-static Vec3 			g_vec3_buffer[LUA_VEC3_BUFFER_SIZE];
+static Vector3 			g_vec3_buffer[LUA_VEC3_BUFFER_SIZE];
 static uint32_t 		g_vec3_used = 0;
 
 static const uint32_t 	LUA_MAT4_BUFFER_SIZE = 4096;
-static Mat4 			g_mat4_buffer[LUA_MAT4_BUFFER_SIZE];
+static Matrix4x4 		g_mat4_buffer[LUA_MAT4_BUFFER_SIZE];
 static uint32_t 		g_mat4_used = 0;
 
 static const uint32_t 	LUA_QUAT_BUFFER_SIZE = 4096;
-static Quat 			g_quat_buffer[LUA_QUAT_BUFFER_SIZE];
+static Quaternion 		g_quat_buffer[LUA_QUAT_BUFFER_SIZE];
 static uint32_t 		g_quat_used = 0;
 
 //-----------------------------------------------------------------------------
-static Vec2* next_vec2(const Vec2& v)
+static Vector2* next_vec2(const Vector2& v)
 {
-	CE_ASSERT(g_vec2_used < LUA_VEC2_BUFFER_SIZE, "Maximum number of Vec2 reached");
+	CE_ASSERT(g_vec2_used < LUA_VEC2_BUFFER_SIZE, "Maximum number of Vector2 reached");
 
 	return &(g_vec2_buffer[g_vec2_used++] = v);
 }
 
 //-----------------------------------------------------------------------------
-static Vec3* next_vec3(const Vec3& v)
+static Vector3* next_vec3(const Vector3& v)
 {
-	CE_ASSERT(g_vec3_used < LUA_VEC3_BUFFER_SIZE, "Maximum number of Vec3 reached");
+	CE_ASSERT(g_vec3_used < LUA_VEC3_BUFFER_SIZE, "Maximum number of Vector3 reached");
 
 	return &(g_vec3_buffer[g_vec3_used++] = v);
 }
 
 //-----------------------------------------------------------------------------
-static Mat4* next_mat4(const Mat4& m)
+static Matrix4x4* next_mat4(const Matrix4x4& m)
 {
-	CE_ASSERT(g_mat4_used < LUA_MAT4_BUFFER_SIZE, "Maximum number of Mat4 reached");
+	CE_ASSERT(g_mat4_used < LUA_MAT4_BUFFER_SIZE, "Maximum number of Matrix4x4 reached");
 
 	return &(g_mat4_buffer[g_mat4_used++] = m);
 }
 
 //-----------------------------------------------------------------------------
-static Quat* next_quat(const Quat& q)
+static Quaternion* next_quat(const Quaternion& q)
 {
-	CE_ASSERT(g_quat_used < LUA_QUAT_BUFFER_SIZE, "Maximum number of Quat reached");
+	CE_ASSERT(g_quat_used < LUA_QUAT_BUFFER_SIZE, "Maximum number of Quaternion reached");
 
 	return &(g_quat_buffer[g_quat_used++] = q);
 }
 
 //-----------------------------------------------------------------------------
-Vec2& LuaStack::get_vec2(int32_t index)
+Vector2& LuaStack::get_vector2(int32_t index)
 {
 	void* v = lua_touserdata(m_state, index);
 
 	if (v < &g_vec2_buffer[0] || v > &g_vec2_buffer[LUA_VEC2_BUFFER_SIZE-1])
 	{
-		luaL_typerror(m_state, index, "Vec2");
+		luaL_typerror(m_state, index, "Vector2");
 	}
 
-	return *(Vec2*)v;
+	return *(Vector2*)v;
 }
 
 //-----------------------------------------------------------------------------
-Vec3& LuaStack::get_vec3(int32_t index)
+Vector3& LuaStack::get_vector3(int32_t index)
 {
 	void* v = lua_touserdata(m_state, index);
 
 	if (v < &g_vec3_buffer[0] || v > &g_vec3_buffer[LUA_VEC3_BUFFER_SIZE-1])
 	{
-		luaL_typerror(m_state, index, "Vec3");
+		luaL_typerror(m_state, index, "Vector3");
 	}
 
-	return *(Vec3*)v;
+	return *(Vector3*)v;
 }
 
 //-----------------------------------------------------------------------------
-Mat4& LuaStack::get_mat4(int32_t index)
+Matrix4x4& LuaStack::get_matrix4x4(int32_t index)
 {
 	void* m = lua_touserdata(m_state, index);
 
 	if (m < &g_mat4_buffer[0] || m > &g_mat4_buffer[LUA_MAT4_BUFFER_SIZE-1])
 	{
-		luaL_typerror(m_state, index, "Mat4");
+		luaL_typerror(m_state, index, "Matrix4x4");
 	}
 
-	return *(Mat4*)m;
+	return *(Matrix4x4*)m;
 }
 
 //-----------------------------------------------------------------------------
-Quat& LuaStack::get_quat(int32_t index)
+Quaternion& LuaStack::get_quaternion(int32_t index)
 {
 	void* q = lua_touserdata(m_state, index);
 
 	if (q < &g_quat_buffer[0] || q > &g_quat_buffer[LUA_QUAT_BUFFER_SIZE-1])
 	{
-		luaL_typerror(m_state, index, "Quat");
+		luaL_typerror(m_state, index, "Quaternion");
 	}
 
-	return *(Quat*)q;
+	return *(Quaternion*)q;
 }
 
-void LuaStack::push_vec2(const Vec2& v)
+//-----------------------------------------------------------------------------
+void LuaStack::push_vector2(const Vector2& v)
 {
 	lua_pushlightuserdata(m_state, next_vec2(v));
 }
 
 //-----------------------------------------------------------------------------
-void LuaStack::push_vec3(const Vec3& v)
+void LuaStack::push_vector3(const Vector3& v)
 {
 	lua_pushlightuserdata(m_state, next_vec3(v));
 }
 
 //-----------------------------------------------------------------------------
-void LuaStack::push_mat4(const Mat4& m)
+void LuaStack::push_matrix4x4(const Matrix4x4& m)
 {
 	lua_pushlightuserdata(m_state, next_mat4(m));
 }
 
 //-----------------------------------------------------------------------------
-void LuaStack::push_quat(const Quat& q)
+void LuaStack::push_quaternion(const Quaternion& q)
 {
 	lua_pushlightuserdata(m_state, next_quat(q));
 }

+ 12 - 12
engine/lua/LuaStack.h

@@ -32,10 +32,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class Vec2;
-class Vec3;
-class Mat4;
-class Quat;
+class Vector2;
+class Vector3;
+class Matrix4x4;
+class Quaternion;
 class Unit;
 class Camera;
 class World;
@@ -197,14 +197,14 @@ public:
 		return (Mesh*) lua_touserdata(m_state, index);
 	}
 
-	Vec2& get_vec2(int32_t index);
-	Vec3& get_vec3(int32_t index);
-	Mat4& get_mat4(int32_t index);
-	Quat& get_quat(int32_t index);
-	void push_vec2(const Vec2& v);
-	void push_vec3(const Vec3& v);
-	void push_mat4(const Mat4& m);
-	void push_quat(const Quat& q);
+	Vector2& get_vector2(int32_t index);
+	Vector3& get_vector3(int32_t index);
+	Matrix4x4& get_matrix4x4(int32_t index);
+	Quaternion& get_quaternion(int32_t index);
+	void push_vector2(const Vector2& v);
+	void push_vector3(const Vector3& v);
+	void push_matrix4x4(const Matrix4x4& m);
+	void push_quaternion(const Quaternion& q);
 
 private:
 

+ 9 - 9
engine/lua/LuaUnit.cpp

@@ -38,7 +38,7 @@ CE_EXPORT int32_t unit_local_position(lua_State* L)
 
 	Unit* unit = stack.get_unit(1);
 
-	stack.push_vec3(unit->local_position());
+	stack.push_vector3(unit->local_position());
 	return 1;
 }
 
@@ -49,7 +49,7 @@ CE_EXPORT int32_t unit_local_rotation(lua_State* L)
 
 	Unit* unit = stack.get_unit(1);
 
-	stack.push_quat(unit->local_rotation());
+	stack.push_quaternion(unit->local_rotation());
 	return 1;
 }
 
@@ -60,7 +60,7 @@ CE_EXPORT int32_t unit_local_pose(lua_State* L)
 
 	Unit* unit = stack.get_unit(1);
 
-	stack.push_mat4(unit->local_pose());
+	stack.push_matrix4x4(unit->local_pose());
 	return 1;
 }
 
@@ -71,7 +71,7 @@ CE_EXPORT int32_t unit_world_position(lua_State* L)
 
 	Unit* unit = stack.get_unit(1);
 
-	stack.push_vec3(unit->world_position());
+	stack.push_vector3(unit->world_position());
 	return 1;
 }
 
@@ -82,7 +82,7 @@ CE_EXPORT int32_t unit_world_rotation(lua_State* L)
 
 	Unit* unit = stack.get_unit(1);
 
-	stack.push_quat(unit->world_rotation());
+	stack.push_quaternion(unit->world_rotation());
 	return 1;
 }
 
@@ -93,7 +93,7 @@ CE_EXPORT int32_t unit_world_pose(lua_State* L)
 
 	Unit* unit = stack.get_unit(1);
 
-	stack.push_mat4(unit->world_pose());
+	stack.push_matrix4x4(unit->world_pose());
 	return 1;
 }
 
@@ -103,7 +103,7 @@ CE_EXPORT int32_t unit_set_local_position(lua_State* L)
 	LuaStack stack(L);
 
 	Unit* unit = stack.get_unit(1);
-	Vec3& pos = stack.get_vec3(2);
+	Vector3& pos = stack.get_vector3(2);
 
 	unit->set_local_position(pos);
 	return 0;
@@ -115,7 +115,7 @@ CE_EXPORT int32_t unit_set_local_rotation(lua_State* L)
 	LuaStack stack(L);
 
 	Unit* unit = stack.get_unit(1);
-	Quat& rot = stack.get_quat(2);
+	Quaternion& rot = stack.get_quaternion(2);
 
 	unit->set_local_rotation(rot);
 	return 0;
@@ -127,7 +127,7 @@ CE_EXPORT int32_t unit_set_local_pose(lua_State* L)
 	LuaStack stack(L);
 
 	Unit* unit = stack.get_unit(1);
-	Mat4& pose = stack.get_mat4(2);
+	Matrix4x4& pose = stack.get_matrix4x4(2);
 
 	unit->set_local_pose(pose);
 	return 0;

+ 70 - 70
engine/lua/LuaVec2.cpp → engine/lua/LuaVector2.cpp

@@ -24,7 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Vec2.h"
+#include "Vector2.h"
 #include "LuaStack.h"
 #include "LuaEnvironment.h"
 
@@ -32,24 +32,24 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2(lua_State* L)
+CE_EXPORT int vector2(lua_State* L)
 {
 	LuaStack stack(L);
 
 	float x = stack.get_float(1);
 	float y = stack.get_float(2);
 
-	stack.push_vec2(Vec2(x, y));
+	stack.push_vector2(Vector2(x, y));
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_values(lua_State* L)
+CE_EXPORT int vector2_values(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
+	Vector2& a = stack.get_vector2(1);
 
 	stack.push_float(a.x);
 	stack.push_float(a.y);
@@ -58,64 +58,64 @@ CE_EXPORT int vec2_values(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_add(lua_State* L)
+CE_EXPORT int vector2_add(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
-	Vec2& b = stack.get_vec2(2);
+	Vector2& a = stack.get_vector2(1);
+	Vector2& b = stack.get_vector2(2);
 
-	stack.push_vec2(a + b);
+	stack.push_vector2(a + b);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_subtract(lua_State* L)
+CE_EXPORT int vector2_subtract(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
-	Vec2& b = stack.get_vec2(2);
+	Vector2& a = stack.get_vector2(1);
+	Vector2& b = stack.get_vector2(2);
 
-	stack.push_vec2(a - b);
+	stack.push_vector2(a - b);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_multiply(lua_State* L)
+CE_EXPORT int vector2_multiply(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
+	Vector2& a = stack.get_vector2(1);
 	float k = stack.get_float(2);
 
-	stack.push_vec2(a * k);
+	stack.push_vector2(a * k);
 
 	return 1;
 }			
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_divide(lua_State* L)
+CE_EXPORT int vector2_divide(lua_State* L)
 {
 	LuaStack stack(L);
 	
-	Vec2& a = stack.get_vec2(1);
+	Vector2& a = stack.get_vector2(1);
 	float k = stack.get_float(2);
 
-	stack.push_vec2(a / k);
+	stack.push_vector2(a / k);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_dot(lua_State* L)
+CE_EXPORT int vector2_dot(lua_State* L)
 {
 	LuaStack stack(L);
 	
-	Vec2& a = stack.get_vec2(1);
-	Vec2& b = stack.get_vec2(2);
+	Vector2& a = stack.get_vector2(1);
+	Vector2& b = stack.get_vector2(2);
 
 	stack.push_float(a.dot(b));
 
@@ -123,12 +123,12 @@ CE_EXPORT int vec2_dot(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_equals(lua_State* L)
+CE_EXPORT int vector2_equals(lua_State* L)
 {
 	LuaStack stack(L);
 	
-	Vec2& a = stack.get_vec2(1);
-	Vec2& b = stack.get_vec2(2);
+	Vector2& a = stack.get_vector2(1);
+	Vector2& b = stack.get_vector2(2);
 
 	stack.push_bool(a == b);
 
@@ -136,12 +136,12 @@ CE_EXPORT int vec2_equals(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_lower(lua_State* L)
+CE_EXPORT int vector2_lower(lua_State* L)
 {
 	LuaStack stack(L);
 	
-	Vec2& a = stack.get_vec2(1);
-	Vec2& b = stack.get_vec2(2);
+	Vector2& a = stack.get_vector2(1);
+	Vector2& b = stack.get_vector2(2);
 
 	stack.push_bool(a < b);
 
@@ -149,12 +149,12 @@ CE_EXPORT int vec2_lower(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_greater(lua_State* L)
+CE_EXPORT int vector2_greater(lua_State* L)
 {
 	LuaStack stack(L);
 	
-	Vec2& a = stack.get_vec2(1);
-	Vec2& b = stack.get_vec2(2);
+	Vector2& a = stack.get_vector2(1);
+	Vector2& b = stack.get_vector2(2);
 	
 	stack.push_bool(a > b);
 
@@ -162,11 +162,11 @@ CE_EXPORT int vec2_greater(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_length(lua_State* L)
+CE_EXPORT int vector2_length(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
+	Vector2& a = stack.get_vector2(1);
 
 	stack.push_float(a.length());
 
@@ -174,11 +174,11 @@ CE_EXPORT int vec2_length(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_squared_length(lua_State* L)
+CE_EXPORT int vector2_squared_length(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
+	Vector2& a = stack.get_vector2(1);
 
 	stack.push_float(a.squared_length());
 
@@ -186,11 +186,11 @@ CE_EXPORT int vec2_squared_length(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_set_length(lua_State* L)
+CE_EXPORT int vector2_set_length(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
+	Vector2& a = stack.get_vector2(1);
 	float len = stack.get_float(2);
 
 	a.set_length(len);
@@ -199,36 +199,36 @@ CE_EXPORT int vec2_set_length(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_normalize(lua_State* L)
+CE_EXPORT int vector2_normalize(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
+	Vector2& a = stack.get_vector2(1);
 
-	stack.push_vec2(a.normalize());
+	stack.push_vector2(a.normalize());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_negate(lua_State* L)
+CE_EXPORT int vector2_negate(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
+	Vector2& a = stack.get_vector2(1);
 
-	stack.push_vec2(a.negate());
+	stack.push_vector2(a.negate());
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_get_distance_to(lua_State* L)
+CE_EXPORT int vector2_get_distance_to(lua_State* L)
 {
 	LuaStack stack(L);
 	
-	Vec2& a = stack.get_vec2(1);
-	Vec2& b = stack.get_vec2(2);
+	Vector2& a = stack.get_vector2(1);
+	Vector2& b = stack.get_vector2(2);
 
 	stack.push_float(a.get_distance_to(b));
 
@@ -236,12 +236,12 @@ CE_EXPORT int vec2_get_distance_to(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_get_angle_between(lua_State* L)
+CE_EXPORT int vector2_get_angle_between(lua_State* L)
 {
 	LuaStack stack(L);
 	
-	Vec2& a = stack.get_vec2(1);
-	Vec2& b = stack.get_vec2(2);
+	Vector2& a = stack.get_vector2(1);
+	Vector2& b = stack.get_vector2(2);
 
 	stack.push_float(a.get_angle_between(b));
 
@@ -249,11 +249,11 @@ CE_EXPORT int vec2_get_angle_between(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec2_zero(lua_State* L)
+CE_EXPORT int vector2_zero(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec2& a = stack.get_vec2(1);
+	Vector2& a = stack.get_vector2(1);
 
 	a.zero();
 
@@ -261,26 +261,26 @@ CE_EXPORT int vec2_zero(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-void load_vec2(LuaEnvironment& env)
+void load_vector2(LuaEnvironment& env)
 {
-	env.load_module_function("Vec2", "new",					vec2);
-	env.load_module_function("Vec2", "val",					vec2_values);
-	env.load_module_function("Vec2", "add",					vec2_add);
-	env.load_module_function("Vec2", "sub",					vec2_subtract);
-	env.load_module_function("Vec2", "mul",					vec2_multiply);
-	env.load_module_function("Vec2", "div",					vec2_divide);
-	env.load_module_function("Vec2", "dot",					vec2_dot);
-	env.load_module_function("Vec2", "equals",				vec2_equals);
-	env.load_module_function("Vec2", "lower",				vec2_lower);
-	env.load_module_function("Vec2", "greater",				vec2_greater);
-	env.load_module_function("Vec2", "length",				vec2_length);
-	env.load_module_function("Vec2", "squared_length",		vec2_squared_length);
-	env.load_module_function("Vec2", "set_length",			vec2_set_length);
-	env.load_module_function("Vec2", "normalize",			vec2_normalize);
-	env.load_module_function("Vec2", "negate",				vec2_negate);
-	env.load_module_function("Vec2", "get_distance_to",		vec2_get_distance_to);
-	env.load_module_function("Vec2", "get_angle_between",	vec2_get_angle_between);
-	env.load_module_function("Vec2", "zero",				vec2_zero);
+	env.load_module_function("Vector2", "new",					vector2);
+	env.load_module_function("Vector2", "val",					vector2_values);
+	env.load_module_function("Vector2", "add",					vector2_add);
+	env.load_module_function("Vector2", "sub",					vector2_subtract);
+	env.load_module_function("Vector2", "mul",					vector2_multiply);
+	env.load_module_function("Vector2", "div",					vector2_divide);
+	env.load_module_function("Vector2", "dot",					vector2_dot);
+	env.load_module_function("Vector2", "equals",				vector2_equals);
+	env.load_module_function("Vector2", "lower",				vector2_lower);
+	env.load_module_function("Vector2", "greater",				vector2_greater);
+	env.load_module_function("Vector2", "length",				vector2_length);
+	env.load_module_function("Vector2", "squared_length",		vector2_squared_length);
+	env.load_module_function("Vector2", "set_length",			vector2_set_length);
+	env.load_module_function("Vector2", "normalize",			vector2_normalize);
+	env.load_module_function("Vector2", "negate",				vector2_negate);
+	env.load_module_function("Vector2", "get_distance_to",		vector2_get_distance_to);
+	env.load_module_function("Vector2", "get_angle_between",	vector2_get_angle_between);
+	env.load_module_function("Vector2", "zero",					vector2_zero);
 }
 
 } // namespace crown

+ 73 - 73
engine/lua/LuaVec3.cpp → engine/lua/LuaVector3.cpp

@@ -24,7 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "Vec3.h"
+#include "Vector3.h"
 #include "LuaStack.h"
 #include "LuaEnvironment.h"
 
@@ -32,7 +32,7 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3(lua_State* L)
+CE_EXPORT int vector3(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -40,17 +40,17 @@ CE_EXPORT int vec3(lua_State* L)
 	float y = stack.get_float(2);
 	float z = stack.get_float(3);
 
-	stack.push_vec3(Vec3(x, y, z));
+	stack.push_vector3(Vector3(x, y, z));
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_values(lua_State* L)
+CE_EXPORT int vector3_values(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
+	Vector3& a = stack.get_vector3(1);
 
 	stack.push_float(a.x);
 	stack.push_float(a.y);
@@ -60,64 +60,64 @@ CE_EXPORT int vec3_values(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_add(lua_State* L)
+CE_EXPORT int vector3_add(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
-	Vec3& b = stack.get_vec3(2);
+	Vector3& a = stack.get_vector3(1);
+	Vector3& b = stack.get_vector3(2);
 
-	stack.push_vec3(a + b);
+	stack.push_vector3(a + b);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_subtract(lua_State* L)
+CE_EXPORT int vector3_subtract(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
-	Vec3& b = stack.get_vec3(2);
+	Vector3& a = stack.get_vector3(1);
+	Vector3& b = stack.get_vector3(2);
 
-	stack.push_vec3(a - b);
+	stack.push_vector3(a - b);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_multiply(lua_State* L)
+CE_EXPORT int vector3_multiply(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
+	Vector3& a = stack.get_vector3(1);
 	float b = stack.get_float(2);
 
-	stack.push_vec3(a * b);
+	stack.push_vector3(a * b);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_divide(lua_State* L)
+CE_EXPORT int vector3_divide(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
+	Vector3& a = stack.get_vector3(1);
 	float b = stack.get_float(2);
 
-	stack.push_vec3(a / b);
+	stack.push_vector3(a / b);
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_dot(lua_State* L)
+CE_EXPORT int vector3_dot(lua_State* L)
 {
 	LuaStack stack(L);
 	
-	Vec3& a = stack.get_vec3(1);
-	Vec3& b = stack.get_vec3(2);
+	Vector3& a = stack.get_vector3(1);
+	Vector3& b = stack.get_vector3(2);
 
 	stack.push_float(a.dot(b));
 
@@ -125,25 +125,25 @@ CE_EXPORT int vec3_dot(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_cross(lua_State* L)
+CE_EXPORT int vector3_cross(lua_State* L)
 {
 	LuaStack stack(L);
 	
-	Vec3& a = stack.get_vec3(1);
-	Vec3& b = stack.get_vec3(2);
+	Vector3& a = stack.get_vector3(1);
+	Vector3& b = stack.get_vector3(2);
 
-	stack.push_vec3(a.cross(b));
+	stack.push_vector3(a.cross(b));
 
 	return 1;
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_equals(lua_State* L)
+CE_EXPORT int vector3_equals(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
-	Vec3& b = stack.get_vec3(2);
+	Vector3& a = stack.get_vector3(1);
+	Vector3& b = stack.get_vector3(2);
 
 	stack.push_bool(a == b);
 
@@ -151,12 +151,12 @@ CE_EXPORT int vec3_equals(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_lower(lua_State* L)
+CE_EXPORT int vector3_lower(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
-	Vec3& b = stack.get_vec3(2);
+	Vector3& a = stack.get_vector3(1);
+	Vector3& b = stack.get_vector3(2);
 
 	stack.push_bool(a < b);
 
@@ -164,12 +164,12 @@ CE_EXPORT int vec3_lower(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_greater(lua_State* L)
+CE_EXPORT int vector3_greater(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
-	Vec3& b = stack.get_vec3(2);
+	Vector3& a = stack.get_vector3(1);
+	Vector3& b = stack.get_vector3(2);
 
 	stack.push_bool(a > b);
 
@@ -177,11 +177,11 @@ CE_EXPORT int vec3_greater(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_length(lua_State* L)
+CE_EXPORT int vector3_length(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
+	Vector3& a = stack.get_vector3(1);
 
 	stack.push_float(a.length());
 
@@ -189,11 +189,11 @@ CE_EXPORT int vec3_length(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_squared_length(lua_State* L)
+CE_EXPORT int vector3_squared_length(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
+	Vector3& a = stack.get_vector3(1);
 
 	stack.push_float(a.squared_length());
 
@@ -201,11 +201,11 @@ CE_EXPORT int vec3_squared_length(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_set_length(lua_State* L)
+CE_EXPORT int vector3_set_length(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
+	Vector3& a = stack.get_vector3(1);
 	float len = stack.get_float(2);
 
 	a.set_length(len);
@@ -214,11 +214,11 @@ CE_EXPORT int vec3_set_length(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_normalize(lua_State* L)
+CE_EXPORT int vector3_normalize(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
+	Vector3& a = stack.get_vector3(1);
 
 	a.normalize();
 
@@ -226,11 +226,11 @@ CE_EXPORT int vec3_normalize(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_negate(lua_State* L)
+CE_EXPORT int vector3_negate(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
+	Vector3& a = stack.get_vector3(1);
 
 	a.negate();
 
@@ -238,12 +238,12 @@ CE_EXPORT int vec3_negate(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_get_distance_to(lua_State* L)
+CE_EXPORT int vector3_get_distance_to(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
-	Vec3& b = stack.get_vec3(2);
+	Vector3& a = stack.get_vector3(1);
+	Vector3& b = stack.get_vector3(2);
 
 	stack.push_float(a.get_distance_to(b));
 
@@ -251,12 +251,12 @@ CE_EXPORT int vec3_get_distance_to(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_get_angle_between(lua_State* L)
+CE_EXPORT int vector3_get_angle_between(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
-	Vec3& b = stack.get_vec3(2);
+	Vector3& a = stack.get_vector3(1);
+	Vector3& b = stack.get_vector3(2);
 
 	stack.push_float(a.get_angle_between(b));
 
@@ -264,11 +264,11 @@ CE_EXPORT int vec3_get_angle_between(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-CE_EXPORT int vec3_zero(lua_State* L)
+CE_EXPORT int vector3_zero(lua_State* L)
 {
 	LuaStack stack(L);
 
-	Vec3& a = stack.get_vec3(1);
+	Vector3& a = stack.get_vector3(1);
 
 	a.zero();
 
@@ -276,27 +276,27 @@ CE_EXPORT int vec3_zero(lua_State* L)
 }	
 
 //-----------------------------------------------------------------------------
-void load_vec3(LuaEnvironment& env)
+void load_vector3(LuaEnvironment& env)
 {
-	env.load_module_function("Vec3", "new", 				vec3);
-	env.load_module_function("Vec3", "val", 				vec3_values);
-	env.load_module_function("Vec3", "add", 				vec3_add);
-	env.load_module_function("Vec3", "sub", 				vec3_subtract);
-	env.load_module_function("Vec3", "mul", 				vec3_multiply);
-	env.load_module_function("Vec3", "div", 				vec3_divide);
-	env.load_module_function("Vec3", "dot", 				vec3_dot);
-	env.load_module_function("Vec3", "cross", 				vec3_cross);
-	env.load_module_function("Vec3", "equals", 				vec3_equals);
-	env.load_module_function("Vec3", "lower", 				vec3_lower);
-	env.load_module_function("Vec3", "greater", 			vec3_greater);
-	env.load_module_function("Vec3", "length", 				vec3_length);
-	env.load_module_function("Vec3", "squared_length", 		vec3_squared_length);
-	env.load_module_function("Vec3", "set_length", 			vec3_set_length);
-	env.load_module_function("Vec3", "normalize", 			vec3_normalize);
-	env.load_module_function("Vec3", "negate", 				vec3_negate);
-	env.load_module_function("Vec3", "get_distance_to", 	vec3_get_distance_to);
-	env.load_module_function("Vec3", "get_angle_between", 	vec3_get_angle_between);
-	env.load_module_function("Vec3", "zero", 				vec3_zero);	
+	env.load_module_function("Vector3", "new", 				vector3);
+	env.load_module_function("Vector3", "val", 				vector3_values);
+	env.load_module_function("Vector3", "add", 				vector3_add);
+	env.load_module_function("Vector3", "sub", 				vector3_subtract);
+	env.load_module_function("Vector3", "mul", 				vector3_multiply);
+	env.load_module_function("Vector3", "div", 				vector3_divide);
+	env.load_module_function("Vector3", "dot", 				vector3_dot);
+	env.load_module_function("Vector3", "cross", 			vector3_cross);
+	env.load_module_function("Vector3", "equals", 			vector3_equals);
+	env.load_module_function("Vector3", "lower", 			vector3_lower);
+	env.load_module_function("Vector3", "greater", 			vector3_greater);
+	env.load_module_function("Vector3", "length", 			vector3_length);
+	env.load_module_function("Vector3", "squared_length", 	vector3_squared_length);
+	env.load_module_function("Vector3", "set_length", 		vector3_set_length);
+	env.load_module_function("Vector3", "normalize", 		vector3_normalize);
+	env.load_module_function("Vector3", "negate", 			vector3_negate);
+	env.load_module_function("Vector3", "get_distance_to", 	vector3_get_distance_to);
+	env.load_module_function("Vector3", "get_angle_between",vector3_get_angle_between);
+	env.load_module_function("Vector3", "zero", 			vector3_zero);	
 }
 
 } // namespace crown

+ 8 - 8
engine/lua/LuaWorld.cpp

@@ -40,8 +40,8 @@ CE_EXPORT int world_spawn_unit(lua_State* L)
 	World* world = stack.get_world(1);
 	const char* name = stack.get_string(2);
 
-	const Vec3& pos = stack.num_args() > 2 ? stack.get_vec3(3) : Vec3::ZERO;
-	const Quat& rot = stack.num_args() > 3 ? stack.get_quat(4) : Quat::IDENTITY;
+	const Vector3& pos = stack.num_args() > 2 ? stack.get_vector3(3) : Vector3::ZERO;
+	const Quaternion& rot = stack.num_args() > 3 ? stack.get_quaternion(4) : Quaternion::IDENTITY;
 
 	UnitId unit = world->spawn_unit(name, pos, rot);
 
@@ -70,7 +70,7 @@ CE_EXPORT int world_play_sound(lua_State* L)
 
 	const bool loop = stack.num_args() > 2 ? stack.get_bool(3) : false;
 	const float volume = stack.num_args() > 3 ? stack.get_float(4) : 1.0f; // test value
-	const Vec3& pos = stack.num_args() > 4 ? stack.get_vec3(5) : Vec3::ZERO;
+	const Vector3& pos = stack.num_args() > 4 ? stack.get_vector3(5) : Vector3::ZERO;
 	const float range = stack.num_args() > 5 ? stack.get_float(6) : 1000.0f; // test value
 
 	SoundInstanceId id = world->play_sound(name, loop, volume, pos, range);
@@ -120,10 +120,10 @@ CE_EXPORT int world_set_listener(lua_State* L)
 
 	World* world = (World*) stack.get_lightdata(1);
 
-	const Vec3& pos = stack.get_vec3(2);
-	const Vec3& vel = stack.get_vec3(3);
-	const Vec3& or_up = stack.get_vec3(4);
-	const Vec3& or_at = stack.get_vec3(5);
+	const Vector3& pos = stack.get_vector3(2);
+	const Vector3& vel = stack.get_vector3(3);
+	const Vector3& or_up = stack.get_vector3(4);
+	const Vector3& or_at = stack.get_vector3(5);
 
 	world->set_listener(pos, vel, or_up, or_at);
 
@@ -140,7 +140,7 @@ CE_EXPORT int world_set_sound_position(lua_State* L)
 	SoundInstanceId id;
 	id.decode(stack.get_int(2));
 
-	const Vec3& pos = stack.get_vec3(3);
+	const Vector3& pos = stack.get_vector3(3);
 
 	world->set_sound_position(id, pos);
 

+ 3 - 3
engine/network/BitMessage.cpp

@@ -440,7 +440,7 @@ void BitMessage::write_float(float f)
 }
 
 //---------------------------------------------------------------------------------------------
-void BitMessage::write_vec3(const Vec3& v)
+void BitMessage::write_vec3(const Vector3& v)
 {
 	write_float(v.x);
 	write_float(v.y);
@@ -646,9 +646,9 @@ float BitMessage::read_float() const
 }
 
 //---------------------------------------------------------------------------------------------
-Vec3 BitMessage::read_vec3() const
+Vector3 BitMessage::read_vec3() const
 {
-	Vec3 v;
+	Vector3 v;
 	
 	v.x = read_float();
 	v.y = read_float();

+ 3 - 3
engine/network/BitMessage.h

@@ -28,7 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Allocator.h"
-#include "Vec3.h"
+#include "Vector3.h"
 #include "NetAddress.h"
 
 namespace crown
@@ -84,7 +84,7 @@ public:
 	void				write_uint16(int32_t c);
 	void				write_int32(int32_t c);
 	void				write_float(float f);
-	void				write_vec3(const Vec3& v);
+	void				write_vec3(const Vector3& v);
 	void				write_string(const char* s, int32_t max_len = -1, bool make_7_bit = true);
 	void				write_data(const void* data, int32_t length);
 	void				write_netaddr(const os::NetAddress addr);
@@ -100,7 +100,7 @@ public:
 	int32_t				read_uint16() const;
 	int32_t				read_int32() const;
 	float				read_float() const;
-	Vec3				read_vec3() const;
+	Vector3				read_vec3() const;
 	int32_t				read_string(char* buffer, int32_t buffer_size) const;
 	int32_t				read_data(void* data, int32_t length) const;
 	void				read_netaddr(os::NetAddress* addr) const;

+ 410 - 0
engine/os/win/OsSocket.h

@@ -0,0 +1,410 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <winsock2.h>
+#pragma comment(lib, "wsock32.lib")
+
+#include "NetAddress.h"
+#include "Assert.h"
+#include "Types.h"
+#include "OS.h"
+
+namespace crown
+{
+
+struct ReadResult
+{
+	enum { NO_ERROR, UNKNOWN, REMOTE_CLOSED } error;
+	size_t received_bytes;
+};
+
+struct WriteResult
+{
+	enum { NO_ERROR, UNKNOWN, REMOTE_CLOSED } error;
+	size_t sent_bytes;
+};
+
+//-----------------------------------------------------------------------------
+class TCPSocket
+{
+public:
+	//-----------------------------------------------------------------------------
+	TCPSocket()
+		: m_socket(0)
+	{
+
+	}
+
+	//-----------------------------------------------------------------------------
+	TCPSocket(int socket)
+		: m_socket(socket)
+	{
+	}
+
+	//-----------------------------------------------------------------------------
+	TCPSocket::~TCPSocket()
+	{
+		close();
+	}
+
+/*	//-----------------------------------------------------------------------------
+	bool TCPSocket::open(uint16_t port)
+	{
+		int32_t sd = socket(AF_INET, SOCK_STREAM, 0);
+
+		if (sd <= 0)
+		{
+			os::print32_tf("failed to open socket\n");
+			set_socket_id(0);
+			return false;
+		}
+
+		set_socket_id(sd);
+
+		// Bind socket
+		sockaddr_in address;
+		address.sin_family = AF_INET;
+		address.sin_addr.s_addr = htonl(INADDR_ANY);
+		address.sin_port = htons(port);
+
+		if (bind(sd, (const sockaddr*)&address, sizeof(sockaddr_in)) < 0)
+		{
+			os::print32_tf("failed to bind socket\n");
+			close();
+			return false;
+		}
+
+		listen(sd, 5);
+		os::print32_tf("listening on port %d", port);
+
+		sockaddr_in client;
+		uint32_t client_length = sizeof(client);
+
+		int32_t active_sd = accept(sd, (sockaddr*)&client, &client_length);
+		if (active_sd < 0)
+		{
+			os::print32_tf("failed to accept connections");
+		}
+
+		set_active_socket_id(active_sd);
+
+		return true;  
+	}*/
+
+	//-----------------------------------------------------------------------------
+	bool TCPSocket::connect(const NetAddress& destination, uint16_t port)
+	{		
+		int sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+		if (sd <= 0)
+		{
+			os::printf("failed to open socket\n");
+			m_socket = 0;
+			return false;
+		}
+		
+		m_socket = sd;
+
+		sockaddr_in address;
+		address.sin_family = AF_INET;
+		address.sin_addr.s_addr = htonl(destination.address());
+		address.sin_port = htons(port);
+
+		if (::connect(sd, (const sockaddr*)&address, sizeof(sockaddr_in)) < 0)
+		{
+			os::printf("failed to connect socket\n");
+			close();
+			return false;
+		}
+	}
+
+	//-----------------------------------------------------------------------------
+	int32_t	TCPSocket::close()
+	{
+		if (m_socket != 0)
+		{
+			::close(m_socket);
+			m_socket = 0;
+		}
+	}
+
+	//-----------------------------------------------------------------------------
+	ReadResult TCPSocket::read(void* data, int32_t size)
+	{
+		CE_ASSERT_NOT_NULL(data);
+
+		int received_bytes = recv(m_socket, (char*)data, size, 0);
+
+		ReadResult result;
+
+		if (received_bytes < 0)
+		{
+			result.error = ReadResult::NO_ERROR;
+			result.received_bytes = 0;
+		}
+		if (received_bytes == 0)
+		{
+			result.error = ReadResult::REMOTE_CLOSED;
+		}
+		else
+		{
+			result.error = ReadResult::NO_ERROR;
+			result.received_bytes = received_bytes;
+		}
+
+		return result;
+	}
+
+	//-----------------------------------------------------------------------------
+	bool TCPSocket::write(const void* data, int32_t size)
+	{
+		CE_ASSERT_NOT_NULL(data);
+
+		int sent_bytes = ::send(sd, (const char*)data, size, 0);
+
+		WriteResult result;
+
+		if (sent_bytes < 0)
+		{
+			result.error = WriteResult::UNKNOWN;
+		}
+		else
+		{
+			result.error = WriteResult::NO_ERROR;
+			result.sent_bytes = sent_bytes;
+		}
+
+		return result;  
+	}
+
+public:
+
+	int m_socket;
+};
+
+//-----------------------------------------------------------------------------
+class TCPListener
+{
+public:
+
+	//-----------------------------------------------------------------------------
+	bool open(uint16_t port)
+	{
+		int& sock_id = m_listener.m_socket;
+
+		sock_id = socket(AF_INET, SOCK_STREAM, 0);
+		CE_ASSERT(socket_id != INVALID_SOCKET, "Unable to open socket");
+
+		// set non-blocking io
+		DWORD non_blocking = 1;
+		int result = ioctlsocket(sock_id, FIONBIO, &non_blocking);
+		CE_ASSERT(result == 0, "Unable to set socket non-blocking");
+
+		// Bind socket
+		sockaddr_in address;
+		address.sin_family = AF_INET;
+		address.sin_addr.s_addr = htonl(INADDR_ANY);
+		address.sin_port = htons(port);
+
+		result = ::bind(sock_id, (const sockaddr*)&address, sizeof(sockaddr_in));
+		CE_ASSERT(result == 0, "Unable to bind socket");
+		
+		result = ::listen(sd, 5);
+		CE_ASSERT(result == 0, "Unable to listen on socket");
+
+		return true;  
+	}
+
+	//-----------------------------------------------------------------------------
+	void close()
+	{
+		m_listener.close();
+	}
+
+	//-----------------------------------------------------------------------------
+	bool listen(TCPSocket& c)
+	{
+		int& sock_id = m_listener.m_socket;
+
+		sockaddr_in client;
+		uint32_t client_length = sizeof(client);
+
+		int32_t asd = accept(sd, (sockaddr*)&client, &client_length);
+		if (asd < 0)
+		{
+			return false;
+		}
+
+		int result = ioctlsocket(asd, FIONBIO, &non_blocking);
+		CE_ASSERT(result == 0, "Unable to set socket non-blocking");		
+
+		c.m_socket = asd;
+
+		return true;
+	}
+
+	//-----------------------------------------------------------------------------
+	ReadResult read(void* data, size_t size)
+	{
+		return m_listener.read(data, size);
+	}
+
+	//-----------------------------------------------------------------------------
+	WriteResult write(const void* data, size_t size)
+	{
+		return m_listener.write(data, size);
+	}
+
+private:
+
+	TCPSocket m_listener;
+};
+
+//-----------------------------------------------------------------------------
+class UDPSocket
+{
+	//-----------------------------------------------------------------------------
+	UDPSocket::UDPSocket()
+		: m_socket(0)
+	{
+	}
+
+	//-----------------------------------------------------------------------------
+	UDPSocket::~UDPSocket()
+	{
+		close();
+	}
+
+	//-----------------------------------------------------------------------------
+	bool UDPSocket::open(uint16_t port)
+	{
+		CE_ASSERT(!is_open(), "Socket is already open");
+
+		m_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+		CE_ASSERT(m_socket != INVALID_SOCKET, "Unable to open socket");
+
+		// bind to port
+		sockaddr_in address;
+		address.sin_family = AF_INET;
+		address.sin_addr.s_addr = INADDR_ANY;
+		address.sin_port = htons(port);
+
+		int result = ::bind(m_socket, (const sockaddr*)&address, sizeof(sockaddr_in));
+		CE_ASSERT(result == 0, "Unable to bind socket");
+
+		// set non-blocking io
+		DWORD non_blocking = 1;
+		result = ioctlsocket(socket, FIONBIO, &non_blocking);
+		CE_ASSERT(result == 0, "Unable to bind socket");
+
+		return true;
+	}
+
+	//-----------------------------------------------------------------------------
+	ReadResult UDPSocket::read(NetAddress& sender, uint16_t& port, const void* data, size_t size)
+	{
+		CE_ASSERT_NOT_NULL(data);
+
+		typedef int socklen_t;
+
+		sockaddr_in from;
+		socklen_t from_length = sizeof(from);
+
+		int received_bytes = recvfrom(m_socket, (char*)data, size, 0, (sockaddr*)&from, &from_length);
+
+		ReadResult result;
+
+		if (received_bytes < 0)
+		{
+			result.error = ReadResult::NO_ERROR;
+			result.received_bytes = 0;
+		}
+		else if (received_bytes == 0)
+		{
+			result.error = ReadResult::REMOTE_CLOSED;
+		}
+		else
+		{
+			result.error = ReadResult::NO_ERROR;
+			result.received_bytes = received_bytes;
+		}
+
+		sender.set(ntohl(from.sin_addr.s_addr));
+		port = ntohs(from.sin_port);
+
+		return result;
+	}
+
+	//-----------------------------------------------------------------------------
+	WriteResult UDPSocket::write(const NetAddress& receiver, uint16_t port, void* data, size_t size)
+	{
+		CE_ASSERT_NOT_NULL(data);
+
+		if (m_socket == 0)
+		{
+			return false;
+		}
+
+		sockaddr_in address;
+		address.sin_family = AF_INET;
+		address.sin_addr.s_addr = htonl(receiver.get_address());
+		address.sin_port = htons(receiver.get_port());
+
+		int32_t sent_bytes = sendto(m_socket, (const char*)data, size, 0, (sockaddr*)&address, sizeof(sockaddr_in));
+
+		WriteResult result;
+
+		if (sent_bytes < 0)
+		{
+			result.error = WriteResult::UNKNOWN;
+			return result;
+		}
+
+		result.error = WriteResult::NO_ERROR;
+		result.sent_bytes = sent_bytes;
+
+		return result;
+	}
+
+	//-----------------------------------------------------------------------------
+	void UDPSocket::close()
+	{
+		if (m_socket != 0)
+		{
+			::close(m_socket);
+			m_socket = 0;
+		}
+	}
+
+	//-----------------------------------------------------------------------------
+	bool UDPSocket::is_open()
+	{
+		return m_socket != 0; 
+	}
+
+};
+
+} // namespace crown

+ 6 - 0
engine/os/win/main.cpp

@@ -25,6 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include <windowsx.h>
+#include <winsock2.h>
 
 #define WM_USER_SET_WINDOW_SIZE     (WM_USER+0)
 #define WM_USER_TOGGLE_WINDOW_FRAME (WM_USER+1)
@@ -181,6 +182,9 @@ public:
 	{
 		init(argc, argv);
 
+		WSADATA WsaData;
+		CE_ASSERT(WSAStartup(MAKEWORD(2,2), &WsaData) == NO_ERROR, "Unable to initialize socket");
+
 		HINSTANCE instance = (HINSTANCE)GetModuleHandle(NULL);
 
 		WNDCLASSEX wnd;
@@ -271,6 +275,8 @@ public:
 		DestroyWindow(m_hwnd);
 		DestroyWindow(hwnd);
 
+		WSACleanup();
+
 		return 0;
 	}
 

+ 22 - 22
engine/renderers/DebugRenderer.cpp

@@ -44,7 +44,7 @@ DebugRenderer::~DebugRenderer()
 }
 
 //-----------------------------------------------------------------------------
-void DebugRenderer::add_line(const Vec3& start, const Vec3& end, const Color4& color, bool depth_write)
+void DebugRenderer::add_line(const Vector3& start, const Vector3& end, const Color4& color, bool depth_write)
 {
 	if (m_lines_count >= MAX_DEBUG_LINES)
 	{
@@ -64,7 +64,7 @@ void DebugRenderer::add_line(const Vec3& start, const Vec3& end, const Color4& c
 }
 
 //-----------------------------------------------------------------------------
-void DebugRenderer::add_sphere(const Vec3& center, const float radius, const Color4& color, bool depth_write)
+void DebugRenderer::add_sphere(const Vector3& center, const float radius, const Color4& color, bool depth_write)
 {
 	const uint32_t deg_step = 15;
 
@@ -74,8 +74,8 @@ void DebugRenderer::add_sphere(const Vec3& center, const float radius, const Col
 		float rad_0 = math::deg_to_rad(deg);
 		float rad_1 = math::deg_to_rad(deg + deg_step);
 
-		Vec3 start(math::cos(rad_0) * radius, 0, -math::sin(rad_0) * radius);
-		Vec3 end  (math::cos(rad_1) * radius, 0, -math::sin(rad_1) * radius);
+		Vector3 start(math::cos(rad_0) * radius, 0, -math::sin(rad_0) * radius);
+		Vector3 end  (math::cos(rad_1) * radius, 0, -math::sin(rad_1) * radius);
 
 		add_line(center + start, center + end, color, depth_write);
 	}
@@ -86,8 +86,8 @@ void DebugRenderer::add_sphere(const Vec3& center, const float radius, const Col
 		float rad_0 = math::deg_to_rad(deg);
 		float rad_1 = math::deg_to_rad(deg + deg_step);
 
-		Vec3 start(math::cos(rad_0) * radius, math::sin(rad_0) * radius, 0);
-		Vec3 end  (math::cos(rad_1) * radius, math::sin(rad_1) * radius, 0);
+		Vector3 start(math::cos(rad_0) * radius, math::sin(rad_0) * radius, 0);
+		Vector3 end  (math::cos(rad_1) * radius, math::sin(rad_1) * radius, 0);
 
 		add_line(center + start, center + end, color, depth_write);
 	}
@@ -98,37 +98,37 @@ void DebugRenderer::add_sphere(const Vec3& center, const float radius, const Col
 		float rad_0 = math::deg_to_rad(deg);
 		float rad_1 = math::deg_to_rad(deg + deg_step);
 
-		Vec3 start(0, math::sin(rad_0) * radius, -math::cos(rad_0) * radius);
-		Vec3 end  (0, math::sin(rad_1) * radius, -math::cos(rad_1) * radius);
+		Vector3 start(0, math::sin(rad_0) * radius, -math::cos(rad_0) * radius);
+		Vector3 end  (0, math::sin(rad_1) * radius, -math::cos(rad_1) * radius);
 
 		add_line(center + start, center + end, color, depth_write);
 	}
 }
 
 //-----------------------------------------------------------------------------
-void DebugRenderer::add_box(const Vec3& min, const Vec3& max, const Color4& color, bool depth_write)
+void DebugRenderer::add_box(const Vector3& min, const Vector3& max, const Color4& color, bool depth_write)
 {
 	// Back lines
-	add_line(min                      , Vec3(max.x, min.y, min.z), color, depth_write);
-	add_line(Vec3(max.x, min.y, min.z), Vec3(max.x, max.y, min.z), color, depth_write);
-	add_line(Vec3(max.x, max.y, min.z), Vec3(min.x, max.y, min.z), color, depth_write);
-	add_line(Vec3(min.x, max.y, min.z), min                      , color, depth_write);
+	add_line(min                      , Vector3(max.x, min.y, min.z), color, depth_write);
+	add_line(Vector3(max.x, min.y, min.z), Vector3(max.x, max.y, min.z), color, depth_write);
+	add_line(Vector3(max.x, max.y, min.z), Vector3(min.x, max.y, min.z), color, depth_write);
+	add_line(Vector3(min.x, max.y, min.z), min                      , color, depth_write);
 
 	// Front lines
-	add_line(Vec3(min.x, min.y, max.z), Vec3(max.x, min.y, max.z), color, depth_write);
-	add_line(Vec3(max.x, min.y, max.z), Vec3(max.x, max.y, max.z), color, depth_write);
-	add_line(Vec3(max.x, max.y, max.z), Vec3(min.x, max.y, max.z), color, depth_write);
-	add_line(Vec3(min.x, max.y, max.z), Vec3(min.x, min.y, max.z), color, depth_write);
+	add_line(Vector3(min.x, min.y, max.z), Vector3(max.x, min.y, max.z), color, depth_write);
+	add_line(Vector3(max.x, min.y, max.z), Vector3(max.x, max.y, max.z), color, depth_write);
+	add_line(Vector3(max.x, max.y, max.z), Vector3(min.x, max.y, max.z), color, depth_write);
+	add_line(Vector3(min.x, max.y, max.z), Vector3(min.x, min.y, max.z), color, depth_write);
 
 	// Connect back and front vertices
-	add_line(min                      , Vec3(min.x, min.y, max.z), color, depth_write);
-	add_line(Vec3(max.x, min.y, min.z), Vec3(max.x, min.y, max.z), color, depth_write);
-	add_line(Vec3(max.x, max.y, min.z), Vec3(max.x, max.y, max.z), color, depth_write);
-	add_line(Vec3(min.x, max.y, min.z), Vec3(min.x, max.y, max.z), color, depth_write);
+	add_line(min                      , Vector3(min.x, min.y, max.z), color, depth_write);
+	add_line(Vector3(max.x, min.y, min.z), Vector3(max.x, min.y, max.z), color, depth_write);
+	add_line(Vector3(max.x, max.y, min.z), Vector3(max.x, max.y, max.z), color, depth_write);
+	add_line(Vector3(min.x, max.y, min.z), Vector3(min.x, max.y, max.z), color, depth_write);
 }
 
 //-----------------------------------------------------------------------------
-void DebugRenderer::add_pose(const Mat4& pose, bool depth_write)
+void DebugRenderer::add_pose(const Matrix4x4& pose, bool depth_write)
 {
 	add_line(pose.translation(), pose.translation() + pose.x(), Color4::RED, depth_write);
 	add_line(pose.translation(), pose.translation() + pose.y(), Color4::GREEN, depth_write);

+ 7 - 7
engine/renderers/DebugRenderer.h

@@ -27,9 +27,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "Vec3.h"
+#include "Vector3.h"
 #include "Color4.h"
-#include "Mat4.h"
+#include "Matrix4x4.h"
 
 namespace crown
 {
@@ -49,16 +49,16 @@ public:
 				DebugRenderer(Renderer& renderer);
 				~DebugRenderer();
 
-	void		add_line(const Vec3& start, const Vec3& end, const Color4& color, bool depth_write);
+	void		add_line(const Vector3& start, const Vector3& end, const Color4& color, bool depth_write);
 
 	/// Total cost: 72 lines
-	void		add_sphere(const Vec3& center, const float radius, const Color4& color, bool depth_write);
+	void		add_sphere(const Vector3& center, const float radius, const Color4& color, bool depth_write);
 
 	/// Total cost: 12 lines
-	void		add_box(const Vec3& min, const Vec3& max, const Color4& color, bool depth_write);
+	void		add_box(const Vector3& min, const Vector3& max, const Color4& color, bool depth_write);
 
 	/// Total cost: 3 lines
-	void		add_pose(const Mat4& pose, bool depth_write);
+	void		add_pose(const Matrix4x4& pose, bool depth_write);
 
 private:
 
@@ -70,7 +70,7 @@ private:
 
 	uint32_t	m_lines_count;
 
-	Vec3		m_lines[MAX_DEBUG_LINES * 2];
+	Vector3		m_lines[MAX_DEBUG_LINES * 2];
 	Color4		m_colors[MAX_DEBUG_LINES * 2];
 	bool		m_depth_writes[MAX_DEBUG_LINES * 2];
 

+ 8 - 8
engine/renderers/RenderContext.h

@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Color4.h"
-#include "Mat4.h"
+#include "Matrix4x4.h"
 #include "IdTable.h"
 #include "CommandBuffer.h"
 #include "ConstantBuffer.h"
@@ -131,7 +131,7 @@ struct RenderState
 	{
 		m_flags = STATE_NONE;
 
-		pose = Mat4::IDENTITY;
+		pose = Matrix4x4::IDENTITY;
 		program.id = INVALID_ID;
 		vb.id = INVALID_ID;
 		ib.id = INVALID_ID;
@@ -147,7 +147,7 @@ public:
 
 	uint64_t		m_flags;
 
-	Mat4			pose;
+	Matrix4x4			pose;
 	GPUProgramId	program;
 	VertexBufferId	vb;
 	IndexBufferId	ib;
@@ -188,7 +188,7 @@ struct RenderContext
 		m_state.m_flags = flags;
 	}
 
-	void set_pose(const Mat4& pose)
+	void set_pose(const Matrix4x4& pose)
 	{
 		m_state.pose = pose;
 	}
@@ -240,14 +240,14 @@ struct RenderContext
 		m_clears[layer].m_depth = depth;
 	}
 
-	void set_layer_view(uint8_t layer, const Mat4& view)
+	void set_layer_view(uint8_t layer, const Matrix4x4& view)
 	{
 		CE_ASSERT(layer < MAX_RENDER_LAYERS, "Layer out of bounds");
 
 		m_view_matrices[layer] = view;
 	}
 
-	void set_layer_projection(uint8_t layer, const Mat4& projection)
+	void set_layer_projection(uint8_t layer, const Matrix4x4& projection)
 	{
 		CE_ASSERT(layer < MAX_RENDER_LAYERS, "Layer out of bounds");
 
@@ -315,8 +315,8 @@ public:
 
 	// Per-layer data
 	RenderTargetId m_targets[MAX_RENDER_LAYERS];
-	Mat4 m_view_matrices[MAX_RENDER_LAYERS];
-	Mat4 m_projection_matrices[MAX_RENDER_LAYERS];
+	Matrix4x4 m_view_matrices[MAX_RENDER_LAYERS];
+	Matrix4x4 m_projection_matrices[MAX_RENDER_LAYERS];
 	ViewRect m_viewports[MAX_RENDER_LAYERS];
 	ViewRect m_scissors[MAX_RENDER_LAYERS];
 

+ 3 - 3
engine/renderers/Renderer.h

@@ -569,7 +569,7 @@ public:
 		m_submit->set_state(flags);
 	}
 
-	inline void set_pose(const Mat4& pose)
+	inline void set_pose(const Matrix4x4& pose)
 	{
 		m_submit->set_pose(pose);
 	}
@@ -609,12 +609,12 @@ public:
 		m_submit->set_layer_clear(layer, flags, color, depth);
 	}
 
-	inline void set_layer_view(uint8_t layer, const Mat4& view)
+	inline void set_layer_view(uint8_t layer, const Matrix4x4& view)
 	{
 		m_submit->set_layer_view(layer, view);
 	}
 
-	inline void set_layer_projection(uint8_t layer, const Mat4& projection)
+	inline void set_layer_projection(uint8_t layer, const Matrix4x4& projection)
 	{
 		m_submit->set_layer_projection(layer, projection);
 	}

+ 5 - 5
engine/renderers/gl/GLRenderer.cpp

@@ -40,9 +40,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Types.h"
 #include "GLRenderer.h"
 #include "Log.h"
-#include "Vec4.h"
-#include "Mat3.h"
-#include "Mat4.h"
+#include "Vector4.h"
+#include "Matrix3x3.h"
+#include "Matrix4x4.h"
 #include "Device.h"
 #include "Hash.h"
 #include "StringUtils.h"
@@ -309,8 +309,8 @@ public:
 				for (uint8_t uniform = 0; uniform < gpu_program.m_num_stock_uniforms; uniform++)
 				{
 					const GLint& uniform_location = gpu_program.m_stock_uniform_locations[uniform];
-					const Mat4& view = context.m_view_matrices[layer];
-					const Mat4& projection = context.m_projection_matrices[layer];
+					const Matrix4x4& view = context.m_view_matrices[layer];
+					const Matrix4x4& projection = context.m_projection_matrices[layer];
 
 					switch (gpu_program.m_stock_uniforms[uniform])
 					{

+ 1 - 1
engine/resource/MaterialResource.h

@@ -29,7 +29,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Types.h"
 #include "TextureResource.h"
 #include "Resource.h"
-#include "Vec3.h"
+#include "Vector3.h"
 #include "Color4.h"
 #include "Bundle.h"
 #include "Allocator.h"

+ 3 - 3
engine/tests/messages.cpp

@@ -1,6 +1,6 @@
 #include <cstdio>
 
-#include "Vec3.h"
+#include "Vector3.h"
 #include "OS.h"
 #include "NetAddress.h"
 #include "BitMessage.h"
@@ -220,8 +220,8 @@ void test_vec3()
   	network::BitMessage m = network::BitMessage(allocator);
 	
 	
-	Vec3 v(0.525f, 0.432f, 0.234f);
-	Vec3 res;
+	Vector3 v(0.525f, 0.432f, 0.234f);
+	Vector3 res;
 	
 	m.init(12);
 	m.write_vec3(v);

+ 16 - 16
samples/terrain/Terrain.cpp

@@ -29,7 +29,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Renderer.h"
 #include "MathUtils.h"
 #include "Log.h"
-#include "Vec2.h"
+#include "Vector2.h"
 #include "Interpolation.h"
 
 namespace crown
@@ -86,11 +86,11 @@ void Terrain::CreateTerrain(uint32_t xSize, uint32_t zSize, uint32_t tilePerMete
 	}
 
 	// Construct drawing data
-	mVertices = (Vec3*)m_allocator.allocate(heightsCount * sizeof(Vec3));		// There are as many vertices as heights
+	mVertices = (Vector3*)m_allocator.allocate(heightsCount * sizeof(Vector3));		// There are as many vertices as heights
 	mVertexCount = heightsCount;
-	mNormals = (Vec3*)m_allocator.allocate(heightsCount * sizeof(Vec3));		// Same as vertices
+	mNormals = (Vector3*)m_allocator.allocate(heightsCount * sizeof(Vector3));		// Same as vertices
 	mNormalCount = heightsCount;
-	mTexCoords = (Vec2*)m_allocator.allocate(heightsCount * sizeof(Vec2));				// Same as vertices
+	mTexCoords = (Vector2*)m_allocator.allocate(heightsCount * sizeof(Vector2));				// Same as vertices
 	mTexCoordCount = heightsCount;
 	mIndices = (uint16_t*)m_allocator.allocate(mTilesInSizeX * mTilesInSizeZ * 6 * sizeof(uint16_t));	//
 	mIndexCount = mTilesInSizeX * mTilesInSizeZ * 6;
@@ -170,9 +170,9 @@ void Terrain::UpdateVertexBuffer(bool recomputeNormals)
 	{
 		for (uint32_t i = 0; i < mIndexCount; i += 3)
 		{
-			Vec3 normal;
-			Vec3 v1;
-			Vec3 v2;
+			Vector3 normal;
+			Vector3 v1;
+			Vector3 v2;
 
 			v1 = mVertices[mIndices[i + 0]] - mVertices[mIndices[i + 1]];
 			v2 = mVertices[mIndices[i + 2]] - mVertices[mIndices[i + 1]];
@@ -196,7 +196,7 @@ float Terrain::GetHeightAt(uint32_t x, uint32_t z) const
 	return mHeights[z * mVerticesInSizeX + x];
 }
 
-float Terrain::GetHeightAt(const Vec3& xyz) const
+float Terrain::GetHeightAt(const Vector3& xyz) const
 {
 	uint32_t x, z;
 
@@ -214,7 +214,7 @@ void Terrain::SetHeightAt(uint32_t x, uint32_t z, float height)
 	mHeights[z * mVerticesInSizeX + x] = math::clamp_to_range(mMinHeight, mMaxHeight, mHeights[z * mVerticesInSizeX + x]);
 }
 
-void Terrain::SetHeightAt(const Vec3& xyz, float height)
+void Terrain::SetHeightAt(const Vector3& xyz, float height)
 {
 	uint32_t x, z;
 
@@ -223,9 +223,9 @@ void Terrain::SetHeightAt(const Vec3& xyz, float height)
 	SetHeightAt(x + 0, z + 0, height);
 }
 
-void Terrain::WorldToHeight(const Vec3& xyz, uint32_t& x, uint32_t& z) const
+void Terrain::WorldToHeight(const Vector3& xyz, uint32_t& x, uint32_t& z) const
 {
-	Vec3 offsetted = xyz + Vec3(-mOffsetX, 0.0f, mOffsetZ);
+	Vector3 offsetted = xyz + Vector3(-mOffsetX, 0.0f, mOffsetZ);
 	offsetted.z = (float)mSizeZ - offsetted.z;
 
 	x = (uint32_t)offsetted.x;
@@ -242,7 +242,7 @@ bool Terrain::TraceRay(const Ray& ray, Triangle& result, Triangle& /*tri2*/, flo
 		Triangle tri(mVertices[mIndices[i + 0]], mVertices[mIndices[i + 1]], mVertices[mIndices[i + 2]]);
 
 		float ret;
-		Vec3 int32_tersectionPoint32_t;
+		Vector3 int32_tersectionPoint32_t;
 		if (Intersection::test_ray_triangle(ray, tri, ret, int32_tersectionPoint32_t))
 		{
 			if (ret < minDist)
@@ -259,15 +259,15 @@ bool Terrain::TraceRay(const Ray& ray, Triangle& result, Triangle& /*tri2*/, flo
 	return hit;
 }
 
-uint32_t Terrain::SnapToGrid(const Vec3& vertex)
+uint32_t Terrain::SnapToGrid(const Vector3& vertex)
 {
 	float minDist = 9999999.0f;
 	uint32_t indexToSnapped;
 	// Find the snapped point32_t to input vertex
 	for (uint32_t i = 0; i < mVertexCount; i++)
 	{
-		Vec3 tmp = mVertices[i];
-		Vec3 vertex2 = vertex;
+		Vector3 tmp = mVertices[i];
+		Vector3 vertex2 = vertex;
 		tmp.y = vertex2.y = 0.0f;
 
 		if (tmp.get_distance_to(vertex2) < minDist)
@@ -367,7 +367,7 @@ void Terrain::ApplyBrush(uint32_t x, uint32_t z, float scale)
 	}
 }
 
-void Terrain::ApplyBrush(const Vec3& xyz, float scale)
+void Terrain::ApplyBrush(const Vector3& xyz, float scale)
 {
 	uint32_t x, z;
 

+ 9 - 9
samples/terrain/Terrain.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include "Vec3.h"
+#include "Vector3.h"
 #include "Triangle.h"
 #include "Intersection.h"
 #include "Ray.h"
@@ -49,24 +49,24 @@ public:
 	void		CreateTerrain(uint32_t xSize, uint32_t zSize, uint32_t tilePerMeter, float initialHeight);
 
 	float		GetHeightAt(uint32_t x, uint32_t z) const;
-	float		GetHeightAt(const Vec3& xyz) const;
+	float		GetHeightAt(const Vector3& xyz) const;
 
 	void		SetHeightAt(uint32_t x, uint32_t z, float height);
-	void		SetHeightAt(const Vec3& xyz, float height);
+	void		SetHeightAt(const Vector3& xyz, float height);
 
-	void		WorldToHeight(const Vec3& xyz, uint32_t& x, uint32_t& z) const;
+	void		WorldToHeight(const Vector3& xyz, uint32_t& x, uint32_t& z) const;
 
 	void		UpdateVertexBuffer(bool recomputeNormals);
 
 	bool		TraceRay(const Ray& ray, Triangle& result, Triangle& tri2, float& dist);
 
-	uint32_t	SnapToGrid(const Vec3& vertex);
+	uint32_t	SnapToGrid(const Vector3& vertex);
 
 	void		BuildBrush(uint32_t width, uint32_t height, float smooth);
 	float		GaussDist(float x, float y, float sigma);
 
 	void		ApplyBrush(uint32_t x, uint32_t z, float scale);
-	void		ApplyBrush(const Vec3& xyz, float scale);
+	void		ApplyBrush(const Vector3& xyz, float scale);
 
 	void		PlotCircle(int32_t xx, int32_t yy, int32_t radius, int32_t i);
 
@@ -91,13 +91,13 @@ private:
 	float			mMaxHeight;
 
 	uint32_t		mVertexCount;
-	Vec3*			mVertices;
+	Vector3*			mVertices;
 
 	uint32_t		mNormalCount;
-	Vec3*			mNormals;
+	Vector3*			mNormals;
 
 	uint32_t		mTexCoordCount;
-	Vec2*			mTexCoords;
+	Vector2*			mTexCoords;
 
 	uint32_t		mIndexCount;
 	uint16_t*		mIndices;

+ 4 - 4
samples/terrain/terrain_main.cpp

@@ -80,7 +80,7 @@ public:
 	//{
 	//	crown::Renderer* renderer = crown::device()->renderer();
 	//	
-	//	Vec3 start = Vec3(0.0f, 10.0f, 0.0f);
+	//	Vector3 start = Vector3(0.0f, 10.0f, 0.0f);
 
 	//	// Add a movable camera
 	//	cam = CE_NEW(m_allocator, Camera)(start, 90.0f, 1.6f);
@@ -141,7 +141,7 @@ public:
 	//	/* Render the terrain */
 	//	renderer->set_ambient_light(Color4(0.5f, 0.5f, 0.5f, 1.0f));
 
-	//	renderer->set_matrix(MT_MODEL, Mat4::IDENTITY);
+	//	renderer->set_matrix(MT_MODEL, Matrix4x4::IDENTITY);
 
 	//	if (device()->is_loaded(grass))
 	//	{
@@ -157,7 +157,7 @@ public:
 	//	if (terrain.TraceRay(ray, tri, tri2, dist))
 	//	{
 	//		renderer->set_depth_test(false);
-	//		Vec3 intersectionPoint = ray.origin() + (ray.direction() * dist);
+	//		Vector3 intersectionPoint = ray.origin() + (ray.direction() * dist);
 	//		if (mouseLeftPressed)
 	//		{
 	//			terrain.ApplyBrush(intersectionPoint, 0.09f);
@@ -177,7 +177,7 @@ public:
 	//HeapAllocator m_allocator;
 	//FPSSystem* system;
 	//Camera* cam;
-	//Mat4 ortho;
+	//Matrix4x4 ortho;
 	//Terrain terrain;
 
 	//// Resources

+ 46 - 46
tools/gui/console/MainWindow.cs

@@ -91,52 +91,52 @@ public partial class MainWindow: Gtk.Window
 		lua_api.AppendValues ("Math.atan2");
 		lua_api.AppendValues ("Math.abs");
 		lua_api.AppendValues ("Math.fmod");
-		lua_api.AppendValues ("Vec2.new");
-		lua_api.AppendValues ("Vec2.val");
-		lua_api.AppendValues ("Vec2.add");
-		lua_api.AppendValues ("Vec2.sub");
-		lua_api.AppendValues ("Vec2.mul");
-		lua_api.AppendValues ("Vec2.div");
-		lua_api.AppendValues ("Vec2.dot");
-		lua_api.AppendValues ("Vec2.equals");
-		lua_api.AppendValues ("Vec2.lower");
-		lua_api.AppendValues ("Vec2.greater");
-		lua_api.AppendValues ("Vec2.length");
-		lua_api.AppendValues ("Vec2.squared_length");
-		lua_api.AppendValues ("Vec2.set_length");
-		lua_api.AppendValues ("Vec2.normalize");
-		lua_api.AppendValues ("Vec2.negate");
-		lua_api.AppendValues ("Vec2.get_distance_to");
-		lua_api.AppendValues ("Vec2.get_angle_between");
-		lua_api.AppendValues ("Vec2.zero");
-		lua_api.AppendValues ("Vec3.new");
-		lua_api.AppendValues ("Vec3.val");
-		lua_api.AppendValues ("Vec3.add");
-		lua_api.AppendValues ("Vec3.sub");
-		lua_api.AppendValues ("Vec3.mul");
-		lua_api.AppendValues ("Vec3.div");
-		lua_api.AppendValues ("Vec3.dot");
-		lua_api.AppendValues ("Vec3.cross");
-		lua_api.AppendValues ("Vec3.equals");
-		lua_api.AppendValues ("Vec3.lower");
-		lua_api.AppendValues ("Vec3.greater");
-		lua_api.AppendValues ("Vec3.length");
-		lua_api.AppendValues ("Vec3.squared_length");
-		lua_api.AppendValues ("Vec3.set_length");
-		lua_api.AppendValues ("Vec3.normalize");
-		lua_api.AppendValues ("Vec3.negate");
-		lua_api.AppendValues ("Vec3.get_distance_to");
-		lua_api.AppendValues ("Vec3.get_angle_between");
-		lua_api.AppendValues ("Vec3.zero");
-		lua_api.AppendValues ("Quat.new");
-		lua_api.AppendValues ("Quat.negate");
-		lua_api.AppendValues ("Quat.load_identity");
-		lua_api.AppendValues ("Quat.length");
-		lua_api.AppendValues ("Quat.conjugate");
-		lua_api.AppendValues ("Quat.inverse");
-		lua_api.AppendValues ("Quat.cross");
-		lua_api.AppendValues ("Quat.mul");
-		lua_api.AppendValues ("Quat.pow");
+		lua_api.AppendValues ("Vector2.new");
+		lua_api.AppendValues ("Vector2.val");
+		lua_api.AppendValues ("Vector2.add");
+		lua_api.AppendValues ("Vector2.sub");
+		lua_api.AppendValues ("Vector2.mul");
+		lua_api.AppendValues ("Vector2.div");
+		lua_api.AppendValues ("Vector2.dot");
+		lua_api.AppendValues ("Vector2.equals");
+		lua_api.AppendValues ("Vector2.lower");
+		lua_api.AppendValues ("Vector2.greater");
+		lua_api.AppendValues ("Vector2.length");
+		lua_api.AppendValues ("Vector2.squared_length");
+		lua_api.AppendValues ("Vector2.set_length");
+		lua_api.AppendValues ("Vector2.normalize");
+		lua_api.AppendValues ("Vector2.negate");
+		lua_api.AppendValues ("Vector2.get_distance_to");
+		lua_api.AppendValues ("Vector2.get_angle_between");
+		lua_api.AppendValues ("Vector2.zero");
+		lua_api.AppendValues ("Vector3.new");
+		lua_api.AppendValues ("Vector3.val");
+		lua_api.AppendValues ("Vector3.add");
+		lua_api.AppendValues ("Vector3.sub");
+		lua_api.AppendValues ("Vector3.mul");
+		lua_api.AppendValues ("Vector3.div");
+		lua_api.AppendValues ("Vector3.dot");
+		lua_api.AppendValues ("Vector3.cross");
+		lua_api.AppendValues ("Vector3.equals");
+		lua_api.AppendValues ("Vector3.lower");
+		lua_api.AppendValues ("Vector3.greater");
+		lua_api.AppendValues ("Vector3.length");
+		lua_api.AppendValues ("Vector3.squared_length");
+		lua_api.AppendValues ("Vector3.set_length");
+		lua_api.AppendValues ("Vector3.normalize");
+		lua_api.AppendValues ("Vector3.negate");
+		lua_api.AppendValues ("Vector3.get_distance_to");
+		lua_api.AppendValues ("Vector3.get_angle_between");
+		lua_api.AppendValues ("Vector3.zero");
+		lua_api.AppendValues ("Quaternion.new");
+		lua_api.AppendValues ("Quaternion.negate");
+		lua_api.AppendValues ("Quaternion.load_identity");
+		lua_api.AppendValues ("Quaternion.length");
+		lua_api.AppendValues ("Quaternion.conjugate");
+		lua_api.AppendValues ("Quaternion.inverse");
+		lua_api.AppendValues ("Quaternion.cross");
+		lua_api.AppendValues ("Quaternion.mul");
+		lua_api.AppendValues ("Quaternion.pow");
 		lua_api.AppendValues ("StringSetting.value");
 		lua_api.AppendValues ("StringSetting.synopsis");
 		lua_api.AppendValues ("StringSetting.update");