comparison pkg/octree/tree.go @ 2499:62adfe9cbbde octree-diff

Be more precise with clipping nodes.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 04 Mar 2019 14:58:22 +0100
parents 12ed6feefea5
children 5c3e63cfd50d
comparison
equal deleted inserted replaced
2498:843f39b9327e 2499:62adfe9cbbde
78 nodesAllInside++ 78 nodesAllInside++
79 continue frames 79 continue frames
80 case IntersectionOutSide: 80 case IntersectionOutSide:
81 // all outside -> clip from tree. 81 // all outside -> clip from tree.
82 nodesClipped++ 82 nodesClipped++
83 if index := ot.index[top.pos:]; len(index) > 7 { 83 index := ot.index[top.pos:]
84 for i := range index { 84 if len(index) > 8 {
85 index[i] = 0 85 index = index[:8]
86 } 86 }
87 for i := range index {
88 index[i] = 0
87 } 89 }
88 continue frames 90 continue frames
89 default: // Overlaps 91 default: // Overlaps
90 if index := ot.index[top.pos:]; len(index) > 7 { 92 if index := ot.index[top.pos:]; len(index) > 7 {
91 children: 93 children:
104 dy*scale[i][3] + top.Y1, 106 dy*scale[i][3] + top.Y1,
105 } 107 }
106 switch p.IntersectionBox2D(nbox) { 108 switch p.IntersectionBox2D(nbox) {
107 case IntersectionInside: 109 case IntersectionInside:
108 // all inside so nothing to clip. 110 // all inside so nothing to clip.
111 nodesAllInside++
109 continue children 112 continue children
110 case IntersectionOutSide: 113 case IntersectionOutSide:
111 // all are ouside -> clip from tree. 114 // all are ouside -> clip from tree.
115 nodesClipped++
112 index[i] = 0 116 index[i] = 0
113 index[i+4] = 0 117 index[i+4] = 0
114 continue 118 continue children
115 default: // Overlaps 119 default: // Overlaps
116 if a != 0 { 120 if a != 0 {
117 stack = append(stack, boxFrame{a, nbox}) 121 stack = append(stack, boxFrame{a, nbox})
118 } 122 }
119 if b != 0 { 123 if b != 0 {