Fix #106929: adjust normalization of zero vector in nodelink shader #107636
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* 2D Quadratic Bezier thick line drawing
|
||||
* 2D Cubic Bezier thick line drawing
|
||||
*/
|
||||
|
||||
#define MID_VERTEX 65
|
||||
|
@ -84,8 +84,14 @@ void main(void)
|
|||
|
||||
vec2 tangent = ((P1 - P0) * one_minus_t2_3 + (P2 - P1) * 6.0 * (t - t2) + (P3 - P2) * t2_3);
|
||||
|
||||
/* tangent space at t */
|
||||
tangent = normalize(tangent);
|
||||
/* Tangent space at t. If the handle overlaps with the endpoint the vector between the two nodes
|
||||
|
||||
* is used as tangent. */
|
||||
if (is_zero(tangent)) {
|
||||
Leon Schittek
commented
I think this is a good place to use the ternary operator:
I think this is a good place to use the ternary operator:
```
tangent = is_zero(tangent) ? normalize(P3 - P0) : normalize(tangent);
```
Marino Toscano
commented
Good idea, much more cleaner. I changed it. Good idea, much more cleaner. I changed it.
|
||||
tangent = normalize(P3 - P0);
|
||||
}
|
||||
else {
|
||||
tangent = normalize(tangent);
|
||||
}
|
||||
vec2 normal = tangent.yx * vec2(-1.0, 1.0);
|
||||
|
||||
/* Position vertex on the curve tangent space */
|
||||
|
|
Loading…
Reference in New Issue
I think "nodes" should be "sockets".
I know this is super nitpicky but I'm not sure "endpoint" and "handle" are good word choices in this part of the code. What about this: