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

Increase precision of dot bounds check in EGP:DrawPath #3184

Merged
merged 3 commits into from
Nov 20, 2024

Conversation

Denneisk
Copy link
Member

Fixes a bug with EGP CircleOutlines where the dot product could be >0.999 and <=1, causing the function to skip calculating every segment but the last.

As far as I can tell, having these so imprecise isn't actually necessary.

@Denneisk Denneisk changed the title Increase precision of dot bounds check Increase precision of dot bounds check in EGP:DrawPath Nov 19, 2024
Copy link
Contributor

@thegrb93 thegrb93 left a comment

Choose a reason for hiding this comment

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

Can you change the comparators to >= and <=? Also move the local scaling calculation?

if dot >= 1 then
    ...
elseif dot <= -1 then
    ...
else
    local scaling = size*math.tan(math.acos(dot)/2)
    if dir.x*-lastdir.y + dir.y*lastdir.x > 0 then
        ...
    else
        ...
    end
end

Minor optimization
@Denneisk
Copy link
Member Author

The function works fine at +/-1 but I'll oblige in case there's some weird precision issue.

@thegrb93
Copy link
Contributor

The function works fine at +/-1 but I'll oblige in case there's some weird precision issue.

It's supposed to take the simpler branch though as an optimization.

@thegrb93 thegrb93 merged commit 6476d29 into wiremod:master Nov 20, 2024
1 check failed
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