I created a minimum repro example to demo the issue:
I am attempting to calculate the distance squared between to vmath.vec3 points and it’s returning an extremely large value. EDIT: Removed WolframAlpha link since I put in the wrong points after creating the repro =X
vmath.length_sqr takes only one argument and returns the square of the length of that argument. The argument may be a vector or a quaternion. You are passing a pair of vectors instead…
If I understand correctly what you are trying to do, you should pass the difference of the two vectors to length_sqr.
I may guess that in your code you are just computing the squared length of the first argument.
Ah thank you, I’m surprised no error is generated in this case. However changing it to subtraction instead of two parameters is yielding 537.03527832031. This is still pretty far away from 55^2 which is 3025… I’m probably just sleep deprived
We generally don’t do defensive programming.
Each little extra check that gets added will cost everyone some precious bytes/kilobytes, and it all adds up in the end.
I see, thanks I was thinking that might be the case. However, is this compile times we’re speaking of? If not, couldn’t the compiler check and then disregard the arguments after some validation?
If you mean a linter, that would make a lot of sense, yes. We’ve talked about it before, but haven’t added something built in for that.
You can probably use the save hook in the editor scripting to perform linting on your code. Not sure if anyone already has implemented that.