Serialize Collider Component done

This commit is contained in:
Sri Sham Haran 2022-10-28 19:39:39 +08:00
parent 04d372b9b8
commit ea9f90f60d
3 changed files with 18 additions and 20 deletions

View File

@ -147,3 +147,11 @@ namespace SHADE
}
} // namespace SHADE
RTTR_REGISTRATION
{
using namespace rttr;
using namespace SHADE;
registration::class_<SHColliderComponent>("Collider Component");
}

View File

@ -100,5 +100,6 @@ namespace SHADE
SHQuaternion orientation;
Colliders colliders;
RTTR_ENABLE()
};
} // namespace SHADE

View File

@ -169,24 +169,12 @@ namespace YAML
{
case SHCollider::Type::BOX:
{
if(auto const bb = dynamic_cast<SHBoundingBox*>(rhs.GetShape()); bb)
{
if (node[HalfExtents])
{
bb->SetHalfExtents(node[HalfExtents].as<SHVec3>());
}
}
rhs.SetBoundingBox(node[HalfExtents].as<SHVec3>());
}
break;
case SHCollider::Type::SPHERE:
{
if(auto const bs = dynamic_cast<SHBoundingSphere*>(rhs.GetShape()); bs)
{
if (node[Radius])
{
bs->SetRadius(node[Radius].as<float>());
}
}
rhs.SetBoundingSphere(node[Radius].as<float>());
}
break;
case SHCollider::Type::CAPSULE: break;
@ -237,6 +225,7 @@ namespace YAML
const SHCollider::Type colliderType = enumAlign.name_to_value(colliderNode[convert<SHCollider>::Type].as<std::string>()).convert<SHCollider::Type>(&ok);
if (!ok)
return false;
switch (colliderType)
{
case SHCollider::Type::BOX: rhs.AddBoundingBox(); break;
@ -244,7 +233,7 @@ namespace YAML
case SHCollider::Type::CAPSULE: break;
default:;
}
rhs.GetCollider(numColliders++) = colliderNode.as<SHCollider>();
YAML::convert<SHCollider>::decode(colliderNode, rhs.GetCollider(numColliders++));
}
}
}
@ -279,13 +268,13 @@ namespace YAML
propNode = rhs.GetProperty<int>(VARIABLE->offset);
break;
case SHADE::SHShaderBlockInterface::Variable::Type::VECTOR2:
propNode = SHSerializationTools::ValToYAML(rhs.GetProperty<SHVec2>(VARIABLE->offset));
propNode = rhs.GetProperty<SHVec2>(VARIABLE->offset);
break;
case SHADE::SHShaderBlockInterface::Variable::Type::VECTOR3:
propNode = SHSerializationTools::ValToYAML(rhs.GetProperty<SHVec3>(VARIABLE->offset));
propNode = rhs.GetProperty<SHVec3>(VARIABLE->offset);
break;
case SHADE::SHShaderBlockInterface::Variable::Type::VECTOR4:
propNode = SHSerializationTools::ValToYAML(rhs.GetProperty<SHVec4>(VARIABLE->offset));
propNode = rhs.GetProperty<SHVec4>(VARIABLE->offset);
break;
case SHADE::SHShaderBlockInterface::Variable::Type::OTHER:
default: