minor changes

This commit is contained in:
faiface 2017-03-08 16:26:09 +01:00
parent 4f2ef50783
commit b0d4233286
1 changed files with 14 additions and 14 deletions

View File

@ -64,7 +64,7 @@ func (b *Batch) MakeTriangles(t Triangles) TargetTriangles {
Triangles: t.Copy(),
orig: MakeTrianglesData(t.Len()),
trans: MakeTrianglesData(t.Len()),
b: b,
dst: b,
}
bt.orig.Update(t)
bt.trans.Update(bt.orig)
@ -75,9 +75,9 @@ func (b *Batch) MakeTriangles(t Triangles) TargetTriangles {
func (b *Batch) MakePicture(p Picture) TargetPicture {
bp := &batchPicture{
Picture: p,
b: b,
dst: b,
}
bp.original = bp
bp.orig = bp
return bp
}
@ -85,28 +85,28 @@ type batchTriangles struct {
Triangles
orig, trans *TrianglesData
b *Batch
dst *Batch
}
func (bt *batchTriangles) draw(bp *batchPicture) {
for i := range *bt.trans {
transPos := mgl64.Mat3(bt.b.mat).Mul3x1(mgl64.Vec3{
transPos := mgl64.Mat3(bt.dst.mat).Mul3x1(mgl64.Vec3{
(*bt.orig)[i].Position.X(),
(*bt.orig)[i].Position.Y(),
1,
})
(*bt.trans)[i].Position = V(float64(transPos.X()), float64(transPos.Y()))
(*bt.trans)[i].Color = (*bt.orig)[i].Color.Mul(bt.b.col)
(*bt.trans)[i].Color = (*bt.orig)[i].Color.Mul(bt.dst.col)
(*bt.trans)[i].Picture = (*bt.orig)[i].Picture
(*bt.trans)[i].Intensity = (*bt.orig)[i].Intensity
}
bt.Triangles.Update(bt.trans)
cont := bt.b.cont.Triangles
cont := bt.dst.cont.Triangles
cont.SetLen(cont.Len() + bt.Triangles.Len())
cont.Slice(cont.Len()-bt.Triangles.Len(), cont.Len()).Update(bt.Triangles)
bt.b.cont.Dirty()
bt.dst.cont.Dirty()
}
func (bt *batchTriangles) Draw() {
@ -116,24 +116,24 @@ func (bt *batchTriangles) Draw() {
type batchPicture struct {
Picture
original *batchPicture
b *Batch
orig *batchPicture
dst *Batch
}
func (bp *batchPicture) Slice(r Rect) Picture {
return &batchPicture{
Picture: bp.Picture.Slice(r),
original: bp.original,
Picture: bp.Picture.Slice(r),
orig: bp.orig,
}
}
func (bp *batchPicture) Original() Picture {
return bp.original
return bp.orig
}
func (bp *batchPicture) Draw(t TargetTriangles) {
bt := t.(*batchTriangles)
if bp.b != bt.b {
if bp.dst != bt.dst {
panic(fmt.Errorf("%T.Draw: TargetTriangles generated by different Batch", bp))
}
bt.draw(bp)