More quality of life
This commit is contained in:
@@ -52,7 +52,10 @@ void Lua::Update(double delta) {
|
||||
if (HasHook("update")) {
|
||||
lua_getglobal(L, "update");
|
||||
lua_pushnumber(L, delta);
|
||||
lua_call(L, 1, 0);
|
||||
int err = lua_pcall(L, 1, 0, 0);
|
||||
if (err != LUA_OK) {
|
||||
Error();
|
||||
}
|
||||
}
|
||||
#endif // LUA_SCRIPTING
|
||||
}
|
||||
@@ -89,7 +92,10 @@ void Lua::LuaKeyHandler(Window *window, int key, int code, int action, int mods)
|
||||
lua_pushinteger(L, code);
|
||||
lua_pushinteger(L, action);
|
||||
lua_pushinteger(L, mods);
|
||||
lua_call(L, 4, 0);
|
||||
int err = lua_pcall(L, 4, 0, 0);
|
||||
if (err != LUA_OK) {
|
||||
Error();
|
||||
}
|
||||
#endif // LUA_SCRIPTING
|
||||
}
|
||||
|
||||
@@ -101,6 +107,9 @@ void Lua::LuaMousePositionHandler(Window *window, double xpos, double ypos, doub
|
||||
lua_pushnumber(L, ypos);
|
||||
lua_pushnumber(L, relx);
|
||||
lua_pushnumber(L, rely);
|
||||
lua_call(L, 4, 0);
|
||||
int err = lua_pcall(L, 4, 0, 1);
|
||||
if (err != LUA_OK) {
|
||||
Error();
|
||||
}
|
||||
#endif // LUA_SCRIPTING
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
void Initialize();
|
||||
void Update(double delta);
|
||||
void Close();
|
||||
void Error();
|
||||
static void Error();
|
||||
bool HasHook(const char *name);
|
||||
private:
|
||||
#ifdef LUA_SCRIPTING
|
||||
|
||||
@@ -8,7 +8,6 @@ public:
|
||||
virtual void Initialize() = 0;
|
||||
virtual void Update(double delta) = 0;
|
||||
virtual void Close() = 0;
|
||||
virtual void Error() = 0;
|
||||
virtual bool HasHook(const char * name) = 0;
|
||||
static ScriptingLanguage *GetCurrentLanguage();
|
||||
protected:
|
||||
|
||||
@@ -24,14 +24,24 @@ void Transform::Translate(cfloat x, cfloat y, cfloat z) {
|
||||
}
|
||||
|
||||
|
||||
Vector3 Transform::Forward() {
|
||||
Vector3 forward(0.0f, 0.0f, -1.0f);
|
||||
Matrix Transform::RotationMatrix() {
|
||||
Matrix mat(1.0f);
|
||||
|
||||
mat = glm::rotate(mat, this->rotation.z, Vector3(0.0f, 0.0f, 1.0f));
|
||||
mat = glm::rotate(mat, this->rotation.y, Vector3(0.0f, 1.0f, 0.0f));
|
||||
mat = glm::rotate(mat, this->rotation.x, Vector3(1.0f, 0.0f, 0.0f));
|
||||
|
||||
|
||||
return glm::vec3(mat * glm::vec4(forward, 1.0f));
|
||||
return mat;
|
||||
}
|
||||
|
||||
Vector3 Transform::Forward() {
|
||||
return glm::vec3(RotationMatrix() * glm::vec4(0.0f, 0.0f, -1.0f, 1.0f));
|
||||
}
|
||||
|
||||
Vector3 Transform::Up() {
|
||||
return glm::vec3(RotationMatrix() * glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
Vector3 Transform::Right() {
|
||||
return glm::vec3(RotationMatrix() * glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ struct Transform {
|
||||
Vector3 scale;
|
||||
void Translate(cfloat x, cfloat y, cfloat z);
|
||||
Vector3 Forward();
|
||||
Vector3 Right();
|
||||
Vector3 Up();
|
||||
Matrix RotationMatrix();
|
||||
};
|
||||
|
||||
#endif /* TRANSFORM_H */
|
||||
|
||||
Reference in New Issue
Block a user