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

Vector cleanups #2895

Merged
merged 2 commits into from
Nov 27, 2023
Merged

Vector cleanups #2895

merged 2 commits into from
Nov 27, 2023

Conversation

Denneisk
Copy link
Member

@Denneisk Denneisk commented Nov 23, 2023

  • Added lerp(vector, vector, number)
  • Optimized min and max to use square magnitude instead
  • Optimized vector:toAngle
  • Changed randVec to use Vector.Random
  • Changed parameter names on mix to be more descriptive
  • Changed mix to use LerpVector
  • Changed ANGLE_ZERO constant to use preexisting angle_zero constant
  • Remove temporary bezier fix

Fixes #2893

Copy link
Contributor

@Vurv78 Vurv78 left a comment

Choose a reason for hiding this comment

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

lgtm, was gonna say maybe lerp(nvv) to match gmod's function but looks like unity, godot and unreal do lerp(from, to, frac) so better to imitate that.

lua/entities/gmod_wire_expression2/core/vector.lua Outdated Show resolved Hide resolved
Comment on lines +417 to +422
e2function vector min(vector vec1, vector vec2)
return vec1:LengthSqr() < vec2:LengthSqr() and vec1 or vec2
end

e2function vector max(vector rv1, vector rv2)
local length1 = ( rv1[1] * rv1[1] + rv1[2] * rv1[2] + rv1[3] * rv1[3] ) ^ 0.5
local length2 = ( rv2[1] * rv2[1] + rv2[2] * rv2[2] + rv2[3] * rv2[3] ) ^ 0.5
if length1 > length2 then return rv1 else return rv2 end
e2function vector max(vector vec1, vector vec2)
return vec1:LengthSqr() > vec2:LengthSqr() and vec1 or vec2
Copy link
Contributor

Choose a reason for hiding this comment

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

These functions are really stupid. Why don't they max/min the components? Is there a different function that does that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, maxVec declared right below this

Copy link
Contributor

Choose a reason for hiding this comment

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

Why would you even need that?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could see uses for both.

@thegrb93 thegrb93 merged commit 0643eab into wiremod:master Nov 27, 2023
1 check passed
@InfHorus

This comment was marked as resolved.

@Vurv78
Copy link
Contributor

Vurv78 commented Dec 1, 2023

congratulation, you successfully broke the bezier function.

Quit bitching, your server is 3 months outdated. (I do appreciate you at least doing this on github, though)

@Denneisk Denneisk deleted the lerp branch November 8, 2024 18:17
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.

4 participants