所以我有一行代码:
new btBvhTriangleMeshShape(meshInterface, true);
这使我的程序崩溃。显然,函数内部有一个
assert(numIndices>0)
这是导致撞车的原因。
如果我再加一个
false
参数,所以看起来像:
new btBvhTriangleMeshShape(meshInterface, true, false);
我告诉它不要生成边界体积数据,它继续正常工作(没有崩溃)。所以我的问题是:为什么当我在
meshInterface
,它崩溃了,说我没有索引。
其他信息:
mesh接口
创建如下:
btTriangleMesh *meshInterface = new btTriangleMesh();
for(uint i = 0; i < terrainMesh.position.size(); i++) {
//don't remove duplicate vertex because there won't ever be any
meshInterface->findOrAddVertex(toBt(terrainMesh.position[i]), false);
}
for(uint i = 0; i < terrainMesh.index.size(); i++) {
meshInterface->addIndex(terrainMesh.index[i]);
}
我已经在另一个对象中设置了数据,我只是将其加载到项目符号设置中。
在这里你可以看到我的
mesh接口
。网格是平面。