从索引缓冲区中获取索引

Getting indices out of index buffer

本文关键字:索引 获取 缓冲区      更新时间:2023-10-16

我有一个索引数组面临我将如何循环并获取每个索引?

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 == 更新.size((更新的索引将超出界限我知道它非常基本但是我将如何解决呢?

代码崩溃,因为您尝试访问超出范围的索引。只需遍历除 2 个项目之外的所有项目:

for (int n = 0; n < updatedIndices.size() - 2; n++)