Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Polygon shader #654

Merged
merged 1 commit into from
Dec 12, 2023
Merged

Conversation

JPonte
Copy link
Contributor

@JPonte JPonte commented Dec 12, 2023

#536

The i and j vars are being initialized outside of the loop and then immediatly at the start of every loop, which means that the initial values are actually never used.

@davesmith00000
Copy link
Member

Any chance of a screenshot? 😄

val e = v(j) - v(i)
val w = p - v(i)
val b = w - e * clamp(dot(w, e) / dot(e, e), 0.0f, 1.0f)
d = min(d, dot(b, b))
val c = bvec3(p.y >= v(i).y, p.y < v(j).y, e.x * w.y > e.y * w.x)
if (all(c) || all(not(c))) s = s * -1.0f
j = i
i = i + 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that makes sense. I can see why I did that but it's also clearly wrong in hindsight. 🤦 😄

@JPonte
Copy link
Contributor Author

JPonte commented Dec 12, 2023

Using this batch of Points:

val vertices = Batch(
  Point(32, 0),
  Point(32, 32),
  Point(0, 32)
)

Before:
Screenshot 2023-12-12 221825

After:
Screenshot 2023-12-12 221741

Copy link
Member

@davesmith00000 davesmith00000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Many thanks! 🙏

@davesmith00000 davesmith00000 merged commit cd3bb6e into PurpleKingdomGames:main Dec 12, 2023
1 check passed
@JPonte JPonte deleted the issue-536 branch December 14, 2023 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants