BruceSherwood / vpython-wx

VPython based on wxPython
Other
70 stars 38 forks source link

Faces truncation bug #18

Closed BruceSherwood closed 10 years ago

BruceSherwood commented 11 years ago

If you truncate faces.pos, the color and normal arrays are also truncated, but incorrectly. As you can see in the following example, the pos array loses its last 3 elements, but the color and normal array lose their first 3 elements.

from visual import * p = [(-1,0,0), (1,0,0), (0,1,0), (1,0,0), (-1,0,0), (0,-1,0) ] c = [color.red, color.orange, color.yellow, color.green, color.cyan, color.blue] n = [(0,0,0.1), (0,0,0.2), (0,0,0.3), (0,0,0.4), (0,0,0.5), (0,0,0.6)] f = faces(pos=p, color=c, normal=n) print('------------------') print(f.pos) print('------------------') print(f.color) print('------------------') print(f.normal) print('**') scene.mouse.getclick() f.pos = f.pos[:-3] print(f.pos) print('------------------') print(f.color) print('------------------') print(f.normal)

BruceSherwood commented 10 years ago

The same problem applies to curve, and there doesn't seem to be a way to do anything about it. The statement f.pos = f.pos[:-3] could just as well be f.pos = array([1,2,3], [4,5,6], [7,8,9]); in other words, we have no idea what portion of the color or normal arrays to use in the truncated object. A possible approach would be to create a new method: f.truncate(i,j) would replace the current pos, color, and (in the case of faces) normal arrays with pos[i:j], color[i:j], and normal[i:j].