Reduce copying in fillPolygon
A slice of points means copying every point into the slice, then copying every point's data from the slice to TrianglesData. An array of indicies lets the compiler make better choices.
This commit is contained in:
parent
918031892a
commit
fc858bff4d
|
@ -354,11 +354,12 @@ func (imd *IMDraw) fillPolygon() {
|
||||||
imd.tri.SetLen(imd.tri.Len() + 3*(len(points)-2))
|
imd.tri.SetLen(imd.tri.Len() + 3*(len(points)-2))
|
||||||
|
|
||||||
for i, j := 1, off; i+1 < len(points); i, j = i+1, j+3 {
|
for i, j := 1, off; i+1 < len(points); i, j = i+1, j+3 {
|
||||||
for k, p := range []point{points[0], points[i], points[i+1]} {
|
for k, p := range []int{0, i, i + 1} {
|
||||||
(*imd.tri)[j+k].Position = p.pos
|
tri := &(*imd.tri)[j+k]
|
||||||
(*imd.tri)[j+k].Color = p.col
|
tri.Position = points[p].pos
|
||||||
(*imd.tri)[j+k].Picture = p.pic
|
tri.Color = points[p].col
|
||||||
(*imd.tri)[j+k].Intensity = p.in
|
tri.Picture = points[p].pic
|
||||||
|
tri.Intensity = points[p].in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue