Fix gizmo line width issue when using perspective (#9067)

# Objective

- In bevy_polyline, we discovered an issue that happens when line width
is smaller than 1.0 and using perspective. It would sometimes end up
negative or NaN. I'm not entirely sure _why_ it happens.

## Solution

- Make sure the width doesn't go below 0 before multiplying it with the
alpha

# Notes 

Here's a link to the bevy_polyline issue
https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline/issues/46

I'm not sure if the solution is correct but it solved the issue in my
testing.

Co-authored-by: François <mockersf@gmail.com>
This commit is contained in:
IceSentry 2023-07-31 14:57:59 -04:00 committed by GitHub
parent cbe13f3aa5
commit 0d7e81ee81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,7 +64,7 @@ fn vertex(vertex: VertexInput) -> VertexOutput {
#endif
// Line thinness fade from https://acegikmo.com/shapes/docs/#anti-aliasing
if line_width < 1. {
if line_width > 0.0 && line_width < 1. {
color.a *= line_width;
line_width = 1.;
}