mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 08:47:58 +03:00
Make GameScriptPosition and GameScriptRotation convertible from PHD_3POS and add a function which puts their position or rotation data into a PHD_3POS. Make their members public since their setters and getters were trivial, aside from some tests which seem to serve no purpose (an int can't be larger than INT_MAX or smaller than INT_MIN).
This commit is contained in:
parent
1a361ebfe7
commit
5f0b5f699f
4 changed files with 43 additions and 98 deletions
|
@ -1,58 +1,35 @@
|
|||
#include "framework.h"
|
||||
#include "GameScriptRotation.h"
|
||||
#include "phd_global.h"
|
||||
|
||||
void GameScriptRotation::Register(sol::state* state)
|
||||
{
|
||||
state->new_usertype<GameScriptRotation>("Rotation",
|
||||
sol::constructors<GameScriptRotation(int, int, int)>(),
|
||||
"X", sol::property(&GameScriptRotation::GetX, &GameScriptRotation::SetX),
|
||||
"Y", sol::property(&GameScriptRotation::GetY, &GameScriptRotation::SetY),
|
||||
"Z", sol::property(&GameScriptRotation::GetZ, &GameScriptRotation::SetZ)
|
||||
);
|
||||
"X", &GameScriptRotation::x,
|
||||
"Y", &GameScriptRotation::y,
|
||||
"Z", &GameScriptRotation::z
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
GameScriptRotation::GameScriptRotation(int x, int y, int z)
|
||||
GameScriptRotation::GameScriptRotation(int aX, int aY, int aZ)
|
||||
{
|
||||
SetX(x);
|
||||
SetY(y);
|
||||
SetZ(z);
|
||||
x = aX;
|
||||
y = aY;
|
||||
z = aZ;
|
||||
}
|
||||
|
||||
int GameScriptRotation::ConvertRotation(int a)
|
||||
void GameScriptRotation::StoreInPHDPos(PHD_3DPOS& pos) const
|
||||
{
|
||||
short component = std::clamp(a, -359, 359);
|
||||
component = static_cast<int>(lround((component/360.0f) * std::numeric_limits<unsigned short>::max()));
|
||||
component = component - std::numeric_limits<short>::max();
|
||||
return component;
|
||||
pos.xRot = x;
|
||||
pos.yRot = y;
|
||||
pos.zRot = z;
|
||||
}
|
||||
|
||||
int GameScriptRotation::GetX() const
|
||||
GameScriptRotation::GameScriptRotation(PHD_3DPOS const & pos)
|
||||
{
|
||||
return x;
|
||||
x = pos.xRot;
|
||||
y = pos.yRot;
|
||||
z = pos.zRot;
|
||||
}
|
||||
|
||||
void GameScriptRotation::SetX(int x)
|
||||
{
|
||||
this->x = ConvertRotation(x);
|
||||
}
|
||||
|
||||
int GameScriptRotation::GetY() const
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
void GameScriptRotation::SetY(int y)
|
||||
{
|
||||
this->y = ConvertRotation(y);
|
||||
}
|
||||
|
||||
int GameScriptRotation::GetZ() const
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
void GameScriptRotation::SetZ(int z)
|
||||
{
|
||||
this->z = ConvertRotation(z);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue