summaryrefslogtreecommitdiffstats
path: root/libdimension/prtree.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-05-08 23:21:48 -0600
committerTavian Barnes <tavianator@gmail.com>2010-05-08 23:21:48 -0600
commit7a21db5914dd7a5666e603d66ed3948b659ba2fc (patch)
treebde8e00a1677ba865adae8a82780d1cc832ece8e /libdimension/prtree.c
parent152362a57dc7fe9dce830ef69118984f854d6375 (diff)
downloaddimension-7a21db5914dd7a5666e603d66ed3948b659ba2fc.tar.xz
New DMNSN_ARRAY_FOREACH() macro, faster than iterating with dmnsn_array_get().
Diffstat (limited to 'libdimension/prtree.c')
-rw-r--r--libdimension/prtree.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/libdimension/prtree.c b/libdimension/prtree.c
index 04d8cc4..dc3ed38 100644
--- a/libdimension/prtree.c
+++ b/libdimension/prtree.c
@@ -430,10 +430,8 @@ dmnsn_pseudo_prtree_leaves(const dmnsn_pseudo_prtree *pseudo)
static void
dmnsn_precompute_objects(const dmnsn_array *objects)
{
- for (size_t i = 0; i < dmnsn_array_size(objects); ++i) {
- dmnsn_object *object;
- dmnsn_array_get(objects, i, &object);
- dmnsn_object_precompute(object);
+ DMNSN_ARRAY_FOREACH (dmnsn_object **, object, objects) {
+ dmnsn_object_precompute(*object);
}
}
@@ -555,12 +553,9 @@ dmnsn_prtree_search(const dmnsn_prtree *tree, dmnsn_line ray,
double t = -1.0;
/* Search the unbounded objects */
- for (size_t i = 0; i < dmnsn_array_size(tree->unbounded); ++i) {
- dmnsn_object *object;
- dmnsn_array_get(tree->unbounded, i, &object);
-
+ DMNSN_ARRAY_FOREACH (dmnsn_object **, object, tree->unbounded) {
dmnsn_intersection local_intersection;
- if ((*object->intersection_fn)(object, ray, &local_intersection)) {
+ if ((*(*object)->intersection_fn)(*object, ray, &local_intersection)) {
if (t < 0.0 || local_intersection.t < t) {
*intersection = local_intersection;
t = local_intersection.t;