Script QoL Improvements #203
|
@ -34,8 +34,11 @@ namespace SHADE
|
|||
void SHRenderable::OnDestroy()
|
||||
{
|
||||
// Remove from SuperBatch
|
||||
Handle<SHSuperBatch> superBatch = sharedMaterial->GetBaseMaterial()->GetPipeline()->GetPipelineState().GetSubpass()->GetSuperBatch();
|
||||
superBatch->Remove(this);
|
||||
if (sharedMaterial)
|
||||
{
|
||||
Handle<SHSuperBatch> superBatch = sharedMaterial->GetBaseMaterial()->GetPipeline()->GetPipelineState().GetSubpass()->GetSuperBatch();
|
||||
superBatch->Remove(this);
|
||||
}
|
||||
|
||||
// Free resources
|
||||
if (material)
|
||||
|
|
|
@ -288,7 +288,15 @@ namespace YAML
|
|||
{
|
||||
YAML::Node node;
|
||||
node[MESH_YAML_TAG.data()] = SHResourceManager::GetAssetID<SHMesh>(rhs.GetMesh()).value_or(0);
|
||||
node[MAT_YAML_TAG.data()] = SHResourceManager::GetAssetID<SHMaterial>(rhs.GetMaterial()->GetBaseMaterial()).value_or(0);
|
||||
auto mat = rhs.GetMaterial();
|
||||
if (mat)
|
||||
{
|
||||
node[MAT_YAML_TAG.data()] = SHResourceManager::GetAssetID<SHMaterial>(rhs.GetMaterial()->GetBaseMaterial()).value_or(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
node[MAT_YAML_TAG.data()] = 0;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
static bool decode(YAML::Node const& node, SHRenderable& rhs)
|
||||
|
|
|
@ -28,7 +28,47 @@ namespace SHADE
|
|||
template<typename FieldType>
|
||||
bool SerialisationUtilities::fieldInsertYaml(System::Reflection::FieldInfo^ fieldInfo, System::Object^ object, YAML::Node& fieldNode)
|
||||
{
|
||||
return varInsertYamlInternal<FieldType>(fieldInfo->GetValue(object), fieldNode);
|
||||
// Handle null objects
|
||||
System::Object^ fieldObject = fieldInfo->GetValue(object);
|
||||
if (fieldObject == nullptr)
|
||||
{
|
||||
// Default construct if null
|
||||
if (fieldInfo->FieldType == FieldType::typeid)
|
||||
{
|
||||
if constexpr (std::is_same_v<FieldType, System::Enum>)
|
||||
{
|
||||
fieldNode = 0;
|
||||
}
|
||||
else if constexpr (std::is_same_v<FieldType, System::String>)
|
||||
{
|
||||
fieldNode = "";
|
||||
}
|
||||
else if constexpr (std::is_same_v<FieldType, Vector2>)
|
||||
{
|
||||
fieldNode.SetStyle(YAML::EmitterStyle::Flow);
|
||||
fieldNode.push_back(0.0f);
|
||||
fieldNode.push_back(0.0f);
|
||||
}
|
||||
else if constexpr (std::is_same_v<FieldType, Vector3>)
|
||||
{
|
||||
fieldNode.SetStyle(YAML::EmitterStyle::Flow);
|
||||
fieldNode.push_back(0.0f);
|
||||
fieldNode.push_back(0.0f);
|
||||
fieldNode.push_back(0.0f);
|
||||
}
|
||||
else if constexpr (std::is_same_v<FieldType, GameObject>)
|
||||
{
|
||||
fieldNode = MAX_EID;
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldNode = FieldType();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return varInsertYamlInternal<FieldType>(fieldObject, fieldNode);
|
||||
}
|
||||
template<typename FieldType>
|
||||
bool SerialisationUtilities::varInsertYamlInternal(System::Object^ object, YAML::Node& fieldNode)
|
||||
|
|
Loading…
Reference in New Issue