Support yaml for ArFrameMetadata
This commit is contained in:
@@ -79,6 +79,20 @@ namespace YAML
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
bool ReadSequence(const Node& node, const int count, T* array)
|
||||
{
|
||||
if (!node.IsSequence()) return false;
|
||||
int readCount = 0;
|
||||
YAML::const_iterator iter = node.begin();
|
||||
for(int i = 0; i < count && iter != node.end(); i++, iter++)
|
||||
{
|
||||
array[i] = iter->as<T>();
|
||||
readCount++;
|
||||
}
|
||||
return readCount == count;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Vector2<T>>
|
||||
{
|
||||
@@ -94,7 +108,7 @@ namespace YAML
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{})", v.x, v.y);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
return ReadSequence(node, 2, &v.x);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -113,7 +127,7 @@ namespace YAML
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{},{})", v.x, v.y, v.z);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
return ReadSequence(node, 3, &v.x);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -132,7 +146,7 @@ namespace YAML
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{},{},{})", v.x, v.y, v.z, v.w);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
return ReadSequence(node, 4, &v.x);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -151,7 +165,7 @@ namespace YAML
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{})", v.x, v.y);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
return ReadSequence(node, 2, &v.x);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -170,10 +184,26 @@ namespace YAML
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{},{})", v.x, v.y, v.z);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
return ReadSequence(node, 3, &v.x);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename MAT>
|
||||
bool ReadSequenceMat(const Node& node, const int size, MAT& data)
|
||||
{
|
||||
if (!node.IsSequence()) return false;
|
||||
int readCount = 0;
|
||||
MAT tmp;
|
||||
YAML::const_iterator iter = node.begin();
|
||||
for(int i = 0; i < size && iter != node.end(); i++, iter++)
|
||||
{
|
||||
if (!iter->IsSequence()) return false;
|
||||
if (ReadSequence(*iter, size, &tmp[i][0])) readCount++;
|
||||
}
|
||||
data = glm::transpose(tmp);
|
||||
return readCount == size;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Matrix3<T>>
|
||||
{
|
||||
@@ -196,7 +226,7 @@ namespace YAML
|
||||
mat[2][0], mat[2][1], mat[2][2]);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
return ReadSequenceMat(node, 3, mat);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -222,7 +252,7 @@ namespace YAML
|
||||
mat[2][0], mat[2][1], mat[2][2]);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
return ReadSequenceMat(node, 3, mat);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -250,7 +280,7 @@ namespace YAML
|
||||
mat[3][0], mat[3][1], mat[3][2], mat[3][3]);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
return ReadSequenceMat(node, 4, mat);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user