1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Add a few more helper members to the Vector3 type.

This commit is contained in:
Sandu Liviu Catalin 2016-08-04 03:21:43 +03:00
parent 9fcbf54893
commit 624606e482
2 changed files with 35 additions and 7 deletions

View File

@ -12,9 +12,19 @@
namespace SqMod { namespace SqMod {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const Vector3 Vector3::NIL = Vector3(0); #define STOVAL(v) static_cast< Vector3::Value >(v)
const Vector3 Vector3::MIN = Vector3(std::numeric_limits< Vector3::Value >::min());
const Vector3 Vector3::MAX = Vector3(std::numeric_limits< Vector3::Value >::max()); // ------------------------------------------------------------------------------------------------
const Vector3 Vector3::NIL(STOVAL(0.0));
const Vector3 Vector3::MIN(std::numeric_limits< Vector3::Value >::min());
const Vector3 Vector3::MAX(std::numeric_limits< Vector3::Value >::max());
const Vector3 Vector3::LEFT(STOVAL(-1.0), STOVAL(0.0), STOVAL(0.0));
const Vector3 Vector3::RIGHT(STOVAL(1.0), STOVAL(0.0), STOVAL(0.0));
const Vector3 Vector3::UP(STOVAL(0.0), STOVAL(1.0), STOVAL(0.0));
const Vector3 Vector3::DOWN(STOVAL(0.0), STOVAL(-1.0), STOVAL(0.0));
const Vector3 Vector3::FORWARD(STOVAL(0.0), STOVAL(0.0), STOVAL(1.0));
const Vector3 Vector3::BACK(STOVAL(0.0), STOVAL(0.0), STOVAL(-1.0));
const Vector3 Vector3::ONE(STOVAL(1.0), STOVAL(1.0), STOVAL(1.0));
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
SQChar Vector3::Delim = ','; SQChar Vector3::Delim = ',';
@ -506,6 +516,17 @@ void Register_Vector3(HSQUIRRELVM vm)
.Ctor() .Ctor()
.Ctor< Val >() .Ctor< Val >()
.Ctor< Val, Val, Val >() .Ctor< Val, Val, Val >()
// Static variables
.SetStaticValue(_SC("NIL"), &Vector3::NIL)
.SetStaticValue(_SC("MIN"), &Vector3::MIN)
.SetStaticValue(_SC("MAX"), &Vector3::MAX)
.SetStaticValue(_SC("LEFT"), &Vector3::LEFT)
.SetStaticValue(_SC("RIGHT"), &Vector3::RIGHT)
.SetStaticValue(_SC("UP"), &Vector3::UP)
.SetStaticValue(_SC("DOWN"), &Vector3::DOWN)
.SetStaticValue(_SC("FORWARD"), &Vector3::FORWARD)
.SetStaticValue(_SC("BACK"), &Vector3::BACK)
.SetStaticValue(_SC("ONE"), &Vector3::ONE)
// Member Variables // Member Variables
.Var(_SC("x"), &Vector3::x) .Var(_SC("x"), &Vector3::x)
.Var(_SC("y"), &Vector3::y) .Var(_SC("y"), &Vector3::y)

View File

@ -20,9 +20,16 @@ struct Vector3
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Helper instances for common values mostly used as return types or comparison. * Helper instances for common values mostly used as return types or comparison.
*/ */
static const Vector3 NIL; static const Vector3 NIL; // ( 0, 0, 0)
static const Vector3 MIN; static const Vector3 MIN; // (<0, <0, <0)
static const Vector3 MAX; static const Vector3 MAX; // (>0, >0, >0)
static const Vector3 LEFT; // (-1, 0, 0)
static const Vector3 RIGHT; // ( 1, 0, 0)
static const Vector3 UP; // ( 0, 1, 0)
static const Vector3 DOWN; // ( 0, -1, 0)
static const Vector3 FORWARD; // ( 0, 0, 1)
static const Vector3 BACK; // ( 0, 0, -1)
static const Vector3 ONE; // ( 1, 1, 1)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* The delimiter character to be used when extracting values from strings. * The delimiter character to be used when extracting values from strings.
@ -346,4 +353,4 @@ struct Vector3
} // Namespace:: SqMod } // Namespace:: SqMod
#endif // _BASE_VECTOR3_HPP_ #endif // _BASE_VECTOR3_HPP_