diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-07-20 17:59:53 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-07-20 17:59:53 -0600 |
commit | 16dc58b64c3d57f73223ad66d5a11334c3f87fd8 (patch) | |
tree | 4d3714f3b174c114bd41ac0e4f146ad64e91e299 /libdimension | |
parent | a9670e8946d655105212c289322dc4eddf7986ed (diff) | |
download | dimension-16dc58b64c3d57f73223ad66d5a11334c3f87fd8.tar.xz |
Move test outside of loop in dmnsn_prtree_intersection_recursive().
Diffstat (limited to 'libdimension')
-rw-r--r-- | libdimension/prtree.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/libdimension/prtree.c b/libdimension/prtree.c index 4e6131b..6980337 100644 --- a/libdimension/prtree.c +++ b/libdimension/prtree.c @@ -598,14 +598,13 @@ dmnsn_prtree_intersection_recursive(const dmnsn_prtree_node *node, dmnsn_optimized_line ray, dmnsn_intersection *intersection, double *t) { - for (size_t i = 0; i < DMNSN_PRTREE_B; ++i) { - if (!node->children[i]) - break; + if (node->is_leaf) { + for (size_t i = 0; i < DMNSN_PRTREE_B; ++i) { + if (!node->children[i]) + break; - if (dmnsn_ray_box_intersection(ray, node->bounding_boxes[i], *t)) { - if (node->is_leaf) { + if (dmnsn_ray_box_intersection(ray, node->bounding_boxes[i], *t)) { dmnsn_object *object = node->children[i]; - dmnsn_intersection local_intersection; if ((*object->intersection_fn)(object, ray.line, &local_intersection)) { if (local_intersection.t < *t) { @@ -613,7 +612,14 @@ dmnsn_prtree_intersection_recursive(const dmnsn_prtree_node *node, *t = local_intersection.t; } } - } else { + } + } + } else { + for (size_t i = 0; i < DMNSN_PRTREE_B; ++i) { + if (!node->children[i]) + break; + + if (dmnsn_ray_box_intersection(ray, node->bounding_boxes[i], *t)) { dmnsn_prtree_intersection_recursive( node->children[i], ray, intersection, t ); |