Simpler conversion SocketType <-> Strings.

AnimGraphEditor
Martin Felis 2022-03-25 10:59:12 +01:00
parent 73e7a60875
commit 2f646bc5ec
2 changed files with 11 additions and 25 deletions

View File

@ -16,31 +16,12 @@ using json = nlohmann::json;
// Socket <-> json // Socket <-> json
// //
std::string sSocketTypeToStr(SocketType pin_type) { std::string sSocketTypeToStr(SocketType pin_type) {
std::string result = "unknown"; if (pin_type < SocketType::SocketTypeUndefined
switch (pin_type) { || pin_type >= SocketType::SocketTypeLast) {
case SocketType::SocketTypeBool: return "Unknown";
result = "Bool";
break;
case SocketType::SocketTypeAnimation:
result = "Animation";
break;
case SocketType::SocketTypeFloat:
result = "Float";
break;
case SocketType::SocketTypeVec3:
result = "Vec3";
break;
case SocketType::SocketTypeQuat:
result = "Quat";
break;
case SocketType::SocketTypeString:
result = "String";
break;
default:
result = "Unknown";
} }
return result; return SocketTypeNames[static_cast<int>(pin_type)];
} }
json sSocketToJson(const Socket& socket) { json sSocketToJson(const Socket& socket) {

View File

@ -49,13 +49,18 @@ SplitOutputAttributeId(int attribute_id, int* node_id, int* output_index) {
enum class SocketType { enum class SocketType {
SocketTypeUndefined, SocketTypeUndefined = 0,
SocketTypeBool, SocketTypeBool,
SocketTypeAnimation, SocketTypeAnimation,
SocketTypeFloat, SocketTypeFloat,
SocketTypeVec3, SocketTypeVec3,
SocketTypeQuat, SocketTypeQuat,
SocketTypeString SocketTypeString,
SocketTypeLast
};
static const char* SocketTypeNames[] = {
"", "Bool", "Animation", "Float", "Vec3", "Quat", "String"
}; };
enum SocketFlags { SocketFlagAffectsTime = 1 }; enum SocketFlags { SocketFlagAffectsTime = 1 };