从索引缓冲区中获取索引

时间:2018-01-20 14:52:41

标签: c++

我有一系列索引 面孔 我将如何循环并获取每个索引?

for (int n = 0 ; n < updatedIndices.size(); n++)
        {
            int n0 = updatedIndices[n+0];
            int n1 = updatedIndices[n+1];
            int n2 = updatedIndices[n+2];

            manual->triangle(n0, n1, n2);

        }

但这会崩溃 因为当n == updated.size()时 updatedIndices将超出范围 我知道它非常基本 但我怎么解决呢?

1 个答案:

答案 0 :(得分:0)

您的代码崩溃是因为您尝试访问超出范围的索引。只需遍历所有但只有2项:

for (int n = 0; n < updatedIndices.size() - 2; n++)
相关问题