Revision: 51692
          http://brlcad.svn.sourceforge.net/brlcad/?rev=51692&view=rev
Author:   r_weiss
Date:     2012-07-27 21:11:38 +0000 (Fri, 27 Jul 2012)
Log Message:
-----------
Updated file "tie.c" functions "tie_tri_prep" and "tie_work". Removed the test 
for a too small of denominator in function "tie_work" and added code to 
function "tie_tri_prep" to prevent normals of (0,0,0) which was causing a zero 
denominator in function "tie_work".  

Modified Paths:
--------------
    brlcad/trunk/src/librt/primitives/bot/tie.c

Modified: brlcad/trunk/src/librt/primitives/bot/tie.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/tie.c 2012-07-27 16:57:37 UTC (rev 
51691)
+++ brlcad/trunk/src/librt/primitives/bot/tie.c 2012-07-27 21:11:38 UTC (rev 
51692)
@@ -55,6 +55,7 @@
     TIE_3 v1, v2, u, v;
     unsigned int i, i1, i2;
     struct tie_tri_s *tri;
+    fastf_t mag_sq;
 
     for (i = 0; i < tie->tri_num; i++) {
        tri = &tie->tri_list[i];
@@ -67,7 +68,15 @@
        VSUB2(v.v,  tri->data[2].v,  tri->data[0].v);
        VCROSS(tri->data[1].v,  u.v,  v.v);
 
-       VUNITIZE(tri->data[1].v);
+       /* Unitize Normal */
+       mag_sq = MAGSQ(tri->data[1].v);
+       if (mag_sq < SMALL_FASTF) {
+           /* Can not unitize normal, most likely we have a zero area
+            * triangle (ie degenerate) so skip it.
+            */
+           continue;
+       }
+       VSCALE(tri->data[1].v, tri->data[1].v, 1.0/sqrt(mag_sq));
 
        /* Compute i1 and i2 */
        u.v[0] = fabs(tri->data[1].v[0]);
@@ -304,13 +313,6 @@
            tri = data->tri_list[i];
            u0 = VDOT( tri->data[1].v,  ray->pos);
            v0 = VDOT( tri->data[1].v,  ray->dir);
-
-           /* skip rays that are practically perpendicular so we
-            * don't try to divide by zero and propagate NaN (or
-            * crash).
-            */
-           if (v0 < RT_DOT_TOL)
-               continue;
            t.dist = -(tri->data[2].v[0] + u0) / v0;
 
            /*

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


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to