summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-06-06 13:07:50 -0600
committerTavian Barnes <tavianator@gmail.com>2010-06-06 13:07:50 -0600
commit347f6268b922012055fbe77bb4ce9962cbdeb18e (patch)
tree438fd9532755bc956ee7860e9a6388043e395802 /libdimension
parent07806324bb384d3707840303e08f209005afaffe (diff)
downloaddimension-347f6268b922012055fbe77bb4ce9962cbdeb18e.tar.xz
New dmnsn_bounding_box_is_infinite() predicate.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/dimension/geometry.h7
-rw-r--r--libdimension/geometry.c9
-rw-r--r--libdimension/prtree.c2
3 files changed, 10 insertions, 8 deletions
diff --git a/libdimension/dimension/geometry.h b/libdimension/dimension/geometry.h
index effac7c..98fc913 100644
--- a/libdimension/dimension/geometry.h
+++ b/libdimension/dimension/geometry.h
@@ -300,4 +300,11 @@ dmnsn_bounding_box_contains(dmnsn_bounding_box box, dmnsn_vector p)
&& (p.x <= box.max.x && p.y <= box.max.y && p.z <= box.max.z);
}
+/* Return whether `box' is infinite */
+DMNSN_INLINE bool
+dmnsn_bounding_box_is_infinite(dmnsn_bounding_box box)
+{
+ return box.min.x == -INFINITY;
+}
+
#endif /* DIMENSION_GEOMETRY_H */
diff --git a/libdimension/geometry.c b/libdimension/geometry.c
index 8edb2c3..5d14953 100644
--- a/libdimension/geometry.c
+++ b/libdimension/geometry.c
@@ -362,14 +362,9 @@ dmnsn_transform_vector(dmnsn_matrix lhs, dmnsn_vector rhs)
dmnsn_bounding_box
dmnsn_transform_bounding_box(dmnsn_matrix trans, dmnsn_bounding_box box)
{
- /* Infinite bounding box support */
- if (isinf(box.min.x) || isinf(box.min.y) || isinf(box.min.z)
- || isinf(box.max.x) || isinf(box.max.y) || isinf(box.max.z))
- {
- box.min = dmnsn_new_vector(-INFINITY, -INFINITY, -INFINITY);
- box.max = dmnsn_new_vector(INFINITY, INFINITY, INFINITY);
+ /* Infinite/zero bounding box support */
+ if (isinf(box.min.x))
return box;
- }
dmnsn_vector corner;
dmnsn_bounding_box ret;
diff --git a/libdimension/prtree.c b/libdimension/prtree.c
index d36e54a..15bc997 100644
--- a/libdimension/prtree.c
+++ b/libdimension/prtree.c
@@ -451,7 +451,7 @@ dmnsn_split_unbounded(dmnsn_list *objects)
dmnsn_object *object;
dmnsn_list_get(i, &object);
- if (isinf(object->bounding_box.min.x)) {
+ if (dmnsn_bounding_box_is_infinite(object->bounding_box)) {
dmnsn_list_iterator *next = dmnsn_list_next(i);
dmnsn_list_iterator_remove(objects, i);
dmnsn_list_iterator_insert(unbounded, NULL, i);