|
|
|
@ -98,7 +98,7 @@ function bvh_add_stroke(bvh, index, stroke) {
@@ -98,7 +98,7 @@ function bvh_add_stroke(bvh, index, stroke) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (bvh.pqueue.capacity < Math.ceil(bvh.nodes.length * 1.2)) { |
|
|
|
|
bvh.pqueue = new MinQueue(bvh.pqueue.capacity * 2); |
|
|
|
|
bvh.pqueue = new MinQueue(bvh.nodes.length * 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// It's as easy as 1-2-3
|
|
|
|
@ -141,7 +141,7 @@ function bvh_add_stroke(bvh, index, stroke) {
@@ -141,7 +141,7 @@ function bvh_add_stroke(bvh, index, stroke) {
|
|
|
|
|
bvh.nodes[new_parent].bbox = new_bbox; |
|
|
|
|
bvh.nodes[new_parent].area = (new_bbox.x2 - new_bbox.x1) * (new_bbox.y2 - new_bbox.y1); |
|
|
|
|
|
|
|
|
|
// 3. Refit
|
|
|
|
|
// 3. Refit and insert in fullnode
|
|
|
|
|
let refit_index = bvh.nodes[leaf_index].parent_index; |
|
|
|
|
while (refit_index !== null) { |
|
|
|
|
const child1 = bvh.nodes[refit_index].child1; |
|
|
|
@ -149,6 +149,10 @@ function bvh_add_stroke(bvh, index, stroke) {
@@ -149,6 +149,10 @@ function bvh_add_stroke(bvh, index, stroke) {
|
|
|
|
|
|
|
|
|
|
bvh.nodes[refit_index].bbox = quad_union(bvh.nodes[child1].bbox, bvh.nodes[child2].bbox); |
|
|
|
|
|
|
|
|
|
if (bvh.nodes[refit_index].is_fullnode) { |
|
|
|
|
tv_add2(bvh.nodes[refit_index].stroke_indices, index); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refit_index = bvh.nodes[refit_index].parent_index; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|