diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-16 10:39:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-16 10:39:40 +0400 |
commit | 6f01b0b11fee61bf6f945eaaa2cf72f87a84a965 (patch) | |
tree | 88488c0bb6771976f9b009ee462b93395181fdda /source/blender/blenlib | |
parent | 4f6cc9a9aae865537ed8e3ee6b9f2171ec8acbfe (diff) |
small speedup for mask rasterizer, only do single sided check for triangle intersection.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index b163be4a70c..f799b7b0ebe 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -154,6 +154,7 @@ int isect_ray_tri_epsilon_v3(const float p1[3], const float d[3], 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]); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index eb30366573b..661c47821fd 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -606,6 +606,20 @@ static short IsectLLPt2Df(const float x0, const float y0, const float x1, const /* 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) { |