diff --git a/Nuake/src/Resource/Serializable.h b/Nuake/src/Resource/Serializable.h index ddb6b57a..af7f5d7a 100644 --- a/Nuake/src/Resource/Serializable.h +++ b/Nuake/src/Resource/Serializable.h @@ -17,7 +17,7 @@ using json = nlohmann::json; #define SERIALIZE_VEC4(v) \ SERIALIZE_VEC3(v) \ - j[#v]["w"] = this->v.z; + j[#v]["w"] = this->v.w; #define DESERIALIZE_VEC3(v, p) \ p = Vector3(v["x"], v["y"], v["z"]); diff --git a/Nuake/src/Scene/Components/TransformComponent.h b/Nuake/src/Scene/Components/TransformComponent.h index 07ba7a35..869b8f8f 100644 --- a/Nuake/src/Scene/Components/TransformComponent.h +++ b/Nuake/src/Scene/Components/TransformComponent.h @@ -46,6 +46,7 @@ namespace Nuake json Serialize() { + Rotation = glm::normalize(Rotation); BEGIN_SERIALIZE(); SERIALIZE_VAL_LBL("Type", "TransformComponent"); SERIALIZE_VEC3(Translation); @@ -58,12 +59,21 @@ namespace Nuake { BEGIN_DESERIALIZE(); this->Translation = Vector3(j["Translation"]["x"], j["Translation"]["y"], j["Translation"]["z"]); - if(j.contains("Rotation")) - this->Rotation = Quat(j["Rotation"]["w"], j["Rotation"]["x"], j["Rotation"]["y"], j["Rotation"]["z"]); + if (j.contains("Rotation")) + { + float w = j["Rotation"]["w"]; + float x = j["Rotation"]["x"]; + float y = j["Rotation"]["y"]; + float z = j["Rotation"]["z"]; + this->Rotation = Quat(w, x, y, z); + } + + this->Scale = Vector3(j["Scale"]["x"], j["Scale"]["y"], j["Scale"]["z"]); LocalTransform = Matrix4(1); GlobalTransform = Matrix4(1); + Dirty = true; return true; } };