summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-03-07 21:43:15 +0100
committermadmaxoft <github@xoft.cz>2014-03-09 15:24:11 +0100
commit93f0de521a0e2abb9c35dfb06bd3d306c548bf1b (patch)
tree11d616affc7542d7ded3dd7f91ebee114e0ea950
parentAdded the first skeleton code for PieceGenerator. (diff)
downloadcuberite-93f0de521a0e2abb9c35dfb06bd3d306c548bf1b.tar
cuberite-93f0de521a0e2abb9c35dfb06bd3d306c548bf1b.tar.gz
cuberite-93f0de521a0e2abb9c35dfb06bd3d306c548bf1b.tar.bz2
cuberite-93f0de521a0e2abb9c35dfb06bd3d306c548bf1b.tar.lz
cuberite-93f0de521a0e2abb9c35dfb06bd3d306c548bf1b.tar.xz
cuberite-93f0de521a0e2abb9c35dfb06bd3d306c548bf1b.tar.zst
cuberite-93f0de521a0e2abb9c35dfb06bd3d306c548bf1b.zip
-rw-r--r--src/Vector3i.cpp52
-rw-r--r--src/Vector3i.h47
2 files changed, 82 insertions, 17 deletions
diff --git a/src/Vector3i.cpp b/src/Vector3i.cpp
index 4ce1e2cf3..2106aea6d 100644
--- a/src/Vector3i.cpp
+++ b/src/Vector3i.cpp
@@ -1,6 +1,11 @@
+// Vector3i.cpp
+
+// Implements the Vector3i class representing an int-based 3D vector
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+#include "math.h"
#include "Vector3i.h"
#include "Vector3d.h"
@@ -8,9 +13,46 @@
-Vector3i::Vector3i( const Vector3d & v )
- : x( (int)v.x )
- , y( (int)v.y )
- , z( (int)v.z )
+Vector3i::Vector3i(const Vector3d & v) :
+ x((int)v.x),
+ y((int)v.y),
+ z((int)v.z)
+{
+}
+
+
+
+
+
+Vector3i::Vector3i(void) :
+ x(0),
+ y(0),
+ z(0)
+{
+}
+
+
+
+
+
+Vector3i::Vector3i(int a_x, int a_y, int a_z) :
+ x(a_x),
+ y(a_y),
+ z(a_z)
+{
+}
+
+
+
+
+
+void Vector3i::Move(int a_MoveX, int a_MoveY, int a_MoveZ)
{
-} \ No newline at end of file
+ x += a_MoveX;
+ y += a_MoveY;
+ z += a_MoveZ;
+}
+
+
+
+
diff --git a/src/Vector3i.h b/src/Vector3i.h
index 7d726a7b3..39e138683 100644
--- a/src/Vector3i.h
+++ b/src/Vector3i.h
@@ -1,22 +1,45 @@
+
+// Vector3i.h
+
+// Declares the Vector3i class representing an int-based 3D vector
+
+
+
+
+
#pragma once
-#include <math.h>
+
+
+
+// fwd:
class Vector3d;
-class Vector3i // tolua_export
-{ // tolua_export
-public: // tolua_export
- Vector3i( const Vector3d & v ); // tolua_export
- Vector3i() : x(0), y(0), z(0) {} // tolua_export
- Vector3i(int a_x, int a_y, int a_z) : x(a_x), y(a_y), z(a_z) {} // tolua_export
- inline void Set(int a_x, int a_y, int a_z) { x = a_x, y = a_y, z = a_z; } // tolua_export
- inline float Length() const { return sqrtf( (float)( x * x + y * y + z * z) ); } // tolua_export
- inline int SqrLength() const { return x * x + y * y + z * z; } // tolua_export
- inline bool Equals( const Vector3i & v ) const { return (x == v.x && y == v.y && z == v.z ); } // tolua_export
- inline bool Equals( const Vector3i * v ) const { return (x == v->x && y == v->y && z == v->z ); } // tolua_export
+
+
+// tolua_begin
+class Vector3i
+{
+public:
+ /** Creates an int vector based on the floor()-ed coords of a double vector. */
+ Vector3i(const Vector3d & v);
+
+ Vector3i(void);
+ Vector3i(int a_x, int a_y, int a_z);
+
+ inline void Set(int a_x, int a_y, int a_z) { x = a_x, y = a_y, z = a_z; }
+ inline float Length() const { return sqrtf( (float)( x * x + y * y + z * z) ); }
+ inline int SqrLength() const { return x * x + y * y + z * z; }
+
+ inline bool Equals( const Vector3i & v ) const { return (x == v.x && y == v.y && z == v.z ); }
+ inline bool Equals( const Vector3i * v ) const { return (x == v->x && y == v->y && z == v->z ); }
+
+ void Move(int a_MoveX, int a_MoveY, int a_MoveZ);
+
+ // tolua_end
void operator += ( const Vector3i& a_V ) { x += a_V.x; y += a_V.y; z += a_V.z; }
void operator += ( Vector3i* a_V ) { x += a_V->x; y += a_V->y; z += a_V->z; }