Skip to content

Commit 5f16cb5

Browse files
committed
#16 fix rendering artifacts in testBasic
1 parent 9d8fc84 commit 5f16cb5

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Sources/vger/sdf.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,15 +539,20 @@ inline bool bezierTest(float2 p, float2 A, float2 B, float2 C) {
539539
// Try to be consistent with lineTest so we don't
540540
// double-flip the inside/outside in edge cases.
541541
if (side(B, A, C)) {
542-
if(s <= 0 or t < 0 or (1-s-t) < 0) {
543-
return false; // outside triangle
542+
if(!side(p, A, C)) {
543+
return false;
544544
}
545545
} else {
546-
if(s < 0 or t < 0 or (1-s-t) < 0) {
547-
return false; // outside triangle
546+
if(side(p, A, C)) {
547+
return false;
548548
}
549549
}
550550

551+
// Are we outside edge (A, B) or (B, C)?
552+
if(s < 0 or (1-s-t) < 0) {
553+
return false; // outside triangle
554+
}
555+
551556
// Transform to canonical coordinte space.
552557
float u = s * .5 + t;
553558
float v = t;

0 commit comments

Comments
 (0)