I’m trying to use GeomVertexRewriter to update some values and I need to read values from the array at the same time, which is why I’m using GeomVertexRewriter. I’ve found that if I try to read values (getData1i) from locations I’ve already written (addData1i), it will sometimes fail.
Here’s some code I’m using to test with:
origstart = nextTriangleIndex for i in range(5): indexrewriter.setRow(nextTriangleIndex) print 'setting row', indexrewriter.getWriteRow(), 'to', i indexrewriter.addData1i(i) nextTriangleIndex += 1 indexrewriter.setRow(origstart) for i in range(5): print 'reading row', indexrewriter.getReadRow(), val = indexrewriter.getData1i() print 'got value', val assert(val == i)
This works fine and prints:
setting row 5682 to 0 setting row 5683 to 1 setting row 5684 to 2 setting row 5685 to 3 setting row 5686 to 4 reading row 5682 got value 0 reading row 5683 got value 1 reading row 5684 got value 2 reading row 5685 got value 3 reading row 5686 got value 4
But if I change range(5) to something larger, e.g. range(200), I get:
setting row 5682 to 0 setting row 5683 to 1 setting row 5684 to 2 setting row 5685 to 3 setting row 5686 to 4 ... ... setting row 5880 to 198 setting row 5881 to 199 reading row 5682 got value 22752
assert(val == i) AssertionError
Any idea what I’m doing wrong?
If I create a new GeomVertexReader each time I want to read a value like this:
indexreader = GeomVertexReader(indexdata) indexreader.setColumn(0) indexreader.setRow(vals) oldval = indexreader.getData1i() del indexreader
it works, but I think it’s a lot slower than if I could use the GeomVertexRewriter.