mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-08-24 08:26:40 +02:00
remove old transform and velocity components and replace with new decomposed components
focus on 2D for now
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
@@ -12,5 +13,26 @@ namespace glm {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec3, x, y, z)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec4, x, y, z, w)
|
||||
|
||||
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(mat4x4, [0], y, z, w)
|
||||
inline void to_json(nlohmann::json& nlohmann_json_j, const mat4x4& nlohmann_json_t) {
|
||||
// TODO: make 2d array?
|
||||
nlohmann_json_j = nlohmann::json::array_t{};
|
||||
nlohmann_json_j[0] = nlohmann_json_t[0];
|
||||
nlohmann_json_j[1] = nlohmann_json_t[1];
|
||||
nlohmann_json_j[2] = nlohmann_json_t[2];
|
||||
nlohmann_json_j[3] = nlohmann_json_t[3];
|
||||
}
|
||||
inline void from_json(const nlohmann::json& nlohmann_json_j, mat4x4& nlohmann_json_t) {
|
||||
if (!nlohmann_json_j.is_array()) {
|
||||
//throw nlohmann::json::type_error::create(0, "", nlohmann_json_j);
|
||||
assert(false && "expected array");
|
||||
return; // TODO: dont fail silently
|
||||
}
|
||||
|
||||
nlohmann_json_j.at(0).get_to(nlohmann_json_t[0]);
|
||||
nlohmann_json_j.at(1).get_to(nlohmann_json_t[1]);
|
||||
nlohmann_json_j.at(2).get_to(nlohmann_json_t[2]);
|
||||
nlohmann_json_j.at(3).get_to(nlohmann_json_t[3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity2d.hpp>
|
||||
#include <mm/components/position2d.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2D, velocity, rotation)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D, pos)
|
||||
} // MM::Components
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/transform2d.hpp>
|
||||
#include <mm/components/position2d_zoffset.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform2D, position, scale, rotation)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position2D_ZOffset, z_offset)
|
||||
} // MM::Components
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity3d.hpp>
|
||||
#include <mm/components/position3d.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity3D, velocity, rotation)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Position3D, pos)
|
||||
} // MM::Components
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/transform3d.hpp>
|
||||
#include <mm/components/rotation2d.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform3D, position, scale, rotation)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Rotation2D, rot)
|
||||
} // MM::Components
|
||||
|
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/scale2d.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Scale2D, scale)
|
||||
} // MM::Components
|
||||
|
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/transform4x4.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform4x4, trans)
|
||||
} // MM::Components
|
||||
|
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity2d_position.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPosition, pos_vel)
|
||||
} // MM::Components
|
||||
|
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity2d_position_intent.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DPositionIntent, intent)
|
||||
} // MM::Components
|
||||
|
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <mm/components/velocity2d_rotation.hpp>
|
||||
|
||||
#include "./json_glm.hpp"
|
||||
|
||||
namespace MM::Components {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2DRotation, rot_vel)
|
||||
} // MM::Components
|
||||
|
Reference in New Issue
Block a user