summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdimension/bvst.c18
-rw-r--r--libdimension/geometry.c9
2 files changed, 17 insertions, 10 deletions
diff --git a/libdimension/bvst.c b/libdimension/bvst.c
index c0888bb..7a57c76 100644
--- a/libdimension/bvst.c
+++ b/libdimension/bvst.c
@@ -105,12 +105,10 @@ dmnsn_bvst_insert(dmnsn_bvst *tree, dmnsn_object *object)
dmnsn_bvst_node *node = dmnsn_new_bvst_node(), *parent = tree->root;
- node->contains = NULL;
- node->container = NULL;
- node->parent = NULL;
- node->object = object;
-
- /* Calculate the new bounding box */
+ node->contains = NULL;
+ node->container = NULL;
+ node->parent = NULL;
+ node->object = object;
node->bounding_box = object->bounding_box;
/* Now insert the node */
@@ -122,9 +120,9 @@ dmnsn_bvst_insert(dmnsn_bvst *tree, dmnsn_object *object)
node->bounding_box.max))
{
/* parent fully contains node */
- if (parent->contains)
+ if (parent->contains) {
parent = parent->contains;
- else {
+ } else {
/* We found our parent; insert node into the tree */
parent->contains = node;
node->parent = parent;
@@ -135,9 +133,9 @@ dmnsn_bvst_insert(dmnsn_bvst *tree, dmnsn_object *object)
already */
dmnsn_bvst_node_swallow(node, parent->bounding_box);
/* node now fully contains parent */
- if (parent->container)
+ if (parent->container) {
parent = parent->container;
- else {
+ } else {
/* We found our parent; insert node into the tree */
parent->container = node;
node->parent = parent;
diff --git a/libdimension/geometry.c b/libdimension/geometry.c
index 7dc6725..304f21d 100644
--- a/libdimension/geometry.c
+++ b/libdimension/geometry.c
@@ -363,6 +363,15 @@ dmnsn_matrix_vector_mul(dmnsn_matrix lhs, dmnsn_vector rhs)
dmnsn_bounding_box
dmnsn_matrix_bounding_box_mul(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);
+ return box;
+ }
+
dmnsn_vector corner;
dmnsn_bounding_box ret;
ret.min = dmnsn_matrix_vector_mul(trans, box.min);