BruceSherwood / vpython-jupyter

This repository has been moved to https://github.com/vpython/vpython-jupyter
64 stars 33 forks source link

Quad setup function sets 4th vertex object _v3 to None #43

Closed russkel closed 6 years ago

russkel commented 6 years ago

I have the following code:

            pt1 = vertex(pos=nodes[nx * N + ny].pos, color=vector(random(), random(), random()))
            pt2 = vertex(pos=nodes[(nx + 1) * N + ny].pos, color=vector(random(), random(), random()))
            pt3 = vertex(pos=nodes[nx * N + ny + 1].pos, color=vector(random(), random(), random()))
            pt4 = vertex(pos=nodes[(nx + 1) * N + ny + 1].pos, color=vector(random(), random(), random()))
            nodes[nx * N + ny].fill = quad(vs=[pt1, pt2, pt4, pt3])

If I do nodes[nx * N + ny].fill.vs[3] it returns a None object. I debugged into the code and tried to find out why but I can't work it out. I also don't understand what is happening with the decrement/incrementTriangleCount code.

BruceSherwood commented 6 years ago

Many thanks for the report. The bug was a simple typo. Will be fixed with next release.

russkel commented 6 years ago

Thanks @BruceSherwood. Could you please explain what the idea behind the triangle count code? I noticed it fell over when I tried to set the vs attribute of a quad object. It gave an error saying the triangle count was already 0.

BruceSherwood commented 6 years ago

Here are the two typos that had to be changed in vpython.py:

# @v3.setter => @v3.setter

elif i == 4: self.v3 = val => elif i == 3: self.v3 = val

These mistakes led indirectly to irrelevant error messages.