Unified Vector classes
This commit is contained in:
parent
b72661681c
commit
b4bf13aa4f
@ -11,6 +11,7 @@ typedef unsigned int UInt32;
|
||||
typedef unsigned short UInt16;
|
||||
|
||||
|
||||
$cfile "../Vector3.h"
|
||||
$cfile "../ChunkDef.h"
|
||||
$cfile "../BiomeDef.h"
|
||||
|
||||
@ -62,9 +63,6 @@ $cfile "../BlockEntities/MobHeadEntity.h"
|
||||
$cfile "../BlockEntities/FlowerPotEntity.h"
|
||||
$cfile "../WebAdmin.h"
|
||||
$cfile "../Root.h"
|
||||
$cfile "../Vector3f.h"
|
||||
$cfile "../Vector3d.h"
|
||||
$cfile "../Vector3i.h"
|
||||
$cfile "../Matrix4f.h"
|
||||
$cfile "../Cuboid.h"
|
||||
$cfile "../BoundingBox.h"
|
||||
@ -97,4 +95,10 @@ typedef unsigned char Byte;
|
||||
|
||||
|
||||
|
||||
// Aliases
|
||||
$renaming Vector3<double> @ Vector3d
|
||||
$renaming Vector3<float> @ Vector3f
|
||||
$renaming Vector3<int> @ Vector3i
|
||||
|
||||
|
||||
|
||||
|
@ -29,6 +29,8 @@ extern "C"
|
||||
#include "lua/src/lauxlib.h"
|
||||
}
|
||||
|
||||
#include "../Vector3.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@ -52,7 +54,6 @@ class cWebAdmin;
|
||||
struct HTTPTemplateRequest;
|
||||
class cTNTEntity;
|
||||
class cCreeper;
|
||||
class Vector3i;
|
||||
class cHopperEntity;
|
||||
class cBlockEntity;
|
||||
|
||||
|
@ -13,13 +13,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "ForEachChunkProvider.h"
|
||||
#include "Vector3.h"
|
||||
|
||||
|
||||
|
||||
|
||||
// fwd:
|
||||
class cCuboid;
|
||||
class Vector3i;
|
||||
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Vector3d.h"
|
||||
#include "Vector3.h"
|
||||
#include "Defines.h"
|
||||
|
||||
|
||||
|
@ -70,9 +70,7 @@ if (NOT MSVC)
|
||||
StringUtils.h
|
||||
Tracer.h
|
||||
UI/Window.h
|
||||
Vector3d.h
|
||||
Vector3f.h
|
||||
Vector3i.h
|
||||
Vector3.h
|
||||
WebAdmin.h
|
||||
World.h
|
||||
)
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Vector3i.h"
|
||||
#include "Vector3.h"
|
||||
#include "BiomeDef.h"
|
||||
|
||||
|
||||
|
@ -22,9 +22,6 @@
|
||||
#include "Blocks/BlockSlab.h"
|
||||
#include "Blocks/ChunkInterface.h"
|
||||
|
||||
#include "Vector3f.h"
|
||||
#include "Vector3d.h"
|
||||
|
||||
#include "Root.h"
|
||||
|
||||
#include "Authenticator.h"
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define CCLIENTHANDLE_H_INCLUDED
|
||||
|
||||
#include "Defines.h"
|
||||
#include "Vector3d.h"
|
||||
#include "Vector3.h"
|
||||
#include "OSSupport/SocketThreads.h"
|
||||
#include "ChunkDef.h"
|
||||
#include "ByteBuffer.h"
|
||||
|
@ -1,8 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Vector3i.h"
|
||||
#include "Vector3d.h"
|
||||
#include "Vector3.h"
|
||||
|
||||
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Item.h"
|
||||
#include "../Vector3d.h"
|
||||
#include "../Vector3f.h"
|
||||
#include "../Vector3i.h"
|
||||
#include "../Vector3.h"
|
||||
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "../OSSupport/Timer.h"
|
||||
#include "../Chunk.h"
|
||||
#include "../Items/ItemHandler.h"
|
||||
#include "../Vector3.h"
|
||||
|
||||
#include "inifile/iniFile.h"
|
||||
#include "json/json.h"
|
||||
|
@ -246,6 +246,14 @@ T Clamp(T a_Value, T a_Min, T a_Max)
|
||||
|
||||
|
||||
|
||||
#ifndef TOLUA_TEMPLATE_BIND
|
||||
#define TOLUA_TEMPLATE_BIND(x)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Common headers (part 2, with macros):
|
||||
#include "ChunkDef.h"
|
||||
#include "BiomeDef.h"
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "Globals.h"
|
||||
#include "LineBlockTracer.h"
|
||||
#include "Vector3d.h"
|
||||
#include "Vector3.h"
|
||||
#include "World.h"
|
||||
#include "Chunk.h"
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#include "Vector3f.h"
|
||||
#include "Vector3.h"
|
||||
|
||||
class Matrix4f
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "Bat.h"
|
||||
#include "../Vector3d.h"
|
||||
#include "../Vector3.h"
|
||||
#include "../Chunk.h"
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "Squid.h"
|
||||
#include "../Vector3d.h"
|
||||
#include "../Vector3.h"
|
||||
#include "../Chunk.h"
|
||||
|
||||
|
||||
|
@ -150,6 +150,8 @@ public:
|
||||
/** Removes all registered players */
|
||||
void Reset(void);
|
||||
|
||||
// tolua_begin
|
||||
|
||||
/** Returns the number of registered players */
|
||||
unsigned int GetNumPlayers(void) const;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "MersenneTwister.h"
|
||||
|
||||
#include "inifile/iniFile.h"
|
||||
#include "Vector3f.h"
|
||||
#include "Vector3.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "Simulator.h"
|
||||
#include "../World.h"
|
||||
#include "../Vector3i.h"
|
||||
#include "../BlockID.h"
|
||||
#include "../Defines.h"
|
||||
#include "../Chunk.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Vector3i.h"
|
||||
#include "../Vector3.h"
|
||||
#include "inifile/iniFile.h"
|
||||
|
||||
|
||||
|
@ -4,10 +4,6 @@
|
||||
#include "Tracer.h"
|
||||
#include "World.h"
|
||||
|
||||
#include "Vector3f.h"
|
||||
#include "Vector3i.h"
|
||||
#include "Vector3d.h"
|
||||
|
||||
#include "Entities/Entity.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
|
@ -1,8 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Vector3i.h"
|
||||
#include "Vector3f.h"
|
||||
#include "Vector3.h"
|
||||
|
||||
|
||||
|
||||
|
264
src/Vector3.h
Normal file
264
src/Vector3.h
Normal file
@ -0,0 +1,264 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
// tolua_begin
|
||||
class Vector3
|
||||
{
|
||||
|
||||
TOLUA_TEMPLATE_BIND((T, int, float, double))
|
||||
|
||||
public:
|
||||
|
||||
T x, y, z;
|
||||
|
||||
|
||||
inline Vector3() : x(0), y(0), z(0) {}
|
||||
inline Vector3(T a_x, T a_y, T a_z) : x(a_x), y(a_y), z(a_z) {}
|
||||
|
||||
|
||||
// tolua_end
|
||||
template <typename _T>
|
||||
Vector3(const Vector3<_T> & a_Rhs) : x(a_Rhs.x), y(a_Rhs.y), z(a_Rhs.z) {}
|
||||
|
||||
template <typename _T>
|
||||
Vector3(const Vector3<_T> * a_Rhs) : x(a_Rhs->x), y(a_Rhs->y), z(a_Rhs->z) {}
|
||||
// tolua_begin
|
||||
|
||||
|
||||
inline void Set(T a_x, T a_y, T a_z)
|
||||
{
|
||||
x = a_x;
|
||||
y = a_y;
|
||||
z = a_z;
|
||||
}
|
||||
|
||||
inline void Normalize(void)
|
||||
{
|
||||
T Len = 1.0 / Length();
|
||||
|
||||
x *= Len;
|
||||
y *= Len;
|
||||
z *= Len;
|
||||
}
|
||||
|
||||
inline Vector3<T> NormalizeCopy(void) const
|
||||
{
|
||||
T Len = 1.0 / Length();
|
||||
|
||||
return Vector3<T>(
|
||||
x * Len,
|
||||
y * Len,
|
||||
z * Len
|
||||
);
|
||||
}
|
||||
|
||||
inline void NormalizeCopy(Vector3<T> & a_Rhs) const
|
||||
{
|
||||
T Len = 1.0 / Length();
|
||||
|
||||
a_Rhs.Set(
|
||||
x * Len,
|
||||
y * Len,
|
||||
z * Len
|
||||
);
|
||||
}
|
||||
|
||||
inline T Length(void) const
|
||||
{
|
||||
return sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
inline T SqrLength(void) const
|
||||
{
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
inline T Dot(const Vector3<T> & a_Rhs) const
|
||||
{
|
||||
return x * a_Rhs.x + y * a_Rhs.y + z * a_Rhs.z;
|
||||
}
|
||||
|
||||
inline Vector3<T> Cross(const Vector3<T> & a_Rhs) const
|
||||
{
|
||||
return Vector3<T>(
|
||||
y * a_Rhs.z - z * a_Rhs.y,
|
||||
z * a_Rhs.x - x * a_Rhs.z,
|
||||
x * a_Rhs.y - y * a_Rhs.x
|
||||
);
|
||||
}
|
||||
|
||||
inline bool Equals(const Vector3<T> & a_Rhs) const
|
||||
{
|
||||
return x == a_Rhs.x && y == a_Rhs.y && z == a_Rhs.z;
|
||||
}
|
||||
|
||||
inline bool operator < (const Vector3<T> & a_Rhs)
|
||||
{
|
||||
// return (x < a_Rhs.x) && (y < a_Rhs.y) && (z < a_Rhs.z); ?
|
||||
return (x < a_Rhs.x) || (x == a_Rhs.x && y < a_Rhs.y) || (x == a_Rhs.x && y == a_Rhs.y && z < a_Rhs.z);
|
||||
}
|
||||
|
||||
inline void Move(T a_X, T a_Y, T a_Z)
|
||||
{
|
||||
x += a_X;
|
||||
y += a_Y;
|
||||
z += a_Z;
|
||||
}
|
||||
|
||||
// tolua_end
|
||||
|
||||
inline void operator += (const Vector3<T> & a_Rhs)
|
||||
{
|
||||
x += a_Rhs.x;
|
||||
y += a_Rhs.y;
|
||||
z += a_Rhs.z;
|
||||
}
|
||||
|
||||
inline void operator -= (const Vector3<T> & a_Rhs)
|
||||
{
|
||||
x -= a_Rhs.x;
|
||||
y -= a_Rhs.y;
|
||||
z -= a_Rhs.z;
|
||||
}
|
||||
|
||||
inline void operator *= (const Vector3<T> & a_Rhs)
|
||||
{
|
||||
x *= a_Rhs.x;
|
||||
y *= a_Rhs.y;
|
||||
z *= a_Rhs.z;
|
||||
}
|
||||
|
||||
inline void operator *= (T a_v)
|
||||
{
|
||||
x *= a_v;
|
||||
y *= a_v;
|
||||
z *= a_v;
|
||||
}
|
||||
|
||||
// tolua_begin
|
||||
|
||||
inline Vector3<T> operator + (const Vector3<T>& a_Rhs) const
|
||||
{
|
||||
return Vector3<T>(
|
||||
x + a_Rhs.x,
|
||||
y + a_Rhs.y,
|
||||
z + a_Rhs.z
|
||||
);
|
||||
}
|
||||
|
||||
inline Vector3<T> operator - (const Vector3<T>& a_Rhs) const
|
||||
{
|
||||
return Vector3<T>(
|
||||
x - a_Rhs.x,
|
||||
y - a_Rhs.y,
|
||||
z - a_Rhs.z
|
||||
);
|
||||
}
|
||||
|
||||
inline Vector3<T> operator * (const Vector3<T>& a_Rhs) const
|
||||
{
|
||||
return Vector3<T>(
|
||||
x * a_Rhs.x,
|
||||
y * a_Rhs.y,
|
||||
z * a_Rhs.z
|
||||
);
|
||||
}
|
||||
|
||||
inline Vector3<T> operator * (T a_v) const
|
||||
{
|
||||
return Vector3<T>(
|
||||
x * a_v,
|
||||
y * a_v,
|
||||
z * a_v
|
||||
);
|
||||
}
|
||||
|
||||
inline Vector3<T> operator / (T a_v) const
|
||||
{
|
||||
return Vector3<T>(
|
||||
x / a_v,
|
||||
y / a_v,
|
||||
z / a_v
|
||||
);
|
||||
}
|
||||
|
||||
inline double LineCoeffToXYPlane(const Vector3<T> & a_OtherEnd, T a_Z) const
|
||||
{
|
||||
if (abs(z - a_OtherEnd.z) < EPS)
|
||||
{
|
||||
return NO_INTERSECTION;
|
||||
}
|
||||
|
||||
return (a_Z - z) / (a_OtherEnd.z - z);
|
||||
}
|
||||
|
||||
inline double LineCoeffToXZPlane(const Vector3<T> & a_OtherEnd, T a_Y) const
|
||||
{
|
||||
if (abs(y - a_OtherEnd.y) < EPS)
|
||||
{
|
||||
return NO_INTERSECTION;
|
||||
}
|
||||
|
||||
return (a_Y - y) / (a_OtherEnd.y - y);
|
||||
}
|
||||
|
||||
inline double LineCoeffToYZPlane(const Vector3<T> & a_OtherEnd, T a_X) const
|
||||
{
|
||||
if (abs(x - a_OtherEnd.x) < EPS)
|
||||
{
|
||||
return NO_INTERSECTION;
|
||||
}
|
||||
|
||||
return (a_X - x) / (a_OtherEnd.x - x);
|
||||
}
|
||||
|
||||
/** The max difference between two coords for which the coords are assumed equal. */
|
||||
static const double EPS;
|
||||
|
||||
/** Return value of LineCoeffToPlane() if the line is parallel to the plane. */
|
||||
static const double NO_INTERSECTION;
|
||||
};
|
||||
// tolua_end
|
||||
|
||||
template <typename T>
|
||||
const double Vector3<T>::EPS = 0.000001;
|
||||
|
||||
template <typename T>
|
||||
const double Vector3<T>::NO_INTERSECTION = 1e70;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// tolua_begin
|
||||
typedef Vector3<double> Vector3d;
|
||||
typedef Vector3<float> Vector3f;
|
||||
typedef Vector3<int> Vector3i;
|
||||
// tolua_end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef std::list<Vector3i> cVector3iList;
|
||||
typedef std::vector<Vector3i> cVector3iArray;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,77 +0,0 @@
|
||||
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "Vector3d.h"
|
||||
#include "Vector3f.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const double Vector3d::EPS = 0.000001; ///< The max difference between two coords for which the coords are assumed equal
|
||||
const double Vector3d::NO_INTERSECTION = 1e70; ///< Return value of LineCoeffToPlane() if the line is parallel to the plane
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Vector3d::Vector3d(const Vector3f & v) :
|
||||
x(v.x),
|
||||
y(v.y),
|
||||
z(v.z)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Vector3d::Vector3d(const Vector3f * v) :
|
||||
x(v->x),
|
||||
y(v->y),
|
||||
z(v->z)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
double Vector3d::LineCoeffToXYPlane(const Vector3d & a_OtherEnd, double a_Z) const
|
||||
{
|
||||
if (abs(z - a_OtherEnd.z) < EPS)
|
||||
{
|
||||
return NO_INTERSECTION;
|
||||
}
|
||||
return (a_Z - z) / (a_OtherEnd.z - z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
double Vector3d::LineCoeffToXZPlane(const Vector3d & a_OtherEnd, double a_Y) const
|
||||
{
|
||||
if (abs(y - a_OtherEnd.y) < EPS)
|
||||
{
|
||||
return NO_INTERSECTION;
|
||||
}
|
||||
return (a_Y - y) / (a_OtherEnd.y - y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
double Vector3d::LineCoeffToYZPlane(const Vector3d & a_OtherEnd, double a_X) const
|
||||
{
|
||||
if (abs(x - a_OtherEnd.x) < EPS)
|
||||
{
|
||||
return NO_INTERSECTION;
|
||||
}
|
||||
return (a_X - x) / (a_OtherEnd.x - x);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,81 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <math.h>
|
||||
|
||||
class Vector3f;
|
||||
|
||||
|
||||
|
||||
// tolua_begin
|
||||
|
||||
class Vector3d
|
||||
{
|
||||
public:
|
||||
// convert from float
|
||||
Vector3d(const Vector3f & v);
|
||||
Vector3d(const Vector3f * v);
|
||||
|
||||
Vector3d() : x(0), y(0), z(0) {}
|
||||
Vector3d(double a_x, double a_y, double a_z) : x(a_x), y(a_y), z(a_z) {}
|
||||
|
||||
inline void Set(double a_x, double a_y, double a_z) { x = a_x, y = a_y, z = a_z; }
|
||||
inline void Normalize() { double l = 1.0f / Length(); x *= l; y *= l; z *= l; }
|
||||
inline Vector3d NormalizeCopy() { double l = 1.0f / Length(); return Vector3d( x * l, y * l, z * l ); }
|
||||
inline void NormalizeCopy(Vector3d & a_V) { double l = 1.0f / Length(); a_V.Set(x*l, y*l, z*l ); }
|
||||
inline double Length() const { return (double)sqrt( x * x + y * y + z * z ); }
|
||||
inline double SqrLength() const { return x * x + y * y + z * z; }
|
||||
inline double Dot( const Vector3d & a_V ) const { return x * a_V.x + y * a_V.y + z * a_V.z; }
|
||||
inline Vector3d Cross( const Vector3d & v ) const { return Vector3d( y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); }
|
||||
|
||||
/** Returns the coefficient for the (a_OtherEnd - this) line to reach the specified Z coord
|
||||
The result satisfies the following equation:
|
||||
(*this + Result * (a_OtherEnd - *this)).z = a_Z
|
||||
If the line is too close to being parallel, this function returns NO_INTERSECTION
|
||||
*/
|
||||
double LineCoeffToXYPlane(const Vector3d & a_OtherEnd, double a_Z) const;
|
||||
|
||||
/** Returns the coefficient for the (a_OtherEnd - this) line to reach the specified Y coord
|
||||
The result satisfies the following equation:
|
||||
(*this + Result * (a_OtherEnd - *this)).y = a_Y
|
||||
If the line is too close to being parallel, this function returns NO_INTERSECTION
|
||||
*/
|
||||
double LineCoeffToXZPlane(const Vector3d & a_OtherEnd, double a_Y) const;
|
||||
|
||||
/** Returns the coefficient for the (a_OtherEnd - this) line to reach the specified X coord
|
||||
The result satisfies the following equation:
|
||||
(*this + Result * (a_OtherEnd - *this)).x = a_X
|
||||
If the line is too close to being parallel, this function returns NO_INTERSECTION
|
||||
*/
|
||||
double LineCoeffToYZPlane(const Vector3d & a_OtherEnd, double a_X) const;
|
||||
|
||||
inline bool Equals(const Vector3d & v) const { return ((x == v.x) && (y == v.y) && (z == v.z)); }
|
||||
|
||||
// tolua_end
|
||||
|
||||
void operator += ( const Vector3d& a_V ) { x += a_V.x; y += a_V.y; z += a_V.z; }
|
||||
void operator += ( Vector3d* a_V ) { x += a_V->x; y += a_V->y; z += a_V->z; }
|
||||
void operator -= ( const Vector3d& a_V ) { x -= a_V.x; y -= a_V.y; z -= a_V.z; }
|
||||
void operator -= ( Vector3d* a_V ) { x -= a_V->x; y -= a_V->y; z -= a_V->z; }
|
||||
void operator *= ( double a_f ) { x *= a_f; y *= a_f; z *= a_f; }
|
||||
|
||||
// tolua_begin
|
||||
|
||||
Vector3d operator + (const Vector3d & v2) const { return Vector3d(x + v2.x, y + v2.y, z + v2.z ); }
|
||||
Vector3d operator + (const Vector3d * v2) const { return Vector3d(x + v2->x, y + v2->y, z + v2->z ); }
|
||||
Vector3d operator - (const Vector3d & v2) const { return Vector3d(x - v2.x, y - v2.y, z - v2.z ); }
|
||||
Vector3d operator - (const Vector3d * v2) const { return Vector3d(x - v2->x, y - v2->y, z - v2->z ); }
|
||||
Vector3d operator * (const double f) const { return Vector3d(x * f, y * f, z * f ); }
|
||||
Vector3d operator * (const Vector3d & v2) const { return Vector3d(x * v2.x, y * v2.y, z * v2.z ); }
|
||||
Vector3d operator / (const double f) const { return Vector3d(x / f, y / f, z / f ); }
|
||||
|
||||
double x, y, z;
|
||||
|
||||
static const double EPS; ///< The max difference between two coords for which the coords are assumed equal
|
||||
static const double NO_INTERSECTION; ///< Return value of LineCoeffToPlane() if the line is parallel to the plane
|
||||
} ;
|
||||
|
||||
// tolua_end
|
||||
|
||||
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "Vector3f.h"
|
||||
#include "Vector3d.h"
|
||||
#include "Vector3i.h"
|
||||
|
||||
Vector3f::Vector3f( const Vector3d & v )
|
||||
: x( (float)v.x )
|
||||
, y( (float)v.y )
|
||||
, z( (float)v.z )
|
||||
{
|
||||
}
|
||||
|
||||
Vector3f::Vector3f( const Vector3d * v )
|
||||
: x( (float)v->x )
|
||||
, y( (float)v->y )
|
||||
, z( (float)v->z )
|
||||
{
|
||||
}
|
||||
|
||||
Vector3f::Vector3f( const Vector3i & v )
|
||||
: x( (float)v.x )
|
||||
, y( (float)v.y )
|
||||
, z( (float)v.z )
|
||||
{
|
||||
}
|
||||
|
||||
Vector3f::Vector3f( const Vector3i * v )
|
||||
: x( (float)v->x )
|
||||
, y( (float)v->y )
|
||||
, z( (float)v->z )
|
||||
{
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <math.h>
|
||||
|
||||
class Vector3i;
|
||||
class Vector3d;
|
||||
class Vector3f // tolua_export
|
||||
{ // tolua_export
|
||||
public: // tolua_export
|
||||
Vector3f( const Vector3d & v ); // tolua_export
|
||||
Vector3f( const Vector3d * v ); // tolua_export
|
||||
Vector3f( const Vector3i & v ); // tolua_export
|
||||
Vector3f( const Vector3i * v ); // tolua_export
|
||||
|
||||
|
||||
Vector3f() : x(0), y(0), z(0) {} // tolua_export
|
||||
Vector3f(float a_x, float a_y, float a_z) : x(a_x), y(a_y), z(a_z) {} // tolua_export
|
||||
|
||||
inline void Set(float a_x, float a_y, float a_z) { x = a_x, y = a_y, z = a_z; } // tolua_export
|
||||
inline void Normalize() { float l = 1.0f / Length(); x *= l; y *= l; z *= l; } // tolua_export
|
||||
inline Vector3f NormalizeCopy() const { float l = 1.0f / Length(); return Vector3f( x * l, y * l, z * l ); }// tolua_export
|
||||
inline void NormalizeCopy(Vector3f & a_V) const { float l = 1.0f / Length(); a_V.Set(x*l, y*l, z*l ); } // tolua_export
|
||||
inline float Length() const { return (float)sqrtf( x * x + y * y + z * z ); } // tolua_export
|
||||
inline float SqrLength() const { return x * x + y * y + z * z; } // tolua_export
|
||||
inline float Dot( const Vector3f & a_V ) const { return x * a_V.x + y * a_V.y + z * a_V.z; } // tolua_export
|
||||
inline Vector3f Cross( const Vector3f & v ) const { return Vector3f( y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); } // tolua_export
|
||||
|
||||
inline bool Equals( const Vector3f & v ) const { return (x == v.x && y == v.y && z == v.z ); } // tolua_export
|
||||
|
||||
void operator += ( const Vector3f& a_V ) { x += a_V.x; y += a_V.y; z += a_V.z; }
|
||||
void operator += ( Vector3f* a_V ) { x += a_V->x; y += a_V->y; z += a_V->z; }
|
||||
void operator -= ( const Vector3f& a_V ) { x -= a_V.x; y -= a_V.y; z -= a_V.z; }
|
||||
void operator -= ( Vector3f* a_V ) { x -= a_V->x; y -= a_V->y; z -= a_V->z; }
|
||||
void operator *= ( float a_f ) { x *= a_f; y *= a_f; z *= a_f; }
|
||||
void operator *= ( Vector3f* a_V ) { x *= a_V->x; y *= a_V->y; z *= a_V->z; }
|
||||
void operator *= ( const Vector3f& a_V ) { x *= a_V.x; y *= a_V.y; z *= a_V.z; }
|
||||
|
||||
Vector3f operator + ( const Vector3f& v2 ) const { return Vector3f( x + v2.x, y + v2.y, z + v2.z ); } // tolua_export
|
||||
Vector3f operator + ( const Vector3f* v2 ) const { return Vector3f( x + v2->x, y + v2->y, z + v2->z ); } // tolua_export
|
||||
Vector3f operator - ( const Vector3f& v2 ) const { return Vector3f( x - v2.x, y - v2.y, z - v2.z ); } // tolua_export
|
||||
Vector3f operator - ( const Vector3f* v2 ) const { return Vector3f( x - v2->x, y - v2->y, z - v2->z ); } // tolua_export
|
||||
Vector3f operator * ( const float f ) const { return Vector3f( x * f, y * f, z * f ); } // tolua_export
|
||||
Vector3f operator * ( const Vector3f& v2 ) const { return Vector3f( x * v2.x, y * v2.y, z * v2.z ); } // tolua_export
|
||||
|
||||
float x, y, z; // tolua_export
|
||||
|
||||
};// tolua_export
|
@ -1,58 +0,0 @@
|
||||
|
||||
// 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"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
x += a_MoveX;
|
||||
y += a_MoveY;
|
||||
z += a_MoveZ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,68 +0,0 @@
|
||||
|
||||
// Vector3i.h
|
||||
|
||||
// Declares the Vector3i class representing an int-based 3D vector
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// fwd:
|
||||
class Vector3d;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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; }
|
||||
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; }
|
||||
void operator *= ( int a_f ) { x *= a_f; y *= a_f; z *= a_f; }
|
||||
|
||||
friend Vector3i operator + ( const Vector3i& v1, const Vector3i& v2 ) { return Vector3i( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z ); }
|
||||
friend Vector3i operator + ( const Vector3i& v1, Vector3i* v2 ) { return Vector3i( v1.x + v2->x, v1.y + v2->y, v1.z + v2->z ); }
|
||||
friend Vector3i operator - ( const Vector3i& v1, const Vector3i& v2 ) { return Vector3i( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z ); }
|
||||
friend Vector3i operator - ( const Vector3i& v1, Vector3i* v2 ) { return Vector3i( v1.x - v2->x, v1.y - v2->y, v1.z - v2->z ); }
|
||||
friend Vector3i operator - ( const Vector3i* v1, Vector3i& v2 ) { return Vector3i( v1->x - v2.x, v1->y - v2.y, v1->z - v2.z ); }
|
||||
friend Vector3i operator * ( const Vector3i& v, const int f ) { return Vector3i( v.x * f, v.y * f, v.z * f ); }
|
||||
friend Vector3i operator * ( const Vector3i& v1, const Vector3i& v2 ) { return Vector3i( v1.x * v2.x, v1.y * v2.y, v1.z * v2.z ); }
|
||||
friend Vector3i operator * ( const int f, const Vector3i& v ) { return Vector3i( v.x * f, v.y * f, v.z * f ); }
|
||||
friend bool operator < ( const Vector3i& v1, const Vector3i& v2 ) { return (v1.x<v2.x)||(v1.x==v2.x && v1.y<v2.y)||(v1.x==v2.x && v1.y == v2.y && v1.z<v2.z); }
|
||||
|
||||
int x, y, z; // tolua_export
|
||||
}; // tolua_export
|
||||
|
||||
typedef std::list<Vector3i> cVector3iList;
|
||||
typedef std::vector<Vector3i> cVector3iArray;
|
||||
|
||||
|
||||
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "Generating/Trees.h"
|
||||
#include "Bindings/PluginManager.h"
|
||||
#include "Blocks/BlockHandler.h"
|
||||
#include "Vector3d.h"
|
||||
|
||||
#include "Tracer.h"
|
||||
|
||||
|
@ -14,8 +14,7 @@
|
||||
#include "ChunkMap.h"
|
||||
#include "WorldStorage/WorldStorage.h"
|
||||
#include "Generating/ChunkGenerator.h"
|
||||
#include "Vector3i.h"
|
||||
#include "Vector3f.h"
|
||||
#include "Vector3.h"
|
||||
#include "ChunkSender.h"
|
||||
#include "Defines.h"
|
||||
#include "LightingThread.h"
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define WSSCOMPACT_H_INCLUDED
|
||||
|
||||
#include "WorldStorage.h"
|
||||
#include "../Vector3i.h"
|
||||
#include "../Vector3.h"
|
||||
#include "json/json.h"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user