setting linesegs index too high causes crash

This is of course user error, but I believe that Panda should assert rather than accept the bad input causing it to crash in all sorts of bad ways. Example code:

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import LineSegs, NodePath
import random

class Game(DirectObject):
    def __init__(self):
        self.border_linesegs = LineSegs()
        self.border_linesegs.setColor(0, 1, 0, 1)
        for i in range(0, 10):
            self.border_linesegs.drawTo(0, 0, 0)
        self.border = NodePath(self.border_linesegs.create())
        self.accept('space', self.randomise)

    def randomise(self):
        for i in range(0, 20):
            r1 = random.random()
            r2 = random.random()
            self.border_linesegs.setVertex(i, r1, 0, r2)


Ah, yes. This used to work properly, but we took some asserts out of the low-level GeomVertexWriter in an attempt to improve performance in some critical inner loops, and failed to notice that we broke the error checking for LineSegs.

I’ll put in a fix.