Revision: 42275
http://brlcad.svn.sourceforge.net/brlcad/?rev=42275&view=rev
Author: brlcad
Date: 2011-01-14 20:08:45 +0000 (Fri, 14 Jan 2011)
Log Message:
-----------
move rt_in_rpp() into bbox.c given the related functionality, remove the
rt_DB_rpp() debugging function.
Modified Paths:
--------------
brlcad/trunk/src/librt/bbox.c
brlcad/trunk/src/librt/shoot.c
Modified: brlcad/trunk/src/librt/bbox.c
===================================================================
--- brlcad/trunk/src/librt/bbox.c 2011-01-14 20:08:06 UTC (rev 42274)
+++ brlcad/trunk/src/librt/bbox.c 2011-01-14 20:08:45 UTC (rev 42275)
@@ -167,6 +167,113 @@
}
+/**
+ * R T _ I N _ R P P
+ *
+ * Compute the intersections of a ray with a rectangular parallelpiped
+ * (RPP) that has faces parallel to the coordinate planes
+ *
+ * The algorithm here was developed by Gary Kuehl for GIFT. A good
+ * description of the approach used can be found in "??" by XYZZY and
+ * Barsky, ACM Transactions on Graphics, Vol 3 No 1, January 1984.
+ *
+ * Note: The computation of entry and exit distance is mandatory, as
+ * the final test catches the majority of misses.
+ *
+ * Note: A hit is returned if the intersect is behind the start point.
+ *
+ * Returns -
+ * 0 if ray does not hit RPP,
+ * !0 if ray hits RPP.
+ *
+ * Implicit return -
+ * rp->r_min = dist from start of ray to point at which ray ENTERS solid
+ * rp->r_max = dist from start of ray to point at which ray LEAVES solid
+ */
+int
+rt_in_rpp(struct xray *rp,
+ register const fastf_t *invdir, /* inverses of rp->r_dir[] */
+ register const fastf_t *min,
+ register const fastf_t *max)
+{
+ register const fastf_t *pt = &rp->r_pt[0];
+ register fastf_t sv;
+#define st sv /* reuse the register */
+ register fastf_t rmin = -INFINITY;
+ register fastf_t rmax = INFINITY;
+
+ /* Start with infinite ray, and trim it down */
+
+ /* X axis */
+ if (*invdir < 0.0) {
+ /* Heading towards smaller numbers */
+ /* if (*min > *pt) miss */
+ if (rmax > (sv = (*min - *pt) * *invdir))
+ rmax = sv;
+ if (rmin < (st = (*max - *pt) * *invdir))
+ rmin = st;
+ } else if (*invdir > 0.0) {
+ /* Heading towards larger numbers */
+ /* if (*max < *pt) miss */
+ if (rmax > (st = (*max - *pt) * *invdir))
+ rmax = st;
+ if (rmin < ((sv = (*min - *pt) * *invdir)))
+ rmin = sv;
+ } else {
+ /*
+ * Direction cosines along this axis is NEAR 0,
+ * which implies that the ray is perpendicular to the axis,
+ * so merely check position against the boundaries.
+ */
+ if ((*min > *pt) || (*max < *pt))
+ return 0; /* MISS */
+ }
+
+ /* Y axis */
+ pt++; invdir++; max++; min++;
+ if (*invdir < 0.0) {
+ if (rmax > (sv = (*min - *pt) * *invdir))
+ rmax = sv;
+ if (rmin < (st = (*max - *pt) * *invdir))
+ rmin = st;
+ } else if (*invdir > 0.0) {
+ if (rmax > (st = (*max - *pt) * *invdir))
+ rmax = st;
+ if (rmin < ((sv = (*min - *pt) * *invdir)))
+ rmin = sv;
+ } else {
+ if ((*min > *pt) || (*max < *pt))
+ return 0; /* MISS */
+ }
+
+ /* Z axis */
+ pt++; invdir++; max++; min++;
+ if (*invdir < 0.0) {
+ if (rmax > (sv = (*min - *pt) * *invdir))
+ rmax = sv;
+ if (rmin < (st = (*max - *pt) * *invdir))
+ rmin = st;
+ } else if (*invdir > 0.0) {
+ if (rmax > (st = (*max - *pt) * *invdir))
+ rmax = st;
+ if (rmin < ((sv = (*min - *pt) * *invdir)))
+ rmin = sv;
+ } else {
+ if ((*min > *pt) || (*max < *pt))
+ return 0; /* MISS */
+ }
+
+ /* If equal, RPP is actually a plane */
+ if (rmin > rmax)
+ return 0; /* MISS */
+
+ /* HIT. Only now do rp->r_min and rp->r_max have to be written */
+ rp->r_min = rmin;
+ rp->r_max = rmax;
+ return 1; /* HIT */
+}
+
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/librt/shoot.c
===================================================================
--- brlcad/trunk/src/librt/shoot.c 2011-01-14 20:08:06 UTC (rev 42274)
+++ brlcad/trunk/src/librt/shoot.c 2011-01-14 20:08:45 UTC (rev 42275)
@@ -1821,240 +1821,6 @@
}
-/**
- * R T _ I N _ R P P
- *
- * Compute the intersections of a ray with a rectangular parallelpiped
- * (RPP) that has faces parallel to the coordinate planes
- *
- * The algorithm here was developed by Gary Kuehl for GIFT. A good
- * description of the approach used can be found in "??" by XYZZY and
- * Barsky, ACM Transactions on Graphics, Vol 3 No 1, January 1984.
- *
- * Note: The computation of entry and exit distance is mandatory, as
- * the final test catches the majority of misses.
- *
- * Note: A hit is returned if the intersect is behind the start point.
- *
- * Returns -
- * 0 if ray does not hit RPP,
- * !0 if ray hits RPP.
- *
- * Implicit return -
- * rp->r_min = dist from start of ray to point at which ray ENTERS solid
- * rp->r_max = dist from start of ray to point at which ray LEAVES solid
- */
-int
-rt_in_rpp(struct xray *rp,
- register const fastf_t *invdir, /* inverses of rp->r_dir[] */
- register const fastf_t *min,
- register const fastf_t *max)
-{
- register const fastf_t *pt = &rp->r_pt[0];
- register fastf_t sv;
-#define st sv /* reuse the register */
- register fastf_t rmin = -INFINITY;
- register fastf_t rmax = INFINITY;
-
- /* Start with infinite ray, and trim it down */
-
- /* X axis */
- if (*invdir < 0.0) {
- /* Heading towards smaller numbers */
- /* if (*min > *pt) miss */
- if (rmax > (sv = (*min - *pt) * *invdir))
- rmax = sv;
- if (rmin < (st = (*max - *pt) * *invdir))
- rmin = st;
- } else if (*invdir > 0.0) {
- /* Heading towards larger numbers */
- /* if (*max < *pt) miss */
- if (rmax > (st = (*max - *pt) * *invdir))
- rmax = st;
- if (rmin < ((sv = (*min - *pt) * *invdir)))
- rmin = sv;
- } else {
- /*
- * Direction cosines along this axis is NEAR 0,
- * which implies that the ray is perpendicular to the axis,
- * so merely check position against the boundaries.
- */
- if ((*min > *pt) || (*max < *pt))
- return 0; /* MISS */
- }
-
- /* Y axis */
- pt++; invdir++; max++; min++;
- if (*invdir < 0.0) {
- if (rmax > (sv = (*min - *pt) * *invdir))
- rmax = sv;
- if (rmin < (st = (*max - *pt) * *invdir))
- rmin = st;
- } else if (*invdir > 0.0) {
- if (rmax > (st = (*max - *pt) * *invdir))
- rmax = st;
- if (rmin < ((sv = (*min - *pt) * *invdir)))
- rmin = sv;
- } else {
- if ((*min > *pt) || (*max < *pt))
- return 0; /* MISS */
- }
-
- /* Z axis */
- pt++; invdir++; max++; min++;
- if (*invdir < 0.0) {
- if (rmax > (sv = (*min - *pt) * *invdir))
- rmax = sv;
- if (rmin < (st = (*max - *pt) * *invdir))
- rmin = st;
- } else if (*invdir > 0.0) {
- if (rmax > (st = (*max - *pt) * *invdir))
- rmax = st;
- if (rmin < ((sv = (*min - *pt) * *invdir)))
- rmin = sv;
- } else {
- if ((*min > *pt) || (*max < *pt))
- return 0; /* MISS */
- }
-
- /* If equal, RPP is actually a plane */
- if (rmin > rmax)
- return 0; /* MISS */
-
- /* HIT. Only now do rp->r_min and rp->r_max have to be written */
- rp->r_min = rmin;
- rp->r_max = rmax;
- return 1; /* HIT */
-}
-
-
-/* For debugging */
-int
-rt_DB_rpp(register struct xray *rp, register const fastf_t *invdir, register
const fastf_t *min, register const fastf_t *max)
-
-/* inverses of rp->r_dir[] */
-
-
-{
- register const fastf_t *pt = &rp->r_pt[0];
- fastf_t sv;
-
- /* Start with infinite ray, and trim it down */
- rp->r_min = -INFINITY;
- rp->r_max = INFINITY;
-
- VPRINT("r_pt ", pt);
- VPRINT("r_dir", rp->r_dir);
- VPRINT("min ", min);
- VPRINT("max ", max);
- /* X axis */
- if (rp->r_dir[X] < 0.0) {
- /* Heading towards smaller numbers */
- /* if (*min > *pt) miss */
- sv = (*min - *pt) * *invdir;
- bu_log("sv=%g, r_max=%g\n", sv, rp->r_max);
- if (rp->r_max > sv)
- rp->r_max = sv;
- st = (*max - *pt) * *invdir;
- bu_log("st=%g, r_min=%g\n", st, rp->r_min);
- if (rp->r_min < st)
- rp->r_min = st;
- bu_log("r_min=%g, r_max=%g\n", rp->r_min, rp->r_max);
- } else if (rp->r_dir[X] > 0.0) {
- /* Heading towards larger numbers */
- /* if (*max < *pt) miss */
- st = (*max - *pt) * *invdir;
- bu_log("st=%g, r_max=%g\n", st, rp->r_max);
- if (rp->r_max > st)
- rp->r_max = st;
- sv = (*min - *pt) * *invdir;
- bu_log("sv=%g, r_min=%g\n", sv, rp->r_min);
- if (rp->r_min < sv)
- rp->r_min = sv;
- bu_log("r_min=%g, r_max=%g\n", rp->r_min, rp->r_max);
- } else {
- /*
- * Direction cosines along this axis is NEAR 0, which implies
- * that the ray is perpendicular to the axis, so merely check
- * position against the boundaries.
- */
- if ((*min > *pt) || (*max < *pt))
- goto miss;
- }
-
- /* Y axis */
- pt++; invdir++; max++; min++;
- if (rp->r_dir[Y] < 0.0) {
- /* Heading towards smaller numbers */
- /* if (*min > *pt) miss */
- sv = (*min - *pt) * *invdir;
- bu_log("sv=%g, r_max=%g\n", sv, rp->r_max);
- if (rp->r_max > sv)
- rp->r_max = sv;
- st = (*max - *pt) * *invdir;
- bu_log("st=%g, r_min=%g\n", st, rp->r_min);
- if (rp->r_min < st)
- rp->r_min = st;
- bu_log("r_min=%g, r_max=%g\n", rp->r_min, rp->r_max);
- } else if (rp->r_dir[Y] > 0.0) {
- /* Heading towards larger numbers */
- /* if (*max < *pt) miss */
- st = (*max - *pt) * *invdir;
- bu_log("st=%g, r_max=%g\n", st, rp->r_max);
- if (rp->r_max > st)
- rp->r_max = st;
- sv = (*min - *pt) * *invdir;
- bu_log("sv=%g, r_min=%g\n", sv, rp->r_min);
- if (rp->r_min < sv)
- rp->r_min = sv;
- bu_log("r_min=%g, r_max=%g\n", rp->r_min, rp->r_max);
- } else {
- if ((*min > *pt) || (*max < *pt))
- goto miss;
- }
-
- /* Z axis */
- pt++; invdir++; max++; min++;
- if (rp->r_dir[Z] < 0.0) {
- /* Heading towards smaller numbers */
- /* if (*min > *pt) miss */
- sv = (*min - *pt) * *invdir;
- bu_log("sv=%g, r_max=%g\n", sv, rp->r_max);
- if (rp->r_max > sv)
- rp->r_max = sv;
- st = (*max - *pt) * *invdir;
- bu_log("st=%g, r_min=%g\n", st, rp->r_min);
- if (rp->r_min < st)
- rp->r_min = st;
- bu_log("r_min=%g, r_max=%g\n", rp->r_min, rp->r_max);
- } else if (rp->r_dir[Z] > 0.0) {
- /* Heading towards larger numbers */
- /* if (*max < *pt) miss */
- st = (*max - *pt) * *invdir;
- bu_log("st=%g, r_max=%g\n", st, rp->r_max);
- if (rp->r_max > st)
- rp->r_max = st;
- sv = (*min - *pt) * *invdir;
- bu_log("sv=%g, r_min=%g\n", sv, rp->r_min);
- if (rp->r_min < sv)
- rp->r_min = sv;
- bu_log("r_min=%g, r_max=%g\n", rp->r_min, rp->r_max);
- } else {
- if ((*min > *pt) || (*max < *pt))
- goto miss;
- }
-
- /* If equal, RPP is actually a plane */
- if (rp->r_min > rp->r_max)
- goto miss;
- bu_log("HIT: %g..%g\n", rp->r_min, rp->r_max);
- return 1; /* HIT */
-miss:
- bu_log("MISS\n");
- return 0; /* MISS */
-}
-
-
void
rt_zero_res_stats(struct resource *resp)
{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits