WIP: drawdag
This commit is contained in:
parent
3c5c0a77b8
commit
aafa6204ed
1 changed files with 22 additions and 21 deletions
|
@ -153,7 +153,6 @@ func (d *drawList) topsort(π geom.Projector) {
|
||||||
|
|
||||||
type drawDAG struct {
|
type drawDAG struct {
|
||||||
*dag
|
*dag
|
||||||
planes set
|
|
||||||
chunks map[image.Point]set
|
chunks map[image.Point]set
|
||||||
chunksRev map[Drawer]image.Rectangle
|
chunksRev map[Drawer]image.Rectangle
|
||||||
chunkSize int
|
chunkSize int
|
||||||
|
@ -163,7 +162,6 @@ type drawDAG struct {
|
||||||
func newDrawDAG(chunkSize int) *drawDAG {
|
func newDrawDAG(chunkSize int) *drawDAG {
|
||||||
return &drawDAG{
|
return &drawDAG{
|
||||||
dag: newDAG(),
|
dag: newDAG(),
|
||||||
planes: make(set), // drawers that take up whole plane
|
|
||||||
chunks: make(map[image.Point]set), // chunk coord -> drawers with bounding rects intersecting chunk
|
chunks: make(map[image.Point]set), // chunk coord -> drawers with bounding rects intersecting chunk
|
||||||
chunksRev: make(map[Drawer]image.Rectangle), // drawer -> rectangle of chunk coords
|
chunksRev: make(map[Drawer]image.Rectangle), // drawer -> rectangle of chunk coords
|
||||||
chunkSize: chunkSize,
|
chunkSize: chunkSize,
|
||||||
|
@ -172,28 +170,31 @@ func newDrawDAG(chunkSize int) *drawDAG {
|
||||||
|
|
||||||
// add adds a Drawer and any needed edges to the DAG and chunk map.
|
// add adds a Drawer and any needed edges to the DAG and chunk map.
|
||||||
func (d *drawDAG) add(x Drawer) {
|
func (d *drawDAG) add(x Drawer) {
|
||||||
switch x := x.(type) {
|
bb := x.(BoundingBoxer)
|
||||||
case BoundingBoxer:
|
br := bb.BoundingBox().BoundingRect(d.proj)
|
||||||
br := x.BoundingBox().BoundingRect(d.proj)
|
min := br.Min.Div(d.chunkSize)
|
||||||
min := br.Min.Div(d.chunkSize)
|
max := br.Max.Sub(image.Pt(1, 1)).Div(d.chunkSize)
|
||||||
max := br.Max.Sub(image.Pt(1, 1)).Div(d.chunkSize)
|
cand := make(set)
|
||||||
cand := make(set)
|
for j := min.Y; j <= max.Y; j++ {
|
||||||
for j := min.Y; j <= max.Y; j++ {
|
for i := min.X; i <= max.X; i++ {
|
||||||
for i := min.X; i <= max.X; i++ {
|
cell := d.chunks[image.Pt(i, j)]
|
||||||
for c := range d.chunks[image.Pt(i, j)] {
|
// Merge cell into cand
|
||||||
cand[c] = struct{}{}
|
for c := range cell {
|
||||||
}
|
cand[c] = struct{}{}
|
||||||
}
|
}
|
||||||
|
// Add x to cell
|
||||||
|
cell[x] = struct{}{}
|
||||||
}
|
}
|
||||||
for c := range cand {
|
}
|
||||||
// TODO: x before or after c?
|
// Add edges between x and elements of cand
|
||||||
d.dag.addEdge(c, x)
|
for c := range cand {
|
||||||
d.dag.addEdge(x, c)
|
y := c.(Drawer)
|
||||||
|
switch {
|
||||||
|
case edge(y, x, d.proj.Sign()):
|
||||||
|
d.dag.addEdge(y, x)
|
||||||
|
case edge(x, y, d.proj.Sign()):
|
||||||
|
d.dag.addEdge(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
case ZPositioner:
|
|
||||||
// TODO: Flat plane
|
|
||||||
d.planes[x] = struct{}{}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue