diff --git a/utils/geom.c b/utils/geom.c index 85e21e7..80e9bf0 100644 --- a/utils/geom.c +++ b/utils/geom.c @@ -2108,25 +2108,22 @@ void get_prism_bounding_box(prism *prsm, geom_box *box) int num_vertices = prsm->vertices.num_items; double height = prsm->height; - // set x,y coordinates of low, high to bounding box - // of prism base polygon (in prism coordinate system) - vector3 low=vertices[0], high=vertices[0]; - int nv; - for(nv=1; nvlow = prism_coordinate_p2c(prsm, low); - box->high = prism_coordinate_p2c(prsm, high); + box->low = box->high = prism_coordinate_p2c(prsm, vertices[0]); + int nv, fc; + for(nv=0; nvlow.x = fmin(box->low.x, vc.x); + box->low.y = fmin(box->low.y, vc.y); + box->low.z = fmin(box->low.z, vc.z); + + box->high.x = fmax(box->high.x, vc.x); + box->high.y = fmax(box->high.y, vc.y); + box->high.z = fmax(box->high.z, vc.z); + } } /***************************************************************/