Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ fastuidraw_banded_rays_compute_winding_contribution(in fastuidraw_banded_rays_cu
B = curve.p1 - curve.p2;
C = curve.p1;

use_t1 = (curve.p3.y < 0.0 && curve.p1.y > 0.0)
|| (curve.p3.y < 0.0 && curve.p2.y > 0.0)
|| (curve.p1.y >= 0.0 && curve.p2.y < 0.0);
use_t1 = (curve.p3.y <= 0.0 && curve.p1.y > 0.0)
|| (curve.p3.y <= 0.0 && curve.p2.y > 0.0)
|| (curve.p1.y > 0.0 && curve.p2.y < 0.0);

use_t2 = (curve.p1.y < 0 && curve.p2.y > 0.0)
|| (curve.p1.y < 0.0 && curve.p3.y > 0.0)
|| (curve.p3.y >= 0.0 && curve.p2.y < 0.0);
use_t2 = (curve.p1.y <= 0.0 && curve.p2.y > 0.0)
|| (curve.p1.y <= 0.0 && curve.p3.y > 0.0)
|| (curve.p3.y > 0.0 && curve.p2.y < 0.0);

if (abs(A.y) > quad_tol)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,52 +412,68 @@ fastuidraw_restricted_rays_compute_winding_contribution(in fastuidraw_restricted
* = (p1 < 0 && p2 > 0) || (p1 < 0 && p3 > 0) || (p3 > 0 && p1 < 0) || (p3 > 0 && p2 < 0)
* = (p1 < 0 && p2 > 0) || (p1 < 0 && p3 > 0) || (p3 > 0 && p2 < 0)
*
* The last issue is to handle the end-points of the curve correctly.
* The last issue is to handle the end-points of the curve correctly
*
* We use the rules:
*
* (a) use 0 if and only if f(0) = 0 && f'(0) < 0
* (b) use 1 if and only if f(1) = 1 && f'(1) > 0
* (a) use 0 if and only if f(0) = 0 && f'(0) > 0
* (b) use 1 if and only if f(1) = 1 && f'(1) < 0
*
* For the case where p1.y = 0, one gets
*
* Which become
* A = p3.y - 2 * p2.y
* B = -p2.y
* C = 0
*
* thus,
*
* (a) use 0 if and only if p1 == 0 && p2 < p1
* (b) use 1 if and only if p3 == 0 && p2 < p3
* B * B - A * C = p2.y * p2.y
*
* If p1.y is zero, then
* which gives
*
* t1 = (B - |B|) / A
* t2 = (B + |B|) / A
* t2 = (-p2.y + |p2.y|) / (p3.y - 2 * p2.y)
*
* If p2 < 0 = p1, then B > 0 and thus t1 = 0, i.e.
* use t1 whenever (a) is true.
* for p2.y > 0, then t2 = 0 which corresponds to (a)
* and for p2.y < 0, t2 = -2 * p2.y / (p3.y - 2 * p2.y)
* which is 0 < t2 < 1 when p3.y > 0. So if p1.y is zero,
* use t2 if one of p3.y or p2.y is strictly positive.
*
* If p3.y is zero, then algebra will give that
* For the case where p3.y = 0, one gets
*
* A = p1.y - 2 * p2.y
* B = p1.y - p2.y
* C = p1.y
*
* thus,
*
* t1 = ((p1 - p2) - |p2|) / (p1 - 2p2)
* t2 = ((p1 - p2) + |p2|) / (p1 - 2p2)
* B * B - A * C = p2.y * p2.y
*
* thus on condition (b) gives
* which gives
*
* t1 = p1 / (p1 - 2p2)
* t2 = 1
* t1 = (p1.y - p2.y - |p2.y|) / (p1.y - 2 * p2.y)
*
* which means use t2 when (b) is true.
* for p2.y > 0, t1 = 1 and this correponds to (b)
* and for p2.y < 0, t1 = (p1.y) / (p1.y - 2 * p2.y)
* which is 0 < t1 < 1 if p1.y > 0. So if p3.y is zero,
* use t1 if one of p1.y or p2.y is strcitly positive.
*
* Thus,
*
* use_t1 = T1 || (p1 == 0 && p2 < 0)
* = (p3 < 0 && p1 > 0) || (p3 < 0 && p2 > 0) || (p1 >= 0 && p2 < 0)
* use_t1 = T1 || (p3 == 0 && p2 > 0) || (p3 == 0 && p1 > 0)
* = (p3 <= 0 && p1 > 0) || (p3 <= 0 && p2 > 0) || (p1 > 0 && p2 < 0)
* = (p3 <= 0 && max(p1, p2) > 0) || (p1 > 0 && p2 < 0)
*
* use_t2 = T2 || (p3 == 0 && p2 < 0)
* = (p1 < 0 && p2 > 0) || (p1 < 0 && p3 > 0) || (p3 >= 0 && p2 < 0)
* use_t2 = T2 || (p1 == 0 && p2 > 0) || (p1 == 0 && p3 > 0)
* = (p1 <= 0 && p2 > 0) || (p1 <= 0 && p3 > 0) || (p3 > 0 && p2 < 0)
* = (p1 <= 0 && max(p2, p3) > 0) || (p3 > 0 && p2 < 0)
*/
use_t1 = (curve.p3.y < 0.0 && curve.p1.y > 0.0)
|| (curve.p3.y < 0.0 && curve.p2.y > 0.0)
|| (curve.p1.y >= 0.0 && curve.p2.y < 0.0);
use_t1 = (curve.p3.y <= 0.0 && curve.p1.y > 0.0)
|| (curve.p3.y <= 0.0 && curve.p2.y > 0.0)
|| (curve.p1.y > 0.0 && curve.p2.y < 0.0);

use_t2 = (curve.p1.y < 0 && curve.p2.y > 0.0)
|| (curve.p1.y < 0.0 && curve.p3.y > 0.0)
|| (curve.p3.y >= 0.0 && curve.p2.y < 0.0);
use_t2 = (curve.p1.y <= 0.0 && curve.p2.y > 0.0)
|| (curve.p1.y <= 0.0 && curve.p3.y > 0.0)
|| (curve.p3.y > 0.0 && curve.p2.y < 0.0);

if (curve.is_quadratic && abs(A.y) > quad_tol)
{
Expand Down
Loading