Added serialization of animation assets for scripts

This commit is contained in:
Kah Wei 2023-03-08 16:13:04 +08:00
parent 79fe9ec43d
commit 43edfeb14f
2 changed files with 105 additions and 81 deletions

View File

@ -23,6 +23,9 @@ of DigiPen Institute of Technology is prohibited.
#include "Assets/MeshAsset.hxx" #include "Assets/MeshAsset.hxx"
#include "Scripts/Script.hxx" #include "Scripts/Script.hxx"
#include "Scripts/ScriptStore.hxx" #include "Scripts/ScriptStore.hxx"
#include "Assets/AnimationClipAsset.hxx"
#include "Assets/AnimationControllerAsset.hxx"
#include "Assets/AnimationRigAsset.hxx"
/*-------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------*/
/* File-Level Constants */ /* File-Level Constants */
@ -181,7 +184,10 @@ namespace SHADE
fieldInsertYaml<GameObject > (fieldInfo, object, fieldNode) || fieldInsertYaml<GameObject > (fieldInfo, object, fieldNode) ||
fieldInsertYaml<FontAsset > (fieldInfo, object, fieldNode) || fieldInsertYaml<FontAsset > (fieldInfo, object, fieldNode) ||
fieldInsertYaml<MaterialAsset > (fieldInfo, object, fieldNode) || fieldInsertYaml<MaterialAsset > (fieldInfo, object, fieldNode) ||
fieldInsertYaml<MeshAsset >(fieldInfo, object, fieldNode); fieldInsertYaml<MeshAsset > (fieldInfo, object, fieldNode) ||
fieldInsertYaml<AnimationClipAsset> (fieldInfo, object, fieldNode) ||
fieldInsertYaml<AnimationControllerAsset>(fieldInfo, object, fieldNode) ||
fieldInsertYaml<AnimationRigAsset> (fieldInfo, object, fieldNode);
// Serialization of more complex types // Serialization of more complex types
if (!PRIMITIVE_SERIALIZED) if (!PRIMITIVE_SERIALIZED)
@ -245,7 +251,10 @@ namespace SHADE
varInsertYamlInternal<GameObject >(object, fieldNode) || varInsertYamlInternal<GameObject >(object, fieldNode) ||
varInsertYamlInternal<FontAsset >(object, fieldNode) || varInsertYamlInternal<FontAsset >(object, fieldNode) ||
varInsertYamlInternal<MaterialAsset >(object, fieldNode) || varInsertYamlInternal<MaterialAsset >(object, fieldNode) ||
varInsertYamlInternal<MeshAsset >(object, fieldNode); varInsertYamlInternal<MeshAsset >(object, fieldNode) ||
varInsertYamlInternal<AnimationClipAsset >(object, fieldNode) ||
varInsertYamlInternal<AnimationRigAsset >(object, fieldNode) ||
varInsertYamlInternal<AnimationControllerAsset>(object, fieldNode);
return INSERTED; return INSERTED;
} }
@ -272,7 +281,10 @@ namespace SHADE
fieldAssignYaml<GameObject >(fieldInfo, object, node) || fieldAssignYaml<GameObject >(fieldInfo, object, node) ||
fieldAssignYaml<FontAsset >(fieldInfo, object, node) || fieldAssignYaml<FontAsset >(fieldInfo, object, node) ||
fieldAssignYaml<MaterialAsset >(fieldInfo, object, node) || fieldAssignYaml<MaterialAsset >(fieldInfo, object, node) ||
fieldAssignYaml<MeshAsset> (fieldInfo, object, node); fieldAssignYaml<MeshAsset >(fieldInfo, object, node) ||
fieldAssignYaml<AnimationClipAsset >(fieldInfo, object, node) ||
fieldAssignYaml<AnimationRigAsset >(fieldInfo, object, node) ||
fieldAssignYaml<AnimationControllerAsset>(fieldInfo, object, node);
if (!ASSIGNED) if (!ASSIGNED)
{ {
if (ReflectionUtilities::FieldIsList(fieldInfo)) if (ReflectionUtilities::FieldIsList(fieldInfo))
@ -346,7 +358,10 @@ namespace SHADE
varAssignYamlInternal<GameObject >(object, node) || varAssignYamlInternal<GameObject >(object, node) ||
varAssignYamlInternal<FontAsset >(object, node) || varAssignYamlInternal<FontAsset >(object, node) ||
varAssignYamlInternal<MaterialAsset >(object, node) || varAssignYamlInternal<MaterialAsset >(object, node) ||
varAssignYamlInternal<MeshAsset> (object, node); varAssignYamlInternal<MeshAsset >(object, node) ||
varAssignYamlInternal<AnimationClipAsset >(object, node) ||
varAssignYamlInternal<AnimationRigAsset >(object, node) ||
varAssignYamlInternal<AnimationControllerAsset>(object, node);
return DESERIALISED; return DESERIALISED;
} }
} }

View File

@ -62,7 +62,10 @@ namespace SHADE
} }
else if constexpr (std::is_same_v<FieldType, FontAsset> || else if constexpr (std::is_same_v<FieldType, FontAsset> ||
std::is_same_v<FieldType, MaterialAsset> || std::is_same_v<FieldType, MaterialAsset> ||
std::is_same_v<FieldType, MeshAsset>) std::is_same_v<FieldType, MeshAsset> ||
std::is_same_v<FieldType, AnimationClipAsset> ||
std::is_same_v<FieldType, AnimationControllerAsset> ||
std::is_same_v<FieldType, AnimationRigAsset>)
{ {
fieldNode = INVALID_ASSET_ID; fieldNode = INVALID_ASSET_ID;
} }
@ -130,7 +133,10 @@ namespace SHADE
} }
else if constexpr (std::is_same_v<FieldType, FontAsset> || else if constexpr (std::is_same_v<FieldType, FontAsset> ||
std::is_same_v<FieldType, MaterialAsset> || std::is_same_v<FieldType, MaterialAsset> ||
std::is_same_v<FieldType, MeshAsset>) std::is_same_v<FieldType, MeshAsset> ||
std::is_same_v<FieldType, AnimationClipAsset> ||
std::is_same_v<FieldType, AnimationControllerAsset> ||
std::is_same_v<FieldType, AnimationRigAsset>)
{ {
if (object->GetType() == FieldType::typeid) if (object->GetType() == FieldType::typeid)
{ {
@ -256,7 +262,10 @@ namespace SHADE
} }
else if constexpr (std::is_same_v<FieldType, FontAsset> || else if constexpr (std::is_same_v<FieldType, FontAsset> ||
std::is_same_v<FieldType, MaterialAsset> || std::is_same_v<FieldType, MaterialAsset> ||
std::is_same_v<FieldType, MeshAsset>) std::is_same_v<FieldType, MeshAsset> ||
std::is_same_v<FieldType, AnimationClipAsset> ||
std::is_same_v<FieldType, AnimationControllerAsset> ||
std::is_same_v<FieldType, AnimationRigAsset>)
{ {
if (object->GetType() == FieldType::typeid) if (object->GetType() == FieldType::typeid)
{ {