3

我对 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三次

平面缓冲区架构:

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);

对此问题的任何帮助将不胜感激

4

1 回答 1

3

与结构一起使用时使用CreateVectorOfStructs而不是。CreateVector

API 应该为使用 CreateVector 接受结构向量负责,我们必须解决这个问题。

于 2017-02-26T20:55:46.880 回答