Revision: 48949
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48949
Author:   campbellbarton
Date:     2012-07-16 06:39:40 +0000 (Mon, 16 Jul 2012)
Log Message:
-----------
small speedup for mask rasterizer, only do single sided check for triangle 
intersection.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c
    trunk/blender/source/blender/blenlib/BLI_math_geom.h
    trunk/blender/source/blender/blenlib/intern/math_geom.c

Modified: trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c     
2012-07-16 03:43:57 UTC (rev 48948)
+++ trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c     
2012-07-16 06:39:40 UTC (rev 48949)
@@ -727,9 +727,9 @@
                        /* tri's */
                        face = (unsigned int *)face_array;
                        for (sf_tri = sf_ctx.fillfacebase.first, face_index = 
0; sf_tri; sf_tri = sf_tri->next, face_index++) {
+                               *(face++) = sf_tri->v3->tmp.u;
+                               *(face++) = sf_tri->v2->tmp.u;
                                *(face++) = sf_tri->v1->tmp.u;
-                               *(face++) = sf_tri->v2->tmp.u;
-                               *(face++) = sf_tri->v3->tmp.u;
                                *(face++) = TRI_VERT;
                        }
 
@@ -881,7 +881,7 @@
                    (cos[1][2] < dist_orig) ||
                    (cos[2][2] < dist_orig))
                {
-                       if (isect_point_tri_v2(xy, cos[face[0]], cos[face[1]], 
cos[face[2]])) {
+                       if (isect_point_tri_v2_cw(xy, cos[face[0]], 
cos[face[1]], cos[face[2]])) {
                                /* we know all tris are close for now */
                                return maskrasterize_layer_z_depth_tri(xy, 
cos[face[0]], cos[face[1]], cos[face[2]]);
                        }
@@ -889,7 +889,7 @@
 #else
                /* we know all tris are close for now */
                if (1) {
-                       if (isect_point_tri_v2(xy, cos[face[0]], cos[face[1]], 
cos[face[2]])) {
+                       if (isect_point_tri_v2_cw(xy, cos[face[0]], 
cos[face[1]], cos[face[2]])) {
                                return 0.0f;
                        }
                }
@@ -911,6 +911,8 @@
                                return maskrasterize_layer_z_depth_quad(xy, 
cos[face[0]], cos[face[1]], cos[face[2]], cos[face[3]]);
                        }
 #elif 1
+                       /* don't use isect_point_tri_v2_cw because we could 
have bowtie quads */
+
                        if (isect_point_tri_v2(xy, cos[face[0]], cos[face[1]], 
cos[face[2]])) {
                                return maskrasterize_layer_z_depth_tri(xy, 
cos[face[0]], cos[face[1]], cos[face[2]]);
                        }

Modified: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h        2012-07-16 
03:43:57 UTC (rev 48948)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h        2012-07-16 
06:39:40 UTC (rev 48949)
@@ -154,6 +154,7 @@
 int isect_point_quad_v2(const float p[2], const float a[2], const float b[2], 
const float c[2], const float d[2]);
 
 int isect_point_tri_v2(const float v1[2], const float v2[2], const float 
v3[2], const float pt[2]);
+int isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float 
v2[2], const float v3[2]);
 int isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int 
y2, const int a, const int b);
 int isect_point_tri_prism_v3(const float p[3], const float v1[3], const float 
v2[3], const float v3[3]);
 

Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c     2012-07-16 
03:43:57 UTC (rev 48948)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c     2012-07-16 
06:39:40 UTC (rev 48949)
@@ -606,6 +606,20 @@
 
 /* point in tri */
 
+/* only single direction */
+int isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float 
v2[2], const float v3[2])
+{
+       if (line_point_side_v2(v1, v2, pt) >= 0.0f) {
+               if (line_point_side_v2(v2, v3, pt) >= 0.0f) {
+                       if (line_point_side_v2(v3, v1, pt) >= 0.0f) {
+                               return 1;
+                       }
+               }
+       }
+
+       return 0;
+}
+
 int isect_point_tri_v2(const float pt[2], const float v1[2], const float 
v2[2], const float v3[2])
 {
        if (line_point_side_v2(v1, v2, pt) >= 0.0f) {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to