Revision: 66055
          http://sourceforge.net/p/brlcad/code/66055
Author:   vasco_costa
Date:     2015-08-20 17:43:32 +0000 (Thu, 20 Aug 2015)
Log Message:
-----------
handle clockwise oriented triangles.

Modified Paths:
--------------
    brlcad/branches/opencl/include/rt/primitives/bot.h
    brlcad/branches/opencl/src/librt/primitives/bot/bot.c
    brlcad/branches/opencl/src/librt/primitives/bot/bot_shot.cl

Modified: brlcad/branches/opencl/include/rt/primitives/bot.h
===================================================================
--- brlcad/branches/opencl/include/rt/primitives/bot.h  2015-08-20 17:37:23 UTC 
(rev 66054)
+++ brlcad/branches/opencl/include/rt/primitives/bot.h  2015-08-20 17:43:32 UTC 
(rev 66055)
@@ -34,13 +34,13 @@
 #include "rt/soltab.h"
 
 __BEGIN_DECLS
-
 #ifdef USE_OPENCL
 /* largest data members first */
 struct clt_bot_specific {
     cl_ulong offsets[4]; /* To: BVH, Triangles, Normals. */
     cl_uint ntri;
-    cl_uchar pad[4];
+    cl_uchar orientation;
+    cl_uchar pad[3];
 };
 
 struct clt_tri_specific {

Modified: brlcad/branches/opencl/src/librt/primitives/bot/bot.c
===================================================================
--- brlcad/branches/opencl/src/librt/primitives/bot/bot.c       2015-08-20 
17:37:23 UTC (rev 66054)
+++ brlcad/branches/opencl/src/librt/primitives/bot/bot.c       2015-08-20 
17:43:32 UTC (rev 66055)
@@ -145,7 +145,8 @@
 
     ntri = bip->num_faces;
 
-    bot->header.ntri = ntri;
+    bot->header.ntri = bip->num_faces;
+    bot->header.orientation = bip->orientation;
     bot->header.offsets[0] = sizeof(bot->header);
     bot->header.offsets[1] = bot->header.offsets[2] = bot->header.offsets[3] = 
0;
 

Modified: brlcad/branches/opencl/src/librt/primitives/bot/bot_shot.cl
===================================================================
--- brlcad/branches/opencl/src/librt/primitives/bot/bot_shot.cl 2015-08-20 
17:37:23 UTC (rev 66054)
+++ brlcad/branches/opencl/src/librt/primitives/bot/bot_shot.cl 2015-08-20 
17:43:32 UTC (rev 66055)
@@ -1,10 +1,17 @@
 #include "common.cl"
 
 
+/* orientations for BOT */
+#define RT_BOT_UNORIENTED 1    /**< @brief unoriented triangles */
+#define RT_BOT_CCW 2           /**< @brief oriented counter-clockwise */
+#define RT_BOT_CW 3            /**< @brief oriented clockwise */
+
+
 struct bot_specific {
     ulong offsets[4];    // To: BVH, Triangles, Normals.
     uint ntri;
-    uchar pad[4];
+    uchar orientation;
+    uchar pad[3];
 };
 
 struct tri_specific {
@@ -70,7 +77,6 @@
                     const double det = dot(e1, P);
 
                     // Backface culling.
-
                     if (ZERO(det)) {
                         continue;   // No hit
                     }
@@ -170,7 +176,9 @@
     const double3 V0 = vload3(0, tri[h].v0);
     const double3 V1 = vload3(0, tri[h].v1);
     const double3 V2 = vload3(0, tri[h].v2);
-    hitp->hit_normal = normalize(cross(V1-V0, V2-V0));
+
+    const double3 normal = normalize(cross(V1-V0, V2-V0));
+    hitp->hit_normal = select(normal, -normal, (ulong3)(bot->orientation == 
RT_BOT_CW));
 }
 
 

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


------------------------------------------------------------------------------
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to