我对flatbuffers很新颖,并且相信我正确地按照教程进行了修改,但将其修改为我的需要,但无法为我的生活找出原因,我得到此错误:FlatBuffers - 创建结构体向量时发生错误
error: could not convert ‘_Positions’ from ‘flatbuffers::Offset<flatbuffers::Vector<Renderer::Import::Vec3> >’ to ‘flatbuffers::Offset<flatbuffers::Vector<const Renderer::Import::Vec3*> >’
_Materials, _Faces);
此外,我只注意到它也扔error: static assertion failed: T must be a scalar type
三次
Flatbuffers模式:
namespace Renderer.Import;
struct Vec3 {
...
}
struct Face {
...
}
struct Material{
...
}
table Mesh{
Name:string;
Positions:[Vec3];
Normals:[Vec3];
Materials:[Material];
Faces:[Face];
}
C++代码:
flatbuffers::FlatBufferBuilder builder(4096);
std::vector<Renderer::Import::Vec3> Normals;
// Populate
std::vector<Renderer::Import::Vec3> Positions;
// Populate
std::vector<Renderer::Import::Material> Materials;
// Populate
std::vector<Renderer::Import::Face> Faces;
// Populate
auto _Name = builder.CreateString(shapes[0].name);
auto _Normals = builder.CreateVector(Normals);
auto _Positions = builder.CreateVector(Positions);
auto _Materials = builder.CreateVector(Materials);
auto _Faces = builder.CreateVector(Faces);
// Errors with `_Position` argument, but maybe the other three are incorrect too
auto mesh = Renderer::Import::CreateMesh(builder, _Name, _Positions, _Normals, _Materials, _Faces);
在这个问题上的任何帮助将与结构使用时,将不胜感激
请注意,您粘贴的错误会过滤掉某些字符,因此很难说出什么问题。您是否可以重新粘贴为代码块?你的模式和代码看起来对我来说是正确的。 '_Positions'和第三个参数'CreateMesh'都应该是相同的类型。 – Aardappel
当您尝试此操作时,您处于调试模式(断言)吗?因为当我尝试传递一个结构向量到'CreateVector'时,我得到'错误:静态断言失败:T必须是标量类型'。 – Aardappel