changeset 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 843f39b9327e
children 5c3e63cfd50d
files pkg/octree/tree.go
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/octree/tree.go	Mon Mar 04 14:46:49 2019 +0100
+++ b/pkg/octree/tree.go	Mon Mar 04 14:58:22 2019 +0100
@@ -80,10 +80,12 @@
 			case IntersectionOutSide:
 				// all outside -> clip from tree.
 				nodesClipped++
-				if index := ot.index[top.pos:]; len(index) > 7 {
-					for i := range index {
-						index[i] = 0
-					}
+				index := ot.index[top.pos:]
+				if len(index) > 8 {
+					index = index[:8]
+				}
+				for i := range index {
+					index[i] = 0
 				}
 				continue frames
 			default: // Overlaps
@@ -106,12 +108,14 @@
 						switch p.IntersectionBox2D(nbox) {
 						case IntersectionInside:
 							// all inside so nothing to clip.
+							nodesAllInside++
 							continue children
 						case IntersectionOutSide:
 							// all are ouside -> clip from tree.
+							nodesClipped++
 							index[i] = 0
 							index[i+4] = 0
-							continue
+							continue children
 						default: // Overlaps
 							if a != 0 {
 								stack = append(stack, boxFrame{a, nbox})