Revision: 46909
          http://brlcad.svn.sourceforge.net/brlcad/?rev=46909&view=rev
Author:   bob1961
Date:     2011-09-26 20:48:41 +0000 (Mon, 26 Sep 2011)
Log Message:
-----------
Added a member to "struct application" for disabling bot normal reversal in 
librt/primitive/bot so that hitting a bot would yield, among other things, the 
bot's actual normal. With "bot normal reversal" disabled, a ray can be used to 
determine if a bot's normal needs to be flipped.

Modified Paths:
--------------
    brlcad/trunk/include/raytrace.h
    brlcad/trunk/src/librt/primitives/bot/bot.c
    brlcad/trunk/src/librt/primitives/bot/g_bot_include.c

Modified: brlcad/trunk/include/raytrace.h
===================================================================
--- brlcad/trunk/include/raytrace.h     2011-09-26 20:35:41 UTC (rev 46908)
+++ brlcad/trunk/include/raytrace.h     2011-09-26 20:48:41 UTC (rev 46909)
@@ -1655,6 +1655,7 @@
     char **            attrs;          /**< @brief  null terminated list of 
attributes
                                         * This list should be the same as 
passed to
                                         * rt_gettrees_and_attrs() */
+    int                        a_bot_reverse_normal_disabled;  /**< @brief  1= 
no bot normals get reversed in BOT_UNORIENTED_NORM */
     /* THESE ELEMENTS ARE USED BY THE PROGRAM "rt" AND MAY BE USED BY */
     /* THE LIBRARY AT SOME FUTURE DATE */
     /* AT THIS TIME THEY MAY BE LEFT ZERO */

Modified: brlcad/trunk/src/librt/primitives/bot/bot.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/bot.c 2011-09-26 20:35:41 UTC (rev 
46908)
+++ brlcad/trunk/src/librt/primitives/bot/bot.c 2011-09-26 20:48:41 UTC (rev 
46909)
@@ -52,20 +52,24 @@
 
 #define BOT_MIN_DN 1.0e-9
 
-#define BOT_UNORIENTED_NORM(_hitp, _out) { \
-       if (_out) {     /* this is an exit */ \
-               if ((_hitp)->hit_vpriv[X] < 0.0) { \
-                       VREVERSE((_hitp)->hit_normal, trip->tri_N); \
-               } else { \
-                       VMOVE((_hitp)->hit_normal, trip->tri_N); \
-               } \
-       } else {        /* this is an entrance */ \
-               if ((_hitp)->hit_vpriv[X] > 0.0) { \
-                       VREVERSE((_hitp)->hit_normal, trip->tri_N); \
-               } else { \
-                       VMOVE((_hitp)->hit_normal, trip->tri_N); \
-               } \
-       } \
+#define BOT_UNORIENTED_NORM(_ap, _hitp, _out) {                            \
+       if (!(_ap)->a_bot_reverse_normal_disabled) {                \
+           if (_out) { /* this is an exit */                       \
+               if ((_hitp)->hit_vpriv[X] < 0.0) {                  \
+                   VREVERSE((_hitp)->hit_normal, trip->tri_N);     \
+               } else {                                            \
+                   VMOVE((_hitp)->hit_normal, trip->tri_N);        \
+               }                                                   \
+           } else {    /* this is an entrance */                   \
+               if ((_hitp)->hit_vpriv[X] > 0.0) {                  \
+                   VREVERSE((_hitp)->hit_normal, trip->tri_N);     \
+               } else {                                            \
+                   VMOVE((_hitp)->hit_normal, trip->tri_N);        \
+               }                                                   \
+           }                                                       \
+       } else {                                                    \
+           VMOVE((_hitp)->hit_normal, trip->tri_N);                \
+       }                                                           \
 }
 
 

Modified: brlcad/trunk/src/librt/primitives/bot/g_bot_include.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/g_bot_include.c       2011-09-26 
20:35:41 UTC (rev 46908)
+++ brlcad/trunk/src/librt/primitives/bot/g_bot_include.c       2011-09-26 
20:48:41 UTC (rev 46909)
@@ -421,13 +421,13 @@
 
            /* set in hit */
            segp->seg_in = hits[i];
-           BOT_UNORIENTED_NORM(&segp->seg_in, IN);
+           BOT_UNORIENTED_NORM(ap, &segp->seg_in, IN);
 
            /* set out hit */
            segp->seg_out.hit_surfno = surfno;
            segp->seg_out.hit_dist = segp->seg_in.hit_dist + los;
            VMOVE(segp->seg_out.hit_vpriv, hits[i].hit_vpriv);
-           BOT_UNORIENTED_NORM(&segp->seg_out, OUT);
+           BOT_UNORIENTED_NORM(ap, &segp->seg_out, OUT);
            segp->seg_out.hit_private = segp->seg_in.hit_private;
            segp->seg_out.hit_rayp = &ap->a_ray;
 
@@ -440,7 +440,7 @@
            /* set in hit */
            segp->seg_in.hit_surfno = surfno;
            VMOVE(segp->seg_in.hit_vpriv, hits[i].hit_vpriv);
-           BOT_UNORIENTED_NORM(&segp->seg_in, IN);
+           BOT_UNORIENTED_NORM(ap, &segp->seg_in, IN);
            segp->seg_in.hit_private = hits[i].hit_private;
            segp->seg_in.hit_dist = hits[i].hit_dist - (los*0.5);
            segp->seg_in.hit_rayp = &ap->a_ray;
@@ -449,7 +449,7 @@
            segp->seg_out.hit_surfno = surfno;
            segp->seg_out.hit_dist = segp->seg_in.hit_dist + los;
            VMOVE(segp->seg_out.hit_vpriv, hits[i].hit_vpriv);
-           BOT_UNORIENTED_NORM(&segp->seg_out, OUT);
+           BOT_UNORIENTED_NORM(ap, &segp->seg_out, OUT);
            segp->seg_out.hit_private = hits[i].hit_private;
            segp->seg_out.hit_rayp = &ap->a_ray;
 
@@ -489,11 +489,11 @@
 
        /* set in hit */
        segp->seg_in = hits[0];
-       BOT_UNORIENTED_NORM(&segp->seg_in, IN);
+       BOT_UNORIENTED_NORM(ap, &segp->seg_in, IN);
 
        /* set out hit */
        segp->seg_out = hits[0];
-       BOT_UNORIENTED_NORM(&segp->seg_out, OUT);
+       BOT_UNORIENTED_NORM(ap, &segp->seg_out, OUT);
 
        BU_LIST_INSERT(&(seghead->l), &(segp->l));
        return 1;
@@ -543,12 +543,12 @@
        /* set in hit */
        segp->seg_in = hits[i];
        trip = (XGLUE(tri_specific_, TRI_TYPE) *)hits[i].hit_private;
-       BOT_UNORIENTED_NORM(&segp->seg_in, IN);
+       BOT_UNORIENTED_NORM(ap, &segp->seg_in, IN);
 
        /* set out hit */
        segp->seg_out = hits[i+1];
        trip = (XGLUE(tri_specific_, TRI_TYPE) *)hits[i+1].hit_private;
-       BOT_UNORIENTED_NORM(&segp->seg_out, OUT);
+       BOT_UNORIENTED_NORM(ap, &segp->seg_out, OUT);
 
        BU_LIST_INSERT(&(seghead->l), &(segp->l));
     }
@@ -596,11 +596,11 @@
 
            /* set in hit */
            segp->seg_in = hits[i];
-           BOT_UNORIENTED_NORM(&segp->seg_in, IN);
+           BOT_UNORIENTED_NORM(ap, &segp->seg_in, IN);
 
            /* set out hit */
            segp->seg_out = hits[i];
-           BOT_UNORIENTED_NORM(&segp->seg_out, OUT);
+           BOT_UNORIENTED_NORM(ap, &segp->seg_out, OUT);
            BU_LIST_INSERT(&(seghead->l), &(segp->l));
        }
        /* Every hit turns into two, and makes a seg.  No leftovers */
@@ -1007,10 +1007,10 @@
        segp->seg_stp = stp;
        segp->seg_in = hits[i]; /* struct copy */
        trip = (XGLUE(tri_specific_, TRI_TYPE) *)hits[i].hit_private;
-       BOT_UNORIENTED_NORM(&segp->seg_in, IN);
+       BOT_UNORIENTED_NORM(ap, &segp->seg_in, IN);
        segp->seg_out = hits[i+1];      /* struct copy */
        trip = (XGLUE(tri_specific_, TRI_TYPE) *)hits[i+1].hit_private;
-       BOT_UNORIENTED_NORM(&segp->seg_out, OUT);
+       BOT_UNORIENTED_NORM(ap, &segp->seg_out, OUT);
        BU_LIST_INSERT(&(seghead->l), &(segp->l));
     }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to