Richard et al,

I completely restructured the rec shot routine because I noticed several 
problems (new and old).  My testing after changing it was very favorable, but 
please let me know if you find a problem.

Right now, the main change was to always test intersections against the 
cylinder and the end plates, then combine duplicate hits if any.  This avoids 
the extensive spaghetti goto logic that was there before.  The predictable 
branching seems to help performance too.

This change should result in the same hit points as before (within tolerance), 
but will prefer normals coming off the end plates instead of the cylinder for 
grazing cases where it's technically hitting both.  The quadratic formula was 
also screwy (at least in a form I'm not used to), so I changed it to the 
classical form (i.e., (-b +- sqrt()) / 2).  Testing gave same results, which is 
surprising but reassuring.

I ran comparisons with a loop over all azimuth+elevation angle pairings 
([0,360]+[0,360]) and encountered no differences with a few testing rcc's, but 
there may be some subtle grazing hit changes.  At least in theory, it's more 
comprehensive now, guaranteed to report hits when they occur.

Keep an eye out for any changes, though, and I'll investigate.

Cheers!
Sean

p.s. A nice improvement would be to prefer the normal facing most towards the 
ray, not just the end-plate normals.  An exercise left for the reader. ;)



On Jul 11, 2013, at 6:25 PM, [email protected] wrote:

> Revision: 56016
>          http://sourceforge.net/p/brlcad/code/56016
> Author:   r_weiss
> Date:     2013-07-11 22:25:29 +0000 (Thu, 11 Jul 2013)
> Log Message:
> -----------
> Fix special case errors when ray tracing the tgc/rec primitive. Needs more 
> testing. Such as sample model "havoc.g" primitive "rt_s.ecov6" with ray 
> r_pt=(12320.0005 -1168 2134) r_dir=(1 0 0).
> 
> Modified Paths:
> --------------
>    brlcad/trunk/src/librt/primitives/rec/rec.c
> 
> Modified: brlcad/trunk/src/librt/primitives/rec/rec.c
> ===================================================================
> --- brlcad/trunk/src/librt/primitives/rec/rec.c       2013-07-11 21:42:00 UTC 
> (rev 56015)
> +++ brlcad/trunk/src/librt/primitives/rec/rec.c       2013-07-11 22:25:29 UTC 
> (rev 56016)
> @@ -467,9 +467,11 @@
> 
>       b = 2 * (dprime[X]*pprime[X] + dprime[Y]*pprime[Y]) *
>           (dx2dy2 = 1 / (dprime[X]*dprime[X] + dprime[Y]*dprime[Y]));
> -     if ((root = b*b - 4 * dx2dy2 *
> -          (pprime[X]*pprime[X] + pprime[Y]*pprime[Y] - 1)) <= 0)
> +     root = b*b - 4 * dx2dy2 * (pprime[X]*pprime[X] + pprime[Y]*pprime[Y] - 
> 1);
> +
> +     if (root < SMALL_FASTF || root > 1.0e10) {
>           goto check_plates;
> +     }
>       root = sqrt(root);
> 
>       k1 = (root-b) * 0.5;
> @@ -481,7 +483,7 @@
>      * See if they fall in range.
>      */
>     VJOIN1(hitp->hit_vpriv, pprime, k1, dprime);              /* hit' */
> -    if (hitp->hit_vpriv[Z] >= 0.0 && hitp->hit_vpriv[Z] <= 1.0) {
> +    if (hitp->hit_vpriv[Z] > -SMALL_FASTF && hitp->hit_vpriv[Z] < (1.0 + 
> SMALL_FASTF)) {
>       hitp->hit_magic = RT_HIT_MAGIC;
>       hitp->hit_dist = k1;
>       hitp->hit_surfno = REC_NORM_BODY;       /* compute N */
> @@ -489,7 +491,7 @@
>     }
> 
>     VJOIN1(hitp->hit_vpriv, pprime, k2, dprime);              /* hit' */
> -    if (hitp->hit_vpriv[Z] >= 0.0 && hitp->hit_vpriv[Z] <= 1.0) {
> +    if (hitp->hit_vpriv[Z] > -SMALL_FASTF && hitp->hit_vpriv[Z] < (1.0 + 
> SMALL_FASTF)) {
>       hitp->hit_magic = RT_HIT_MAGIC;
>       hitp->hit_dist = k2;
>       hitp->hit_surfno = REC_NORM_BODY;       /* compute N */
> @@ -507,7 +509,7 @@
> 
>       VJOIN1(hitp->hit_vpriv, pprime, k1, dprime);    /* hit' */
>       if (hitp->hit_vpriv[X] * hitp->hit_vpriv[X] +
> -         hitp->hit_vpriv[Y] * hitp->hit_vpriv[Y] <= 1.0) {
> +         hitp->hit_vpriv[Y] * hitp->hit_vpriv[Y] < (1.0 + SMALL_FASTF)) {
>           hitp->hit_magic = RT_HIT_MAGIC;
>           hitp->hit_dist = k1;
>           hitp->hit_surfno = REC_NORM_BOT;    /* -H */
> @@ -516,7 +518,7 @@
> 
>       VJOIN1(hitp->hit_vpriv, pprime, k2, dprime);    /* hit' */
>       if (hitp->hit_vpriv[X] * hitp->hit_vpriv[X] +
> -         hitp->hit_vpriv[Y] * hitp->hit_vpriv[Y] <= 1.0) {
> +         hitp->hit_vpriv[Y] * hitp->hit_vpriv[Y] < (1.0 + SMALL_FASTF)) {
>           hitp->hit_magic = RT_HIT_MAGIC;
>           hitp->hit_dist = k2;
>           hitp->hit_surfno = REC_NORM_TOP;    /* +H */
> 
> This was sent by the SourceForge.net collaborative development platform, the 
> world's largest Open Source development site.
> 
> 
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> BRL-CAD Source Commits mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/brlcad-commits


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to