Fix #106929: adjust normalization of zero vector in nodelink shader #107636

Merged
Leon Schittek merged 2 commits from merotosc/blender:bugfix/missing_nodelink_segment into main 2023-05-12 20:35:30 +02:00
1 changed files with 9 additions and 3 deletions
Showing only changes of commit 3e9e68cb59 - Show all commits

View File

@ -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

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:

  /* Tangent space at t. If the inner and outer control points overlap, the tangent is invalid.
   * Use the vector between the sockets instead. */
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: ``` /* Tangent space at t. If the inner and outer control points overlap, the tangent is invalid. * Use the vector between the sockets instead. */ ```
* is used as tangent. */
if (is_zero(tangent)) {

I think this is a good place to use the ternary operator:

 tangent = is_zero(tangent) ? normalize(P3 - P0) : normalize(tangent);
I think this is a good place to use the ternary operator: ``` tangent = is_zero(tangent) ? normalize(P3 - P0) : normalize(tangent); ```

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 */