Add to string conversion for glm types in lua
This commit is contained in:
@@ -18,6 +18,7 @@ LuaScript = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
update = function(self, deltaTime)
|
update = function(self, deltaTime)
|
||||||
|
|
||||||
self.camera = getCameraComponent()
|
self.camera = getCameraComponent()
|
||||||
|
|
||||||
if self.camera.type == CameraType.Orthographic then
|
if self.camera.type == CameraType.Orthographic then
|
||||||
@@ -25,6 +26,7 @@ LuaScript = {
|
|||||||
elseif self.camera.type == CameraType.Perspective then
|
elseif self.camera.type == CameraType.Perspective then
|
||||||
LuaScript:updatePerspective(deltaTime)
|
LuaScript:updatePerspective(deltaTime)
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
updateOrthographic = function(self, deltaTime)
|
updateOrthographic = function(self, deltaTime)
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
namespace Inferno {
|
namespace Inferno {
|
||||||
|
|
||||||
|
const LogStream& operator<<(const LogStream& stream, const glm::vec2& value)
|
||||||
|
{
|
||||||
|
return stream << "{ " << value.x << ", " << value.y << " }";
|
||||||
|
}
|
||||||
|
|
||||||
const LogStream& operator<<(const LogStream& stream, const glm::vec3& value)
|
const LogStream& operator<<(const LogStream& stream, const glm::vec3& value)
|
||||||
{
|
{
|
||||||
return stream << "{ " << value.x << ", " << value.y << ", " << value.z << " }";
|
return stream << "{ " << value.x << ", " << value.y << ", " << value.z << " }";
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace Inferno {
|
|||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
|
|
||||||
|
const LogStream& operator<<(const LogStream& stream, const glm::vec2& value);
|
||||||
const LogStream& operator<<(const LogStream& stream, const glm::vec3& value);
|
const LogStream& operator<<(const LogStream& stream, const glm::vec3& value);
|
||||||
const LogStream& operator<<(const LogStream& stream, const glm::vec4& value);
|
const LogStream& operator<<(const LogStream& stream, const glm::vec4& value);
|
||||||
const LogStream& operator<<(const LogStream& stream, const glm::mat4& value);
|
const LogStream& operator<<(const LogStream& stream, const glm::mat4& value);
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ namespace Inferno {
|
|||||||
"__add", addition<glm::vec2, float>(),
|
"__add", addition<glm::vec2, float>(),
|
||||||
"__sub", subtraction<glm::vec2, float>(),
|
"__sub", subtraction<glm::vec2, float>(),
|
||||||
"__mul", multiplication<glm::vec2, float>(),
|
"__mul", multiplication<glm::vec2, float>(),
|
||||||
"__div", division<glm::vec2, float>()
|
"__div", division<glm::vec2, float>(),
|
||||||
|
"__tostring", string<glm::vec2>
|
||||||
);
|
);
|
||||||
|
|
||||||
auto vec3 = glm.new_usertype<glm::vec3>(
|
auto vec3 = glm.new_usertype<glm::vec3>(
|
||||||
@@ -45,8 +46,8 @@ namespace Inferno {
|
|||||||
"__add", addition<glm::vec3, float>(),
|
"__add", addition<glm::vec3, float>(),
|
||||||
"__sub", subtraction<glm::vec3, float>(),
|
"__sub", subtraction<glm::vec3, float>(),
|
||||||
"__mul", multiplication<glm::vec3, float>(),
|
"__mul", multiplication<glm::vec3, float>(),
|
||||||
"__div", division<glm::vec3, float>()
|
"__div", division<glm::vec3, float>(),
|
||||||
// "__tostring", [](glm::vec3 self) { return self.x; } // Template!!! convert via logstream
|
"__tostring", string<glm::vec3>
|
||||||
);
|
);
|
||||||
|
|
||||||
auto vec4 = glm.new_usertype<glm::vec4>(
|
auto vec4 = glm.new_usertype<glm::vec4>(
|
||||||
@@ -58,7 +59,8 @@ namespace Inferno {
|
|||||||
"__add", addition<glm::vec4, float>(),
|
"__add", addition<glm::vec4, float>(),
|
||||||
"__sub", subtraction<glm::vec4, float>(),
|
"__sub", subtraction<glm::vec4, float>(),
|
||||||
"__mul", multiplication<glm::vec4, float>(),
|
"__mul", multiplication<glm::vec4, float>(),
|
||||||
"__div", division<glm::vec4, float>()
|
"__div", division<glm::vec4, float>(),
|
||||||
|
"__tostring", string<glm::vec4>
|
||||||
);
|
);
|
||||||
|
|
||||||
glm.set_function("radians", sol::overload(
|
glm.set_function("radians", sol::overload(
|
||||||
@@ -110,7 +112,6 @@ namespace Inferno {
|
|||||||
void Registration::input(sol::state_view& state)
|
void Registration::input(sol::state_view& state)
|
||||||
{
|
{
|
||||||
state.set_function("keyCode", &keyCode);
|
state.set_function("keyCode", &keyCode);
|
||||||
// state["keyCode"] = &KeyCode;
|
|
||||||
|
|
||||||
auto input = state.new_usertype<Input>("Input", sol::no_constructor);
|
auto input = state.new_usertype<Input>("Input", sol::no_constructor);
|
||||||
input["isKeyPressed"] = &Input::isKeyPressed;
|
input["isKeyPressed"] = &Input::isKeyPressed;
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "sol/overload.hpp" // sol::overload
|
#include "sol/overload.hpp" // sol::overload
|
||||||
#include "sol/state_view.hpp" // sol::state_view
|
#include "sol/state_view.hpp" // sol::state_view
|
||||||
|
|
||||||
|
#include "inferno/io/log.h"
|
||||||
|
|
||||||
namespace Inferno {
|
namespace Inferno {
|
||||||
|
|
||||||
class Registration final {
|
class Registration final {
|
||||||
@@ -54,6 +56,14 @@ namespace Inferno {
|
|||||||
[](const V& lhs, const T& rhs) { return lhs / rhs; }
|
[](const V& lhs, const T& rhs) { return lhs / rhs; }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static std::string string(const T& t)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
str(&result) << t;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user