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

Do not register two Quaternion types.

This commit is contained in:
Sandu Liviu Catalin 2021-03-20 20:21:05 +02:00
parent 370c5cfe88
commit 8985866060
2 changed files with 15 additions and 47 deletions

View File

@ -39,7 +39,6 @@ SQMOD_DECL_TYPENAME(EntityRGBTn, _SC("LgEntityRGB"))
SQMOD_DECL_TYPENAME(RGBATn, _SC("RGBA")) SQMOD_DECL_TYPENAME(RGBATn, _SC("RGBA"))
SQMOD_DECL_TYPENAME(ARGBTn, _SC("ARGB")) SQMOD_DECL_TYPENAME(ARGBTn, _SC("ARGB"))
SQMOD_DECL_TYPENAME(VectorTn, _SC("Vector")) SQMOD_DECL_TYPENAME(VectorTn, _SC("Vector"))
SQMOD_DECL_TYPENAME(QuaternionTn, _SC("Quaternion"))
SQMOD_DECL_TYPENAME(EntityVectorTn, _SC("LgEntityVector")) SQMOD_DECL_TYPENAME(EntityVectorTn, _SC("LgEntityVector"))
SQMOD_DECL_TYPENAME(EntityQuaternionTn, _SC("LgEntityQuaternion")) SQMOD_DECL_TYPENAME(EntityQuaternionTn, _SC("LgEntityQuaternion"))
SQMOD_DECL_TYPENAME(BoundsTn, _SC("Bounds")) SQMOD_DECL_TYPENAME(BoundsTn, _SC("Bounds"))
@ -156,7 +155,7 @@ static SQInteger QuaternionToString(HSQUIRRELVM vm)
{ {
try try
{ {
Var< LgQuaternion * > v(SqVM(), 1); Var< Quaternion * > v(SqVM(), 1);
// Validate the instance, just to be sure // Validate the instance, just to be sure
if (!v.value) if (!v.value)
{ {
@ -309,16 +308,8 @@ void Register_Official(HSQUIRRELVM vm)
.Prop(_SC("z"), &LgEntityVector::GetZ, &LgEntityVector::SetZ) .Prop(_SC("z"), &LgEntityVector::GetZ, &LgEntityVector::SetZ)
); );
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
RootTable(vm).Bind(QuaternionTn::Str,
DerivedClass< LgQuaternion, Quaternion >(vm, QuaternionTn::Str)
// Constructors
.Ctor< Quaternion::Value, Quaternion::Value, Quaternion::Value >()
// Global Member Methods
.SquirrelFunc(_SC("_tostring"), &QuaternionToString)
);
// --------------------------------------------------------------------------------------------
RootTable(vm).Bind(EntityQuaternionTn::Str, RootTable(vm).Bind(EntityQuaternionTn::Str,
DerivedClass< LgEntityQuaternion, LgQuaternion >(vm, EntityQuaternionTn::Str) DerivedClass< LgEntityQuaternion, Quaternion >(vm, EntityQuaternionTn::Str)
// Constructors // Constructors
.Ctor< int, int, int, Quaternion::Value, Quaternion::Value, Quaternion::Value, Quaternion::Value >() .Ctor< int, int, int, Quaternion::Value, Quaternion::Value, Quaternion::Value, Quaternion::Value >()
// Properties // Properties

View File

@ -119,30 +119,7 @@ struct LgEntityVector : public LgVector
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Entity quaternion. * Entity quaternion.
*/ */
struct LgQuaternion : public Quaternion struct LgEntityQuaternion : public Quaternion
{
/* --------------------------------------------------------------------------------------------
* Default constructor.
*/
LgQuaternion() = default;
/* --------------------------------------------------------------------------------------------
* Copy constructor.
*/
explicit LgQuaternion(const Quaternion & q)
: Quaternion(q)
{
}
/* --------------------------------------------------------------------------------------------
* Import from base class.
*/
using Quaternion::Quaternion;
using Quaternion::operator =;
};
/* ------------------------------------------------------------------------------------------------
* Entity quaternion.
*/
struct LgEntityQuaternion : public LgQuaternion
{ {
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Entity identifier. * Entity identifier.
@ -163,7 +140,7 @@ struct LgEntityQuaternion : public LgQuaternion
* Base constructor. * Base constructor.
*/ */
LgEntityQuaternion(int id, int type, int flag, Value x, Value y, Value z, Value w) LgEntityQuaternion(int id, int type, int flag, Value x, Value y, Value z, Value w)
: LgQuaternion(x, y, z, w) : Quaternion(x, y, z, w)
, mID(static_cast< int16_t >(id)) , mID(static_cast< int16_t >(id))
, mType(static_cast< uint8_t >(type)) , mType(static_cast< uint8_t >(type))
, mFlag(static_cast< uint8_t >(flag)) , mFlag(static_cast< uint8_t >(flag))
@ -174,7 +151,7 @@ struct LgEntityQuaternion : public LgQuaternion
* Base constructor. * Base constructor.
*/ */
LgEntityQuaternion(int id, int type, int flag, const Quaternion & q) LgEntityQuaternion(int id, int type, int flag, const Quaternion & q)
: LgQuaternion{q} : Quaternion{q}
, mID(static_cast< int16_t >(id)) , mID(static_cast< int16_t >(id))
, mType(static_cast< uint8_t >(type)) , mType(static_cast< uint8_t >(type))
, mFlag(static_cast< uint8_t >(flag)) , mFlag(static_cast< uint8_t >(flag))
@ -184,42 +161,42 @@ struct LgEntityQuaternion : public LgQuaternion
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Retrieve the X component of the quaternion. * Retrieve the X component of the quaternion.
*/ */
SQMOD_NODISCARD Value GetX() const { return LgQuaternion::x; } SQMOD_NODISCARD Value GetX() const { return Quaternion::x; }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Retrieve the Y component of the quaternion. * Retrieve the Y component of the quaternion.
*/ */
SQMOD_NODISCARD Value GetY() const { return LgQuaternion::y; } SQMOD_NODISCARD Value GetY() const { return Quaternion::y; }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Retrieve the Z component of the quaternion. * Retrieve the Z component of the quaternion.
*/ */
SQMOD_NODISCARD Value GetZ() const { return LgQuaternion::z; } SQMOD_NODISCARD Value GetZ() const { return Quaternion::z; }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Retrieve the W component of the quaternion. * Retrieve the W component of the quaternion.
*/ */
SQMOD_NODISCARD Value GetW() const { return LgQuaternion::w; } SQMOD_NODISCARD Value GetW() const { return Quaternion::w; }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Modify the X component of the quaternion. * Modify the X component of the quaternion.
*/ */
void SetX(Value v) { LgQuaternion::x = v; Set(); } void SetX(Value v) { Quaternion::x = v; Set(); }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Modify the Y component of the quaternion. * Modify the Y component of the quaternion.
*/ */
void SetY(Value v) { LgQuaternion::y = v; Set(); } void SetY(Value v) { Quaternion::y = v; Set(); }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Modify the Z component of the quaternion. * Modify the Z component of the quaternion.
*/ */
void SetZ(Value v) { LgQuaternion::z = v; Set(); } void SetZ(Value v) { Quaternion::z = v; Set(); }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Modify the W component of the quaternion. * Modify the W component of the quaternion.
*/ */
void SetW(Value v) { LgQuaternion::w = v; Set(); } void SetW(Value v) { Quaternion::w = v; Set(); }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Modify the X, Y, Z and W component of the quaternion. * Modify the X, Y, Z and W component of the quaternion.
@ -229,8 +206,8 @@ struct LgEntityQuaternion : public LgQuaternion
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Import from base class. * Import from base class.
*/ */
using LgQuaternion::LgQuaternion; using Quaternion::Quaternion;
using LgQuaternion::operator =; using Quaternion::operator =;
}; };
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------