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
//
std::string sSocketTypeToStr(SocketType pin_type) {
std::string result = "unknown";
switch (pin_type) {
case SocketType::SocketTypeBool:
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";
if (pin_type < SocketType::SocketTypeUndefined
|| pin_type >= SocketType::SocketTypeLast) {
return "Unknown";
}
return result;
return SocketTypeNames[static_cast<int>(pin_type)];
}
json sSocketToJson(const Socket& socket) {

View File

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